diff --git a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.controller.service.impl/pom.xml b/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.controller.service.impl/pom.xml deleted file mode 100644 index b1930e8f0..000000000 --- a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.controller.service.impl/pom.xml +++ /dev/null @@ -1,261 +0,0 @@ - - - - - - camera-plugin - org.wso2.carbon.devicemgt-plugins - 2.1.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.device.mgt.iot.camera.controller.service.impl - war - WSO2 Carbon - IoT Server Camera API - WSO2 Carbon - Camera Service Controller API Implementation - http://wso2.org - - - - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.common - provided - - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.core - provided - - - org.apache.axis2.wso2 - axis2-client - - - - - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.analytics - provided - - - org.apache.axis2.wso2 - axis2-client - - - - - - org.wso2.carbon.devicemgt - org.wso2.carbon.certificate.mgt.core - provided - - - commons-codec.wso2 - commons-codec - - - - - - - - org.apache.cxf - cxf-rt-frontend-jaxws - provided - - - org.apache.cxf - cxf-rt-frontend-jaxrs - provided - - - org.apache.cxf - cxf-rt-transports-http - provided - - - - - org.eclipse.paho - org.eclipse.paho.client.mqttv3 - provided - - - - - org.apache.httpcomponents - httpasyncclient - 4.1 - provided - - - org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot - provided - - - org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.camera.plugin.impl - provided - - - - - org.codehaus.jackson - jackson-core-asl - - - org.codehaus.jackson - jackson-jaxrs - - - javax - javaee-web-api - provided - - - javax.ws.rs - jsr311-api - provided - - - commons-httpclient.wso2 - commons-httpclient - provided - - - - org.wso2.carbon - org.wso2.carbon.utils - provided - - - org.bouncycastle.wso2 - bcprov-jdk15on - - - org.wso2.carbon - org.wso2.carbon.user.api - - - org.wso2.carbon - org.wso2.carbon.queuing - - - org.wso2.carbon - org.wso2.carbon.base - - - org.apache.axis2.wso2 - axis2 - - - org.igniterealtime.smack.wso2 - smack - - - org.igniterealtime.smack.wso2 - smackx - - - jaxen - jaxen - - - commons-fileupload.wso2 - commons-fileupload - - - org.apache.ant.wso2 - ant - - - org.apache.ant.wso2 - ant - - - commons-httpclient.wso2 - commons-httpclient - - - org.eclipse.equinox - javax.servlet - - - org.wso2.carbon - org.wso2.carbon.registry.api - - - - - - commons-codec.wso2 - commons-codec - - - - org.wso2.carbon.devicemgt - org.wso2.carbon.apimgt.annotations - provided - - - - org.igniterealtime.smack.wso2 - smack - provided - - - org.igniterealtime.smack.wso2 - smackx - provided - - - org.wso2.carbon.devicemgt - org.wso2.carbon.apimgt.webapp.publisher - provided - - - - - - - - - maven-compiler-plugin - - UTF-8 - ${wso2.maven.compiler.source} - ${wso2.maven.compiler.target} - - - - maven-war-plugin - - camera - - - - - - diff --git a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.manager.service.impl/pom.xml b/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.manager.service.impl/pom.xml deleted file mode 100644 index 98667f028..000000000 --- a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.manager.service.impl/pom.xml +++ /dev/null @@ -1,261 +0,0 @@ - - - - - - camera-plugin - org.wso2.carbon.devicemgt-plugins - 2.1.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.device.mgt.iot.camera.manager.service.impl - war - WSO2 Carbon - IoT Server Camera API - WSO2 Carbon - Camera Service Management API Implementation - http://wso2.org - - - - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.common - provided - - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.core - provided - - - org.apache.axis2.wso2 - axis2-client - - - - - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.analytics - provided - - - org.apache.axis2.wso2 - axis2-client - - - - - - org.wso2.carbon.devicemgt - org.wso2.carbon.certificate.mgt.core - provided - - - commons-codec.wso2 - commons-codec - - - - - - - - org.apache.cxf - cxf-rt-frontend-jaxws - provided - - - org.apache.cxf - cxf-rt-frontend-jaxrs - provided - - - org.apache.cxf - cxf-rt-transports-http - provided - - - - - org.eclipse.paho - org.eclipse.paho.client.mqttv3 - provided - - - - - org.apache.httpcomponents - httpasyncclient - 4.1 - provided - - - org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot - provided - - - org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.camera.plugin.impl - provided - - - - - org.codehaus.jackson - jackson-core-asl - - - org.codehaus.jackson - jackson-jaxrs - - - javax - javaee-web-api - provided - - - javax.ws.rs - jsr311-api - provided - - - commons-httpclient.wso2 - commons-httpclient - provided - - - - org.wso2.carbon - org.wso2.carbon.utils - provided - - - org.bouncycastle.wso2 - bcprov-jdk15on - - - org.wso2.carbon - org.wso2.carbon.user.api - - - org.wso2.carbon - org.wso2.carbon.queuing - - - org.wso2.carbon - org.wso2.carbon.base - - - org.apache.axis2.wso2 - axis2 - - - org.igniterealtime.smack.wso2 - smack - - - org.igniterealtime.smack.wso2 - smackx - - - jaxen - jaxen - - - commons-fileupload.wso2 - commons-fileupload - - - org.apache.ant.wso2 - ant - - - org.apache.ant.wso2 - ant - - - commons-httpclient.wso2 - commons-httpclient - - - org.eclipse.equinox - javax.servlet - - - org.wso2.carbon - org.wso2.carbon.registry.api - - - - - - commons-codec.wso2 - commons-codec - - - - org.wso2.carbon.devicemgt - org.wso2.carbon.apimgt.annotations - provided - - - - org.igniterealtime.smack.wso2 - smack - provided - - - org.igniterealtime.smack.wso2 - smackx - provided - - - org.wso2.carbon.devicemgt - org.wso2.carbon.apimgt.webapp.publisher - provided - - - - - - - - - maven-compiler-plugin - - UTF-8 - ${wso2.maven.compiler.source} - ${wso2.maven.compiler.target} - - - - maven-war-plugin - - camera_mgt - - - - - - diff --git a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/pom.xml b/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/pom.xml deleted file mode 100644 index bd3c82af6..000000000 --- a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/pom.xml +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - camera-plugin - org.wso2.carbon.devicemgt-plugins - 2.1.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.device.mgt.iot.camera.plugin.impl - bundle - WSO2 Carbon - IoT Server Camera Management Plugin - WSO2 Carbon - Camera Management/Control Plugin Implementation - http://wso2.org - - - - - org.apache.felix - maven-scr-plugin - - - maven-compiler-plugin - - 1.7 - 1.7 - - 2.3.2 - - - org.apache.felix - maven-bundle-plugin - 1.4.0 - true - - - ${project.artifactId} - ${project.artifactId} - ${carbon.devicemgt.plugins.version} - IoT Server Camera Impl Bundle - org.wso2.carbon.device.mgt.iot.camera.plugin.internal - - org.osgi.framework, - org.osgi.service.component, - org.apache.commons.logging, - javax.xml.bind.*, - javax.naming, - javax.sql, - javax.xml.bind.annotation.*, - javax.xml.parsers, - 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.iot.camera.plugin.internal, - org.wso2.carbon.device.mgt.iot.camera.plugin.* - - - - - - - - - - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.osgi - org.eclipse.osgi.services - - - - org.wso2.carbon - org.wso2.carbon.logging - - - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.common - - - org.wso2.carbon - org.wso2.carbon.ndatasource.core - - - - org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot - - - - - \ No newline at end of file diff --git a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/constants/CameraConstants.java b/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/constants/CameraConstants.java deleted file mode 100644 index fa9b91d83..000000000 --- a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/constants/CameraConstants.java +++ /dev/null @@ -1,27 +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.camera.plugin.constants; - -public class CameraConstants { - public final static String DEVICE_TYPE = "camera"; - public final static String DEVICE_PLUGIN_DEVICE_NAME = "DEVICE_NAME"; - public final static String DEVICE_PLUGIN_DEVICE_ID = "CAMERA_DEVICE_ID"; - public final static String STATE_ON = "ON"; - public final static String STATE_OFF = "OFF"; -} diff --git a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/impl/CameraManager.java b/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/impl/CameraManager.java deleted file mode 100644 index 1498a4b58..000000000 --- a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/impl/CameraManager.java +++ /dev/null @@ -1,281 +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.camera.plugin.impl; - - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -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.DeviceManager; -import org.wso2.carbon.device.mgt.common.EnrolmentInfo; -import org.wso2.carbon.device.mgt.common.FeatureManager; -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.common.license.mgt.LicenseManagementException; -import org.wso2.carbon.device.mgt.iot.camera.plugin.impl.dao.CameraDAO; -import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceManagementDAOException; -import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceManagementDAOFactory; -import org.wso2.carbon.device.mgt.iot.util.iotdevice.dto.IotDevice; -import org.wso2.carbon.device.mgt.iot.util.iotdevice.util.IotDeviceManagementUtil; - -import java.util.ArrayList; -import java.util.List; - - -/** - * This represents the FireAlarm implementation of DeviceManagerService. - */ -public class CameraManager implements DeviceManager { - - private static final IotDeviceManagementDAOFactory iotDeviceManagementDAOFactory = new CameraDAO(); - private static final Log log = LogFactory.getLog(CameraManager.class); - - - @Override - public FeatureManager getFeatureManager() { - return null; - } - - @Override - public boolean saveConfiguration(TenantConfiguration tenantConfiguration) - throws DeviceManagementException { - //TODO implement this - return false; - } - - @Override - public TenantConfiguration getConfiguration() throws DeviceManagementException { - //TODO implement this - return null; - } - - @Override - public boolean enrollDevice(Device device) throws DeviceManagementException { - boolean status; - IotDevice iotDevice = IotDeviceManagementUtil.convertToIotDevice(device); - try { - if (log.isDebugEnabled()) { - log.debug("Enrolling a new Camera device : " + device.getDeviceIdentifier()); - } - CameraDAO.beginTransaction(); - status = iotDeviceManagementDAOFactory.getIotDeviceDAO().addIotDevice( - iotDevice); - CameraDAO.commitTransaction(); - } catch (IotDeviceManagementDAOException e) { - try { - CameraDAO.rollbackTransaction(); - } catch (IotDeviceManagementDAOException iotDAOEx) { - String msg = "Error occurred while roll back the device enrol transaction :" + device.toString(); - log.warn(msg, iotDAOEx); - } - String msg = "Error while enrolling the Camera device : " + device.getDeviceIdentifier(); - log.error(msg, e); - throw new DeviceManagementException(msg, e); - } - return status; - } - - @Override - public boolean modifyEnrollment(Device device) throws DeviceManagementException { - boolean status; - IotDevice iotDevice = IotDeviceManagementUtil.convertToIotDevice(device); - try { - if (log.isDebugEnabled()) { - log.debug("Modifying the Camera device enrollment data"); - } - CameraDAO.beginTransaction(); - status = iotDeviceManagementDAOFactory.getIotDeviceDAO() - .updateIotDevice(iotDevice); - CameraDAO.commitTransaction(); - } catch (IotDeviceManagementDAOException e) { - try { - CameraDAO.rollbackTransaction(); - } catch (IotDeviceManagementDAOException iotDAOEx) { - String msg = "Error occurred while roll back the update device transaction :" + device.toString(); - log.warn(msg, iotDAOEx); - } - String msg = "Error while updating the enrollment of the Camera device : " + - device.getDeviceIdentifier(); - log.error(msg, e); - throw new DeviceManagementException(msg, e); - } - return status; - } - - @Override - public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException { - boolean status; - try { - if (log.isDebugEnabled()) { - log.debug("Dis-enrolling Camera device : " + deviceId); - } - CameraDAO.beginTransaction(); - status = iotDeviceManagementDAOFactory.getIotDeviceDAO() - .deleteIotDevice(deviceId.getId()); - CameraDAO.commitTransaction(); - } catch (IotDeviceManagementDAOException e) { - try { - CameraDAO.rollbackTransaction(); - } catch (IotDeviceManagementDAOException iotDAOEx) { - String msg = "Error occurred while roll back the device dis enrol transaction :" + deviceId.toString(); - log.warn(msg, iotDAOEx); - } - String msg = "Error while removing the Camera device : " + deviceId.getId(); - log.error(msg, e); - throw new DeviceManagementException(msg, e); - } - return status; - } - - @Override - public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException { - boolean isEnrolled = false; - try { - if (log.isDebugEnabled()) { - log.debug("Checking the enrollment of Camera device : " + deviceId.getId()); - } - IotDevice iotDevice = - iotDeviceManagementDAOFactory.getIotDeviceDAO().getIotDevice( - deviceId.getId()); - if (iotDevice != null) { - isEnrolled = true; - } - } catch (IotDeviceManagementDAOException e) { - String msg = "Error while checking the enrollment status of Camera device : " + - deviceId.getId(); - log.error(msg, e); - throw new DeviceManagementException(msg, e); - } - return isEnrolled; - } - - @Override - public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException { - return true; - } - - @Override - public boolean setActive(DeviceIdentifier deviceId, boolean status) - throws DeviceManagementException { - return true; - } - - @Override - public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException { - Device device; - try { - if (log.isDebugEnabled()) { - log.debug("Getting the details of Camera device : " + deviceId.getId()); - } - IotDevice iotDevice = iotDeviceManagementDAOFactory.getIotDeviceDAO(). - getIotDevice(deviceId.getId()); - device = IotDeviceManagementUtil.convertToDevice(iotDevice); - } catch (IotDeviceManagementDAOException e) { - String msg = "Error while fetching the Camera device : " + deviceId.getId(); - log.error(msg, e); - throw new DeviceManagementException(msg, e); - } - return device; - } - - @Override - public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) - throws DeviceManagementException { - return true; - } - - public boolean isClaimable(DeviceIdentifier deviceIdentifier) throws DeviceManagementException { - return false; - } - - @Override - public boolean setStatus(DeviceIdentifier deviceId, String currentOwner, - EnrolmentInfo.Status status) throws DeviceManagementException { - return false; - } - - @Override - public License getLicense(String s) throws LicenseManagementException { - return null; - } - - @Override - public void addLicense(License license) throws LicenseManagementException { - - } - - @Override - public boolean requireDeviceAuthorization() { - return false; - } - - @Override - public boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device) throws DeviceManagementException { - boolean status; - IotDevice iotDevice = IotDeviceManagementUtil.convertToIotDevice(device); - try { - if (log.isDebugEnabled()) { - log.debug( - "updating the details of Camera device : " + deviceIdentifier); - } - CameraDAO.beginTransaction(); - status = iotDeviceManagementDAOFactory.getIotDeviceDAO() - .updateIotDevice(iotDevice); - CameraDAO.commitTransaction(); - } catch (IotDeviceManagementDAOException e) { - try { - CameraDAO.rollbackTransaction(); - } catch (IotDeviceManagementDAOException iotDAOEx) { - String msg = "Error occurred while roll back the update device info transaction :" + device.toString(); - log.warn(msg, iotDAOEx); - } - String msg = - "Error while updating the Camera device : " + deviceIdentifier; - log.error(msg, e); - throw new DeviceManagementException(msg, e); - } - return status; - } - - @Override - public List getAllDevices() throws DeviceManagementException { - List devices = null; - try { - if (log.isDebugEnabled()) { - log.debug("Fetching the details of all Camera devices"); - } - List iotDevices = - iotDeviceManagementDAOFactory.getIotDeviceDAO().getAllIotDevices(); - if (iotDevices != null) { - devices = new ArrayList(); - for (IotDevice iotDevice : iotDevices) { - devices.add(IotDeviceManagementUtil.convertToDevice(iotDevice)); - } - } - } catch (IotDeviceManagementDAOException e) { - String msg = "Error while fetching all Camera devices."; - log.error(msg, e); - throw new DeviceManagementException(msg, e); - } - return devices; - } - -} \ No newline at end of file diff --git a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/impl/CameraManagerService.java b/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/impl/CameraManagerService.java deleted file mode 100644 index a6241b940..000000000 --- a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/impl/CameraManagerService.java +++ /dev/null @@ -1,112 +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.camera.plugin.impl; - -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.DeviceManager; -import org.wso2.carbon.device.mgt.common.app.mgt.Application; -import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException; -import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager; -import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; -import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; -import org.wso2.carbon.device.mgt.iot.camera.plugin.constants.CameraConstants; - -import java.util.List; - -public class CameraManagerService implements DeviceManagementService{ - private DeviceManager deviceManager; - @Override - public String getType() { - return CameraConstants.DEVICE_TYPE; - } - - - @Override - public String getProviderTenantDomain() { - return "carbon.super"; - } - - @Override - public boolean isSharedWithAllTenants() { - return true; - } - - @Override - public String[] getSharedTenantsDomain() { - return new String[0]; - } - - @Override - public void init() throws DeviceManagementException { - this.deviceManager=new CameraManager(); - } - - @Override - public DeviceManager getDeviceManager() { - return deviceManager; - } - - @Override - public ApplicationManager getApplicationManager() { - return null; - } - - @Override - public void notifyOperationToDevices(Operation operation, List deviceIds) - throws DeviceManagementException { - - } - - @Override - public Application[] getApplications(String domain, int pageNumber, int size) - throws ApplicationManagementException { - return new Application[0]; - } - - @Override - public void updateApplicationStatus(DeviceIdentifier deviceId, Application application, - String status) throws ApplicationManagementException { - - } - - @Override - public String getApplicationStatus(DeviceIdentifier deviceId, Application application) - throws ApplicationManagementException { - return null; - } - - @Override - public void installApplicationForDevices(Operation operation, List deviceIdentifiers) - throws ApplicationManagementException { - - } - - @Override - public void installApplicationForUsers(Operation operation, List userNameList) - throws ApplicationManagementException { - - } - - @Override - public void installApplicationForUserRoles(Operation operation, List userRoleList) - throws ApplicationManagementException { - - } -} diff --git a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/impl/dao/CameraDAO.java b/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/impl/dao/CameraDAO.java deleted file mode 100644 index 35571d851..000000000 --- a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/impl/dao/CameraDAO.java +++ /dev/null @@ -1,121 +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.camera.plugin.impl.dao; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.iot.camera.plugin.constants.CameraConstants; -import org.wso2.carbon.device.mgt.iot.camera.plugin.impl.dao.impl.CameraDeviceDAOImpl; -import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceDAO; -import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceManagementDAOException; -import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceManagementDAOFactory; -import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceManagementDAOFactoryInterface; - -import javax.sql.DataSource; -import java.sql.Connection; -import java.sql.SQLException; - -public class CameraDAO extends IotDeviceManagementDAOFactory implements IotDeviceManagementDAOFactoryInterface { - - private static final Log log = LogFactory.getLog(CameraDAO.class); - static DataSource dataSource; - private static ThreadLocal currentConnection = new ThreadLocal(); - - public CameraDAO() { - initFireAlarmDAO(); - } - - public static void initFireAlarmDAO() { - dataSource = getDataSourceMap().get(CameraConstants.DEVICE_TYPE); - } - - @Override public IotDeviceDAO getIotDeviceDAO() { - return new CameraDeviceDAOImpl(); - } - - public static void beginTransaction() throws IotDeviceManagementDAOException { - try { - Connection conn = dataSource.getConnection(); - conn.setAutoCommit(false); - currentConnection.set(conn); - } catch (SQLException e) { - throw new IotDeviceManagementDAOException("Error occurred while retrieving datasource connection", e); - } - } - - public static Connection getConnection() throws IotDeviceManagementDAOException { - if (currentConnection.get() == null) { - try { - currentConnection.set(dataSource.getConnection()); - } catch (SQLException e) { - throw new IotDeviceManagementDAOException("Error occurred while retrieving data source connection", e); - } - } - return currentConnection.get(); - } - - public static void commitTransaction() throws IotDeviceManagementDAOException { - try { - Connection conn = currentConnection.get(); - if (conn != null) { - conn.commit(); - } else { - if (log.isDebugEnabled()) { - log.debug("Datasource connection associated with the current thread is null, hence commit " - + "has not been attempted"); - } - } - } catch (SQLException e) { - throw new IotDeviceManagementDAOException("Error occurred while committing the transaction", e); - } finally { - closeConnection(); - } - } - - public static void closeConnection() throws IotDeviceManagementDAOException { - - Connection con = currentConnection.get(); - if (con != null) { - try { - con.close(); - } catch (SQLException e) { - log.error("Error occurred while close the connection"); - } - } - currentConnection.remove(); - } - - public static void rollbackTransaction() throws IotDeviceManagementDAOException { - try { - Connection conn = currentConnection.get(); - if (conn != null) { - conn.rollback(); - } else { - if (log.isDebugEnabled()) { - log.debug("Datasource connection associated with the current thread is null, hence rollback " - + "has not been attempted"); - } - } - } catch (SQLException e) { - throw new IotDeviceManagementDAOException("Error occurred while rollback the transaction", e); - } finally { - closeConnection(); - } - } -} \ No newline at end of file diff --git a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/impl/dao/impl/CameraDeviceDAOImpl.java b/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/impl/dao/impl/CameraDeviceDAOImpl.java deleted file mode 100644 index 59e68335b..000000000 --- a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/impl/dao/impl/CameraDeviceDAOImpl.java +++ /dev/null @@ -1,237 +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.camera.plugin.impl.dao.impl; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.iot.camera.plugin.constants.CameraConstants; -import org.wso2.carbon.device.mgt.iot.camera.plugin.impl.dao.CameraDAO; -import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceDAO; -import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceManagementDAOException; -import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.util.IotDeviceManagementDAOUtil; -import org.wso2.carbon.device.mgt.iot.util.iotdevice.dto.IotDevice; - -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Implements IotDeviceDAO for camera Devices. - */ -public class CameraDeviceDAOImpl implements IotDeviceDAO{ - - - private static final Log log = LogFactory.getLog(CameraDeviceDAOImpl.class); - - @Override - public IotDevice getIotDevice(String iotDeviceId) - throws IotDeviceManagementDAOException { - Connection conn = null; - PreparedStatement stmt = null; - IotDevice iotDevice = null; - ResultSet resultSet = null; - try { - conn = CameraDAO.getConnection(); - String selectDBQuery = - "SELECT CAMERA_DEVICE_ID, DEVICE_NAME" + - " FROM CAMERA_DEVICE WHERE CAMERA_DEVICE_ID = ?"; - stmt = conn.prepareStatement(selectDBQuery); - stmt.setString(1, iotDeviceId); - resultSet = stmt.executeQuery(); - - if (resultSet.next()) { - iotDevice = new IotDevice(); - iotDevice.setIotDeviceName(resultSet.getString( - CameraConstants.DEVICE_PLUGIN_DEVICE_NAME)); - Map propertyMap = new HashMap(); - - - - iotDevice.setDeviceProperties(propertyMap); - - if (log.isDebugEnabled()) { - log.debug("Camera device " + iotDeviceId + " data has been fetched from " + - "Camera database."); - } - } - } catch (SQLException e) { - String msg = "Error occurred while fetching Camera device : '" + iotDeviceId + "'"; - log.error(msg, e); - throw new IotDeviceManagementDAOException(msg, e); - } finally { - IotDeviceManagementDAOUtil.cleanupResources(stmt, resultSet); - CameraDAO.closeConnection(); - } - - return iotDevice; - } - - @Override - public boolean addIotDevice(IotDevice iotDevice) - throws IotDeviceManagementDAOException { - boolean status = false; - Connection conn = null; - PreparedStatement stmt = null; - try { - conn = CameraDAO.getConnection(); - String createDBQuery = - "INSERT INTO CAMERA_DEVICE(CAMERA_DEVICE_ID, DEVICE_NAME) VALUES (?, ?)"; - - stmt = conn.prepareStatement(createDBQuery); - stmt.setString(1, iotDevice.getIotDeviceId()); - stmt.setString(2,iotDevice.getIotDeviceName()); - if (iotDevice.getDeviceProperties() == null) { - iotDevice.setDeviceProperties(new HashMap()); - } - - - int rows = stmt.executeUpdate(); - if (rows > 0) { - status = true; - if (log.isDebugEnabled()) { - log.debug("Camera device " + iotDevice.getIotDeviceId() + " data has been" + - " added to the Camere database."); - } - } - } catch (SQLException e) { - String msg = "Error occurred while adding the Camera device '" + - iotDevice.getIotDeviceId() + "' to the Camera db."; - log.error(msg, e); - throw new IotDeviceManagementDAOException(msg, e); - } finally { - IotDeviceManagementDAOUtil.cleanupResources(stmt, null); - } - return status; - } - - @Override - public boolean updateIotDevice(IotDevice iotDevice) - throws IotDeviceManagementDAOException { - boolean status = false; - Connection conn = null; - PreparedStatement stmt = null; - try { - conn = CameraDAO.getConnection(); - String updateDBQuery = - "UPDATE CAMERA_DEVICE SET DEVICE_NAME = ? WHERE CAMERA_DEVICE_ID = ?"; - - stmt = conn.prepareStatement(updateDBQuery); - - if (iotDevice.getDeviceProperties() == null) { - iotDevice.setDeviceProperties(new HashMap()); - } - stmt.setString(1, iotDevice.getIotDeviceName()); - - stmt.setString(2, iotDevice.getIotDeviceId()); - int rows = stmt.executeUpdate(); - if (rows > 0) { - status = true; - if (log.isDebugEnabled()) { - log.debug("Camera device " + iotDevice.getIotDeviceId() + " data has been" + - " modified."); - } - } - } catch (SQLException e) { - String msg = "Error occurred while modifying the Camera device '" + - iotDevice.getIotDeviceId() + "' data."; - log.error(msg, e); - throw new IotDeviceManagementDAOException(msg, e); - } finally { - IotDeviceManagementDAOUtil.cleanupResources(stmt, null); - } - return status; - } - - @Override - public boolean deleteIotDevice(String iotDeviceId) - throws IotDeviceManagementDAOException { - boolean status = false; - Connection conn = null; - PreparedStatement stmt = null; - try { - conn = CameraDAO.getConnection(); - String deleteDBQuery = - "DELETE FROM CAMERA_DEVICE WHERE CAMERA_DEVICE_ID = ?"; - stmt = conn.prepareStatement(deleteDBQuery); - stmt.setString(1, iotDeviceId); - int rows = stmt.executeUpdate(); - if (rows > 0) { - status = true; - if (log.isDebugEnabled()) { - log.debug("Camera device " + iotDeviceId + " data has deleted from the Camera database."); - } - } - } catch (SQLException e) { - String msg = "Error occurred while deleting Camera device " + iotDeviceId; - log.error(msg, e); - throw new IotDeviceManagementDAOException(msg, e); - } finally { - IotDeviceManagementDAOUtil.cleanupResources(stmt, null); - } - return status; - } - - @Override - public List getAllIotDevices() - throws IotDeviceManagementDAOException { - - Connection conn = null; - PreparedStatement stmt = null; - ResultSet resultSet = null; - IotDevice iotDevice; - List iotDevices = new ArrayList(); - - try { - conn = CameraDAO.getConnection(); - String selectDBQuery = - "SELECT CAMERA_DEVICE_ID, DEVICE_NAME " + - "FROM CAMERA_DEVICE"; - stmt = conn.prepareStatement(selectDBQuery); - resultSet = stmt.executeQuery(); - while (resultSet.next()) { - iotDevice = new IotDevice(); - iotDevice.setIotDeviceId(resultSet.getString(CameraConstants.DEVICE_PLUGIN_DEVICE_ID)); - iotDevice.setIotDeviceName(resultSet.getString(CameraConstants.DEVICE_PLUGIN_DEVICE_NAME)); - - Map propertyMap = new HashMap(); - - iotDevice.setDeviceProperties(propertyMap); - iotDevices.add(iotDevice); - } - if (log.isDebugEnabled()) { - log.debug("All Camera device details have fetched from Firealarm database."); - } - return iotDevices; - } catch (SQLException e) { - String msg = "Error occurred while fetching all Camera device data'"; - log.error(msg, e); - throw new IotDeviceManagementDAOException(msg, e); - } finally { - IotDeviceManagementDAOUtil.cleanupResources(stmt, resultSet); - CameraDAO.closeConnection(); - } - - } - - } \ No newline at end of file diff --git a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/impl/util/VirtualFireAlarmUtils.java b/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/impl/util/VirtualFireAlarmUtils.java deleted file mode 100644 index b47c6d84a..000000000 --- a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/impl/util/VirtualFireAlarmUtils.java +++ /dev/null @@ -1,45 +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.camera.plugin.impl.util; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.util.Map; - -/** - * Contains utility methods used by FireAlarm plugin. - */ -public class VirtualFireAlarmUtils { - - private static Log log = LogFactory.getLog(VirtualFireAlarmUtils.class); - - public static String getDeviceProperty(Map deviceProperties, String property) { - - String deviceProperty = deviceProperties.get(property); - - if (deviceProperty == null) { - return ""; - } - - return deviceProperty; - } - - -} diff --git a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/internal/CameraManagementServiceComponent.java b/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/internal/CameraManagementServiceComponent.java deleted file mode 100644 index 3546dd987..000000000 --- a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/internal/CameraManagementServiceComponent.java +++ /dev/null @@ -1,98 +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.camera.plugin.internal; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceRegistration; -import org.osgi.service.component.ComponentContext; -import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; -import org.wso2.carbon.device.mgt.iot.camera.plugin.impl.CameraManagerService; -import org.wso2.carbon.device.mgt.iot.service.DeviceTypeService; - - -/** - * @scr.component name="org.wso2.carbon.device.mgt.iot.camera.plugin.internal - * .CameraManagementServiceComponent" - * immediate="true" - * @scr.reference name="org.wso2.carbon.device.mgt.iot.service.DeviceTypeServiceImpl" - * interface="org.wso2.carbon.device.mgt.iot.service.DeviceTypeService" - * cardinality="1..1" - * policy="dynamic" - * bind="setDeviceTypeService" - * unbind="unsetDeviceTypeService" - */ -public class CameraManagementServiceComponent { - - private static final Log log = LogFactory.getLog(CameraManagementServiceComponent.class); - private ServiceRegistration firealarmServiceRegRef; - - protected void activate(ComponentContext ctx) { - if (log.isDebugEnabled()) { - log.debug("Activating Camera Device Management Service Component"); - } - try { - BundleContext bundleContext = ctx.getBundleContext(); - firealarmServiceRegRef = - bundleContext.registerService(DeviceManagementService.class.getName(), - new CameraManagerService(), null); - - if (log.isDebugEnabled()) { - log.debug( - "Camera Device Management Service Component has been successfully activated"); - } - } catch (Throwable e) { - log.error( - "Error occurred while activating Camera Device Management Service Component", e); - } - } - - protected void deactivate(ComponentContext ctx) { - if (log.isDebugEnabled()) { - log.debug("De-activating Camera Device Management Service Component"); - } - try { - if (firealarmServiceRegRef != null) { - firealarmServiceRegRef.unregister(); - } - - if (log.isDebugEnabled()) { - log.debug( - "Camera Device Management Service Component has been successfully de-activated"); - } - } catch (Throwable e) { - log.error( - "Error occurred while de-activating Camera Device Management bundle", e); - } - } - - protected void setDeviceTypeService(DeviceTypeService deviceTypeService) { - /* This is to avoid this component getting initialized before the common registered */ - if (log.isDebugEnabled()) { - log.debug("Data source service set to mobile service component"); - } - } - - protected void unsetDeviceTypeService(DeviceTypeService deviceTypeService) { - //do nothing - } - - -} diff --git a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.ui/pom.xml b/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.ui/pom.xml deleted file mode 100644 index 89bc215a2..000000000 --- a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.ui/pom.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - camera-plugin - org.wso2.carbon.devicemgt-plugins - 2.1.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.device.mgt.iot.camera.ui - WSO2 Carbon - IoT Server Camera UI - pom - - - - - maven-assembly-plugin - 2.5.5 - - ${project.artifactId}-${carbon.device.mgt.version} - false - - src/assembly/src.xml - - - - - create-archive - package - - single - - - - - - - - \ No newline at end of file diff --git a/components/iot-plugins/camera-plugin/pom.xml b/components/iot-plugins/camera-plugin/pom.xml deleted file mode 100644 index ebeed88cc..000000000 --- a/components/iot-plugins/camera-plugin/pom.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - org.wso2.carbon.devicemgt-plugins - iot-plugins - 2.1.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.devicemgt-plugins - camera-plugin - pom - WSO2 Carbon - Arduino Plugin - http://wso2.org - - - org.wso2.carbon.device.mgt.iot.camera.controller.service.impl - org.wso2.carbon.device.mgt.iot.camera.manager.service.impl - org.wso2.carbon.device.mgt.iot.camera.plugin.impl - org.wso2.carbon.device.mgt.iot.camera.ui - - - - - - - org.apache.felix - maven-scr-plugin - 1.7.2 - - - generate-scr-scrdescriptor - - scr - - - - - - - - - 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 58841062b..e1f8431bc 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 @@ -22,7 +22,10 @@ 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.*; +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.configuration.mgt.TenantConfiguration; import org.wso2.carbon.device.mgt.common.license.mgt.License; import org.wso2.carbon.device.mgt.core.dto.DeviceType; @@ -33,7 +36,17 @@ import org.wso2.carbon.device.mgt.iot.sensormgt.SensorRecord; import javax.jws.WebService; import javax.servlet.http.HttpServletResponse; -import javax.ws.rs.*; +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 javax.ws.rs.core.Response; import java.util.ArrayList; @@ -97,22 +110,6 @@ import java.util.List; } } - @Path("/device/user/{username}/ungrouped") - @GET - @Consumes("application/json") - @Produces("application/json") - public Device[] getUnGroupedDevices(@PathParam("username") String username){ - try{ - List devices = this.getServiceProvider().getUnGroupedDevices(username); - return this.getActiveDevices(devices); - } catch (DeviceManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return null; - } finally { - this.endTenantFlow(); - } - } - @Path("/device/user/{username}/all/count") @GET @Consumes("application/json") @@ -205,66 +202,6 @@ import java.util.List; } } - @Path("/device/enrollment/invitation") - @POST - @Consumes("application/json") - @Produces("application/json") - public void sendEnrolmentInvitation(@FormParam("messageBody") String messageBody, - @FormParam("mailTo") String[] mailTo, @FormParam("ccList") String[] ccList, - @FormParam("bccList") String[] bccList, @FormParam("subject") String subject, - @FormParam("firstName") String firstName, @FormParam("enrolmentUrl") String enrolmentUrl, - @FormParam("title") String title, @FormParam("password") String password, - @FormParam("userName") String userName){ - EmailMessageProperties config = new EmailMessageProperties(); - config.setMessageBody(messageBody); - config.setMailTo(mailTo); - config.setCcList(ccList); - config.setBccList(bccList); - config.setSubject(subject); - config.setFirstName(firstName); - config.setEnrolmentUrl(enrolmentUrl); - config.setTitle(title); - config.setUserName(userName); - config.setPassword(password); - try { - this.getServiceProvider().sendEnrolmentInvitation(config); - } catch (DeviceManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - } finally { - this.endTenantFlow(); - } - } - - @Path("/device/registration/invitation") - @POST - @Consumes("application/json") - @Produces("application/json") - public void sendRegistrationEmail(@FormParam("messageBody") String messageBody, - @FormParam("mailTo") String[] mailTo, @FormParam("ccList") String[] ccList, - @FormParam("bccList") String[] bccList, @FormParam("subject") String subject, - @FormParam("firstName") String firstName, @FormParam("enrolmentUrl") String enrolmentUrl, - @FormParam("title") String title, @FormParam("password") String password, - @FormParam("userName") String userName){ - EmailMessageProperties config = new EmailMessageProperties(); - config.setMessageBody(messageBody); - config.setMailTo(mailTo); - config.setCcList(ccList); - config.setBccList(bccList); - config.setSubject(subject); - config.setFirstName(firstName); - config.setEnrolmentUrl(enrolmentUrl); - config.setTitle(title); - config.setUserName(userName); - config.setPassword(password); - try { - this.getServiceProvider().sendRegistrationEmail(config); - } catch (DeviceManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - } finally { - this.endTenantFlow(); - } - } - @Path("/device/type/{type}/config") @GET @Consumes("application/json") @@ -394,10 +331,12 @@ import java.util.List; @Produces("application/json") boolean modifyEnrollment(@PathParam("type") String type, @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){ + @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); @@ -412,7 +351,6 @@ import java.util.List; device.setDeviceIdentifier(identifier); device.setName(name); device.setDescription(description); - device.setGroupId(groupId); device.setEnrolmentInfo(enrolmentInfo); try { return this.getServiceProvider().modifyEnrollment(device); @@ -430,10 +368,12 @@ import java.util.List; @Produces("application/json") boolean enrollDevice(@FormParam("type") String type, @FormParam("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){ + @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); @@ -448,7 +388,6 @@ import java.util.List; device.setDeviceIdentifier(identifier); device.setName(name); device.setDescription(description); - device.setGroupId(groupId); device.setEnrolmentInfo(enrolmentInfo); try { return this.getServiceProvider().enrollDevice(device); 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 496410386..4e109c9ca 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 @@ -27,10 +27,10 @@ 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.group.common.DeviceGroup; -import org.wso2.carbon.device.mgt.group.common.GroupManagementException; -import org.wso2.carbon.device.mgt.group.common.GroupUser; -import org.wso2.carbon.device.mgt.group.core.providers.GroupManagementServiceProvider; +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.ResponsePayload; import javax.jws.WebService; @@ -73,7 +73,7 @@ public class GroupManagerService { private HttpServletResponse response; private PrivilegedCarbonContext ctx; - private GroupManagementServiceProvider getServiceProvider() { + private GroupManagementProviderService getServiceProvider() { String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain(); String username = CarbonContext.getThreadLocalCarbonContext().getUsername(); PrivilegedCarbonContext.startTenantFlow(); @@ -82,7 +82,7 @@ public class GroupManagerService { if (log.isDebugEnabled()) { log.debug("Getting thread local carbon context for tenant domain: " + tenantDomain); } - return (GroupManagementServiceProvider) ctx.getOSGiService(GroupManagementServiceProvider.class, null); + return (GroupManagementProviderService) ctx.getOSGiService(GroupManagementProviderService.class, null); } private void endTenantFlow() { @@ -108,7 +108,7 @@ public class GroupManagerService { group.setDateOfLastUpdate(new Date().getTime()); boolean isAdded = false; try { - GroupManagementServiceProvider groupManagementService = this.getServiceProvider(); + GroupManagementProviderService groupManagementService = this.getServiceProvider(); int groupId = groupManagementService.createGroup(group, DEFAULT_ADMIN_ROLE, DEFAULT_ADMIN_PERMISSIONS); if (groupId == -2) { ResponsePayload responsePayload = new ResponsePayload(); @@ -151,7 +151,7 @@ public class GroupManagerService { return false; } try { - GroupManagementServiceProvider groupManagementService = this.getServiceProvider(); + GroupManagementProviderService groupManagementService = this.getServiceProvider(); DeviceGroup group = groupManagementService.getGroup(groupId); group.setName(name); group.setDescription(description); @@ -219,7 +219,7 @@ public class GroupManagerService { @FormParam("username") String username) { DeviceGroup[] deviceGroups = null; try { - List groups = this.getServiceProvider().findGroups(groupName, username); + List groups = this.getServiceProvider().findInGroups(groupName, username); deviceGroups = new DeviceGroup[groups.size()]; response.setStatus(Response.Status.OK.getStatusCode()); groups.toArray(deviceGroups); @@ -240,7 +240,7 @@ public class GroupManagerService { @QueryParam("permission") String permission) { DeviceGroup[] deviceGroups = null; try { - GroupManagementServiceProvider groupManagementService = this.getServiceProvider(); + GroupManagementProviderService groupManagementService = this.getServiceProvider(); List groups; if (permission != null) { groups = groupManagementService.getGroups(username, permission); 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/StatsManagerService.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/StatsManagerService.java deleted file mode 100644 index 4c696654a..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/StatsManagerService.java +++ /dev/null @@ -1,103 +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; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.analytics.common.AnalyticsDataRecord; -import org.wso2.carbon.device.mgt.analytics.exception.DeviceManagementAnalyticsException; -import org.wso2.carbon.device.mgt.analytics.service.DeviceAnalyticsService; -import javax.jws.WebService; -import javax.servlet.http.HttpServletResponse; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -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.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -@WebService public class StatsManagerService { - - private static Log log = LogFactory.getLog(StatsManagerService.class); - - @Context //injected response proxy supporting multiple thread - private HttpServletResponse response; - //TODO THIS NEEDS TO BE REMOVED. - @Path("/stats/device/type/{type}/identifier/{identifier}") - @GET - @Consumes("application/json") - @Produces("application/json") - public DeviceUsageDTO[] getDeviceStats(@PathParam("type") String type, @PathParam("identifier") String identifier, - @QueryParam("table") String table, @QueryParam("column") String column, @QueryParam("username") String user, - @QueryParam("from") long from, @QueryParam("to") long to) { - - String fromDate = String.valueOf(from); - String toDate = String.valueOf(to); - - List deviceUsageDTOs = new ArrayList<>(); - PrivilegedCarbonContext.startTenantFlow(); - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - ctx.setTenantDomain("carbon.super", true); - DeviceAnalyticsService deviceAnalyticsService = (DeviceAnalyticsService) ctx - .getOSGiService(DeviceAnalyticsService.class, null); - String query = "owner:" + user + " AND deviceId:" + identifier + " AND deviceType:" + type + - " AND time : [" + fromDate + " TO " + toDate + "]"; - try { - List records = deviceAnalyticsService.getAllEventsForDevice(table, query); - - Collections.sort(records, new Comparator() { - @Override - public int compare(AnalyticsDataRecord o1, AnalyticsDataRecord o2) { - long t1 = (Long) o1.getValue("time"); - long t2 = (Long) o2.getValue("time"); - if (t1 < t2) { - return -1; - } else if (t1 > t2) { - return 1; - } else { - return 0; - } - } - }); - - for (AnalyticsDataRecord record : records) { - DeviceUsageDTO deviceUsageDTO = new DeviceUsageDTO(); - deviceUsageDTO.setTime("" + (long)record.getValue("time")); - deviceUsageDTO.setValue("" + (float) record.getValue(column.toLowerCase())); - deviceUsageDTOs.add(deviceUsageDTO); - } - return deviceUsageDTOs.toArray(new DeviceUsageDTO[deviceUsageDTOs.size()]); - } catch (DeviceManagementAnalyticsException e) { - String errorMsg= "Error on retrieving stats on table " + table + " with query " + query; - log.error(errorMsg); - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return deviceUsageDTOs.toArray(new DeviceUsageDTO[deviceUsageDTOs.size()]); - } finally { - PrivilegedCarbonContext.endTenantFlow(); - } - } - -} diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.api/src/main/webapp/WEB-INF/cxf-servlet.xml index 1112d721e..739f0bee9 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.api/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.api/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -45,16 +45,6 @@ - - - - - - - - - - - - - - - - - - - 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 cfdc32dbc..27ad2fed1 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 @@ -66,25 +66,20 @@ javax.xml.namespace;resolution:=optional, javax.xml.validation;resolution:=optional, org.apache.commons.codec.binary, - org.apache.commons.collections.map, org.apache.http.*, org.apache.commons.io.*, org.apache.commons.logging.*, org.json;version="${commons-json.version}", org.wso2.carbon.base.*, org.wso2.carbon.databridge.*, - org.wso2.carbon.user.api, - org.wso2.carbon.user.core.service, org.osgi.framework, org.osgi.service.component, 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, javax.crypto, + javax.ws.rs.core, + javax.xml, org.apache.tomcat.util.codec.binary, org.w3c.dom;resolution:=optional, org.wso2.carbon.core;version="${carbon.kernel.version.range}", @@ -92,7 +87,6 @@ org.wso2.carbon.device.mgt.common.*, org.wso2.carbon.device.mgt.core.*, org.wso2.carbon.context.*;version="${carbon.kernel.version.range}", - org.wso2.carbon.ndatasource.core;version="${carbon.kernel.version.range}", org.eclipse.paho.client.mqttv3.*;version="${eclipse.paho.version}" @@ -144,6 +138,12 @@ org.wso2.carbon.devicemgt org.wso2.carbon.device.mgt.core + + + org.apache.httpcomponents.wso2 + httpclient + + org.wso2.carbon diff --git a/components/iot-plugins/pom.xml b/components/iot-plugins/pom.xml index 0020ee7f1..45e660e7c 100644 --- a/components/iot-plugins/pom.xml +++ b/components/iot-plugins/pom.xml @@ -27,20 +27,18 @@ 4.0.0 - org.wso2.carbon.devicemgt-plugins iot-plugins pom WSO2 Carbon - IoT Plugins http://wso2.org - androidsense-plugin - arduino-plugin - camera-plugin - digital-display-plugin - drone-analyzer-plugin - raspberrypi-plugin - virtual-fire-alarm-plugin + + + + + + iot-base-plugin diff --git a/pom.xml b/pom.xml index 318c7e3df..c31949282 100644 --- a/pom.xml +++ b/pom.xml @@ -38,7 +38,7 @@ components/mobile-plugins - + components/iot-plugins features/mobile-plugins-feature @@ -1030,6 +1030,10 @@ + + 1.7 + 1.7 + 4.4.3 [4.4.0, 4.5.0)