Commit e3747d78 by Adi Amir

bugfix: index out of bound while building link file name

parent 4b908432
Showing with 17 additions and 2 deletions
......@@ -77,6 +77,11 @@ public class GEManager {
SimpleHttpResponse resp = null;
BaseRestResponse brr = new BaseRestResponse(false,null);
String api = "";
for (String tk: apiIdAsParams)
api += tk + ".";
logger.info("received getCamera() serviceId=" + serviceId + " api=" + api);
req = buildCameraHttpRequest(requestContext,content,apiIdAsParams);
try {
resp = httpClient.processRequest(req);
......@@ -87,6 +92,7 @@ public class GEManager {
if(resp.getStatusCode() == 200)
return buildCameraResp(resp);
else if (resp.getStatusCode() == 403 || resp.getStatusCode() == 401) {
logger.info("no valid token - obtain a new token ...");
if(getNewToken())
brr = executeRequest(serviceId,apiIdAsParams,requestContext,content,isMaintenanceRequest);
else
......@@ -103,6 +109,11 @@ public class GEManager {
SimpleHttpResponse resp = null;
BaseRestResponse brr = new BaseRestResponse(false,null);
String api = "";
for (String tk: apiIdAsParams)
api += tk + ".";
logger.info("received getCamerasList() serviceId=" + serviceId + " api=" + api);
req = buildCamerasHttpRequest(requestContext,content);
try {
resp = httpClient.processRequest(req);
......@@ -110,8 +121,9 @@ public class GEManager {
e.printStackTrace();
}
if(resp.getStatusCode() == 200)
return buildCamerasResp(resp);
return buildCameraListResp(resp);
else if (resp.getStatusCode() == 403 || resp.getStatusCode() == 401) {
logger.info("no valid token - obtain a new token ...");
if(getNewToken())
brr = executeRequest(serviceId,apiIdAsParams,requestContext,content,isMaintenanceRequest);
else
......@@ -160,7 +172,10 @@ public class GEManager {
// file name
String filename = getImageFileName(url);
String[] fileNameTokens = filename.split("\\.");
if (fileNameTokens.length == 2)
filename = fileNameTokens[0] + ".latest" + "." + fileNameTokens[1];
else
filename = fileNameTokens[0] + ".latest";
dataObj.put("fileName", filename);
// data
dataObj.put("data", resp.getContent());
......@@ -174,7 +189,7 @@ public class GEManager {
}
return brr;
}
private BaseRestResponse buildCamerasResp(SimpleHttpResponse resp) {
private BaseRestResponse buildCameraListResp(SimpleHttpResponse resp) {
BaseRestResponse brr = new BaseRestResponse(true,null);
int size;
String content = resp.getContent();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment