|
|
@ -16,7 +16,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
package org.wso2.carbon.device.mgt.iot.sample.firealarm.service.impl;
|
|
|
|
package org.wso2.carbon.device.mgt.iot.sample.firealarm.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.httpclient.HttpStatus;
|
|
|
|
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.apache.http.HttpResponse;
|
|
|
|
import org.apache.http.HttpResponse;
|
|
|
@ -46,6 +45,7 @@ import javax.ws.rs.Path;
|
|
|
|
import javax.ws.rs.PathParam;
|
|
|
|
import javax.ws.rs.PathParam;
|
|
|
|
import javax.ws.rs.core.Context;
|
|
|
|
import javax.ws.rs.core.Context;
|
|
|
|
import javax.ws.rs.core.MediaType;
|
|
|
|
import javax.ws.rs.core.MediaType;
|
|
|
|
|
|
|
|
import javax.ws.rs.core.Response;
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.IOException;
|
|
|
@ -61,6 +61,11 @@ import java.util.concurrent.Future;
|
|
|
|
public class FireAlarmControllerService {
|
|
|
|
public class FireAlarmControllerService {
|
|
|
|
|
|
|
|
|
|
|
|
private static Log log = LogFactory.getLog(FireAlarmControllerService.class);
|
|
|
|
private static Log log = LogFactory.getLog(FireAlarmControllerService.class);
|
|
|
|
|
|
|
|
//TODO; replace this tenant domain
|
|
|
|
|
|
|
|
private final String SUPER_TENANT = "carbon.super";
|
|
|
|
|
|
|
|
@Context //injected response proxy supporting multiple thread
|
|
|
|
|
|
|
|
private HttpServletResponse response;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final String URL_PREFIX = "http://";
|
|
|
|
private static final String URL_PREFIX = "http://";
|
|
|
|
private static final String BULB_CONTEXT = "/BULB/";
|
|
|
|
private static final String BULB_CONTEXT = "/BULB/";
|
|
|
@ -89,7 +94,7 @@ public class FireAlarmControllerService {
|
|
|
|
deviceToIpMap.put(deviceId, deviceIP);
|
|
|
|
deviceToIpMap.put(deviceId, deviceIP);
|
|
|
|
|
|
|
|
|
|
|
|
result = "Device-IP Registered";
|
|
|
|
result = "Device-IP Registered";
|
|
|
|
response.setStatus(HttpStatus.SC_OK);
|
|
|
|
response.setStatus(Response.Status.OK.getStatusCode());
|
|
|
|
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug(result);
|
|
|
|
log.debug(result);
|
|
|
@ -111,15 +116,14 @@ public class FireAlarmControllerService {
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
DeviceValidator deviceValidator = new DeviceValidator();
|
|
|
|
DeviceValidator deviceValidator = new DeviceValidator();
|
|
|
|
if (!deviceValidator.isExist(owner, new DeviceIdentifier(deviceId,
|
|
|
|
if (!deviceValidator.isExist(owner, SUPER_TENANT, new DeviceIdentifier(deviceId,
|
|
|
|
FireAlarmConstants
|
|
|
|
FireAlarmConstants.DEVICE_TYPE))) {
|
|
|
|
.DEVICE_TYPE))) {
|
|
|
|
response.setStatus(Response.Status.UNAUTHORIZED.getStatusCode());
|
|
|
|
response.setStatus(HttpStatus.SC_UNAUTHORIZED);
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
log.error("DeviceValidation Failed for deviceId: " + deviceId + " of user: " + owner);
|
|
|
|
log.error("DeviceValidation Failed for deviceId: " + deviceId + " of user: " + owner);
|
|
|
|
response.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR);
|
|
|
|
response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -128,13 +132,13 @@ public class FireAlarmControllerService {
|
|
|
|
if (!switchToState.equals(FireAlarmConstants.STATE_ON) && !switchToState.equals(
|
|
|
|
if (!switchToState.equals(FireAlarmConstants.STATE_ON) && !switchToState.equals(
|
|
|
|
FireAlarmConstants.STATE_OFF)) {
|
|
|
|
FireAlarmConstants.STATE_OFF)) {
|
|
|
|
log.error("The requested state change shoud be either - 'ON' or 'OFF'");
|
|
|
|
log.error("The requested state change shoud be either - 'ON' or 'OFF'");
|
|
|
|
response.setStatus(HttpStatus.SC_BAD_REQUEST);
|
|
|
|
response.setStatus(Response.Status.BAD_REQUEST.getStatusCode());
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
String deviceIP = deviceToIpMap.get(deviceId);
|
|
|
|
String deviceIP = deviceToIpMap.get(deviceId);
|
|
|
|
if (deviceIP == null) {
|
|
|
|
if (deviceIP == null) {
|
|
|
|
response.setStatus(HttpStatus.SC_PRECONDITION_FAILED);
|
|
|
|
response.setStatus(Response.Status.PRECONDITION_FAILED.getStatusCode());
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -161,7 +165,7 @@ public class FireAlarmControllerService {
|
|
|
|
if (protocolString == null) {
|
|
|
|
if (protocolString == null) {
|
|
|
|
sendCommandViaHTTP(deviceIP, 80, callUrlPattern, true);
|
|
|
|
sendCommandViaHTTP(deviceIP, 80, callUrlPattern, true);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
response.setStatus(HttpStatus.SC_NOT_IMPLEMENTED);
|
|
|
|
response.setStatus(Response.Status.NOT_ACCEPTABLE.getStatusCode());
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -169,11 +173,11 @@ public class FireAlarmControllerService {
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
log.error("Failed to send command '" + callUrlPattern + "' to: " + deviceIP + " via" +
|
|
|
|
log.error("Failed to send command '" + callUrlPattern + "' to: " + deviceIP + " via" +
|
|
|
|
" " + protocol);
|
|
|
|
" " + protocol);
|
|
|
|
response.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR);
|
|
|
|
response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
response.setStatus(HttpStatus.SC_OK);
|
|
|
|
response.setStatus(Response.Status.OK.getStatusCode());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -187,15 +191,15 @@ public class FireAlarmControllerService {
|
|
|
|
|
|
|
|
|
|
|
|
DeviceValidator deviceValidator = new DeviceValidator();
|
|
|
|
DeviceValidator deviceValidator = new DeviceValidator();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (!deviceValidator.isExist(owner, new DeviceIdentifier(deviceId,
|
|
|
|
if (!deviceValidator.isExist(owner, SUPER_TENANT, new DeviceIdentifier(deviceId,
|
|
|
|
FireAlarmConstants
|
|
|
|
FireAlarmConstants
|
|
|
|
.DEVICE_TYPE))) {
|
|
|
|
.DEVICE_TYPE))) {
|
|
|
|
response.setStatus(HttpStatus.SC_UNAUTHORIZED);
|
|
|
|
response.setStatus(Response.Status.UNAUTHORIZED.getStatusCode());
|
|
|
|
return "Unauthorized Access";
|
|
|
|
return "Unauthorized Access";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
replyMsg = e.getErrorMessage();
|
|
|
|
replyMsg = e.getErrorMessage();
|
|
|
|
response.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR);
|
|
|
|
response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
|
|
|
|
return replyMsg;
|
|
|
|
return replyMsg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -203,7 +207,7 @@ public class FireAlarmControllerService {
|
|
|
|
|
|
|
|
|
|
|
|
if (deviceIp == null) {
|
|
|
|
if (deviceIp == null) {
|
|
|
|
replyMsg = "IP not registered for device: " + deviceId + " of owner: " + owner;
|
|
|
|
replyMsg = "IP not registered for device: " + deviceId + " of owner: " + owner;
|
|
|
|
response.setStatus(HttpStatus.SC_PRECONDITION_FAILED);
|
|
|
|
response.setStatus(Response.Status.PRECONDITION_FAILED.getStatusCode());
|
|
|
|
return replyMsg;
|
|
|
|
return replyMsg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -231,18 +235,18 @@ public class FireAlarmControllerService {
|
|
|
|
replyMsg = sendCommandViaHTTP(deviceIp, 80, SONAR_CONTEXT, false);
|
|
|
|
replyMsg = sendCommandViaHTTP(deviceIp, 80, SONAR_CONTEXT, false);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
replyMsg = "Requested protocol '" + protocol + "' is not supported";
|
|
|
|
replyMsg = "Requested protocol '" + protocol + "' is not supported";
|
|
|
|
response.setStatus(HttpStatus.SC_NOT_IMPLEMENTED);
|
|
|
|
response.setStatus(Response.Status.NOT_ACCEPTABLE.getStatusCode());
|
|
|
|
return replyMsg;
|
|
|
|
return replyMsg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
replyMsg = e.getErrorMessage();
|
|
|
|
replyMsg = e.getErrorMessage();
|
|
|
|
response.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR);
|
|
|
|
response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
|
|
|
|
return replyMsg;
|
|
|
|
return replyMsg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
response.setStatus(HttpStatus.SC_OK);
|
|
|
|
response.setStatus(Response.Status.OK.getStatusCode());
|
|
|
|
replyMsg = "The current sonar reading of the device is " + replyMsg;
|
|
|
|
replyMsg = "The current sonar reading of the device is " + replyMsg;
|
|
|
|
return replyMsg;
|
|
|
|
return replyMsg;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -258,15 +262,15 @@ public class FireAlarmControllerService {
|
|
|
|
|
|
|
|
|
|
|
|
DeviceValidator deviceValidator = new DeviceValidator();
|
|
|
|
DeviceValidator deviceValidator = new DeviceValidator();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (!deviceValidator.isExist(owner, new DeviceIdentifier(deviceId,
|
|
|
|
if (!deviceValidator.isExist(owner, SUPER_TENANT, new DeviceIdentifier(deviceId,
|
|
|
|
FireAlarmConstants
|
|
|
|
FireAlarmConstants
|
|
|
|
.DEVICE_TYPE))) {
|
|
|
|
.DEVICE_TYPE))) {
|
|
|
|
response.setStatus(HttpStatus.SC_UNAUTHORIZED);
|
|
|
|
response.setStatus(Response.Status.UNAUTHORIZED.getStatusCode());
|
|
|
|
return "Unauthorized Access";
|
|
|
|
return "Unauthorized Access";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
replyMsg = e.getErrorMessage();
|
|
|
|
replyMsg = e.getErrorMessage();
|
|
|
|
response.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR);
|
|
|
|
response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
|
|
|
|
return replyMsg;
|
|
|
|
return replyMsg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -274,7 +278,7 @@ public class FireAlarmControllerService {
|
|
|
|
|
|
|
|
|
|
|
|
if (deviceIp == null) {
|
|
|
|
if (deviceIp == null) {
|
|
|
|
replyMsg = "IP not registered for device: " + deviceId + " of owner: " + owner;
|
|
|
|
replyMsg = "IP not registered for device: " + deviceId + " of owner: " + owner;
|
|
|
|
response.setStatus(HttpStatus.SC_PRECONDITION_FAILED);
|
|
|
|
response.setStatus(Response.Status.PRECONDITION_FAILED.getStatusCode());
|
|
|
|
return replyMsg;
|
|
|
|
return replyMsg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -303,18 +307,18 @@ public class FireAlarmControllerService {
|
|
|
|
replyMsg = sendCommandViaHTTP(deviceIp, 80, TEMPERATURE_CONTEXT, false);
|
|
|
|
replyMsg = sendCommandViaHTTP(deviceIp, 80, TEMPERATURE_CONTEXT, false);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
replyMsg = "Requested protocol '" + protocol + "' is not supported";
|
|
|
|
replyMsg = "Requested protocol '" + protocol + "' is not supported";
|
|
|
|
response.setStatus(HttpStatus.SC_NOT_IMPLEMENTED);
|
|
|
|
response.setStatus(Response.Status.NOT_ACCEPTABLE.getStatusCode());
|
|
|
|
return replyMsg;
|
|
|
|
return replyMsg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
replyMsg = e.getErrorMessage();
|
|
|
|
replyMsg = e.getErrorMessage();
|
|
|
|
response.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR);
|
|
|
|
response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
|
|
|
|
return replyMsg;
|
|
|
|
return replyMsg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
response.setStatus(HttpStatus.SC_OK);
|
|
|
|
response.setStatus(Response.Status.OK.getStatusCode());
|
|
|
|
replyMsg = "The current temperature of the device is " + replyMsg;
|
|
|
|
replyMsg = "The current temperature of the device is " + replyMsg;
|
|
|
|
return replyMsg;
|
|
|
|
return replyMsg;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -385,14 +389,14 @@ public class FireAlarmControllerService {
|
|
|
|
"Unregistered IP: Temperature Data Received from an un-registered IP " +
|
|
|
|
"Unregistered IP: Temperature Data Received from an un-registered IP " +
|
|
|
|
deviceIp +
|
|
|
|
deviceIp +
|
|
|
|
" for device ID - " + deviceId);
|
|
|
|
" for device ID - " + deviceId);
|
|
|
|
response.setStatus(HttpStatus.SC_PRECONDITION_FAILED);
|
|
|
|
response.setStatus(Response.Status.PRECONDITION_FAILED.getStatusCode());
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
} else if (!registeredIp.equals(deviceIp)) {
|
|
|
|
} else if (!registeredIp.equals(deviceIp)) {
|
|
|
|
log.warn("Conflicting IP: Received IP is " + deviceIp + ". Device with ID " +
|
|
|
|
log.warn("Conflicting IP: Received IP is " + deviceIp + ". Device with ID " +
|
|
|
|
deviceId +
|
|
|
|
deviceId +
|
|
|
|
" is already registered under some other IP. Re-registration " +
|
|
|
|
" is already registered under some other IP. Re-registration " +
|
|
|
|
"required");
|
|
|
|
"required");
|
|
|
|
response.setStatus(HttpStatus.SC_CONFLICT);
|
|
|
|
response.setStatus(Response.Status.CONFLICT.getStatusCode());
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -408,10 +412,10 @@ public class FireAlarmControllerService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!result) {
|
|
|
|
if (!result) {
|
|
|
|
response.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR);
|
|
|
|
response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (UnauthorizedException e) {
|
|
|
|
} catch (UnauthorizedException e) {
|
|
|
|
response.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR);
|
|
|
|
response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
|
|
|
|
log.error("Data Push Attempt Failed for BAM Publisher: " + e.getMessage());
|
|
|
|
log.error("Data Push Attempt Failed for BAM Publisher: " + e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -427,10 +431,10 @@ public class FireAlarmControllerService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!result) {
|
|
|
|
if (!result) {
|
|
|
|
response.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR);
|
|
|
|
response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (UnauthorizedException e) {
|
|
|
|
} catch (UnauthorizedException e) {
|
|
|
|
response.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR);
|
|
|
|
response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
|
|
|
|
log.error("Data Push Attempt Failed for CEP Publisher: " + e.getMessage());
|
|
|
|
log.error("Data Push Attempt Failed for CEP Publisher: " + e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -465,7 +469,7 @@ public class FireAlarmControllerService {
|
|
|
|
temperature, "TEMPERATURE");
|
|
|
|
temperature, "TEMPERATURE");
|
|
|
|
|
|
|
|
|
|
|
|
if (!result) {
|
|
|
|
if (!result) {
|
|
|
|
response.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR);
|
|
|
|
response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
|
|
|
|
log.error("Error whilst pushing temperature: " + sensorValues);
|
|
|
|
log.error("Error whilst pushing temperature: " + sensorValues);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -478,7 +482,7 @@ public class FireAlarmControllerService {
|
|
|
|
"BULB");
|
|
|
|
"BULB");
|
|
|
|
|
|
|
|
|
|
|
|
if (!result) {
|
|
|
|
if (!result) {
|
|
|
|
response.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR);
|
|
|
|
response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
|
|
|
|
log.error("Error whilst pushing Bulb data: " + sensorValues);
|
|
|
|
log.error("Error whilst pushing Bulb data: " + sensorValues);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -491,7 +495,7 @@ public class FireAlarmControllerService {
|
|
|
|
"SONAR");
|
|
|
|
"SONAR");
|
|
|
|
|
|
|
|
|
|
|
|
if (!result) {
|
|
|
|
if (!result) {
|
|
|
|
response.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR);
|
|
|
|
response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
|
|
|
|
log.error("Error whilst pushing Sonar data: " + sensorValues);
|
|
|
|
log.error("Error whilst pushing Sonar data: " + sensorValues);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -503,13 +507,13 @@ public class FireAlarmControllerService {
|
|
|
|
System.currentTimeMillis(), "DeviceData",
|
|
|
|
System.currentTimeMillis(), "DeviceData",
|
|
|
|
dataMsg.value, dataMsg.reply);
|
|
|
|
dataMsg.value, dataMsg.reply);
|
|
|
|
if (!result) {
|
|
|
|
if (!result) {
|
|
|
|
response.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR);
|
|
|
|
response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
|
|
|
|
log.error("Error whilst pushing sensor data: " + sensorValues);
|
|
|
|
log.error("Error whilst pushing sensor data: " + sensorValues);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} catch (UnauthorizedException e) {
|
|
|
|
} catch (UnauthorizedException e) {
|
|
|
|
response.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR);
|
|
|
|
response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
|
|
|
|
log.error("Data Push Attempt Failed at Publisher: " + e.getMessage());
|
|
|
|
log.error("Data Push Attempt Failed at Publisher: " + e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -544,10 +548,12 @@ public class FireAlarmControllerService {
|
|
|
|
String scriptPath = CarbonUtils.getCarbonHome() + seperator + scriptsFolder + seperator
|
|
|
|
String scriptPath = CarbonUtils.getCarbonHome() + seperator + scriptsFolder + seperator
|
|
|
|
+ "xmpp_client.py ";
|
|
|
|
+ "xmpp_client.py ";
|
|
|
|
|
|
|
|
|
|
|
|
scriptArguments = "-j " + xmppAdminUserLogin + " -p " + xmppAdminPass + " -c " + clientToConnect + " -r " + resource + " -s " + state;
|
|
|
|
scriptArguments =
|
|
|
|
|
|
|
|
"-j " + xmppAdminUserLogin + " -p " + xmppAdminPass + " -c " + clientToConnect +
|
|
|
|
|
|
|
|
" -r " + resource + " -s " + state;
|
|
|
|
command = "python " + scriptPath + scriptArguments;
|
|
|
|
command = "python " + scriptPath + scriptArguments;
|
|
|
|
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()){
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Connecting to XMPP Server via Admin credentials: " + xmppAdminUserLogin);
|
|
|
|
log.debug("Connecting to XMPP Server via Admin credentials: " + xmppAdminUserLogin);
|
|
|
|
log.debug("Trying to contact xmpp device account: " + clientToConnect);
|
|
|
|
log.debug("Trying to contact xmpp device account: " + clientToConnect);
|
|
|
|
log.debug("Arguments used for the scripts: '" + scriptArguments + "'");
|
|
|
|
log.debug("Arguments used for the scripts: '" + scriptArguments + "'");
|
|
|
|