Hi isomorphic, i'm trying to perform a remove operation via Rest but when the RestHandler process the request it drops all not primaryKey criteria/values.
SC Version:
v110p_2016-12-19
This is my JSON Request:
In the dataSource I overwrited the remove operation to pass through a DMI in which i expect the entire record sent inside the JSON request, but when i perform this call, after that the RestHandler process the request to construct the dsRequest if i watch inside the criteria (dsRequest.getCriteria()) or values (dsRequest.getValues()) there is only the PrimaryKey value, in this case the "shortName" value. other values have been removed.
I've also tried to add "allowMultiUpdate" or "providesMissingKeys" on the operationBinding but i obtain the same result.
My RestHandler
My DataSource:
my DMI
SC Version:
v110p_2016-12-19
This is my JSON Request:
Code:
{ "data": { "uid": null, "mail": "test@mail.com", "commonName": "test", "nome": "test", "gruppi": "gruppo_test", "shortName":"Primary key value", "cognome": "test", "NOME_GRUPPO": "ROLE_GRUPPO_TEST" }, "dataSource": "TEST_REMOVE", "operationType": "remove" }
I've also tried to add "allowMultiUpdate" or "providesMissingKeys" on the operationBinding but i obtain the same result.
My RestHandler
Code:
package it.test.rest; import com.isomorphic.datasource.DSRequest; import com.isomorphic.datasource.DSResponse; import com.isomorphic.log.Logger; import com.isomorphic.rpc.RPCManager; import com.isomorphic.servlet.RESTHandler; import com.isomorphic.servlet.RequestContext; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; public class RestService extends RESTHandler { private Logger log = new Logger(RestService.class.getName()); @Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { log.debug("entra in doPost"); super.doPost(request, response); } @Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { log.debug("entra in doGet"); super.doGet(request, response); } @Override public void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { log.debug("entra in processRequest, metodo = " + request.getMethod()); super.processRequest(request, response); } @Override public DSResponse handleDSRequest(DSRequest dsRequest, RPCManager rpc, RequestContext context) throws Exception { try { HttpServletRequest httpServletRequest = dsRequest.getHttpServletRequest(); log.debug("Richiesta REST, method: " + httpServletRequest.getMethod() + ", dataSource = " + dsRequest.getDataSourceName() + ", operationType: " + dsRequest.getOperationType()); DSResponse dsResponse = super.handleDSRequest(dsRequest, rpc, context); return dsResponse; } catch (Exception e) { log.error("Eccezione", e); throw e; } } }
My DataSource:
Code:
<DataSource xmlns="http://www.smartclient.com/schema" ID="TEST_REMOVE" dropExtraFields="false" serverType="generic"> <fields> <field name="shortName" type="text" primaryKey="true"/> <field name="uid" type="text"/> <field name="commonName" type="text"/> <field name="name" type="text"/> <field name="surname" type="text"/> <field name="mail" type="text"/> <field name="groups" type="text"/> </fields> <operationBindings> <operationBinding operationType="remove"> <serverObject lookupStyle="new" className="it.test.DMI.TestRemoveDMI"/> </operationBinding> </operationBindings> </DataSource>
my DMI
Code:
package it.test.DMI; import com.isomorphic.datasource.DSRequest; import com.isomorphic.datasource.DSResponse; import com.isomorphic.rpc.RPCManager; import javax.servlet.http.HttpServletRequest; import java.util.*; public class TestRemoveDMI { public DSResponse fetch(DSRequest dsRequest, HttpServletRequest request, RPCManager rpcManager) { DSResponse dsResponse = new DSResponse(); dsResponse.setData(new ArrayList<>()); return dsResponse; } public DSResponse remove(DSRequest dsRequest, HttpServletRequest request, RPCManager rpcManager) throws Exception { DSResponse dsResponse = new DSResponse(); Map criteriaTemp = dsRequest.getValues(); if(criteriaTemp.get("mail") == null){ dsResponse.setFailure("mail parameter cannot be null"); } else { dsResponse.setSuccess(); } return dsResponse; } }
Comment