svn commit: r1801267 - in /ofbiz/ofbiz-framework/trunk/framework: service/src/main/java/org/apache/ofbiz/service/ service/src/main/java/org/apache/ofbiz/service/engine/ webapp/src/main/java/org/apache/ofbiz/webapp/event/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1801267 - in /ofbiz/ofbiz-framework/trunk/framework: service/src/main/java/org/apache/ofbiz/service/ service/src/main/java/org/apache/ofbiz/service/engine/ webapp/src/main/java/org/apache/ofbiz/webapp/event/

Deepak Dixit-5
Author: deepak
Date: Sat Jul  8 09:01:37 2017
New Revision: 1801267

URL: http://svn.apache.org/viewvc?rev=1801267&view=rev
Log:
Improved: Added new constraints for INOUT modelservice param, Also updated remaining occurrences for hardcoded IN, OUT and INOUT model service param. (OFBIZ-9434)

Modified:
    ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/DispatchContext.java
    ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelParam.java
    ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelService.java
    ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelServiceReader.java
    ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/EntityAutoEngine.java
    ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/GroovyEngine.java
    ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/ScriptEngine.java
    ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/XMLRPCClientEngine.java
    ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/XmlRpcEventHandler.java

Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/DispatchContext.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/DispatchContext.java?rev=1801267&r1=1801266&r2=1801267&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/DispatchContext.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/DispatchContext.java Sat Jul  8 09:01:37 2017
@@ -175,9 +175,9 @@ public class DispatchContext implements
         Map<String, Object> newContext;
 
         int modeInt = 0;
-        if (mode.equalsIgnoreCase("in")) {
+        if (mode.equalsIgnoreCase(ModelService.IN_PARAM)) {
             modeInt = 1;
-        } else if (mode.equalsIgnoreCase("out")) {
+        } else if (mode.equalsIgnoreCase(ModelService.OUT_PARAM)) {
             modeInt = 2;
         }
 

Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelParam.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelParam.java?rev=1801267&r1=1801266&r2=1801267&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelParam.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelParam.java Sat Jul  8 09:01:37 2017
@@ -166,11 +166,11 @@ public class ModelParam implements Seria
     }
 
     public boolean isIn() {
-        return "IN".equals(this.mode) || "INOUT".equals(this.mode);
+        return ModelService.IN_PARAM.equals(this.mode) || ModelService.IN_OUT_PARAM.equals(this.mode);
     }
 
     public boolean isOut() {
-        return "OUT".equals(this.mode) || "INOUT".equals(this.mode);
+        return ModelService.OUT_PARAM.equals(this.mode) || ModelService.IN_OUT_PARAM.equals(this.mode);
     }
 
     public boolean isOptional() {

Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelService.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelService.java?rev=1801267&r1=1801266&r2=1801267&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelService.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelService.java Sat Jul  8 09:01:37 2017
@@ -97,6 +97,7 @@ public class ModelService extends Abstra
     public static final String TNS = "http://ofbiz.apache.org/service/";
     public static final String OUT_PARAM = "OUT";
     public static final String IN_PARAM = "IN";
+    public static final String IN_OUT_PARAM = "INOUT";
 
     public static final String RESPONSE_MESSAGE = "responseMessage";
     public static final String RESPOND_SUCCESS = "success";
@@ -478,7 +479,7 @@ public class ModelService extends Abstra
         List<ModelParam> params = this.getModelParamList();
         if (params != null) {
             for (ModelParam param: params) {
-                if ("INOUT".equals(param.mode) || mode.equals(param.mode)) {
+                if (IN_OUT_PARAM.equals(param.mode) || mode.equals(param.mode)) {
                     Object defaultValueObj = param.getDefaultValue();
                     if (defaultValueObj != null && context.get(param.name) == null) {
                         context.put(param.name, defaultValueObj);
@@ -513,7 +514,7 @@ public class ModelService extends Abstra
         // get the info values
         for (ModelParam modelParam: this.contextParamList) {
             // Debug.logInfo("In ModelService.validate preparing parameter [" + modelParam.name + (modelParam.optional?"(optional):":"(required):") + modelParam.mode + "] for service [" + this.name + "]", module);
-            if ("INOUT".equals(modelParam.mode) || mode.equals(modelParam.mode)) {
+            if (IN_OUT_PARAM.equals(modelParam.mode) || mode.equals(modelParam.mode)) {
                 if (modelParam.optional) {
                     optionalInfo.put(modelParam.name, modelParam.type);
                 } else {
@@ -583,12 +584,12 @@ public class ModelService extends Abstra
         }
 
         // required and type validation complete, do allow-html validation
-        if ("IN".equals(mode)) {
+        if (IN_PARAM.equals(mode)) {
             List<String> errorMessageList = new LinkedList<String>();
             for (ModelParam modelParam : this.contextInfo.values()) {
                 // the param is a String, allow-html is not any, and we are looking at an IN parameter during input parameter validation
                 if (context.get(modelParam.name) != null && ("String".equals(modelParam.type) || "java.lang.String".equals(modelParam.type))
-                        && !"any".equals(modelParam.allowHtml) && ("INOUT".equals(modelParam.mode) || "IN".equals(modelParam.mode))) {
+                        && !"any".equals(modelParam.allowHtml) && (IN_OUT_PARAM.equals(modelParam.mode) || IN_PARAM.equals(modelParam.mode))) {
                     String value = (String) context.get(modelParam.name);
                     UtilCodec.checkStringForHtmlStrictNone(modelParam.name, value, errorMessageList);
                 }
@@ -799,14 +800,14 @@ public class ModelService extends Abstra
     public List<String> getParameterNames(String mode, boolean optional, boolean internal) {
         List<String> names = new LinkedList<String>();
 
-        if (!"IN".equals(mode) && !"OUT".equals(mode) && !"INOUT".equals(mode)) {
+        if (!IN_PARAM.equals(mode) && !OUT_PARAM.equals(mode) && !IN_OUT_PARAM.equals(mode)) {
             return names;
         }
         if (contextInfo.size() == 0) {
             return names;
         }
         for (ModelParam param: contextParamList) {
-            if (param.mode.equals("INOUT") || param.mode.equals(mode)) {
+            if (param.mode.equals(IN_OUT_PARAM) || param.mode.equals(mode)) {
                 if (optional || !param.optional) {
                     if (internal || !param.internal) {
                         names.add(param.name);
@@ -870,7 +871,7 @@ public class ModelService extends Abstra
         if (source == null) {
             return target;
         }
-        if (!"IN".equals(mode) && !"OUT".equals(mode) && !"INOUT".equals(mode)) {
+        if (!IN_PARAM.equals(mode) && !OUT_PARAM.equals(mode) && !IN_OUT_PARAM.equals(mode)) {
             return target;
         }
         if (contextInfo.size() == 0) {
@@ -900,7 +901,7 @@ public class ModelService extends Abstra
         for (ModelParam param: contextParamList) {
             //boolean internalParam = param.internal;
 
-            if (param.mode.equals("INOUT") || param.mode.equals(mode)) {
+            if (param.mode.equals(IN_OUT_PARAM) || param.mode.equals(mode)) {
                 String key = param.name;
 
                 // internal map of strings
@@ -988,7 +989,7 @@ public class ModelService extends Abstra
                 return result;
             }
             if (permission != null) {
-                Map<String, Object> ctx = permission.makeValid(context, ModelService.IN_PARAM);
+                Map<String, Object> ctx = permission.makeValid(context, IN_PARAM);
                 if (UtilValidate.isNotEmpty(this.permissionMainAction)) {
                     ctx.put("mainAction", this.permissionMainAction);
                 }
@@ -1075,7 +1076,7 @@ public class ModelService extends Abstra
         }
         for (ModelParam modelParam: this.contextParamList) {
             // don't include OUT parameters in this list, only IN and INOUT
-            if ("OUT".equals(modelParam.mode)) continue;
+            if (OUT_PARAM.equals(modelParam.mode)) continue;
 
             Object srcObject = source.get(modelParam.name);
             if (srcObject != null) {
@@ -1103,7 +1104,7 @@ public class ModelService extends Abstra
         List<ModelParam> inList = new LinkedList<ModelParam>();
         for (ModelParam modelParam: this.contextParamList) {
             // don't include OUT parameters in this list, only IN and INOUT
-            if ("OUT".equals(modelParam.mode)) continue;
+            if (OUT_PARAM.equals(modelParam.mode)) continue;
 
             inList.add(modelParam);
         }
@@ -1143,8 +1144,8 @@ public class ModelService extends Abstra
                             if (existingParam != null) {
                                 // if the existing param is not INOUT and the newParam.mode is different from existingParam.mode, make the existing param optional and INOUT
                                 // TODO: this is another case where having different optional/required settings for IN and OUT would be quite valuable...
-                                if (!"INOUT".equals(existingParam.mode) && !existingParam.mode.equals(newParam.mode)) {
-                                    existingParam.mode = "INOUT";
+                                if (!IN_OUT_PARAM.equals(existingParam.mode) && !existingParam.mode.equals(newParam.mode)) {
+                                    existingParam.mode = IN_OUT_PARAM;
                                     if (existingParam.optional || newParam.optional) {
                                         existingParam.optional = true;
                                     }

Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelServiceReader.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelServiceReader.java?rev=1801267&r1=1801266&r2=1801267&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelServiceReader.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelServiceReader.java Sat Jul  8 09:01:37 2017
@@ -543,7 +543,7 @@ public class ModelServiceReader implemen
         def = new ModelParam();
         def.name = ModelService.RESPONSE_MESSAGE;
         def.type = "String";
-        def.mode = "OUT";
+        def.mode = ModelService.OUT_PARAM;
         def.optional = true;
         def.internal = true;
         service.addParam(def);
@@ -551,7 +551,7 @@ public class ModelServiceReader implemen
         def = new ModelParam();
         def.name = ModelService.ERROR_MESSAGE;
         def.type = "String";
-        def.mode = "OUT";
+        def.mode = ModelService.OUT_PARAM;
         def.optional = true;
         def.internal = true;
         service.addParam(def);
@@ -559,7 +559,7 @@ public class ModelServiceReader implemen
         def = new ModelParam();
         def.name = ModelService.ERROR_MESSAGE_LIST;
         def.type = "java.util.List";
-        def.mode = "OUT";
+        def.mode = ModelService.OUT_PARAM;
         def.optional = true;
         def.internal = true;
         service.addParam(def);
@@ -567,7 +567,7 @@ public class ModelServiceReader implemen
         def = new ModelParam();
         def.name = ModelService.SUCCESS_MESSAGE;
         def.type = "String";
-        def.mode = "OUT";
+        def.mode = ModelService.OUT_PARAM;
         def.optional = true;
         def.internal = true;
         service.addParam(def);
@@ -575,7 +575,7 @@ public class ModelServiceReader implemen
         def = new ModelParam();
         def.name = ModelService.SUCCESS_MESSAGE_LIST;
         def.type = "java.util.List";
-        def.mode = "OUT";
+        def.mode = ModelService.OUT_PARAM;
         def.optional = true;
         def.internal = true;
         service.addParam(def);
@@ -583,7 +583,7 @@ public class ModelServiceReader implemen
         def = new ModelParam();
         def.name = "userLogin";
         def.type = "org.apache.ofbiz.entity.GenericValue";
-        def.mode = "INOUT";
+        def.mode = ModelService.IN_OUT_PARAM;
         def.optional = true;
         def.internal = true;
         service.addParam(def);
@@ -591,7 +591,7 @@ public class ModelServiceReader implemen
         def = new ModelParam();
         def.name = "login.username";
         def.type = "String";
-        def.mode = "IN";
+        def.mode = ModelService.IN_PARAM;
         def.optional = true;
         def.internal = true;
         service.addParam(def);
@@ -599,7 +599,7 @@ public class ModelServiceReader implemen
         def = new ModelParam();
         def.name = "login.password";
         def.type = "String";
-        def.mode = "IN";
+        def.mode = ModelService.IN_PARAM;
         def.optional = true;
         def.internal = true;
         service.addParam(def);
@@ -607,7 +607,7 @@ public class ModelServiceReader implemen
         def = new ModelParam();
         def.name = "locale";
         def.type = "java.util.Locale";
-        def.mode = "INOUT";
+        def.mode = ModelService.IN_OUT_PARAM;
         def.optional = true;
         def.internal = true;
         service.addParam(def);
@@ -615,7 +615,7 @@ public class ModelServiceReader implemen
         def = new ModelParam();
         def.name = "timeZone";
         def.type = "java.util.TimeZone";
-        def.mode = "INOUT";
+        def.mode = ModelService.IN_OUT_PARAM;
         def.optional = true;
         def.internal = true;
         service.addParam(def);

Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/EntityAutoEngine.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/EntityAutoEngine.java?rev=1801267&r1=1801266&r2=1801267&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/EntityAutoEngine.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/EntityAutoEngine.java Sat Jul  8 09:01:37 2017
@@ -135,7 +135,7 @@ public final class EntityAutoEngine exte
             GenericValue crudValue = (GenericValue) result.get("crudValue");
             if (crudValue != null) {
                 result.remove("crudValue");
-                result.putAll(modelService.makeValid(crudValue, "OUT"));
+                result.putAll(modelService.makeValid(crudValue, ModelService.OUT_PARAM));
             }
         } catch (GeneralException e) {
             Debug.logError(e, "Error doing entity-auto operation for entity [" + modelEntity.getEntityName() + "] in service [" + modelService.name + "]: " + e.toString(), module);

Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/GroovyEngine.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/GroovyEngine.java?rev=1801267&r1=1801266&r2=1801267&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/GroovyEngine.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/GroovyEngine.java Sat Jul  8 09:01:37 2017
@@ -116,7 +116,7 @@ public final class GroovyEngine extends
                 return cast(resultObj);
             }
             Map<String, Object> result = ServiceUtil.returnSuccess();
-            result.putAll(modelService.makeValid(scriptContext.getBindings(ScriptContext.ENGINE_SCOPE), "OUT"));
+            result.putAll(modelService.makeValid(scriptContext.getBindings(ScriptContext.ENGINE_SCOPE), ModelService.OUT_PARAM));
             return result;
         } catch (GeneralException ge) {
             throw new GenericServiceException(ge);

Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/ScriptEngine.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/ScriptEngine.java?rev=1801267&r1=1801266&r2=1801267&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/ScriptEngine.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/ScriptEngine.java Sat Jul  8 09:01:37 2017
@@ -90,7 +90,7 @@ public final class ScriptEngine extends
                 return cast(resultObj);
             }
             Map<String, Object> result = ServiceUtil.returnSuccess();
-            result.putAll(modelService.makeValid(scriptContext.getBindings(ScriptContext.ENGINE_SCOPE), "OUT"));
+            result.putAll(modelService.makeValid(scriptContext.getBindings(ScriptContext.ENGINE_SCOPE), ModelService.OUT_PARAM));
             return result;
         } catch (ScriptException se) {
             return ServiceUtil.returnError(se.getMessage());

Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/XMLRPCClientEngine.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/XMLRPCClientEngine.java?rev=1801267&r1=1801266&r2=1801267&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/XMLRPCClientEngine.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/XMLRPCClientEngine.java Sat Jul  8 09:01:37 2017
@@ -130,7 +130,7 @@ public class XMLRPCClientEngine extends
         Map<String, Object> params = new HashMap<String, Object>();
         for (ModelParam modelParam: modelService.getModelParamList()) {
             // don't include OUT parameters in this list, only IN and INOUT
-            if ("OUT".equals(modelParam.mode) || modelParam.internal) continue;
+            if (ModelService.OUT_PARAM.equals(modelParam.mode) || modelParam.internal) continue;
 
             Object paramValue = context.get(modelParam.name);
             if (paramValue != null) {

Modified: ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/XmlRpcEventHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/XmlRpcEventHandler.java?rev=1801267&r1=1801266&r2=1801267&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/XmlRpcEventHandler.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/XmlRpcEventHandler.java Sat Jul  8 09:01:37 2017
@@ -294,7 +294,7 @@ public class XmlRpcEventHandler extends
                 // more than one parameter; use list notation based on service def order
                 if (parameterCount > 1) {
                     int x = 0;
-                    for (String name: model.getParameterNames("IN", true, true)) {
+                    for (String name: model.getParameterNames(ModelService.IN_PARAM, true, true)) {
                         context.put(name, xmlRpcReq.getParameter(x));
                         x++;