Changes to minor errors in the VirtualFireAlarmService

Shabirmean 9 years ago
parent 677e07ac36
commit 060c2dd079

5
.gitignore vendored

@ -24,4 +24,7 @@ target
hs_err_pid* hs_err_pid*
# Ignore generated capps # Ignore generated capps
carbonapps carbonapps
# Ignore generated device-type DBs
*.h2.db

@ -121,8 +121,8 @@ public class VirtualFireAlarmService {
final VirtualFireAlarmXMPPConnector virtualFireAlarmXMPPConnector) { final VirtualFireAlarmXMPPConnector virtualFireAlarmXMPPConnector) {
this.virtualFireAlarmXMPPConnector = virtualFireAlarmXMPPConnector; this.virtualFireAlarmXMPPConnector = virtualFireAlarmXMPPConnector;
if (MqttConfig.getInstance().isEnabled()) { if (XmppConfig.getInstance().isEnabled()) {
Runnable mqttStarter = new Runnable() { Runnable xmppStarter = new Runnable() {
@Override @Override
public void run() { public void run() {
virtualFireAlarmXMPPConnector.initConnector(); virtualFireAlarmXMPPConnector.initConnector();
@ -130,9 +130,9 @@ public class VirtualFireAlarmService {
} }
}; };
Thread mqttStarterThread = new Thread(mqttStarter); Thread xmppStarterThread = new Thread(xmppStarter);
mqttStarterThread.setDaemon(true); xmppStarterThread.setDaemon(true);
mqttStarterThread.start(); xmppStarterThread.start();
} else { } else {
log.warn("MQTT disabled in 'devicemgt-config.xml'. Hence, VirtualFireAlarmMQTTConnector not started."); log.warn("MQTT disabled in 'devicemgt-config.xml'. Hence, VirtualFireAlarmMQTTConnector not started.");
} }
@ -144,7 +144,7 @@ public class VirtualFireAlarmService {
public void setVirtualFireAlarmMQTTConnector( public void setVirtualFireAlarmMQTTConnector(
final VirtualFireAlarmMQTTConnector virtualFireAlarmMQTTConnector) { final VirtualFireAlarmMQTTConnector virtualFireAlarmMQTTConnector) {
this.virtualFireAlarmMQTTConnector = virtualFireAlarmMQTTConnector; this.virtualFireAlarmMQTTConnector = virtualFireAlarmMQTTConnector;
if (XmppConfig.getInstance().isEnabled()) { if (MqttConfig.getInstance().isEnabled()) {
virtualFireAlarmMQTTConnector.connect(); virtualFireAlarmMQTTConnector.connect();
} else { } else {
log.warn("XMPP disabled in 'devicemgt-config.xml'. Hence, VirtualFireAlarmXMPPConnector not started."); log.warn("XMPP disabled in 'devicemgt-config.xml'. Hence, VirtualFireAlarmXMPPConnector not started.");

@ -71,42 +71,43 @@ public class VirtualFireAlarmXMPPConnector extends XMPPTransportHandler {
} }
public void createXMPPAccountForDeviceType() { public void createXMPPAccountForDeviceType() {
boolean accountExists = false; boolean accountExists;
XmppServerClient xmppServerClient = new XmppServerClient(); XmppServerClient xmppServerClient = new XmppServerClient();
xmppServerClient.initControlQueue(); xmppServerClient.initControlQueue();
try { try {
accountExists = xmppServerClient.doesXMPPUserAccountExist(xmppVFireAlarmAdminUsername); accountExists = xmppServerClient.doesXMPPUserAccountExist(xmppVFireAlarmAdminUsername);
} catch (DeviceControllerException e) {
String errorMsg = "An error was encountered whilst trying to check whether Server XMPP account exists " +
"for device-type - " + VirtualFireAlarmConstants.DEVICE_TYPE;
log.error(errorMsg, e);
}
if (!accountExists) { if (!accountExists) {
XmppAccount xmppAccount = new XmppAccount(); XmppAccount xmppAccount = new XmppAccount();
xmppAccount.setAccountName(xmppVFireAlarmAdminUsername); xmppAccount.setAccountName(xmppVFireAlarmAdminUsername);
xmppAccount.setUsername(xmppVFireAlarmAdminUsername); xmppAccount.setUsername(xmppVFireAlarmAdminUsername);
xmppAccount.setPassword(V_FIREALARM_XMPP_PASSWORD); xmppAccount.setPassword(V_FIREALARM_XMPP_PASSWORD);
xmppAccount.setEmail(""); xmppAccount.setEmail("");
try { try {
boolean xmppCreated = xmppServerClient.createXMPPAccount(xmppAccount); boolean xmppCreated = xmppServerClient.createXMPPAccount(xmppAccount);
if (!xmppCreated) { if (!xmppCreated) {
log.warn("Server XMPP Account was not created for device-type - " + log.warn("Server XMPP Account was not created for device-type - " +
VirtualFireAlarmConstants.DEVICE_TYPE + VirtualFireAlarmConstants.DEVICE_TYPE +
". Check whether XMPP is enabled in \"devicemgt-config.xml\" & restart."); ". Check whether XMPP is enabled in \"devicemgt-config.xml\" & restart.");
} else { } else {
log.info("Server XMPP Account [" + xmppVFireAlarmAdminUsername + log.info("Server XMPP Account [" + xmppVFireAlarmAdminUsername +
"] was not created for device-type - " + VirtualFireAlarmConstants.DEVICE_TYPE); "] was not created for device-type - " + VirtualFireAlarmConstants.DEVICE_TYPE);
}
} catch (DeviceControllerException e) {
String errorMsg =
"An error was encountered whilst trying to create Server XMPP account for device-type - "
+ VirtualFireAlarmConstants.DEVICE_TYPE;
log.error(errorMsg, e);
} }
} catch (DeviceControllerException e) {
String errorMsg =
"An error was encountered whilst trying to create Server XMPP account for device-type - "
+ VirtualFireAlarmConstants.DEVICE_TYPE;
log.error(errorMsg, e);
} }
} catch (DeviceControllerException e) {
String errorMsg = "An error was encountered whilst trying to check whether Server XMPP account exists " +
"for device-type - " + VirtualFireAlarmConstants.DEVICE_TYPE + ".\n Check [devicemgt-config.xml]";
log.error(errorMsg, e);
} }
} }

@ -95,14 +95,9 @@ public class VirtualFireAlarmService {
@Context //injected response proxy supporting multiple thread @Context //injected response proxy supporting multiple thread
private HttpServletResponse response; private HttpServletResponse response;
public static final String XMPP_PROTOCOL = "XMPP";
public static final String HTTP_PROTOCOL = "HTTP";
public static final String MQTT_PROTOCOL = "MQTT";
private VerificationManager verificationManager; private VerificationManager verificationManager;
private VirtualFireAlarmMQTTConnector virtualFireAlarmMQTTConnector; private VirtualFireAlarmMQTTConnector virtualFireAlarmMQTTConnector;
private VirtualFireAlarmXMPPConnector virtualFireAlarmXMPPConnector; private VirtualFireAlarmXMPPConnector virtualFireAlarmXMPPConnector;
private ConcurrentHashMap<String, String> deviceToIpMap = new ConcurrentHashMap<>();
/** /**
* @param verificationManager * @param verificationManager

Loading…
Cancel
Save