Displaying differences for changeset
 
display as  

src/java/m/sci/V1_3.java

@@ -20,6 +20,10 @@
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
 import csip.ModelDataService;
+import static csip.ModelDataService.ERROR;
+import static csip.ModelDataService.FAILED;
+import static csip.ModelDataService.KEY_METAINFO;
+import static csip.ModelDataService.KEY_STATUS;
 import static util.ErosionConst.CONV_KGM2_TONACRE;
 import static util.ErosionConst.KEY_LENGTH;
 import static util.ErosionConst.KEY_MGMTS;
@@ -103,6 +107,8 @@
 
                 File[] dummy = new File[0]; // the client function should check for null array.
                 JSONObject syncRequest = JSONUtils.clone(getRequest());
+                String status;
+                String error;
                 if (JSONUtils.checkKeyExistsB(getParamMap(), KEY_LENGTH)
                         && JSONUtils.checkKeyExistsB(getParamMap(), KEY_STEEPNESS)) {
                     // do a r2 call >>>
@@ -125,6 +131,14 @@
                     JSONObject r2Response = new Client(LOG).doPOST("http://localhost:8080/csip-erosion/m/rusle2/1.3", syncRequest);
                     LOG.info("R2 Response "+ syncRequest);
 
+                    status = r2Response.getJSONObject(KEY_METAINFO).getString(KEY_STATUS);
+                    
+                    if(status.equals(FAILED)){
+                        error = r2Response.getJSONObject(KEY_METAINFO).getString(ERROR);
+                        return error;
+                    }
+                        
+                    
                     Map<String, JSONObject> r2Results = JSONUtils.preprocess(r2Response.getJSONArray(KEY_RESULT));
 
                     r2erosion = Double.parseDouble(r2Results.get(RES_SLOPE_DEGRAD).getString(VALUE));
@@ -165,8 +179,15 @@
 
                 //JSONObject wepsResponse = new Client(LOG).doPOST("http://localhost:8080/csip-erosion/m/weps/1.2", getRequest(), dummy);
                 JSONObject wepsResponse = new Client(LOG).doPOST("http://localhost:8080/csip-erosion/m/weps/1.3", syncRequest);
+                status = wepsResponse.getJSONObject(KEY_METAINFO).getString(KEY_STATUS);
                 
-
+                
+                if(status.equals(FAILED))
+                {
+                    error = wepsResponse.getJSONObject(KEY_METAINFO).getString(ERROR);
+                    return error;
+                }
+                
                 Map<String, JSONObject> wepsResults = JSONUtils.preprocess(wepsResponse.getJSONArray(KEY_RESULT));
 
                 double wepserosion = (Double.parseDouble(wepsResults.get(WEPS_RES_WIND_EROS).getString(VALUE)));

src/java/m/weps/V1_3.java

@@ -222,28 +222,35 @@
      */
     private void loadRequiredParameters() throws ServiceException {
         try {
+            LOG.info("SOIL_KEY");
             if (JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_SOIL)) {
                 soilkey = JSONUtils.getValue(getParamMap().get(WEPS_KEY_SOIL));
             }
+            LOG.info("SOIL_FILE");
             if (JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_SOIL_FILE)) {
                 soilfile = JSONUtils.getValue(getParamMap().get(WEPS_KEY_SOIL_FILE));
             }
+            LOG.info("SET_LAT");
             if (JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_LATITUDE)) {
                 wmr.setLat(JSONUtils.getValue(getParamMap().get(WEPS_KEY_LATITUDE)));
             }
+            LOG.info("SET_LONG");
             if (JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_LONGITUDE)) {
                 wmr.setLongitude(JSONUtils.getValue(getParamMap().get(WEPS_KEY_LONGITUDE)));
             }
+            LOG.info("SET_ELEVATION");
             if (JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_ELEVATION)) {
                 double elevationInM = Double.parseDouble(JSONUtils.getValue(getParamMap().get(WEPS_KEY_ELEVATION))) * CONV_FT_TO_M;
                 wmr.setElevation(String.valueOf(elevationInM));
             }
+            LOG.info("SET_LENGTH");
             if (JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_FIELD_LENGTH)) {
                 double fieldLengthInM = Double.parseDouble(JSONUtils.getValue(getParamMap().get(WEPS_KEY_FIELD_LENGTH))) * CONV_FT_TO_M;
                 if (fieldLengthInM <= 0)
                     appendMetainfoWarning(ErosionConst.WEPS_FIELD_LENGTH_IS_INVALID);
                 wmr.setSimYLen(String.valueOf(fieldLengthInM));
             }
+            LOG.info("WIDTH");
             if (JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_FIELD_WIDTH)) {
                 double fieldWidthInM = Double.parseDouble(JSONUtils.getValue(getParamMap().get(WEPS_KEY_FIELD_WIDTH))) * CONV_FT_TO_M;
                 if (fieldWidthInM <= 0)
@@ -251,10 +258,12 @@
                 
                 wmr.setSimXLen(String.valueOf(fieldWidthInM));
             }
+            LOG.info("EROSION_LOSS");
             if (JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_WATER_EROSION_LOSS)) {
                 double waterErosionLoss = Double.parseDouble(JSONUtils.getValue(getParamMap().get(WEPS_KEY_WATER_EROSION_LOSS))) * CONV_TONACRE_TO_KGM2;
                 wmr.setWaterErosionLoss(String.valueOf(waterErosionLoss));
             }
+            LOG.info("ORIENTATION");
             if (JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_FIELD_ORIENTATION)) {
                 double fieldOrient = Double.parseDouble(JSONUtils.getValue(getParamMap().get(WEPS_KEY_FIELD_ORIENTATION)));
                 wmr.setSimRegionAngle(String.valueOf(fieldOrient));