Skip to content

Commit

Permalink
handle file not found case
Browse files Browse the repository at this point in the history
  • Loading branch information
qqmyers committed Nov 10, 2023
1 parent 6ad55eb commit 48f02dd
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.http.util.EntityUtils;

import jakarta.json.Json;
import jakarta.json.JsonArray;
import jakarta.json.JsonObject;
import jakarta.json.JsonObjectBuilder;

Expand Down Expand Up @@ -189,7 +190,11 @@ public long retrieveSizeFromMedia() {
String responseString = EntityUtils.toString(response.getEntity());
logger.info("Response from " + get.getURI().toString() + " is: " + responseString);
JsonObject responseJson = JsonUtil.getJsonObject(responseString);
return (long) responseJson.getJsonArray("DATA").getJsonObject(0).getInt("size");
JsonArray dataArray = responseJson.getJsonArray("DATA");
if (dataArray != null && dataArray.size() != 0) {
//File found
return (long) responseJson.getJsonArray("DATA").getJsonObject(0).getInt("size");
}
} else {
logger.warning("Response from " + get.getURI().toString() + " was "
+ response.getStatusLine().getStatusCode());
Expand Down

0 comments on commit 48f02dd

Please sign in to comment.