Skip to content

Commit

Permalink
oops we can have x,y be negative
Browse files Browse the repository at this point in the history
  • Loading branch information
naknomum committed Jan 15, 2025
1 parent 19ec3ab commit 5ec856b
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/main/java/org/ecocean/Annotation.java
Original file line number Diff line number Diff line change
Expand Up @@ -1383,20 +1383,28 @@ public static Object validateFieldValue(String fieldName, JSONObject data)
}
break;

case "x":
case "y":
case "width":
case "height":
// value must be > 0 (also will catch unset)
returnValue = data.optInt(fieldName, -1);
if (((int)returnValue < 0) ||
(((int)returnValue < 1) &&
(fieldName.equals("width") || fieldName.equals("height")))) {
if ((int)returnValue < 1) {
error.put("code", ApiException.ERROR_RETURN_CODE_INVALID);
error.put("value", returnValue);
throw new ApiException(exMessage, error);
}
break;

case "x":
case "y":
// x/y can be negative or zero, but they are required
// little hacky as prevents this actual x/y value, but um...
returnValue = data.optInt(fieldName, -999999);
if ((int)returnValue == -999999) {
error.put("code", ApiException.ERROR_RETURN_CODE_REQUIRED);
throw new ApiException(exMessage, error);
}
break;

case "theta":
returnValue = data.optDouble(fieldName, 9999.9);
double dval = (double)returnValue;
Expand Down

0 comments on commit 5ec856b

Please sign in to comment.