Displaying differences for changeset
 
display as  

src/java/m/wqm/nutrientslpsrp/V1_0.java

@@ -50,46 +50,58 @@
 
     @Override
     // reading the inputs from the json file into input object and placing it in the arraylist
-    protected void preProcess() throws Exception {        
+    protected void preProcess(){        
         this.Service = null;
         
         JSONArray request = getRequest().optJSONArray("parameter");
         
-        if ( JSONUtils.checkKeyExistsB( JSONUtils.preprocess(request), "AoAId") && JSONUtils.checkKeyExistsB( JSONUtils.preprocess(request), "aoa_geometry") ){
-            aoa_id = getStringParam("AoAId");
-            aoa_comp_drained = getBooleanParam("aoa_comp_drained");
-            //Get the entire aoa_geometry group as it matches the input payload exactly for WQM-2
-            aoaGeometry = getJSONParam("aoa_geometry");
-            this.is_5_6_Only = false;
-        }
-        else
-            if ( JSONUtils.checkKeyExistsB( JSONUtils.preprocess(request), "soilcomponents") ){
-                //  If this key exists then we have it at the top level by design, so keep the object as the payload
-                aoa_id = getStringParam("AoAId");
-                this.soilComponents = request;
-                this.is_5_6_Only = true;
-            }
-            else{
-                //  No valid input stream for this service
-                this.error_msg = "No valid input parameters found .";
-            }      
+    try{
+        if ( JSONUtils.checkKeyExistsB( JSONUtils.preprocess(request), "AoAId") && JSONUtils.checkKeyExistsB( JSONUtils.preprocess(request), "aoa_geometry") ){
+        aoa_id = getStringParam("AoAId");
+        aoa_comp_drained = getBooleanParam("aoa_comp_drained");
+        //Get the entire aoa_geometry group as it matches the input payload exactly for WQM-2
+        aoaGeometry = getJSONParam("aoa_geometry");
+        this.is_5_6_Only = false;
+        }
+        else
+        if ( JSONUtils.checkKeyExistsB( JSONUtils.preprocess(request), "soilcomponents") ){
+            //  If this key exists then we have it at the top level by design, so keep the object as the payload
+            aoa_id = getStringParam("AoAId");
+            this.soilComponents = request;
+            this.is_5_6_Only = true;
+        }
+        else{
+            //  No valid input stream for this service
+            this.error_msg = "No valid input parameters found .";
+        }      
+    }
+    catch( Exception ex ){
+        this.error_msg = "Error reading JSON request: " + ex.getMessage();
+    }
     }
 
     @Override
-    protected String process() throws Exception {
-        //  Call WQM-2 processing member functions, then apply results to WQM-5() and WQM-6() objects inputs        
-        if ( this.is_5_6_Only ){
-            //This is just a 5/6 combined request
-            Service = new wqm_21( this.soilComponents );           
-        }
-        else{
-            //This is a full combined request 2/5/6
-            Service = new wqm_21( this.aoa_id, this.aoa_comp_drained, this.aoaGeometry);
-        }
-        
-        if ( !Service.process() ){
-            this.error_msg += " " + Service.getErrorMsg();
-        }
+    protected String process(){
+    if ( this.error_msg.isEmpty() ){
+        try{
+        //  Call WQM-2 processing member functions, then apply results to WQM-5() and WQM-6() objects inputs        
+        if ( this.is_5_6_Only ){
+            //This is just a 5/6 combined request
+            Service = new wqm_21( this.soilComponents );           
+        }
+        else{
+            //This is a full combined request 2/5/6
+            Service = new wqm_21( this.aoa_id, this.aoa_comp_drained, this.aoaGeometry);
+        }
+
+        if ( !Service.process() ){
+            this.error_msg += " " + Service.getErrorMsg();
+        }
+        }
+        catch( Exception ex ){
+        this.error_msg += "Error processing this request: " + ex.getMessage();
+        }
+    }
         
         return ( this.error_msg.isEmpty()? EXEC_OK : this.error_msg );
     }