diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.service.impl/pom.xml b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/pom.xml similarity index 96% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.service.impl/pom.xml rename to components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/pom.xml index ff7e3bfa1..d9cff3eee 100644 --- a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.service.impl/pom.xml +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/pom.xml @@ -3,15 +3,14 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - device-mgt-iot-androidsense + androidsense-plugin org.wso2.carbon.devicemgt-plugins - 2.0.4-SNAPSHOT + 2.1.0-SNAPSHOT ../pom.xml 4.0.0 - org.wso2.carbon.device.mgt.iot.androidsense.service.impl - 2.0.4-SNAPSHOT + org.wso2.carbon.device.mgt.iot.androidsense.api war WSO2 Carbon - Android Sense API WSO2 Carbon - Android Sense Service-API Implementation @@ -98,7 +97,6 @@ org.wso2.carbon.devicemgt org.wso2.carbon.device.mgt.analytics.data.publisher - 1.1.0-SNAPSHOT provided diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseControllerService.java b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseControllerService.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseControllerService.java rename to components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseControllerService.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseControllerServiceImpl.java b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseControllerServiceImpl.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseControllerServiceImpl.java rename to components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseControllerServiceImpl.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseManagerService.java b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseManagerService.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseManagerService.java rename to components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseManagerService.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseManagerServiceImpl.java b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseManagerServiceImpl.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseManagerServiceImpl.java rename to components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseManagerServiceImpl.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/transport/AndroidSenseMQTTConnector.java b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/transport/AndroidSenseMQTTConnector.java similarity index 94% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/transport/AndroidSenseMQTTConnector.java rename to components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/transport/AndroidSenseMQTTConnector.java index ca6825b82..0b8f30e22 100644 --- a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/transport/AndroidSenseMQTTConnector.java +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/transport/AndroidSenseMQTTConnector.java @@ -141,6 +141,22 @@ public class AndroidSenseMQTTConnector extends MQTTTransportHandler { String sensorName = null; PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + DeviceManagementProviderService deviceManagementProviderService = + (DeviceManagementProviderService) ctx.getOSGiService(DeviceManagementProviderService.class, null); + if (deviceManagementProviderService != null) { + DeviceIdentifier identifier = new DeviceIdentifier(deviceId, AndroidSenseConstants.DEVICE_TYPE); + Device device = deviceManagementProviderService.getDevice(identifier); + if (device != null) { + String owner = device.getEnrolmentInfo().getOwner(); + ctx.setUsername(owner); + ctx.setTenantDomain(MultitenantUtils.getTenantDomain(owner), true); + } else { + return; + } + + } else { + return; + } ctx.setTenantDomain("carbon.super", true); for (SensorData sensor : sensorData) { if (sensor.key.equals("battery")) { @@ -254,6 +270,8 @@ public class AndroidSenseMQTTConnector extends MQTTTransportHandler { } } catch (JsonSyntaxException e) { throw new TransportHandlerException("Invalid message format " + mqttMessage.toString()); + } catch (DeviceManagementException e) { + throw new TransportHandlerException("Invalid device id " + deviceId); } finally { PrivilegedCarbonContext.endTenantFlow(); } diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/APIUtil.java b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/APIUtil.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/APIUtil.java rename to components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/APIUtil.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/DeviceData.java b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/DeviceData.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/DeviceData.java rename to components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/DeviceData.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/SensorData.java b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/SensorData.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/SensorData.java rename to components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/SensorData.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.service.impl/src/main/webapp/META-INF/permissions.xml b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/META-INF/permissions.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.service.impl/src/main/webapp/META-INF/permissions.xml rename to components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/META-INF/permissions.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.service.impl/src/main/webapp/META-INF/webapp-classloading.xml b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/META-INF/webapp-classloading.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.service.impl/src/main/webapp/META-INF/webapp-classloading.xml rename to components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/META-INF/webapp-classloading.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.service.impl/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/WEB-INF/cxf-servlet.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.service.impl/src/main/webapp/WEB-INF/cxf-servlet.xml rename to components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/WEB-INF/cxf-servlet.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.service.impl/src/main/webapp/WEB-INF/web.xml b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.service.impl/src/main/webapp/WEB-INF/web.xml rename to components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/WEB-INF/web.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.plugin/pom.xml b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.plugin/pom.xml index fc0d2f4c9..923d12a83 100644 --- a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.plugin/pom.xml +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.plugin/pom.xml @@ -56,18 +56,10 @@ org.osgi.framework, org.osgi.service.component, org.apache.commons.logging, - javax.xml.bind.*;resolution:=optional, javax.naming;resolution:=optional, javax.sql;resolution:=optional, - javax.xml.bind.annotation.*;resolution:=optional, - javax.xml.parsers;resolution:=optional, - javax.net;resolution:=optional, - javax.net.ssl;resolution:=optional, - org.w3c.dom;resolution:=optional, org.wso2.carbon.device.mgt.common.*, org.wso2.carbon.device.mgt.common, - org.wso2.carbon.context.*, - org.wso2.carbon.ndatasource.core, org.wso2.carbon.device.mgt.iot.*, org.wso2.carbon.device.mgt.extensions.feature.mgt.*, org.wso2.carbon.utils.* diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/plugin/impl/AndroidSenseManagerService.java b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/plugin/impl/AndroidSenseManagerService.java index b31b86531..a57c4e5e1 100644 --- a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/plugin/impl/AndroidSenseManagerService.java +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/plugin/impl/AndroidSenseManagerService.java @@ -30,6 +30,8 @@ import java.util.List; public class AndroidSenseManagerService implements DeviceManagementService { private DeviceManager deviceManager; + private static final String SUPER_TENANT_DOMAIN = "carbon.super"; + @Override public String getType() { return AndroidSenseConstants.DEVICE_TYPE; @@ -37,7 +39,7 @@ public class AndroidSenseManagerService implements DeviceManagementService { @Override public String getProviderTenantDomain() { - return "carbon.super"; + return SUPER_TENANT_DOMAIN; } @Override diff --git a/components/iot-plugins/androidsense-plugin/pom.xml b/components/iot-plugins/androidsense-plugin/pom.xml index 5dfd9d68e..3d310a1e2 100644 --- a/components/iot-plugins/androidsense-plugin/pom.xml +++ b/components/iot-plugins/androidsense-plugin/pom.xml @@ -34,7 +34,7 @@ org.wso2.carbon.device.mgt.iot.androidsense.analytics - org.wso2.carbon.device.mgt.iot.androidsense.service.impl + org.wso2.carbon.device.mgt.iot.androidsense.api org.wso2.carbon.device.mgt.iot.androidsense.plugin org.wso2.carbon.device.mgt.iot.androidsense.ui diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.service.impl/pom.xml b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/pom.xml similarity index 88% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.service.impl/pom.xml rename to components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/pom.xml index 5962d72b0..7d698874a 100644 --- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.service.impl/pom.xml +++ b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/pom.xml @@ -21,15 +21,14 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - device-mgt-iot-arduino + arduino-plugin org.wso2.carbon.devicemgt-plugins - 2.0.4-SNAPSHOT + 2.1.0-SNAPSHOT ../pom.xml 4.0.0 - org.wso2.carbon.device.mgt.iot.arduino.service.impl - 2.0.4-SNAPSHOT + org.wso2.carbon.device.mgt.iot.arduino.api war WSO2 Carbon - IoT Server Arduino Service API WSO2 Carbon - Arduino Service API Implementation @@ -55,12 +54,7 @@ org.wso2.carbon.devicemgt - org.wso2.carbon.apimgt.application.extension - 1.1.0-SNAPSHOT - - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.jwt.client.extension + org.wso2.carbon.identity.jwt.client.extension provided @@ -90,7 +84,6 @@ org.wso2.carbon.devicemgt org.wso2.carbon.device.mgt.analytics.data.publisher - 1.1.0-SNAPSHOT provided @@ -139,7 +132,7 @@ org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.arduino.plugin.impl + org.wso2.carbon.device.mgt.iot.arduino.plugin provided @@ -162,11 +155,6 @@ jsr311-api provided - - org.wso2.carbon.devicemgt - org.wso2.carbon.apimgt.annotations - provided - org.wso2.carbon.devicemgt org.wso2.carbon.apimgt.webapp.publisher diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoControllerService.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoControllerService.java similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoControllerService.java rename to components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoControllerService.java diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoControllerServiceImpl.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoControllerServiceImpl.java similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoControllerServiceImpl.java rename to components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoControllerServiceImpl.java diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoManagerService.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoManagerService.java similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoManagerService.java rename to components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoManagerService.java diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoManagerServiceImpl.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoManagerServiceImpl.java similarity index 97% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoManagerServiceImpl.java rename to components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoManagerServiceImpl.java index db9ad20be..3ef897128 100644 --- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoManagerServiceImpl.java +++ b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoManagerServiceImpl.java @@ -33,10 +33,10 @@ import org.wso2.carbon.device.mgt.iot.arduino.plugin.constants.ArduinoConstants; import org.wso2.carbon.device.mgt.iot.exception.DeviceControllerException; import org.wso2.carbon.device.mgt.iot.util.ZipArchive; import org.wso2.carbon.device.mgt.iot.util.ZipUtil; -import org.wso2.carbon.device.mgt.jwt.client.extension.JWTClient; -import org.wso2.carbon.device.mgt.jwt.client.extension.JWTClientManager; -import org.wso2.carbon.device.mgt.jwt.client.extension.dto.AccessTokenInfo; -import org.wso2.carbon.device.mgt.jwt.client.extension.exception.JWTClientException; +import org.wso2.carbon.identity.jwt.client.extension.JWTClient; +import org.wso2.carbon.identity.jwt.client.extension.JWTClientManager; +import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo; +import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException; import org.wso2.carbon.user.api.UserStoreException; import javax.ws.rs.core.Response; import java.nio.ByteBuffer; diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/dto/DeviceData.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/dto/DeviceData.java similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/dto/DeviceData.java rename to components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/dto/DeviceData.java diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/dto/SensorData.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/dto/SensorData.java similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/dto/SensorData.java rename to components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/dto/SensorData.java diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/exception/ArduinoException.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/exception/ArduinoException.java similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/exception/ArduinoException.java rename to components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/exception/ArduinoException.java diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/APIUtil.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/APIUtil.java similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/APIUtil.java rename to components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/APIUtil.java diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/ArduinoServiceUtils.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/ArduinoServiceUtils.java similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/ArduinoServiceUtils.java rename to components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/ArduinoServiceUtils.java diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.service.impl/src/main/webapp/META-INF/permissions.xml b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/webapp/META-INF/permissions.xml similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.service.impl/src/main/webapp/META-INF/permissions.xml rename to components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/webapp/META-INF/permissions.xml diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.service.impl/src/main/webapp/META-INF/webapp-classloading.xml b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/webapp/META-INF/webapp-classloading.xml similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.service.impl/src/main/webapp/META-INF/webapp-classloading.xml rename to components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/webapp/META-INF/webapp-classloading.xml diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.service.impl/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/webapp/WEB-INF/cxf-servlet.xml similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.service.impl/src/main/webapp/WEB-INF/cxf-servlet.xml rename to components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/webapp/WEB-INF/cxf-servlet.xml diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.service.impl/src/main/webapp/WEB-INF/web.xml b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.service.impl/src/main/webapp/WEB-INF/web.xml rename to components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/webapp/WEB-INF/web.xml diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin.impl/pom.xml b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/pom.xml similarity index 89% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin.impl/pom.xml rename to components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/pom.xml index 0c870b611..f32a29f81 100644 --- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin.impl/pom.xml +++ b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/pom.xml @@ -28,7 +28,7 @@ 4.0.0 - org.wso2.carbon.device.mgt.iot.arduino.plugin.impl + org.wso2.carbon.device.mgt.iot.arduino.plugin bundle WSO2 Carbon - IoT Server Arduino Management Plugin WSO2 Carbon - Arduino Management/Control Plugin Implementation @@ -64,18 +64,10 @@ org.osgi.framework, org.osgi.service.component, org.apache.commons.logging, - javax.xml.bind.*;resolution:=optional, javax.naming;resolution:=optional, javax.sql;resolution:=optional, - javax.xml.bind.annotation.*;resolution:=optional, - javax.xml.parsers;resolution:=optional, - javax.net;resolution:=optional, - javax.net.ssl;resolution:=optional, - org.w3c.dom;resolution:=optional, org.wso2.carbon.device.mgt.common.*, org.wso2.carbon.device.mgt.common, - org.wso2.carbon.context.*, - org.wso2.carbon.ndatasource.core, org.wso2.carbon.device.mgt.iot.*, org.wso2.carbon.device.mgt.extensions.feature.mgt.*, org.wso2.carbon.utils.* diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/constants/ArduinoConstants.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/constants/ArduinoConstants.java similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/constants/ArduinoConstants.java rename to components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/constants/ArduinoConstants.java diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/exception/ArduinoDeviceMgtPluginException.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/exception/ArduinoDeviceMgtPluginException.java similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/exception/ArduinoDeviceMgtPluginException.java rename to components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/exception/ArduinoDeviceMgtPluginException.java diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/ArduinoManager.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/ArduinoManager.java similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/ArduinoManager.java rename to components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/ArduinoManager.java diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/ArduinoManagerService.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/ArduinoManagerService.java similarity index 96% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/ArduinoManagerService.java rename to components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/ArduinoManagerService.java index 15f1ff60c..19ea0b8c5 100644 --- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/ArduinoManagerService.java +++ b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/ArduinoManagerService.java @@ -32,6 +32,7 @@ import java.util.List; public class ArduinoManagerService implements DeviceManagementService { private DeviceManager deviceManager; + private final static String DEVICE_TYPE_PROVIDER_DOMAIN = "carbon.super"; @Override public String getType() { @@ -40,7 +41,7 @@ public class ArduinoManagerService implements DeviceManagementService { @Override public String getProviderTenantDomain() { - return "carbon.super"; + return DEVICE_TYPE_PROVIDER_DOMAIN; } @Override diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/dao/ArduinoDAO.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/dao/ArduinoDAO.java similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/dao/ArduinoDAO.java rename to components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/dao/ArduinoDAO.java diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/dao/impl/ArduinoDeviceDAOImpl.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/dao/impl/ArduinoDeviceDAOImpl.java similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/dao/impl/ArduinoDeviceDAOImpl.java rename to components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/dao/impl/ArduinoDeviceDAOImpl.java diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/feature/ArduinoFeatureManager.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/feature/ArduinoFeatureManager.java similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/feature/ArduinoFeatureManager.java rename to components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/feature/ArduinoFeatureManager.java diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/util/ArduinoUtils.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/util/ArduinoUtils.java similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/util/ArduinoUtils.java rename to components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/util/ArduinoUtils.java diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/util/DeviceSchemaInitializer.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/util/DeviceSchemaInitializer.java similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/util/DeviceSchemaInitializer.java rename to components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/impl/util/DeviceSchemaInitializer.java diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/internal/ArduinoManagementServiceComponent.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/internal/ArduinoManagementServiceComponent.java similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/internal/ArduinoManagementServiceComponent.java rename to components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/plugin/internal/ArduinoManagementServiceComponent.java diff --git a/components/iot-plugins/arduino-plugin/pom.xml b/components/iot-plugins/arduino-plugin/pom.xml index 9d2d85743..6436080ff 100644 --- a/components/iot-plugins/arduino-plugin/pom.xml +++ b/components/iot-plugins/arduino-plugin/pom.xml @@ -35,8 +35,8 @@ org.wso2.carbon.device.mgt.iot.arduino.analytics - org.wso2.carbon.device.mgt.iot.arduino.service.impl - org.wso2.carbon.device.mgt.iot.arduino.plugin.impl + org.wso2.carbon.device.mgt.iot.arduino.api + org.wso2.carbon.device.mgt.iot.arduino.plugin org.wso2.carbon.device.mgt.iot.arduino.ui diff --git a/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.service.impl/pom.xml b/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.api/pom.xml similarity index 89% rename from components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.service.impl/pom.xml rename to components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.api/pom.xml index 25355cd3f..0c7304c63 100644 --- a/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.service.impl/pom.xml +++ b/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.api/pom.xml @@ -4,15 +4,14 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - device-mgt-iot-digitaldisplay + digital-display-plugin org.wso2.carbon.devicemgt-plugins - 2.0.4-SNAPSHOT + 2.1.0-SNAPSHOT ../pom.xml 4.0.0 - org.wso2.carbon.device.mgt.iot.digitaldisplay.service.impl - 2.0.4-SNAPSHOT + org.wso2.carbon.device.mgt.iot.digitaldisplay.api war WSO2 Carbon - IoT Server DigitalDisplay API WSO2 Carbon - Digital Display Service API Implementation @@ -49,23 +48,7 @@ org.wso2.carbon.devicemgt - org.wso2.carbon.apimgt.application.extension - 1.1.0-SNAPSHOT - - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.jwt.client.extension - provided - - - org.wso2.carbon.devicemgt - org.wso2.carbon.apimgt.application.extension - provided - - - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.analytics + org.wso2.carbon.device.mgt.analytics.data.publisher provided @@ -241,7 +224,7 @@ org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.jwt.client.extension + org.wso2.carbon.identity.jwt.client.extension provided diff --git a/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/DigitalDisplayControllerService.java b/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.api/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/DigitalDisplayControllerService.java similarity index 100% rename from components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/DigitalDisplayControllerService.java rename to components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.api/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/DigitalDisplayControllerService.java diff --git a/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/DigitalDisplayControllerServiceImpl.java b/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.api/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/DigitalDisplayControllerServiceImpl.java similarity index 100% rename from components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/DigitalDisplayControllerServiceImpl.java rename to components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.api/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/DigitalDisplayControllerServiceImpl.java diff --git a/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/DigitalDisplayManagerService.java b/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.api/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/DigitalDisplayManagerService.java similarity index 100% rename from components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/DigitalDisplayManagerService.java rename to components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.api/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/DigitalDisplayManagerService.java diff --git a/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/DigitalDisplayManagerServiceImpl.java b/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.api/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/DigitalDisplayManagerServiceImpl.java similarity index 97% rename from components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/DigitalDisplayManagerServiceImpl.java rename to components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.api/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/DigitalDisplayManagerServiceImpl.java index 6cfc34159..382a22c6f 100644 --- a/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/DigitalDisplayManagerServiceImpl.java +++ b/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.api/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/DigitalDisplayManagerServiceImpl.java @@ -34,10 +34,10 @@ import org.wso2.carbon.device.mgt.iot.digitaldisplay.plugin.constants.DigitalDis import org.wso2.carbon.device.mgt.iot.exception.DeviceControllerException; import org.wso2.carbon.device.mgt.iot.util.ZipArchive; import org.wso2.carbon.device.mgt.iot.util.ZipUtil; -import org.wso2.carbon.device.mgt.jwt.client.extension.JWTClient; -import org.wso2.carbon.device.mgt.jwt.client.extension.JWTClientManager; -import org.wso2.carbon.device.mgt.jwt.client.extension.dto.AccessTokenInfo; -import org.wso2.carbon.device.mgt.jwt.client.extension.exception.JWTClientException; +import org.wso2.carbon.identity.jwt.client.extension.JWTClient; +import org.wso2.carbon.identity.jwt.client.extension.JWTClientManager; +import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo; +import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException; import org.wso2.carbon.user.api.UserStoreException; import javax.ws.rs.core.Response; diff --git a/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/dto/DeviceJSON.java b/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.api/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/dto/DeviceJSON.java similarity index 100% rename from components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/dto/DeviceJSON.java rename to components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.api/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/dto/DeviceJSON.java diff --git a/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/exception/DigitalDisplayException.java b/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.api/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/exception/DigitalDisplayException.java similarity index 100% rename from components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/exception/DigitalDisplayException.java rename to components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.api/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/exception/DigitalDisplayException.java diff --git a/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/model/ScreenShotModel.java b/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.api/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/model/ScreenShotModel.java similarity index 100% rename from components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/model/ScreenShotModel.java rename to components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.api/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/model/ScreenShotModel.java diff --git a/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/util/APIUtil.java b/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.api/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/util/APIUtil.java similarity index 100% rename from components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/util/APIUtil.java rename to components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.api/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/util/APIUtil.java diff --git a/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/util/DigitalDisplayMQTTConnector.java b/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.api/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/util/DigitalDisplayMQTTConnector.java similarity index 100% rename from components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/util/DigitalDisplayMQTTConnector.java rename to components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.api/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/util/DigitalDisplayMQTTConnector.java diff --git a/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/websocket/DigitalDisplayWebSocketServerEndPoint.java b/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.api/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/websocket/DigitalDisplayWebSocketServerEndPoint.java similarity index 100% rename from components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/websocket/DigitalDisplayWebSocketServerEndPoint.java rename to components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.api/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/service/impl/websocket/DigitalDisplayWebSocketServerEndPoint.java diff --git a/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.service.impl/src/main/webapp/META-INF/permissions.xml b/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.api/src/main/webapp/META-INF/permissions.xml similarity index 100% rename from components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.service.impl/src/main/webapp/META-INF/permissions.xml rename to components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.api/src/main/webapp/META-INF/permissions.xml diff --git a/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.service.impl/src/main/webapp/META-INF/webapp-classloading.xml b/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.api/src/main/webapp/META-INF/webapp-classloading.xml similarity index 100% rename from components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.service.impl/src/main/webapp/META-INF/webapp-classloading.xml rename to components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.api/src/main/webapp/META-INF/webapp-classloading.xml diff --git a/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.service.impl/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.api/src/main/webapp/WEB-INF/cxf-servlet.xml similarity index 100% rename from components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.service.impl/src/main/webapp/WEB-INF/cxf-servlet.xml rename to components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.api/src/main/webapp/WEB-INF/cxf-servlet.xml diff --git a/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.service.impl/src/main/webapp/WEB-INF/web.xml b/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.api/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.service.impl/src/main/webapp/WEB-INF/web.xml rename to components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.api/src/main/webapp/WEB-INF/web.xml diff --git a/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.plugin/pom.xml b/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.plugin/pom.xml index 6cce70392..ec3538f13 100644 --- a/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.plugin/pom.xml +++ b/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.plugin/pom.xml @@ -47,18 +47,10 @@ org.osgi.framework, org.osgi.service.component, org.apache.commons.logging, - javax.xml.bind.*;resolution:=optional, javax.naming;resolution:=optional, javax.sql;resolution:=optional, - javax.xml.bind.annotation.*;resolution:=optional, - javax.xml.parsers;resolution:=optional, - javax.net, - javax.net.ssl, - org.w3c.dom, org.wso2.carbon.device.mgt.common.*, org.wso2.carbon.device.mgt.common, - org.wso2.carbon.context.*, - org.wso2.carbon.ndatasource.core, org.wso2.carbon.device.mgt.iot.*, org.wso2.carbon.device.mgt.extensions.feature.mgt.*, org.wso2.carbon.utils.* diff --git a/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/plugin/impl/DigitalDisplayManagerService.java b/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/plugin/impl/DigitalDisplayManagerService.java index 429694b41..593b16e91 100644 --- a/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/plugin/impl/DigitalDisplayManagerService.java +++ b/components/iot-plugins/digital-display-plugin/org.wso2.carbon.device.mgt.iot.digitaldisplay.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/plugin/impl/DigitalDisplayManagerService.java @@ -30,6 +30,8 @@ import java.util.List; public class DigitalDisplayManagerService implements DeviceManagementService{ private DeviceManager deviceManager; + private final static String DEVICE_TYPE_PROVIDER_DOMAIN = "carbon.super"; + @Override public String getType() { return DigitalDisplayConstants.DEVICE_TYPE; @@ -37,7 +39,7 @@ public class DigitalDisplayManagerService implements DeviceManagementService{ @Override public String getProviderTenantDomain() { - return "carbon.super"; + return DEVICE_TYPE_PROVIDER_DOMAIN; } @Override diff --git a/components/iot-plugins/digital-display-plugin/pom.xml b/components/iot-plugins/digital-display-plugin/pom.xml index 638c77813..cc0c36866 100644 --- a/components/iot-plugins/digital-display-plugin/pom.xml +++ b/components/iot-plugins/digital-display-plugin/pom.xml @@ -33,7 +33,7 @@ http://wso2.org - org.wso2.carbon.device.mgt.iot.digitaldisplay.service.impl + org.wso2.carbon.device.mgt.iot.digitaldisplay.api org.wso2.carbon.device.mgt.iot.digitaldisplay.plugin org.wso2.carbon.device.mgt.iot.digitaldisplay.ui diff --git a/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.service.impl/pom.xml b/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.api/pom.xml similarity index 94% rename from components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.service.impl/pom.xml rename to components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.api/pom.xml index c5ad56224..f70d61299 100644 --- a/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.service.impl/pom.xml +++ b/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.api/pom.xml @@ -1,14 +1,13 @@ - device-mgt-iot-droneanalyzer + drone-analyzer-plugin org.wso2.carbon.devicemgt-plugins - 2.0.4-SNAPSHOT + 2.1.0-SNAPSHOT ../pom.xml 4.0.0 - org.wso2.carbon.device.mgt.iot.droneanalyzer.service.impl - 2.0.4-SNAPSHOT + org.wso2.carbon.device.mgt.iot.droneanalyzer.api war WSO2 Carbon - IoT Server Drone Analyzer API http://maven.apache.org @@ -35,7 +34,6 @@ org.wso2.carbon.devicemgt org.wso2.carbon.device.mgt.analytics.data.publisher - 1.1.0-SNAPSHOT provided @@ -231,12 +229,7 @@ org.wso2.carbon.devicemgt - org.wso2.carbon.apimgt.application.extension - 1.1.0-SNAPSHOT - - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.jwt.client.extension + org.wso2.carbon.identity.jwt.client.extension provided diff --git a/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/DroneControllerService.java b/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.api/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/DroneControllerService.java similarity index 100% rename from components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/DroneControllerService.java rename to components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.api/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/DroneControllerService.java diff --git a/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/DroneControllerServiceImpl.java b/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.api/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/DroneControllerServiceImpl.java similarity index 100% rename from components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/DroneControllerServiceImpl.java rename to components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.api/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/DroneControllerServiceImpl.java diff --git a/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/DroneManagerService.java b/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.api/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/DroneManagerService.java similarity index 100% rename from components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/DroneManagerService.java rename to components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.api/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/DroneManagerService.java diff --git a/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/DroneManagerServiceImpl.java b/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.api/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/DroneManagerServiceImpl.java similarity index 97% rename from components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/DroneManagerServiceImpl.java rename to components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.api/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/DroneManagerServiceImpl.java index 1cd052644..d9fbfb44b 100644 --- a/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/DroneManagerServiceImpl.java +++ b/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.api/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/DroneManagerServiceImpl.java @@ -35,10 +35,10 @@ import org.wso2.carbon.device.mgt.iot.droneanalyzer.plugin.constants.DroneConsta import org.wso2.carbon.device.mgt.iot.exception.DeviceControllerException; import org.wso2.carbon.device.mgt.iot.util.ZipArchive; import org.wso2.carbon.device.mgt.iot.util.ZipUtil; -import org.wso2.carbon.device.mgt.jwt.client.extension.JWTClient; -import org.wso2.carbon.device.mgt.jwt.client.extension.JWTClientManager; -import org.wso2.carbon.device.mgt.jwt.client.extension.dto.AccessTokenInfo; -import org.wso2.carbon.device.mgt.jwt.client.extension.exception.JWTClientException; +import org.wso2.carbon.identity.jwt.client.extension.JWTClient; +import org.wso2.carbon.identity.jwt.client.extension.JWTClientManager; +import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo; +import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException; import org.wso2.carbon.user.api.UserStoreException; import javax.ws.rs.core.Response; import java.nio.ByteBuffer; diff --git a/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/DroneRealTimeService.java b/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.api/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/DroneRealTimeService.java similarity index 100% rename from components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/DroneRealTimeService.java rename to components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.api/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/DroneRealTimeService.java diff --git a/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/exception/DroneAnalyzerException.java b/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.api/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/exception/DroneAnalyzerException.java similarity index 100% rename from components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/exception/DroneAnalyzerException.java rename to components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.api/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/exception/DroneAnalyzerException.java diff --git a/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/transport/DroneAnalyzerXMPPConnector.java b/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.api/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/transport/DroneAnalyzerXMPPConnector.java similarity index 100% rename from components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/transport/DroneAnalyzerXMPPConnector.java rename to components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.api/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/transport/DroneAnalyzerXMPPConnector.java diff --git a/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/trasformer/MessageTransformer.java b/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.api/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/trasformer/MessageTransformer.java similarity index 100% rename from components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/trasformer/MessageTransformer.java rename to components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.api/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/trasformer/MessageTransformer.java diff --git a/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/util/APIUtil.java b/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.api/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/util/APIUtil.java similarity index 100% rename from components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/util/APIUtil.java rename to components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.api/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/util/APIUtil.java diff --git a/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/util/DroneAnalyzerServiceUtils.java b/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.api/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/util/DroneAnalyzerServiceUtils.java similarity index 100% rename from components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/util/DroneAnalyzerServiceUtils.java rename to components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.api/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/service/impl/util/DroneAnalyzerServiceUtils.java diff --git a/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.service.impl/src/main/webapp/META-INF/permissions.xml b/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.api/src/main/webapp/META-INF/permissions.xml similarity index 100% rename from components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.service.impl/src/main/webapp/META-INF/permissions.xml rename to components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.api/src/main/webapp/META-INF/permissions.xml diff --git a/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.service.impl/src/main/webapp/META-INF/webapp-classloading.xml b/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.api/src/main/webapp/META-INF/webapp-classloading.xml similarity index 100% rename from components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.service.impl/src/main/webapp/META-INF/webapp-classloading.xml rename to components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.api/src/main/webapp/META-INF/webapp-classloading.xml diff --git a/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.service.impl/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.api/src/main/webapp/WEB-INF/cxf-servlet.xml similarity index 100% rename from components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.service.impl/src/main/webapp/WEB-INF/cxf-servlet.xml rename to components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.api/src/main/webapp/WEB-INF/cxf-servlet.xml diff --git a/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.service.impl/src/main/webapp/WEB-INF/web.xml b/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.api/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.service.impl/src/main/webapp/WEB-INF/web.xml rename to components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.api/src/main/webapp/WEB-INF/web.xml diff --git a/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.plugin/pom.xml b/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.plugin/pom.xml index a3482fca4..e1f404772 100644 --- a/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.plugin/pom.xml +++ b/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.plugin/pom.xml @@ -49,18 +49,10 @@ org.osgi.framework, org.osgi.service.component, org.apache.commons.logging, - javax.xml.bind.*;resolution:=optional, javax.naming;resolution:=optional, javax.sql;resolution:=optional, - javax.xml.bind.annotation.*;resolution:=optional, - javax.xml.parsers;resolution:=optional, - javax.net;resolution:=optional, - javax.net.ssl;resolution:=optional, - org.w3c.dom;resolution:=optional, org.wso2.carbon.device.mgt.common.*, org.wso2.carbon.device.mgt.common, - org.wso2.carbon.context.*, - org.wso2.carbon.ndatasource.core, org.wso2.carbon.device.mgt.iot.*, org.wso2.carbon.device.mgt.extensions.feature.mgt.*, org.wso2.carbon.utils.* diff --git a/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/plugin/impl/DroneAnalyzerManagerService.java b/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/plugin/impl/DroneAnalyzerManagerService.java index 5af1a9008..3890febc1 100644 --- a/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/plugin/impl/DroneAnalyzerManagerService.java +++ b/components/iot-plugins/drone-analyzer-plugin/org.wso2.carbon.device.mgt.iot.droneanalyzer.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/droneanalyzer/plugin/impl/DroneAnalyzerManagerService.java @@ -29,9 +29,10 @@ import org.wso2.carbon.device.mgt.iot.droneanalyzer.plugin.constants.DroneConsta import java.util.List; - public class DroneAnalyzerManagerService implements DeviceManagementService { private DeviceManager deviceManager; + private final static String DEVICE_TYPE_PROVIDER_DOMAIN = "carbon.super"; + @Override public String getType() { return DroneConstants.DEVICE_TYPE; @@ -95,7 +96,7 @@ public class DroneAnalyzerManagerService implements DeviceManagementService { @Override public String getProviderTenantDomain() { - return "carbon.super"; + return DEVICE_TYPE_PROVIDER_DOMAIN; } @Override diff --git a/components/iot-plugins/drone-analyzer-plugin/pom.xml b/components/iot-plugins/drone-analyzer-plugin/pom.xml index 63728b11c..67a0f721f 100644 --- a/components/iot-plugins/drone-analyzer-plugin/pom.xml +++ b/components/iot-plugins/drone-analyzer-plugin/pom.xml @@ -34,7 +34,7 @@ org.wso2.carbon.device.mgt.iot.droneanalyzer.ui - org.wso2.carbon.device.mgt.iot.droneanalyzer.service.impl + org.wso2.carbon.device.mgt.iot.droneanalyzer.api org.wso2.carbon.device.mgt.iot.droneanalyzer.plugin diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.api/src/main/java/org/wso2/carbon/device/mgt/iot/api/DeviceUsageDTO.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.api/src/main/java/org/wso2/carbon/device/mgt/iot/api/DeviceUsageDTO.java deleted file mode 100644 index 222f00d41..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.api/src/main/java/org/wso2/carbon/device/mgt/iot/api/DeviceUsageDTO.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.device.mgt.iot.api; - -public class DeviceUsageDTO { - - private String time; - private String value; - - public String getTime() { - return time; - } - - public void setTime(String time) { - this.time = time; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - -} diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.api/src/main/java/org/wso2/carbon/device/mgt/iot/api/DevicesManagerService.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.api/src/main/java/org/wso2/carbon/device/mgt/iot/api/DevicesManagerService.java index e1f8431bc..ee5333b69 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.api/src/main/java/org/wso2/carbon/device/mgt/iot/api/DevicesManagerService.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.api/src/main/java/org/wso2/carbon/device/mgt/iot/api/DevicesManagerService.java @@ -20,12 +20,7 @@ package org.wso2.carbon.device.mgt.iot.api; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.CarbonContext; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.common.Device; -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.EnrolmentInfo; +import org.wso2.carbon.device.mgt.common.*; import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration; import org.wso2.carbon.device.mgt.common.license.mgt.License; import org.wso2.carbon.device.mgt.core.dto.DeviceType; @@ -33,56 +28,20 @@ import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.iot.exception.DeviceControllerException; import org.wso2.carbon.device.mgt.iot.sensormgt.SensorDataManager; import org.wso2.carbon.device.mgt.iot.sensormgt.SensorRecord; - -import javax.jws.WebService; -import javax.servlet.http.HttpServletResponse; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.FormParam; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; +import org.wso2.carbon.device.mgt.iot.util.APIUtil; +import javax.ws.rs.*; import javax.ws.rs.core.Response; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; -@WebService public class DevicesManagerService { - - private static Log log = LogFactory.getLog(DevicesManagerService.class); - - @Context //injected response proxy supporting multiple thread - private HttpServletResponse response; - - private PrivilegedCarbonContext ctx; - private DeviceManagementProviderService getServiceProvider() { - String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain(); - PrivilegedCarbonContext.startTenantFlow(); - ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - ctx.setTenantDomain(tenantDomain, true); - if (log.isDebugEnabled()) { - log.debug("Getting thread local carbon context for tenant domain: " + tenantDomain); - } - return (DeviceManagementProviderService) ctx.getOSGiService(DeviceManagementProviderService.class, null); - } +public class DevicesManagerService { - private void endTenantFlow() { - PrivilegedCarbonContext.endTenantFlow(); - ctx = null; - if (log.isDebugEnabled()) { - log.debug("Tenant flow ended"); - } - } + private static final Log log = LogFactory.getLog(DevicesManagerService.class); - private Device[] getActiveDevices(List devices){ + private Device[] getActiveDevices(List devices) { List activeDevices = new ArrayList<>(); if (devices != null) { for (Device device : devices) { @@ -94,29 +53,27 @@ import java.util.List; return activeDevices.toArray(new Device[activeDevices.size()]); } - @Path("/device/user/{username}/all") + @Path("/devices/users/{userName}") @GET - @Consumes("application/json") @Produces("application/json") - public Device[] getDevicesOfUser(@PathParam("username") String username) { + public Response getDevicesOfUser(@PathParam("userName") String userName) { try { - List devices = this.getServiceProvider().getDevicesOfUser(username); - return this.getActiveDevices(devices); + List devices = APIUtil.getDeviceManagementService() + .getDevicesOfUser(userName); + Device[] devicesArr = this.getActiveDevices(devices); + return Response.status(Response.Status.OK).entity(devicesArr).build(); } catch (DeviceManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return null; - } finally { - this.endTenantFlow(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } - @Path("/device/user/{username}/all/count") + @Path("/devices/users/{userName}/count") @GET - @Consumes("application/json") @Produces("application/json") - public int getDeviceCount(@PathParam("username") String username){ + public Response getDeviceCount(@PathParam("userName") String userName) { try { - List devices = this.getServiceProvider().getDevicesOfUser(username); + List devices = APIUtil.getDeviceManagementService() + .getDevicesOfUser(userName); if (devices != null) { List activeDevices = new ArrayList<>(); for (Device device : devices) { @@ -124,191 +81,182 @@ import java.util.List; activeDevices.add(device); } } - return activeDevices.size(); + return Response.status(Response.Status.OK).entity(activeDevices.size()).build(); } - return 0; + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } catch (DeviceManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return 0; - } finally { - this.endTenantFlow(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } - @Path("/device/type/{type}/identifier/{identifier}") + @Path("/devices/{deviceType}/{identifier}") @GET - @Consumes("application/json") @Produces("application/json") - public Device getDevice(@PathParam("type") String type, @PathParam("identifier") String identifier){ + public Response getDevice(@PathParam("deviceType") String deviceType, + @PathParam("identifier") String identifier) { - try{ + try { DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); deviceIdentifier.setId(identifier); - deviceIdentifier.setType(type); - return this.getServiceProvider().getDevice(deviceIdentifier); + deviceIdentifier.setType(deviceType); + Device device = APIUtil.getDeviceManagementService().getDevice( + deviceIdentifier); + if (device != null) { + return Response.status(Response.Status.OK).entity(device).build(); + } else { + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + } } catch (DeviceManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return null; - } finally { - this.endTenantFlow(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } - @Path("/device/type/all") + @Path("/devices/types") @GET - @Consumes("application/json") @Produces("application/json") - public DeviceType[] getDeviceTypes(){ - try{ - List deviceTypes = this.getServiceProvider().getAvailableDeviceTypes(); - return deviceTypes.toArray(new DeviceType[deviceTypes.size()]); + public Response getDeviceTypes() { + try { + List deviceTypes = APIUtil.getDeviceManagementService() + .getAvailableDeviceTypes(); + DeviceType[] deviceTypesArr = deviceTypes.toArray(new DeviceType[deviceTypes.size()]); + return Response.status(Response.Status.OK).entity(deviceTypesArr).build(); } catch (DeviceManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return null; - } finally { - this.endTenantFlow(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } - @Path("/device/type/{type}/all") + @Path("/devices/{deviceType}") @GET - @Consumes("application/json") @Produces("application/json") - public Device[] getAllDevices(@PathParam("type") String type){ - try{ - List devices = this.getServiceProvider().getAllDevices(type); - return this.getActiveDevices(devices); + public Response getAllDevices(@PathParam("deviceType") String deviceType) { + try { + List devices = APIUtil.getDeviceManagementService() + .getAllDevices(deviceType); + Device[] devicesArr = this.getActiveDevices(devices); + return Response.status(Response.Status.OK).entity(devicesArr).build(); } catch (DeviceManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return null; - } finally { - this.endTenantFlow(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } - @Path("/device/all") + @Path("/devices") @GET - @Consumes("application/json") @Produces("application/json") - public Device[] getAllDevices(){ - try{ - List devices = this.getServiceProvider().getAllDevices(); - return this.getActiveDevices(devices); + public Response getAllDevices() { + try { + List devices = APIUtil.getDeviceManagementService() + .getAllDevices(); + return Response.status(Response.Status.OK).entity(this.getActiveDevices(devices)).build(); } catch (DeviceManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return null; - } finally { - this.endTenantFlow(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } - @Path("/device/type/{type}/config") + @Path("/devices/{deviceType}/config") @GET - @Consumes("application/json") @Produces("application/json") - public TenantConfiguration getConfiguration(@PathParam("type") String type){ + public Response getConfiguration(@PathParam("deviceType") String deviceType) { try { - return this.getServiceProvider().getConfiguration(type); + TenantConfiguration tenantConfiguration = APIUtil.getDeviceManagementService().getConfiguration(deviceType); + if (tenantConfiguration != null) { + return Response.status(Response.Status.OK).entity(tenantConfiguration).build(); + } else { + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + } } catch (DeviceManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return null; - } finally { - this.endTenantFlow(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } - @Path("/device/role/{role}/all") + @Path("/devices/search/role") @GET - @Consumes("application/json") @Produces("application/json") - public Device[] getAllDevicesOfRole(@PathParam("role") String roleName){ - try{ - List devices = this.getServiceProvider().getAllDevicesOfRole(roleName); - return this.getActiveDevices(devices); + public Response getAllDevicesOfRole(@QueryParam("roleName") String roleName) { + try { + List devices = APIUtil.getDeviceManagementService() + .getAllDevicesOfRole(roleName); + Device[] devicesArr = this.getActiveDevices(devices); + return Response.status(Response.Status.OK).entity(devicesArr).build(); } catch (DeviceManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return null; - } finally { - this.endTenantFlow(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } - @Path("/device/name/{name}/all") + @Path("/devices/search/name") @GET - @Consumes("application/json") @Produces("application/json") - public Device[] getDevicesByName(@PathParam("name") String name) { - try{ - List devices = this.getServiceProvider().getDevicesByName(name); - return this.getActiveDevices(devices); + public Response getDevicesByName(@PathParam("deviceName") String deviceName) { + try { + List devices = APIUtil.getDeviceManagementService() + .getDevicesByName(deviceName); + Device[] devicesArr = this.getActiveDevices(devices); + return Response.status(Response.Status.OK).entity(devicesArr).build(); } catch (DeviceManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return null; - } finally { - this.endTenantFlow(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } - @Path("/device/type/{type}/identifier/{identifier}/status") + @Path("/devices/{deviceType}/{identifier}/status") @PUT @Consumes("application/json") @Produces("application/json") - void updateDeviceEnrolmentInfo(@PathParam("type") String type, @PathParam("identifier") String identifier, - @FormParam("status") EnrolmentInfo.Status status) { - DeviceManagementProviderService providerService = this.getServiceProvider(); - DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); - deviceIdentifier.setType(type); - deviceIdentifier.setId(identifier); + public Response updateDeviceEnrolmentInfo(@PathParam("deviceType") String deviceType, + @PathParam("identifier") String identifier, + @FormParam("status") EnrolmentInfo.Status status) { try { + DeviceManagementProviderService providerService = APIUtil.getDeviceManagementService(); + DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); + deviceIdentifier.setType(deviceType); + deviceIdentifier.setId(identifier); Device device = providerService.getDevice(deviceIdentifier); providerService.updateDeviceEnrolmentInfo(device, status); + return Response.status(Response.Status.NO_CONTENT).build(); } catch (DeviceManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - } finally { - this.endTenantFlow(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } - @Path("/device/status/{status}/all") + @Path("/devices/search/status") @GET - @Consumes("application/json") @Produces("application/json") - public Device[] getDevicesByStatus(@PathParam("status") EnrolmentInfo.Status status) { - try{ - List devices = this.getServiceProvider().getDevicesByStatus(status); - return this.getActiveDevices(devices); + public Response getDevicesByStatus(@QueryParam("status") EnrolmentInfo.Status status) { + try { + List devices = APIUtil.getDeviceManagementService() + .getDevicesByStatus(status); + Device[] devicesArr = this.getActiveDevices(devices); + return Response.status(Response.Status.OK).entity(devicesArr).build(); } catch (DeviceManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return null; - } finally { - this.endTenantFlow(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } - @Path("/device/type/{type}/license") + @Path("/devices/{deviceType}/license") @GET - @Consumes("application/json") @Produces("application/json") - public License getLicense(@PathParam("type") String type, @QueryParam("languageCode") String languageCode) { - try{ - return this.getServiceProvider().getLicense(type, languageCode); + public Response getLicense(@PathParam("deviceType") String deviceType, + @QueryParam("languageCode") String languageCode) { + try { + License license = APIUtil.getDeviceManagementService().getLicense( + deviceType, languageCode); + if (license != null) { + return Response.status(Response.Status.OK).entity(license).build(); + } else { + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + } } catch (DeviceManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return null; - } finally { - this.endTenantFlow(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } - @Path("/device/type/{type}/license") + @Path("/devices/{deviceType}/license") @POST - @Consumes("application/json") @Produces("application/json") - public void addLicense(@PathParam("type") String type, @FormParam("provider") String provider, - @FormParam("name") String name, @FormParam("version") String version, - @FormParam("language") String language, @FormParam("validFrom") Date validFrom, - @FormParam("validTo") Date validTo, @FormParam("text") String text) { - try{ + public Response addLicense(@PathParam("deviceType") String deviceType, + @FormParam("provider") String provider, @FormParam("name") String name, + @FormParam("version") String version, @FormParam("language") String language, + @FormParam("validFrom") Date validFrom, @FormParam("validTo") Date validTo, + @FormParam("text") String text) { + try { License license = new License(); license.setProvider(provider); license.setName(name); @@ -317,26 +265,27 @@ import java.util.List; license.setValidFrom(validFrom); license.setValidTo(validTo); license.setText(text); - this.getServiceProvider().addLicense(type, license); + APIUtil.getDeviceManagementService().addLicense(deviceType, license); + return Response.status(Response.Status.NO_CONTENT).build(); } catch (DeviceManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - } finally { - this.endTenantFlow(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } - @Path("/device/type/{type}/identifier/{identifier}") + @Path("/devices/{deviceType}/{identifier}/enrollment") @PUT - @Consumes("application/json") @Produces("application/json") - boolean modifyEnrollment(@PathParam("type") String type, @PathParam("identifier") String identifier, - @FormParam("name") String name, @FormParam("description") String description, - @FormParam("enrollmentId") int enrollmentId, - @FormParam("dateOfEnrolment") long dateOfEnrolment, - @FormParam("dateOfLastUpdate") long dateOfLastUpdate, - @FormParam("ownership") EnrolmentInfo.OwnerShip ownership, - @FormParam("status") EnrolmentInfo.Status status, - @FormParam("owner") String owner) { + public Response modifyEnrollment(@PathParam("deviceType") String deviceType, + @PathParam("identifier") String identifier, + @FormParam("name") String name, + @FormParam("description") String description, + @FormParam("groupId") int groupId, + @FormParam("enrollmentId") int enrollmentId, + @FormParam("dateOfEnrolment") long dateOfEnrolment, + @FormParam("dateOfLastUpdate") long dateOfLastUpdate, + @FormParam("ownership") EnrolmentInfo.OwnerShip ownership, + @FormParam("status") EnrolmentInfo.Status status, + @FormParam("owner") String owner) { EnrolmentInfo enrolmentInfo = new EnrolmentInfo(); enrolmentInfo.setId(enrollmentId); @@ -347,33 +296,36 @@ import java.util.List; enrolmentInfo.setOwner(owner); Device device = new Device(); - device.setType(type); + device.setType(deviceType); device.setDeviceIdentifier(identifier); device.setName(name); device.setDescription(description); device.setEnrolmentInfo(enrolmentInfo); try { - return this.getServiceProvider().modifyEnrollment(device); + boolean isModified = APIUtil.getDeviceManagementService() + .modifyEnrollment(device); + if (isModified) { + return Response.status(Response.Status.NO_CONTENT).build(); + } else { + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + } } catch (DeviceManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return false; - } finally { - this.endTenantFlow(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } - @Path("/device") + @Path("/devices/{deviceType}/{identifier}/enrollment") @POST - @Consumes("application/json") @Produces("application/json") - boolean enrollDevice(@FormParam("type") String type, @FormParam("identifier") String identifier, - @FormParam("name") String name, @FormParam("description") String description, - @FormParam("enrollmentId") int enrollmentId, - @FormParam("dateOfEnrolment") long dateOfEnrolment, - @FormParam("dateOfLastUpdate") long dateOfLastUpdate, - @FormParam("ownership") EnrolmentInfo.OwnerShip ownership, - @FormParam("status") EnrolmentInfo.Status status, - @FormParam("owner") String owner) { + public Response enrollDevice(@PathParam("deviceType") String deviceType, @PathParam("identifier") String identifier, + @FormParam("name") String name, @FormParam("description") String description, + @FormParam("groupId") int groupId, + @FormParam("enrollmentId") int enrollmentId, + @FormParam("dateOfEnrolment") long dateOfEnrolment, + @FormParam("dateOfLastUpdate") long dateOfLastUpdate, + @FormParam("ownership") EnrolmentInfo.OwnerShip ownership, + @FormParam("status") EnrolmentInfo.Status status, + @FormParam("owner") String owner) { EnrolmentInfo enrolmentInfo = new EnrolmentInfo(); enrolmentInfo.setId(enrollmentId); @@ -384,197 +336,232 @@ import java.util.List; enrolmentInfo.setOwner(owner); Device device = new Device(); - device.setType(type); + device.setType(deviceType); device.setDeviceIdentifier(identifier); device.setName(name); device.setDescription(description); device.setEnrolmentInfo(enrolmentInfo); try { - return this.getServiceProvider().enrollDevice(device); + boolean isModified = APIUtil.getDeviceManagementService().enrollDevice( + device); + if (isModified) { + return Response.status(Response.Status.NO_CONTENT).build(); + } else { + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + } } catch (DeviceManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return false; - } finally { - this.endTenantFlow(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } - @Path("/device/tenantconfiguration") + @Path("/devices/tenant/configuration") @GET - @Consumes("application/json") @Produces("application/json") - public TenantConfiguration getConfiguration(){ + public Response getTenantConfiguration() { try { - return this.getServiceProvider().getConfiguration(); + TenantConfiguration tenantConfiguration = APIUtil.getDeviceManagementService().getConfiguration(); + if (tenantConfiguration != null) { + return Response.status(Response.Status.OK).entity(tenantConfiguration).build(); + } else { + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + } } catch (DeviceManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return null; - } finally { - this.endTenantFlow(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } - @Path("/device/tenantconfiguration") + @Path("/devices/tenant/configuration") @POST - @Consumes("application/json") @Produces("application/json") - public boolean saveConfiguration(@FormParam("tenantConfiguration") TenantConfiguration tenantConfiguration){ + public Response saveTenantConfiguration(@FormParam("tenantConfiguration") TenantConfiguration tenantConfiguration) { try { - return this.getServiceProvider().saveConfiguration(tenantConfiguration); + boolean isSaved = APIUtil.getDeviceManagementService() + .saveConfiguration(tenantConfiguration); + if (isSaved) { + return Response.status(Response.Status.NO_CONTENT).build(); + } else { + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + } } catch (DeviceManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return false; - } finally { - this.endTenantFlow(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } - @Path("/device/type/{type}/identifier/{identifier}") + @Path("/devices/{deviceType}/{identifier}") @DELETE - @Consumes("application/json") @Produces("application/json") - public boolean disenrollDevice(@PathParam("type") String type, @PathParam("identifier") String identifier){ + public Response disenrollDevice(@PathParam("deviceType") String deviceType, + @PathParam("identifier") String identifier) { DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); - deviceIdentifier.setType(type); + deviceIdentifier.setType(deviceType); deviceIdentifier.setId(identifier); try { - return this.getServiceProvider().disenrollDevice(deviceIdentifier); + boolean isDisEnrolled = APIUtil.getDeviceManagementService() + .disenrollDevice(deviceIdentifier); + if (isDisEnrolled) { + return Response.status(Response.Status.NO_CONTENT).build(); + } else { + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + } } catch (DeviceManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return false; - } finally { - this.endTenantFlow(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } - @Path("/device/type/{type}/identifier/{identifier}/enrolled") + @Path("/devices/{deviceType}/{identifier}/enrollment") @GET - @Consumes("application/json") @Produces("application/json") - public boolean isEnrolled(@PathParam("type") String type, @PathParam("identifier") String identifier){ + public Response isEnrolled(@PathParam("deviceType") String deviceType, + @PathParam("identifier") String identifier) { DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); - deviceIdentifier.setType(type); + deviceIdentifier.setType(deviceType); deviceIdentifier.setId(identifier); try { - return this.getServiceProvider().isEnrolled(deviceIdentifier); + boolean isEnrolled = APIUtil.getDeviceManagementService().isEnrolled( + deviceIdentifier); + if (isEnrolled) { + return Response.status(Response.Status.NO_CONTENT).build(); + } else { + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + } } catch (DeviceManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return false; - } finally { - this.endTenantFlow(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } - @Path("/device/type/{type}/identifier/{identifier}/active") + + @Path("/devices/{deviceType}/{identifier}/status") @GET - @Consumes("application/json") @Produces("application/json") - public boolean isActive(@PathParam("type") String type, @PathParam("identifier") String identifier){ + public Response isActive(@PathParam("deviceType") String deviceType, + @PathParam("identifier") String identifier) { DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); - deviceIdentifier.setType(type); + deviceIdentifier.setType(deviceType); deviceIdentifier.setId(identifier); try { - return this.getServiceProvider().isActive(deviceIdentifier); + boolean isActive = APIUtil.getDeviceManagementService().isActive( + deviceIdentifier); + if (isActive) { + return Response.status(Response.Status.NO_CONTENT).build(); + } else { + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + } } catch (DeviceManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return false; - } finally { - this.endTenantFlow(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } - @Path("/device/type/{type}/identifier/{identifier}/active") + @Path("/devices/{deviceType}/{identifier}/status") @PUT @Consumes("application/json") @Produces("application/json") - public boolean setActive(@PathParam("type") String type, @PathParam("identifier") String identifier, - @FormParam("status") boolean status){ + public Response changeDeviceStatus(@PathParam("deviceType") String deviceType, + @PathParam("identifier") String identifier, + @FormParam("status") boolean status) { DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); - deviceIdentifier.setType(type); + deviceIdentifier.setType(deviceType); deviceIdentifier.setId(identifier); try { - return this.getServiceProvider().setActive(deviceIdentifier, status); + boolean isActivated = APIUtil.getDeviceManagementService().setActive( + deviceIdentifier, status); + if (isActivated) { + return Response.status(Response.Status.NO_CONTENT).build(); + } else { + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + } } catch (DeviceManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return false; - } finally { - this.endTenantFlow(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } - @Path("/device/type/{type}/identifier/{identifier}/ownership") + @Path("/devices/{deviceType}/{identifier}/ownership") @PUT @Consumes("application/json") @Produces("application/json") - public boolean setOwnership(@PathParam("type") String type, @PathParam("identifier") String identifier, - @FormParam("ownership") String ownership){ + public Response setOwnership(@PathParam("deviceType") String deviceType, + @PathParam("identifier") String identifier, + @FormParam("ownership") String ownership) { DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); - deviceIdentifier.setType(type); + deviceIdentifier.setType(deviceType); deviceIdentifier.setId(identifier); try { - return this.getServiceProvider().setOwnership(deviceIdentifier, ownership); + boolean isOwnershipChanged = APIUtil.getDeviceManagementService() + .setOwnership(deviceIdentifier, ownership); + if (isOwnershipChanged) { + return Response.status(Response.Status.NO_CONTENT).build(); + } else { + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + } } catch (DeviceManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return false; - } finally { - this.endTenantFlow(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } - @Path("/device/type/{type}/identifier/{identifier}/status") + @Path("/devices/{deviceType}/{identifier}/enrollment/status") @PUT @Consumes("application/json") @Produces("application/json") - public boolean setStatus(@PathParam("type") String type, @PathParam("identifier") String identifier, - @FormParam("owner") String owner, @FormParam("status") EnrolmentInfo.Status status){ + public Response setStatus(@PathParam("deviceType") String deviceType, + @PathParam("identifier") String identifier, @FormParam("owner") String owner, + @FormParam("status") EnrolmentInfo.Status status) { DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); - deviceIdentifier.setType(type); + deviceIdentifier.setType(deviceType); deviceIdentifier.setId(identifier); try { - return this.getServiceProvider().setStatus(deviceIdentifier, owner, status); + boolean isStatusChanged = APIUtil.getDeviceManagementService() + .setStatus(deviceIdentifier, owner, status); + if (isStatusChanged) { + return Response.status(Response.Status.NO_CONTENT).build(); + } else { + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + } } catch (DeviceManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return false; - } finally { - this.endTenantFlow(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } - @Path("/device/type/{type}/identifier/{identifier}/sensor/{sensorName}") + @Path("/devices/{deviceType}/{identifier}/sensors/{sensorName}") @POST @Consumes("application/json") @Produces("application/json") - public boolean setSensorValue(@PathParam("type") String type, @PathParam("identifier") String deviceId, - @PathParam("sensorName") String sensorName, - @HeaderParam("sensorValue") String sensorValue){ - - try { - return SensorDataManager.getInstance().setSensorRecord(deviceId, sensorName, sensorValue, Calendar - .getInstance().getTimeInMillis()); - } finally { - this.endTenantFlow(); + public Response setSensorValue(@PathParam("deviceType") String deviceType, + @PathParam("identifier") String deviceId, + @PathParam("sensorName") String sensorName, + @FormParam("sensorValue") String sensorValue) { + boolean isValueSet = SensorDataManager.getInstance().setSensorRecord(deviceId, sensorName, + sensorValue, Calendar.getInstance().getTimeInMillis()); + if (isValueSet) { + return Response.status(Response.Status.NO_CONTENT).build(); + } else { + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } - @Path("/device/type/{type}/identifier/{identifier}/sensor/{sensorName}") + @Path("/devices/{deviceType}/{identifier}/sensors/{sensorName}") @GET @Consumes("application/json") @Produces("application/json") - public SensorRecord getSensorValue(@PathParam("type") String type, @PathParam("identifier") String deviceId, - @PathParam("sensorName") String sensorName, @HeaderParam("defaultValue") String defaultValue){ + public Response getSensorValue(@PathParam("deviceType") String deviceType, + @PathParam("identifier") String deviceId, + @PathParam("sensorName") String sensorName, + @QueryParam("defaultValue") String defaultValue) { try { - return SensorDataManager.getInstance().getSensorRecord(deviceId, sensorName); + SensorRecord sensorRecord = SensorDataManager.getInstance().getSensorRecord(deviceId, sensorName); + if (sensorRecord != null) { + return Response.status(Response.Status.OK).entity(sensorRecord).build(); + } else { + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + } } catch (DeviceControllerException e) { log.error("Error on reading sensor value: " + e.getMessage()); - if(defaultValue != null){ - return new SensorRecord(defaultValue, Calendar.getInstance().getTimeInMillis()); - }else{ - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return null; + if (defaultValue != null) { + SensorRecord sensorRecord = new SensorRecord(defaultValue, + Calendar.getInstance().getTimeInMillis()); + return Response.status(Response.Status.OK).entity(sensorRecord).build(); + } else { + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } - } finally { - this.endTenantFlow(); } } -} +} \ No newline at end of file diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.api/src/main/java/org/wso2/carbon/device/mgt/iot/api/GroupManagerService.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.api/src/main/java/org/wso2/carbon/device/mgt/iot/api/GroupManagerService.java index 335a3c79e..2776534d9 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.api/src/main/java/org/wso2/carbon/device/mgt/iot/api/GroupManagerService.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.api/src/main/java/org/wso2/carbon/device/mgt/iot/api/GroupManagerService.java @@ -21,21 +21,16 @@ package org.wso2.carbon.device.mgt.iot.api; import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.device.mgt.common.PaginationRequest; -import org.wso2.carbon.device.mgt.common.PaginationResult; import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup; import org.wso2.carbon.device.mgt.common.group.mgt.GroupManagementException; import org.wso2.carbon.device.mgt.common.group.mgt.GroupUser; import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService; +import org.wso2.carbon.device.mgt.iot.util.APIUtil; import org.wso2.carbon.device.mgt.iot.util.ResponsePayload; -import javax.jws.WebService; -import javax.servlet.http.HttpServletResponse; -import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.FormParam; import javax.ws.rs.GET; @@ -45,12 +40,10 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; import java.util.Date; import java.util.List; -@WebService public class GroupManagerService { private static final String DEFAULT_ADMIN_ROLE = "admin"; @@ -69,46 +62,21 @@ public class GroupManagerService { private static Log log = LogFactory.getLog(GroupManagerService.class); - @Context //injected response proxy supporting multiple threads - private HttpServletResponse response; - private PrivilegedCarbonContext ctx; - - private GroupManagementProviderService getServiceProvider() { - String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain(); - String username = CarbonContext.getThreadLocalCarbonContext().getUsername(); - PrivilegedCarbonContext.startTenantFlow(); - ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - ctx.setTenantDomain(tenantDomain, true); - if (log.isDebugEnabled()) { - log.debug("Getting thread local carbon context for tenant domain: " + tenantDomain); - } - return (GroupManagementProviderService) ctx.getOSGiService(GroupManagementProviderService.class, null); - } - - private void endTenantFlow() { - PrivilegedCarbonContext.endTenantFlow(); - ctx = null; - if (log.isDebugEnabled()) { - log.debug("Tenant flow ended"); - } - } - - @Path("/group") + @Path("/groups") @POST - @Consumes("application/json") @Produces("application/json") - public Response createGroup(@FormParam("name") String name, - @FormParam("username") String username, - @FormParam("description") String description) { + public Response createGroup(@FormParam("groupName") String groupName, + @FormParam("userName") String username, + @FormParam("description") String description) { DeviceGroup group = new DeviceGroup(); - group.setName(name); + group.setName(username); group.setDescription(description); group.setOwner(username); group.setDateOfCreation(new Date().getTime()); group.setDateOfLastUpdate(new Date().getTime()); boolean isAdded = false; try { - GroupManagementProviderService groupManagementService = this.getServiceProvider(); + GroupManagementProviderService groupManagementService = APIUtil.getGroupManagementProviderService(); int groupId = groupManagementService.createGroup(group, DEFAULT_ADMIN_ROLE, DEFAULT_ADMIN_PERMISSIONS); if (groupId == -2) { ResponsePayload responsePayload = new ResponsePayload(); @@ -134,451 +102,374 @@ public class GroupManagerService { } } catch (GroupManagementException e) { return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).entity(e.getMessage()).build(); - } finally { - this.endTenantFlow(); } } - @Path("/group/id/{groupId}") + @Path("/groups/{groupId}") @PUT - @Consumes("application/json") @Produces("application/json") - public boolean updateGroup(@PathParam("groupId") int groupId, @FormParam("name") String name, - @FormParam("username") String username, - @FormParam("description") String description) { - if (!isAuthorized(username, groupId, "/permission/device-mgt/admin/groups/modify")) { - response.setStatus(Response.Status.FORBIDDEN.getStatusCode()); - return false; - } + public Response updateGroup(@PathParam("groupId") int groupId, @FormParam("groupName") String groupName, + @FormParam("userName") String userName, + @FormParam("description") String description) { try { - GroupManagementProviderService groupManagementService = this.getServiceProvider(); + GroupManagementProviderService groupManagementService = APIUtil.getGroupManagementProviderService(); DeviceGroup group = groupManagementService.getGroup(groupId); - group.setName(name); + group.setName(groupName); group.setDescription(description); - group.setOwner(username); + group.setOwner(userName); group.setDateOfLastUpdate(new Date().getTime()); - response.setStatus(Response.Status.OK.getStatusCode()); + Response.status(Response.Status.OK.getStatusCode()); groupManagementService.updateGroup(group); - return true; + return Response.status(Response.Status.NO_CONTENT).build(); } catch (GroupManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); log.error(e.getErrorMessage(), e); - return false; - } finally { - this.endTenantFlow(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } - @Path("/group/id/{groupId}") + @Path("/groups/{groupId}") @DELETE - @Consumes("application/json") @Produces("application/json") - public boolean deleteGroup(@PathParam("groupId") int groupId, - @QueryParam("username") String username) { - if (!isAuthorized(username, groupId, "/permission/device-mgt/admin/groups/delete")) { - response.setStatus(Response.Status.FORBIDDEN.getStatusCode()); - return false; + public Response deleteGroup(@PathParam("groupId") int groupId, @QueryParam("userName") String userName) { + + if (!checkAuthorize(getCurrentUserName(), groupId, "/permission/device-mgt/admin/groups/delete")) { + return Response.status(Response.Status.FORBIDDEN).build(); } - boolean isDeleted = false; + try { - response.setStatus(Response.Status.OK.getStatusCode()); - isDeleted = this.getServiceProvider().deleteGroup(groupId); + boolean isDeleted = APIUtil.getGroupManagementProviderService().deleteGroup( + groupId); + if (isDeleted) { + return Response.status(Response.Status.NO_CONTENT).build(); + } else { + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + } } catch (GroupManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - log.error(e.getErrorMessage(), e); - } finally { - this.endTenantFlow(); + log.error(e.getMessage()); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } - return isDeleted; } - @Path("/group/id/{groupId}") + @Path("/groups/{groupId}") @GET - @Consumes("application/json") @Produces("application/json") - public DeviceGroup getGroup(@PathParam("groupId") int groupId, - @FormParam("username") String username) { - DeviceGroup deviceGroup = null; + public Response getGroup(@PathParam("groupId") int groupId) { try { - response.setStatus(Response.Status.OK.getStatusCode()); - deviceGroup = this.getServiceProvider().getGroup(groupId); + DeviceGroup deviceGroup = APIUtil.getGroupManagementProviderService().getGroup( + groupId); + if (deviceGroup != null) { + return Response.status(Response.Status.OK).entity(deviceGroup).build(); + } else { + return Response.status(Response.Status.NOT_FOUND).build(); + } } catch (GroupManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - log.error(e.getErrorMessage(), e); - } finally { - this.endTenantFlow(); + log.error(e.getMessage(), e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } - return deviceGroup; } - @Path("/group/name/{groupName}") + @Path("/groups/search") @GET - @Consumes("application/json") @Produces("application/json") - public DeviceGroup[] findGroups(@PathParam("groupName") String groupName, - @FormParam("username") String username) { - DeviceGroup[] deviceGroups = null; + public Response findGroups(@QueryParam("groupName") String groupName, + @QueryParam("userName") String userName) { try { - List groups = this.getServiceProvider().findInGroups(groupName, username); - deviceGroups = new DeviceGroup[groups.size()]; - response.setStatus(Response.Status.OK.getStatusCode()); + List groups = APIUtil.getGroupManagementProviderService() + .findInGroups(groupName, userName); + DeviceGroup[] deviceGroups = new DeviceGroup[groups.size()]; groups.toArray(deviceGroups); + return Response.status(Response.Status.OK).entity(deviceGroups).build(); } catch (GroupManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - log.error(e.getErrorMessage(), e); - } finally { - this.endTenantFlow(); + log.error(e.getMessage(), e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } - return deviceGroups; } - @Path("/group/user/{username}/all") + @Path("/groups") @GET - @Consumes("application/json") @Produces("application/json") - public DeviceGroup[] getGroups(@PathParam("username") String username, - @QueryParam("permission") String permission) { - DeviceGroup[] deviceGroups = null; + public Response getGroups(@QueryParam("userName") String userName, + @QueryParam("permission") String permission) { try { - GroupManagementProviderService groupManagementService = this.getServiceProvider(); + GroupManagementProviderService groupManagementService = APIUtil.getGroupManagementProviderService(); List groups; if (permission != null) { - groups = groupManagementService.getGroups(username, permission); + groups = groupManagementService.getGroups(userName, permission); } else { - groups = groupManagementService.getGroups(username); + groups = groupManagementService.getGroups(userName); } - deviceGroups = new DeviceGroup[groups.size()]; - response.setStatus(Response.Status.OK.getStatusCode()); + DeviceGroup[] deviceGroups = new DeviceGroup[groups.size()]; groups.toArray(deviceGroups); + return Response.status(Response.Status.OK).entity(deviceGroups).build(); } catch (GroupManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - log.error(e.getErrorMessage(), e); - } finally { - this.endTenantFlow(); + log.error(e.getMessage(), e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } - return deviceGroups; } - @Path("/group/user/{username}/all/count") + @Path("/groups/count") @GET - @Consumes("application/json") @Produces("application/json") - public int getGroupCount(@PathParam("username") String username) { - int count = -1; + public Response getGroupCount(@QueryParam("userName") String userName) { try { - response.setStatus(Response.Status.OK.getStatusCode()); - count = this.getServiceProvider().getGroupCount(username); + int count = APIUtil.getGroupManagementProviderService().getGroupCount(userName); + return Response.status(Response.Status.OK).entity(count).build(); } catch (GroupManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - log.error(e.getErrorMessage(), e); - } finally { - this.endTenantFlow(); + log.error(e.getMessage(), e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } - return count; } - @Path("/group/id/{groupId}/share") - @POST - @Consumes("application/json") + @Path("/groups/{groupId}/share") + @PUT @Produces("application/json") - public boolean shareGroup(@FormParam("username") String username, - @FormParam("shareUser") String shareUser, - @PathParam("groupId") int groupId, - @FormParam("role") String sharingRole) { - if (!isAuthorized(username, groupId, "/permission/device-mgt/admin/groups/share")) { - response.setStatus(Response.Status.FORBIDDEN.getStatusCode()); - return false; + public Response shareGroup(@FormParam("userName") String userName, + @FormParam("shareUser") String shareUser, @PathParam("groupId") int groupId, + @FormParam("roleName") String sharingRole) { + if (!checkAuthorize(getCurrentUserName(), groupId, "/permission/device-mgt/admin/groups/share")) { + return Response.status(Response.Status.FORBIDDEN).build(); } - boolean isShared = false; + try { - response.setStatus(Response.Status.OK.getStatusCode()); - isShared = this.getServiceProvider().shareGroup(shareUser, groupId, sharingRole); + boolean isShared = APIUtil.getGroupManagementProviderService().shareGroup( + shareUser, groupId, sharingRole); + if (isShared) { + return Response.status(Response.Status.NO_CONTENT).build(); + } else { + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + } } catch (GroupManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - log.error(e.getErrorMessage(), e); - } finally { - this.endTenantFlow(); + log.error(e.getMessage(), e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } - return isShared; } - @Path("/group/id/{groupId}/unshare") - @POST - @Consumes("application/json") + @Path("/groups/{groupId}/unshare") + @PUT @Produces("application/json") - public boolean unShareGroup(@FormParam("username") String username, - @FormParam("unShareUser") String unShareUser, - @PathParam("groupId") int groupId, - @FormParam("role") String sharingRole) { - if (!isAuthorized(username, groupId, "/permission/device-mgt/admin/groups/share")) { - response.setStatus(Response.Status.FORBIDDEN.getStatusCode()); - return false; + public Response unShareGroup(@FormParam("userName") String userName, + @FormParam("unShareUser") String unShareUser, + @PathParam("groupId") int groupId, + @FormParam("roleName") String sharingRole) { + if (!checkAuthorize(getCurrentUserName(), groupId, "/permission/device-mgt/admin/groups/share")) { + return Response.status(Response.Status.FORBIDDEN).build(); } - boolean isUnShared = false; + try { - response.setStatus(Response.Status.OK.getStatusCode()); - isUnShared = this.getServiceProvider().unshareGroup(unShareUser, groupId, sharingRole); + boolean isUnShared = APIUtil.getGroupManagementProviderService().unshareGroup( + unShareUser, groupId, sharingRole); + if (isUnShared) { + return Response.status(Response.Status.NO_CONTENT).build(); + } else { + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + } } catch (GroupManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - log.error(e.getErrorMessage(), e); - } finally { - this.endTenantFlow(); + log.error(e.getMessage(), e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } - return isUnShared; } - @Path("/group/id/{groupId}/role") - @POST - @Consumes("application/json") + @Path("/groups/{groupId}/share/roles/{roleName}/permissions") + @PUT @Produces("application/json") - public boolean addSharing(@FormParam("username") String username, - @PathParam("groupId") int groupId, - @FormParam("role") String roleName, - @FormParam("permissions") String[] permissions) { - if (!isAuthorized(username, groupId, "/permission/device-mgt/admin/groups/share")) { - response.setStatus(Response.Status.FORBIDDEN.getStatusCode()); - return false; + public Response addSharing(@QueryParam("userName") String userName, @PathParam("groupId") int groupId, + @PathParam("roleName") String roleName, + @FormParam("permissions") String[] permissions) { + if (!checkAuthorize(getCurrentUserName(), groupId, "/permission/device-mgt/admin/groups/share")) { + return Response.status(Response.Status.FORBIDDEN).build(); } - boolean isAdded = false; + try { - response.setStatus(Response.Status.OK.getStatusCode()); - isAdded = this.getServiceProvider().addGroupSharingRole(username, groupId, roleName, permissions); + boolean isAdded = APIUtil.getGroupManagementProviderService().addGroupSharingRole( + userName, groupId, roleName, permissions); + if (isAdded) { + return Response.status(Response.Status.NO_CONTENT).build(); + } else { + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + } } catch (GroupManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - log.error(e.getErrorMessage(), e); - } finally { - this.endTenantFlow(); + log.error(e.getMessage(), e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } - return isAdded; } - @Path("/group/id/{groupId}/role/{role}") @DELETE - @Consumes("application/json") + @Path("/groups/{groupId}/share/roles/{roleName}/permissions") @Produces("application/json") - public boolean removeSharing(@QueryParam("username") String username, - @PathParam("groupId") int groupId, - @PathParam("role") String roleName) { - if (!isAuthorized(username, groupId, "/permission/device-mgt/admin/groups/share")) { - response.setStatus(Response.Status.FORBIDDEN.getStatusCode()); - } - boolean isRemoved = false; - try { - response.setStatus(Response.Status.OK.getStatusCode()); - isRemoved = this.getServiceProvider().removeGroupSharingRole(groupId, roleName); - } catch (GroupManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - log.error(e.getErrorMessage(), e); - } finally { - this.endTenantFlow(); + public Response removeSharing(@QueryParam("userName") String userName, @PathParam("groupId") int groupId, + @PathParam("roleName") String roleName) { + if (!checkAuthorize(getCurrentUserName(), groupId, "/permission/device-mgt/admin/groups/share")) { + return Response.status(Response.Status.FORBIDDEN).build(); } - return isRemoved; - } - @Path("/group/id/{groupId}/role/all") - @GET - @Consumes("application/json") - @Produces("application/json") - public String[] getRoles(@PathParam("groupId") int groupId) { - String[] rolesArray = null; try { - List roles = this.getServiceProvider().getRoles(groupId); - rolesArray = new String[roles.size()]; - response.setStatus(Response.Status.OK.getStatusCode()); - roles.toArray(rolesArray); + boolean isRemoved = APIUtil.getGroupManagementProviderService().removeGroupSharingRole( + groupId, roleName); + if (isRemoved) { + return Response.status(Response.Status.NO_CONTENT).build(); + } else { + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + } } catch (GroupManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - log.error(e.getErrorMessage(), e); - } finally { - this.endTenantFlow(); + log.error(e.getMessage(), e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } - return rolesArray; } - @Path("/group/id/{groupId}/{user}/role/all") @GET - @Consumes("application/json") + @Path("/groups/{groupId}/share/roles") @Produces("application/json") - public String[] getRoles(@PathParam("user") String user, @PathParam("groupId") int groupId) { - String[] rolesArray = null; + public Response getRoles(@PathParam("groupId") int groupId, @QueryParam("userName") String userName) { try { - List roles = this.getServiceProvider().getRoles(user, groupId); - rolesArray = new String[roles.size()]; - response.setStatus(Response.Status.OK.getStatusCode()); + List roles; + if (userName != null && !userName.isEmpty()) { + roles = APIUtil.getGroupManagementProviderService().getRoles(userName, + groupId); + } else { + roles = APIUtil.getGroupManagementProviderService().getRoles(groupId); + } + String[] rolesArray = new String[roles.size()]; roles.toArray(rolesArray); + return Response.status(Response.Status.OK).entity(rolesArray).build(); } catch (GroupManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - log.error(e.getErrorMessage(), e); - } finally { - this.endTenantFlow(); + log.error(e.getMessage(), e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } - return rolesArray; } - @Path("/group/id/{groupId}/user/all") @GET - @Consumes("application/json") + @Path("/groups/{groupId}/users") @Produces("application/json") - public GroupUser[] getUsers(@PathParam("groupId") int groupId) { - GroupUser[] usersArray = null; + public Response getUsers(@PathParam("groupId") int groupId) { try { - List users = this.getServiceProvider().getUsers(groupId); - usersArray = new GroupUser[users.size()]; - response.setStatus(Response.Status.OK.getStatusCode()); + List users = APIUtil.getGroupManagementProviderService().getUsers( + groupId); + GroupUser[] usersArray = new GroupUser[users.size()]; users.toArray(usersArray); + return Response.status(Response.Status.OK).entity(usersArray).build(); } catch (GroupManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - log.error(e.getErrorMessage(), e); - } finally { - this.endTenantFlow(); + log.error(e.getMessage(), e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } - return usersArray; } - @Path("/group/id/{groupId}/device/all") @GET - @Consumes("application/json") + @Path("/groups/{groupId}/devices/all") @Produces("application/json") - public Device[] getDevices(@PathParam("groupId") int groupId) { - Device[] deviceArray = null; + public Response getDevices(@PathParam("groupId") int groupId) { try { - List devices = this.getServiceProvider().getDevices(groupId); - deviceArray = new Device[devices.size()]; - response.setStatus(Response.Status.OK.getStatusCode()); + List devices = APIUtil.getGroupManagementProviderService().getDevices( + groupId); + Device[] deviceArray = new Device[devices.size()]; devices.toArray(deviceArray); + return Response.status(Response.Status.OK).entity(deviceArray).build(); } catch (GroupManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - log.error(e.getErrorMessage(), e); - } finally { - this.endTenantFlow(); + log.error(e.getMessage(), e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } - return deviceArray; } - @Path("/group/id/{groupId}/device/count") @GET - @Consumes("application/json") + @Path("/groups/{groupId}/devices/count") @Produces("application/json") - public int getDeviceCount(@PathParam("groupId") int groupId) { + public Response getDeviceCount(@PathParam("groupId") int groupId) { try { - return this.getServiceProvider().getDeviceCount(groupId); + int count = APIUtil.getGroupManagementProviderService().getDeviceCount(groupId); + return Response.status(Response.Status.OK).entity(count).build(); } catch (GroupManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - log.error(e.getErrorMessage(), e); - return -1; - } finally { - this.endTenantFlow(); + log.error(e.getMessage(), e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } - @Path("/group/id/{groupId}/device") - @GET - @Consumes("application/json") - @Produces("application/json") - public List getDevices(@PathParam("groupId") int groupId, - @QueryParam("index") int index, - @QueryParam("limit") int limit) { - try { - PaginationRequest request = new PaginationRequest(index, limit); - return this.getServiceProvider().getDevices(groupId, request); - } catch (GroupManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - log.error(e.getErrorMessage(), e); - return null; - } finally { - this.endTenantFlow(); - } - } - - @Path("/group/id/{groupId}/device/assign") @PUT - @Consumes("application/json") + @Path("/groups/{groupId}/devices/{deviceType}/{deviceId}") @Produces("application/json") - public boolean addDevice(@PathParam("groupId") int groupId, - @FormParam("deviceId") String deviceId, - @FormParam("deviceType") String deviceType, - @FormParam("username") String username) { - if (!isAuthorized(username, groupId, "/permission/device-mgt/admin/groups/add_devices")) { - response.setStatus(Response.Status.FORBIDDEN.getStatusCode()); - return false; + public Response addDevice(@PathParam("groupId") int groupId, @PathParam("deviceId") String deviceId, + @PathParam("deviceType") String deviceType, + @FormParam("userName") String userName) { + if (!checkAuthorize(getCurrentUserName(), groupId, + "/permission/device-mgt/admin/groups/add_devices")) { + return Response.status(Response.Status.FORBIDDEN).build(); } - boolean isAdded = false; try { DeviceIdentifier deviceIdentifier = new DeviceIdentifier(deviceId, deviceType); - response.setStatus(Response.Status.OK.getStatusCode()); - isAdded = this.getServiceProvider().addDevice(deviceIdentifier, groupId); + boolean isAdded = APIUtil.getGroupManagementProviderService().addDevice( + deviceIdentifier, groupId); + if (isAdded) { + return Response.status(Response.Status.NO_CONTENT).build(); + } else { + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + } } catch (GroupManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - log.error(e.getErrorMessage(), e); - } finally { - this.endTenantFlow(); + log.error(e.getMessage(), e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } - return isAdded; } - @Path("/group/id/{groupId}/device/assign") @DELETE - @Consumes("application/json") + @Path("/groups/{groupId}/devices/{deviceType}/{deviceId}") @Produces("application/json") - public boolean removeDevice(@PathParam("groupId") int groupId, - @FormParam("deviceId") String deviceId, - @FormParam("deviceType") String deviceType, - @FormParam("username") String username) { - if (!isAuthorized(username, groupId, "/permission/device-mgt/admin/groups/remove_devices")) { - response.setStatus(Response.Status.FORBIDDEN.getStatusCode()); - return false; + public Response removeDevice(@PathParam("groupId") int groupId, @PathParam("deviceId") String deviceId, + @PathParam("deviceType") String deviceType) { + if (!checkAuthorize(getCurrentUserName(), groupId, + "/permission/device-mgt/admin/groups/remove_devices")) { + return Response.status(Response.Status.FORBIDDEN).build(); } - boolean isRemoved = false; try { DeviceIdentifier deviceIdentifier = new DeviceIdentifier(deviceId, deviceType); - response.setStatus(Response.Status.OK.getStatusCode()); - isRemoved = this.getServiceProvider().removeDevice(deviceIdentifier, groupId); + boolean isRemoved = APIUtil.getGroupManagementProviderService().removeDevice( + deviceIdentifier, groupId); + if (isRemoved) { + return Response.status(Response.Status.NO_CONTENT).build(); + } else { + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + } } catch (GroupManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - log.error(e.getErrorMessage(), e); - } finally { - this.endTenantFlow(); + log.error(e.getMessage(), e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } - return isRemoved; } - @Path("/group/id/{groupId}/user/{username}/permissions") @GET - @Consumes("application/json") + @Path("/groups/{groupId}/users/{userName}/permissions") @Produces("application/json") - public String[] getPermissions(@PathParam("username") String username, + public Response getPermissions(@PathParam("userName") String userName, @PathParam("groupId") int groupId) { - String[] permissions = null; try { - response.setStatus(Response.Status.OK.getStatusCode()); - permissions = this.getServiceProvider().getPermissions(username, groupId); + String[] permissions = APIUtil.getGroupManagementProviderService() + .getPermissions(userName, groupId); + return Response.status(Response.Status.OK).entity(permissions).build(); } catch (GroupManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - log.error(e.getErrorMessage(), e); - } finally { - this.endTenantFlow(); + log.error(e.getMessage(), e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } - return permissions; } - @Path("/group/id/{groupId}/user/{username}/authorized") @GET - @Consumes("application/json") + @Path("/groups/{groupId}/users/{userName}/authorized") @Produces("application/json") - public boolean isAuthorized(@PathParam("username") String username, - @PathParam("groupId") int groupId, - @QueryParam("permission") String permission) { - boolean isAuthorized = false; + public Response isAuthorized(@PathParam("userName") String userName, @PathParam("groupId") int groupId, + @QueryParam("permission") String permission) { + boolean isAuthorized = checkAuthorize(userName, groupId, permission); + if (isAuthorized) { + return Response.status(Response.Status.OK).build(); + } else { + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + } + } + + private boolean checkAuthorize(String userName, int groupId, String permission) { try { - response.setStatus(Response.Status.OK.getStatusCode()); - isAuthorized = this.getServiceProvider().isAuthorized(username, groupId, permission); + return APIUtil.getGroupManagementProviderService().isAuthorized(userName, groupId, permission); } catch (GroupManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - log.error(e.getErrorMessage(), e); - } finally { - this.endTenantFlow(); + log.error(e.getMessage(), e); + return false; } - return isAuthorized; } -} + private String getCurrentUserName() { + return PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); + } + +} \ No newline at end of file diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.api/src/main/java/org/wso2/carbon/device/mgt/iot/api/PolicyManagementService.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.api/src/main/java/org/wso2/carbon/device/mgt/iot/api/PolicyManagementService.java index 702ea89ed..d9a928457 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.api/src/main/java/org/wso2/carbon/device/mgt/iot/api/PolicyManagementService.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.api/src/main/java/org/wso2/carbon/device/mgt/iot/api/PolicyManagementService.java @@ -24,6 +24,7 @@ import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.iot.util.APIUtil; import org.wso2.carbon.policy.mgt.common.Policy; import org.wso2.carbon.policy.mgt.common.PolicyAdministratorPoint; import org.wso2.carbon.policy.mgt.common.PolicyManagementException; @@ -40,190 +41,108 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; import java.util.List; -@WebService public class PolicyManagementService { - private static Log log = LogFactory.getLog(PolicyManagementService.class); - - @Context //injected response proxy supporting multiple thread - private HttpServletResponse response; - - private PrivilegedCarbonContext ctx; - - private PolicyManagerService getPolicyServiceProvider() throws DeviceManagementException { - String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain(); - PrivilegedCarbonContext.startTenantFlow(); - ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - ctx.setTenantDomain(tenantDomain, true); - - if (log.isDebugEnabled()) { - log.debug("Getting thread local carbon context for tenant domain: " + tenantDomain); - } - - PolicyManagerService policyManagerService = (PolicyManagerService) ctx.getOSGiService( - PolicyManagerService.class, null); - - if (policyManagerService == null) { - String msg = "Policy Management service not initialized"; - log.error(msg); - throw new DeviceManagementException(msg); - } - - return policyManagerService; - } - - private void endTenantFlow() { - PrivilegedCarbonContext.endTenantFlow(); - ctx = null; - if (log.isDebugEnabled()) { - log.debug("Tenant flow ended"); - } - } + private static final Log log = LogFactory.getLog(PolicyManagementService.class); @POST - @Path("/inactive-policy") + @Path("/policies/inactive") @Produces("application/json") - public boolean addPolicy(Policy policy) { - - try { - PolicyManagerService policyManagerService = getPolicyServiceProvider(); - PolicyAdministratorPoint pap = policyManagerService.getPAP(); - pap.addPolicy(policy); - response.setStatus(Response.Status.CREATED.getStatusCode()); - if (log.isDebugEnabled()) { - log.debug("Policy has been added successfully."); - } - return true; - } catch (PolicyManagementException e) { - String error = "Policy Management related exception."; - log.error(error, e); - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return false; - } catch (DeviceManagementException e) { - String error = "Error occurred while invoking Policy Management Service."; - log.error(error, e); - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return false; - } finally { - this.endTenantFlow(); - } + public Response addInactivePolicy(@FormParam("policy") Policy policy) { + return addPolicy(policy); } @POST - @Path("/active-policy") + @Path("/policies/active") @Produces("application/json") - public boolean addActivePolicy(Policy policy) { - + public Response addActivePolicy(@FormParam("policy") Policy policy) { policy.setActive(true); + return addPolicy(policy); + } + private Response addPolicy(Policy policy) { try { - PolicyManagerService policyManagerService = getPolicyServiceProvider(); + PolicyManagerService policyManagerService = APIUtil.getPolicyManagerService(); PolicyAdministratorPoint pap = policyManagerService.getPAP(); pap.addPolicy(policy); - response.setStatus(Response.Status.CREATED.getStatusCode()); if (log.isDebugEnabled()) { log.debug("Policy has been added successfully."); } - return true; - } catch (PolicyManagementException e) { + return Response.status(Response.Status.NO_CONTENT).build(); + } catch (PolicyManagementException e) { String error = "Policy Management related exception."; log.error(error, e); - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return false; - } catch (DeviceManagementException e) { - String error = "Error occurred while invoking Policy Management Service."; - log.error(error, e); - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return false; - } finally { - this.endTenantFlow(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } @GET + @Path("/policies") @Produces("application/json") - public Policy[] getAllPolicies() { + public Response getAllPolicies() { + try { - PolicyManagerService policyManagerService = getPolicyServiceProvider(); + PolicyManagerService policyManagerService = APIUtil.getPolicyManagerService(); PolicyAdministratorPoint policyAdministratorPoint = policyManagerService.getPAP(); List policies = policyAdministratorPoint.getPolicies(); - return policyAdministratorPoint.getPolicies().toArray(new Policy[policies.size()]); - } catch (PolicyManagementException e) { + Policy[] policyArr = policyAdministratorPoint.getPolicies().toArray(new Policy[policies.size()]); + return Response.status(Response.Status.OK).entity(policyArr).build(); + } catch (PolicyManagementException e) { String error = "Policy Management related exception"; log.error(error, e); - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return null; - } catch (DeviceManagementException e) { - String error = "Error occurred while invoking Policy Management Service."; - log.error(error, e); - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return null; - } finally { - this.endTenantFlow(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } @GET + @Path("/policies/{policyId}") @Produces("application/json") - @Path("/{id}") - public Policy getPolicy(@PathParam("id") int policyId) { + public Response getPolicy(@PathParam("policyId") int policyId) { + try { - PolicyManagerService policyManagerService = getPolicyServiceProvider(); + PolicyManagerService policyManagerService = APIUtil.getPolicyManagerService(); PolicyAdministratorPoint policyAdministratorPoint = policyManagerService.getPAP(); Policy policy = policyAdministratorPoint.getPolicy(policyId); if (policy != null) { if (log.isDebugEnabled()) { log.debug("Sending policy for ID " + policyId); } - return policy; + return Response.status(Response.Status.OK).entity(policy).build(); } else { log.error("Policy for ID " + policyId + " not found."); - response.setStatus(Response.Status.NOT_FOUND.getStatusCode()); - return null; + return Response.status(Response.Status.NOT_FOUND).build(); } - } catch (PolicyManagementException e) { + } catch (PolicyManagementException e) { String error = "Policy Management related exception"; log.error(error, e); - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return null; - } catch (DeviceManagementException e) { - String error = "Error occurred while invoking Policy Management Service."; - log.error(error, e); - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return null; - } finally { - this.endTenantFlow(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } @GET - @Path("/count") - public int getPolicyCount() { + @Path("/policies/inactive/count") + @Produces("application/json") + public Response getPolicyCount() { + try { - PolicyManagerService policyManagerService = getPolicyServiceProvider(); + PolicyManagerService policyManagerService = APIUtil.getPolicyManagerService(); PolicyAdministratorPoint policyAdministratorPoint = policyManagerService.getPAP(); - return policyAdministratorPoint.getPolicyCount(); - } catch (PolicyManagementException e) { + int policyCount = policyAdministratorPoint.getPolicyCount(); + return Response.status(Response.Status.OK).entity(policyCount).build(); + } catch (PolicyManagementException e) { String error = "Policy Management related exception"; log.error(error, e); - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return -1; - } catch (DeviceManagementException e) { - String error = "Error occurred while invoking Policy Management Service."; - log.error(error, e); - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return -1; - } finally { - this.endTenantFlow(); - } + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + } } @PUT - @Path("/{id}") + @Path("/policies/{policyId}") @Produces("application/json") - public boolean updatePolicy(Policy policy, @PathParam("id") int policyId) { + public Response updatePolicy(@FormParam("policy") Policy policy, @PathParam("policyId") int policyId) { + try { - PolicyManagerService policyManagerService = getPolicyServiceProvider(); + PolicyManagerService policyManagerService = APIUtil.getPolicyManagerService(); PolicyAdministratorPoint pap = policyManagerService.getPAP(); Policy previousPolicy = pap.getPolicy(policyId); policy.setProfile(pap.getProfile(previousPolicy.getProfileId())); @@ -232,64 +151,49 @@ public class PolicyManagementService { if (log.isDebugEnabled()) { log.debug("Policy with ID " + policyId + " has been updated successfully."); } - return true; - } catch (PolicyManagementException e) { + return Response.status(Response.Status.NO_CONTENT).build(); + } catch (PolicyManagementException e) { String error = "Policy Management related exception"; log.error(error, e); - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return false; - } catch (DeviceManagementException e) { - String error = "Error occurred while invoking Policy Management Service."; - log.error(error, e); - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return false; - } finally { - this.endTenantFlow(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } @PUT - @Path("/priorities") + @Path("/policies/priorities") @Consumes("application/json") @Produces("application/json") - public boolean updatePolicyPriorities(List priorityUpdatedPolicies) { + public Response updatePolicyPriorities(@FormParam("policies") List priorityUpdatedPolicies) { + try { - PolicyManagerService policyManagerService = getPolicyServiceProvider(); + PolicyManagerService policyManagerService = APIUtil.getPolicyManagerService(); PolicyAdministratorPoint pap = policyManagerService.getPAP(); boolean policiesUpdated = pap.updatePolicyPriorities(priorityUpdatedPolicies); if (policiesUpdated) { if (log.isDebugEnabled()) { log.debug("Policy Priorities successfully updated."); } - return true; + return Response.status(Response.Status.NO_CONTENT).build(); } else { if (log.isDebugEnabled()) { log.debug("Policy priorities did not update. Bad Request."); } - response.setStatus(Response.Status.BAD_REQUEST.getStatusCode()); - return false; + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } - } catch (PolicyManagementException e) { + } catch (PolicyManagementException e) { String error = "Exception in updating policy priorities."; log.error(error, e); - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return false; - } catch (DeviceManagementException e) { - String error = "Error occurred while invoking Policy Management Service."; - log.error(error, e); - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return false; - } finally { - this.endTenantFlow(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } @DELETE - @Path("/{id}") + @Path("/policies/{policyId}") @Produces("application/json") - public boolean deletePolicy(@PathParam("id") int policyId) { + public Response deletePolicy(@PathParam("policyId") int policyId) { + try { - PolicyManagerService policyManagerService = getPolicyServiceProvider(); + PolicyManagerService policyManagerService = APIUtil.getPolicyManagerService(); PolicyAdministratorPoint pap = policyManagerService.getPAP(); Policy policy = pap.getPolicy(policyId); boolean policyDeleted = pap.deletePolicy(policy); @@ -297,211 +201,156 @@ public class PolicyManagementService { if (log.isDebugEnabled()) { log.debug("Policy by id:" + policyId + " has been successfully deleted."); } - return true; + return Response.status(Response.Status.OK).build(); } else { if (log.isDebugEnabled()) { log.debug("Policy by id:" + policyId + " does not exist."); } - response.setStatus(Response.Status.NOT_FOUND.getStatusCode()); - return false; + return Response.status(Response.Status.NOT_FOUND).build(); } - } catch (PolicyManagementException e) { + } catch (PolicyManagementException e) { String error = "Exception in deleting policy by id:" + policyId; log.error(error, e); - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return false; - } catch (DeviceManagementException e) { - String error = "Error occurred while invoking Policy Management Service."; - log.error(error, e); - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return false; - } finally { - this.endTenantFlow(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } @PUT + @Path("/policies/{policyId}/activate") @Produces("application/json") - @Path("/activate/{id}") - public boolean activatePolicy(@PathParam("id") int policyId) { + public Response activatePolicy(@PathParam("policyId") int policyId) { + try { - PolicyManagerService policyManagerService = getPolicyServiceProvider(); + PolicyManagerService policyManagerService = APIUtil.getPolicyManagerService(); PolicyAdministratorPoint pap = policyManagerService.getPAP(); pap.activatePolicy(policyId); if (log.isDebugEnabled()) { log.debug("Policy by id:" + policyId + " has been successfully activated."); } - return true; - } catch (PolicyManagementException e) { + return Response.status(Response.Status.NO_CONTENT).build(); + } catch (PolicyManagementException e) { String error = "Exception in activating policy by id:" + policyId; log.error(error, e); - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return false; - } catch (DeviceManagementException e) { - String error = "Error occurred while invoking Policy Management Service."; - log.error(error, e); - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return false; - } finally { - this.endTenantFlow(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } @PUT + @Path("/policies/{policyId}/inactivate") @Produces("application/json") - @Path("/inactivate/{id}") - public boolean inactivatePolicy(@PathParam("id") int policyId) { + public Response inactivatePolicy(@PathParam("policyId") int policyId) { try { - PolicyManagerService policyManagerService = getPolicyServiceProvider(); + PolicyManagerService policyManagerService = APIUtil.getPolicyManagerService(); PolicyAdministratorPoint pap = policyManagerService.getPAP(); pap.inactivatePolicy(policyId); if (log.isDebugEnabled()) { log.debug("Policy by id:" + policyId + " has been successfully inactivated."); } - return true; - } catch (PolicyManagementException e) { + return Response.status(Response.Status.NO_CONTENT).build(); + } catch (PolicyManagementException e) { String error = "Exception in inactivating policy by id:" + policyId; log.error(error, e); - return false; - } catch (DeviceManagementException e) { - String error = "Error occurred while invoking Policy Management Service."; - log.error(error, e); - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return false; - } finally { - this.endTenantFlow(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } @PUT + @Path("/policies/publish-changes") @Produces("application/json") - @Path("/apply-changes") - public boolean applyChanges() { + public Response publishChanges() { try { - PolicyManagerService policyManagerService = getPolicyServiceProvider(); + PolicyManagerService policyManagerService = APIUtil.getPolicyManagerService(); PolicyAdministratorPoint pap = policyManagerService.getPAP(); pap.publishChanges(); if (log.isDebugEnabled()) { log.debug("Changes have been successfully updated."); } - return true; - } catch (PolicyManagementException e) { + return Response.status(Response.Status.NO_CONTENT).build(); + } catch (PolicyManagementException e) { String error = "Exception in applying changes."; log.error(error, e); - return false; - } catch (DeviceManagementException e) { - String error = "Error occurred while invoking Policy Management Service."; - log.error(error, e); - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return false; - } finally { - this.endTenantFlow(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } - @GET - @Path("/start-task/{milliseconds}") - public boolean startTaskService(@PathParam("milliseconds") int monitoringFrequency) { + @PUT + @Path("/policies/monitor-task/start") + @Produces("application/json") + public Response startTaskService(@FormParam("milliseconds") int monitoringFrequency) { try { - PolicyManagerService policyManagerService = getPolicyServiceProvider(); + PolicyManagerService policyManagerService = APIUtil.getPolicyManagerService(); TaskScheduleService taskScheduleService = policyManagerService.getTaskScheduleService(); taskScheduleService.startTask(monitoringFrequency); if (log.isDebugEnabled()) { log.debug("Policy monitoring service started successfully."); } - return true; + return Response.status(Response.Status.NO_CONTENT).build(); } catch (PolicyMonitoringTaskException e) { String error = "Policy Management related exception."; log.error(error, e); - return false; - } catch (DeviceManagementException e) { - String error = "Error occurred while invoking Policy Management Service."; - log.error(error, e); - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return false; - } finally { - this.endTenantFlow(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } - @GET - @Path("/update-task/{milliseconds}") - public boolean updateTaskService(@PathParam("milliseconds") int monitoringFrequency) { + @PUT + @Path("/policies/monitor-task/update") + @Produces("application/json") + public Response updateTaskService(@FormParam("milliseconds") int monitoringFrequency) { try { - PolicyManagerService policyManagerService = getPolicyServiceProvider(); + PolicyManagerService policyManagerService = APIUtil.getPolicyManagerService();; TaskScheduleService taskScheduleService = policyManagerService.getTaskScheduleService(); taskScheduleService.updateTask(monitoringFrequency); if (log.isDebugEnabled()) { log.debug("Policy monitoring service updated successfully."); } - return true; + return Response.status(Response.Status.NO_CONTENT).build(); } catch (PolicyMonitoringTaskException e) { String error = "Policy Management related exception."; log.error(error, e); - return false; - } catch (DeviceManagementException e) { - String error = "Error occurred while invoking Policy Management Service."; - log.error(error, e); - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return false; - } finally { - this.endTenantFlow(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } - @GET - @Path("/stop-task") - public boolean stopTaskService() { - + @PUT + @Path("/policies/monitor-task/stop") + @Produces("application/json") + public Response stopTaskService() { try { - PolicyManagerService policyManagerService = getPolicyServiceProvider(); + PolicyManagerService policyManagerService = APIUtil.getPolicyManagerService(); TaskScheduleService taskScheduleService = policyManagerService.getTaskScheduleService(); taskScheduleService.stopTask(); if (log.isDebugEnabled()) { log.debug("Policy monitoring service stopped successfully."); } - return true; + return Response.status(Response.Status.NO_CONTENT).build(); } catch (PolicyMonitoringTaskException e) { String error = "Policy Management related exception."; log.error(error, e); - return false; - } catch (DeviceManagementException e) { - String error = "Error occurred while invoking Policy Management Service."; - log.error(error, e); - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return false; - } finally { - this.endTenantFlow(); - } + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + } } @GET - @Path("/{type}/{id}") - public ComplianceData getComplianceDataOfDevice(@PathParam("id") String deviceId, - @PathParam("type") String deviceType) { + @Path("/policies/compliance/{deviceType}/{deviceId}") + @Produces("application/json") + public Response getComplianceDataOfDevice(@PathParam("deviceId") String deviceId, + @PathParam("deviceType") String deviceType) { try { - PolicyManagerService policyManagerService = getPolicyServiceProvider(); + PolicyManagerService policyManagerService = APIUtil.getPolicyManagerService(); DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); deviceIdentifier.setType(deviceType); deviceIdentifier.setId(deviceId); - return policyManagerService.getDeviceCompliance(deviceIdentifier); - } catch (PolicyComplianceException e) { + ComplianceData complianceData = policyManagerService.getDeviceCompliance(deviceIdentifier); + return Response.status(Response.Status.OK).entity(complianceData).build(); + } catch (PolicyComplianceException e) { String error = "Error occurred while getting the compliance data."; log.error(error, e); - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return null; - } catch (DeviceManagementException e) { - String error = "Error occurred while invoking Policy Management Service."; - log.error(error, e); - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return null; - } finally { - this.endTenantFlow(); - } + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + } } -} +} \ No newline at end of file diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.api/src/main/java/org/wso2/carbon/device/mgt/iot/util/APIUtil.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.api/src/main/java/org/wso2/carbon/device/mgt/iot/util/APIUtil.java new file mode 100644 index 000000000..e18324d12 --- /dev/null +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.api/src/main/java/org/wso2/carbon/device/mgt/iot/util/APIUtil.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.device.mgt.iot.util; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; +import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService; +import org.wso2.carbon.policy.mgt.core.PolicyManagerService; + +/** + * This class provides utility functions used by REST-API. + */ +public class APIUtil { + private static Log log = LogFactory.getLog(APIUtil.class); + + public static GroupManagementProviderService getGroupManagementProviderService() { + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + GroupManagementProviderService groupManagementProviderService = + (GroupManagementProviderService) ctx.getOSGiService(GroupManagementProviderService.class, null); + if (groupManagementProviderService == null) { + String msg = "Group Management service has not initialized."; + log.error(msg); + throw new IllegalStateException(msg); + } + return groupManagementProviderService; + } + + public static DeviceManagementProviderService getDeviceManagementService() { + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + DeviceManagementProviderService deviceManagementProviderService = + (DeviceManagementProviderService) ctx.getOSGiService(DeviceManagementProviderService.class, null); + if (deviceManagementProviderService == null) { + String msg = "Device Management service has not initialized."; + log.error(msg); + throw new IllegalStateException(msg); + } + return deviceManagementProviderService; + } + + public static PolicyManagerService getPolicyManagerService() { + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + PolicyManagerService policyManagerService = + (PolicyManagerService) ctx.getOSGiService(PolicyManagerService.class, null); + if (policyManagerService == null) { + String msg = "Policy management service has not initialized."; + log.error(msg); + throw new IllegalStateException(msg); + } + return policyManagerService; + } +} diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/pom.xml b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/pom.xml index 76bc21a38..76c09c753 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/pom.xml +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/pom.xml @@ -83,8 +83,8 @@ org.wso2.carbon.utils.*;version="${carbon.kernel.version.range}", org.wso2.carbon.device.mgt.common.*, org.eclipse.paho.client.mqttv3.*;version="${eclipse.paho.version}", - javax.ws.rs.core, - javax.xml + javax.xml;resolution:=optional, + javax.net.ssl;resolution:=optional !org.wso2.carbon.device.mgt.iot.internal, diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/controlqueue/xmpp/XmppServerClient.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/controlqueue/xmpp/XmppServerClient.java index 55c86707d..e415803b6 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/controlqueue/xmpp/XmppServerClient.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/controlqueue/xmpp/XmppServerClient.java @@ -33,10 +33,9 @@ import org.apache.http.util.EntityUtils; import org.json.JSONArray; import org.json.JSONObject; import org.wso2.carbon.device.mgt.iot.exception.DeviceControllerException; -import org.wso2.carbon.device.mgt.iot.exception.IoTException; import org.wso2.carbon.device.mgt.iot.util.IoTUtil; -import javax.ws.rs.core.MediaType; + import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; @@ -54,6 +53,7 @@ public class XmppServerClient { @SuppressWarnings("unused") private static final String APPLICATION_JSON_MT = "application/json"; private static final String DEVICEMGT_CONFIG_FILE = "devicemgt-config.xml"; + private static final String APPLICATION_JSON = "application/json"; private String xmppEndpoint; private String xmppUsername; private String xmppPassword; @@ -100,7 +100,7 @@ public class XmppServerClient { StringEntity requestEntity; try { - requestEntity = new StringEntity(jsonRequest, MediaType.APPLICATION_JSON, + requestEntity = new StringEntity(jsonRequest, APPLICATION_JSON, StandardCharsets.UTF_8.toString()); } catch (UnsupportedEncodingException e) { return false; @@ -140,7 +140,7 @@ public class XmppServerClient { EntityUtils.consume(httpResponse.getEntity()); return true; } - } catch (IOException | IoTException e) { + } catch (IOException e) { String errorMsg = "Error occured whilst trying a 'POST' at : " + xmppUsersAPIEndpoint; log.error(errorMsg); throw new DeviceControllerException(errorMsg, e); @@ -199,7 +199,7 @@ public class XmppServerClient { return false; } - } catch (IOException | IoTException e) { + } catch (IOException e) { String errorMsg = "Error occured whilst trying a 'GET' at : " + xmppCheckUserAPIEndpoint; log.error(errorMsg); throw new DeviceControllerException(errorMsg, e); @@ -250,7 +250,7 @@ public class XmppServerClient { HttpGet httpGet = new HttpGet(xmppSessionsAPIEndpoint); httpGet.addHeader(HttpHeaders.AUTHORIZATION, authorizationHeader); - httpGet.addHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON); + httpGet.addHeader(HttpHeaders.ACCEPT, APPLICATION_JSON); try { HttpResponse httpResponse = httpClient.execute(httpGet); @@ -266,7 +266,7 @@ public class XmppServerClient { xmppSessions = new JSONObject(response).getJSONArray("session"); return xmppSessions; - } catch (IOException | IoTException e) { + } catch (IOException e) { String errorMsg = "Error occured whilst trying a 'GET' at : " + xmppSessionsAPIEndpoint; log.error(errorMsg); throw new DeviceControllerException(errorMsg, e); diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/internal/IoTCommonDataHolder.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/internal/IoTCommonDataHolder.java deleted file mode 100644 index 6ed374350..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/internal/IoTCommonDataHolder.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.device.mgt.iot.internal; - -import org.wso2.carbon.base.ServerConfiguration; -import org.wso2.carbon.databridge.core.DataBridgeReceiverService; - -public class IoTCommonDataHolder { - - private static IoTCommonDataHolder thisInstance = new IoTCommonDataHolder(); - String trustStoreLocaiton; - String trustStorePassword; - private IoTCommonDataHolder() { - - } - - public void initialize(){ - setTrustStore(); - } - - public static IoTCommonDataHolder getInstance() { - return thisInstance; - } - - private void setTrustStore(){ - this.trustStoreLocaiton = ServerConfiguration.getInstance().getFirstProperty("Security.TrustStore.Location"); - this.trustStorePassword = ServerConfiguration.getInstance().getFirstProperty("Security.TrustStore.Password"); - } - - public String getTrustStoreLocation(){ - return trustStoreLocaiton; - } - - public String getTrustStorePassword(){ - return trustStorePassword; - } - -} diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/internal/IotDeviceManagementServiceComponent.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/internal/IotDeviceManagementServiceComponent.java index dadc99f97..76e045c5c 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/internal/IotDeviceManagementServiceComponent.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/internal/IotDeviceManagementServiceComponent.java @@ -54,7 +54,6 @@ public class IotDeviceManagementServiceComponent { /* Initialize the data source configuration */ DeviceManagementConfigurationManager.getInstance().initConfig(); bundleContext.registerService(ServerStartupObserver.class.getName(), new IoTServerStartupListener(), null); - IoTCommonDataHolder.getInstance().initialize(); if (log.isDebugEnabled()) { log.debug("Iot Device Management Service Component has been successfully activated"); } diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/util/IoTUtil.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/util/IoTUtil.java index 76e375e27..8cc76e938 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/util/IoTUtil.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/util/IoTUtil.java @@ -22,18 +22,13 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; -import org.apache.http.conn.scheme.PlainSocketFactory; -import org.apache.http.conn.scheme.Scheme; -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.PoolingClientConnectionManager; -import org.apache.http.params.BasicHttpParams; -import org.apache.http.params.HttpParams; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.conn.ssl.SSLContextBuilder; +import org.apache.http.conn.ssl.TrustSelfSignedStrategy; +import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; import org.wso2.carbon.base.ServerConfiguration; import org.wso2.carbon.device.mgt.iot.exception.IoTException; -import org.wso2.carbon.device.mgt.iot.internal.IoTCommonDataHolder; import org.wso2.carbon.utils.NetworkUtils; import java.io.BufferedReader; @@ -43,49 +38,33 @@ import java.net.SocketException; import java.security.KeyManagementException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; -import java.security.UnrecoverableKeyException; public class IoTUtil { public static final String HOST_NAME = "HostName"; private static final Log log = LogFactory.getLog(IoTUtil.class); + private static final String HTTPS_PROTOCOL = "https"; /** * Return a http client instance - * - * @param port - server port * @param protocol- service endpoint protocol http/https * @return */ public static HttpClient getHttpClient(int port, String protocol) - throws UnrecoverableKeyException, NoSuchAlgorithmException, KeyStoreException, - KeyManagementException { - SchemeRegistry registry = new SchemeRegistry(); - - if ("https".equals(protocol)) { - System.setProperty("javax.net.ssl.trustStrore", IoTCommonDataHolder.getInstance().getTrustStoreLocation()); - System.setProperty("javax.net.ssl.trustStorePassword", - IoTCommonDataHolder.getInstance().getTrustStorePassword()); - - if (port >= 0) { - registry.register(new Scheme("https", port, SSLSocketFactory.getSocketFactory())); - } else { - registry.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory())); - } - } else if ("http".equals(protocol)) { - if (port >= 0) { - registry.register(new Scheme("http", port, PlainSocketFactory.getSocketFactory())); - } else { - registry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory())); - } + throws IOException, KeyStoreException, NoSuchAlgorithmException, KeyManagementException { + HttpClient httpclient; + if (HTTPS_PROTOCOL.equals(protocol)) { + SSLContextBuilder builder = new SSLContextBuilder(); + builder.loadTrustMaterial(null, new TrustSelfSignedStrategy()); + SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(builder.build()); + httpclient = HttpClients.custom().setSSLSocketFactory(sslsf).build(); + } else { + httpclient = HttpClients.createDefault(); } - HttpParams params = new BasicHttpParams(); - PoolingClientConnectionManager tcm = new PoolingClientConnectionManager(registry); - HttpClient client = new DefaultHttpClient(tcm, params); - return client; + return httpclient; } - public static String getResponseString(HttpResponse httpResponse) throws IoTException { + public static String getResponseString(HttpResponse httpResponse) throws IOException { BufferedReader br = null; try { br = new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent())); @@ -95,9 +74,6 @@ public class IoTUtil { response += readLine; } return response; - } catch (IOException e) { - throw new IoTException("Error while reading the response from the remote. " - + e.getMessage(), e); } finally { EntityUtils.consumeQuietly(httpResponse.getEntity()); if (br != null) { diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl/pom.xml b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/pom.xml similarity index 93% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl/pom.xml rename to components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/pom.xml index 1800946bb..3a0095939 100644 --- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl/pom.xml +++ b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/pom.xml @@ -21,16 +21,15 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - device-mgt-iot-raspberrypi + raspberrypi-plugin org.wso2.carbon.devicemgt-plugins - 2.0.4-SNAPSHOT + 2.1.0-SNAPSHOT ../pom.xml 4.0.0 - org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl - 2.0.4-SNAPSHOT + org.wso2.carbon.device.mgt.iot.raspberrypi.api war WSO2 Carbon - IoT Server RaspberryPi API WSO2 Carbon - RaspberryPi Service API Implementation @@ -93,7 +92,7 @@ org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl + org.wso2.carbon.device.mgt.iot.raspberrypi.plugin provided @@ -120,7 +119,6 @@ org.wso2.carbon.devicemgt org.wso2.carbon.device.mgt.analytics.data.publisher - 1.1.0-SNAPSHOT provided @@ -135,7 +133,7 @@ org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.jwt.client.extension + org.wso2.carbon.identity.jwt.client.extension provided diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiControllerService.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiControllerService.java similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiControllerService.java rename to components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiControllerService.java diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiControllerServiceImpl.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiControllerServiceImpl.java similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiControllerServiceImpl.java rename to components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiControllerServiceImpl.java diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiManagerService.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiManagerService.java similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiManagerService.java rename to components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiManagerService.java diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiManagerServiceImpl.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiManagerServiceImpl.java similarity index 97% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiManagerServiceImpl.java rename to components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiManagerServiceImpl.java index ecc5e3a32..5151a6fa9 100644 --- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiManagerServiceImpl.java +++ b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiManagerServiceImpl.java @@ -37,10 +37,10 @@ import org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.constants.RaspberrypiCo import org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl.util.APIUtil; import org.wso2.carbon.device.mgt.iot.util.ZipArchive; import org.wso2.carbon.device.mgt.iot.util.ZipUtil; -import org.wso2.carbon.device.mgt.jwt.client.extension.JWTClient; -import org.wso2.carbon.device.mgt.jwt.client.extension.JWTClientManager; -import org.wso2.carbon.device.mgt.jwt.client.extension.dto.AccessTokenInfo; -import org.wso2.carbon.device.mgt.jwt.client.extension.exception.JWTClientException; +import org.wso2.carbon.identity.jwt.client.extension.JWTClient; +import org.wso2.carbon.identity.jwt.client.extension.JWTClientManager; +import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo; +import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException; import org.wso2.carbon.user.api.UserStoreException; import javax.ws.rs.core.Response; diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/dto/DeviceData.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/dto/DeviceData.java similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/dto/DeviceData.java rename to components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/dto/DeviceData.java diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/dto/SensorData.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/dto/SensorData.java similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/dto/SensorData.java rename to components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/dto/SensorData.java diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/exception/RaspberrypiException.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/exception/RaspberrypiException.java similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/exception/RaspberrypiException.java rename to components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/exception/RaspberrypiException.java diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/transport/RaspberryPiMQTTConnector.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/transport/RaspberryPiMQTTConnector.java similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/transport/RaspberryPiMQTTConnector.java rename to components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/transport/RaspberryPiMQTTConnector.java diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/util/APIUtil.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/util/APIUtil.java similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/util/APIUtil.java rename to components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/util/APIUtil.java diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/util/RaspberrypiServiceUtils.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/util/RaspberrypiServiceUtils.java similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/util/RaspberrypiServiceUtils.java rename to components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/util/RaspberrypiServiceUtils.java diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl/src/main/webapp/META-INF/permissions.xml b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/webapp/META-INF/permissions.xml similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl/src/main/webapp/META-INF/permissions.xml rename to components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/webapp/META-INF/permissions.xml diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl/src/main/webapp/META-INF/webapp-classloading.xml b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/webapp/META-INF/webapp-classloading.xml similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl/src/main/webapp/META-INF/webapp-classloading.xml rename to components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/webapp/META-INF/webapp-classloading.xml diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/webapp/WEB-INF/cxf-servlet.xml similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl/src/main/webapp/WEB-INF/cxf-servlet.xml rename to components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/webapp/WEB-INF/cxf-servlet.xml diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl/src/main/webapp/WEB-INF/web.xml b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl/src/main/webapp/WEB-INF/web.xml rename to components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/webapp/WEB-INF/web.xml diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl/pom.xml b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/pom.xml similarity index 89% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl/pom.xml rename to components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/pom.xml index 8d96e651a..bd822b57a 100644 --- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl/pom.xml +++ b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/pom.xml @@ -29,7 +29,7 @@ 4.0.0 - org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl + org.wso2.carbon.device.mgt.iot.raspberrypi.plugin bundle WSO2 Carbon - IoT Server RaspberryPi Management Plugin WSO2 Carbon - RaspberryPi Management/Control Plugin Implementation @@ -65,18 +65,10 @@ org.osgi.framework, org.osgi.service.component, org.apache.commons.logging, - javax.xml.bind.*, - javax.naming;resolution:=optional,, + javax.naming;resolution:=optional, javax.sql;resolution:=optional, - javax.xml.bind.annotation.*;resolution:=optional, - javax.xml.parsers;resolution:=optional, - javax.net;resolution:=optional, - javax.net.ssl;resolution:=optional, - org.w3c.dom;resolution:=optional, org.wso2.carbon.device.mgt.common.*, org.wso2.carbon.device.mgt.common, - org.wso2.carbon.context.*, - org.wso2.carbon.ndatasource.core, org.wso2.carbon.device.mgt.iot.*, org.wso2.carbon.device.mgt.extensions.feature.mgt.*, org.wso2.carbon.utils.* diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/constants/RaspberrypiConstants.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/constants/RaspberrypiConstants.java similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/constants/RaspberrypiConstants.java rename to components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/constants/RaspberrypiConstants.java diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/exception/RaspberrypiDeviceMgtPluginException.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/exception/RaspberrypiDeviceMgtPluginException.java similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/exception/RaspberrypiDeviceMgtPluginException.java rename to components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/exception/RaspberrypiDeviceMgtPluginException.java diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/RaspberrypiManager.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/RaspberrypiManager.java similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/RaspberrypiManager.java rename to components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/RaspberrypiManager.java diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/RaspberrypiManagerService.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/RaspberrypiManagerService.java similarity index 96% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/RaspberrypiManagerService.java rename to components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/RaspberrypiManagerService.java index 96ce170ef..963475d4c 100644 --- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/RaspberrypiManagerService.java +++ b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/RaspberrypiManagerService.java @@ -33,6 +33,7 @@ import java.util.List; public class RaspberrypiManagerService implements DeviceManagementService { private DeviceManager deviceManager; + private final static String DEVICE_TYPE_PROVIDER_DOMAIN = "carbon.super"; @Override public String getType() { @@ -41,12 +42,12 @@ public class RaspberrypiManagerService implements DeviceManagementService { @Override public String getProviderTenantDomain() { - return "carbon.super"; + return DEVICE_TYPE_PROVIDER_DOMAIN; } @Override public boolean isSharedWithAllTenants() { - return false; + return true; } @Override diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/dao/RaspberrypiDAO.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/dao/RaspberrypiDAO.java similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/dao/RaspberrypiDAO.java rename to components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/dao/RaspberrypiDAO.java diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/dao/impl/RaspberrypiDeviceDAOImpl.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/dao/impl/RaspberrypiDeviceDAOImpl.java similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/dao/impl/RaspberrypiDeviceDAOImpl.java rename to components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/dao/impl/RaspberrypiDeviceDAOImpl.java diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/feature/RaspberrypiFeatureManager.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/feature/RaspberrypiFeatureManager.java similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/feature/RaspberrypiFeatureManager.java rename to components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/feature/RaspberrypiFeatureManager.java diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/util/DeviceSchemaInitializer.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/util/DeviceSchemaInitializer.java similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/util/DeviceSchemaInitializer.java rename to components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/util/DeviceSchemaInitializer.java diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/util/RaspberrypiUtils.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/util/RaspberrypiUtils.java similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/util/RaspberrypiUtils.java rename to components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/util/RaspberrypiUtils.java diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/internal/RaspberrypiManagementServiceComponent.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/internal/RaspberrypiManagementServiceComponent.java similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/internal/RaspberrypiManagementServiceComponent.java rename to components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/internal/RaspberrypiManagementServiceComponent.java diff --git a/components/iot-plugins/raspberrypi-plugin/pom.xml b/components/iot-plugins/raspberrypi-plugin/pom.xml index 7d1d84f82..29c4a8605 100644 --- a/components/iot-plugins/raspberrypi-plugin/pom.xml +++ b/components/iot-plugins/raspberrypi-plugin/pom.xml @@ -33,10 +33,10 @@ http://wso2.org - org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl + org.wso2.carbon.device.mgt.iot.raspberrypi.plugin org.wso2.carbon.device.mgt.iot.raspberrypi.ui org.wso2.carbon.device.mgt.iot.raspberrypi.analytics - org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl + org.wso2.carbon.device.mgt.iot.raspberrypi.api diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/pom.xml b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/pom.xml similarity index 95% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/pom.xml rename to components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/pom.xml index abb81ac7e..e50829cf8 100644 --- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/pom.xml +++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/pom.xml @@ -21,15 +21,14 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - device-mgt-iot-virtualfirealarm + virtual-fire-alarm-plugin org.wso2.carbon.devicemgt-plugins - 2.0.4-SNAPSHOT + 2.1.0-SNAPSHOT ../pom.xml 4.0.0 - org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl - 2.0.4-SNAPSHOT + org.wso2.carbon.device.mgt.iot.virtualfirealarm.api war WSO2 Carbon - IoT Server VirtualFireAlarm API WSO2 Carbon - Virtual FireAlarm Service Management API Implementation @@ -57,7 +56,6 @@ org.wso2.carbon.devicemgt org.wso2.carbon.device.mgt.analytics.data.publisher - 1.1.0-SNAPSHOT provided @@ -118,7 +116,7 @@ org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl + org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin provided @@ -239,7 +237,7 @@ org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.jwt.client.extension + org.wso2.carbon.identity.jwt.client.extension provided diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmControllerService.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmControllerService.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmControllerService.java rename to components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmControllerService.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmControllerServiceImpl.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmControllerServiceImpl.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmControllerServiceImpl.java rename to components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmControllerServiceImpl.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmManagerService.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmManagerService.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmManagerService.java rename to components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmManagerService.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmManagerServiceImpl.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmManagerServiceImpl.java similarity index 97% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmManagerServiceImpl.java rename to components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmManagerServiceImpl.java index 98af9fd42..f230dac1a 100644 --- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmManagerServiceImpl.java +++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmManagerServiceImpl.java @@ -35,10 +35,10 @@ import org.wso2.carbon.device.mgt.iot.util.ZipArchive; import org.wso2.carbon.device.mgt.iot.util.ZipUtil; import org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl.util.APIUtil; import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.constants.VirtualFireAlarmConstants; -import org.wso2.carbon.device.mgt.jwt.client.extension.JWTClient; -import org.wso2.carbon.device.mgt.jwt.client.extension.JWTClientManager; -import org.wso2.carbon.device.mgt.jwt.client.extension.dto.AccessTokenInfo; -import org.wso2.carbon.device.mgt.jwt.client.extension.exception.JWTClientException; +import org.wso2.carbon.identity.jwt.client.extension.JWTClient; +import org.wso2.carbon.identity.jwt.client.extension.JWTClientManager; +import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo; +import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException; import org.wso2.carbon.user.api.UserStoreException; import javax.ws.rs.core.Response; diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/dto/DeviceData.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/dto/DeviceData.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/dto/DeviceData.java rename to components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/dto/DeviceData.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/dto/SensorData.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/dto/SensorData.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/dto/SensorData.java rename to components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/dto/SensorData.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/exception/VirtualFireAlarmException.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/exception/VirtualFireAlarmException.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/exception/VirtualFireAlarmException.java rename to components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/exception/VirtualFireAlarmException.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/transport/VirtualFireAlarmMQTTConnector.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/transport/VirtualFireAlarmMQTTConnector.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/transport/VirtualFireAlarmMQTTConnector.java rename to components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/transport/VirtualFireAlarmMQTTConnector.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/transport/VirtualFireAlarmXMPPConnector.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/transport/VirtualFireAlarmXMPPConnector.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/transport/VirtualFireAlarmXMPPConnector.java rename to components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/transport/VirtualFireAlarmXMPPConnector.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/APIUtil.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/APIUtil.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/APIUtil.java rename to components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/APIUtil.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/SecurityManager.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/SecurityManager.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/SecurityManager.java rename to components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/SecurityManager.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/VirtualFireAlarmServiceUtils.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/VirtualFireAlarmServiceUtils.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/VirtualFireAlarmServiceUtils.java rename to components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/VirtualFireAlarmServiceUtils.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/scep/ContentType.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/scep/ContentType.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/scep/ContentType.java rename to components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/scep/ContentType.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/scep/SCEPOperation.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/scep/SCEPOperation.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/scep/SCEPOperation.java rename to components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/scep/SCEPOperation.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/src/main/webapp/META-INF/permissions.xml b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/META-INF/permissions.xml similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/src/main/webapp/META-INF/permissions.xml rename to components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/META-INF/permissions.xml diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/src/main/webapp/META-INF/webapp-classloading.xml b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/META-INF/webapp-classloading.xml similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/src/main/webapp/META-INF/webapp-classloading.xml rename to components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/META-INF/webapp-classloading.xml diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/WEB-INF/cxf-servlet.xml similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/src/main/webapp/WEB-INF/cxf-servlet.xml rename to components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/WEB-INF/cxf-servlet.xml diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/src/main/webapp/WEB-INF/web.xml b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl/src/main/webapp/WEB-INF/web.xml rename to components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/WEB-INF/web.xml diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl/pom.xml b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/pom.xml similarity index 91% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl/pom.xml rename to components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/pom.xml index 0090fcc36..29b7704e1 100644 --- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl/pom.xml +++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/pom.xml @@ -29,7 +29,7 @@ 4.0.0 - org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl + org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin bundle WSO2 Carbon - IoT Server VirtualFireAlarm Management Plugin WSO2 Carbon - Virtual FireAlarm Management/Control Plugin Implementation @@ -65,18 +65,10 @@ org.osgi.framework, org.osgi.service.component, org.apache.commons.logging, - javax.xml.bind.*;resolution:=optional, javax.naming;resolution:=optional, javax.sql;resolution:=optional, - javax.xml.bind.annotation.*;resolution:=optional, - javax.xml.parsers;resolution:=optional, - javax.net;resolution:=optional, - javax.net.ssl;resolution:=optional, - org.w3c.dom;resolution:=optional, org.wso2.carbon.device.mgt.common.*, org.wso2.carbon.device.mgt.common, - org.wso2.carbon.context.*, - org.wso2.carbon.ndatasource.core, org.wso2.carbon.device.mgt.iot.*, org.wso2.carbon.device.mgt.extensions.feature.mgt.*, org.wso2.carbon.utils.* diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/constants/VirtualFireAlarmConstants.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/constants/VirtualFireAlarmConstants.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/constants/VirtualFireAlarmConstants.java rename to components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/constants/VirtualFireAlarmConstants.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/exception/VirtualFirealarmDeviceMgtPluginException.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/exception/VirtualFirealarmDeviceMgtPluginException.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/exception/VirtualFirealarmDeviceMgtPluginException.java rename to components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/exception/VirtualFirealarmDeviceMgtPluginException.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFireAlarmManager.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFireAlarmManager.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFireAlarmManager.java rename to components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFireAlarmManager.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFireAlarmManagerService.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFireAlarmManagerService.java similarity index 96% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFireAlarmManagerService.java rename to components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFireAlarmManagerService.java index 68c8ec94f..214afd849 100644 --- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFireAlarmManagerService.java +++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFireAlarmManagerService.java @@ -32,6 +32,8 @@ import java.util.List; public class VirtualFireAlarmManagerService implements DeviceManagementService{ private DeviceManager deviceManager; + private final static String DEVICE_TYPE_PROVIDER_DOMAIN = "carbon.super"; + @Override public String getType() { return VirtualFireAlarmConstants.DEVICE_TYPE; @@ -40,7 +42,7 @@ public class VirtualFireAlarmManagerService implements DeviceManagementService{ @Override public String getProviderTenantDomain() { - return "carbon.super"; + return DEVICE_TYPE_PROVIDER_DOMAIN; } @Override diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/dao/VirtualFireAlarmDAO.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/dao/VirtualFireAlarmDAO.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/dao/VirtualFireAlarmDAO.java rename to components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/dao/VirtualFireAlarmDAO.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/dao/impl/VirtualFireAlarmDeviceDAOImpl.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/dao/impl/VirtualFireAlarmDeviceDAOImpl.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/dao/impl/VirtualFireAlarmDeviceDAOImpl.java rename to components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/dao/impl/VirtualFireAlarmDeviceDAOImpl.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/feature/VirtualFirealarmFeatureManager.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/feature/VirtualFirealarmFeatureManager.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/feature/VirtualFirealarmFeatureManager.java rename to components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/feature/VirtualFirealarmFeatureManager.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/util/DeviceSchemaInitializer.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/util/DeviceSchemaInitializer.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/util/DeviceSchemaInitializer.java rename to components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/util/DeviceSchemaInitializer.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/util/VirtualFireAlarmUtils.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/util/VirtualFireAlarmUtils.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/util/VirtualFireAlarmUtils.java rename to components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/util/VirtualFireAlarmUtils.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/internal/VirtualFirealarmManagementServiceComponent.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/internal/VirtualFirealarmManagementServiceComponent.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/internal/VirtualFirealarmManagementServiceComponent.java rename to components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/internal/VirtualFirealarmManagementServiceComponent.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/pom.xml b/components/iot-plugins/virtual-fire-alarm-plugin/pom.xml index addf734b8..91a2933c5 100644 --- a/components/iot-plugins/virtual-fire-alarm-plugin/pom.xml +++ b/components/iot-plugins/virtual-fire-alarm-plugin/pom.xml @@ -33,12 +33,12 @@ http://wso2.org - org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl + org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl org.wso2.carbon.device.mgt.iot.virtualfirealarm.analytics - org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl + org.wso2.carbon.device.mgt.iot.virtualfirealarm.api diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/pom.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/pom.xml index 15f5e0f91..33605f760 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/pom.xml +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/pom.xml @@ -57,23 +57,14 @@ org.osgi.service.component, org.apache.commons.logging, javax.xml.bind.*, - javax.naming, javax.sql, - javax.xml.bind.annotation.*, - javax.xml.parsers.*;resolution:=optional, - org.w3c.dom, - org.wso2.carbon.core, org.wso2.carbon.context, - org.wso2.carbon.utils.*, org.wso2.carbon.device.mgt.common.*, org.wso2.carbon.device.mgt.mobile.*, org.wso2.carbon.ndatasource.core, org.wso2.carbon.policy.mgt.common.*, - org.wso2.carbon.policy.mgt.core.*, org.wso2.carbon.registry.core, - org.wso2.carbon.registry.core.exceptions, org.wso2.carbon.registry.core.service, - org.wso2.carbon.registry.core.session, org.wso2.carbon.registry.api, org.wso2.carbon.device.mgt.extensions.license.mgt.registry, com.google.gson.* diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManagementService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManagementService.java index 9949b69ae..c9f8f2c73 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManagementService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManagementService.java @@ -36,12 +36,23 @@ public class AndroidDeviceManagementService implements DeviceManagementService { private DeviceManager deviceManager; public static final String DEVICE_TYPE_ANDROID = "android"; + private static final String SUPER_TENANT_DOMAIN = "carbon.super"; @Override public String getType() { return AndroidDeviceManagementService.DEVICE_TYPE_ANDROID; } + @Override + public String getProviderTenantDomain() { + return SUPER_TENANT_DOMAIN; + } + + @Override + public boolean isSharedWithAllTenants() { + return false; + } + @Override public void init() throws DeviceManagementException { this.deviceManager = new AndroidDeviceManager(); diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManagementService.java b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManagementService.java index 18e088ee0..ee2729275 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManagementService.java +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManagementService.java @@ -34,12 +34,23 @@ public class AndroidDeviceManagementService implements DeviceManagementService { private DeviceManager deviceManager; public static final String DEVICE_TYPE_ANDROID = "android"; + private static final String SUPER_TENANT_DOMAIN = "carbon.super"; @Override public String getType() { return AndroidDeviceManagementService.DEVICE_TYPE_ANDROID; } + @Override + public String getProviderTenantDomain() { + return SUPER_TENANT_DOMAIN; + } + + @Override + public boolean isSharedWithAllTenants() { + return true; + } + @Override public void init() throws DeviceManagementException { this.deviceManager = new AndroidDeviceManager(); diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManagementService.java b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManagementService.java index 45426cd35..3ac01a301 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManagementService.java +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManagementService.java @@ -36,12 +36,23 @@ public class WindowsDeviceManagementService implements DeviceManagementService { private DeviceManager deviceManager; public static final String DEVICE_TYPE_WINDOWS = "windows"; + private static final String SUPER_TENANT_DOMAIN = "carbon.super"; @Override public String getType() { return WindowsDeviceManagementService.DEVICE_TYPE_WINDOWS; } + @Override + public String getProviderTenantDomain() { + return SUPER_TENANT_DOMAIN; + } + + @Override + public boolean isSharedWithAllTenants() { + return true; + } + @Override public void init() throws DeviceManagementException { this.deviceManager = new WindowsDeviceManager(); diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/pom.xml b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/pom.xml index 2440f0fff..66b075e66 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/pom.xml +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/pom.xml @@ -57,26 +57,15 @@ org.osgi.service.component, org.apache.commons.logging, javax.xml.bind.*, - javax.naming, javax.sql, - javax.xml.bind.annotation.*, - javax.xml.parsers.*;resolution:=optional, - org.w3c.dom, - org.wso2.carbon.core, - org.wso2.carbon.context, - org.wso2.carbon.utils.*, org.wso2.carbon.device.mgt.common.*, org.wso2.carbon.device.mgt.mobile.*, org.wso2.carbon.ndatasource.core, org.wso2.carbon.policy.mgt.common.*, - org.wso2.carbon.policy.mgt.core.*, org.wso2.carbon.registry.core, - org.wso2.carbon.registry.core.exceptions, org.wso2.carbon.registry.core.service, - org.wso2.carbon.registry.core.session, org.wso2.carbon.registry.api, - org.wso2.carbon.device.mgt.extensions.license.mgt.registry, - com.google.gson.* + org.wso2.carbon.device.mgt.extensions.license.mgt.registry !org.wso2.carbon.device.mgt.mobile.windows.internal, diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsDeviceManagementService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsDeviceManagementService.java index 366fda747..74bb7992f 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsDeviceManagementService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsDeviceManagementService.java @@ -36,12 +36,23 @@ public class WindowsDeviceManagementService implements DeviceManagementService { private DeviceManager deviceManager; public static final String DEVICE_TYPE_WINDOWS = "windows"; + private final static String DEVICE_TYPE_PROVIDER_DOMAIN = "carbon.super"; @Override public String getType() { return WindowsDeviceManagementService.DEVICE_TYPE_WINDOWS; } + @Override + public String getProviderTenantDomain() { + return DEVICE_TYPE_PROVIDER_DOMAIN; + } + + @Override + public boolean isSharedWithAllTenants() { + return true; + } + @Override public void init() throws DeviceManagementException { this.deviceManager = new WindowsDeviceManager(); diff --git a/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/pom.xml b/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/pom.xml new file mode 100644 index 000000000..d5e1b378f --- /dev/null +++ b/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/pom.xml @@ -0,0 +1,219 @@ + + + + + + + + org.wso2.carbon.devicemgt-plugins + androidsense-plugin-feature + 2.1.0-SNAPSHOT + ../pom.xml + + + 4.0.0 + org.wso2.carbon.device.mgt.iot.androidsense.feature + 2.1.0-SNAPSHOT + pom + WSO2 Carbon - IoT Server Android Sense Feature + http://wso2.org + This feature contains the Android Sense Device type specific implementations for the IoT Server + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.androidsense.plugin + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.androidsense.api + war + + + com.h2database.wso2 + h2-database-engine + + + + + + + maven-resources-plugin + + + copy-resources + generate-resources + + copy-resources + + + src/main/resources + + + resources + + build.properties + p2.inf + + + + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + unpack + package + + unpack + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.androidsense.analytics + + ${project.version} + zip + true + + ${project.build.directory}/maven-shared-archive-resources/carbonapps + + **/* + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.androidsense.ui + + ${project.version} + zip + true + + ${project.build.directory}/maven-shared-archive-resources/jaggeryapps/devicemgt + + **/* + + + + + + copy-jaxrs-war + package + + copy + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.androidsense.api + war + true + ${project.build.directory}/maven-shared-archive-resources/webapps/ + android_sense.war + + + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + + create-android-sense-plugin-mgt-schema + package + + run + + + + + + + + + + + + + + + + + + + + + + + + + + + org.wso2.maven + carbon-p2-plugin + ${carbon.p2.plugin.version} + + + p2-feature-generation + package + + p2-feature-gen + + + org.wso2.carbon.device.mgt.iot.androidsense + ../../../features/etc/feature.properties + + + org.wso2.carbon.p2.category.type:server + org.eclipse.equinox.p2.type.group:false + + + + + org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot.androidsense.plugin:${carbon.devicemgt.plugins.version} + + + + org.wso2.carbon.core.server:${carbon.kernel.version} + org.wso2.carbon.device.mgt.server:${carbon.device.mgt.version} + + + + + + + + + diff --git a/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/agent/androidsense.apk b/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/agent/androidsense.apk new file mode 100644 index 000000000..730f3d65c Binary files /dev/null and b/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/agent/androidsense.apk differ diff --git a/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/agent/sketch.properties b/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/agent/sketch.properties new file mode 100644 index 000000000..aefe1a60b --- /dev/null +++ b/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/agent/sketch.properties @@ -0,0 +1,2 @@ +templates=androidsense.apk +zipfilename=androidsense.zip \ No newline at end of file diff --git a/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/build.properties b/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/build.properties new file mode 100644 index 000000000..93c4b1070 --- /dev/null +++ b/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/build.properties @@ -0,0 +1 @@ +custom = true \ No newline at end of file diff --git a/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/configs/android_sense.json b/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/configs/android_sense.json new file mode 100644 index 000000000..f3ab98a9b --- /dev/null +++ b/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/configs/android_sense.json @@ -0,0 +1,120 @@ +{ + "deviceType": { + "label": "Android Sense", + "category": "iot" + }, + "analyticStreams": [ + { + "name": "Accelerometer", + "table": "DEVICE_ACCELEROMETER_SUMMARY", + "ui_unit": { + "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"}} + ] + } + }, + { + "name": "Battery", + "table": "DEVICE_BATTERY_SUMMARY", + "ui_unit": { + "name": "cdmf.unit.analytics.line-chart", + "data":[ + {"column": {"name":"TIME", "label":"time", "ui-mapping":"x-axis"}}, + {"column": {"name":"BATTERY", "label":"Battery Level", "ui-mapping":"y-axis"}} + ] + } + }, + { + "name": "GPS", + "table": "DEVICE_GPS_SUMMARY", + "ui_unit": { + "name": "cdmf.unit.analytics.google-map", + "data":[ + {"column": {"name":"TIME", "label":"time", "ui-mapping":"time"}}, + {"column": {"name":"LATITUDE", "label":"Latitude", "ui-mapping":"lat"}}, + {"column": {"name":"LONGITUDE", "label":"Longitude", "ui-mapping":"lat"}} + ] + } + }, + { + "name": "Gravity", + "table": "DEVICE_GRAVITY_SUMMARY", + "ui_unit": { + "name": "cdmf.unit.analytics.line-chart", + "data":[ + {"column": {"name":"TIME", "label":"time", "ui-mapping":"x-axis"}}, + {"column": {"name":"GRAVITY", "label":"Gravity", "ui-mapping":"y-axis"}} + ] + } + }, + { + "name": "Gyroscope", + "table": "DEVICE_GYROSCOPE_SUMMARY", + "ui_unit": { + "name": "cdmf.unit.analytics.line-chart", + "data":[ + {"column": {"name":"TIME", "label":"time", "ui-mapping":"x-axis"}}, + {"column": {"name":"GYROSCOPE", "label":"Gyroscope", "ui-mapping":"y-axis"}} + ] + } + }, + { + "name": "Light", + "table": "DEVICE_LIGHT_SUMMARY", + "ui_unit": { + "name": "cdmf.unit.analytics.line-chart", + "data":[ + {"column": {"name":"TIME", "label":"time", "ui-mapping":"x-axis"}}, + {"column": {"name":"LIGHT", "label":"Light", "ui-mapping":"y-axis"}} + ] + } + }, + { + "name": "Magnetic", + "table": "DEVICE_MAGNETIC_SUMMARY", + "ui_unit": { + "name": "cdmf.unit.analytics.line-chart", + "data":[ + {"column": {"name":"TIME", "label":"time", "ui-mapping":"x-axis"}}, + {"column": {"name":"MAGNETIC", "label":"Magnetic", "ui-mapping":"y-axis"}} + ] + } + }, + { + "name": "Pressure", + "table": "DEVICE_PRESSURE_SUMMARY", + "ui_unit": { + "name": "cdmf.unit.analytics.line-chart", + "data":[ + {"column": {"name":"TIME", "label":"time", "ui-mapping":"x-axis"}}, + {"column": {"name":"PRESSURE", "label":"Pressure", "ui-mapping":"y-axis"}} + ] + } + }, + { + "name": "Proximity", + "table": "DEVICE_PROXIMITY_SUMMARY", + "ui_unit": { + "name": "cdmf.unit.analytics.bar-chart", + "data":[ + {"column": {"name":"TIME", "label":"time", "ui-mapping":"x-axis"}}, + {"column": {"name":"PROXIMITY", "label":"Proximity", "ui-mapping":"y-axis"}} + ] + } + }, + { + "name": "Rotation", + "table": "DEVICE_ROTATION_SUMMARY", + "ui_unit": "cdmf.unit.analytics.line-chart", + "ui_unit": { + "name": "cdmf.unit.analytics.line-chart", + "data":[ + {"column": {"name":"TIME", "label":"time", "ui-mapping":"x-axis"}}, + {"column": {"name":"ROTATION", "label":"Rotation", "ui-mapping":"y-axis"}} + ] + } + } + ] +} \ No newline at end of file diff --git a/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/datasources/androidsense-datasources.xml b/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/datasources/androidsense-datasources.xml new file mode 100644 index 000000000..9a1374b09 --- /dev/null +++ b/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/datasources/androidsense-datasources.xml @@ -0,0 +1,46 @@ + + + + + org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader + + + + AndroidSenseDM_DB + The datasource used for the Android Sense database + + jdbc/AndroidSenseDM_DB + + + + jdbc:h2:repository/database/AndroidSenseDM_DB;DB_CLOSE_ON_EXIT=FALSE + + wso2carbon + wso2carbon + org.h2.Driver + 50 + 60000 + true + SELECT 1 + 30000 + + + + + diff --git a/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/dbscripts/h2.sql b/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/dbscripts/h2.sql new file mode 100644 index 000000000..218cdbf05 --- /dev/null +++ b/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/dbscripts/h2.sql @@ -0,0 +1,11 @@ + +-- ----------------------------------------------------- +-- Table `ANDROID_DEVICE` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `ANDROID_SENSE_DEVICE` ( + `ANDROID_DEVICE_ID` VARCHAR(45) NOT NULL , + `DEVICE_NAME` VARCHAR(100) NULL DEFAULT NULL, + PRIMARY KEY (`ANDROID_DEVICE_ID`) ); + + + diff --git a/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/dbscripts/mysql.sql b/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/dbscripts/mysql.sql new file mode 100644 index 000000000..4637b4daf --- /dev/null +++ b/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/dbscripts/mysql.sql @@ -0,0 +1,12 @@ +-- ----------------------------------------------------- +-- Table `ANDROID_DEVICE` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `ANDROID_SENSE_DEVICE` ( + `ANDROID_DEVICE_ID` VARCHAR(45) NOT NULL , + `DEVICE_NAME` VARCHAR(100) NULL DEFAULT NULL, + PRIMARY KEY (`ANDROID_DEVICE_ID`) ) +ENGINE = InnoDB; + + + + diff --git a/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/p2.inf b/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/p2.inf new file mode 100644 index 000000000..840e414d6 --- /dev/null +++ b/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/p2.inf @@ -0,0 +1,17 @@ +instructions.configure = \ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../conf/device-types/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/configs/,target:${installFolder}/../../conf/device-types/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/webapps/,target:${installFolder}/../../deployment/server/webapps/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/carbonapps/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/carbonapps/,target:${installFolder}/../../deployment/server/carbonapps/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/dbscripts/,target:${installFolder}/../../../dbscripts/cdm/plugins/android_sense,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/datasources/,target:${installFolder}/../../conf/datasources/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/jaggeryapps/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/jaggeryapps/,target:${installFolder}/../../deployment/server/jaggeryapps/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/sketches/);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/sketches/android_sense/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/agent/,target:${installFolder}/../../resources/sketches/android_sense/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../database/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/database/,target:${installFolder}/../../database/,overwrite:true);\ + diff --git a/features/iot-plugins-feature/androidsense-plugin-feature/pom.xml b/features/iot-plugins-feature/androidsense-plugin-feature/pom.xml new file mode 100644 index 000000000..ba1348b7d --- /dev/null +++ b/features/iot-plugins-feature/androidsense-plugin-feature/pom.xml @@ -0,0 +1,40 @@ + + + + + + + org.wso2.carbon.devicemgt-plugins + iot-plugins-feature + 2.1.0-SNAPSHOT + ../pom.xml + + + 4.0.0 + androidsense-plugin-feature + pom + WSO2 Carbon - IoT Server Android Sense Device Feature + http://wso2.org + + + org.wso2.carbon.device.mgt.iot.androidsense.feature + + + diff --git a/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/pom.xml b/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/pom.xml new file mode 100644 index 000000000..a3c706701 --- /dev/null +++ b/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/pom.xml @@ -0,0 +1,222 @@ + + + + + + + + org.wso2.carbon.devicemgt-plugins + arduino-plugin-feature + 2.1.0-SNAPSHOT + ../pom.xml + + + 4.0.0 + org.wso2.carbon.device.mgt.iot.arduino.feature + pom + WSO2 Carbon - IoT Server Arduino Feature + http://wso2.org + This feature contains the Arduino Device type specific implementations for the IoT Server + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.arduino.plugin + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.arduino.api + war + + + com.h2database.wso2 + h2-database-engine + + + + + + + maven-resources-plugin + + + copy-resources + generate-resources + + copy-resources + + + src/main/resources + + + resources + + build.properties + p2.inf + + + + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + unpack + package + + unpack + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.arduino.analytics + + ${project.version} + zip + true + + ${project.build.directory}/maven-shared-archive-resources/carbonapps + + **/* + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.arduino.ui + + ${project.version} + zip + true + + ${project.build.directory}/maven-shared-archive-resources/jaggeryapps/devicemgt + + **/* + + + + + + copy-jaxrs-war + package + + copy + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.arduino.api + + war + true + ${project.build.directory}/maven-shared-archive-resources/webapps/ + + arduino.war + + + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + + create-arduino-plugin-mgt-schema + package + + run + + + + + + + + + + + + + + + + + + + + + + + + + + + org.wso2.maven + carbon-p2-plugin + ${carbon.p2.plugin.version} + + + p2-feature-generation + package + + p2-feature-gen + + + org.wso2.carbon.device.mgt.iot.arduino + ../../../features/etc/feature.properties + + + org.wso2.carbon.p2.category.type:server + org.eclipse.equinox.p2.type.group:false + + + + + org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot.arduino.plugin:${carbon.devicemgt.plugins.version} + + + + org.wso2.carbon.core.server:${carbon.kernel.version} + + org.wso2.carbon.device.mgt.server:${carbon.device.mgt.version} + + + + + + + + + + diff --git a/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/ArduinoBoardSketch.h b/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/ArduinoBoardSketch.h new file mode 100644 index 000000000..d55466d90 --- /dev/null +++ b/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/ArduinoBoardSketch.h @@ -0,0 +1,69 @@ +/** + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +**/ + +#ifndef ArduinoWifiAgent_H +#define ArduinoWifiAgent_H + +#include "Arduino.h" + +// These are the interrupt and control pins +#define ADAFRUIT_CC3000_IRQ 3 // MUST be an interrupt pin! +// These can be any two pins +#define ADAFRUIT_CC3000_VBAT 5 +#define ADAFRUIT_CC3000_CS 10 + +#define WLAN_SSID "ssid" // Your wifi network SSID (cannot be longer than 32 characters!) +#define WLAN_PASS "password" // Your wifi network password + +#define WLAN_SECURITY WLAN_SEC_WPA2 +// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2 +#define IDLE_TIMEOUT_MS 3000 + + +#define DEVICE_OWNER "${DEVICE_OWNER}" +#define DEVICE_ID "${DEVICE_ID}" +#define DEVICE_TOKEN "${DEVICE_TOKEN}" +#define REFRESH_DEVICE_TOKEN "${DEVICE_REFRESH_TOKEN}" + +#define SERVICE_EPOINT "/arduino/controller/" + +#define POLL_INTERVAL 1000 +#define PUSH_INTERVAL 10000 +#define DEBUG true +#define CON_DEBUG true + +#define SERVICE_PORT 9763 //http port of iot server + +byte server[4] = {192,168,43,168}; //Ip address of iot server +byte deviceIP[4] = { 192, 168, 43,11 }; //Ststic ip address of arduino + +byte dns2[] = { 8, 8, 8, 8 }; //Ststic dns of arduino +byte subnet[] = { 255, 255, 255, 0 }; //Ststic subnet of arduino +byte gateway[] = { 192, 168, 43, 1 }; //Ststic gateway of arduino + + +String host, jsonPayLoad, replyMsg; +String responseMsg, subStrn; +double cpuTemperature =0; +static unsigned long pushTimestamp = 0; +static unsigned long pollTimestamp = 0; + + +#endif + + diff --git a/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/ArduinoBoardSketch.ino b/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/ArduinoBoardSketch.ino new file mode 100644 index 000000000..50627d074 --- /dev/null +++ b/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/ArduinoBoardSketch.ino @@ -0,0 +1,83 @@ +/** + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +**/ + + +#include "ArduinoBoardSketch.h" +#include +#include +#include +Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT, + SPI_CLOCK_DIVIDER); // you can change this clock speed + +Adafruit_CC3000_Client client; + +uint32_t sserver; + + +void setup() +{ + Serial.begin(115200); + Serial.println(F("Internal Temperature Sensor")); + pinMode(6, OUTPUT); + pinMode(13, OUTPUT); + connectHttp(); + setupResource(); + wdt_enable(WDTO_8S); + +} + +void loop() +{ + wdt_reset(); + while( !cc3000.checkConnected() ){ + connectHttp(); + + } + + + cpuTemperature=getBoardTemp(); + + + if(millis() - pushTimestamp > PUSH_INTERVAL){ + while (!client.connected()) { + setupClient(); + } + pushData(); + + pushTimestamp = millis(); + } + + //Serial.println("PUSHED"); + + + wdt_reset(); + + if(millis() - pollTimestamp > POLL_INTERVAL){ + while (!client.connected()) { + setupClient(); + } + Serial.println("Read Controls"); + readControls(); + + pollTimestamp = millis(); + + } + +// //Serial.println("LOOPING"); + wdt_reset(); +} \ No newline at end of file diff --git a/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/Connect.ino b/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/Connect.ino new file mode 100644 index 000000000..dbc838a89 --- /dev/null +++ b/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/Connect.ino @@ -0,0 +1,158 @@ +/** + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +**/ + +#include "ArduinoBoardSketch.h" +/********************************************************************************************** + Use the below variables when required to set a static IP for the WifiSheild + ***********************************************************************************************/ + + uint32_t ip, ddns, ssubnet, ggateway; + +String connecting = "connecting.... "; + +void connectHttp() { + /* Initialise the module */ + if(DEBUG) Serial.println(F("\nInitializing...")); + if (!cc3000.begin()) + { + if(DEBUG) Serial.println(F("Couldn't begin()! Check your wiring?")); + while(1); + } + + /********************************************************************************************** + Only required if using static IP for the WifiSheild + ***********************************************************************************************/ + + ip = cc3000.IP2U32(deviceIP[0], deviceIP[1], deviceIP[2], deviceIP[3]); + ddns = cc3000.IP2U32(dns2[0], dns2[1], dns2[2], dns2[3]); + ssubnet = cc3000.IP2U32(subnet[0], subnet[1], subnet[2], subnet[3]); + ggateway = cc3000.IP2U32(gateway[0], gateway[1], gateway[2], gateway[3]); + cc3000.setStaticIPAddress(ip, ssubnet, ggateway, ddns); // required for setting static IP + + /***********************************************************************************************/ + + + sserver = cc3000.IP2U32(server[0], server[1], server[2], server[3]); + + if(CON_DEBUG) { + Serial.print(F("\nAttempting to connect to ")); + Serial.println(WLAN_SSID); + } + + cc3000.deleteProfiles(); + + if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) { + if(CON_DEBUG) Serial.println(F("Failed!")); + while(1); + } + + if(CON_DEBUG) Serial.println(F("Connected to Wifi network!")); + + if(CON_DEBUG) Serial.println(F("Request DHCP")); + while (!cc3000.checkDHCP()) + { + delay(100); + } + + /* Display the IP address DNS, Gateway, etc. */ + while (! displayConnectionDetails()) { + delay(1000); + } + + if (cc3000.checkConnected()) { + Serial.println("client Connected to AP"); + client = cc3000.connectTCP(sserver, SERVICE_PORT); + if (client.connected()) { + if(CON_DEBUG) Serial.println("client Connected to server"); + } else { + if(CON_DEBUG) Serial.println(F("client Connection failed")); + } + } else { + Serial.println(F("client Connection to AP failed")); + } + + if(CON_DEBUG) Serial.println(F("-------------------------------------")); +} + + +void setupResource(){ + String hostIP = getHostIP(server); + String port = String(SERVICE_PORT); + + host = "Host: " + hostIP + ":" + port; + if(DEBUG) Serial.println(host); + + jsonPayLoad = "{\"owner\":\""; + jsonPayLoad += String(DEVICE_OWNER); + jsonPayLoad += "\",\"deviceId\":\""; + jsonPayLoad += String(DEVICE_ID); + jsonPayLoad += "\",\"reply\":\""; + + if(DEBUG) { + Serial.print("JSON Payload: "); + Serial.println(jsonPayLoad); + Serial.println("-------------------------------"); + } +} + +String getHostIP(byte server[4]){ + String hostIP = String(server[0]); + + for ( int index = 1; index < 4; index++) { + hostIP += "." + String(server[index]); + } + + return hostIP; +} + + +bool displayConnectionDetails(void) +{ + uint32_t ipAddress, netmask, gateway, dhcpserv, dnsserv; + + if(!cc3000.getIPAddress(&ipAddress, &netmask, &gateway, &dhcpserv, &dnsserv)) + { + if(DEBUG) Serial.println(F("Unable to retrieve the IP Address!\r\n")); + return false; + } + else + { + if(CON_DEBUG) { + Serial.print(F("\nIP Addr: ")); cc3000.printIPdotsRev(ipAddress); + Serial.print(F("\nNetmask: ")); cc3000.printIPdotsRev(netmask); + Serial.print(F("\nGateway: ")); cc3000.printIPdotsRev(gateway); + Serial.print(F("\nDHCPsrv: ")); cc3000.printIPdotsRev(dhcpserv); + Serial.print(F("\nDNSserv: ")); cc3000.printIPdotsRev(dnsserv); + Serial.println(); + } + return true; + } +} + +void setupClient(){ + client = cc3000.connectTCP(sserver, SERVICE_PORT); //SERVICE_PORT + if (client.connected()) { + if(CON_DEBUG) Serial.println("client Connected to server"); + } else { + while( !cc3000.checkConnected() ){ + connectHttp(); + + } + if(CON_DEBUG) Serial.println(F("client Connection failed")); + } +} \ No newline at end of file diff --git a/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/PollServer.ino b/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/PollServer.ino new file mode 100644 index 000000000..486fad7a1 --- /dev/null +++ b/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/PollServer.ino @@ -0,0 +1,76 @@ +/** + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +**/ + +#include "ArduinoBoardSketch.h" +void readControls() { + // String responseMsg; + + Serial.println("Started.."); + + client.fastrprint(F("GET ")); + client.fastrprint(SERVICE_EPOINT); + client.fastrprint(F("readcontrols")); + client.fastrprint(F(" HTTP/1.1")); + client.fastrprint(F("\n")); + client.fastrprint(host.c_str()); + client.fastrprint(F("\n")); + client.fastrprint(DEVICE_ID); + client.fastrprint(F("owner: ")); + client.fastrprint(DEVICE_OWNER); + client.fastrprint(F("\n")); + client.fastrprint(F("deviceId: ")); + client.fastrprint(F(DEVICE_ID)); + client.fastrprint(F("\n")); + client.fastrprint(F("deviceId: ")); + client.fastrprint(F("protocol: HTTP\n")); + client.println(); + + + delay(1000); + Serial.println("Ended.."); + while (client.available()) { + char response = client.read(); + responseMsg += response; + + } + int index = responseMsg.lastIndexOf(":"); + int newLine = responseMsg.lastIndexOf("\n"); + subStrn = responseMsg.substring(index + 1); + responseMsg = responseMsg.substring(newLine + 1, index); + + if(DEBUG) { + Serial.print(responseMsg); + Serial.println(); + Serial.println("-------------------------------"); + } + + if (subStrn.equals("ON")) { + Serial.println("ITS ON"); + digitalWrite(13, HIGH); + digitalWrite(6, HIGH); + } else if (subStrn.equals("OFF")){ + + Serial.println("ITS OFF"); + digitalWrite(13, LOW); + digitalWrite(6, LOW); + + } + +} + + diff --git a/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/PushData.ino b/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/PushData.ino new file mode 100644 index 000000000..6b95b4155 --- /dev/null +++ b/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/PushData.ino @@ -0,0 +1,138 @@ +/** + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +**/ + +#include "ArduinoBoardSketch.h" + +/********************************************************************************************** + This method will traverse the array of digital pins and batch the data from the those pins together. + It makes a single call to the server and sends all pin values as a batch. + Server dis-assembles it accordingly and makes multiple publish calls for each sensor type. + ***********************************************************************************************/ + +void pushData(){ + String payLoad = "Temp"; + payLoad = payLoad + "\",\"value\":\""; + + + payLoad+=cpuTemperature; + + + payLoad += "\"}"; + + client.fastrprint(F("POST ")); + client.fastrprint(SERVICE_EPOINT); client.fastrprint(F("pushdata")); + client.fastrprint(F(" HTTP/1.1")); client.fastrprint(F("\n")); + client.fastrprint(host.c_str()); client.fastrprint(F("\n")); + client.fastrprint(F("Content-Type: application/json")); client.fastrprint(F("\n")); + client.fastrprint(F("Content-Length: ")); + + int payLength = jsonPayLoad.length() + payLoad.length(); + + client.fastrprint(String(payLength).c_str()); client.fastrprint(F("\n")); + client.fastrprint(F("\n")); + + if(DEBUG) { + Serial.print("POST "); + Serial.print(SERVICE_EPOINT); + Serial.print("pushdata"); + Serial.print(" HTTP/1.1"); Serial.println(); + Serial.print(host); Serial.println(); + Serial.print("Content-Type: application/json"); Serial.println(); + Serial.print("Content-Length: "); + Serial.print(payLength); Serial.println(); + Serial.println(); + } + + + int chunkSize = 50; + + for (int i = 0; i < jsonPayLoad.length(); i++) { + if ( (i+1)*chunkSize > jsonPayLoad.length()) { + client.print(jsonPayLoad.substring(i*chunkSize, jsonPayLoad.length())); + if(DEBUG) Serial.print(jsonPayLoad.substring(i*chunkSize, jsonPayLoad.length())); + i = jsonPayLoad.length(); + } else { + client.print(jsonPayLoad.substring(i*chunkSize, (i+1)*chunkSize)); + if(DEBUG) Serial.print(jsonPayLoad.substring(i*chunkSize, (i+1)*chunkSize)); + } + } + + for (int i = 0; i < payLoad.length(); i++) { + if ( (i+1)*chunkSize > payLoad.length()) { + client.print(payLoad.substring(i*chunkSize, payLoad.length())); + if(DEBUG) Serial.print(payLoad.substring(i*chunkSize, payLoad.length())); + i = payLoad.length(); + } else { + client.print(payLoad.substring(i*chunkSize, (i+1)*chunkSize)); + if(DEBUG) Serial.print(payLoad.substring(i*chunkSize, (i+1)*chunkSize)); + } + } + + client.fastrprint(F("\n")); + if(DEBUG) Serial.println(); + + delay(1000); + + + while (client.available()) { + char response = client.read(); + if(DEBUG) Serial.print(response); + } + + + if(DEBUG) { + Serial.println(); + Serial.println("-------------------------------"); + } + + payLoad = ""; +} + + + + +double getBoardTemp(void) +{ + unsigned int wADC; + double t; + + // The internal temperature has to be used + // with the internal reference of 1.1V. + // Channel 8 can not be selected with + // the analogRead function yet. + + // Set the internal reference and mux. + ADMUX = (_BV(REFS1) | _BV(REFS0) | _BV(MUX3)); + ADCSRA |= _BV(ADEN); // enable the ADC + + delay(20); // wait for voltages to become stable. + + ADCSRA |= _BV(ADSC); // Start the ADC + + // Detect end-of-conversion + while (bit_is_set(ADCSRA,ADSC)); + + // Reading register "ADCW" takes care of how to read ADCL and ADCH. + wADC = ADCW; + + // The offset of 324.31 could be wrong. It is just an indication. + t = (wADC - 324.31 ) / 1.22; + + // The returned temperature is in degrees Celcius. + return (t); +} diff --git a/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/sketch.properties b/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/sketch.properties new file mode 100644 index 000000000..57ba905ef --- /dev/null +++ b/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/sketch.properties @@ -0,0 +1,20 @@ +# +# Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +# +# WSO2 Inc. licenses this file to you under the Apache License, +# Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +templates=ArduinoBoardSketch.h +zipfilename=ArduinoBoardSketch.zip \ No newline at end of file diff --git a/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/build.properties b/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/build.properties new file mode 100644 index 000000000..9c86577d7 --- /dev/null +++ b/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/build.properties @@ -0,0 +1 @@ +custom = true diff --git a/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/configs/arduino.json b/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/configs/arduino.json new file mode 100644 index 000000000..9d2ba3682 --- /dev/null +++ b/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/configs/arduino.json @@ -0,0 +1,20 @@ +{ + "deviceType": { + "label": "Arduino", + "category": "iot", + "downloadAgentUri": "manager/device/arduino/download", + }, + "analyticStreams": [ + { + "name": "Temperature", + "table": "DEVICE_TEMPERATURE_SUMMARY", + "ui_unit": { + "name": "cdmf.unit.analytics.line-chart", + "data":[ + {"column": {"name":"TIME", "label":"time", "ui-mapping":"x-axis"}}, + {"column": {"name":"TEMPERATURE", "label":"temperature", "ui-mapping":"y-axis"}} + ] + } + } + ] +} \ No newline at end of file diff --git a/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/datasources/arduino-datasources.xml b/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/datasources/arduino-datasources.xml new file mode 100644 index 000000000..767bee7fb --- /dev/null +++ b/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/datasources/arduino-datasources.xml @@ -0,0 +1,48 @@ + + + + + org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader + + + + + Arduino_DB + The datasource used for the Arduino database + + jdbc/ArduinoDM_DB + + + + jdbc:h2:repository/database/ArduinoDM_DB;DB_CLOSE_ON_EXIT=FALSE + + wso2carbon + wso2carbon + org.h2.Driver + 50 + 60000 + true + SELECT 1 + 30000 + + + + + + diff --git a/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/dbscripts/h2.sql b/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/dbscripts/h2.sql new file mode 100644 index 000000000..2e9bc926b --- /dev/null +++ b/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/dbscripts/h2.sql @@ -0,0 +1,11 @@ + +-- ----------------------------------------------------- +-- Table for `ARDUINO_DEVICE` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `ARDUINO_DEVICE` ( + `ARDUINO_DEVICE_ID` VARCHAR(45) NOT NULL , + `DEVICE_NAME` VARCHAR(100) NULL DEFAULT NULL, + PRIMARY KEY (`ARDUINO_DEVICE_ID`) ); + + + diff --git a/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/dbscripts/mysql.sql b/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/dbscripts/mysql.sql new file mode 100644 index 000000000..a9d5fd922 --- /dev/null +++ b/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/dbscripts/mysql.sql @@ -0,0 +1,12 @@ +-- ----------------------------------------------------- +-- Table for `ARDUINO_DEVICE` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `ARDUINO_DEVICE` ( + `ARDUINO_DEVICE_ID` VARCHAR(45) NOT NULL , + `DEVICE_NAME` VARCHAR(100) NULL DEFAULT NULL, + PRIMARY KEY (`ARDUINO_DEVICE_ID`) ) +ENGINE = InnoDB; + + + + diff --git a/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/p2.inf b/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/p2.inf new file mode 100644 index 000000000..ef0ff6ae9 --- /dev/null +++ b/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/p2.inf @@ -0,0 +1,14 @@ +instructions.configure = \ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../conf/device-types/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.arduino_${feature.version}/configs/,target:${installFolder}/../../conf/device-types/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.arduino_${feature.version}/webapps/,target:${installFolder}/../../deployment/server/webapps/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/sketches/);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/sketches/arduino/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.arduino_${feature.version}/agent/,target:${installFolder}/../../resources/sketches/arduino/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.arduino_${feature.version}/dbscripts/,target:${installFolder}/../../../dbscripts/cdm/plugins/arduino,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/jaggeryapps/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.arduino_${feature.version}/jaggeryapps/,target:${installFolder}/../../deployment/server/jaggeryapps/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.arduino_${feature.version}/datasources/,target:${installFolder}/../../conf/datasources/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../database/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.arduino_${feature.version}/database/,target:${installFolder}/../../database/,overwrite:true);\ diff --git a/features/iot-plugins-feature/arduino-plugin-feature/pom.xml b/features/iot-plugins-feature/arduino-plugin-feature/pom.xml new file mode 100644 index 000000000..a03406b5a --- /dev/null +++ b/features/iot-plugins-feature/arduino-plugin-feature/pom.xml @@ -0,0 +1,40 @@ + + + + + + + org.wso2.carbon.devicemgt-plugins + iot-plugins-feature + 2.1.0-SNAPSHOT + ../pom.xml + + + 4.0.0 + arduino-plugin-feature + pom + WSO2 Carbon - IoT Server Arduino Device Feature + http://wso2.org + + + org.wso2.carbon.device.mgt.iot.arduino.feature + + + diff --git a/features/iot-plugins-feature/digital-display-plugin-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/pom.xml b/features/iot-plugins-feature/digital-display-plugin-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/pom.xml new file mode 100644 index 000000000..9501c2e37 --- /dev/null +++ b/features/iot-plugins-feature/digital-display-plugin-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/pom.xml @@ -0,0 +1,213 @@ + + + + + + + org.wso2.carbon.devicemgt-plugins + digital-display-plugin-feature + 2.1.0-SNAPSHOT + ../pom.xml + + + 4.0.0 + org.wso2.carbon.device.mgt.iot.digitaldisplay.feature + pom + WSO2 Carbon - IoT Server DigitalDisplay Feature + http://wso2.org + This feature contains the DigitalDisplay Device type specific implementations for the IoT Server + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.digitaldisplay.plugin + ${carbon.devicemgt.plugins.version} + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.digitaldisplay.api + ${carbon.devicemgt.plugins.version} + war + + + com.h2database.wso2 + h2-database-engine + + + + + + + maven-resources-plugin + + + copy-resources + generate-resources + + copy-resources + + + src/main/resources + + + resources + + build.properties + p2.inf + + + + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + unpack + package + + unpack + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.digitaldisplay.ui + + ${project.version} + zip + true + + ${project.build.directory}/maven-shared-archive-resources/jaggeryapps/devicemgt + + **/* + + + + + + copy-jaxrs-war + package + + copy + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.digitaldisplay.api + + war + true + ${project.build.directory}/maven-shared-archive-resources/webapps/ + digital_display.war + + + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + + create-digital-display-plugin-mgt-schema + package + + run + + + + + + + + + + + + + + + + + + + + + + + + + + + org.wso2.maven + carbon-p2-plugin + ${carbon.p2.plugin.version} + + + p2-feature-generation + package + + p2-feature-gen + + + org.wso2.carbon.device.mgt.iot.digitaldisplay + ../../../features/etc/feature.properties + + + org.wso2.carbon.p2.category.type:server + org.eclipse.equinox.p2.type.group:false + + + + + org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot.digitaldisplay.plugin:${carbon.devicemgt.plugins.version} + + + + org.wso2.carbon.core.server:${carbon.kernel.version} + + org.wso2.carbon.device.mgt.server:${carbon.device.mgt.version} + + + + + + + + + + + \ No newline at end of file diff --git a/features/iot-plugins-feature/digital-display-plugin-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/agent/DigitalDisplay.zip b/features/iot-plugins-feature/digital-display-plugin-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/agent/DigitalDisplay.zip new file mode 100644 index 000000000..72dae1f2b Binary files /dev/null and b/features/iot-plugins-feature/digital-display-plugin-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/agent/DigitalDisplay.zip differ diff --git a/features/iot-plugins-feature/digital-display-plugin-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/agent/deviceConfig.properties b/features/iot-plugins-feature/digital-display-plugin-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/agent/deviceConfig.properties new file mode 100644 index 000000000..a189416d5 --- /dev/null +++ b/features/iot-plugins-feature/digital-display-plugin-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/agent/deviceConfig.properties @@ -0,0 +1,29 @@ +# +# Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# + +#[Device-Configurations] +owner=${DEVICE_OWNER} +deviceId=${DEVICE_ID} +device-name=${DEVICE_NAME} +controller-context=/digital_display/controller +mqtt-ep=${MQTT_EP} +auth-method=token +auth-token=${DEVICE_TOKEN} +refresh-token=${DEVICE_REFRESH_TOKEN} +push-interval=15 + + diff --git a/features/iot-plugins-feature/digital-display-plugin-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/agent/installPackages.sh b/features/iot-plugins-feature/digital-display-plugin-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/agent/installPackages.sh new file mode 100755 index 000000000..c95f674a3 --- /dev/null +++ b/features/iot-plugins-feature/digital-display-plugin-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/agent/installPackages.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# installing dependencies +echo ===Installing Dependencies +sudo apt-get install python-pip +sudo pip install paho-mqtt +sudo apt-get install python-lxml +sudo apt-get install gtk2 +sudo apt-get install xdotool + +# unzipping the archive +echo ===Unzipping DigitalDisplay.zip +unzip DigitalDisplay + +# copying the property file +echo ===Moving deviceConfig.properties +cp ./deviceConfig.properties ./DigitalDisplay \ No newline at end of file diff --git a/features/iot-plugins-feature/digital-display-plugin-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/agent/sketch.properties b/features/iot-plugins-feature/digital-display-plugin-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/agent/sketch.properties new file mode 100644 index 000000000..e794c1942 --- /dev/null +++ b/features/iot-plugins-feature/digital-display-plugin-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/agent/sketch.properties @@ -0,0 +1,2 @@ +templates=deviceConfig.properties +zipfilename=DigitalDisplayAgent.zip diff --git a/features/iot-plugins-feature/digital-display-plugin-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/agent/wso2Agent.sh b/features/iot-plugins-feature/digital-display-plugin-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/agent/wso2Agent.sh new file mode 100755 index 000000000..bad47d0e6 --- /dev/null +++ b/features/iot-plugins-feature/digital-display-plugin-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/agent/wso2Agent.sh @@ -0,0 +1,12 @@ +#!/bin/bash +ps aux|grep wso2server.py|awk '{print $2}'|xargs kill -9 +ps aux|grep httpserver.py|awk '{print $2}'|xargs kill -9 +#xdotool mousemove 0 0 +#xdotool search -name LXTerminal windowunmap +#cd ~/ +cd ./DigitalDisplay/ +mkdir -p tmp/dd-kernel-test +python displayagent.py +while true; do +sleep 100 +done diff --git a/features/iot-plugins-feature/digital-display-plugin-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/build.properties b/features/iot-plugins-feature/digital-display-plugin-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/build.properties new file mode 100644 index 000000000..9c86577d7 --- /dev/null +++ b/features/iot-plugins-feature/digital-display-plugin-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/build.properties @@ -0,0 +1 @@ +custom = true diff --git a/features/iot-plugins-feature/digital-display-plugin-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/configs/digital_display.json b/features/iot-plugins-feature/digital-display-plugin-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/configs/digital_display.json new file mode 100644 index 000000000..58e14efa1 --- /dev/null +++ b/features/iot-plugins-feature/digital-display-plugin-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/configs/digital_display.json @@ -0,0 +1,7 @@ +{ + "deviceType": { + "label": "Digital Display", + "category": "iot" + } +} + diff --git a/features/iot-plugins-feature/digital-display-plugin-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/datasources/digitaldisplay-datasources.xml b/features/iot-plugins-feature/digital-display-plugin-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/datasources/digitaldisplay-datasources.xml new file mode 100644 index 000000000..0f841dc50 --- /dev/null +++ b/features/iot-plugins-feature/digital-display-plugin-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/datasources/digitaldisplay-datasources.xml @@ -0,0 +1,46 @@ + + + + + org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader + + + + DigitalDisplayDM_DB + The datasource used for the Digital Display database + + jdbc/DigitalDisplayDM_DB + + + + jdbc:h2:repository/database/DigitalDisplayDM_DB;DB_CLOSE_ON_EXIT=FALSE + + wso2carbon + wso2carbon + org.h2.Driver + 50 + 60000 + true + SELECT 1 + 30000 + + + + + diff --git a/features/iot-plugins-feature/digital-display-plugin-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/dbscripts/h2.sql b/features/iot-plugins-feature/digital-display-plugin-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/dbscripts/h2.sql new file mode 100644 index 000000000..5bf6884c5 --- /dev/null +++ b/features/iot-plugins-feature/digital-display-plugin-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/dbscripts/h2.sql @@ -0,0 +1,11 @@ + +-- ----------------------------------------------------- +-- Table `DIGITAL_DISPLAY_DEVICE` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `DIGITAL_DISPLAY_DEVICE` ( + `DIGITAL_DISPLAY_DEVICE_ID` VARCHAR(45) NOT NULL , + `DEVICE_NAME` VARCHAR(100) NULL DEFAULT NULL, + PRIMARY KEY (`DIGITAL_DISPLAY_DEVICE_ID`) ); + + + diff --git a/features/iot-plugins-feature/digital-display-plugin-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/dbscripts/mysql.sql b/features/iot-plugins-feature/digital-display-plugin-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/dbscripts/mysql.sql new file mode 100644 index 000000000..c87e4b95d --- /dev/null +++ b/features/iot-plugins-feature/digital-display-plugin-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/dbscripts/mysql.sql @@ -0,0 +1,12 @@ +-- ----------------------------------------------------- +-- Table `DIGITAL_DISPLAY_DEVICE` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `DIGITAL_DISPLAY_DEVICE` ( + `DIGITAL_DISPLAY_DEVICE_ID` VARCHAR(45) NOT NULL , + `DEVICE_NAME` VARCHAR(100) NULL DEFAULT NULL, + PRIMARY KEY (`DIGITAL_DISPLAY_DEVICE_ID`) ) +ENGINE = InnoDB; + + + + diff --git a/features/iot-plugins-feature/digital-display-plugin-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/p2.inf b/features/iot-plugins-feature/digital-display-plugin-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/p2.inf new file mode 100644 index 000000000..d248d6295 --- /dev/null +++ b/features/iot-plugins-feature/digital-display-plugin-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/p2.inf @@ -0,0 +1,14 @@ +instructions.configure = \ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../conf/device-types/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.digitaldisplay_${feature.version}/configs/,target:${installFolder}/../../conf/device-types/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.digitaldisplay_${feature.version}/webapps/,target:${installFolder}/../../deployment/server/webapps/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/sketches/);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/sketches/digital_display/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.digitaldisplay_${feature.version}/agent/,target:${installFolder}/../../resources/sketches/digital_display/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.digitaldisplay_${feature.version}/dbscripts/,target:${installFolder}/../../../dbscripts/cdm/plugins/digital_display,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.digitaldisplay_${feature.version}/datasources/,target:${installFolder}/../../conf/datasources/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/jaggeryapps/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.digitaldisplay_${feature.version}/jaggeryapps/,target:${installFolder}/../../deployment/server/jaggeryapps/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../database/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.digitaldisplay_${feature.version}/database/,target:${installFolder}/../../database/,overwrite:true);\ diff --git a/features/iot-plugins-feature/digital-display-plugin-feature/pom.xml b/features/iot-plugins-feature/digital-display-plugin-feature/pom.xml new file mode 100644 index 000000000..77f7c61c0 --- /dev/null +++ b/features/iot-plugins-feature/digital-display-plugin-feature/pom.xml @@ -0,0 +1,23 @@ + + + + + org.wso2.carbon.devicemgt-plugins + iot-plugins-feature + 2.1.0-SNAPSHOT + ../pom.xml + + + 4.0.0 + digital-display-plugin-feature + pom + WSO2 Carbon - IoT Server DigitalDisplay Device Feature + http://wso2.org + + + org.wso2.carbon.device.mgt.iot.digitaldisplay.feature + + + \ No newline at end of file diff --git a/features/iot-plugins-feature/drone-analyzer-plugin-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/pom.xml b/features/iot-plugins-feature/drone-analyzer-plugin-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/pom.xml new file mode 100644 index 000000000..03a1dbf1c --- /dev/null +++ b/features/iot-plugins-feature/drone-analyzer-plugin-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/pom.xml @@ -0,0 +1,209 @@ + + + + + org.wso2.carbon.devicemgt-plugins + drone-analyzer-plugin-feature + 2.1.0-SNAPSHOT + ../pom.xml + + 4.0.0 + + org.wso2.carbon.device.mgt.iot.droneanalyzer.feature + pom + WSO2 Carbon - IoT Server Drone Analyzer Feature + http://maven.apache.org + This feature contains the Drone Device type specific implementations for the IoT Server + + + + UTF-8 + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.droneanalyzer.plugin + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.droneanalyzer.api + ${carbon.devicemgt.plugins.version} + war + + + com.h2database.wso2 + h2-database-engine + + + + + + maven-resources-plugin + + + copy-resources + generate-resources + + copy-resources + + + src/main/resources + + + resources + + build.properties + p2.inf + + + + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + unpack + package + + unpack + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.droneanalyzer.ui + + ${project.version} + zip + true + + ${project.build.directory}/maven-shared-archive-resources/jaggeryapps/devicemgt + + **/* + + + + + + copy-jaxrs-war + package + + copy + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.droneanalyzer.api + + war + true + ${project.build.directory}/maven-shared-archive-resources/webapps/ + drone_analyzer.war + + + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + + create-drone-analyzer-plugin-mgt-schema + package + + run + + + + + + + + + + + + + + + + + + + + + + + + + + + org.wso2.maven + carbon-p2-plugin + ${carbon.p2.plugin.version} + + + p2-feature-generation + package + + p2-feature-gen + + + org.wso2.carbon.device.mgt.iot.droneanalyzer + ../../../features/etc/feature.properties + + + org.wso2.carbon.p2.category.type:server + org.eclipse.equinox.p2.type.group:false + + + + + org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot.droneanalyzer.plugin:${carbon.devicemgt.plugins.version} + + + + org.wso2.carbon.core.server:${carbon.kernel.version} + + org.wso2.carbon.device.mgt.server:${carbon.device.mgt.version} + + + + + + + + + + diff --git a/features/iot-plugins-feature/drone-analyzer-plugin-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/agent/deviceConfig.properties b/features/iot-plugins-feature/drone-analyzer-plugin-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/agent/deviceConfig.properties new file mode 100644 index 000000000..50d1d9d89 --- /dev/null +++ b/features/iot-plugins-feature/drone-analyzer-plugin-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/agent/deviceConfig.properties @@ -0,0 +1,33 @@ +# +# Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# + +[Device-Configurations] +owner=${DEVICE_OWNER} +deviceId=${DEVICE_ID} +device-name=${DEVICE_NAME} +controller-context=/drone_analyzer/controller +https-ep=${HTTPS_EP} +http-ep=${HTTP_EP} +apim-ep=${APIM_EP} +mqtt-ep=${MQTT_EP} +xmpp-ep=${XMPP_EP} +auth-method=token +auth-token=${DEVICE_TOKEN} +refresh-token=${DEVICE_REFRESH_TOKEN} +push-interval=15 + + diff --git a/features/iot-plugins-feature/drone-analyzer-plugin-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/agent/sketch.properties b/features/iot-plugins-feature/drone-analyzer-plugin-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/agent/sketch.properties new file mode 100644 index 000000000..7492fd635 --- /dev/null +++ b/features/iot-plugins-feature/drone-analyzer-plugin-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/agent/sketch.properties @@ -0,0 +1,2 @@ +templates=deviceConfig.properties +zipfilename=drone_analyzer.zip diff --git a/features/iot-plugins-feature/drone-analyzer-plugin-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/agent/src/IRIS+DroneStatistics.py b/features/iot-plugins-feature/drone-analyzer-plugin-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/agent/src/IRIS+DroneStatistics.py new file mode 100755 index 000000000..f6d896dfd --- /dev/null +++ b/features/iot-plugins-feature/drone-analyzer-plugin-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/agent/src/IRIS+DroneStatistics.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python +""" +/** +* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +* +* WSO2 Inc. licenses this file to you under the Apache License, +* Version 2.0 (the "License"); you may not use this file except +* in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +**/ +""" + +#This script can be used to observe drone attribute (state) changes and push those status changes to xmpp server. + +import argparse +import time + +from dronekit import connect, VehicleMode +import xmppClient + +CONNECTION_TARGET = "/dev/ttyACM0" +PUSH_INTERVAL = 1 +BAUD = 57600 + + +parser = argparse.ArgumentParser(description='Connects to drone on ') +parser.add_argument("-c", "--connect", default='/dev/ttyACM0',help="vehicle connection target. Default '/dev/ttyACM0'") +parser.add_argument("-b", '--baud', type=int ,default=57600,help="Serial communication speed. Default 57600") +parser.add_argument("-i", "--push_interval", type=int, default=1,help="This is the interval which is used to push drone" + " status to xmpp server") +args = parser.parse_args() + +if args.connect: + CONNECTION_TARGET = args.connect + +if args.push_interval: + PUSH_INTERVAL = args.push_interval + +if args.baud: + BAUD = args.baud + +isConnected = xmppClient.connectToXMPPServer() +if isConnected: + print "\nConnecting to vehicle on: %s" % CONNECTION_TARGET + print "----------------------------------------------------------------------" + vehicle = connect(CONNECTION_TARGET, wait_ready=True, baud=BAUD) + while (True): + print " Attitude: %s" % vehicle.attitude.yaw + current_state = "{\"quatanium_val\":["+str(vehicle.attitude.yaw)+","+str(vehicle.attitude.pitch)+ \ + ", "+str(vehicle.attitude.roll)+"],\"basicParam\":{\"velocity\":["+str(vehicle.velocity[0])+"," \ + +str(vehicle.velocity[1])+","+str(vehicle.velocity[2])+"],\"global_location\":["+ \ + str(vehicle.location.global_relative_frame.alt)+","+str(vehicle.location.global_relative_frame.lat)+ \ + ","+str(vehicle.location.global_relative_frame.lon)+"]},\"battery_level\":"+ \ + str(vehicle.battery.level)+",\"battery_voltage\":"+str(vehicle.battery.voltage)+ \ + ",\"device_type\":\"IRIS_DRONE\"}"; + #current_state = "{\"quatanium_val\":[0.345, 0.567, 0.456, 0.6345],\"basicParam\":{\"velocity\":[3, 2, 1], " \ + #"\"global_location\":[0.567, 2.345, 0.456]},\"battery_level\":56,\"battery_voltage\":34,\"device_type\":\"SIMULATOR\"}"; + xmppClient.sendMessage(current_state) + time.sleep(PUSH_INTERVAL) + print "-------------------------------------------------------------------------------------------------" + +print "\nClose vehicle object" +vehicle.close() +print("Completed") \ No newline at end of file diff --git a/features/iot-plugins-feature/drone-analyzer-plugin-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/agent/src/util.py b/features/iot-plugins-feature/drone-analyzer-plugin-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/agent/src/util.py new file mode 100644 index 000000000..33a84fea7 --- /dev/null +++ b/features/iot-plugins-feature/drone-analyzer-plugin-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/agent/src/util.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python + +""" +/** +* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +* +* WSO2 Inc. licenses this file to you under the Apache License, +* Version 2.0 (the "License"); you may not use this file except +* in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +**/ +""" +import ConfigParser, os + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Device specific info when pushing data to server +# Read from a file "deviceConfig.properties" in the same folder level +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +configParser = ConfigParser.RawConfigParser() +configFilePath = r'./deviceConfig.properties' +configParser.read(configFilePath) + +DEVICE_OWNER = configParser.get('Device-Configurations', 'owner') +DEVICE_ID = configParser.get('Device-Configurations', 'deviceId') +XMPP_EP = configParser.get('Device-Configurations', 'xmpp-ep') +AUTH_TOKEN = configParser.get('Device-Configurations', 'auth-token') +DEVICE_PASSWORD = configParser.get('Device-Configurations', 'auth-token') +CONTROLLER_CONTEXT = configParser.get('Device-Configurations', 'controller-context') +HTTPS_EP = configParser.get('Device-Configurations', 'https-ep') +HTTP_EP = configParser.get('Device-Configurations', 'http-ep') +### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \ No newline at end of file diff --git a/features/iot-plugins-feature/drone-analyzer-plugin-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/agent/src/xmppClient.py b/features/iot-plugins-feature/drone-analyzer-plugin-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/agent/src/xmppClient.py new file mode 100644 index 000000000..30434d601 --- /dev/null +++ b/features/iot-plugins-feature/drone-analyzer-plugin-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/agent/src/xmppClient.py @@ -0,0 +1,66 @@ +""" +/** +* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +* +* WSO2 Inc. licenses this file to you under the Apache License, +* Version 2.0 (the "License"); you may not use this file except +* in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +**/ +""" +import xmpp +import util + +XMPP_ENDPOINT = util.XMPP_EP.split(":") +XMPP_IP = XMPP_ENDPOINT[1].replace('//', '') +XMPP_PORT = int(XMPP_ENDPOINT[2]) +MESSAGE_TO = util.DEVICE_OWNER +XMPP_PWD = util.DEVICE_PASSWORD +XMPP_OWN = util.DEVICE_ID + +XMPP_RESOURCE = "drone_current_status" +XMPP_JID = MESSAGE_TO + "@" + XMPP_IP + "/" + XMPP_RESOURCE + + +global droneClient +droneClient = xmpp.Client(XMPP_IP, debug=[]) + +def loginToXMPPServer(): + auth = droneClient.auth(XMPP_OWN, XMPP_PWD, resource=XMPP_RESOURCE) + if not auth: + print 'could not authenticate!' + return 0 + print 'authenticated using', auth + droneClient.sendInitPresence() + return 1 + + +def connectToXMPPServer(): + connection = droneClient.connect(server=(XMPP_IP, XMPP_PORT)) + if not connection: + print 'could not connect to xmpp server at ' + str(XMPP_IP) + return 0 + + print 'connected with', connection + response = loginToXMPPServer() + if response: + return 1 + else: + return 0 + + +def sendMessage(message): + xmpp_message = xmpp.Message(XMPP_JID, message) + xmpp_message.setAttr('type', 'chat') + droneClient.send(xmpp_message) + print message + diff --git a/features/iot-plugins-feature/drone-analyzer-plugin-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/agent/start_server.sh b/features/iot-plugins-feature/drone-analyzer-plugin-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/agent/start_server.sh new file mode 100755 index 000000000..cc62706d9 --- /dev/null +++ b/features/iot-plugins-feature/drone-analyzer-plugin-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/agent/start_server.sh @@ -0,0 +1,83 @@ + +#/** +#* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +#* +#* WSO2 Inc. licenses this file to you under the Apache License, +#* Version 2.0 (the "License"); you may not use this file except +#* in compliance with the License. +#* You may obtain a copy of the License at +#* +#* http://www.apache.org/licenses/LICENSE-2.0 +#* +#* Unless required by applicable law or agreed to in writing, +#* software distributed under the License is distributed on an +#* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +#* KIND, either express or implied. See the License for the +#* specific language governing permissions and limitations +#* under the License. +#**/ + +#!/bin/bash + +echo "----------------------------------------------------------------" +echo "| WSO2 IOT Sample " +echo "| Drone Analyzer " +echo "| ---------------- " +echo "| ....initializing startup-script " +echo "----------------------------------------------------------------" + +currentDir=$PWD + + +while true; do + read -p "Do you wish to run 'apt-get update' and continue? [Yes/No] " yn + case $yn in + [Yy]* ) sudo apt-get update; + break;; + [Nn]* ) echo "Continuing without apt-get update..."; + break;; + * ) echo "Please answer yes or no."; + esac +done + +for f in ./deviceConfig.properties; do + if [ -e "$f" ]; then + echo "Configuration file found......" + else + echo "'deviceConfig.properties' file does not exist in current path. \nExiting installation..."; + exit; + fi + break +done + +#installing dependencies +sudo apt-get install python-pip python-dev +sudo pip install dronekit +sudo apt-get install python-xmpp + +while true; do + read -p "Whats the time-interval (in seconds) between successive Data-Pushes to the XMPP server (ex: '60' indicates 1 minute) > " push_interval + read -p "Vehicle connection target. Default '/dev/ttyACM0' :" connection_target + read -p "Serial communication speed. Default 57600 :" baud + + if [ $input -eq $input 2>/dev/null ] + then + echo "Setting data-push interval to $push_interval seconds." + break + else + echo "Input needs to be an integer indicating the number seconds between successive data-pushes." + fi + +done + +cp deviceConfig.properties ./src +python ./src/IRIS+DroneStatistics.py -i $push_interval -b $baud -c $connection_target + +if [ $? -ne 0 ]; then + echo "Could not start the service..." + exit; +fi + +echo "--------------------------------------------------------------------------" +echo "| Successfully Started " +echo "---------------------------------------------------------------------------" diff --git a/features/iot-plugins-feature/drone-analyzer-plugin-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/build.properties b/features/iot-plugins-feature/drone-analyzer-plugin-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/build.properties new file mode 100644 index 000000000..9c86577d7 --- /dev/null +++ b/features/iot-plugins-feature/drone-analyzer-plugin-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/build.properties @@ -0,0 +1 @@ +custom = true diff --git a/features/iot-plugins-feature/drone-analyzer-plugin-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/configs/drone_analyzer.json b/features/iot-plugins-feature/drone-analyzer-plugin-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/configs/drone_analyzer.json new file mode 100644 index 000000000..731a4fb80 --- /dev/null +++ b/features/iot-plugins-feature/drone-analyzer-plugin-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/configs/drone_analyzer.json @@ -0,0 +1,6 @@ +{ + "deviceType": { + "label": "Drone Analyzer", + "category": "iot" + } +} \ No newline at end of file diff --git a/features/iot-plugins-feature/drone-analyzer-plugin-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/datasources/drone_analyzer-datasources.xml b/features/iot-plugins-feature/drone-analyzer-plugin-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/datasources/drone_analyzer-datasources.xml new file mode 100644 index 000000000..43c848734 --- /dev/null +++ b/features/iot-plugins-feature/drone-analyzer-plugin-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/datasources/drone_analyzer-datasources.xml @@ -0,0 +1,50 @@ + + + + + org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader + + + + + DroneAnalyzerDM_DB + The datasource used for the Drone Analyzer database + + jdbc/DroneAnalyzerDM_DB + + + + jdbc:h2:repository/database/DroneAnalyzerDM_DB;DB_CLOSE_ON_EXIT=FALSE + + wso2carbon + wso2carbon + org.h2.Driver + 50 + 60000 + true + SELECT 1 + 30000 + + + + + + + + diff --git a/features/iot-plugins-feature/drone-analyzer-plugin-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/dbscripts/h2.sql b/features/iot-plugins-feature/drone-analyzer-plugin-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/dbscripts/h2.sql new file mode 100644 index 000000000..f7dac408b --- /dev/null +++ b/features/iot-plugins-feature/drone-analyzer-plugin-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/dbscripts/h2.sql @@ -0,0 +1,11 @@ + +-- ----------------------------------------------------- +-- Table `DRONE_DEVICE` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `DRONE_DEVICE` ( + `DRONE_DEVICE_ID` VARCHAR(45) NOT NULL , + `DEVICE_NAME` VARCHAR(100) NULL DEFAULT NULL, + PRIMARY KEY (`DRONE_DEVICE_ID`) ); + + + diff --git a/features/iot-plugins-feature/drone-analyzer-plugin-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/dbscripts/mysql.sql b/features/iot-plugins-feature/drone-analyzer-plugin-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/dbscripts/mysql.sql new file mode 100644 index 000000000..525190452 --- /dev/null +++ b/features/iot-plugins-feature/drone-analyzer-plugin-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/dbscripts/mysql.sql @@ -0,0 +1,12 @@ +-- ----------------------------------------------------- +-- Table `DRONE_DEVICE` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `DRONE_DEVICE` ( + `DRONE_DEVICE_ID` VARCHAR(45) NOT NULL , + `DEVICE_NAME` VARCHAR(100) NULL DEFAULT NULL, + PRIMARY KEY (`DRONE_DEVICE_ID`) ) +ENGINE = InnoDB; + + + + diff --git a/features/iot-plugins-feature/drone-analyzer-plugin-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/p2.inf b/features/iot-plugins-feature/drone-analyzer-plugin-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/p2.inf new file mode 100644 index 000000000..420a62ee2 --- /dev/null +++ b/features/iot-plugins-feature/drone-analyzer-plugin-feature/org.wso2.carbon.device.mgt.iot.droneanalyzer.feature/src/main/resources/p2.inf @@ -0,0 +1,14 @@ +instructions.configure = \ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../conf/device-types/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.droneanalyzer_${feature.version}/configs/,target:${installFolder}/../../conf/device-types/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.droneanalyzer_${feature.version}/webapps/,target:${installFolder}/../../deployment/server/webapps/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/sketches/);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/sketches/drone_analyzer/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.droneanalyzer_${feature.version}/agent/,target:${installFolder}/../../resources/sketches/drone_analyzer/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.droneanalyzer_${feature.version}/dbscripts/,target:${installFolder}/../../../dbscripts/cdm/plugins/drone_analyzer,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/jaggeryapps/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.droneanalyzer_${feature.version}/jaggeryapps/,target:${installFolder}/../../deployment/server/jaggeryapps/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.droneanalyzer_${feature.version}/datasources/,target:${installFolder}/../../conf/datasources/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../database/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.droneanalyzer_${feature.version}/database/,target:${installFolder}/../../database/,overwrite:true);\ diff --git a/features/iot-plugins-feature/drone-analyzer-plugin-feature/pom.xml b/features/iot-plugins-feature/drone-analyzer-plugin-feature/pom.xml new file mode 100644 index 000000000..688ee559b --- /dev/null +++ b/features/iot-plugins-feature/drone-analyzer-plugin-feature/pom.xml @@ -0,0 +1,40 @@ + + + + + + + org.wso2.carbon.devicemgt-plugins + iot-plugins-feature + 2.1.0-SNAPSHOT + ../pom.xml + + + 4.0.0 + drone-analyzer-plugin-feature + pom + WSO2 Carbon - IoT Server Drone Device Feature + http://wso2.org + + + org.wso2.carbon.device.mgt.iot.droneanalyzer.feature + + + diff --git a/features/iot-plugins-feature/pom.xml b/features/iot-plugins-feature/pom.xml index c1ebe4604..10a0ac19a 100644 --- a/features/iot-plugins-feature/pom.xml +++ b/features/iot-plugins-feature/pom.xml @@ -34,6 +34,12 @@ http://wso2.org + androidsense-plugin-feature + arduino-plugin-feature + digital-display-plugin-feature + drone-analyzer-plugin-feature + raspberrypi-plugin-feature + virtual-fire-alarm-plugin-feature iot-base-plugin-feature diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/pom.xml b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/pom.xml new file mode 100644 index 000000000..5c6f210e0 --- /dev/null +++ b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/pom.xml @@ -0,0 +1,221 @@ + + + + + + + + org.wso2.carbon.devicemgt-plugins + raspberrypi-plugin-feature + 2.1.0-SNAPSHOT + ../pom.xml + + + 4.0.0 + org.wso2.carbon.device.mgt.iot.raspberrypi.feature + pom + WSO2 Carbon - IoT Server RaspberryPi Feature + http://wso2.org + This feature contains the RaspberryPi Device type specific implementations for the IoT Server + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.raspberrypi.plugin + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.raspberrypi.api + war + + + com.h2database.wso2 + h2-database-engine + + + + + + + maven-resources-plugin + + + copy-resources + generate-resources + + copy-resources + + + src/main/resources + + + resources + + build.properties + p2.inf + + + + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + unpack + package + + unpack + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.raspberrypi.analytics + + ${project.version} + zip + true + + ${project.build.directory}/maven-shared-archive-resources/carbonapps + + **/* + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.raspberrypi.ui + + ${project.version} + zip + true + + ${project.build.directory}/maven-shared-archive-resources/jaggeryapps/devicemgt + + **/* + + + + + + copy-jaxrs-war + package + + copy + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.raspberrypi.api + + war + true + ${project.build.directory}/maven-shared-archive-resources/webapps/ + raspberrypi.war + + + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + + create-raspberrypi-plugin-mgt-schema + package + + run + + + + + + + + + + + + + + + + + + + + + + + + + + + org.wso2.maven + carbon-p2-plugin + ${carbon.p2.plugin.version} + + + p2-feature-generation + package + + p2-feature-gen + + + org.wso2.carbon.device.mgt.iot.raspberrypi + ../../../features/etc/feature.properties + + + org.wso2.carbon.p2.category.type:server + org.eclipse.equinox.p2.type.group:false + + + + + org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot.raspberrypi.plugin:${carbon.devicemgt.plugins.version} + + + + org.wso2.carbon.core.server:${carbon.kernel.version} + + org.wso2.carbon.device.mgt.server:${carbon.device.mgt.version} + + + + + + + + + + diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/README.md b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/README.md new file mode 100644 index 000000000..d80a3e63d --- /dev/null +++ b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/README.md @@ -0,0 +1,43 @@ +## Copyright and license + +Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +WSO2 Inc. licenses this file to you under the Apache License,Version 2.0 (the "License"); you may not use this file except +in compliance with the License.You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the +specific language governing permissions and limitations under the License. + + + -------------- + testAgent.sh + -------------- +This script is used to run this service in a testing environment. It can be run on a real Raspberry Pi device or in a +virtual environment. + +To run: ` sudo ./testAgent.sh ` and follow the instructions. + + ------------------- + startService.sh + ------------------- +After testing, this script can be used to deploy this application as a service on Raspberry Pi which will get loaded +during boot up process. + +create a service: + ` sudo ./startService.sh ` + +get current state of the service: + ` sudo service RaspberryService.sh status ` + +start service: + ` sudo service RaspberryService.sh start ` + +stop service: + ` sudo service RaspberryService.sh stop ` + +restart service: + ` sudo service RaspberryService.sh restart ` + + + + + diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/RaspberryService.sh b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/RaspberryService.sh new file mode 100644 index 000000000..e32907e54 --- /dev/null +++ b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/RaspberryService.sh @@ -0,0 +1,96 @@ +#""" +#/** +#* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +#* +#* WSO2 Inc. licenses this file to you under the Apache License, +#* Version 2.0 (the "License"); you may not use this file except +#* in compliance with the License. +#* You may obtain a copy of the License at +#* +#* http://www.apache.org/licenses/LICENSE-2.0 +#* +#* Unless required by applicable law or agreed to in writing, +#* software distributed under the License is distributed on an +#* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +#* KIND, either express or implied. See the License for the +#* specific language governing permissions and limitations +#* under the License. +#**/ +#""" + +#!/bin/sh + +### BEGIN INIT INFO +# Provides: RaspberryService +# Required-Start: $remote_fs $syslog $network +# Required-Stop: $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: WSO2-IOT RPi Service +# Description: RPi Service used to Publish RPi Stats to the WSO2 Device Cloud +### END INIT INFO + +PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin +DESC="This service is used to publish events from the Raspberry Pi to the WSO2 Device Cloud" +NAME=RaspberryStats + +DIR=/usr/local/src/RaspberryAgent/src/ +DAEMON=$DIR/RaspberryAgent.py +DAEMON_NAME=$NAME +SCRIPTNAME=RaspberryService.sh + +# The process ID of the script when it runs is stored here: +PIDFILE=/var/run/$DAEMON_NAME.pid + +# Add any command line options for your daemon here +DAEMON_OPTS="-l /usr/local/src/RaspberryAgent/RaspberryStats.log -m N -i 60" + +# This next line determines what user the script runs as. +DAEMON_USER=root #pi + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.2-14) to ensure that this file is present +# and status_of_proc is working. +. /lib/lsb/init-functions + +do_start () { + log_daemon_msg "Starting system $DAEMON_NAME daemon" + start-stop-daemon --start --background --pidfile $PIDFILE --make-pidfile --user $DAEMON_USER --chuid $DAEMON_USER --startas $DAEMON -- $DAEMON_OPTS + log_end_msg $? +} +do_stop () { + log_daemon_msg "Stopping system $DAEMON_NAME daemon" + start-stop-daemon --stop --pidfile $PIDFILE --retry 10 + log_end_msg $? +} + +case "$1" in + + start|stop) + do_${1} + ;; + + restart|reload|force-reload) + do_stop + do_start + ;; + + status) + status_of_proc "$DAEMON_NAME" "$DAEMON" && exit 0 || exit $? + ;; + + getdeviceid) + $DIR/getMac.sh && exit 0 || exit $? + ;; + + *) + #echo Usage: /etc/init.d/$DAEMON_NAME {start|stop|restart|status}" + echo "Usage: /etc/init.d/$SCRIPTNAME {start|stop|restart|status}" + exit 1 + ;; + +esac +exit 0 diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/deviceConfig.properties b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/deviceConfig.properties new file mode 100644 index 000000000..489af7042 --- /dev/null +++ b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/deviceConfig.properties @@ -0,0 +1,33 @@ +# +# Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +[Device-Configurations] +server-name=${SERVER_NAME} +owner=${DEVICE_OWNER} +deviceId=${DEVICE_ID} +device-name=${DEVICE_NAME} +controller-context=/raspberrypi/controller +https-ep=${HTTPS_EP} +http-ep=${HTTP_EP} +apim-ep=${APIM_EP} +mqtt-ep=${MQTT_EP} +xmpp-ep=${XMPP_EP} +auth-method=token +auth-token=${DEVICE_TOKEN} +refresh-token=${DEVICE_REFRESH_TOKEN} +push-interval=15 + + diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/sketch.properties b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/sketch.properties new file mode 100644 index 000000000..f06105047 --- /dev/null +++ b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/sketch.properties @@ -0,0 +1,2 @@ +templates=deviceConfig.properties +zipfilename=RaspberryPiAgent.zip diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/RaspberryAgent.py b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/RaspberryAgent.py new file mode 100644 index 000000000..188eca451 --- /dev/null +++ b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/RaspberryAgent.py @@ -0,0 +1,323 @@ +#!/usr/bin/env python +""" +/** +* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +* +* WSO2 Inc. licenses this file to you under the Apache License, +* Version 2.0 (the "License"); you may not use this file except +* in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +**/ +""" + +import logging, logging.handlers +import sys, os, signal, argparse +import running_mode +import time, threading, datetime + +import httplib, ssl +from functools import wraps + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Overriding the default SSL version used in some of the Python (2.7.x) versions +# This is a known issue in earlier Python releases +# But was fixed in later versions. Ex-2.7.11 +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def sslwrap(func): + @wraps(func) + def bar(*args, **kw): + kw['ssl_version'] = ssl.PROTOCOL_TLSv1 + return func(*args, **kw) + return bar +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +PUSH_INTERVAL = 5000 # time interval between successive data pushes in seconds + + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Logger defaults +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +LOG_FILENAME = "RaspberryStats.log" +logging_enabled = False +LOG_LEVEL = logging.INFO # Could be e.g. "DEBUG" or "WARNING" +### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Python version +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +if sys.version_info<(2,7,0): + sys.stderr.write("You need python 2.7.0 or later to run this script\n") + exit(1) +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Define and parse command line arguments +# If the log file is specified on the command line then override the default +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +parser = argparse.ArgumentParser(description="Python service to push RPi info to the Device Cloud") +parser.add_argument("-l", "--log", help="file to write log to (default '" + LOG_FILENAME + "')") + +help_string_for_data_push_interval = "time interval between successive data pushes (default '" + str(PUSH_INTERVAL) + "')" +help_string_for_running_mode = "where is going to run on the real device or not" +parser.add_argument("-i", "--interval", type=int, help=help_string_for_data_push_interval) +parser.add_argument("-m", "--mode", type=str, help=help_string_for_running_mode) + +args = parser.parse_args() +if args.log: + LOG_FILENAME = args.log + +if args.interval: + PUSH_INTERVAL = args.interval + +if args.mode: + running_mode.RUNNING_MODE = args.mode + iotUtils = __import__('iotUtils') + httpServer = __import__('httpServer') # python script used to start a http-server to listen for operations + # (includes the TEMPERATURE global variable) + + if running_mode.RUNNING_MODE == 'N': + Adafruit_DHT = __import__('Adafruit_DHT') # Adafruit library required for temperature sensing +### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Endpoint specific settings to which the data is pushed +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +DC_ENDPOINT = iotUtils.HTTPS_EP.split(":") +DC_IP = DC_ENDPOINT[1].replace('//', '') +DC_PORT = int(DC_ENDPOINT[2]) +DC_ENDPOINT_CONTEXT = iotUtils.CONTROLLER_CONTEXT +PUSH_ENDPOINT = str(DC_ENDPOINT_CONTEXT) + '/push_temperature/' +REGISTER_ENDPOINT = str(DC_ENDPOINT_CONTEXT) + '/register' + +HOST = iotUtils.getDeviceIP() +HOST_HTTP_SERVER_PORT = iotUtils.getHTTPServerPort() +HOST_AND_PORT = str(HOST)+ ":" + str(HOST_HTTP_SERVER_PORT) +### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# A class we can use to capture stdout and sterr in the log +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +class IOTLogger(object): + def __init__(self, logger, level): + """Needs a logger and a logger level.""" + self.logger = logger + self.level = level + + def write(self, message): + if message.rstrip() != "": # Only log if there is a message (not just a new line) + self.logger.log(self.level, message.rstrip()) +### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Configure logging to log to a file, +# making a new file at midnight and keeping the last 3 day's data +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def configureLogger(loggerName): + logger = logging.getLogger(loggerName) + logger.setLevel(LOG_LEVEL) # Set the log level to LOG_LEVEL + handler = logging.handlers.TimedRotatingFileHandler(LOG_FILENAME, when="midnight", + backupCount=3) # Handler that writes to a file, + # ~~~make new file at midnight and keep 3 backups + formatter = logging.Formatter('%(asctime)s %(levelname)-8s %(message)s') # Format each log message like this + handler.setFormatter(formatter) # Attach the formatter to the handler + logger.addHandler(handler) # Attach the handler to the logger + + if (logging_enabled): + sys.stdout = IOTLogger(logger, logging.INFO) # Replace stdout with logging to file at INFO level + sys.stderr = IOTLogger(logger, logging.ERROR) # Replace stderr with logging to file at ERROR level +### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# This method registers the DevieIP in the Device-Cloud +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def registerDeviceIP(): + ssl.wrap_socket = sslwrap(ssl.wrap_socket) # using the overridden sslwrap that uses TLSv1 + if sys.version_info<(2,7,9): + dcConncection = httplib.HTTPSConnection(host=DC_IP, port=DC_PORT) + else: + dcConncection = httplib.HTTPSConnection(host=DC_IP, port=DC_PORT, context=ssl._create_unverified_context()) + #TODO need to get server certificate when initializing https connection + dcConncection.set_debuglevel(1) + dcConncection.connect() + + registerURL = str(REGISTER_ENDPOINT) + '/' + str(iotUtils.DEVICE_OWNER) + '/' + str(iotUtils.DEVICE_ID) + '/' + \ + str(HOST) + '/' + str(HOST_HTTP_SERVER_PORT) + '/' + dcConncection.putrequest('POST', registerURL) + dcConncection.putheader('Authorization', 'Bearer ' + iotUtils.AUTH_TOKEN) + dcConncection.endheaders() + dcResponse = dcConncection.getresponse() + + print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' + print ('RASPBERRY_STATS: ' + str(registerURL)) + print ('RASPBERRY_STATS: ' + str(dcResponse.status)) + print ('RASPBERRY_STATS: ' + str(dcResponse.reason)) + print ('RASPBERRY_STATS: Response Message') + print str(dcResponse.msg) + + dcConncection.close() + print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' +### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# This method connects to the Device-Cloud and pushes data +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def connectAndPushData(): + if sys.version_info<(2,7,9): + dcConnection = httplib.HTTPSConnection(host=DC_IP, port=DC_PORT) + else: + dcConnection = httplib.HTTPSConnection(host=DC_IP, port=DC_PORT, context=ssl._create_unverified_context()) + + dcConnection.set_debuglevel(1) + dcConnection.connect() + request = dcConnection.putrequest('POST', PUSH_ENDPOINT) + dcConnection.putheader('Authorization', 'Bearer ' + iotUtils.AUTH_TOKEN) + dcConnection.putheader('Content-Type', 'application/json') + ### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ### Read the Temperature and Load info of RPi and construct payload + ### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + rPiTemperature = iotUtils.LAST_TEMP # Push the last read temperature value + PUSH_DATA = iotUtils.DEVICE_INFO + iotUtils.DEVICE_IP.format(ip=HOST_AND_PORT) + iotUtils.DEVICE_DATA.format( + temperature=rPiTemperature) + PUSH_DATA += '}' + dcConnection.putheader('Content-Length', len(PUSH_DATA)) + dcConnection.endheaders() + + print PUSH_DATA + print '~~~~~~~~~~~~~~~~~~~~~~~~ Pushing Device-Data ~~~~~~~~~~~~~~~~~~~~~~~~~' + + dcConnection.send(PUSH_DATA) # Push the data + dcResponse = dcConnection.getresponse() + + print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' + print ('RASPBERRY_STATS: ' + str(dcResponse.status)) + print ('RASPBERRY_STATS: ' + str(dcResponse.reason)) + print ('RASPBERRY_STATS: Response Message') + print str(dcResponse.msg) + print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' + dcConnection.close() + + if (dcResponse.status == 409 or dcResponse.status == 412): + print 'RASPBERRY_STATS: Re-registering Device IP' + registerDeviceIP() +### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# This is a Thread object for reading temperature continuously +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +class TemperatureReaderThread(object): + def __init__(self): + if running_mode.RUNNING_MODE == 'N': + self.interval = iotUtils.TEMPERATURE_READING_INTERVAL_REAL_MODE + else: + self.interval = iotUtils.TEMPERATURE_READING_INTERVAL_VIRTUAL_MODE + thread = threading.Thread(target=self.run, args=()) + thread.daemon = True # Daemonize thread + thread.start() # Start the execution + + def run(self): + + # Try to grab a sensor reading. Use the read_retry method which will retry up + # to 15 times to get a sensor reading (waiting 2 seconds between each retry). + while True: + try: + if running_mode.RUNNING_MODE == 'N': + humidity, temperature = Adafruit_DHT.read_retry(iotUtils.TEMP_SENSOR_TYPE, iotUtils.TEMP_PIN) + else: + humidity, temperature = iotUtils.generateRandomTemperatureAndHumidityValues() + + if temperature != iotUtils.LAST_TEMP: + time.sleep(PUSH_INTERVAL) + iotUtils.LAST_TEMP = temperature + connectAndPushData() + + iotUtils.LAST_TEMP = temperature + print 'RASPBERRY_STATS: Temp={0:0.1f}*C Humidity={1:0.1f}%'.format(temperature, humidity) + + except Exception, e: + print "RASPBERRY_STATS: Exception in TempReaderThread: Could not successfully read Temperature" + print ("RASPBERRY_STATS: " + str(e)) + print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' + pass + time.sleep(self.interval) +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# This is a Thread object for listening for MQTT Messages +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +class UtilsThread(object): + def __init__(self): + thread = threading.Thread(target=self.run, args=()) + thread.daemon = True # Daemonize thread + thread.start() # Start the execution + + def run(self): + iotUtils.main() +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# This is a Thread object for HTTP-Server that listens for operations on RPi +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +class ListenHTTPServerThread(object): + def __init__(self): + thread = threading.Thread(target=self.run, args=()) + thread.daemon = True # Daemonize thread + thread.start() # Start the execution + + def run(self): + httpServer.main() +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# When sysvinit sends the TERM signal, cleanup before exiting +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def sigterm_handler(_signo, _stack_frame): + print("[] received signal {}, exiting...".format(_signo)) + sys.exit(0) +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + +signal.signal(signal.SIGTERM, sigterm_handler) + + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# The Main method of the RPi Agent +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def main(): + configureLogger("WSO2IOT_RPiStats") + if running_mode.RUNNING_MODE == 'N': + iotUtils.setUpGPIOPins() + UtilsThread() + registerDeviceIP() # Call the register endpoint and register Device IP + TemperatureReaderThread() # initiates and runs the thread to continuously read temperature from DHT Sensor + ListenHTTPServerThread() # starts an HTTP Server that listens for operational commands to switch ON/OFF Led + while True: + try: + if iotUtils.LAST_TEMP > 0: # Push data only if there had been a successful temperature read + connectAndPushData() # Push Sensor (Temperature) data to WSO2 BAM + time.sleep(PUSH_INTERVAL) + except (KeyboardInterrupt, Exception) as e: + print "RASPBERRY_STATS: Exception in RaspberryAgentThread (either KeyboardInterrupt or Other)" + print ("RASPBERRY_STATS: " + str(e)) + print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' + pass +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + +if __name__ == "__main__": + main() diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/RaspberryStats.log b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/RaspberryStats.log new file mode 100644 index 000000000..e69de29bb diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/deviceConfig.properties b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/deviceConfig.properties new file mode 100644 index 000000000..489af7042 --- /dev/null +++ b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/deviceConfig.properties @@ -0,0 +1,33 @@ +# +# Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +[Device-Configurations] +server-name=${SERVER_NAME} +owner=${DEVICE_OWNER} +deviceId=${DEVICE_ID} +device-name=${DEVICE_NAME} +controller-context=/raspberrypi/controller +https-ep=${HTTPS_EP} +http-ep=${HTTP_EP} +apim-ep=${APIM_EP} +mqtt-ep=${MQTT_EP} +xmpp-ep=${XMPP_EP} +auth-method=token +auth-token=${DEVICE_TOKEN} +refresh-token=${DEVICE_REFRESH_TOKEN} +push-interval=15 + + diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/httpServer.py b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/httpServer.py new file mode 100644 index 000000000..334fad2a2 --- /dev/null +++ b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/httpServer.py @@ -0,0 +1,118 @@ +#!/usr/bin/env python + +""" +/** +* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +* +* WSO2 Inc. licenses this file to you under the Apache License, +* Version 2.0 (the "License"); you may not use this file except +* in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +**/ +""" + +import time +import BaseHTTPServer +import iotUtils +import running_mode +import os +import subprocess +import re + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Class that handles HTTP GET requests for operations on the RPi +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +class OnRequestListener(BaseHTTPServer.BaseHTTPRequestHandler): + def do_GET(request): + # """Respond to a GET request.""" + + if not processURLPath(request.path): + return + + print request.path.split("/")[1].upper() + resource = request.path.split("/")[1].upper() + state = request.path.split("/")[2].upper() + print "HTTP_SERVER: Resource - " + resource + + if resource == "TEMPERATURE": + request.send_response(200) + request.send_header('Content-Type', 'application/json') + request.send_header('Authorization', 'Bearer ' + iotUtils.AUTH_TOKEN) + request.end_headers() + request.wfile.write(iotUtils.LAST_TEMP) + + elif resource == "BULB": + iotUtils.switchBulb(state) + print "HTTP_SERVER: Requested Switch State - " + state + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Check the URL string of the request and validate +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def processURLPath(path): + if path.count("/") != 2 and not "favicon" in path: + print "HTTP_SERVER: Invalid URL String: " + path + return False + + resource = path.split("/")[1] + + if not iequal("BULB", resource) and not iequal("TEMPERATURE", resource): + if not "favicon" in resource: + print "HTTP_SERVER: Invalid resource - " + resource + " to execute operation" + return False + + return True +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Case-Insensitive check on whether two string are similar +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def iequal(a, b): + try: + return a.upper() == b.upper() + except AttributeError: + return a == b + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# The Main method of the server script +# This method is invoked from RaspberryStats.py on a new thread +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def main(): + HOST_NAME = iotUtils.getDeviceIP() + HTTP_SERVER_PORT = iotUtils.getHTTPServerPort() + server_class = BaseHTTPServer.HTTPServer + + while True: + try: + httpd = server_class((HOST_NAME, HTTP_SERVER_PORT), OnRequestListener) + print "HTTP_SERVER: " + time.asctime(), "Server Starts - %s:%s" % (HOST_NAME, HTTP_SERVER_PORT) + + httpd.serve_forever() + except (KeyboardInterrupt, Exception) as e: + print "HTTP_SERVER: Exception in HttpServerThread (either KeyboardInterrupt or Other)" + print ("HTTP_SERVER: " + str(e)) + + if running_mode.RUNNING_MODE == "N": + iotUtils.switchBulb("OFF") + else : + iotUtils.switchBulb("OFF") + httpd.server_close() + print "HTTP_SERVER: " + time.asctime(), "Server Stops - %s:%s" % (HOST_NAME, HTTP_SERVER_PORT) + print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' + pass +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +if __name__ == '__main__': + main() diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/iotUtils.py b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/iotUtils.py new file mode 100644 index 000000000..1419f91d6 --- /dev/null +++ b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/iotUtils.py @@ -0,0 +1,185 @@ +#!/usr/bin/env python + +""" +/** +* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +* +* WSO2 Inc. licenses this file to you under the Apache License, +* Version 2.0 (the "License"); you may not use this file except +* in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +**/ +""" + +import time +import ConfigParser, os +import random +import running_mode + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# HOST_NAME(IP) of the Device +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +global HOST_NAME +HOST_NAME = "0.0.0.0" +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +HTTP_SERVER_PORT = 5678 # http server port which is listning on + +global LAST_TEMP +LAST_TEMP = 25 # The Last read temperature value from the DHT sensor. Kept globally +# Updated by the temperature reading thread +# Associate pin 23 to TRIG +TEMPERATURE_READING_INTERVAL_REAL_MODE = 3 +TEMPERATURE_READING_INTERVAL_VIRTUAL_MODE = 60 +TEMP_PIN = 4 +TEMP_SENSOR_TYPE = 11 +BULB_PIN = 11 # The GPIO Pin# in RPi to which the LED is connected +global GPIO + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Device specific info when pushing data to server +# Read from a file "deviceConfig.properties" in the same folder level +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +configParser = ConfigParser.RawConfigParser() +configFilePath = os.path.join(os.path.dirname(__file__), './deviceConfig.properties') +configParser.read(configFilePath) + +DEVICE_OWNER = configParser.get('Device-Configurations', 'owner') +DEVICE_ID = configParser.get('Device-Configurations', 'deviceId') +MQTT_EP = configParser.get('Device-Configurations', 'mqtt-ep') +XMPP_EP = configParser.get('Device-Configurations', 'xmpp-ep') +AUTH_TOKEN = configParser.get('Device-Configurations', 'auth-token') +CONTROLLER_CONTEXT = configParser.get('Device-Configurations', 'controller-context') +DEVICE_INFO = '{"owner":"' + DEVICE_OWNER + '","deviceId":"' + DEVICE_ID + '","reply":' +HTTPS_EP = configParser.get('Device-Configurations', 'https-ep') +HTTP_EP = configParser.get('Device-Configurations', 'http-ep') +APIM_EP = configParser.get('Device-Configurations', 'apim-ep') +DEVICE_IP = '"{ip}","value":' +DEVICE_DATA = '"{temperature}"' # '"{temperature}:{load}:OFF"' + + +### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Method used to switch ON/OFF the LED attached to RPi +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def switchBulb(state): + print "Requested Switch State: " + state + + if running_mode.RUNNING_MODE == "N": + import RPi.GPIO as GPIO + if state == "ON": + GPIO.output(BULB_PIN, True) + print "BULB Switched ON" + elif state == "OFF": + GPIO.output(BULB_PIN, False) + print "BULB Switched OFF" + else: + if state == "ON": + print "BULB Switched ON" + elif state == "OFF": + print "BULB Switched OFF" + print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# This method generate a random temperature value +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def generateRandomTemperatureAndHumidityValues(): + return [random.randint(15, 40),random.randint(15, 40)] +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + +# If an agent runs on a real setup GPIO needs to be imported +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def initGPIOModule(): + if running_mode.RUNNING_MODE == 'N': + import RPi.GPIO as GPIO +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Get the IP-Address of the interface via which the RPi is connected +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def getDeviceIP(): + # for POSIX system like MacOS and Linux + if os.name != "nt": + import commands + rPi_IP = commands.getoutput("ifconfig | grep inet | grep -v inet6 | grep -v 127.0.0.1 | awk '{print $2}'").split('\n') + if len(rPi_IP) > 0: + print "------------------------------------------------------------------------------------" + print "IOT_UTILS: IP Addresses of RaspberryPi: " + str(rPi_IP) + print "IOT_UTILS: IP Address used for HTTP Server: " + rPi_IP[0] + print "------------------------------------------------------------------------------------" + if len(rPi_IP[0].split(":"))>1: + return rPi_IP[0].split(":")[1] + else: + return rPi_IP[0] + + # for windows systems + else: + from subprocess import check_output + rPi_IP = check_output("for /f \"tokens=14\" %a in ('ipconfig ^| findstr \"IPv4\" ^| findstr /v \"127.0.0.1\"') do echo %a", shell=True).decode() + rPi_IP = rPi_IP.replace('\r', '') + rPi_IP = rPi_IP.split('\n') + + for IPs in rPi_IP: + if IPs != '' and len(aps) < 16: + print("------------------------------------------------------------------------------------") + print("IOT_UTILS: IP Address used for HTTP Server: " + IPs) + print("------------------------------------------------------------------------------------") + return IPs +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Get the port which http server is listening on +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def getHTTPServerPort(): + return HTTP_SERVER_PORT +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Set the GPIO pin modes for the ones to be read +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def setUpGPIOPins(): + import RPi.GPIO as GPIO + try: + GPIO.setwarnings(False) + GPIO.setmode(GPIO.BOARD) + except Exception as e: + print "IOT_UTILS: Exception at 'GPIO.setmode'" + print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' + pass + + GPIO.setup(BULB_PIN, GPIO.OUT) + GPIO.output(BULB_PIN, False) +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# The Main method of the server script +# This method is invoked from RaspberryStats.py on a new thread +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def main(): + global HOST_NAME + HOST_NAME = getDeviceIP() + if running_mode.RUNNING_MODE == 'N': + setUpGPIOPins() + + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/running_mode.py b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/running_mode.py new file mode 100644 index 000000000..1b28e4aa3 --- /dev/null +++ b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/running_mode.py @@ -0,0 +1,2 @@ + +global RUNNING_MODE \ No newline at end of file diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/startService.sh b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/startService.sh new file mode 100644 index 000000000..e073b1092 --- /dev/null +++ b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/startService.sh @@ -0,0 +1,43 @@ +#""" +#/** +#* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +#* +#* WSO2 Inc. licenses this file to you under the Apache License, +#* Version 2.0 (the "License"); you may not use this file except +#* in compliance with the License. +#* You may obtain a copy of the License at +#* +#* http://www.apache.org/licenses/LICENSE-2.0 +#* +#* Unless required by applicable law or agreed to in writing, +#* software distributed under the License is distributed on an +#* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +#* KIND, either express or implied. See the License for the +#* specific language governing permissions and limitations +#* under the License. +#**/ +#""" + +#!/usr/bin/env bash + +echo "----------------------------------------------------------------" +echo "| WSO2 IOT Sample " +echo "| RaspiAgent " +echo "| ---------------- " +echo "| ....initializing service-start-script " +echo "----------------------------------------------------------------" + +destination="/usr/local/src/RaspberryAgent" +currentDir=$PWD +if [ ! -d "$destination" ] +then + mkdir $destination +fi +sudo cp $currentDir/deviceConfig.properties $currentDir/src +sudo cp -r $currentDir/src $destination +sudo chmod +x $destination/src/RaspberryAgent.py +sudo update-rc.d -f RaspberryService.sh remove +sudo cp $currentDir/RaspberryService.sh /etc/init.d +sudo chmod +x /etc/init.d/RaspberryService.sh +sudo update-rc.d RaspberryService.sh defaults +sudo service RaspberryService.sh start diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/testAgent.sh b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/testAgent.sh new file mode 100644 index 000000000..ea9e4bee1 --- /dev/null +++ b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/testAgent.sh @@ -0,0 +1,117 @@ +#""" +#/** +#* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +#* +#* WSO2 Inc. licenses this file to you under the Apache License, +#* Version 2.0 (the "License"); you may not use this file except +#* in compliance with the License. +#* You may obtain a copy of the License at +#* +#* http://www.apache.org/licenses/LICENSE-2.0 +#* +#* Unless required by applicable law or agreed to in writing, +#* software distributed under the License is distributed on an +#* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +#* KIND, either express or implied. See the License for the +#* specific language governing permissions and limitations +#* under the License. +#**/ +#""" + +#!/bin/bash + +echo "----------------------------------------------------------------" +echo "| WSO2 IOT Sample " +echo "| RaspiAgent " +echo "| ---------------- " +echo "| ....initializing startup-script " +echo "----------------------------------------------------------------" + +currentDir=$PWD + +while true; do + read -p "Do you wish to run 'apt-get update' and continue? [Yes/No] " yn + case $yn in + [Yy]* ) sudo apt-get update; + break;; + [Nn]* ) echo "Continuing without apt-get update..."; + break;; + * ) echo "Please answer yes or no."; + esac +done + +if [ $? -ne 0 ]; then + echo "apt-get update failed.... Some dependencies may not get installed" + echo "If an already installed version of the package exists, try running:" + echo "----------------------------------------------------------------" + echo "sudo -i" + echo "cd /var/lib/dpkg/info" + echo "rm -rf wso2-raspi-alarm*" + echo "dpkg --remove --force-remove-reinstreq wso2-raspi-agent" + echo "exit" + echo "----------------------------------------------------------------" + echo "Retry Installation...." + break; +fi + +for f in ./deviceConfig.properties; do + ## Check if the glob gets expanded to existing files. + ## If not, f here will be exactly the pattern above + ## and the exists test will evaluate to false. + if [ -e "$f" ]; then + echo "Configuration file found......" + else + echo "'deviceConfig.properties' file does not exist in current path. \nExiting installation..."; + exit; + fi + ## This is all we needed to know, so we can break after the first iteration + break +done + +cd $currentDir + +while true; do + read -p "Whats the time-interval (in seconds) between successive Data-Pushes to the WSO2-DC (ex: '60' indicates 1 minute) > " input + read -p "Are you want to run this as a virtual agent? (Yes/No) " mode + + if [ $input -eq $input 2>/dev/null ] + then + echo "Setting data-push interval to $input seconds." + else + echo "Input needs to be an integer indicating the number seconds between successive data-pushes." + fi + case $mode in + [Yy]* ) mode="Y" + echo "----------------------------------------------------------" + echo " This will run as a virtual agent " + echo "----------------------------------------------------------" + break;; + [Nn]* ) mode="N" + echo "----------------------------------------------------------" + echo " This will run as a real agent " + echo "----------------------------------------------------------" + break;; + * ) echo "Please answer yes or no."; + esac +done +cp deviceConfig.properties ./src + +if [ "$mode" = "N" ]; then + sudo apt-get install rpi.gpio + git clone https://github.com/adafruit/Adafruit_Python_DHT.git + sudo apt-get install build-essential python-dev python-openssl + sudo python ./Adafruit_Python_DHT/setup.py install +fi + +chmod +x ./src/RaspberryAgent.py +./src/RaspberryAgent.py -i $input -m $mode + +if [ $? -ne 0 ]; then + echo "Could not start the service..." + exit; +fi + + +echo "--------------------------------------------------------------------------" +echo "| Successfully Started " +echo "| -------------------------- " \ No newline at end of file diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/build.properties b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/build.properties new file mode 100644 index 000000000..9c86577d7 --- /dev/null +++ b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/build.properties @@ -0,0 +1 @@ +custom = true diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/configs/raspberrypi.json b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/configs/raspberrypi.json new file mode 100644 index 000000000..aad069ddc --- /dev/null +++ b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/configs/raspberrypi.json @@ -0,0 +1,19 @@ +{ + "deviceType": { + "label": "RaspberryPi", + "category": "iot" + }, + "analyticStreams": [ + { + "name": "Temperature", + "table": "DEVICE_TEMPERATURE_SUMMARY", + "ui_unit": { + "name": "cdmf.unit.analytics.line-chart", + "data":[ + {"column": {"name":"TIME", "label":"time", "ui-mapping":"x-axis"}}, + {"column": {"name":"TEMPERATURE", "label":"Temperature", "ui-mapping":"y-axis"}} + ] + } + } + ] +} \ No newline at end of file diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/datasources/raspberrypi-datasources.xml b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/datasources/raspberrypi-datasources.xml new file mode 100644 index 000000000..62982ef29 --- /dev/null +++ b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/datasources/raspberrypi-datasources.xml @@ -0,0 +1,48 @@ + + + + + org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader + + + + + RaspberryPi_DB + The datasource used for the RaspberryPi database + + jdbc/RaspberryPiDM_DB + + + + jdbc:h2:repository/database/RaspberryPiDM_DB;DB_CLOSE_ON_EXIT=FALSE + + wso2carbon + wso2carbon + org.h2.Driver + 50 + 60000 + true + SELECT 1 + 30000 + + + + + + diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/dbscripts/h2.sql b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/dbscripts/h2.sql new file mode 100644 index 000000000..aead055a4 --- /dev/null +++ b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/dbscripts/h2.sql @@ -0,0 +1,11 @@ + +-- ----------------------------------------------------- +-- Table `RASPBERRYPI_DEVICE` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `RASPBERRYPI_DEVICE` ( + `RASPBERRYPI_DEVICE_ID` VARCHAR(45) NOT NULL , + `DEVICE_NAME` VARCHAR(100) NULL DEFAULT NULL, + PRIMARY KEY (`RASPBERRYPI_DEVICE_ID`) ); + + + diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/dbscripts/mysql.sql b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/dbscripts/mysql.sql new file mode 100644 index 000000000..ad0ec54b7 --- /dev/null +++ b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/dbscripts/mysql.sql @@ -0,0 +1,12 @@ +-- ----------------------------------------------------- +-- Table `RASPBERRYPI_DEVICE` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `RASPBERRYPI_DEVICE` ( + `RASPBERRYPI_DEVICE_ID` VARCHAR(45) NOT NULL , + `DEVICE_NAME` VARCHAR(100) NULL DEFAULT NULL, + PRIMARY KEY (`RASPBERRYPI_DEVICE_ID`) ) +ENGINE = InnoDB; + + + + diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/p2.inf b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/p2.inf new file mode 100644 index 000000000..97d22ac40 --- /dev/null +++ b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/p2.inf @@ -0,0 +1,14 @@ +instructions.configure = \ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../conf/device-types/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.raspberrypi_${feature.version}/configs/,target:${installFolder}/../../conf/device-types/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.raspberrypi_${feature.version}/webapps/,target:${installFolder}/../../deployment/server/webapps/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/sketches/);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/sketches/raspberrypi/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.raspberrypi_${feature.version}/agent/,target:${installFolder}/../../resources/sketches/raspberrypi/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.raspberrypi_${feature.version}/dbscripts/,target:${installFolder}/../../../dbscripts/cdm/plugins/raspberrypi,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/jaggeryapps/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.raspberrypi_${feature.version}/jaggeryapps/,target:${installFolder}/../../deployment/server/jaggeryapps/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.raspberrypi_${feature.version}/datasources/,target:${installFolder}/../../conf/datasources/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../database/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.raspberrypi_${feature.version}/database/,target:${installFolder}/../../database/,overwrite:true);\ diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/pom.xml b/features/iot-plugins-feature/raspberrypi-plugin-feature/pom.xml new file mode 100644 index 000000000..da8d1375b --- /dev/null +++ b/features/iot-plugins-feature/raspberrypi-plugin-feature/pom.xml @@ -0,0 +1,41 @@ + + + + + + + org.wso2.carbon.devicemgt-plugins + iot-plugins-feature + 2.1.0-SNAPSHOT + ../pom.xml + + + 4.0.0 + raspberrypi-plugin-feature + pom + WSO2 Carbon - IoT Server RaspberryPi Device Feature + http://wso2.org + + + org.wso2.carbon.device.mgt.iot.raspberrypi.feature + + + diff --git a/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/pom.xml b/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/pom.xml new file mode 100644 index 000000000..a64bb38ba --- /dev/null +++ b/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/pom.xml @@ -0,0 +1,250 @@ + + + + + + + + org.wso2.carbon.devicemgt-plugins + virtual-fire-alarm-plugin-feature + 2.1.0-SNAPSHOT + ../pom.xml + + + 4.0.0 + org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature + pom + WSO2 Carbon - IoT Server VirtualFireAlarm Feature + http://wso2.org + This feature contains the VirtualFireAlarm Device type specific implementations for the IoT Server + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.virtualfirealarm.api + war + + + com.h2database.wso2 + h2-database-engine + + + + + + + maven-resources-plugin + + + copy-resources + generate-resources + + copy-resources + + + src/main/resources + + + resources + + build.properties + p2.inf + + + + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + unpack + package + + unpack + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.virtualfirealarm.analytics + + ${project.version} + zip + true + + ${project.build.directory}/maven-shared-archive-resources/carbonapps + + **/* + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui + + ${project.version} + zip + true + + ${project.build.directory}/maven-shared-archive-resources/jaggeryapps/devicemgt + + **/* + + + + + + copy-jaxrs-war + package + + copy + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.virtualfirealarm.api + + war + true + ${project.build.directory}/maven-shared-archive-resources/webapps/ + virtual_firealarm.war + + + + + + + copy-agent-jar + package + + copy + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl + + true + ${project.build.directory}/maven-shared-archive-resources/agent/ + wso2-firealarm-virtual-agent.jar + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl + + true + ${project.build.directory}/maven-shared-archive-resources/advanced_agent/ + wso2-firealarm-virtual-agent-advanced.jar + + + + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + + create-virtual-firealarm-plugin-mgt-schema + package + + run + + + + + + + + + + + + + + + + + + + + + + + + + + + org.wso2.maven + carbon-p2-plugin + ${carbon.p2.plugin.version} + + + p2-feature-generation + package + + p2-feature-gen + + + org.wso2.carbon.device.mgt.iot.virtualfirealarm + ../../../features/etc/feature.properties + + + org.wso2.carbon.p2.category.type:server + org.eclipse.equinox.p2.type.group:false + + + + + org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin:${carbon.devicemgt.plugins.version} + + + + org.wso2.carbon.core.server:${carbon.kernel.version} + + org.wso2.carbon.device.mgt.server:${carbon.device.mgt.version} + + + + + + + + + + diff --git a/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/advanced_agent/deviceConfig.properties b/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/advanced_agent/deviceConfig.properties new file mode 100644 index 000000000..9e200340e --- /dev/null +++ b/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/advanced_agent/deviceConfig.properties @@ -0,0 +1,34 @@ +# +# Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# + +#[Device-Configurations] +server-name=${SERVER_NAME} +owner=${DEVICE_OWNER} +deviceId=${DEVICE_ID} +device-name=${DEVICE_NAME} +controller-context=/virtual_firealarm/controller +https-ep=${HTTPS_EP} +http-ep=${HTTP_EP} +apim-ep=${APIM_EP} +mqtt-ep=${MQTT_EP} +xmpp-ep=${XMPP_EP} +auth-method=token +auth-token=${DEVICE_TOKEN} +refresh-token=${DEVICE_REFRESH_TOKEN} +push-interval=15 + + diff --git a/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/advanced_agent/sketch.properties b/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/advanced_agent/sketch.properties new file mode 100644 index 000000000..801bd88de --- /dev/null +++ b/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/advanced_agent/sketch.properties @@ -0,0 +1,2 @@ +templates=deviceConfig.properties +zipfilename=FireAlarmVirtualAgent.zip diff --git a/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/advanced_agent/start-device.sh b/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/advanced_agent/start-device.sh new file mode 100755 index 000000000..647ea81c9 --- /dev/null +++ b/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/advanced_agent/start-device.sh @@ -0,0 +1,190 @@ +#!/bin/bash + +echo "----------------------------------------------------------------" +echo "| WSO2 IOT Sample " +echo "| Virtual RaspiAlarm " +echo "| ---------------- " +echo "| ....initializing startup-script " +echo "----------------------------------------------------------------" + +#while true; do +# read -p "What is the network-interface of your device that the Agent should use (find from ifconfig. ex: wlan0,en0,eth0..) > " interface +# +# echo "Setting the network-interface to " $interface +# sed s/^network-interface=.*/network-interface=$interface/ deviceConfig.properties > myTmp +# mv -f myTmp deviceConfig.properties +# break; +#done +# +#while true; do +# read -p "Whats the time-interval (in seconds) between successive Data-Pushes to the WSO2-IoT-Server (ex: '60' indicates 1 minute) > " interval +# +# if [ $interval -eq $interval 2>/dev/null ] +# then +# echo "Setting data-push interval to " $interval " seconds." +# sed s/^push-interval=.*/push-interval=$interval/ deviceConfig.properties > myTmp +# mv -f myTmp deviceConfig.properties +# break; +# else +# echo "Input needs to be an integer indicating the number seconds between successive data-pushes." +# fi +#done + + +java -jar wso2-firealarm-virtual-agent-advanced.jar + +#while true; do +# read -p "Do you wish to run 'apt-get update' and continue? [Yes/No] " yn +# case $yn in +# [Yy]* ) sudo apt-get update; +# break;; +# [Nn]* ) echo "Continuing without apt-get update..."; +# break;; +# * ) echo "Please answer yes or no."; +# esac +#done +# +#if [ $? -ne 0 ]; then +# echo "apt-get update failed.... Some dependencies may not get installed" +# echo "If an already installed version of the package exists, try running:" +# echo "----------------------------------------------------------------" +# echo "sudo -i" +# echo "cd /var/lib/dpkg/info" +# echo "rm -rf wso2-raspi-alarm*" +# echo "dpkg --remove --force-remove-reinstreq wso2-raspi-alarm" +# echo "exit" +# echo "----------------------------------------------------------------" +# echo "Retry Installation...." +# break; +#fi +# +#echo "Installing 'gdebi' package..." +#sudo apt-get install gdebi # installation of gdebi +# +# +#if [ $? -ne 0 ]; then +# echo "gdebi installation failed.... dependencies will not be installed without gdebi" +# read -p "Do you wish to continue without gdebi? [Yes/No] " yn +# case $yn in +# [Yy]* ) echo "Continueing without gdebi.....";; +# [Nn]* ) echo "Try to resolve errors and re-run the script."; +# exit;; +# * ) exit;; +# esac +#fi +# +# +#for f in ./wso2-raspi-alarm_1.0_armhf.deb; do +# ## Check if the glob gets expanded to existing files. +# ## If not, f here will be exactly the pattern above +# ## and the exists test will evaluate to false. +# # [ -e "$f" ] && echo "'wso2-raspi-alarm_1.0_armhf.deb' file found and installing" || echo "'wso2-raspi-alarm_1.0_armhf.deb' file does not exist in current path"; exit; +# if [ -e "$f" ]; then +# echo "'wso2-raspi-alarm_1.0_armhf.deb' file found and installing now...." +# else +# echo "'wso2-raspi-alarm_1.0_armhf.deb' file does not exist in current path. \nExiting installation..."; +# exit; +# fi +# ## This is all we needed to know, so we can break after the first iteration +# break +#done +# +#echo "Installing the 'wso2-raspi-alarm deb package'" +#sudo gdebi wso2-raspi-alarm_1.0_armhf.deb +# +#if [ $? -ne 0 ]; then +# echo "Installation Failed...." +# exit; +#fi + +#sudo killall -9 python +# +#for f in ./RaspberryAgent.zip; do +# ## Check if the glob gets expanded to existing files. +# ## If not, f here will be exactly the pattern above +# ## and the exists test will evaluate to false. +# # [ -e "$f" ] && echo "'wso2-raspi-alarm_1.0_armhf.deb' file found and installing" || echo "'wso2-raspi-alarm_1.0_armhf.deb' file does not exist in current path"; exit; +# if [ -e "$f" ]; then +# echo "Agent files found......" +# sudo rm -rf /usr/local/src/RaspberryAgent +# sudo unzip RaspberryAgent.zip -d /usr/local/src/ +# else +# echo "'RaspberryAgent.zip' file does not exist in current path. \nInstalling without upgrading agent..."; +# fi +# ## This is all we needed to know, so we can break after the first iteration +# break +#done +# +#for f in /usr/local/src/RaspberryAgent/rc.local; do +# ## Check if the glob gets expanded to existing files. +# ## If not, f here will be exactly the pattern above +# ## and the exists test will evaluate to false. +# if [ -e "$f" ]; then +# echo "Copying boot script" +# sudo mv /usr/local/src/RaspberryAgent/rc.local /etc/rc.local +# sudo chmod +x /etc/rc.local +# else +# echo "Unable to set agent statup on boot"; +# fi +# ## This is all we needed to know, so we can break after the first iteration +# break +#done +# +#for f in ./deviceConfigs.cfg; do +# ## Check if the glob gets expanded to existing files. +# ## If not, f here will be exactly the pattern above +# ## and the exists test will evaluate to false. +# if [ -e "$f" ]; then +# echo "Configuration file found......" +# else +# echo "'deviceConfigs.cfg' file does not exist in current path. \nExiting installation..."; +# exit; +# fi +# ## This is all we needed to know, so we can break after the first iteration +# break +#done +# +#echo "Altering Configuration file" +#sed -i 's|[/,]||g' deviceConfigs.cfg +# +#echo "Copying configurations file to /usr/local/src/RaspberryAgent" +#sudo cp ./deviceConfigs.cfg /usr/local/src/RaspberryAgent/ +# +#if [ $? -ne 0 ]; then +# echo "Copying configuration file failed...." +# exit; +#fi +# +#while true; do +# read -p "Whats the time-interval (in seconds) between successive Data-Pushes to the WSO2-DC (ex: '60' indicates 1 minute) > " input +# +# if [ $input -eq $input 2>/dev/null ] +# then +# echo "Setting data-push interval to $input seconds." +# echo $input > /usr/local/src/RaspberryAgent/time-interval +# break; +# else +# echo "Input needs to be an integer indicating the number seconds between successive data-pushes." +# fi +#done +# +#cd /usr/local/src/RaspberryAgent/ +#sudo chmod +x RaspberryStats.py +#sudo nohup ./RaspberryStats.py -i $input " interface +# +# echo "Setting the network-interface to " $interface +# sed s/^network-interface=.*/network-interface=$interface/ deviceConfig.properties > myTmp +# mv -f myTmp deviceConfig.properties +# break; +#done +# +#while true; do +# read -p "Whats the time-interval (in seconds) between successive Data-Pushes to the WSO2-IoT-Server (ex: '60' indicates 1 minute) > " interval +# +# if [ $interval -eq $interval 2>/dev/null ] +# then +# echo "Setting data-push interval to " $interval " seconds." +# sed s/^push-interval=.*/push-interval=$interval/ deviceConfig.properties > myTmp +# mv -f myTmp deviceConfig.properties +# break; +# else +# echo "Input needs to be an integer indicating the number seconds between successive data-pushes." +# fi +#done + + +java -jar wso2-firealarm-virtual-agent.jar + +#while true; do +# read -p "Do you wish to run 'apt-get update' and continue? [Yes/No] " yn +# case $yn in +# [Yy]* ) sudo apt-get update; +# break;; +# [Nn]* ) echo "Continuing without apt-get update..."; +# break;; +# * ) echo "Please answer yes or no."; +# esac +#done +# +#if [ $? -ne 0 ]; then +# echo "apt-get update failed.... Some dependencies may not get installed" +# echo "If an already installed version of the package exists, try running:" +# echo "----------------------------------------------------------------" +# echo "sudo -i" +# echo "cd /var/lib/dpkg/info" +# echo "rm -rf wso2-raspi-alarm*" +# echo "dpkg --remove --force-remove-reinstreq wso2-raspi-alarm" +# echo "exit" +# echo "----------------------------------------------------------------" +# echo "Retry Installation...." +# break; +#fi +# +#echo "Installing 'gdebi' package..." +#sudo apt-get install gdebi # installation of gdebi +# +# +#if [ $? -ne 0 ]; then +# echo "gdebi installation failed.... dependencies will not be installed without gdebi" +# read -p "Do you wish to continue without gdebi? [Yes/No] " yn +# case $yn in +# [Yy]* ) echo "Continueing without gdebi.....";; +# [Nn]* ) echo "Try to resolve errors and re-run the script."; +# exit;; +# * ) exit;; +# esac +#fi +# +# +#for f in ./wso2-raspi-alarm_1.0_armhf.deb; do +# ## Check if the glob gets expanded to existing files. +# ## If not, f here will be exactly the pattern above +# ## and the exists test will evaluate to false. +# # [ -e "$f" ] && echo "'wso2-raspi-alarm_1.0_armhf.deb' file found and installing" || echo "'wso2-raspi-alarm_1.0_armhf.deb' file does not exist in current path"; exit; +# if [ -e "$f" ]; then +# echo "'wso2-raspi-alarm_1.0_armhf.deb' file found and installing now...." +# else +# echo "'wso2-raspi-alarm_1.0_armhf.deb' file does not exist in current path. \nExiting installation..."; +# exit; +# fi +# ## This is all we needed to know, so we can break after the first iteration +# break +#done +# +#echo "Installing the 'wso2-raspi-alarm deb package'" +#sudo gdebi wso2-raspi-alarm_1.0_armhf.deb +# +#if [ $? -ne 0 ]; then +# echo "Installation Failed...." +# exit; +#fi + +#sudo killall -9 python +# +#for f in ./RaspberryAgent.zip; do +# ## Check if the glob gets expanded to existing files. +# ## If not, f here will be exactly the pattern above +# ## and the exists test will evaluate to false. +# # [ -e "$f" ] && echo "'wso2-raspi-alarm_1.0_armhf.deb' file found and installing" || echo "'wso2-raspi-alarm_1.0_armhf.deb' file does not exist in current path"; exit; +# if [ -e "$f" ]; then +# echo "Agent files found......" +# sudo rm -rf /usr/local/src/RaspberryAgent +# sudo unzip RaspberryAgent.zip -d /usr/local/src/ +# else +# echo "'RaspberryAgent.zip' file does not exist in current path. \nInstalling without upgrading agent..."; +# fi +# ## This is all we needed to know, so we can break after the first iteration +# break +#done +# +#for f in /usr/local/src/RaspberryAgent/rc.local; do +# ## Check if the glob gets expanded to existing files. +# ## If not, f here will be exactly the pattern above +# ## and the exists test will evaluate to false. +# if [ -e "$f" ]; then +# echo "Copying boot script" +# sudo mv /usr/local/src/RaspberryAgent/rc.local /etc/rc.local +# sudo chmod +x /etc/rc.local +# else +# echo "Unable to set agent statup on boot"; +# fi +# ## This is all we needed to know, so we can break after the first iteration +# break +#done +# +#for f in ./deviceConfigs.cfg; do +# ## Check if the glob gets expanded to existing files. +# ## If not, f here will be exactly the pattern above +# ## and the exists test will evaluate to false. +# if [ -e "$f" ]; then +# echo "Configuration file found......" +# else +# echo "'deviceConfigs.cfg' file does not exist in current path. \nExiting installation..."; +# exit; +# fi +# ## This is all we needed to know, so we can break after the first iteration +# break +#done +# +#echo "Altering Configuration file" +#sed -i 's|[/,]||g' deviceConfigs.cfg +# +#echo "Copying configurations file to /usr/local/src/RaspberryAgent" +#sudo cp ./deviceConfigs.cfg /usr/local/src/RaspberryAgent/ +# +#if [ $? -ne 0 ]; then +# echo "Copying configuration file failed...." +# exit; +#fi +# +#while true; do +# read -p "Whats the time-interval (in seconds) between successive Data-Pushes to the WSO2-DC (ex: '60' indicates 1 minute) > " input +# +# if [ $input -eq $input 2>/dev/null ] +# then +# echo "Setting data-push interval to $input seconds." +# echo $input > /usr/local/src/RaspberryAgent/time-interval +# break; +# else +# echo "Input needs to be an integer indicating the number seconds between successive data-pushes." +# fi +#done +# +#cd /usr/local/src/RaspberryAgent/ +#sudo chmod +x RaspberryStats.py +#sudo nohup ./RaspberryStats.py -i $input + + + + org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader + + + + + VirtualFireAlarmDM_DB + The datasource used for the Virtual-Firealarm database + + jdbc/VirtualFireAlarmDM_DB + + + + jdbc:h2:repository/database/VirtualFireAlarmDM_DB;DB_CLOSE_ON_EXIT=FALSE + + wso2carbon + wso2carbon + org.h2.Driver + 50 + 60000 + true + SELECT 1 + 30000 + + + + + + diff --git a/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/dbscripts/h2.sql b/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/dbscripts/h2.sql new file mode 100644 index 000000000..340ba6a70 --- /dev/null +++ b/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/dbscripts/h2.sql @@ -0,0 +1,11 @@ + +-- ----------------------------------------------------- +-- Table `FIREALARM_DEVICE` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `VIRTUAL_FIREALARM_DEVICE` ( + `VIRTUAL_FIREALARM_DEVICE_ID` VARCHAR(45) NOT NULL , + `DEVICE_NAME` VARCHAR(100) NULL DEFAULT NULL, + PRIMARY KEY (`VIRTUAL_FIREALARM_DEVICE_ID`) ); + + + diff --git a/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/dbscripts/mysql.sql b/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/dbscripts/mysql.sql new file mode 100644 index 000000000..432ecbb0e --- /dev/null +++ b/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/dbscripts/mysql.sql @@ -0,0 +1,12 @@ +-- ----------------------------------------------------- +-- Table `FIREALARM_DEVICE` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `VIRTUAL_FIREALARM_DEVICE` ( + `VIRTUAL_FIREALARM_DEVICE_ID` VARCHAR(45) NOT NULL , + `DEVICE_NAME` VARCHAR(100) NULL DEFAULT NULL, + PRIMARY KEY (`VIRTUAL_FIREALARM_DEVICE_ID`) ) +ENGINE = InnoDB; + + + + diff --git a/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/p2.inf b/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/p2.inf new file mode 100644 index 000000000..7711271ef --- /dev/null +++ b/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/p2.inf @@ -0,0 +1,18 @@ +instructions.configure = \ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../conf/device-types/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.virtualfirealarm_${feature.version}/configs/,target:${installFolder}/../../conf/device-types/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.virtualfirealarm_${feature.version}/webapps/,target:${installFolder}/../../deployment/server/webapps/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/carbonapps/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.virtualfirealarm_${feature.version}/carbonapps/,target:${installFolder}/../../deployment/server/carbonapps/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/sketches/);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/sketches/virtual_firealarm/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.virtualfirealarm_${feature.version}/agent/,target:${installFolder}/../../resources/sketches/virtual_firealarm/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/sketches/virtual_firealarm_advanced/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.virtualfirealarm_${feature.version}/advanced_agent/,target:${installFolder}/../../resources/sketches/virtual_firealarm_advanced/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.virtualfirealarm_${feature.version}/dbscripts/,target:${installFolder}/../../../dbscripts/cdm/plugins/virtual_firealarm,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/jaggeryapps/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.virtualfirealarm_${feature.version}/jaggeryapps/,target:${installFolder}/../../deployment/server/jaggeryapps/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.virtualfirealarm_${feature.version}/datasources/,target:${installFolder}/../../conf/datasources/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../database/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.virtualfirealarm_${feature.version}/database/,target:${installFolder}/../../database/,overwrite:true);\ diff --git a/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/pom.xml b/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/pom.xml new file mode 100644 index 000000000..3a56662c7 --- /dev/null +++ b/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/pom.xml @@ -0,0 +1,41 @@ + + + + + + + org.wso2.carbon.devicemgt-plugins + iot-plugins-feature + 2.1.0-SNAPSHOT + ../pom.xml + + + 4.0.0 + virtual-fire-alarm-plugin-feature + pom + WSO2 Carbon - IoT Server VirtualFireAlarm Device Feature + http://wso2.org + + + org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature + + + diff --git a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/pom.xml b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/pom.xml index 04a5dff15..d92c4dcaa 100644 --- a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/pom.xml +++ b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/pom.xml @@ -161,7 +161,7 @@ - org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.mobile.impl:${carbon.mobile.device.mgt.version} + org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.mobile:${carbon.mobile.device.mgt.version} org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.mobile.url.printer:${carbon.mobile.device.mgt.version} diff --git a/pom.xml b/pom.xml index 1c0f7443d..c0df257a1 100644 --- a/pom.xml +++ b/pom.xml @@ -265,7 +265,7 @@ org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.jwt.client.extension + org.wso2.carbon.identity.jwt.client.extension ${carbon.devicemgt.version} @@ -339,13 +339,7 @@ org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.androidsense.controller.api - ${carbon.devicemgt.plugins.version} - war - - - org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.androidsense.manager.api + org.wso2.carbon.device.mgt.iot.androidsense.api ${carbon.devicemgt.plugins.version} war @@ -355,24 +349,12 @@ org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.arduino.plugin.impl + org.wso2.carbon.device.mgt.iot.arduino.plugin ${carbon.devicemgt.plugins.version} org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.arduino.service.impl - ${carbon.devicemgt.plugins.version} - war - - - org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.arduino.manager.service.impl - ${carbon.devicemgt.plugins.version} - war - - - org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.arduino.controller.service.impl + org.wso2.carbon.device.mgt.iot.arduino.api ${carbon.devicemgt.plugins.version} war @@ -386,13 +368,7 @@ org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.digitaldisplay.manager.api - ${carbon.devicemgt.plugins.version} - war - - - org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.digitaldisplay.controller.api + org.wso2.carbon.device.mgt.iot.digitaldisplay.api ${carbon.devicemgt.plugins.version} war @@ -408,14 +384,7 @@ org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.droneanalyzer.manager.api - ${carbon.devicemgt.plugins.version} - war - - - - org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.droneanalyzer.controller.api + org.wso2.carbon.device.mgt.iot.droneanalyzer.api ${carbon.devicemgt.plugins.version} war @@ -425,18 +394,12 @@ org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl + org.wso2.carbon.device.mgt.iot.raspberrypi.plugin ${carbon.devicemgt.plugins.version} org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.raspberrypi.manager.service.impl - ${carbon.devicemgt.plugins.version} - war - - - org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.raspberrypi.controller.service.impl + org.wso2.carbon.device.mgt.iot.raspberrypi.api ${carbon.devicemgt.plugins.version} war @@ -446,20 +409,13 @@ org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl + org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin ${carbon.devicemgt.plugins.version} org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.virtualfirealarm.manager.service.impl - ${carbon.devicemgt.plugins.version} - war - - - - org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.virtualfirealarm.controller.service.impl + org.wso2.carbon.device.mgt.iot.virtualfirealarm.api ${carbon.devicemgt.plugins.version} war @@ -480,7 +436,7 @@ org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.camera.plugin.impl + org.wso2.carbon.device.mgt.iot.camera.plugin ${carbon.devicemgt.plugins.version} @@ -495,7 +451,7 @@ org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.mobile.impl + org.wso2.carbon.device.mgt.mobile ${carbon.mobile.device.mgt.version} @@ -1136,8 +1092,8 @@ 5.0.11 [5.0.11,6.0.0) - 1.0.6-SNAPSHOT - [1.0.6,2.0.0] + 1.0.5 + [1.0.5,2.0.0] 1.51.0.0