Commit f25d9f84 by Adi Amir

change details api name to latestEvent

parent b18d9b3e
Showing with 11 additions and 13 deletions
......@@ -22,14 +22,12 @@ import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
import web.App;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.DecimalFormat;
import java.util.Deque;
import java.util.Map;
......@@ -96,8 +94,8 @@ public class GEManager {
else if (apiIdAsParams.length == 1 && apiIdAsParams[0].equals("sensors")) {
brr = getSensorList(requestContext);
}
else if (apiIdAsParams.length == 3 && apiIdAsParams[0].equals("sensor") && apiIdAsParams[2].equals("details")) {
brr = getSensorDetails(apiIdAsParams[1]/*sensorId*/, requestContext);
else if (apiIdAsParams.length == 3 && apiIdAsParams[0].equals("sensor") && apiIdAsParams[2].equals("latestEvent")) {
brr = getSensorLatestEvent(apiIdAsParams[1]/*sensorId*/, requestContext);
}
else {
String err = "executeRequest() failed. Unknown api: " + getApiIdString(apiIdAsParams);
......@@ -232,12 +230,12 @@ public class GEManager {
logger.info("getCameraDetails() successfull. camId=" + cameraId);
return brr;
}
private BaseRestResponse getSensorDetails(String sensorId, RequestContext requestContext) {
private BaseRestResponse getSensorLatestEvent(String sensorId, RequestContext requestContext) {
SimpleHttpRequest req = null;
SimpleHttpResponse httpResp = null;
BaseRestResponse brr = new BaseRestResponse(false,null);
logger.info("getSensorDetails() activated. camId=" + sensorId);
logger.info("getSensorLatestEvent() activated. camId=" + sensorId);
// execute the request ...
// envType
......@@ -255,27 +253,27 @@ public class GEManager {
return errorResponse("missing mandatory parameter: startTime");
Long tsStartTime = Long.parseLong(startTime);
req = buildSensorDetailsRequest(sensorId, envType, tsStartTime, tsEndTime);
req = buildSensorLatestEventRequest(sensorId, envType, tsStartTime, tsEndTime);
try {
httpResp = httpClient.processRequest(req);
if(httpResp.getStatusCode() == 200)
brr = buildSensorDetailsResp(httpResp);
brr = buildSensorLatestEventResp(httpResp);
else {
logHttpError("getSensorDetails", httpResp);
logHttpError("getSensorLatestEvent", httpResp);
return errorHttpResponse(httpResp);
}
} catch (Exception e) {
String err = "getSensorDetails() failed with exception. e=" + e.toString();
String err = "getSensorLatestEvent() failed with exception. e=" + e.toString();
logger.error(err);
return errorResponse(err);
}
logger.info("getSensorDetails() successfull. camId=" + sensorId);
logger.info("getSensorLatestEvent() successfull. camId=" + sensorId);
return brr;
}
private SimpleHttpRequest buildSensorDetailsRequest(String sensdorId, String envType, Long tsStartTime, Long tsEndTime) {
private SimpleHttpRequest buildSensorLatestEventRequest(String sensdorId, String envType, Long tsStartTime, Long tsEndTime) {
SimpleHttpRequest request = new SimpleHttpRequest();
request.setProtocol("https");
request.setDomain(EVENT_URL);
......@@ -296,7 +294,7 @@ public class GEManager {
return request;
}
private BaseRestResponse buildSensorDetailsResp(SimpleHttpResponse resp) {
private BaseRestResponse buildSensorLatestEventResp(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