Hi Isomorphic,
I'm using latest 5.1p and a .ds.xml file for my BatchUpload that has validators defined like this:
.ds.xml excerpt:
Please note the $errorMessage with no further text. This is to localize the error message within the validator.
For this I need to know the user's browser language, which I get from the HttpServletRequest:
ValidatorContactDetailsRequiredIf.java
This should be pretty basic and worked before (DMI with additional parameter "HttpServletRequest httpServletRequest"), but I don't know until when.
Now, if I try to import data I get this message in the server log:
Server log:
It seems the framework has difficulties to provide the HttpServletRequest, but this has worked before. Could you please check if there are recent (last 2-3 month) changes in this area?
Thank you & Best regards
Blama
I'm using latest 5.1p and a .ds.xml file for my BatchUpload that has validators defined like this:
.ds.xml excerpt:
Code:
<field name="CUST_SOURCEUID" uploadFieldName="Kunden-ID" length="50" type="text" escapeHTML="true"> <title><fmt:message key="customerIDSource" /></title> <validators> <validator type="serverCustom"> <serverObject lookupStyle="new" className="com.lmscompany.lms.server.worker.validator.ValidatorContactDetailsRequiredIf" /> <errorMessage>$errorMessage</errorMessage> </validator> </validators> </field>
For this I need to know the user's browser language, which I get from the HttpServletRequest:
ValidatorContactDetailsRequiredIf.java
Code:
package com.lmscompany.lms.server.worker.validator; import java.util.ArrayList; import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletRequest; import com.isomorphic.datasource.DataSource; import com.isomorphic.datasource.Validator; import com.isomorphic.log.Logger; import com.lmscompany.lms.server.i18n.I18n; import com.lmscompany.lms.server.worker.T_USER; import com.lmscompany.lms.shared.type.DatasourceFieldEnum; public class ValidatorContactDetailsRequiredIf { Logger log = new Logger(ValidatorContactDetailsRequiredIf.class.getName()); public boolean condition(Object value, Validator validator, String fieldName, Map<Object, Object> record, DataSource ds, HttpServletRequest httpServletRequest) { log.info("Validating for field \"" + fieldName + "\", value \"" + (value == null ? "" : value.toString()) + "\""); if (value == null) return true; else { List<String> missingFields = new ArrayList<String>(); if (record.get(DatasourceFieldEnum.V_LEAD_CURRENT__CUST_NAME.getValue()) == null) missingFields.add(I18n.getDSXMLString("companyName", httpServletRequest)); if (record.get(DatasourceFieldEnum.V_LEAD_CURRENT__CUST_CONTACTPERS_GENDER_SN.getValue()) == null) missingFields.add(I18n.getDSXMLString("salutation", httpServletRequest)); if (record.get(DatasourceFieldEnum.V_LEAD_CURRENT__CUST_CONTACTPERS_SURNAME.getValue()) == null) missingFields.add(I18n.getDSXMLString("surname", httpServletRequest)); if (record.get(DatasourceFieldEnum.V_LEAD_CURRENT__CUST_ADDRESS_STREET.getValue()) == null) missingFields.add(I18n.getDSXMLString("street", httpServletRequest)); if (record.get(DatasourceFieldEnum.V_LEAD_CURRENT__CUST_ADDRESS_ZIPCODE.getValue()) == null) missingFields.add(I18n.getDSXMLString("zipCode", httpServletRequest)); if (record.get(DatasourceFieldEnum.V_LEAD_CURRENT__CUST_ADDRESS_CITY.getValue()) == null) missingFields.add(I18n.getDSXMLString("city", httpServletRequest)); if (record.get(DatasourceFieldEnum.V_LEAD_CURRENT__CUST_ADDRESS_COUNTRY_ID.getValue()) == null) missingFields.add(I18n.getDSXMLString("country", httpServletRequest)); if (missingFields.isEmpty()) return true; else { if (missingFields.size() == 1) validator.addErrorMessageVariable("errorMessage", String.format(I18n.getString("alsoEnterOtherField", httpServletRequest), T_USER.join(missingFields, ", "))); else validator.addErrorMessageVariable("errorMessage", String.format(I18n.getString("alsoEnterOtherFields", httpServletRequest), T_USER.join(missingFields, ", "))); return false; } } } }
Now, if I try to import data I get this message in the server log:
Server log:
Code:
[B]=== 2016-02-17 23:46:29,818 [ec-5] WARN DefaultValidators - Validator DMI invocation threw exception: java.lang.Exception: Unable to assign a required or optional argument to slot #6 taking type: javax.servlet.http.HttpServletRequest of method:[/B] public boolean com.lmscompany.lms.server.worker.validator.ValidatorContactDetailsRequiredIf.condition(java.lang.Object,com.isomorphic.datasource.Validator,java.lang.String,java.util.Map,com.isomorphic.datasource.DataSource,javax.servlet.http.HttpServletRequest) No remaining optional arguments match this type and all required arguments passed by the client have already been assigned. at com.isomorphic.base.Reflection.adaptArgsAndInvoke(Reflection.java:955) at com.isomorphic.base.Reflection.adaptArgsAndInvoke(Reflection.java:794) at com.isomorphic.util.DefaultValidators$serverCustom.callServerObject(DefaultValidators.java:1472) at com.isomorphic.util.DefaultValidators$serverCustom.validate(DefaultValidators.java:1383) at com.isomorphic.util.DefaultValidators.processValidator(DefaultValidators.java:292) at com.isomorphic.util.DefaultValidators.validateField(DefaultValidators.java:250) at com.isomorphic.datasource.SimpleType.validateValue(SimpleType.java:97) at com.isomorphic.datasource.SimpleType.create(SimpleType.java:73) at com.isomorphic.datasource.BasicDataSource.validateFieldValue(BasicDataSource.java:2088) at com.isomorphic.datasource.BasicDataSource.validateFieldValue(BasicDataSource.java:2003) at com.isomorphic.datasource.BasicDataSource.toRecord(BasicDataSource.java:1367) at com.isomorphic.datasource.BasicDataSource.toRecords(BasicDataSource.java:1279) at com.isomorphic.datasource.DataSource.validate(DataSource.java:3521) at com.isomorphic.tools.DataImport.importAndValidateDSRows(DataImport.java:410) at com.isomorphic.tools.DataImport.importAndValidateDSRows(DataImport.java:343) at com.isomorphic.tools.BatchUpload.internalBatchUpload(BatchUpload.java:148) at com.isomorphic.tools.BatchUpload.batchUpload(BatchUpload.java:88) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.isomorphic.base.Reflection.adaptArgsAndInvoke(Reflection.java:964) at com.isomorphic.datasource.DataSourceDMI.execute(DataSourceDMI.java:416) at com.isomorphic.datasource.DataSourceDMI.execute(DataSourceDMI.java:64) at com.isomorphic.datasource.DSRequest.execute(DSRequest.java:2690) at com.isomorphic.servlet.IDACall.handleDSRequest(IDACall.java:228) at com.lmscompany.lms.server.LMSIDACall.handleDSRequest(LMSIDACall.java:87) at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:187) at com.lmscompany.lms.server.LMSIDACall.processRequest(LMSIDACall.java:43) at com.isomorphic.servlet.IDACall._processRequest(IDACall.java:119) at com.isomorphic.servlet.IDACall.doPost(IDACall.java:79) at javax.servlet.http.HttpServlet.service(HttpServlet.java:648) at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:162) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.isomorphic.servlet.CompressionFilter._doFilter(CompressionFilter.java:260) at com.isomorphic.servlet.BaseFilter.doFilter(BaseFilter.java:88) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:614) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:521) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1096) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:674) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Unknown Source) com.isomorphic.util.ValidatorException: Validator DMI invocation threw exception: java.lang.Exception with error: Unable to assign a required or optional argument to slot #6 taking type: javax.servlet.http.HttpServletRequest of method: public boolean com.lmscompany.lms.server.worker.validator.ValidatorContactDetailsRequiredIf.condition(java.lang.Object,com.isomorphic.datasource.Validator,java.lang.String,java.util.Map,com.isomorphic.datasource.DataSource,javax.servlet.http.HttpServletRequest) No remaining optional arguments match this type and all required arguments passed by the client have already been assigned. at com.isomorphic.util.DefaultValidators$serverCustom.callServerObject(DefaultValidators.java:1481) at com.isomorphic.util.DefaultValidators$serverCustom.validate(DefaultValidators.java:1383) at com.isomorphic.util.DefaultValidators.processValidator(DefaultValidators.java:292) at com.isomorphic.util.DefaultValidators.validateField(DefaultValidators.java:250) at com.isomorphic.datasource.SimpleType.validateValue(SimpleType.java:97) at com.isomorphic.datasource.SimpleType.create(SimpleType.java:73) at com.isomorphic.datasource.BasicDataSource.validateFieldValue(BasicDataSource.java:2088) at com.isomorphic.datasource.BasicDataSource.validateFieldValue(BasicDataSource.java:2003) at com.isomorphic.datasource.BasicDataSource.toRecord(BasicDataSource.java:1367) at com.isomorphic.datasource.BasicDataSource.toRecords(BasicDataSource.java:1279) at com.isomorphic.datasource.DataSource.validate(DataSource.java:3521) at com.isomorphic.tools.DataImport.importAndValidateDSRows(DataImport.java:410) at com.isomorphic.tools.DataImport.importAndValidateDSRows(DataImport.java:343) at com.isomorphic.tools.BatchUpload.internalBatchUpload(BatchUpload.java:148) at com.isomorphic.tools.BatchUpload.batchUpload(BatchUpload.java:88) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.isomorphic.base.Reflection.adaptArgsAndInvoke(Reflection.java:964) at com.isomorphic.datasource.DataSourceDMI.execute(DataSourceDMI.java:416) at com.isomorphic.datasource.DataSourceDMI.execute(DataSourceDMI.java:64) at com.isomorphic.datasource.DSRequest.execute(DSRequest.java:2690) at com.isomorphic.servlet.IDACall.handleDSRequest(IDACall.java:228) at com.lmscompany.lms.server.LMSIDACall.handleDSRequest(LMSIDACall.java:87) at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:187) at com.lmscompany.lms.server.LMSIDACall.processRequest(LMSIDACall.java:43) at com.isomorphic.servlet.IDACall._processRequest(IDACall.java:119) at com.isomorphic.servlet.IDACall.doPost(IDACall.java:79) at javax.servlet.http.HttpServlet.service(HttpServlet.java:648) at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:162) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.isomorphic.servlet.CompressionFilter._doFilter(CompressionFilter.java:260) at com.isomorphic.servlet.BaseFilter.doFilter(BaseFilter.java:88) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:614) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:521) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1096) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:674) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Unknown Source) === 2016-02-17 23:46:29,820 [ec-5] DEBUG BatchUpload - Rows: [ ] === 2016-02-17 23:46:29,820 [ec-5] DEBUG BatchUpload - Errors: [ ] === 2016-02-17 23:46:29,821 [ec-5] DEBUG BatchUpload - Errors after conversion: [ "Validator DMI invocation threw exception: java.lang.Exception with error: Unable to assign a required or optional argument to slot #6 taking type: javax.servlet.http.HttpServletRequest of method:\n\npublic boolean com.lmscompany.lms.server.worker.validator.ValidatorContactDetailsRequiredIf.condition(java.lang.Object,com.isomorphic.datasource.Validator,java.lang.String,java.util.Map,com.isomorphic.datasource.DataSource,javax.servlet.http.HttpServletRequest)\n\nNo remaining optional arguments match this type and all required arguments passed by the client have already been assigned.\n\n\n\nSee the log for more details about this error." ] === 2016-02-17 23:46:29,821 [ec-5] INFO DSResponse - DSResponse: Map with 3 keys === 2016-02-17 23:46:29,821 [ec-5] DEBUG RPCManager - Content type for RPC transaction: text/html; charset=UTF-8 === 2016-02-17 23:46:29,821 [ec-5] DEBUG RPCManager - DMI response, dropExtraFields: false === 2016-02-17 23:46:29,822 [ec-5] INFO Compression - /lms/lms/sc/IDACall: 1360 -> 769 bytes
Thank you & Best regards
Blama
Comment