Implemented: Add a isValid() method to the ModelService class
(OFBIZ-9158)

Improves after a discussion with Scott and Taher on dev ML

Improved to be called only with IN params, the JavaDoc is also improved to 
reflect the changes



git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1776447 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/service/src/main/java/org/apache/ofbiz/service/ModelService.java b/framework/service/src/main/java/org/apache/ofbiz/service/ModelService.java
index f2156ff..fd02d8c 100644
--- a/framework/service/src/main/java/org/apache/ofbiz/service/ModelService.java
+++ b/framework/service/src/main/java/org/apache/ofbiz/service/ModelService.java
@@ -600,25 +600,15 @@
     }
 
     /**
-     * Validates a Map against the IN or OUT parameter information
-     * Same than validate() with same signature but returns a boolean instead of exceptions
-     * @param context the context
-     * @param mode Test either mode IN or mode OUT
+     * Check a Map against the IN parameter information, uses the validate() method for that
+     * Always called with only IN_PARAM, so to be called before the service is called with the passed context
+     * @param context the passed context
      * @param locale the actual locale to use
+     * @return boolean True is the service called with these IN_PARAM is valid
      */
-    public boolean isValid(Map<String, Object> context, String mode, Locale locale) { 
-        boolean verboseOn = Debug.verboseOn();
-        if (verboseOn) Debug.logVerbose("[ModelService.validate] : {" + this.name + "} : Validating context - " + context, module);
-
-        // do not validate results with errors
-        if (mode.equals(OUT_PARAM) && context != null && context.containsKey(RESPONSE_MESSAGE)) {
-            if (RESPOND_ERROR.equals(context.get(RESPONSE_MESSAGE)) || RESPOND_FAIL.equals(context.get(RESPONSE_MESSAGE))) {
-                if (verboseOn) Debug.logVerbose("[ModelService.validate] : {" + this.name + "} : response was an error, not validating.", module);
-                return false;
-            }
-        }
+    public boolean isValid(Map<String, Object> context, Locale locale) {
         try {
-            validate(context, mode, locale);
+            validate(context, IN_PARAM, locale);
         } catch (ServiceValidationException e) {
             return false;
         }