Merge pull request #129 from NuwanSameera/IoTS-1.0.0-M1

Fixed arduino analitics problems and remove unused logs
Ruwan 9 years ago
commit c8d99d3ac8

@ -280,7 +280,7 @@ public class ArduinoService {
response.setStatus(HttpStatus.SC_NO_CONTENT);
} else {
try {
result = deviceControlList.remove(); //returns the head value
result = deviceControlList.remove();
response.setStatus(HttpStatus.SC_ACCEPTED);
} catch (NoSuchElementException ex) {
@ -310,49 +310,16 @@ public class ArduinoService {
@Context HttpServletRequest request) {
String owner = dataMsg.owner;
String deviceId = dataMsg.deviceId;
String deviceIp = dataMsg.reply; //TODO:: Get IP from request
float temperature = dataMsg.value;
try {
DeviceValidator deviceValidator = new DeviceValidator();
if (!deviceValidator.isExist(owner, SUPER_TENANT, new DeviceIdentifier(deviceId,
ArduinoConstants.DEVICE_TYPE))) {
response.setStatus(Response.Status.UNAUTHORIZED.getStatusCode());
log.warn("Temperature data Received from unregistered Arduino device [" + deviceId + "] for owner [" +
owner + "]");
return;
}
String registeredIp = deviceToIpMap.get(deviceId);
if (registeredIp == null) {
log.warn("Unregistered IP: Temperature Data Received from an un-registered IP " + deviceIp +
" for device ID - " + deviceId);
response.setStatus(Response.Status.PRECONDITION_FAILED.getStatusCode());
return;
} else if (!registeredIp.equals(deviceIp)) {
log.warn("Conflicting IP: Received IP is " + deviceIp + ". Device with ID " + deviceId +
" is already registered under some other IP. Re-registration required");
response.setStatus(Response.Status.CONFLICT.getStatusCode());
return;
}
if (log.isDebugEnabled()) {
log.debug("Received Pin Data Value: " + temperature + " degrees C");
}
SensorDataManager.getInstance().setSensorRecord(deviceId, ArduinoConstants.SENSOR_TEMPERATURE,
SensorDataManager.getInstance().setSensorRecord(deviceId, ArduinoConstants.SENSOR_TEMPERATURE,
String.valueOf(temperature),
Calendar.getInstance().getTimeInMillis());
if (!ArduinoServiceUtils.publishToDAS(dataMsg.owner, dataMsg.deviceId, dataMsg.value)) {
response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
log.warn("An error occured whilst trying to publish temperature data of Arduino with ID [" + deviceId +
if (!ArduinoServiceUtils.publishToDAS(dataMsg.owner, dataMsg.deviceId, dataMsg.value)) {
response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
log.warn("An error occured whilst trying to publish temperature data of Arduino with ID [" + deviceId +
"] of owner [" + owner + "]");
}
} catch (DeviceManagementException e) {
String errorMsg = "Validation attempt for deviceId [" + deviceId + "] of owner [" + owner + "] failed.\n";
log.error(errorMsg + Response.Status.INTERNAL_SERVER_ERROR.getReasonPhrase() + "\n" + e.getErrorMessage());
}
}
}

@ -80,8 +80,6 @@ public class DigitalDisplayControllerService {
@HeaderParam("sessionId") String sessionId,
@Context HttpServletResponse response) {
log.info("Restart Browser : " + deviceId);
try {
sendCommandViaMQTT(owner, deviceId, sessionId + "::" + DigitalDisplayConstants.RESTART_BROWSER_CONSTANT + ":", "");
response.setStatus(Response.Status.OK.getStatusCode());
@ -113,8 +111,6 @@ public class DigitalDisplayControllerService {
@HeaderParam("sessionId") String sessionId,
@Context HttpServletResponse response) {
log.info("Close Browser : " + deviceId);
try {
sendCommandViaMQTT(owner, deviceId, sessionId + "::" + DigitalDisplayConstants.CLOSE_BROWSER_CONSTANT + ":", "");
response.setStatus(Response.Status.OK.getStatusCode());
@ -145,8 +141,6 @@ public class DigitalDisplayControllerService {
@HeaderParam("sessionId") String sessionId,
@Context HttpServletResponse response) {
log.info("Terminate Display : " + deviceId);
try {
sendCommandViaMQTT(owner, deviceId, sessionId + "::" + DigitalDisplayConstants.TERMINATE_DISPLAY_CONSTANT + ":", "");
response.setStatus(Response.Status.OK.getStatusCode());
@ -177,8 +171,6 @@ public class DigitalDisplayControllerService {
@HeaderParam("sessionId") String sessionId,
@Context HttpServletResponse response) {
log.info("Restart Display : " + deviceId);
try {
sendCommandViaMQTT(owner, deviceId, sessionId + "::" + DigitalDisplayConstants.RESTART_DISPLAY_CONSTANT + ":", "");
response.setStatus(Response.Status.OK.getStatusCode());
@ -215,8 +207,6 @@ public class DigitalDisplayControllerService {
@HeaderParam("sessionId") String sessionId,
@Context HttpServletResponse response) {
log.info("Edit Content Display Id - " + deviceId + " by " + owner);
try {
String params = path + "|" + attribute + "|" + newValue;
sendCommandViaMQTT(owner, deviceId, sessionId + "::" + DigitalDisplayConstants.EDIT_SEQUENCE_CONSTANT + ":", params);
@ -255,7 +245,6 @@ public class DigitalDisplayControllerService {
@HeaderParam("sessionId") String sessionId,
@Context HttpServletResponse response) {
log.info("Add Sequence : " + deviceId);
String params;
try {
@ -296,8 +285,6 @@ public class DigitalDisplayControllerService {
@HeaderParam("sessionId") String sessionId,
@Context HttpServletResponse response) {
log.info("Remove Resource : " + deviceId);
try {
sendCommandViaMQTT(owner, deviceId, sessionId + "::" +
DigitalDisplayConstants.REMOVE_RESOURCE_CONSTANT + ":", path);
@ -331,7 +318,6 @@ public class DigitalDisplayControllerService {
@HeaderParam("sessionId") String sessionId,
@Context HttpServletResponse response) {
log.info("Remove Directory : " + deviceId);
try {
sendCommandViaMQTT(owner, deviceId, sessionId + "::" +
DigitalDisplayConstants.REMOVE_DIRECTORY_CONSTANT + ":", directoryName);
@ -367,7 +353,6 @@ public class DigitalDisplayControllerService {
@HeaderParam("sessionId") String sessionId,
@Context HttpServletResponse response) {
log.info("Remove Content : " + deviceId);
try {
String param = directoryName + "|" + content;
sendCommandViaMQTT(owner, deviceId, sessionId + "::" + DigitalDisplayConstants.REMOVE_CONTENT_CONSTANT + ":", param);
@ -399,8 +384,6 @@ public class DigitalDisplayControllerService {
@HeaderParam("sessionId") String sessionId,
@Context HttpServletResponse response) {
log.info("Shut down display : " + deviceId);
try {
sendCommandViaMQTT(owner, deviceId, sessionId + "::" + DigitalDisplayConstants.SHUTDOWN_DISPLAY_CONSTANT + ":", "");
response.setStatus(Response.Status.OK.getStatusCode());
@ -425,14 +408,12 @@ public class DigitalDisplayControllerService {
@Path("/get-status")
@POST
@Feature(code = "get-status", name = "Get Status", type="operation",
description = "Check specific digital display power ON of OFF")
description = "Check specific digital display power ON or OFF")
public void getStatus(@HeaderParam("deviceId") String deviceId,
@HeaderParam("owner") String owner,
@HeaderParam("sessionId") String sessionId,
@Context HttpServletResponse response) {
log.info("Status : " + deviceId);
try {
sendCommandViaMQTT(owner, deviceId, sessionId + ":" + DigitalDisplayConstants.GET_STATUS_CONSTANT, "");
response.setStatus(Response.Status.OK.getStatusCode());

@ -12,7 +12,7 @@
"name": "cdmf.unit.analytics.line-chart",
"data":[
{"column": {"name":"TIME", "label":"time", "ui-mapping":"x-axis"}},
{"column": {"name":"ACCELEROMETER", "label":"Accelerometer", "ui-mapping":"y-axis"}}
{"column": {"name":"TEMPERATURE", "label":"temperature", "ui-mapping":"y-axis"}}
]
}
}

Loading…
Cancel
Save