Commit e3747d78 by Adi Amir

bugfix: index out of bound while building link file name

parent 4b908432
Showing with 18 additions and 3 deletions
...@@ -77,6 +77,11 @@ public class GEManager { ...@@ -77,6 +77,11 @@ public class GEManager {
SimpleHttpResponse resp = null; SimpleHttpResponse resp = null;
BaseRestResponse brr = new BaseRestResponse(false,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); req = buildCameraHttpRequest(requestContext,content,apiIdAsParams);
try { try {
resp = httpClient.processRequest(req); resp = httpClient.processRequest(req);
...@@ -87,6 +92,7 @@ public class GEManager { ...@@ -87,6 +92,7 @@ public class GEManager {
if(resp.getStatusCode() == 200) if(resp.getStatusCode() == 200)
return buildCameraResp(resp); return buildCameraResp(resp);
else if (resp.getStatusCode() == 403 || resp.getStatusCode() == 401) { else if (resp.getStatusCode() == 403 || resp.getStatusCode() == 401) {
logger.info("no valid token - obtain a new token ...");
if(getNewToken()) if(getNewToken())
brr = executeRequest(serviceId,apiIdAsParams,requestContext,content,isMaintenanceRequest); brr = executeRequest(serviceId,apiIdAsParams,requestContext,content,isMaintenanceRequest);
else else
...@@ -103,6 +109,11 @@ public class GEManager { ...@@ -103,6 +109,11 @@ public class GEManager {
SimpleHttpResponse resp = null; SimpleHttpResponse resp = null;
BaseRestResponse brr = new BaseRestResponse(false,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); req = buildCamerasHttpRequest(requestContext,content);
try { try {
resp = httpClient.processRequest(req); resp = httpClient.processRequest(req);
...@@ -110,8 +121,9 @@ public class GEManager { ...@@ -110,8 +121,9 @@ public class GEManager {
e.printStackTrace(); e.printStackTrace();
} }
if(resp.getStatusCode() == 200) if(resp.getStatusCode() == 200)
return buildCamerasResp(resp); return buildCameraListResp(resp);
else if (resp.getStatusCode() == 403 || resp.getStatusCode() == 401) { else if (resp.getStatusCode() == 403 || resp.getStatusCode() == 401) {
logger.info("no valid token - obtain a new token ...");
if(getNewToken()) if(getNewToken())
brr = executeRequest(serviceId,apiIdAsParams,requestContext,content,isMaintenanceRequest); brr = executeRequest(serviceId,apiIdAsParams,requestContext,content,isMaintenanceRequest);
else else
...@@ -160,7 +172,10 @@ public class GEManager { ...@@ -160,7 +172,10 @@ public class GEManager {
// file name // file name
String filename = getImageFileName(url); String filename = getImageFileName(url);
String[] fileNameTokens = filename.split("\\."); String[] fileNameTokens = filename.split("\\.");
filename = fileNameTokens[0] + ".latest" + "." + fileNameTokens[1]; if (fileNameTokens.length == 2)
filename = fileNameTokens[0] + ".latest" + "." + fileNameTokens[1];
else
filename = fileNameTokens[0] + ".latest";
dataObj.put("fileName", filename); dataObj.put("fileName", filename);
// data // data
dataObj.put("data", resp.getContent()); dataObj.put("data", resp.getContent());
...@@ -174,7 +189,7 @@ public class GEManager { ...@@ -174,7 +189,7 @@ public class GEManager {
} }
return brr; return brr;
} }
private BaseRestResponse buildCamerasResp(SimpleHttpResponse resp) { private BaseRestResponse buildCameraListResp(SimpleHttpResponse resp) {
BaseRestResponse brr = new BaseRestResponse(true,null); BaseRestResponse brr = new BaseRestResponse(true,null);
int size; int size;
String content = resp.getContent(); 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