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 84221478a..2985b3292 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 @@ -67,7 +67,8 @@ org.wso2.carbon.core, org.wso2.carbon.core.util, org.wso2.carbon.event.output.adapter.core, - org.wso2.carbon.event.output.adapter.core.exception + org.wso2.carbon.event.output.adapter.core.exception, + org.wso2.carbon.ndatasource.core !org.wso2.carbon.device.mgt.iot.androidsense.plugin.internal, 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/AndroidSenseManager.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/AndroidSenseManager.java index f5bd7e61e..fff692b37 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/AndroidSenseManager.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/AndroidSenseManager.java @@ -25,7 +25,7 @@ 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.configuration.mgt.PlatformConfiguration; 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.androidsense.plugin.exception.AndroidSenseDeviceMgtPluginException; @@ -49,14 +49,14 @@ public class AndroidSenseManager implements DeviceManager { } @Override - public boolean saveConfiguration(TenantConfiguration tenantConfiguration) + public boolean saveConfiguration(PlatformConfiguration PlatformConfiguration) throws DeviceManagementException { //TODO implement this return false; } @Override - public TenantConfiguration getConfiguration() throws DeviceManagementException { + public PlatformConfiguration getConfiguration() throws DeviceManagementException { //TODO implement this return null; } 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/dao/AndroidSenseDAOUtil.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/dao/AndroidSenseDAOUtil.java index b879f24ae..c847e16c4 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/dao/AndroidSenseDAOUtil.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/dao/AndroidSenseDAOUtil.java @@ -43,7 +43,7 @@ public class AndroidSenseDAOUtil { Context ctx = new InitialContext(); dataSource = (DataSource) ctx.lookup(AndroidSenseConstants.DATA_SOURCE_NAME); } catch (NamingException e) { - log.error("Error while looking up the data source: " + AndroidSenseConstants.DATA_SOURCE_NAME); + log.error("Error while looking up the data source: " + AndroidSenseConstants.DATA_SOURCE_NAME, e); } } 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/util/AndroidSenseUtils.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/util/AndroidSenseUtils.java index cba547d56..bb6120f5e 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/util/AndroidSenseUtils.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/util/AndroidSenseUtils.java @@ -85,13 +85,12 @@ public class AndroidSenseUtils { try { Context ctx = new InitialContext(); DataSource dataSource = (DataSource) ctx.lookup(AndroidSenseConstants.DATA_SOURCE_NAME); - DeviceSchemaInitializer initializer = - new DeviceSchemaInitializer(dataSource); + DeviceSchemaInitializer initializer = new DeviceSchemaInitializer(dataSource); log.info("Initializing device management repository database schema"); initializer.createRegistryDatabase(); } catch (NamingException e) { - log.error("Error while looking up the data source: " + AndroidSenseConstants.DATA_SOURCE_NAME); + log.error("Error while looking up the data source: " + AndroidSenseConstants.DATA_SOURCE_NAME, e); } catch (Exception e) { throw new AndroidSenseDeviceMgtPluginException("Error occurred while initializing Iot Device " + "Management database schema", e); 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/util/DeviceSchemaInitializer.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/util/DeviceSchemaInitializer.java index eabc7f44b..7b02de7e8 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/util/DeviceSchemaInitializer.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/util/DeviceSchemaInitializer.java @@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.iot.androidsense.plugin.impl.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.iot.androidsense.plugin.constants.AndroidSenseConstants; import org.wso2.carbon.utils.CarbonUtils; import org.wso2.carbon.utils.dbcreator.DatabaseCreator; @@ -33,7 +34,8 @@ public class DeviceSchemaInitializer extends DatabaseCreator{ private static final Log log = LogFactory.getLog(DeviceSchemaInitializer.class); private static final String setupSQLScriptBaseLocation = CarbonUtils.getCarbonHome() + File.separator + "dbscripts" - + File.separator + "cdm" + File.separator + "plugins" + File.separator; + + File.separator + "cdm" + File.separator + "plugins" + File.separator + AndroidSenseConstants.DEVICE_TYPE + + File.separator; public DeviceSchemaInitializer(DataSource dataSource) { super(dataSource); 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/internal/AndroidSenseManagementServiceComponent.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/internal/AndroidSenseManagementServiceComponent.java index f287650ec..981b4e04b 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/internal/AndroidSenseManagementServiceComponent.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/internal/AndroidSenseManagementServiceComponent.java @@ -28,6 +28,7 @@ import org.wso2.carbon.device.mgt.iot.androidsense.plugin.impl.AndroidSenseManag import org.wso2.carbon.device.mgt.iot.androidsense.plugin.impl.util.AndroidSenseStartupListener; import org.wso2.carbon.device.mgt.iot.androidsense.plugin.impl.util.AndroidSenseUtils; import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterService; +import org.wso2.carbon.ndatasource.core.DataSourceService; /** * @scr.component name="org.wso2.carbon.device.mgt.iot.android.internal.AndroidSenseManagementServiceComponent" @@ -38,6 +39,12 @@ import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterService; * policy="dynamic" * bind="setOutputEventAdapterService" * unbind="unsetOutputEventAdapterService" + * @scr.reference name="org.wso2.carbon.ndatasource" + * interface="org.wso2.carbon.ndatasource.core.DataSourceService" + * cardinality="1..1" + * policy="dynamic" + * bind="setDataSourceService" + * unbind="unsetDataSourceService" */ public class AndroidSenseManagementServiceComponent { @@ -57,8 +64,7 @@ public class AndroidSenseManagementServiceComponent { String setupOption = System.getProperty("setup"); if (setupOption != null) { if (log.isDebugEnabled()) { - log.debug( - "-Dsetup is enabled. Iot Device management repository schema initialization is about " + + log.debug("-Dsetup is enabled. Iot Device management repository schema initialization is about " + "to begin"); } try { @@ -108,4 +114,16 @@ public class AndroidSenseManagementServiceComponent { protected void unsetOutputEventAdapterService(OutputEventAdapterService outputEventAdapterService) { AndroidSenseManagementDataHolder.getInstance().setOutputEventAdapterService(null); } + + protected void setDataSourceService(DataSourceService dataSourceService) { + /* This is to avoid mobile device management component getting initialized before the underlying datasources + are registered */ + if (log.isDebugEnabled()) { + log.debug("Data source service set to service component"); + } + } + + protected void unsetDataSourceService(DataSourceService dataSourceService) { + //do nothing + } } diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/css/styles.css b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/css/styles.css new file mode 100644 index 000000000..0c138185a --- /dev/null +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/css/styles.css @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2016, 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. + */ +.circle { + background: none repeat scroll 0 0 #191919; + border-radius: 50px; + height: 50px; + padding: 10px; + width: 50px; + color: #fff; +} + +.padding-top-double { + padding-top: 20px; +} + +.padding-double { + padding: 20px; +} + +.grey { + color: #333; +} + +hr { + display: block; + height: 1px; + border: 0; + border-top: 1px solid #7f7f7f; + margin: 1em 0; + padding: 0; + opacity: 0.2; +} + +.light-grey { + color: #7c7c7c; +} + +.uppercase { + text-transform: uppercase; +} + +.grey-bg { + background-color: #f6f4f4; +} + +.doc-link { + background: #11375B; + padding: 20px; + color: white; + margin-top: 0; +} + +.doc-link a { + color: white; +} \ No newline at end of file diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.hbs b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.hbs index a243a0302..8fb2ff97c 100644 --- a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.hbs +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.hbs @@ -272,61 +272,9 @@ - +{{#zone "topCss"}} + {{css "css/styles.css"}} +{{/zone}} {{#zone "bottomJs"}} {{js "/js/download.js"}} @@ -342,4 +290,4 @@ } {{js "/js/jquery.validate.js"}} -{{/zone}} +{{/zone}} \ No newline at end of file diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/pom.xml b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/pom.xml index 0c7f52a35..5b900b936 100644 --- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/pom.xml +++ b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.plugin/pom.xml @@ -69,7 +69,8 @@ org.wso2.carbon.device.mgt.common, org.wso2.carbon.device.mgt.iot.*, org.wso2.carbon.device.mgt.extensions.feature.mgt.*, - org.wso2.carbon.utils.* + org.wso2.carbon.utils.*, + org.wso2.carbon.ndatasource.core diff --git a/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 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 index 35dbdb4ea..c3d80d8d6 100644 --- a/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 +++ 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 @@ -27,7 +27,7 @@ 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.configuration.mgt.PlatformConfiguration; 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.arduino.plugin.exception.ArduinoDeviceMgtPluginException; @@ -51,14 +51,14 @@ public class ArduinoManager implements DeviceManager { } @Override - public boolean saveConfiguration(TenantConfiguration tenantConfiguration) + public boolean saveConfiguration(PlatformConfiguration PlatformConfiguration) throws DeviceManagementException { //TODO implement this return false; } @Override - public TenantConfiguration getConfiguration() throws DeviceManagementException { + public PlatformConfiguration getConfiguration() throws DeviceManagementException { //TODO implement this return null; } diff --git a/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/ArduinoDAOUtil.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/ArduinoDAOUtil.java index 6e8895f4a..4a7cb00ec 100644 --- a/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/ArduinoDAOUtil.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/ArduinoDAOUtil.java @@ -45,7 +45,7 @@ public class ArduinoDAOUtil { Context ctx = new InitialContext(); dataSource = (DataSource) ctx.lookup(ArduinoConstants.DATA_SOURCE_NAME); } catch (NamingException e) { - log.error("Error while looking up the data source: " + ArduinoConstants.DATA_SOURCE_NAME); + log.error("Error while looking up the data source: " + ArduinoConstants.DATA_SOURCE_NAME, e); } } diff --git a/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 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 index f5e364274..1bc62d74d 100644 --- a/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 +++ 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 @@ -97,13 +97,12 @@ public class ArduinoUtils { try { Context ctx = new InitialContext(); DataSource dataSource = (DataSource) ctx.lookup(ArduinoConstants.DATA_SOURCE_NAME); - DeviceSchemaInitializer initializer = - new DeviceSchemaInitializer(dataSource); + DeviceSchemaInitializer initializer = new DeviceSchemaInitializer(dataSource); log.info("Initializing device management repository database schema"); initializer.createRegistryDatabase(); } catch (NamingException e) { - log.error("Error while looking up the data source: " + ArduinoConstants.DATA_SOURCE_NAME); + log.error("Error while looking up the data source: " + ArduinoConstants.DATA_SOURCE_NAME, e); } catch (Exception e) { throw new ArduinoDeviceMgtPluginException("Error occurred while initializing Iot Device " + "Management database schema", e); diff --git a/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 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 index 3567e776f..eff15d20f 100644 --- a/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 +++ 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 @@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.iot.arduino.plugin.impl.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.iot.arduino.plugin.constants.ArduinoConstants; import org.wso2.carbon.utils.CarbonUtils; import org.wso2.carbon.utils.dbcreator.DatabaseCreator; @@ -33,7 +34,8 @@ public class DeviceSchemaInitializer extends DatabaseCreator{ private static final Log log = LogFactory.getLog(DeviceSchemaInitializer.class); private static final String setupSQLScriptBaseLocation = CarbonUtils.getCarbonHome() + File.separator + "dbscripts" - + File.separator + "cdm" + File.separator + "plugins" + File.separator; + + File.separator + "cdm" + File.separator + "plugins" + File.separator + ArduinoConstants.DEVICE_TYPE + + File.separator; public DeviceSchemaInitializer(DataSource dataSource) { super(dataSource); diff --git a/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 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 index fc5fe40a3..719378575 100644 --- a/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 +++ 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 @@ -27,9 +27,17 @@ import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; import org.wso2.carbon.device.mgt.iot.arduino.plugin.exception.ArduinoDeviceMgtPluginException; import org.wso2.carbon.device.mgt.iot.arduino.plugin.impl.ArduinoManagerService; import org.wso2.carbon.device.mgt.iot.arduino.plugin.impl.util.ArduinoUtils; +import org.wso2.carbon.ndatasource.core.DataSourceService; + /** * @scr.component name="org.wso2.carbon.device.mgt.iot.arduino.internal.ArduinoManagementServiceComponent" * immediate="true" + * @scr.reference name="org.wso2.carbon.ndatasource" + * interface="org.wso2.carbon.ndatasource.core.DataSourceService" + * cardinality="1..1" + * policy="dynamic" + * bind="setDataSourceService" + * unbind="unsetDataSourceService" */ public class ArduinoManagementServiceComponent { @@ -83,4 +91,16 @@ public class ArduinoManagementServiceComponent { log.error("Error occurred while de-activating Arduino Device Management bundle", e); } } + + protected void setDataSourceService(DataSourceService dataSourceService) { + /* This is to avoid mobile device management component getting initialized before the underlying datasources + are registered */ + if (log.isDebugEnabled()) { + log.debug("Data source service set to service component"); + } + } + + protected void unsetDataSourceService(DataSourceService dataSourceService) { + //do nothing + } } diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/public/css/styles.css b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/public/css/styles.css new file mode 100644 index 000000000..984c46c7f --- /dev/null +++ b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/public/css/styles.css @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2016, 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. + */ +.circle { + background: none repeat scroll 0 0 #191919; + border-radius: 50px; + height: 50px; + padding: 10px; + width: 50px; + color: #fff; +} +.padding-top-double { + padding-top: 20px; +} +.padding-double { + padding: 20px; +} +.grey { + color: #333; +} +hr { + display: block; + height: 1px; + border: 0; + border-top: 1px solid #7f7f7f; + margin: 1em 0; + padding: 0; + opacity: 0.2; +} +.light-grey { + color: #7c7c7c; +} +.uppercase { + text-transform: uppercase; +} +.grey-bg { + background-color: #f6f4f4; +} +.doc-link { + background: #11375B; + padding: 20px; + color: white; +} +.doc-link a { + color: white; +} diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/type-view.hbs b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/type-view.hbs index 9280cbfb7..921db639f 100644 --- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/type-view.hbs +++ b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/type-view.hbs @@ -289,51 +289,7 @@ {{#zone "topCss"}} - + {{css "css/styles.css"}} {{/zone}} {{#zone "bottomJs"}} diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/pom.xml b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/pom.xml index d9d03a682..38cfc40df 100644 --- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/pom.xml +++ b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/pom.xml @@ -76,7 +76,8 @@ org.wso2.carbon.core, org.wso2.carbon.core.util, org.wso2.carbon.event.output.adapter.core, - org.wso2.carbon.event.output.adapter.core.exception + org.wso2.carbon.event.output.adapter.core.exception, + org.wso2.carbon.ndatasource.core !org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.internal, diff --git a/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 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 index eec07bf7c..00370b8bf 100644 --- a/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 +++ 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 @@ -26,7 +26,7 @@ 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.configuration.mgt.PlatformConfiguration; 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.raspberrypi.plugin.exception.RaspberrypiDeviceMgtPluginException; @@ -49,13 +49,13 @@ public class RaspberrypiManager implements DeviceManager { } @Override - public boolean saveConfiguration(TenantConfiguration tenantConfiguration) + public boolean saveConfiguration(PlatformConfiguration tenantConfiguration) throws DeviceManagementException { return false; } @Override - public TenantConfiguration getConfiguration() throws DeviceManagementException { + public PlatformConfiguration getConfiguration() throws DeviceManagementException { return null; } diff --git a/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/RaspberrypiDAOUtil.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/RaspberrypiDAOUtil.java index 3eb68ee79..fab06b33b 100644 --- a/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/RaspberrypiDAOUtil.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/RaspberrypiDAOUtil.java @@ -49,7 +49,7 @@ public class RaspberrypiDAOUtil { Context ctx = new InitialContext(); dataSource = (DataSource) ctx.lookup(RaspberrypiConstants.DATA_SOURCE_NAME); } catch (NamingException e) { - log.error("Error while looking up the data source: " + RaspberrypiConstants.DATA_SOURCE_NAME); + log.error("Error while looking up the data source: " + RaspberrypiConstants.DATA_SOURCE_NAME, e); } } diff --git a/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 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 index 7919c4d76..ba790567a 100644 --- a/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 +++ 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 @@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.constants.RaspberrypiConstants; import org.wso2.carbon.utils.CarbonUtils; import org.wso2.carbon.utils.dbcreator.DatabaseCreator; @@ -33,7 +34,8 @@ public class DeviceSchemaInitializer extends DatabaseCreator{ private static final Log log = LogFactory.getLog(DeviceSchemaInitializer.class); private static final String setupSQLScriptBaseLocation = CarbonUtils.getCarbonHome() + File.separator + "dbscripts" - + File.separator + "cdm" + File.separator + "plugins" + File.separator; + + File.separator + "cdm" + File.separator + "plugins" + File.separator + RaspberrypiConstants.DEVICE_TYPE + + File.separator; public DeviceSchemaInitializer(DataSource dataSource) { super(dataSource); diff --git a/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 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 index 791f1db03..9f98b19f8 100644 --- a/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 +++ 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 @@ -87,12 +87,11 @@ public class RaspberrypiUtils { try { Context ctx = new InitialContext(); DataSource dataSource = (DataSource) ctx.lookup(RaspberrypiConstants.DATA_SOURCE_NAME); - DeviceSchemaInitializer initializer = - new DeviceSchemaInitializer(dataSource); + DeviceSchemaInitializer initializer = new DeviceSchemaInitializer(dataSource); log.info("Initializing device management repository database schema"); initializer.createRegistryDatabase(); } catch (NamingException e) { - log.error("Error while looking up the data source: " + RaspberrypiConstants.DATA_SOURCE_NAME); + log.error("Error while looking up the data source: " + RaspberrypiConstants.DATA_SOURCE_NAME, e); } catch (Exception e) { throw new RaspberrypiDeviceMgtPluginException("Error occurred while initializing Iot Device " + "Management database schema", e); diff --git a/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 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 index 5068ae3d3..a61b0624d 100644 --- a/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 +++ 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 @@ -30,6 +30,7 @@ import org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl.RaspberrypiManager import org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl.util.RaspberrypiStartupListener; import org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl.util.RaspberrypiUtils; import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterService; +import org.wso2.carbon.ndatasource.core.DataSourceService; /** * @scr.component name="org.wso2.carbon.device.mgt.iot.raspberrypi.internal.RaspberrypiManagementServiceComponent" @@ -40,6 +41,12 @@ import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterService; * policy="dynamic" * bind="setOutputEventAdapterService" * unbind="unsetOutputEventAdapterService" + * @scr.reference name="org.wso2.carbon.ndatasource" + * interface="org.wso2.carbon.ndatasource.core.DataSourceService" + * cardinality="1..1" + * policy="dynamic" + * bind="setDataSourceService" + * unbind="unsetDataSourceService" */ public class RaspberrypiManagementServiceComponent { @@ -110,4 +117,16 @@ public class RaspberrypiManagementServiceComponent { RaspberrypiManagementDataHolder.getInstance().setOutputEventAdapterService(null); } + protected void setDataSourceService(DataSourceService dataSourceService) { + /* This is to avoid mobile device management component getting initialized before the underlying datasources + are registered */ + if (log.isDebugEnabled()) { + log.debug("Data source service set to service component"); + } + } + + protected void unsetDataSourceService(DataSourceService dataSourceService) { + //do nothing + } + } diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/css/styles.css b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/css/styles.css new file mode 100644 index 000000000..0c138185a --- /dev/null +++ b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/css/styles.css @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2016, 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. + */ +.circle { + background: none repeat scroll 0 0 #191919; + border-radius: 50px; + height: 50px; + padding: 10px; + width: 50px; + color: #fff; +} + +.padding-top-double { + padding-top: 20px; +} + +.padding-double { + padding: 20px; +} + +.grey { + color: #333; +} + +hr { + display: block; + height: 1px; + border: 0; + border-top: 1px solid #7f7f7f; + margin: 1em 0; + padding: 0; + opacity: 0.2; +} + +.light-grey { + color: #7c7c7c; +} + +.uppercase { + text-transform: uppercase; +} + +.grey-bg { + background-color: #f6f4f4; +} + +.doc-link { + background: #11375B; + padding: 20px; + color: white; + margin-top: 0; +} + +.doc-link a { + color: white; +} \ No newline at end of file diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/type-view.hbs b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/type-view.hbs index 68e842b42..52bc44c84 100644 --- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/type-view.hbs +++ b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/type-view.hbs @@ -278,61 +278,7 @@ {{#zone "topCss"}} - + {{css "css/styles.css"}} {{/zone}} {{#zone "bottomJs"}} diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/pom.xml b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/pom.xml index 07dec13f5..a76d313cc 100644 --- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/pom.xml +++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/pom.xml @@ -91,7 +91,7 @@ javax.xml.bind, javax.xml.bind.annotation, javax.xml.parsers, - org.w3c.dom + org.w3c.dom, !org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.internal, diff --git a/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 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 index 557376624..96617f47b 100644 --- a/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 +++ 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 @@ -26,7 +26,7 @@ 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.configuration.mgt.PlatformConfiguration; 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.virtualfirealarm.plugin.exception.VirtualFirealarmDeviceMgtPluginException; @@ -50,13 +50,13 @@ public class VirtualFireAlarmManager implements DeviceManager { } @Override - public boolean saveConfiguration(TenantConfiguration tenantConfiguration) + public boolean saveConfiguration(PlatformConfiguration PlatformConfiguration) throws DeviceManagementException { return false; } @Override - public TenantConfiguration getConfiguration() throws DeviceManagementException { + public PlatformConfiguration getConfiguration() throws DeviceManagementException { return null; } diff --git a/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/VirtualFireAlarmDAOUtil.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/VirtualFireAlarmDAOUtil.java index a3ec4f274..109cbe243 100644 --- a/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/VirtualFireAlarmDAOUtil.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/VirtualFireAlarmDAOUtil.java @@ -45,7 +45,7 @@ public class VirtualFireAlarmDAOUtil { Context ctx = new InitialContext(); dataSource = (DataSource) ctx.lookup(VirtualFireAlarmConstants.DATA_SOURCE_NAME); } catch (NamingException e) { - log.error("Error while looking up the data source: " + VirtualFireAlarmConstants.DATA_SOURCE_NAME); + log.error("Error while looking up the data source: " + VirtualFireAlarmConstants.DATA_SOURCE_NAME, e); } } diff --git a/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 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 index 450014502..a738386af 100644 --- a/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 +++ 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 @@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.constants.VirtualFireAlarmConstants; import org.wso2.carbon.utils.CarbonUtils; import org.wso2.carbon.utils.dbcreator.DatabaseCreator; @@ -33,7 +34,8 @@ public class DeviceSchemaInitializer extends DatabaseCreator{ private static final Log log = LogFactory.getLog(DeviceSchemaInitializer.class); private static final String setupSQLScriptBaseLocation = CarbonUtils.getCarbonHome() + File.separator + "dbscripts" - + File.separator + "cdm" + File.separator + "plugins" + File.separator; + + File.separator + "cdm" + File.separator + "plugins" + File.separator + + VirtualFireAlarmConstants.DEVICE_TYPE + File.separator; public DeviceSchemaInitializer(DataSource dataSource) { super(dataSource); diff --git a/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 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 index 16189c263..49bbe1982 100644 --- a/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 +++ 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 @@ -100,12 +100,11 @@ public class VirtualFireAlarmUtils { try { Context ctx = new InitialContext(); DataSource dataSource = (DataSource) ctx.lookup(VirtualFireAlarmConstants.DATA_SOURCE_NAME); - DeviceSchemaInitializer initializer = - new DeviceSchemaInitializer(dataSource); + DeviceSchemaInitializer initializer = new DeviceSchemaInitializer(dataSource); log.info("Initializing device management repository database schema"); initializer.createRegistryDatabase(); } catch (NamingException e) { - log.error("Error while looking up the data source: " + VirtualFireAlarmConstants.DATA_SOURCE_NAME); + log.error("Error while looking up the data source: " + VirtualFireAlarmConstants.DATA_SOURCE_NAME, e); } catch (Exception e) { throw new VirtualFirealarmDeviceMgtPluginException("Error occurred while initializing Iot Device " + "Management database schema", e); diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/public/css/styles.css b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/public/css/styles.css new file mode 100644 index 000000000..47250fc86 --- /dev/null +++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/public/css/styles.css @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2016, 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. + */ +.circle { + background: none repeat scroll 0 0 #191919; + border-radius: 50px; + height: 50px; + padding: 10px; + width: 50px; + color: #fff; +} + +.padding-top-double { + padding-top: 20px; +} + +.padding-double { + padding: 20px; +} + +.grey { + color: #333; +} + +hr { + display: block; + height: 1px; + border: 0; + border-top: 1px solid #7f7f7f; + margin: 1em 0; + padding: 0; + opacity: 0.2; +} + +.light-grey { + color: #7c7c7c; +} + +.uppercase { + text-transform: uppercase; +} + +.grey-bg { + background-color: #f6f4f4; +} + +.doc-link { + background: #11375B; + padding: 20px; + color: white; + margin-top: 0; +} + +.doc-link a { + color: white; +} diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/type-view.hbs b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/type-view.hbs index 81853ee5d..6a254dd5b 100644 --- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/type-view.hbs +++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/type-view.hbs @@ -250,65 +250,10 @@ {{#zone "topCss"}} - + {{css "css/styles.css"}} {{/zone}} {{#zone "bottomJs"}} {{js "/js/download.js"}} {{js "/js/jquery.validate.js"}} -{{/zone}} +{{/zone}} \ No newline at end of file diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml index 943612caf..d08016c5d 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml @@ -46,7 +46,7 @@ 2.2 WEB-INF/lib/*cxf*.jar - ${project.artifactId} + mdm-android-agent @@ -72,7 +72,7 @@ - + diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/configuration/ConfigurationMgtService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/configuration/ConfigurationMgtService.java index f47999149..c05579aaf 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/configuration/ConfigurationMgtService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/configuration/ConfigurationMgtService.java @@ -19,7 +19,7 @@ package org.wso2.carbon.mdm.services.android.services.configuration; import io.swagger.annotations.*; -import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration; +import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; @@ -46,14 +46,14 @@ public interface ConfigurationMgtService { @ApiResponse(code = 500, message = "Internal Server Error") }) Response configureSettings(@ApiParam(name = "configuration", value = "AndroidPlatformConfiguration") - TenantConfiguration configuration) throws AndroidAgentException; + PlatformConfiguration configuration) throws AndroidAgentException; @GET @ApiOperation( httpMethod = "GET", value = "Getting Android Platform Configurations", notes = "Get the Android platform configuration details using this REST API", - response = TenantConfiguration.class + response = PlatformConfiguration.class ) @ApiResponses(value = { @ApiResponse(code = 200, message = "Get Android Configurations"), @@ -75,5 +75,5 @@ public interface ConfigurationMgtService { "Android platform") }) Response updateConfiguration(@ApiParam(name = "configuration", value = "AndroidPlatformConfiguration") - TenantConfiguration configuration) throws AndroidAgentException; + PlatformConfiguration configuration) throws AndroidAgentException; } diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/configuration/impl/ConfigurationMgtServiceImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/configuration/impl/ConfigurationMgtServiceImpl.java index 9517f88e4..57f5d7693 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/configuration/impl/ConfigurationMgtServiceImpl.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/configuration/impl/ConfigurationMgtServiceImpl.java @@ -23,7 +23,7 @@ import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry; -import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration; +import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; import org.wso2.carbon.device.mgt.common.license.mgt.License; import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException; import org.wso2.carbon.mdm.services.android.services.configuration.ConfigurationMgtService; @@ -45,7 +45,7 @@ public class ConfigurationMgtServiceImpl implements ConfigurationMgtService { private static Log log = LogFactory.getLog(ConfigurationMgtServiceImpl.class); @POST - public Response configureSettings(TenantConfiguration configuration) + public Response configureSettings(PlatformConfiguration configuration) throws AndroidAgentException { Message responseMsg = new Message(); @@ -87,15 +87,15 @@ public class ConfigurationMgtServiceImpl implements ConfigurationMgtService { @GET public Response getConfiguration() throws AndroidAgentException { String msg; - TenantConfiguration tenantConfiguration = null; + PlatformConfiguration PlatformConfiguration = null; List configs; try { - tenantConfiguration = AndroidAPIUtils.getDeviceManagementService(). + PlatformConfiguration = AndroidAPIUtils.getDeviceManagementService(). getConfiguration(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); - if (tenantConfiguration != null) { - configs = tenantConfiguration.getConfiguration(); + if (PlatformConfiguration != null) { + configs = PlatformConfiguration.getConfiguration(); } else { - tenantConfiguration = new TenantConfiguration(); + PlatformConfiguration = new PlatformConfiguration(); configs = new ArrayList<>(); } @@ -109,18 +109,18 @@ public class ConfigurationMgtServiceImpl implements ConfigurationMgtService { entry.setName(AndroidConstants.TenantConfigProperties.LICENSE_KEY); entry.setValue(license.getText()); configs.add(entry); - tenantConfiguration.setConfiguration(configs); + PlatformConfiguration.setConfiguration(configs); } } catch (DeviceManagementException e) { msg = "Error occurred while retrieving the Android tenant configuration"; log.error(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } - return Response.status(Response.Status.OK).entity(tenantConfiguration).build(); + return Response.status(Response.Status.OK).entity(PlatformConfiguration).build(); } @PUT - public Response updateConfiguration(TenantConfiguration configuration) throws AndroidAgentException { + public Response updateConfiguration(PlatformConfiguration configuration) throws AndroidAgentException { String msg; Message responseMsg = new Message(); ConfigurationEntry licenseEntry = null; @@ -145,7 +145,7 @@ public class ConfigurationMgtServiceImpl implements ConfigurationMgtService { } configuration.setConfiguration(configs); AndroidAPIUtils.getDeviceManagementService().saveConfiguration(configuration); - AndroidAPIUtils.getGCMService().resetTenantConfigCache(); + //AndroidAPIUtils.getGCMService().resetTenantConfigCache(); Response.status(Response.Status.ACCEPTED); responseMsg.setResponseMessage("Android platform configuration has updated successfully."); responseMsg.setResponseCode(Response.Status.ACCEPTED.toString()); diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidAPIUtils.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidAPIUtils.java index 778d1d80b..acb487d68 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidAPIUtils.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidAPIUtils.java @@ -46,7 +46,6 @@ import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceDetailsMgtExcept import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager; import org.wso2.carbon.device.mgt.core.search.mgt.impl.Utils; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; -import org.wso2.carbon.device.mgt.mobile.impl.android.gcm.GCMService; import org.wso2.carbon.mdm.services.android.bean.DeviceState; import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException; import org.wso2.carbon.policy.mgt.core.PolicyManagerService; @@ -94,16 +93,16 @@ public class AndroidAPIUtils { return deviceManagementProviderService; } - public static GCMService getGCMService() { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - GCMService gcmService = (GCMService) ctx.getOSGiService(GCMService.class, null); - if (gcmService == null) { - String msg = "GCM service has not initialized."; - log.error(msg); - throw new IllegalStateException(msg); - } - return gcmService; - } +// public static GCMService getGCMService() { +// PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); +// GCMService gcmService = (GCMService) ctx.getOSGiService(GCMService.class, null); +// if (gcmService == null) { +// String msg = "GCM service has not initialized."; +// log.error(msg); +// throw new IllegalStateException(msg); +// } +// return gcmService; +// } public static MediaType getResponseMediaType(String acceptHeader) { MediaType responseMediaType; @@ -126,17 +125,17 @@ public class AndroidAPIUtils { List validDeviceIds = deviceIDHolder.getValidDeviceIDList(); Activity activity = getDeviceManagementService().addOperation( DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, operation, validDeviceIds); - if (activity != null) { - GCMService gcmService = getGCMService(); - if (gcmService.isGCMEnabled()) { - List deviceIDList = deviceIDHolder.getValidDeviceIDList(); - List devices = new ArrayList(deviceIDList.size()); - for (DeviceIdentifier deviceIdentifier : deviceIDList) { - devices.add(getDeviceManagementService().getDevice(deviceIdentifier)); - } - getGCMService().sendNotification(operation.getCode(), devices); - } - } +// if (activity != null) { +// GCMService gcmService = getGCMService(); +// if (gcmService.isGCMEnabled()) { +// List deviceIDList = deviceIDHolder.getValidDeviceIDList(); +// List devices = new ArrayList(deviceIDList.size()); +// for (DeviceIdentifier deviceIdentifier : deviceIDList) { +// devices.add(getDeviceManagementService().getDevice(deviceIdentifier)); +// } +// getGCMService().sendNotification(operation.getCode(), devices); +// } +// } if (!deviceIDHolder.getErrorDeviceIdList().isEmpty()) { return javax.ws.rs.core.Response.status(AndroidConstants.StatusCodes. MULTI_STATUS_HTTP_CODE).type( diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/public/css/styles.css b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/public/css/styles.css new file mode 100644 index 000000000..04e2a2611 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/public/css/styles.css @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2016, 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. + */ +.circle { + background: none repeat scroll 0 0 #191919; + border-radius: 50px; + height: 50px; + padding: 10px; + width: 50px; + color: #fff; +} +.padding-top-double { + padding-top: 20px; +} +.padding-double { + padding: 20px; +} +.grey { + color: #333; +} +hr { + display: block; + height: 1px; + border: 0; + border-top: 1px solid #7f7f7f; + margin: 1em 0; + padding: 0; + opacity: 0.2; +} +.light-grey { + color: #7c7c7c; +} +.uppercase { + text-transform: uppercase; +} +.grey-bg { + background-color: #f6f4f4; +} + +.doc-link { + background: #11375B; + padding: 20px; + color: white; + margin-top: 0; +} + +.doc-link a { + color: white; +} \ No newline at end of file diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/type-view.hbs b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/type-view.hbs index 09c98431b..93e2e0a2f 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/type-view.hbs +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/type-view.hbs @@ -79,59 +79,11 @@ {{#zone "topCss"}} - + {{css "css/styles.css"}} {{/zone}} {{#zone "bottomJs"}} {{/zone}} \ No newline at end of file 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 9841815ed..acae2dc47 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 @@ -35,6 +35,10 @@ + + org.apache.maven.plugins + maven-compiler-plugin + org.apache.felix maven-scr-plugin 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/AndroidDeviceManager.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/AndroidDeviceManager.java index 545de690a..951dd27e1 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/AndroidDeviceManager.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/AndroidDeviceManager.java @@ -27,7 +27,7 @@ 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.configuration.mgt.PlatformConfiguration; 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.common.license.mgt.LicenseManager; @@ -85,7 +85,7 @@ public class AndroidDeviceManager implements DeviceManager { } @Override - public boolean saveConfiguration(TenantConfiguration tenantConfiguration) + public boolean saveConfiguration(PlatformConfiguration tenantConfiguration) throws DeviceManagementException { boolean status; try { @@ -96,7 +96,7 @@ public class AndroidDeviceManager implements DeviceManager { DeviceManagementConstants. MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); StringWriter writer = new StringWriter(); - JAXBContext context = JAXBContext.newInstance(TenantConfiguration.class); + JAXBContext context = JAXBContext.newInstance(PlatformConfiguration.class); Marshaller marshaller = context.createMarshaller(); marshaller.marshal(tenantConfiguration, writer); @@ -119,7 +119,7 @@ public class AndroidDeviceManager implements DeviceManager { } @Override - public TenantConfiguration getConfiguration() throws DeviceManagementException { + public PlatformConfiguration getConfiguration() throws DeviceManagementException { Resource resource; try { String androidRegPath = @@ -127,9 +127,9 @@ public class AndroidDeviceManager implements DeviceManager { MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); resource = MobileDeviceManagementUtil.getRegistryResource(androidRegPath); if (resource != null) { - JAXBContext context = JAXBContext.newInstance(TenantConfiguration.class); + JAXBContext context = JAXBContext.newInstance(PlatformConfiguration.class); Unmarshaller unmarshaller = context.createUnmarshaller(); - return (TenantConfiguration) unmarshaller.unmarshal( + return (PlatformConfiguration) unmarshaller.unmarshal( new StringReader(new String((byte[]) resource.getContent(), Charset. forName(MobilePluginConstants.CHARSET_UTF8)))); } 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/gcm/GCMUtil.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/gcm/GCMUtil.java index ba41698e8..c89671403 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/gcm/GCMUtil.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/gcm/GCMUtil.java @@ -27,7 +27,7 @@ import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry; -import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration; +import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; import org.wso2.carbon.device.mgt.mobile.android.impl.util.AndroidPluginConstants; import org.wso2.carbon.device.mgt.mobile.android.internal.AndroidDeviceManagementDataHolder; @@ -56,7 +56,7 @@ public class GCMUtil { private static final int TIME_TO_LIVE = 60; private static final int HTTP_STATUS_CODE_OK = 200; - private static HashMap tenantConfigurationCache = new HashMap<>(); + private static HashMap tenantConfigurationCache = new HashMap<>(); public static GCMResult sendWakeUpCall(String message, List devices) { GCMResult result = new GCMResult(); @@ -163,7 +163,7 @@ public class GCMUtil { getAndroidDeviceManagementService(); try { //Get the TenantConfiguration from cache if not we'll get it from DM service - TenantConfiguration tenantConfiguration = getTenantConfigurationFromCache(); + PlatformConfiguration tenantConfiguration = getTenantConfigurationFromCache(); if (tenantConfiguration == null) { tenantConfiguration = androidDMService.getDeviceManager().getConfiguration(); if (tenantConfiguration != null) { @@ -190,11 +190,11 @@ public class GCMUtil { tenantConfigurationCache.remove(getTenantId()); } - private static void addTenantConfigurationToCache(TenantConfiguration tenantConfiguration) { + private static void addTenantConfigurationToCache(PlatformConfiguration tenantConfiguration) { tenantConfigurationCache.put(getTenantId(), tenantConfiguration); } - private static TenantConfiguration getTenantConfigurationFromCache() { + private static PlatformConfiguration getTenantConfigurationFromCache() { return tenantConfigurationCache.get(getTenantId()); } 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 deleted file mode 100644 index 5eae35cbe..000000000 --- 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 +++ /dev/null @@ -1,70 +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.mobile.impl.android; - -import org.wso2.carbon.device.mgt.common.*; -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.push.notification.PushNotificationConfig; -import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; - -import java.util.List; - -/** - * This represents the Android implementation of DeviceManagerService. - */ -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 void init() throws DeviceManagementException { - this.deviceManager = new AndroidDeviceManager(); - } - - @Override - public DeviceManager getDeviceManager() { - return deviceManager; - } - - @Override - public ApplicationManager getApplicationManager() { - return null; - } - - @Override - public ProvisioningConfig getProvisioningConfig() { - return new ProvisioningConfig(SUPER_TENANT_DOMAIN, true); - } - - @Override - public PushNotificationConfig getPushNotificationConfig() { - return null; - } - -} 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/AndroidDeviceManager.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/AndroidDeviceManager.java deleted file mode 100644 index c69e6b0cb..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManager.java +++ /dev/null @@ -1,342 +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.mobile.impl.android; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -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.common.license.mgt.LicenseManagementException; -import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager; -import org.wso2.carbon.device.mgt.extensions.license.mgt.registry.RegistryBasedLicenseManager; -import org.wso2.carbon.device.mgt.mobile.common.MobileDeviceMgtPluginException; -import org.wso2.carbon.device.mgt.mobile.common.MobilePluginConstants; -import org.wso2.carbon.device.mgt.mobile.dao.AbstractMobileDeviceManagementDAOFactory; -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; -import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice; -import org.wso2.carbon.device.mgt.mobile.impl.android.dao.AndroidDAOFactory; -import org.wso2.carbon.device.mgt.mobile.impl.android.util.AndroidPluginUtils; -import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil; -import org.wso2.carbon.registry.api.RegistryException; -import org.wso2.carbon.registry.api.Resource; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; -import javax.xml.bind.Unmarshaller; -import java.io.StringReader; -import java.io.StringWriter; -import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.List; - -public class AndroidDeviceManager implements DeviceManager { - - private AbstractMobileDeviceManagementDAOFactory daoFactory; - private static final Log log = LogFactory.getLog(AndroidDeviceManagementService.class); - private FeatureManager featureManager = new AndroidFeatureManager(); - private LicenseManager licenseManager; - - public AndroidDeviceManager() { - this.daoFactory = new AndroidDAOFactory(); - this.licenseManager = new RegistryBasedLicenseManager(); - License defaultLicense; - - try { - if (licenseManager.getLicense(AndroidDeviceManagementService.DEVICE_TYPE_ANDROID, - MobilePluginConstants.LANGUAGE_CODE_ENGLISH_US) == null) { - defaultLicense = AndroidPluginUtils.getDefaultLicense(); - licenseManager.addLicense(AndroidDeviceManagementService.DEVICE_TYPE_ANDROID, defaultLicense); - } - featureManager.addSupportedFeaturesToDB(); - } catch (LicenseManagementException e) { - log.error("Error occurred while adding default license for Android devices", e); - } catch (DeviceManagementException e) { - throw new IllegalStateException("Error occurred while adding Android features to the DB."); - } - } - - @Override - public FeatureManager getFeatureManager() { - return featureManager; - } - - @Override - public boolean saveConfiguration(TenantConfiguration tenantConfiguration) - throws DeviceManagementException { - boolean status; - try { - if (log.isDebugEnabled()) { - log.debug("Persisting android configurations in Registry"); - } - String resourcePath = MobileDeviceManagementUtil.getPlatformConfigPath( - DeviceManagementConstants. - MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); - StringWriter writer = new StringWriter(); - JAXBContext context = JAXBContext.newInstance(TenantConfiguration.class); - Marshaller marshaller = context.createMarshaller(); - marshaller.marshal(tenantConfiguration, writer); - - Resource resource = MobileDeviceManagementUtil.getConfigurationRegistry().newResource(); - resource.setContent(writer.toString()); - resource.setMediaType(MobilePluginConstants.MEDIA_TYPE_XML); - MobileDeviceManagementUtil.putRegistryResource(resourcePath, resource); - status = true; - } catch (MobileDeviceMgtPluginException e) { - throw new DeviceManagementException( - "Error occurred while retrieving the Registry instance", e); - } catch (RegistryException e) { - throw new DeviceManagementException( - "Error occurred while persisting the Registry resource of Android Configuration", e); - } catch (JAXBException e) { - throw new DeviceManagementException( - "Error occurred while parsing the Android configuration", e); - } - return status; - } - - @Override - public TenantConfiguration getConfiguration() throws DeviceManagementException { - Resource resource; - try { - String androidRegPath = - MobileDeviceManagementUtil.getPlatformConfigPath(DeviceManagementConstants. - MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); - resource = MobileDeviceManagementUtil.getRegistryResource(androidRegPath); - if (resource != null) { - JAXBContext context = JAXBContext.newInstance(TenantConfiguration.class); - Unmarshaller unmarshaller = context.createUnmarshaller(); - return (TenantConfiguration) unmarshaller.unmarshal( - new StringReader(new String((byte[]) resource.getContent(), Charset. - forName(MobilePluginConstants.CHARSET_UTF8)))); - } - return null; - } catch (MobileDeviceMgtPluginException e) { - throw new DeviceManagementException( - "Error occurred while retrieving the Registry instance", e); - } catch (JAXBException e) { - throw new DeviceManagementException( - "Error occurred while parsing the Android configuration", e); - } catch (RegistryException e) { - throw new DeviceManagementException( - "Error occurred while retrieving the Registry resource of Android Configuration", e); - } - } - - @Override - public boolean enrollDevice(Device device) throws DeviceManagementException { - boolean status = false; - boolean isEnrolled = this.isEnrolled( - new DeviceIdentifier(device.getDeviceIdentifier(), device.getType())); - - try { - if (log.isDebugEnabled()) { - log.debug("Enrolling a new Android device : " + device.getDeviceIdentifier()); - } - - if (isEnrolled) { - this.modifyEnrollment(device); - } else { - MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device); - AndroidDAOFactory.beginTransaction(); - status = daoFactory.getMobileDeviceDAO().addMobileDevice(mobileDevice); - AndroidDAOFactory.commitTransaction(); - } - } catch (MobileDeviceManagementDAOException e) { - try { - AndroidDAOFactory.rollbackTransaction(); - } catch (MobileDeviceManagementDAOException mobileDAOEx) { - String msg = "Error occurred while roll back the device enrol transaction :" + device.toString(); - log.warn(msg, mobileDAOEx); - } - String msg = "Error occurred while enrolling the Android device : " + device.getDeviceIdentifier(); - throw new DeviceManagementException(msg, e); - } - return status; - } - - @Override - public boolean modifyEnrollment(Device device) throws DeviceManagementException { - boolean status; - MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device); - try { - if (log.isDebugEnabled()) { - log.debug("Modifying the Android device enrollment data"); - } - AndroidDAOFactory.beginTransaction(); - status = daoFactory.getMobileDeviceDAO().updateMobileDevice(mobileDevice); - AndroidDAOFactory.commitTransaction(); - } catch (MobileDeviceManagementDAOException e) { - try { - AndroidDAOFactory.rollbackTransaction(); - } catch (MobileDeviceManagementDAOException mobileDAOEx) { - String msg = "Error occurred while roll back the update device transaction :" + device.toString(); - log.warn(msg, mobileDAOEx); - } - String msg = "Error occurred while updating the enrollment of the Android device : " + - device.getDeviceIdentifier(); - throw new DeviceManagementException(msg, e); - } - return status; - } - - @Override - public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException { - //Here we don't have anything specific to do. Hence returning. - return true; - } - - @Override - public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException { - boolean isEnrolled = false; - try { - if (log.isDebugEnabled()) { - log.debug("Checking the enrollment of Android device : " + deviceId.getId()); - } - MobileDevice mobileDevice = - daoFactory.getMobileDeviceDAO().getMobileDevice(deviceId.getId()); - if (mobileDevice != null) { - isEnrolled = true; - } - } catch (MobileDeviceManagementDAOException e) { - String msg = "Error occurred while checking the enrollment status of Android device : " + deviceId.getId(); - 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 Android device : '" + deviceId.getId() + "'"); - } - MobileDevice mobileDevice = daoFactory.getMobileDeviceDAO(). - getMobileDevice(deviceId.getId()); - device = MobileDeviceManagementUtil.convertToDevice(mobileDevice); - } catch (MobileDeviceManagementDAOException e) { - throw new DeviceManagementException( - "Error occurred while fetching the Android device: '" + deviceId.getId() + "'", e); - } - return device; - } - - @Override - public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) - throws DeviceManagementException { - return true; - } - - @Override - public boolean isClaimable(DeviceIdentifier deviceIdentifier) throws DeviceManagementException { - return false; - } - - @Override - public boolean setStatus(DeviceIdentifier deviceIdentifier, String currentUser, - EnrolmentInfo.Status status) throws DeviceManagementException { - return false; - } - - @Override - public License getLicense(String languageCode) throws LicenseManagementException { - return licenseManager. - getLicense(AndroidDeviceManagementService.DEVICE_TYPE_ANDROID, languageCode); - } - - @Override - public void addLicense(License license) throws LicenseManagementException { - licenseManager.addLicense(AndroidDeviceManagementService.DEVICE_TYPE_ANDROID, license); - } - - @Override - public boolean requireDeviceAuthorization() { - return true; - } - - @Override - public boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device) - throws DeviceManagementException { - boolean status; - Device existingDevice = this.getDevice(deviceIdentifier); - // This object holds the current persisted device object - MobileDevice existingMobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(existingDevice); - // This object holds the newly received device object from response - MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device); - // Updating current object features using newer ones - existingMobileDevice.setLatitude(mobileDevice.getLatitude()); - existingMobileDevice.setLongitude(mobileDevice.getLongitude()); - existingMobileDevice.setDeviceProperties(mobileDevice.getDeviceProperties()); - - try { - if (log.isDebugEnabled()) { - log.debug( - "updating the details of Android device : " + device.getDeviceIdentifier()); - } - AndroidDAOFactory.beginTransaction(); - status = daoFactory.getMobileDeviceDAO().updateMobileDevice(existingMobileDevice); - AndroidDAOFactory.commitTransaction(); - } catch (MobileDeviceManagementDAOException e) { - try { - AndroidDAOFactory.rollbackTransaction(); - } catch (MobileDeviceManagementDAOException e1) { - log.warn("Error occurred while roll back the update device info transaction : '" + - device.toString() + "'", e1); - } - throw new DeviceManagementException( - "Error occurred while updating the Android device: '" + device.getDeviceIdentifier() + "'", e); - } - return status; - } - - @Override - public List getAllDevices() throws DeviceManagementException { - List devices = null; - try { - if (log.isDebugEnabled()) { - log.debug("Fetching the details of all Android devices"); - } - List mobileDevices = - daoFactory.getMobileDeviceDAO().getAllMobileDevices(); - if (mobileDevices != null) { - devices = new ArrayList<>(mobileDevices.size()); - for (MobileDevice mobileDevice : mobileDevices) { - devices.add(MobileDeviceManagementUtil.convertToDevice(mobileDevice)); - } - } - } catch (MobileDeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while fetching all Android devices", e); - } - return devices; - } - -} 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/AndroidFeatureManager.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/AndroidFeatureManager.java deleted file mode 100644 index a408360b9..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidFeatureManager.java +++ /dev/null @@ -1,296 +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.mobile.impl.android; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.Feature; -import org.wso2.carbon.device.mgt.common.FeatureManager; -import org.wso2.carbon.device.mgt.mobile.dao.AbstractMobileDeviceManagementDAOFactory; -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory; -import org.wso2.carbon.device.mgt.mobile.dao.MobileFeatureDAO; -import org.wso2.carbon.device.mgt.mobile.dto.MobileFeature; -import org.wso2.carbon.device.mgt.mobile.impl.android.dao.AndroidDAOFactory; -import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil; - -import java.util.ArrayList; -import java.util.List; - -public class AndroidFeatureManager implements FeatureManager { - - private MobileFeatureDAO featureDAO; - private static final Log log = LogFactory.getLog(AndroidFeatureManager.class); - - public AndroidFeatureManager() { - MobileDeviceManagementDAOFactory daoFactory = new AndroidDAOFactory(); - this.featureDAO = daoFactory.getMobileFeatureDAO(); - } - - @Override - public boolean addFeature(Feature feature) throws DeviceManagementException { - try { - AndroidDAOFactory.beginTransaction(); - MobileFeature mobileFeature = MobileDeviceManagementUtil.convertToMobileFeature(feature); - featureDAO.addFeature(mobileFeature); - AndroidDAOFactory.commitTransaction(); - return true; - } catch (MobileDeviceManagementDAOException e) { - try { - AndroidDAOFactory.rollbackTransaction(); - } catch (MobileDeviceManagementDAOException e1) { - log.warn("Error occurred while roll-backing the transaction", e); - } - throw new DeviceManagementException("Error occurred while adding the feature", e); - } - } - - @Override - public boolean addFeatures(List features) throws DeviceManagementException { - List mobileFeatures = new ArrayList(features.size()); - for (Feature feature : features) { - mobileFeatures.add(MobileDeviceManagementUtil.convertToMobileFeature(feature)); - } - try { - AndroidDAOFactory.beginTransaction(); - featureDAO.addFeatures(mobileFeatures); - AndroidDAOFactory.commitTransaction(); - return true; - } catch (MobileDeviceManagementDAOException e) { - try { - AndroidDAOFactory.rollbackTransaction(); - } catch (MobileDeviceManagementDAOException e1) { - log.warn("Error occurred while roll-backing the transaction", e); - } - throw new DeviceManagementException("Error occurred while adding the features", e); - } - } - - @Override - public Feature getFeature(String name) throws DeviceManagementException { - try { - MobileFeature mobileFeature = featureDAO.getFeatureByCode(name); - Feature feature = MobileDeviceManagementUtil.convertToFeature(mobileFeature); - return feature; - } catch (MobileDeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while retrieving the feature", e); - } - } - - @Override - public List getFeatures() throws DeviceManagementException { - try { - List mobileFeatures = featureDAO.getAllFeatures(); - List featureList = new ArrayList(mobileFeatures.size()); - for (MobileFeature mobileFeature : mobileFeatures) { - featureList.add(MobileDeviceManagementUtil.convertToFeature(mobileFeature)); - } - return featureList; - } catch (MobileDeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while retrieving the list of features registered for " + - "Android platform", e); - } - } - - @Override - public boolean removeFeature(String code) throws DeviceManagementException { - boolean status; - try { - AndroidDAOFactory.beginTransaction(); - featureDAO.deleteFeatureByCode(code); - AndroidDAOFactory.commitTransaction(); - status = true; - } catch (MobileDeviceManagementDAOException e) { - try { - AndroidDAOFactory.rollbackTransaction(); - } catch (MobileDeviceManagementDAOException e1) { - log.warn("Error occurred while roll-backing the transaction", e); - } - throw new DeviceManagementException("Error occurred while removing the feature", e); - } - return status; - } - - @Override - public boolean addSupportedFeaturesToDB() throws DeviceManagementException { - synchronized (this) { - List supportedFeatures = getSupportedFeatures(); - List existingFeatures = this.getFeatures(); - List missingFeatures = MobileDeviceManagementUtil. - getMissingFeatures(supportedFeatures, existingFeatures); - if (missingFeatures.size() > 0) { - return this.addFeatures(missingFeatures); - } - return true; - } - } - - //Get the supported feature list. - private static List getSupportedFeatures() { - List supportedFeatures = new ArrayList(); - - Feature feature = new Feature(); - feature.setCode("DEVICE_LOCK"); - feature.setName("Device Lock"); - feature.setDescription("Lock the device"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DEVICE_UNLOCK"); - feature.setName("Device Unlock"); - feature.setDescription("Unlock the device"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DEVICE_LOCATION"); - feature.setName("Location"); - feature.setDescription("Request coordinates of device location"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("WIFI"); - feature.setName("wifi"); - feature.setDescription("Setting up wifi configuration"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("CAMERA"); - feature.setName("camera"); - feature.setDescription("Enable or disable camera"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("EMAIL"); - feature.setName("Email"); - feature.setDescription("Configure email settings"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DEVICE_MUTE"); - feature.setName("Mute"); - feature.setDescription("Enable mute in the device"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DEVICE_INFO"); - feature.setName("Device info"); - feature.setDescription("Request device information"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("ENTERPRISE_WIPE"); - feature.setName("Enterprise Wipe"); - feature.setDescription("Remove enterprise applications"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("CLEAR_PASSWORD"); - feature.setName("Clear Password"); - feature.setDescription("Clear current password"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("WIPE_DATA"); - feature.setName("Wipe Data"); - feature.setDescription("Factory reset the device"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("APPLICATION_LIST"); - feature.setName("Application List"); - feature.setDescription("Request list of current installed applications"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("CHANGE_LOCK_CODE"); - feature.setName("Change Lock-code"); - feature.setDescription("Change current lock code"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("INSTALL_APPLICATION"); - feature.setName("Install App"); - feature.setDescription("Install Enterprise or Market application"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("UPDATE_APPLICATION"); - feature.setName("Update App"); - feature.setDescription("Update Enterprise or Market application"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("UNINSTALL_APPLICATION"); - feature.setName("Uninstall App"); - feature.setDescription("Uninstall application"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("BLACKLIST_APPLICATIONS"); - feature.setName("Blacklist app"); - feature.setDescription("Blacklist applications"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("ENCRYPT_STORAGE"); - feature.setName("Encrypt storage"); - feature.setDescription("Encrypt storage"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DEVICE_RING"); - feature.setName("Ring"); - feature.setDescription("Ring the device"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("PASSCODE_POLICY"); - feature.setName("Password Policy"); - feature.setDescription("Set passcode policy"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("NOTIFICATION"); - feature.setName("Message"); - feature.setDescription("Send message"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DEVICE_REBOOT"); - feature.setName("Reboot"); - feature.setDescription("Reboot the device"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("UPGRADE_FIRMWARE"); - feature.setName("Upgrade Firmware"); - feature.setDescription("Upgrade Firmware"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("VPN"); - feature.setName("Configure VPN"); - feature.setDescription("Configure VPN settings"); - supportedFeatures.add(feature); - - return supportedFeatures; - } - -} 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/AndroidPolicyMonitoringService.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/AndroidPolicyMonitoringService.java deleted file mode 100644 index ced47139f..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidPolicyMonitoringService.java +++ /dev/null @@ -1,100 +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.mobile.impl.android; - -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonParser; -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.DeviceManagementConstants; -import org.wso2.carbon.device.mgt.mobile.impl.android.gcm.GCMService; -import org.wso2.carbon.device.mgt.mobile.internal.MobileDeviceManagementDataHolder; -import org.wso2.carbon.policy.mgt.common.Policy; -import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData; -import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature; -import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException; -import org.wso2.carbon.policy.mgt.common.spi.PolicyMonitoringService; - -import java.util.ArrayList; -import java.util.List; - -public class AndroidPolicyMonitoringService implements PolicyMonitoringService { - - private static Log log = LogFactory.getLog(AndroidPolicyMonitoringService.class); - - @Override - public void notifyDevices(List list) throws PolicyComplianceException { - GCMService gcmService = MobileDeviceManagementDataHolder.getInstance().getGCMService(); - if (gcmService.isGCMEnabled() && !list.isEmpty()) { - gcmService.sendNotification("POLICY_BUNDLE", list); - } - } - - @Override - public ComplianceData checkPolicyCompliance(DeviceIdentifier deviceIdentifier, Policy policy, - Object compliancePayload) throws PolicyComplianceException { - if (log.isDebugEnabled()) { - log.debug("Checking policy compliance status of device '" + deviceIdentifier.getId() + "'"); - } - ComplianceData complianceData = new ComplianceData(); - if (compliancePayload == null || policy == null) { - return complianceData; - } - String compliancePayloadString = new Gson().toJson(compliancePayload); - // Parsing json string to get compliance features. - JsonElement jsonElement; - if (compliancePayloadString instanceof String) { - jsonElement = new JsonParser().parse(compliancePayloadString); - } else { - throw new PolicyComplianceException("Invalid policy compliance payload"); - } - - JsonArray jsonArray = jsonElement.getAsJsonArray(); - Gson gson = new Gson(); - ComplianceFeature complianceFeature; - List complianceFeatures = new ArrayList(jsonArray.size()); - List nonComplianceFeatures = new ArrayList<>(); - - for (JsonElement element : jsonArray) { - complianceFeature = gson.fromJson(element, ComplianceFeature.class); - complianceFeatures.add(complianceFeature); - } - - for (ComplianceFeature cf : complianceFeatures) { - if (!cf.isCompliant()) { - complianceData.setStatus(false); - nonComplianceFeatures.add(cf); - break; - } - } - - complianceData.setComplianceFeatures(nonComplianceFeatures); - return complianceData; - } - - @Override - public String getType() { - return DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID; - } -} \ No newline at end of file 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/dao/AndroidDAOFactory.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/dao/AndroidDAOFactory.java deleted file mode 100644 index 183a47e64..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/AndroidDAOFactory.java +++ /dev/null @@ -1,117 +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.mobile.impl.android.dao; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; -import org.wso2.carbon.device.mgt.mobile.dao.*; -import org.wso2.carbon.device.mgt.mobile.impl.android.dao.impl.AndroidDeviceDAOImpl; -import org.wso2.carbon.device.mgt.mobile.impl.android.dao.impl.AndroidFeatureDAOImpl; - -import javax.sql.DataSource; -import java.sql.Connection; -import java.sql.SQLException; - -public class AndroidDAOFactory extends AbstractMobileDeviceManagementDAOFactory { - - private static final Log log = LogFactory.getLog(AndroidDAOFactory.class); - protected static DataSource dataSource; - private static ThreadLocal currentConnection = new ThreadLocal<>(); - - public AndroidDAOFactory() { - this.dataSource = getDataSourceMap().get(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); - } - - @Override - public MobileDeviceDAO getMobileDeviceDAO() { - return new AndroidDeviceDAOImpl(); - } - - public MobileFeatureDAO getMobileFeatureDAO() { - return new AndroidFeatureDAOImpl(); - } - - public static void beginTransaction() throws MobileDeviceManagementDAOException { - try { - Connection conn = dataSource.getConnection(); - conn.setAutoCommit(false); - currentConnection.set(conn); - } catch (SQLException e) { - throw new MobileDeviceManagementDAOException("Error occurred while retrieving datasource connection", e); - } - } - - public static Connection getConnection() throws MobileDeviceManagementDAOException { - if (currentConnection.get() == null) { - try { - currentConnection.set(dataSource.getConnection()); - } catch (SQLException e) { - throw new MobileDeviceManagementDAOException("Error occurred while retrieving data source connection", - e); - } - } - return currentConnection.get(); - } - - public static void commitTransaction() throws MobileDeviceManagementDAOException { - 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 MobileDeviceManagementDAOException("Error occurred while committing the transaction", e); - } - } - - public static void closeConnection() throws MobileDeviceManagementDAOException { - Connection conn = currentConnection.get(); - try { - if (conn != null) { - conn.close(); - } - } catch (SQLException e) { - log.error("Error occurred while close the connection"); - } - currentConnection.remove(); - } - - public static void rollbackTransaction() throws MobileDeviceManagementDAOException { - 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 MobileDeviceManagementDAOException("Error occurred while rollback the transaction", e); - } - } - -} \ No newline at end of file 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/dao/AndroidFeatureManagementDAOException.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/dao/AndroidFeatureManagementDAOException.java deleted file mode 100644 index 68d5a17d6..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/AndroidFeatureManagementDAOException.java +++ /dev/null @@ -1,79 +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.mobile.impl.android.dao; - -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; - -public class AndroidFeatureManagementDAOException extends MobileDeviceManagementDAOException { - - private String message; - private static final long serialVersionUID = 2021891706072918865L; - - /** - * Constructs a new MobileDeviceManagementDAOException with the specified detail message and - * nested exception. - * - * @param message error message - * @param nestedException exception - */ - public AndroidFeatureManagementDAOException(String message, Exception nestedException) { - super(message, nestedException); - setErrorMessage(message); - } - - /** - * Constructs a new MobileDeviceManagementDAOException with the specified detail message - * and cause. - * - * @param message the detail message. - * @param cause the cause of this exception. - */ - public AndroidFeatureManagementDAOException(String message, Throwable cause) { - super(message, cause); - setErrorMessage(message); - } - - /** - * Constructs a new MobileDeviceManagementDAOException with the specified detail message. - * - * @param message the detail message. - */ - public AndroidFeatureManagementDAOException(String message) { - super(message); - setErrorMessage(message); - } - - /** - * Constructs a new MobileDeviceManagementDAOException with the specified and cause. - * - * @param cause the cause of this exception. - */ - public AndroidFeatureManagementDAOException(Throwable cause) { - super(cause); - } - - public String getMessage() { - return message; - } - - public void setErrorMessage(String errorMessage) { - this.message = errorMessage; - } - -} 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/dao/impl/AndroidDeviceDAOImpl.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/dao/impl/AndroidDeviceDAOImpl.java deleted file mode 100644 index 84ad8512e..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/impl/AndroidDeviceDAOImpl.java +++ /dev/null @@ -1,265 +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.mobile.impl.android.dao.impl; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceDAO; -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; -import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil; -import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice; -import org.wso2.carbon.device.mgt.mobile.impl.android.dao.AndroidDAOFactory; -import org.wso2.carbon.device.mgt.mobile.impl.android.util.AndroidPluginConstants; - -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 MobileDeviceDAO for Android Devices. - */ -public class AndroidDeviceDAOImpl implements MobileDeviceDAO{ - - private static final Log log = LogFactory.getLog(AndroidDeviceDAOImpl.class); - - @Override - public MobileDevice getMobileDevice(String mblDeviceId) throws MobileDeviceManagementDAOException { - Connection conn; - PreparedStatement stmt = null; - MobileDevice mobileDevice = null; - ResultSet rs = null; - try { - conn = AndroidDAOFactory.getConnection(); - String selectDBQuery = - "SELECT DEVICE_ID, GCM_TOKEN, DEVICE_INFO, DEVICE_MODEL, SERIAL, " + - "VENDOR, MAC_ADDRESS, DEVICE_NAME, LATITUDE, LONGITUDE, IMEI, IMSI, OS_VERSION" + - " FROM AD_DEVICE WHERE DEVICE_ID = ?"; - stmt = conn.prepareStatement(selectDBQuery); - stmt.setString(1, mblDeviceId); - rs = stmt.executeQuery(); - - if (rs.next()) { - mobileDevice = new MobileDevice(); - mobileDevice.setMobileDeviceId(rs.getString(AndroidPluginConstants.DEVICE_ID)); - mobileDevice.setModel(rs.getString(AndroidPluginConstants.DEVICE_MODEL)); - mobileDevice.setSerial(rs.getString(AndroidPluginConstants.SERIAL)); - mobileDevice.setVendor(rs.getString(AndroidPluginConstants.VENDOR)); - mobileDevice.setLatitude(rs.getString(AndroidPluginConstants.LATITUDE)); - mobileDevice.setLongitude(rs.getString(AndroidPluginConstants.LONGITUDE)); - mobileDevice.setImei(rs.getString(AndroidPluginConstants.IMEI)); - mobileDevice.setImsi(rs.getString(AndroidPluginConstants.IMSI)); - mobileDevice.setOsVersion(rs.getString(AndroidPluginConstants.OS_VERSION)); - - Map propertyMap = new HashMap(); - propertyMap.put(AndroidPluginConstants.GCM_TOKEN, rs.getString(AndroidPluginConstants.GCM_TOKEN)); - propertyMap.put(AndroidPluginConstants.DEVICE_INFO, rs.getString(AndroidPluginConstants.DEVICE_INFO)); - propertyMap.put(AndroidPluginConstants.DEVICE_NAME, rs.getString(AndroidPluginConstants.DEVICE_NAME)); - mobileDevice.setDeviceProperties(propertyMap); - - if (log.isDebugEnabled()) { - log.debug("Android device " + mblDeviceId + " data has been fetched from " + - "Android database."); - } - } - } catch (SQLException e) { - String msg = "Error occurred while fetching Android device : '" + mblDeviceId + "'"; - log.error(msg, e); - throw new MobileDeviceManagementDAOException(msg, e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs); - AndroidDAOFactory.closeConnection(); - } - - return mobileDevice; - } - - @Override - public boolean addMobileDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException { - boolean status = false; - Connection conn; - PreparedStatement stmt = null; - try { - conn = AndroidDAOFactory.getConnection(); - String createDBQuery = - "INSERT INTO AD_DEVICE(DEVICE_ID, GCM_TOKEN, DEVICE_INFO, SERIAL, " + - "VENDOR, MAC_ADDRESS, DEVICE_NAME, LATITUDE, LONGITUDE, IMEI, IMSI, " + - "OS_VERSION, DEVICE_MODEL) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; - - stmt = conn.prepareStatement(createDBQuery); - stmt.setString(1, mobileDevice.getMobileDeviceId()); - - Map properties = mobileDevice.getDeviceProperties(); - stmt.setString(2, properties.get(AndroidPluginConstants.GCM_TOKEN)); - stmt.setString(3, properties.get(AndroidPluginConstants.DEVICE_INFO)); - stmt.setString(4, mobileDevice.getSerial()); - stmt.setString(5, mobileDevice.getVendor()); - stmt.setString(6, mobileDevice.getMobileDeviceId()); - stmt.setString(7, properties.get(AndroidPluginConstants.DEVICE_NAME)); - stmt.setString(8, mobileDevice.getLatitude()); - stmt.setString(9, mobileDevice.getLongitude()); - stmt.setString(10, mobileDevice.getImei()); - stmt.setString(11, mobileDevice.getImsi()); - stmt.setString(12, mobileDevice.getOsVersion()); - stmt.setString(13, mobileDevice.getModel()); - int rows = stmt.executeUpdate(); - if (rows > 0) { - status = true; - if (log.isDebugEnabled()) { - log.debug("Android device " + mobileDevice.getMobileDeviceId() + " data has been" + - " added to the Android database."); - } - } - } catch (SQLException e) { - throw new MobileDeviceManagementDAOException("Error occurred while adding the Android device '" + - mobileDevice.getMobileDeviceId() + "' information to the Android plugin data store.", e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); - } - return status; - } - - @Override - public boolean updateMobileDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException { - boolean status = false; - Connection conn; - PreparedStatement stmt = null; - try { - conn = AndroidDAOFactory.getConnection(); - String updateDBQuery = - "UPDATE AD_DEVICE SET GCM_TOKEN = ?, DEVICE_INFO = ?, SERIAL = ?, VENDOR = ?, " + - "MAC_ADDRESS = ?, DEVICE_NAME = ?, LATITUDE = ?, LONGITUDE = ?, IMEI = ?, " + - "IMSI = ?, OS_VERSION = ?, DEVICE_MODEL = ? WHERE DEVICE_ID = ?"; - stmt = conn.prepareStatement(updateDBQuery); - - Map properties = mobileDevice.getDeviceProperties(); - stmt.setString(1, properties.get(AndroidPluginConstants.GCM_TOKEN)); - stmt.setString(2, properties.get(AndroidPluginConstants.DEVICE_INFO)); - stmt.setString(3, mobileDevice.getSerial()); - stmt.setString(4, mobileDevice.getVendor()); - stmt.setString(5, mobileDevice.getMobileDeviceId()); - stmt.setString(6, properties.get(AndroidPluginConstants.DEVICE_NAME)); - stmt.setString(7, mobileDevice.getLatitude()); - stmt.setString(8, mobileDevice.getLongitude()); - stmt.setString(9, mobileDevice.getImei()); - stmt.setString(10, mobileDevice.getImsi()); - stmt.setString(11, mobileDevice.getOsVersion()); - stmt.setString(12, mobileDevice.getModel()); - stmt.setString(13, mobileDevice.getMobileDeviceId()); - int rows = stmt.executeUpdate(); - if (rows > 0) { - status = true; - if (log.isDebugEnabled()) { - log.debug("Android device " + mobileDevice.getMobileDeviceId() + " data has been" + - " modified."); - } - } - } catch (SQLException e) { - String msg = "Error occurred while modifying the Android device '" + - mobileDevice.getMobileDeviceId() + "' data."; - log.error(msg, e); - throw new MobileDeviceManagementDAOException(msg, e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); - } - return status; - } - - @Override - public boolean deleteMobileDevice(String mblDeviceId) - throws MobileDeviceManagementDAOException { - boolean status = false; - Connection conn; - PreparedStatement stmt = null; - try { - conn = AndroidDAOFactory.getConnection(); - String deleteDBQuery = - "DELETE FROM AD_DEVICE WHERE DEVICE_ID = ?"; - stmt = conn.prepareStatement(deleteDBQuery); - stmt.setString(1, mblDeviceId); - int rows = stmt.executeUpdate(); - if (rows > 0) { - status = true; - if (log.isDebugEnabled()) { - log.debug("Android device " + mblDeviceId + " data has deleted" + - " from the Android database."); - } - } - } catch (SQLException e) { - throw new MobileDeviceManagementDAOException("Error occurred while deleting android device '" + - mblDeviceId + "'", e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); - } - return status; - } - - @Override - public List getAllMobileDevices() throws MobileDeviceManagementDAOException { - Connection conn; - PreparedStatement stmt = null; - ResultSet rs = null; - MobileDevice mobileDevice; - List mobileDevices = new ArrayList(); - try { - conn = AndroidDAOFactory.getConnection(); - String selectDBQuery = - "SELECT DEVICE_ID, GCM_TOKEN, DEVICE_INFO, DEVICE_MODEL, SERIAL, " + - "VENDOR, MAC_ADDRESS, DEVICE_NAME, LATITUDE, LONGITUDE, IMEI, IMSI, OS_VERSION " + - "FROM AD_DEVICE"; - stmt = conn.prepareStatement(selectDBQuery); - rs = stmt.executeQuery(); - - while (rs.next()) { - mobileDevice = new MobileDevice(); - mobileDevice.setMobileDeviceId(rs.getString(AndroidPluginConstants.DEVICE_ID)); - mobileDevice.setModel(rs.getString(AndroidPluginConstants.DEVICE_MODEL)); - mobileDevice.setSerial(rs.getString(AndroidPluginConstants.SERIAL)); - mobileDevice.setVendor(rs.getString(AndroidPluginConstants.VENDOR)); - mobileDevice.setLatitude(rs.getString(AndroidPluginConstants.LATITUDE)); - mobileDevice.setLongitude(rs.getString(AndroidPluginConstants.LONGITUDE)); - mobileDevice.setImei(rs.getString(AndroidPluginConstants.IMEI)); - mobileDevice.setImsi(rs.getString(AndroidPluginConstants.IMSI)); - mobileDevice.setOsVersion(rs.getString(AndroidPluginConstants.OS_VERSION)); - - Map propertyMap = new HashMap<>(); - propertyMap.put(AndroidPluginConstants.GCM_TOKEN, rs.getString(AndroidPluginConstants.GCM_TOKEN)); - propertyMap.put(AndroidPluginConstants.DEVICE_INFO, rs.getString(AndroidPluginConstants.DEVICE_INFO)); - propertyMap.put(AndroidPluginConstants.DEVICE_NAME, rs.getString(AndroidPluginConstants.DEVICE_NAME)); - mobileDevice.setDeviceProperties(propertyMap); - - mobileDevices.add(mobileDevice); - } - if (log.isDebugEnabled()) { - log.debug("All Android device details have fetched from Android database."); - } - return mobileDevices; - } catch (SQLException e) { - throw new MobileDeviceManagementDAOException("Error occurred while fetching all Android device data", e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs); - AndroidDAOFactory.closeConnection(); - } - } - -} 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/dao/impl/AndroidFeatureDAOImpl.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/dao/impl/AndroidFeatureDAOImpl.java deleted file mode 100644 index de6ec0bf6..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/impl/AndroidFeatureDAOImpl.java +++ /dev/null @@ -1,285 +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.mobile.impl.android.dao.impl; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; -import org.wso2.carbon.device.mgt.mobile.dao.MobileFeatureDAO; -import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil; -import org.wso2.carbon.device.mgt.mobile.dto.MobileFeature; -import org.wso2.carbon.device.mgt.mobile.impl.android.dao.AndroidDAOFactory; -import org.wso2.carbon.device.mgt.mobile.impl.android.dao.AndroidFeatureManagementDAOException; -import org.wso2.carbon.device.mgt.mobile.impl.android.util.AndroidPluginConstants; - -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; - -public class AndroidFeatureDAOImpl implements MobileFeatureDAO { - - private static final Log log = LogFactory.getLog(AndroidFeatureDAOImpl.class); - - public AndroidFeatureDAOImpl() { - - } - - @Override - public boolean addFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException { - PreparedStatement stmt = null; - boolean status = false; - Connection conn; - try { - conn = AndroidDAOFactory.getConnection(); - String sql = "INSERT INTO AD_FEATURE(CODE, NAME, DESCRIPTION) VALUES (?, ?, ?)"; - stmt = conn.prepareStatement(sql); - stmt.setString(1, mobileFeature.getCode()); - stmt.setString(2, mobileFeature.getName()); - stmt.setString(3, mobileFeature.getDescription()); - stmt.executeUpdate(); - status = true; - } catch (SQLException e) { - throw new AndroidFeatureManagementDAOException( - "Error occurred while adding android feature '" + - mobileFeature.getName() + "' into the metadata repository", e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); - } - return status; - } - - @Override - public boolean addFeatures(List mobileFeatures) throws MobileDeviceManagementDAOException { - PreparedStatement stmt = null; - MobileFeature mobileFeature; - boolean status = false; - Connection conn; - try { - conn = AndroidDAOFactory.getConnection(); - stmt = conn.prepareStatement("INSERT INTO AD_FEATURE(CODE, NAME, DESCRIPTION) VALUES (?, ?, ?)"); - for (int i = 0; i < mobileFeatures.size(); i++) { - mobileFeature = mobileFeatures.get(i); - stmt.setString(1, mobileFeature.getCode()); - stmt.setString(2, mobileFeature.getName()); - stmt.setString(3, mobileFeature.getDescription()); - stmt.addBatch(); - } - stmt.executeBatch(); - status = true; - } catch (SQLException e) { - throw new AndroidFeatureManagementDAOException( - "Error occurred while adding android features into the metadata repository", e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); - } - return status; - } - - @Override - public boolean updateFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException { - boolean status = false; - Connection conn; - PreparedStatement stmt = null; - try { - conn = AndroidDAOFactory.getConnection(); - String updateDBQuery = - "UPDATE AD_FEATURE SET NAME = ?, DESCRIPTION = ?" + - "WHERE CODE = ?"; - - stmt = conn.prepareStatement(updateDBQuery); - stmt.setString(1, mobileFeature.getName()); - stmt.setString(2, mobileFeature.getDescription()); - stmt.setString(3, mobileFeature.getCode()); - - int rows = stmt.executeUpdate(); - if (rows > 0) { - status = true; - if (log.isDebugEnabled()) { - log.debug("Android Feature " + mobileFeature.getCode() + " data has been " + - "modified."); - } - } - } catch (SQLException e) { - String msg = "Error occurred while updating the Android Feature '" + - mobileFeature.getCode() + "' to the Android db."; - log.error(msg, e); - throw new AndroidFeatureManagementDAOException(msg, e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); - } - return status; - } - - @Override - public boolean deleteFeatureById(int mblFeatureId) throws MobileDeviceManagementDAOException { - - PreparedStatement stmt = null; - boolean status = false; - Connection conn; - try { - conn = AndroidDAOFactory.getConnection(); - String sql = "DELETE FROM AD_FEATURE WHERE ID = ?"; - stmt = conn.prepareStatement(sql); - stmt.setInt(1, mblFeatureId); - stmt.execute(); - status = true; - } catch (SQLException e) { - throw new AndroidFeatureManagementDAOException( - "Error occurred while deleting android feature '" + - mblFeatureId + "' from Android database.", e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); - } - return status; - } - - @Override - public boolean deleteFeatureByCode(String mblFeatureCode) throws MobileDeviceManagementDAOException { - PreparedStatement stmt = null; - boolean status = false; - Connection conn; - try { - conn = AndroidDAOFactory.getConnection(); - String sql = "DELETE FROM AD_FEATURE WHERE CODE = ?"; - stmt = conn.prepareStatement(sql); - stmt.setString(1, mblFeatureCode); - stmt.execute(); - status = true; - } catch (SQLException e) { - throw new AndroidFeatureManagementDAOException( - "Error occurred while deleting android feature '" + - mblFeatureCode + "' from Android database.", e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); - } - return status; - } - - @Override - public MobileFeature getFeatureById(int mblFeatureId) throws MobileDeviceManagementDAOException { - PreparedStatement stmt = null; - ResultSet rs = null; - Connection conn; - try { - conn = AndroidDAOFactory.getConnection(); - String sql = "SELECT ID, CODE, NAME, DESCRIPTION FROM AD_FEATURE WHERE ID = ?"; - stmt = conn.prepareStatement(sql); - stmt.setInt(1, mblFeatureId); - rs = stmt.executeQuery(); - - MobileFeature mobileFeature = null; - if (rs.next()) { - mobileFeature = new MobileFeature(); - mobileFeature.setId(rs.getInt(AndroidPluginConstants.ANDROID_FEATURE_ID)); - mobileFeature.setCode(rs.getString(AndroidPluginConstants.ANDROID_FEATURE_CODE)); - mobileFeature.setName(rs.getString(AndroidPluginConstants.ANDROID_FEATURE_NAME)); - mobileFeature.setDescription(rs.getString(AndroidPluginConstants. - ANDROID_FEATURE_DESCRIPTION)); - mobileFeature.setDeviceType( - DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); - } - return mobileFeature; - } catch (SQLException e) { - throw new AndroidFeatureManagementDAOException( - "Error occurred while retrieving android feature '" + - mblFeatureId + "' from the Android database.", e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs); - AndroidDAOFactory.closeConnection(); - } - } - - @Override - public MobileFeature getFeatureByCode(String mblFeatureCode) throws MobileDeviceManagementDAOException { - PreparedStatement stmt = null; - ResultSet rs = null; - Connection conn; - - try { - conn = AndroidDAOFactory.getConnection(); - String sql = "SELECT ID, CODE, NAME, DESCRIPTION FROM AD_FEATURE WHERE CODE = ?"; - stmt = conn.prepareStatement(sql); - stmt.setString(1, mblFeatureCode); - rs = stmt.executeQuery(); - - MobileFeature mobileFeature = null; - if (rs.next()) { - mobileFeature = new MobileFeature(); - mobileFeature.setId(rs.getInt(AndroidPluginConstants.ANDROID_FEATURE_ID)); - mobileFeature.setCode(rs.getString(AndroidPluginConstants.ANDROID_FEATURE_CODE)); - mobileFeature.setName(rs.getString(AndroidPluginConstants.ANDROID_FEATURE_NAME)); - mobileFeature.setDescription(rs.getString(AndroidPluginConstants. - ANDROID_FEATURE_DESCRIPTION)); - mobileFeature.setDeviceType( - DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); - } - return mobileFeature; - } catch (SQLException e) { - throw new AndroidFeatureManagementDAOException( - "Error occurred while retrieving android feature '" + - mblFeatureCode + "' from the Android database.", e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs); - AndroidDAOFactory.closeConnection(); - } - } - - @Override - public List getFeatureByDeviceType(String deviceType) - throws MobileDeviceManagementDAOException { - return this.getAllFeatures(); - } - - @Override - public List getAllFeatures() throws MobileDeviceManagementDAOException { - PreparedStatement stmt = null; - ResultSet rs = null; - Connection conn = null; - List features = new ArrayList<>(); - try { - conn = AndroidDAOFactory.getConnection(); - String sql = "SELECT ID, CODE, NAME, DESCRIPTION FROM AD_FEATURE"; - stmt = conn.prepareStatement(sql); - rs = stmt.executeQuery(); - MobileFeature mobileFeature = null; - - while (rs.next()) { - mobileFeature = new MobileFeature(); - mobileFeature.setId(rs.getInt(AndroidPluginConstants.ANDROID_FEATURE_ID)); - mobileFeature.setCode(rs.getString(AndroidPluginConstants.ANDROID_FEATURE_CODE)); - mobileFeature.setName(rs.getString(AndroidPluginConstants.ANDROID_FEATURE_NAME)); - mobileFeature.setDescription(rs.getString(AndroidPluginConstants.ANDROID_FEATURE_DESCRIPTION)); - mobileFeature.setDeviceType( - DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); - features.add(mobileFeature); - } - return features; - } catch (SQLException e) { - throw new AndroidFeatureManagementDAOException("Error occurred while retrieving all " + - "android features from the android database.", e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs); - AndroidDAOFactory.closeConnection(); - } - } -} \ No newline at end of file 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/gcm/GCMResult.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/gcm/GCMResult.java deleted file mode 100644 index c15d6d4c4..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMResult.java +++ /dev/null @@ -1,53 +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.mobile.impl.android.gcm; - -/** - * Represents model object for holding GCM response data. - */ -public class GCMResult { - - private String errorMsg; - private String msg; - private int statusCode; - - public String getErrorMsg() { - return errorMsg; - } - - public void setErrorMsg(String errorMsg) { - this.errorMsg = errorMsg; - } - - public String getMsg() { - return msg; - } - - public void setMsg(String msg) { - this.msg = msg; - } - - public int getStatusCode() { - return statusCode; - } - - public void setStatusCode(int statusCode) { - this.statusCode = statusCode; - } -} 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/gcm/GCMService.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/gcm/GCMService.java deleted file mode 100644 index e49e14d32..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMService.java +++ /dev/null @@ -1,64 +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.mobile.impl.android.gcm; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.common.Device; - -import java.util.ArrayList; -import java.util.List; - -/** - * GCM notification service implementation for Android platform. - */ -public class GCMService { - - private static final Log log = LogFactory.getLog(GCMService.class); - private static final String NOTIFIER_TYPE = "notifierType"; - private static final String GCM_NOTIFIER_CODE = "2"; - - public boolean isGCMEnabled() { - String notifierType = GCMUtil.getConfigurationProperty(NOTIFIER_TYPE); - if (GCM_NOTIFIER_CODE.equals(notifierType)) { - return true; - } - return false; - } - - public void sendNotification(String messageData, Device device) { - List devices = new ArrayList<>(1); - devices.add(device); - GCMResult result = GCMUtil.sendWakeUpCall(messageData, devices); - if (result.getStatusCode() != 200) { - log.error("Exception occurred while sending the GCM notification : " + result.getErrorMsg()); - } - } - - public void sendNotification(String messageData, List devices) { - GCMResult result = GCMUtil.sendWakeUpCall(messageData, devices); - if (result.getStatusCode() != 200) { - log.error("Exception occurred while sending the GCM notification : " + result.getErrorMsg()); - } - } - - public void resetTenantConfigCache() { - GCMUtil.resetTenantConfigCache(); - } -} \ No newline at end of file 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/gcm/GCMUtil.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/gcm/GCMUtil.java deleted file mode 100644 index 19f594bc8..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMUtil.java +++ /dev/null @@ -1,198 +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.mobile.impl.android.gcm; - -import com.google.gson.*; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.CarbonContext; -import org.wso2.carbon.device.mgt.common.Device; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry; -import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration; -import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; -import org.wso2.carbon.device.mgt.mobile.impl.android.util.AndroidPluginConstants; -import org.wso2.carbon.device.mgt.mobile.internal.MobileDeviceManagementDataHolder; - -import java.io.*; -import java.net.HttpURLConnection; -import java.net.ProtocolException; -import java.net.URL; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -/** - * Implements utility methods used by GCMService. - */ -public class GCMUtil { - - private static final Log log = LogFactory.getLog(GCMService.class); - - private final static String GCM_ENDPOINT = "https://gcm-http.googleapis.com/gcm/send"; - private static final String GCM_API_KEY = "gcmAPIKey"; - private static final int TIME_TO_LIVE = 60; - private static final int HTTP_STATUS_CODE_OK = 200; - - private static HashMap tenantConfigurationCache = new HashMap<>(); - - public static GCMResult sendWakeUpCall(String message, List devices) { - GCMResult result = new GCMResult(); - - byte[] bytes = getGCMRequest(message, getGCMTokens(devices)).getBytes(); - HttpURLConnection conn; - try { - conn = (HttpURLConnection) (new URL(GCM_ENDPOINT)).openConnection(); - conn.setDoOutput(true); - conn.setUseCaches(false); - conn.setFixedLengthStreamingMode(bytes.length); - conn.setRequestMethod("POST"); - conn.setRequestProperty("Content-Type", "application/json"); - conn.setRequestProperty("Authorization", "key=" + getConfigurationProperty(GCM_API_KEY)); - - OutputStream out = conn.getOutputStream(); - out.write(bytes); - out.close(); - - int status = conn.getResponseCode(); - result.setStatusCode(status); - if (status != HTTP_STATUS_CODE_OK) { - result.setErrorMsg(getString(conn.getErrorStream())); - } else { - result.setMsg(getString(conn.getInputStream())); - } - } catch (ProtocolException e) { - log.error("Exception occurred while setting the HTTP protocol.", e); - } catch (IOException ex) { - log.error("Exception occurred while sending the GCM request.", ex); - } - - return result; - } - - private static String getString(InputStream stream) throws IOException { - if (stream != null) { - BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); - StringBuilder content = new StringBuilder(); - - String newLine; - do { - newLine = reader.readLine(); - if (newLine != null) { - content.append(newLine).append('\n'); - } - } while (newLine != null); - - if (content.length() > 0) { - content.setLength(content.length() - 1); - } - - return content.toString(); - } - return null; - } - - private static String getGCMRequest(String message, List registrationIds) { - JsonObject gcmRequest = new JsonObject(); - gcmRequest.addProperty("delay_while_idle", false); - gcmRequest.addProperty("time_to_live", TIME_TO_LIVE); - - //Add message to GCM request - JsonObject data = new JsonObject(); - if (message != null && !message.isEmpty()) { - data.addProperty("data", message); - gcmRequest.add("data", data); - } - - //Set device reg-ids - JsonArray regIds = new JsonArray(); - for (String regId : registrationIds) { - if (regId == null || regId.isEmpty()) { - continue; - } - regIds.add(new JsonPrimitive(regId)); - } - - gcmRequest.add("registration_ids", regIds); - return gcmRequest.toString(); - } - - private static List getGCMTokens(List devices) { - List tokens = new ArrayList<>(devices.size()); - for (Device device : devices) { - tokens.add(getGCMToken(device.getProperties())); - } - return tokens; - } - - private static String getGCMToken(List properties) { - String gcmToken = null; - for (Device.Property property : properties) { - if (AndroidPluginConstants.GCM_TOKEN.equals(property.getName())) { - gcmToken = property.getValue(); - break; - } - } - return gcmToken; - } - - public static String getConfigurationProperty(String property) { - DeviceManagementService androidDMService = MobileDeviceManagementDataHolder.getInstance(). - getAndroidDeviceManagementService(); - try { - //Get the TenantConfiguration from cache if not we'll get it from DM service - TenantConfiguration tenantConfiguration = getTenantConfigurationFromCache(); - if (tenantConfiguration == null) { - tenantConfiguration = androidDMService.getDeviceManager().getConfiguration(); - if (tenantConfiguration != null) { - addTenantConfigurationToCache(tenantConfiguration); - } - } - - if (tenantConfiguration != null) { - List configs = tenantConfiguration.getConfiguration(); - for (ConfigurationEntry entry : configs) { - if (property.equals(entry.getName())) { - return (String) entry.getValue(); - } - } - } - return ""; - } catch (DeviceManagementException e) { - log.error("Exception occurred while fetching the tenant-config.",e); - } - return null; - } - - public static void resetTenantConfigCache() { - tenantConfigurationCache.remove(getTenantId()); - } - - private static void addTenantConfigurationToCache(TenantConfiguration tenantConfiguration) { - tenantConfigurationCache.put(getTenantId(), tenantConfiguration); - } - - private static TenantConfiguration getTenantConfigurationFromCache() { - return tenantConfigurationCache.get(getTenantId()); - } - - private static int getTenantId() { - return CarbonContext.getThreadLocalCarbonContext().getTenantId(); - } -} \ No newline at end of file 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/util/AndroidPluginConstants.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/util/AndroidPluginConstants.java deleted file mode 100644 index 798f5fef1..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/util/AndroidPluginConstants.java +++ /dev/null @@ -1,47 +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.mobile.impl.android.util; - -/** - * Defines constants used by android plugin. - */ -public class AndroidPluginConstants { - - //Properties related to AD_DEVICE table - public static final String DEVICE_ID = "DEVICE_ID"; - public static final String GCM_TOKEN = "GCM_TOKEN"; - public static final String DEVICE_INFO = "DEVICE_INFO"; - public static final String SERIAL = "SERIAL"; - public static final String DEVICE_MODEL = "DEVICE_MODEL"; - public static final String DEVICE_NAME = "DEVICE_NAME"; - public static final String LATITUDE = "LATITUDE"; - public static final String LONGITUDE = "LONGITUDE"; - public static final String IMEI = "IMEI"; - public static final String IMSI = "IMSI"; - public static final String VENDOR = "VENDOR"; - public static final String OS_VERSION = "OS_VERSION"; - public static final String MAC_ADDRESS = "MAC_ADDRESS"; - - //Properties related to AD_FEATURE table - public static final String ANDROID_FEATURE_ID = "ID"; - public static final String ANDROID_FEATURE_CODE = "CODE"; - public static final String ANDROID_FEATURE_NAME = "NAME"; - public static final String ANDROID_FEATURE_DESCRIPTION = "DESCRIPTION"; - -} 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/util/AndroidPluginUtils.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/util/AndroidPluginUtils.java deleted file mode 100644 index ea93017c2..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/util/AndroidPluginUtils.java +++ /dev/null @@ -1,58 +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.mobile.impl.android.util; - -import org.wso2.carbon.device.mgt.common.license.mgt.License; -import org.wso2.carbon.device.mgt.mobile.impl.android.AndroidDeviceManagementService; - -/** - * Contains utility methods used by Android plugin. - */ -public class AndroidPluginUtils { - - public static License getDefaultLicense() { - License license = new License(); - license.setName(AndroidDeviceManagementService.DEVICE_TYPE_ANDROID); - license.setLanguage("en_US"); - license.setVersion("1.0.0"); - license.setText("This End User License Agreement (\"Agreement\") is a legal agreement between you (\"You\") " + - "and WSO2, Inc., regarding the enrollment of Your personal mobile device (\"Device\") in SoR's " + - "mobile device management program, and the loading to and removal from Your Device and Your use " + - "of certain applications and any associated software and user documentation, whether provided in " + - "\"online\" or electronic format, used in connection with the operation of or provision of services " + - "to WSO2, Inc., BY SELECTING \"I ACCEPT\" DURING INSTALLATION, YOU ARE ENROLLING YOUR DEVICE, AND " + - "THEREBY AUTHORIZING SOR OR ITS AGENTS TO INSTALL, UPDATE AND REMOVE THE APPS FROM YOUR DEVICE AS " + - "DESCRIBED IN THIS AGREEMENT. YOU ARE ALSO EXPLICITLY ACKNOWLEDGING AND AGREEING THAT (1) THIS IS " + - "A BINDING CONTRACT AND (2) YOU HAVE READ AND AGREE TO THE TERMS OF THIS AGREEMENT.\n" + - "\n" + - "IF YOU DO NOT ACCEPT THESE TERMS, DO NOT ENROLL YOUR DEVICE AND DO NOT PROCEED ANY FURTHER.\n" + - "\n" + - "You agree that: (1) You understand and agree to be bound by the terms and conditions contained " + - "in this Agreement, and (2) You are at least 21 years old and have the legal capacity to enter " + - "into this Agreement as defined by the laws of Your jurisdiction. SoR shall have the right, " + - "without prior notice, to terminate or suspend (i) this Agreement, (ii) the enrollment of Your " + - "Device, or (iii) the functioning of the Apps in the event of a violation of this Agreement or " + - "the cessation of Your relationship with SoR (including termination of Your employment if You are " + - "an employee or expiration or termination of Your applicable franchise or supply agreement if You " + - "are a franchisee of or supplier to the WSO2 WSO2, Inc., system). SoR expressly reserves all " + - "rights not expressly granted herein."); - return license; - } - -} 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/util/AndroidUtils.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/util/AndroidUtils.java deleted file mode 100644 index 48753ed4c..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/util/AndroidUtils.java +++ /dev/null @@ -1,31 +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.mobile.impl.android.util; - -import java.util.Map; - -/** - * Contains utility methods used by Android plugin. - */ -public class AndroidUtils { - - public static String getDeviceProperty(Map deviceProperties, String property) { - return deviceProperties.get(property); - } -} 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 deleted file mode 100644 index fe5372077..000000000 --- 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 +++ /dev/null @@ -1,73 +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.mobile.impl.windows; - -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.ProvisioningConfig; -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.push.notification.PushNotificationConfig; -import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; - -import java.util.List; - -/** - * This represents the Windows implementation of DeviceManagerService. - */ -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 void init() throws DeviceManagementException { - this.deviceManager = new WindowsDeviceManager(); - } - - @Override - public DeviceManager getDeviceManager() { - return deviceManager; - } - - @Override - public ApplicationManager getApplicationManager() { - return null; - } - - @Override - public ProvisioningConfig getProvisioningConfig() { - return new ProvisioningConfig(SUPER_TENANT_DOMAIN, true); - } - - @Override - public PushNotificationConfig getPushNotificationConfig() { - return null; - } - -} 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/WindowsDeviceManager.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/WindowsDeviceManager.java deleted file mode 100644 index b9f03cf49..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java +++ /dev/null @@ -1,312 +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.mobile.impl.windows; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -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.common.license.mgt.LicenseManagementException; -import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager; -import org.wso2.carbon.device.mgt.extensions.license.mgt.registry.RegistryBasedLicenseManager; -import org.wso2.carbon.device.mgt.mobile.common.MobileDeviceMgtPluginException; -import org.wso2.carbon.device.mgt.mobile.common.MobilePluginConstants; -import org.wso2.carbon.device.mgt.mobile.dao.AbstractMobileDeviceManagementDAOFactory; -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; -import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice; -import org.wso2.carbon.device.mgt.mobile.impl.windows.dao.WindowsDAOFactory; -import org.wso2.carbon.device.mgt.mobile.impl.windows.util.WindowsPluginUtils; -import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil; -import org.wso2.carbon.registry.api.RegistryException; -import org.wso2.carbon.registry.api.Resource; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; -import javax.xml.bind.Unmarshaller; -import java.io.StringReader; -import java.io.StringWriter; -import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.List; - -public class WindowsDeviceManager implements DeviceManager { - - private AbstractMobileDeviceManagementDAOFactory daoFactory; - private LicenseManager licenseManager; - private FeatureManager featureManager = new WindowsFeatureManager(); - private static final Log log = LogFactory.getLog(WindowsDeviceManagementService.class); - - public WindowsDeviceManager() { - this.daoFactory = new WindowsDAOFactory(); - this.licenseManager = new RegistryBasedLicenseManager(); - - License defaultLicense = WindowsPluginUtils.getDefaultLicense(); - - try { - if (licenseManager.getLicense(WindowsDeviceManagementService.DEVICE_TYPE_WINDOWS, - MobilePluginConstants.LANGUAGE_CODE_ENGLISH_US) == null) { - licenseManager.addLicense(WindowsDeviceManagementService.DEVICE_TYPE_WINDOWS, defaultLicense); - } - featureManager.addSupportedFeaturesToDB(); - } catch (LicenseManagementException e) { - log.error("Error occurred while adding default license for Windows devices", e); - } catch (DeviceManagementException e) { - throw new IllegalStateException("Error occurred while adding windows features to the DB."); - } - } - - @Override - public FeatureManager getFeatureManager() { - return featureManager; - } - - @Override - public boolean saveConfiguration(TenantConfiguration tenantConfiguration) throws DeviceManagementException { - boolean status; - Resource resource; - try { - if (log.isDebugEnabled()) { - log.debug("Persisting windows configurations in Registry"); - } - String resourcePath = MobileDeviceManagementUtil.getPlatformConfigPath( - DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); - StringWriter writer = new StringWriter(); - JAXBContext context = JAXBContext.newInstance(TenantConfiguration.class); - Marshaller marshaller = context.createMarshaller(); - marshaller.marshal(tenantConfiguration, writer); - - resource = MobileDeviceManagementUtil.getConfigurationRegistry().newResource(); - resource.setContent(writer.toString()); - resource.setMediaType(MobilePluginConstants.MEDIA_TYPE_XML); - MobileDeviceManagementUtil.putRegistryResource(resourcePath, resource); - status = true; - } catch (MobileDeviceMgtPluginException e) { - throw new DeviceManagementException( - "Error occurred while retrieving the Registry instance", e); - } catch (RegistryException e) { - throw new DeviceManagementException( - "Error occurred while persisting the Registry resource of Windows configuration", e); - } catch (JAXBException e) { - throw new DeviceManagementException( - "Error occurred while parsing the Windows configuration", e); - } - return status; - } - - @Override - public TenantConfiguration getConfiguration() throws DeviceManagementException { - Resource resource; - try { - String windowsTenantRegistryPath = MobileDeviceManagementUtil. - getPlatformConfigPath(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); - resource = MobileDeviceManagementUtil.getRegistryResource(windowsTenantRegistryPath); - if (resource != null) { - JAXBContext context = JAXBContext.newInstance(TenantConfiguration.class); - Unmarshaller unmarshaller = context.createUnmarshaller(); - return (TenantConfiguration) unmarshaller.unmarshal(new StringReader( - new String((byte[]) resource.getContent(), Charset. - forName(MobilePluginConstants.CHARSET_UTF8)))); - } - return null; - } catch (MobileDeviceMgtPluginException e) { - throw new DeviceManagementException( - "Error occurred while retrieving the Registry instance", e); - } catch (JAXBException e) { - throw new DeviceManagementException( - "Error occurred while parsing the Windows configuration", e); - } catch (RegistryException e) { - throw new DeviceManagementException( - "Error occurred while retrieving the Registry resource of Windows configuration", e); - } - } - - @Override - public boolean modifyEnrollment(Device device) throws DeviceManagementException { - boolean status = false; - MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device); - try { - if (log.isDebugEnabled()) { - log.debug("Modifying the Windows device enrollment data"); - } - WindowsDAOFactory.beginTransaction(); - if (daoFactory.getMobileDeviceDAO() != null) { - status = daoFactory.getMobileDeviceDAO().updateMobileDevice(mobileDevice); - } - WindowsDAOFactory.commitTransaction(); - } catch (MobileDeviceManagementDAOException e) { - WindowsDAOFactory.rollbackTransaction(); - throw new DeviceManagementException("Error occurred while updating the enrollment of the " + - "Windows device : " + device.getDeviceIdentifier(), e); - } finally { - WindowsDAOFactory.closeConnection(); - } - return status; - } - - @Override - public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException { - //Here we don't have anything specific to do. Hence returning. - return true; - } - - @Override - public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException { - MobileDevice mobileDevice; - try { - if (log.isDebugEnabled()) { - log.debug("Checking the enrollment of Windows device : " + deviceId.getId()); - } - if (daoFactory.getMobileDeviceDAO() != null) { - mobileDevice = daoFactory.getMobileDeviceDAO().getMobileDevice(deviceId.getId()); - } else { - throw new DeviceManagementException("Error occurred while getting DAO object."); - } - } catch (MobileDeviceManagementDAOException e) { - String msg = "Error occurred while checking the enrollment status of Windows device : " + deviceId.getId(); - throw new DeviceManagementException(msg, e); - } - return (mobileDevice != null); - } - - @Override - public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException { - return true; - } - - @Override - public boolean setActive(DeviceIdentifier deviceId, boolean status) - throws DeviceManagementException { - return true; - } - - public List getAllDevices() throws DeviceManagementException { - List devices = null; - List mobileDevices = null; - try { - if (log.isDebugEnabled()) { - log.debug("Fetching the details of all Windows devices"); - } - WindowsDAOFactory.openConnection(); - if (daoFactory.getMobileDeviceDAO() != null) { - mobileDevices = daoFactory.getMobileDeviceDAO().getAllMobileDevices(); - } - if (mobileDevices != null) { - devices = new ArrayList<>(mobileDevices.size()); - for (MobileDevice mobileDevice : mobileDevices) { - devices.add(MobileDeviceManagementUtil.convertToDevice(mobileDevice)); - } - } - } catch (MobileDeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while fetching all Windows devices", e); - } finally { - WindowsDAOFactory.closeConnection(); - } - return devices; - } - - @Override - public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException { - Device device = null; - MobileDevice mobileDevice = null; - try { - if (log.isDebugEnabled()) { - log.debug("Getting the details of Windows device : '" + deviceId.getId() + "'"); - } - WindowsDAOFactory.openConnection(); - if (daoFactory.getMobileDeviceDAO() != null) { - mobileDevice = daoFactory.getMobileDeviceDAO().getMobileDevice(deviceId.getId()); - } - device = MobileDeviceManagementUtil.convertToDevice(mobileDevice); - } catch (MobileDeviceManagementDAOException e) { - throw new DeviceManagementException( - "Error occurred while fetching the Windows device: '" + deviceId.getId() + "'", e); - } finally { - WindowsDAOFactory.closeConnection(); - } - return device; - } - - @Override - public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) - throws DeviceManagementException { - return true; - } - - @Override - public boolean isClaimable(DeviceIdentifier deviceIdentifier) throws DeviceManagementException { - return false; - } - - @Override - public boolean setStatus(DeviceIdentifier deviceIdentifier, String currentUser, - EnrolmentInfo.Status status) throws DeviceManagementException { - return false; - } - - @Override - public License getLicense(String languageCode) throws LicenseManagementException { - return licenseManager.getLicense(WindowsDeviceManagementService.DEVICE_TYPE_WINDOWS, languageCode); - } - - @Override - public void addLicense(License license) throws LicenseManagementException { - licenseManager.addLicense(WindowsDeviceManagementService.DEVICE_TYPE_WINDOWS, license); - } - - @Override - public boolean requireDeviceAuthorization() { - return false; - } - - @Override - public boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, - Device device) throws DeviceManagementException { - return true; - } - - @Override - public boolean enrollDevice(Device device) throws DeviceManagementException { - boolean status = false; - MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device); - try { - if (log.isDebugEnabled()) { - log.debug("Enrolling a new windows device : " + device.getDeviceIdentifier()); - } - boolean isEnrolled = this.isEnrolled( - new DeviceIdentifier(device.getDeviceIdentifier(), device.getType())); - if (isEnrolled) { - this.modifyEnrollment(device); - } else { - WindowsDAOFactory.beginTransaction(); - if (daoFactory.getMobileDeviceDAO() != null) { - status = daoFactory.getMobileDeviceDAO().addMobileDevice(mobileDevice); - } - WindowsDAOFactory.commitTransaction(); - } - } catch (MobileDeviceManagementDAOException e) { - WindowsDAOFactory.rollbackTransaction(); - throw new DeviceManagementException("Error occurred while enrolling the windows device : " - + device.getDeviceIdentifier(), e); - } - return status; - } - -} 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/WindowsFeatureManager.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/WindowsFeatureManager.java deleted file mode 100644 index cdca8334c..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsFeatureManager.java +++ /dev/null @@ -1,198 +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.mobile.impl.windows; - -import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.Feature; -import org.wso2.carbon.device.mgt.common.FeatureManager; -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory; -import org.wso2.carbon.device.mgt.mobile.dao.MobileFeatureDAO; -import org.wso2.carbon.device.mgt.mobile.dto.MobileFeature; -import org.wso2.carbon.device.mgt.mobile.impl.windows.dao.WindowsDAOFactory; -import org.wso2.carbon.device.mgt.mobile.impl.windows.util.WindowsUtils; -import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil; - -import java.util.ArrayList; -import java.util.List; - -public class WindowsFeatureManager implements FeatureManager { - - private MobileFeatureDAO featureDAO; - - public WindowsFeatureManager() { - MobileDeviceManagementDAOFactory daoFactory = new WindowsDAOFactory(); - this.featureDAO = daoFactory.getMobileFeatureDAO(); - } - - @Override - public boolean addFeature(Feature feature) throws DeviceManagementException { - try { - WindowsDAOFactory.beginTransaction(); - MobileFeature mobileFeature = MobileDeviceManagementUtil.convertToMobileFeature(feature); - featureDAO.addFeature(mobileFeature); - WindowsDAOFactory.commitTransaction(); - return true; - } catch (MobileDeviceManagementDAOException e) { - WindowsDAOFactory.rollbackTransaction(); - throw new DeviceManagementException("Error occurred while adding the feature", e); - } finally { - WindowsDAOFactory.closeConnection(); - } - } - - @Override - public boolean addFeatures(List features) throws DeviceManagementException { - List mobileFeatures = new ArrayList(features.size()); - for (Feature feature : features) { - mobileFeatures.add(MobileDeviceManagementUtil.convertToMobileFeature(feature)); - } - try { - WindowsDAOFactory.beginTransaction(); - featureDAO.addFeatures(mobileFeatures); - WindowsDAOFactory.commitTransaction(); - return true; - } catch (MobileDeviceManagementDAOException e) { - WindowsDAOFactory.rollbackTransaction(); - throw new DeviceManagementException("Error occurred while adding the features", e); - } finally { - WindowsDAOFactory.closeConnection(); - } - } - - @Override - public Feature getFeature(String name) throws DeviceManagementException { - try { - WindowsDAOFactory.openConnection(); - MobileFeature mobileFeature = featureDAO.getFeatureByCode(name); - Feature feature = MobileDeviceManagementUtil.convertToFeature(mobileFeature); - return feature; - } catch (MobileDeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while retrieving the feature", e); - } finally { - WindowsDAOFactory.closeConnection(); - } - } - - @Override - public List getFeatures() throws DeviceManagementException { - - try { - WindowsDAOFactory.openConnection(); - List mobileFeatures = featureDAO.getAllFeatures(); - List featureList = new ArrayList(mobileFeatures.size()); - for (MobileFeature mobileFeature : mobileFeatures) { - featureList.add(MobileDeviceManagementUtil.convertToFeature(mobileFeature)); - } - return featureList; - } catch (MobileDeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while retrieving the list of features registered for " + - "Windows platform", e); - } finally { - WindowsDAOFactory.closeConnection(); - } - } - - @Override - public boolean removeFeature(String code) throws DeviceManagementException { - boolean status; - try { - WindowsDAOFactory.beginTransaction(); - featureDAO.deleteFeatureByCode(code); - WindowsDAOFactory.commitTransaction(); - status = true; - return status; - } catch (MobileDeviceManagementDAOException e) { - WindowsDAOFactory.rollbackTransaction(); - throw new DeviceManagementException("Error occurred while removing the feature", e); - } finally { - WindowsDAOFactory.closeConnection(); - } - } - - @Override - public boolean addSupportedFeaturesToDB() throws DeviceManagementException { - synchronized (this) { - List supportedFeatures = getSupportedFeatures(); - List existingFeatures = this.getFeatures(); - List missingFeatures = MobileDeviceManagementUtil. - getMissingFeatures(supportedFeatures, existingFeatures); - if (missingFeatures.size() > 0) { - return this.addFeatures(missingFeatures); - } - return true; - } - } - - /** - * Get supported Windows features. - * - * @return Supported features. - */ - public static List getSupportedFeatures() { - List supportedFeatures = new ArrayList<>(); - Feature feature; - feature = WindowsUtils.getMobileFeature(); - feature.setCode("DEVICE_LOCK"); - feature.setName("Device Lock"); - feature.setDescription("Lock the device"); - supportedFeatures.add(feature); - feature = WindowsUtils.getMobileFeature(); - feature.setCode("CAMERA"); - feature.setName("camera"); - feature.setDescription("Enable or disable camera"); - supportedFeatures.add(feature); - feature = WindowsUtils.getMobileFeature(); - feature.setCode("DEVICE_INFO"); - feature.setName("Device info"); - feature.setDescription("Request device information"); - supportedFeatures.add(feature); - feature = WindowsUtils.getMobileFeature(); - feature.setCode("WIPE_DATA"); - feature.setName("Wipe Data"); - feature.setDescription("Factory reset the device"); - supportedFeatures.add(feature); - feature = WindowsUtils.getMobileFeature(); - feature.setCode("ENCRYPT_STORAGE"); - feature.setName("Encrypt storage"); - feature.setDescription("Encrypt storage"); - supportedFeatures.add(feature); - feature = WindowsUtils.getMobileFeature(); - feature.setCode("DEVICE_RING"); - feature.setName("Ring"); - feature.setDescription("Ring the device"); - supportedFeatures.add(feature); - feature = WindowsUtils.getMobileFeature(); - feature.setCode("PASSCODE_POLICY"); - feature.setName("Password Policy"); - feature.setDescription("Set passcode policy"); - supportedFeatures.add(feature); - feature = WindowsUtils.getMobileFeature(); - feature.setCode("DISENROLL"); - feature.setName("DisEnroll"); - feature.setDescription("DisEnroll the device"); - supportedFeatures.add(feature); - feature = WindowsUtils.getMobileFeature(); - feature.setCode("LOCK_RESET"); - feature.setName("LockReset"); - feature.setDescription("Lock Reset device"); - supportedFeatures.add(feature); - return supportedFeatures; - } -} 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/WindowsPolicyMonitoringService.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/WindowsPolicyMonitoringService.java deleted file mode 100644 index b4bb0bac1..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsPolicyMonitoringService.java +++ /dev/null @@ -1,73 +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.mobile.impl.windows; - -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.DeviceManagementConstants; -import org.wso2.carbon.policy.mgt.common.Policy; -import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData; -import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature; -import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException; -import org.wso2.carbon.policy.mgt.common.spi.PolicyMonitoringService; - -import java.util.ArrayList; -import java.util.List; - -public class WindowsPolicyMonitoringService implements PolicyMonitoringService { - - private static Log log = LogFactory.getLog(WindowsPolicyMonitoringService.class); - - @Override - public void notifyDevices(List list) throws PolicyComplianceException { - - } - - @Override - public ComplianceData checkPolicyCompliance(DeviceIdentifier deviceIdentifier, Policy policy, Object compliancePayload) - throws PolicyComplianceException { - if (log.isDebugEnabled()) { - log.debug("checking policy compliance status of device '" + deviceIdentifier.getId() + "'"); - } - List complianceFeatures = (List) compliancePayload; - List nonComplianceFeatures = new ArrayList<>(); - ComplianceData complianceData = new ComplianceData(); - - if (policy == null || compliancePayload == null) { - return complianceData; - } - - for (ComplianceFeature complianceFeature : complianceFeatures) { - if (!complianceFeature.isCompliant()) { - complianceData.setStatus(false); - nonComplianceFeatures.add(complianceFeature); - break; - } - } - complianceData.setComplianceFeatures(nonComplianceFeatures); - return complianceData; - } - - @Override - public String getType() { - return DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS; - } -} 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/dao/WindowsDAOFactory.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/dao/WindowsDAOFactory.java deleted file mode 100644 index 7fd0461c4..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/dao/WindowsDAOFactory.java +++ /dev/null @@ -1,132 +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.mobile.impl.windows.dao; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; -import org.wso2.carbon.device.mgt.mobile.dao.AbstractMobileDeviceManagementDAOFactory; -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceDAO; -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; -import org.wso2.carbon.device.mgt.mobile.dao.MobileFeatureDAO; -import org.wso2.carbon.device.mgt.mobile.impl.windows.dao.impl.WindowsDeviceDAOImpl; -import org.wso2.carbon.device.mgt.mobile.impl.windows.dao.impl.WindowsFeatureDAOImpl; - -import javax.sql.DataSource; -import java.sql.Connection; -import java.sql.SQLException; - -public class WindowsDAOFactory extends AbstractMobileDeviceManagementDAOFactory { - - private static final Log log = LogFactory.getLog(WindowsDAOFactory.class); - protected static DataSource dataSource; - private static ThreadLocal currentConnection = new ThreadLocal<>(); - - public WindowsDAOFactory() { - this.dataSource = getDataSourceMap().get( - DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); - } - - @Override - public MobileDeviceDAO getMobileDeviceDAO() { - return new WindowsDeviceDAOImpl(); - } - - @Override - public MobileFeatureDAO getMobileFeatureDAO() { - return new WindowsFeatureDAOImpl(); - } - - public static void beginTransaction() throws MobileDeviceManagementDAOException { - try { - Connection conn = dataSource.getConnection(); - conn.setAutoCommit(false); - currentConnection.set(conn); - } catch (SQLException e) { - throw new MobileDeviceManagementDAOException("Error occurred while retrieving datasource connection", e); - } - } - - public static void openConnection() throws MobileDeviceManagementDAOException { - if (currentConnection.get() == null) { - Connection conn; - try { - conn = dataSource.getConnection(); - currentConnection.set(conn); - } catch (SQLException e) { - throw new MobileDeviceManagementDAOException - ("Error occurred while retrieving data source connection", e); - } - } - } - - public static Connection getConnection() throws MobileDeviceManagementDAOException { - if (currentConnection.get() == null) { - try { - currentConnection.set(dataSource.getConnection()); - } catch (SQLException e) { - throw new MobileDeviceManagementDAOException - ("Error occurred while retrieving data source connection", e); - } - } - return currentConnection.get(); - } - - public static void commitTransaction() { - 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) { - log.error("Error occurred while committing the transaction", e); - } - } - - public static void closeConnection() { - Connection con = currentConnection.get(); - try { - con.close(); - } catch (SQLException e) { - log.error("Error occurred while close the connection"); - } - currentConnection.remove(); - } - - public static void rollbackTransaction() { - 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) { - log.warn("Error occurred while roll-backing the transaction", e); - } - } -} 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/dao/WindowsFeatureManagementDAOException.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/dao/WindowsFeatureManagementDAOException.java deleted file mode 100644 index 7596b3956..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/dao/WindowsFeatureManagementDAOException.java +++ /dev/null @@ -1,80 +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.mobile.impl.windows.dao; - -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; - -/** - * This class responsible for wrapping exceptions related on Windows device features. - */ -public class WindowsFeatureManagementDAOException extends MobileDeviceManagementDAOException { - - private String message; - private static final long serialVersionUID = 2021891706072918865L; - - /** - * Constructs a new MobileDeviceManagementDAOException with the specified detail message and - * nested exception. - * - * @param message error message - * @param nestedException exception - */ - public WindowsFeatureManagementDAOException(String message, Exception nestedException) { - super(message, nestedException); - } - - /** - * Constructs a new MobileDeviceManagementDAOException with the specified detail message - * and cause. - * - * @param message the detail message. - * @param cause the cause of this exception. - */ - public WindowsFeatureManagementDAOException(String message, Throwable cause) { - super(message, cause); - setErrorMessage(message); - } - - /** - * Constructs a new MobileDeviceManagementDAOException with the specified detail message. - * - * @param message the detail message. - */ - public WindowsFeatureManagementDAOException(String message) { - super(message); - setErrorMessage(message); - } - - /** - * Constructs a new MobileDeviceManagementDAOException with the specified and cause. - * - * @param cause the cause of this exception. - */ - public WindowsFeatureManagementDAOException(Throwable cause) { - super(cause); - } - - public String getMessage() { - return message; - } - - public void setErrorMessage(String errorMessage) { - this.message = errorMessage; - } -} 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/dao/impl/WindowsDeviceDAOImpl.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/dao/impl/WindowsDeviceDAOImpl.java deleted file mode 100644 index d8039f67f..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/dao/impl/WindowsDeviceDAOImpl.java +++ /dev/null @@ -1,238 +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.mobile.impl.windows.dao.impl; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceDAO; -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; -import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil; -import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice; -import org.wso2.carbon.device.mgt.mobile.impl.windows.dao.WindowsDAOFactory; -import org.wso2.carbon.device.mgt.mobile.impl.windows.util.WindowsPluginConstants; -import org.wso2.carbon.device.mgt.mobile.impl.windows.util.WindowsUtils; - -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 MobileDeviceDAO for Windows Devices. - */ -public class WindowsDeviceDAOImpl implements MobileDeviceDAO { - - private static final Log log = LogFactory.getLog(WindowsDeviceDAOImpl.class); - - @Override - public MobileDevice getMobileDevice(String mblDeviceId) throws MobileDeviceManagementDAOException { - Connection conn; - PreparedStatement stmt = null; - ResultSet rs = null; - MobileDevice mobileDevice = null; - try { - conn = WindowsDAOFactory.getConnection(); - String selectDBQuery = - "SELECT DEVICE_ID, CHANNEL_URI, DEVICE_INFO, IMEI, IMSI, " + - "OS_VERSION, DEVICE_MODEL, VENDOR, LATITUDE, LONGITUDE, SERIAL, MAC_ADDRESS," + - " OS_VERSION, DEVICE_NAME " + - "FROM WIN_DEVICE WHERE DEVICE_ID = ?"; - stmt = conn.prepareStatement(selectDBQuery); - stmt.setString(1, mblDeviceId); - rs = stmt.executeQuery(); - - while (rs.next()) { - mobileDevice = WindowsUtils.loadMobileDevices(rs); - Map propertyMap = new HashMap<>(); - propertyMap.put(WindowsPluginConstants.CHANNEL_URI, rs.getString(WindowsPluginConstants.CHANNEL_URI)); - propertyMap.put(WindowsPluginConstants.DEVICE_INFO, rs.getString(WindowsPluginConstants.DEVICE_INFO)); - propertyMap.put(WindowsPluginConstants.MAC_ADDRESS, rs.getString(WindowsPluginConstants.MAC_ADDRESS)); - propertyMap.put(WindowsPluginConstants.DEVICE_NAME, rs.getString(WindowsPluginConstants.DEVICE_NAME)); - - mobileDevice.setDeviceProperties(propertyMap); - } - if (log.isDebugEnabled()) { - log.debug("All Windows device details have fetched from Windows database."); - } - return mobileDevice; - } catch (SQLException e) { - throw new MobileDeviceManagementDAOException("Error occurred while fetching all Windows device data", e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs); - } - } - - @Override - public boolean addMobileDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException { - boolean status = false; - Connection conn; - PreparedStatement stmt = null; - try { - conn = WindowsDAOFactory.getConnection(); - String createDBQuery = - "INSERT INTO WIN_DEVICE(DEVICE_ID, CHANNEL_URI, DEVICE_INFO, IMEI, " + - "IMSI, OS_VERSION, DEVICE_MODEL, VENDOR, LATITUDE, LONGITUDE, SERIAL, " + - "MAC_ADDRESS, DEVICE_NAME) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; - - stmt = conn.prepareStatement(createDBQuery); - stmt.setString(1, mobileDevice.getMobileDeviceId()); - - Map properties = mobileDevice.getDeviceProperties(); - stmt.setString(2, properties.get(WindowsPluginConstants.CHANNEL_URI)); - stmt.setString(3, properties.get(WindowsPluginConstants.DEVICE_INFO)); - stmt.setString(4, mobileDevice.getImei()); - stmt.setString(5, mobileDevice.getImsi()); - stmt.setString(6, mobileDevice.getOsVersion()); - stmt.setString(7, mobileDevice.getModel()); - stmt.setString(8, mobileDevice.getVendor()); - stmt.setString(9, mobileDevice.getLatitude()); - stmt.setString(10, mobileDevice.getLongitude()); - stmt.setString(11, mobileDevice.getSerial()); - stmt.setString(12, properties.get(WindowsPluginConstants.MAC_ADDRESS)); - stmt.setString(13, properties.get(WindowsPluginConstants.DEVICE_NAME)); - int rows = stmt.executeUpdate(); - if (rows > 0) { - status = true; - if (log.isDebugEnabled()) { - log.debug("Windows device " + mobileDevice.getMobileDeviceId() + " data has been" + - " added to the Windows database."); - } - } - } catch (SQLException e) { - throw new MobileDeviceManagementDAOException("Error occurred while adding the Windows device '" + - mobileDevice.getMobileDeviceId() + "' to the Windows db.", e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); - } - return status; - } - - @Override - public boolean updateMobileDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException { - boolean status = false; - Connection conn; - PreparedStatement stmt = null; - try { - conn = WindowsDAOFactory.getConnection(); - String updateDBQuery = - "UPDATE WIN_DEVICE SET CHANNEL_URI = ?, DEVICE_INFO = ?, IMEI = ?, IMSI = ?, " + - "OS_VERSION = ?, DEVICE_MODEL = ?, VENDOR = ?, LATITUDE = ?, LONGITUDE = ?, " + - "SERIAL = ?, MAC_ADDRESS = ?, DEVICE_NAME = ? WHERE DEVICE_ID = ?"; - - stmt = conn.prepareStatement(updateDBQuery); - - Map properties = mobileDevice.getDeviceProperties(); - stmt.setString(1, properties.get(WindowsPluginConstants.CHANNEL_URI)); - stmt.setString(2, properties.get(WindowsPluginConstants.DEVICE_INFO)); - stmt.setString(3, mobileDevice.getImei()); - stmt.setString(4, mobileDevice.getImsi()); - stmt.setString(5, mobileDevice.getOsVersion()); - stmt.setString(6, mobileDevice.getModel()); - stmt.setString(7, mobileDevice.getVendor()); - stmt.setString(8, mobileDevice.getLatitude()); - stmt.setString(9, mobileDevice.getLongitude()); - stmt.setString(10, mobileDevice.getSerial()); - stmt.setString(11, properties.get(WindowsPluginConstants.MAC_ADDRESS)); - stmt.setString(12, properties.get(WindowsPluginConstants.DEVICE_NAME)); - stmt.setString(13, mobileDevice.getMobileDeviceId()); - int rows = stmt.executeUpdate(); - if (rows > 0) { - status = true; - if (log.isDebugEnabled()) { - log.debug("Windows device " + mobileDevice.getMobileDeviceId() + " data has been" + - " modified."); - } - } - } catch (SQLException e) { - throw new MobileDeviceManagementDAOException("Error occurred while modifying the Windows device '" + - mobileDevice.getMobileDeviceId() + "' data.", e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); - } - return status; - } - - @Override - public boolean deleteMobileDevice(String mblDeviceId) throws MobileDeviceManagementDAOException { - boolean status = false; - Connection conn; - PreparedStatement stmt = null; - try { - conn = WindowsDAOFactory.getConnection(); - String deleteDBQuery = "DELETE FROM WIN_DEVICE WHERE DEVICE_ID = ?"; - stmt = conn.prepareStatement(deleteDBQuery); - stmt.setString(1, mblDeviceId); - int rows = stmt.executeUpdate(); - if (rows > 0) { - status = true; - if (log.isDebugEnabled()) { - log.debug("Windows device " + mblDeviceId + " data has deleted" + - " from the windows database."); - } - } - } catch (SQLException e) { - throw new MobileDeviceManagementDAOException("Error occurred while deleting windows device '" + - mblDeviceId + "'", e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); - } - return status; - } - - @Override - public List getAllMobileDevices() throws MobileDeviceManagementDAOException { - Connection conn; - PreparedStatement stmt = null; - ResultSet rs = null; - MobileDevice mobileDevice; - List mobileDevices = new ArrayList<>(); - try { - conn = WindowsDAOFactory.getConnection(); - String selectDBQuery = - "SELECT DEVICE_ID, CHANNEL_URI, DEVICE_INFO, IMEI, IMSI, " + - "OS_VERSION, DEVICE_MODEL, VENDOR, LATITUDE, LONGITUDE, SERIAL, MAC_ADDRESS," + - " OS_VERSION, DEVICE_NAME " + - "FROM WIN_DEVICE"; - stmt = conn.prepareStatement(selectDBQuery); - rs = stmt.executeQuery(); - - while (rs.next()) { - mobileDevice = WindowsUtils.loadMobileDevices(rs); - Map propertyMap = new HashMap<>(); - propertyMap.put(WindowsPluginConstants.CHANNEL_URI, rs.getString(WindowsPluginConstants.CHANNEL_URI)); - propertyMap.put(WindowsPluginConstants.DEVICE_INFO, rs.getString(WindowsPluginConstants.DEVICE_INFO)); - propertyMap.put(WindowsPluginConstants.DEVICE_NAME, rs.getString(WindowsPluginConstants.DEVICE_NAME)); - mobileDevice.setDeviceProperties(propertyMap); - mobileDevices.add(mobileDevice); - } - if (log.isDebugEnabled()) { - log.debug("All Windows device details have fetched from Windows database."); - } - return mobileDevices; - } catch (SQLException e) { - throw new MobileDeviceManagementDAOException("Error occurred while fetching all Windows device data", e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs); - } - } - -} 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/dao/impl/WindowsFeatureDAOImpl.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/dao/impl/WindowsFeatureDAOImpl.java deleted file mode 100644 index 007eedb78..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/dao/impl/WindowsFeatureDAOImpl.java +++ /dev/null @@ -1,267 +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.mobile.impl.windows.dao.impl; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; -import org.wso2.carbon.device.mgt.mobile.dao.MobileFeatureDAO; -import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil; -import org.wso2.carbon.device.mgt.mobile.dto.MobileFeature; -import org.wso2.carbon.device.mgt.mobile.impl.windows.dao.WindowsDAOFactory; -import org.wso2.carbon.device.mgt.mobile.impl.windows.dao.WindowsFeatureManagementDAOException; -import org.wso2.carbon.device.mgt.mobile.impl.windows.util.WindowsPluginConstants; - -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; - -/** - * Implement MobileFeatureDAO for Windows devices. - */ -public class WindowsFeatureDAOImpl implements MobileFeatureDAO { - - private static final Log log = LogFactory.getLog(WindowsFeatureDAOImpl.class); - - @Override - public boolean addFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException { - PreparedStatement stmt = null; - boolean status; - Connection conn; - try { - conn = WindowsDAOFactory.getConnection(); - String sql = "INSERT INTO WIN_FEATURE(CODE, NAME, DESCRIPTION) VALUES (?, ?, ?)"; - stmt = conn.prepareStatement(sql); - stmt.setString(1, mobileFeature.getCode()); - stmt.setString(2, mobileFeature.getName()); - stmt.setString(3, mobileFeature.getDescription()); - stmt.executeUpdate(); - status = true; - } catch (SQLException e) { - throw new WindowsFeatureManagementDAOException( - "Error occurred while adding windows feature '" + - mobileFeature.getName() + "' into the metadata repository", e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); - } - return status; - } - - @Override - public boolean addFeatures(List mobileFeatures) throws MobileDeviceManagementDAOException { - PreparedStatement stmt = null; - boolean status = false; - Connection conn; - try { - conn = WindowsDAOFactory.getConnection(); - stmt = conn.prepareStatement("INSERT INTO WIN_FEATURE(CODE, NAME, DESCRIPTION) VALUES (?, ?, ?)"); - for (MobileFeature mobileFeature : mobileFeatures) { - stmt.setString(1, mobileFeature.getCode()); - stmt.setString(2, mobileFeature.getName()); - stmt.setString(3, mobileFeature.getDescription()); - stmt.addBatch(); - } - stmt.executeBatch(); - status = true; - } catch (SQLException e) { - throw new WindowsFeatureManagementDAOException( - "Error occurred while adding windows features into the metadata repository", e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); - } - return status; - } - - @Override - public boolean updateFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException { - boolean status = false; - Connection conn; - PreparedStatement stmt = null; - try { - conn = WindowsDAOFactory.getConnection(); - String updateDBQuery = - "UPDATE WIN_FEATURE SET NAME = ?, DESCRIPTION = ?" + - "WHERE CODE = ?"; - stmt = conn.prepareStatement(updateDBQuery); - stmt.setString(1, mobileFeature.getName()); - stmt.setString(2, mobileFeature.getDescription()); - stmt.setString(3, mobileFeature.getCode()); - int rows = stmt.executeUpdate(); - if (rows > 0) { - status = true; - if (log.isDebugEnabled()) { - log.debug("Windows Feature " + mobileFeature.getCode() + " data has been " + - "modified."); - } - } - } catch (SQLException e) { - throw new WindowsFeatureManagementDAOException("Error occurred while updating the Windows Feature '" + - mobileFeature.getCode() + "' to the Windows db.", e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); - } - return status; - } - - @Override - public boolean deleteFeatureById(int mblFeatureId) throws MobileDeviceManagementDAOException { - PreparedStatement stmt = null; - boolean status = false; - Connection conn; - try { - conn = WindowsDAOFactory.getConnection(); - String sql = "DELETE FROM WIN_FEATURE WHERE ID = ?"; - stmt = conn.prepareStatement(sql); - stmt.setInt(1, mblFeatureId); - stmt.execute(); - status = true; - } catch (SQLException e) { - throw new WindowsFeatureManagementDAOException( - "Error occurred while deleting windows feature '" + - mblFeatureId + "' from Windows database.", e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); - } - return status; - } - - @Override - public boolean deleteFeatureByCode(String mblFeatureCode) throws MobileDeviceManagementDAOException { - PreparedStatement stmt = null; - boolean status = false; - Connection conn; - try { - conn = WindowsDAOFactory.getConnection(); - String sql = "DELETE FROM WIN_FEATURE WHERE CODE = ?"; - stmt = conn.prepareStatement(sql); - stmt.setString(1, mblFeatureCode); - stmt.execute(); - status = true; - } catch (SQLException e) { - throw new WindowsFeatureManagementDAOException( - "Error occurred while deleting windows feature '" + - mblFeatureCode + "' from Windows database.", e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); - } - return status; - } - - @Override - public MobileFeature getFeatureById(int mblFeatureId) throws MobileDeviceManagementDAOException { - PreparedStatement stmt = null; - ResultSet rs = null; - Connection conn; - try { - conn = WindowsDAOFactory.getConnection(); - String sql = "SELECT ID, CODE, NAME, DESCRIPTION FROM WIN_FEATURE WHERE ID = ?"; - stmt = conn.prepareStatement(sql); - stmt.setInt(1, mblFeatureId); - rs = stmt.executeQuery(); - MobileFeature mobileFeature = null; - if (rs.next()) { - mobileFeature = new MobileFeature(); - mobileFeature.setId(rs.getInt(WindowsPluginConstants.WINDOWS_FEATURE_ID)); - mobileFeature.setCode(rs.getString(WindowsPluginConstants.WINDOWS_FEATURE_CODE)); - mobileFeature.setName(rs.getString(WindowsPluginConstants.WINDOWS_FEATURE_NAME)); - mobileFeature.setDescription(rs.getString(WindowsPluginConstants.WINDOWS_FEATURE_DESCRIPTION)); - mobileFeature.setDeviceType( - DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); - } - return mobileFeature; - } catch (SQLException e) { - throw new WindowsFeatureManagementDAOException( - "Error occurred while retrieving windows feature '" + - mblFeatureId + "' from the Windows database.", e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs); - } - } - - @Override - public MobileFeature getFeatureByCode(String mblFeatureCode) throws MobileDeviceManagementDAOException { - PreparedStatement stmt = null; - ResultSet rs = null; - Connection conn; - try { - conn = WindowsDAOFactory.getConnection(); - String sql = "SELECT ID, CODE, NAME, DESCRIPTION FROM WIN_FEATURE WHERE CODE = ?"; - stmt = conn.prepareStatement(sql); - stmt.setString(1, mblFeatureCode); - rs = stmt.executeQuery(); - MobileFeature mobileFeature = null; - if (rs.next()) { - mobileFeature = new MobileFeature(); - mobileFeature.setId(rs.getInt(WindowsPluginConstants.WINDOWS_FEATURE_ID)); - mobileFeature.setCode(rs.getString(WindowsPluginConstants.WINDOWS_FEATURE_CODE)); - mobileFeature.setName(rs.getString(WindowsPluginConstants.WINDOWS_FEATURE_NAME)); - mobileFeature.setDescription(rs.getString(WindowsPluginConstants.WINDOWS_FEATURE_DESCRIPTION)); - mobileFeature.setDeviceType( - DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); - } - return mobileFeature; - } catch (SQLException e) { - throw new WindowsFeatureManagementDAOException( - "Error occurred while retrieving windows feature '" + - mblFeatureCode + "' from the Windows database.", e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs); - } - } - - @Override - public List getFeatureByDeviceType(String deviceType) throws MobileDeviceManagementDAOException { - return this.getAllFeatures(); - } - - @Override - public List getAllFeatures() throws MobileDeviceManagementDAOException { - PreparedStatement stmt = null; - ResultSet rs = null; - Connection conn; - List features = new ArrayList<>(); - try { - conn = WindowsDAOFactory.getConnection(); - String sql = "SELECT ID, CODE, NAME, DESCRIPTION FROM WIN_FEATURE"; - stmt = conn.prepareStatement(sql); - rs = stmt.executeQuery(); - MobileFeature mobileFeature; - while (rs.next()) { - mobileFeature = new MobileFeature(); - mobileFeature.setId(rs.getInt(WindowsPluginConstants.WINDOWS_FEATURE_ID)); - mobileFeature.setCode(rs.getString(WindowsPluginConstants.WINDOWS_FEATURE_CODE)); - mobileFeature.setName(rs.getString(WindowsPluginConstants.WINDOWS_FEATURE_NAME)); - mobileFeature.setDescription(rs.getString(WindowsPluginConstants.WINDOWS_FEATURE_DESCRIPTION)); - mobileFeature.setDeviceType( - DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); - features.add(mobileFeature); - } - return features; - } catch (SQLException e) { - throw new WindowsFeatureManagementDAOException("Error occurred while retrieving all " + - "windows features from the Windows database.", e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs); - } - } -} 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/util/WindowsPluginConstants.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/util/WindowsPluginConstants.java deleted file mode 100644 index edae380d4..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsPluginConstants.java +++ /dev/null @@ -1,48 +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.mobile.impl.windows.util; - -/** - * Define constance used by Windows plugin. - */ -public class WindowsPluginConstants { - - //properties related to database table WINDOWS_DEVICE - public static final String DEVICE_ID = "DEVICE_ID"; - public static final String CHANNEL_URI = "CHANNEL_URI"; - public static final String DEVICE_INFO = "DEVICE_INFO"; - public static final String IMEI = "IMEI"; - public static final String IMSI = "IMSI"; - public static final String OS_VERSION = "OS_VERSION"; - public static final String DEVICE_MODEL = "DEVICE_MODEL"; - public static final String VENDOR = "VENDOR"; - public static final String LATITUDE = "LATITUDE"; - public static final String LONGITUDE = "LONGITUDE"; - public static final String SERIAL = "SERIAL"; - public static final String MAC_ADDRESS = "MAC_ADDRESS"; - public static final String DEVICE_NAME = "DEVICE_NAME"; - - //Properties related to WIN_FEATURE table - public static final String WINDOWS_FEATURE_ID = "ID"; - public static final String WINDOWS_FEATURE_CODE = "CODE"; - public static final String WINDOWS_FEATURE_NAME = "NAME"; - public static final String WINDOWS_FEATURE_DESCRIPTION = "DESCRIPTION"; - - -} 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/util/WindowsPluginUtils.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/util/WindowsPluginUtils.java deleted file mode 100644 index a3b389c9b..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsPluginUtils.java +++ /dev/null @@ -1,58 +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.mobile.impl.windows.util; - -import org.wso2.carbon.device.mgt.common.license.mgt.License; -import org.wso2.carbon.device.mgt.mobile.impl.windows.WindowsDeviceManagementService; - -/** - * Contains utility method used by Windows plugin. - */ -public class WindowsPluginUtils { - - public static License getDefaultLicense() { - License license = new License(); - license.setName(WindowsDeviceManagementService.DEVICE_TYPE_WINDOWS); - license.setLanguage("en_US"); - license.setVersion("1.0.0"); - license.setText("This End User License Agreement (\"Agreement\") is a legal agreement between you (\"You\") " + - "and WSO2, Inc., regarding the enrollment of Your personal mobile device (\"Device\") in SoR's " + - "mobile device management program, and the loading to and removal from Your Device and Your use " + - "of certain applications and any associated software and user documentation, whether provided in " + - "\"online\" or electronic format, used in connection with the operation of or provision of services " + - "to WSO2, Inc., BY SELECTING \"I ACCEPT\" DURING INSTALLATION, YOU ARE ENROLLING YOUR DEVICE, AND " + - "THEREBY AUTHORIZING SOR OR ITS AGENTS TO INSTALL, UPDATE AND REMOVE THE APPS FROM YOUR DEVICE AS " + - "DESCRIBED IN THIS AGREEMENT. YOU ARE ALSO EXPLICITLY ACKNOWLEDGING AND AGREEING THAT (1) THIS IS " + - "A BINDING CONTRACT AND (2) YOU HAVE READ AND AGREE TO THE TERMS OF THIS AGREEMENT.\n" + - "\n" + - "IF YOU DO NOT ACCEPT THESE TERMS, DO NOT ENROLL YOUR DEVICE AND DO NOT PROCEED ANY FURTHER.\n" + - "\n" + - "You agree that: (1) You understand and agree to be bound by the terms and conditions contained " + - "in this Agreement, and (2) You are at least 21 years old and have the legal capacity to enter " + - "into this Agreement as defined by the laws of Your jurisdiction. SoR shall have the right, " + - "without prior notice, to terminate or suspend (i) this Agreement, (ii) the enrollment of Your " + - "Device, or (iii) the functioning of the Apps in the event of a violation of this Agreement or " + - "the cessation of Your relationship with SoR (including termination of Your employment if You are " + - "an employee or expiration or termination of Your applicable franchise or supply agreement if You " + - "are a franchisee of or supplier to the WSO2 WSO2, Inc., system). SoR expressly reserves all " + - "rights not expressly granted herein."); - return license; - } -} 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/util/WindowsUtils.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/util/WindowsUtils.java deleted file mode 100644 index e4ba56346..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsUtils.java +++ /dev/null @@ -1,50 +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.mobile.impl.windows.util; - -import org.wso2.carbon.device.mgt.common.Feature; -import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice; - -import java.sql.ResultSet; -import java.sql.SQLException; - -/** - * Contains utility methods which are used by Windows plugin. - */ -public class WindowsUtils { - - public static MobileDevice loadMobileDevices(ResultSet rs) throws SQLException { - MobileDevice mobileDevice = new MobileDevice(); - mobileDevice.setMobileDeviceId(rs.getString(WindowsPluginConstants.DEVICE_ID)); - mobileDevice.setImei(rs.getString(WindowsPluginConstants.IMEI)); - mobileDevice.setImsi(rs.getString(WindowsPluginConstants.IMSI)); - mobileDevice.setModel(rs.getString(WindowsPluginConstants.DEVICE_MODEL)); - mobileDevice.setVendor(rs.getString(WindowsPluginConstants.VENDOR)); - mobileDevice.setLatitude(rs.getString(WindowsPluginConstants.LATITUDE)); - mobileDevice.setLongitude(rs.getString(WindowsPluginConstants.LONGITUDE)); - mobileDevice.setSerial(rs.getString(WindowsPluginConstants.SERIAL)); - mobileDevice.setOsVersion(rs.getString(WindowsPluginConstants.LATITUDE)); - return mobileDevice; - } - - public static Feature getMobileFeature() { - Feature feature = new Feature(); - return feature; - } -} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementDataHolder.java b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementDataHolder.java index 869904e81..6444afd90 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementDataHolder.java +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementDataHolder.java @@ -19,7 +19,6 @@ package org.wso2.carbon.device.mgt.mobile.internal; import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; -import org.wso2.carbon.device.mgt.mobile.impl.android.gcm.GCMService; import org.wso2.carbon.registry.core.service.RegistryService; /** @@ -29,7 +28,6 @@ public class MobileDeviceManagementDataHolder { private RegistryService registryService; private DeviceManagementService androidDeviceManagementService; - private GCMService gcmService; private static MobileDeviceManagementDataHolder thisInstance = new MobileDeviceManagementDataHolder(); @@ -57,11 +55,4 @@ public class MobileDeviceManagementDataHolder { this.androidDeviceManagementService = androidDeviceManagementService; } - public GCMService getGCMService() { - return gcmService; - } - - public void setGCMService(GCMService gcmService) { - this.gcmService = gcmService; - } } diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java index 92404b67a..5b7f85931 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java @@ -23,20 +23,13 @@ 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.mobile.common.MobileDeviceMgtPluginException; import org.wso2.carbon.device.mgt.mobile.config.MobileDeviceConfigurationManager; import org.wso2.carbon.device.mgt.mobile.config.MobileDeviceManagementConfig; import org.wso2.carbon.device.mgt.mobile.config.datasource.MobileDataSourceConfig; import org.wso2.carbon.device.mgt.mobile.dao.AbstractMobileDeviceManagementDAOFactory; import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil; -import org.wso2.carbon.device.mgt.mobile.impl.android.AndroidDeviceManagementService; -import org.wso2.carbon.device.mgt.mobile.impl.android.AndroidPolicyMonitoringService; -import org.wso2.carbon.device.mgt.mobile.impl.android.gcm.GCMService; -import org.wso2.carbon.device.mgt.mobile.impl.windows.WindowsDeviceManagementService; -import org.wso2.carbon.device.mgt.mobile.impl.windows.WindowsPolicyMonitoringService; import org.wso2.carbon.ndatasource.core.DataSourceService; -import org.wso2.carbon.policy.mgt.common.spi.PolicyMonitoringService; import org.wso2.carbon.registry.core.service.RegistryService; import java.util.Map; @@ -60,8 +53,6 @@ import java.util.Map; */ public class MobileDeviceManagementServiceComponent { - private ServiceRegistration androidServiceRegRef; - private ServiceRegistration windowsServiceRegRef; private ServiceRegistration gcmServiceRegRef; private static final Log log = LogFactory.getLog(MobileDeviceManagementServiceComponent.class); @@ -100,30 +91,7 @@ public class MobileDeviceManagementServiceComponent { log.error("Exception occurred while initializing mobile device management database schema", e); } } - DeviceManagementService androidDeviceManagementService = new AndroidDeviceManagementService(); - GCMService gcmService = new GCMService(); - androidServiceRegRef = - bundleContext.registerService(DeviceManagementService.class.getName(), - androidDeviceManagementService, null); - windowsServiceRegRef = - bundleContext.registerService(DeviceManagementService.class.getName(), - new WindowsDeviceManagementService(), null); - - gcmServiceRegRef = - bundleContext.registerService(GCMService.class.getName(), gcmService, null); - - - // Policy management service - - bundleContext.registerService(PolicyMonitoringService.class, - new AndroidPolicyMonitoringService(), null); - bundleContext.registerService(PolicyMonitoringService.class, - new WindowsPolicyMonitoringService(), null); - - MobileDeviceManagementDataHolder.getInstance().setAndroidDeviceManagementService( - androidDeviceManagementService); - MobileDeviceManagementDataHolder.getInstance().setGCMService(gcmService); if (log.isDebugEnabled()) { log.debug("Mobile Device Management Service Component has been successfully activated"); } @@ -137,12 +105,6 @@ public class MobileDeviceManagementServiceComponent { log.debug("De-activating Mobile Device Management Service Component"); } try { - if (androidServiceRegRef != null) { - androidServiceRegRef.unregister(); - } - if (windowsServiceRegRef != null) { - windowsServiceRegRef.unregister(); - } if (gcmServiceRegRef != null) { gcmServiceRegRef.unregister(); } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/WindowsAPIUtils.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/WindowsAPIUtils.java index 6b8462e9f..13f115240 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/WindowsAPIUtils.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/WindowsAPIUtils.java @@ -27,7 +27,7 @@ import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration; +import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementService; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; @@ -165,7 +165,7 @@ public class WindowsAPIUtils { getDeviceManagementService().updateOperation(deviceIdentifier, operation); } - public static TenantConfiguration getTenantConfiguration() throws DeviceManagementException { + public static PlatformConfiguration getTenantConfiguration() throws DeviceManagementException { return getDeviceManagementService().getConfiguration( DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/configurationmgtservice/ConfigurationMgtService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/configurationmgtservice/ConfigurationMgtService.java index cbf499680..018db96e5 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/configurationmgtservice/ConfigurationMgtService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/configurationmgtservice/ConfigurationMgtService.java @@ -22,7 +22,7 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; -import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration; +import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsConfigurationException; import org.wso2.carbon.mdm.mobileservices.windows.common.util.Message; @@ -58,7 +58,7 @@ public interface ConfigurationMgtService { @ApiResponse(code = 201, message = "Windows platform configuration saved successfully"), @ApiResponse(code = 500, message = "Internal Server Error") }) - Message ConfigureSettings(TenantConfiguration configuration) throws WindowsConfigurationException; + Message ConfigureSettings(PlatformConfiguration configuration) throws WindowsConfigurationException; /** * Retrieve Tenant configurations according to the device type. @@ -71,13 +71,13 @@ public interface ConfigurationMgtService { httpMethod = "GET", value = "Getting Windows Platform Configurations", notes = "Get the Windows platform configuration details using this REST API", - response = TenantConfiguration.class + response = PlatformConfiguration.class ) @ApiResponses(value = { @ApiResponse(code = 200, message = "Get Windows Configurations"), @ApiResponse(code = 500, message = "Server Error") }) - TenantConfiguration getConfiguration() throws WindowsConfigurationException; + PlatformConfiguration getConfiguration() throws WindowsConfigurationException; /** * Update Tenant Configurations for the specific Device type. @@ -99,5 +99,5 @@ public interface ConfigurationMgtService { @ApiResponse(code = 500, message = "Error occurred while modifying configuration settings of " + "windows platform") }) - Message updateConfiguration(TenantConfiguration configuration) throws WindowsConfigurationException; + Message updateConfiguration(PlatformConfiguration configuration) throws WindowsConfigurationException; } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/configurationmgtservice/impl/ConfigurationMgtServiceImpl.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/configurationmgtservice/impl/ConfigurationMgtServiceImpl.java index 1fd0b2c84..1c7734d42 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/configurationmgtservice/impl/ConfigurationMgtServiceImpl.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/configurationmgtservice/impl/ConfigurationMgtServiceImpl.java @@ -23,7 +23,8 @@ import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry; -import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration; +import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; +import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; import org.wso2.carbon.device.mgt.common.license.mgt.License; import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants; import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsConfigurationException; @@ -54,7 +55,7 @@ public class ConfigurationMgtServiceImpl { * @throws WindowsConfigurationException */ @POST - public Message ConfigureSettings(TenantConfiguration configuration) throws WindowsConfigurationException { + public Message ConfigureSettings(PlatformConfiguration configuration) throws WindowsConfigurationException { Message responseMsg = new Message(); ConfigurationEntry licenseEntry = null; String message; @@ -106,15 +107,15 @@ public class ConfigurationMgtServiceImpl { * @throws WindowsConfigurationException */ @GET - public TenantConfiguration getConfiguration() throws WindowsConfigurationException { + public PlatformConfiguration getConfiguration() throws WindowsConfigurationException { String msg; - TenantConfiguration tenantConfiguration = null; + PlatformConfiguration PlatformConfiguration = null; try { if (WindowsAPIUtils.getDeviceManagementService(). getConfiguration(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS) != null) { - tenantConfiguration = WindowsAPIUtils.getDeviceManagementService(). + PlatformConfiguration = WindowsAPIUtils.getDeviceManagementService(). getConfiguration(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); - List configs = tenantConfiguration.getConfiguration(); + List configs = PlatformConfiguration.getConfiguration(); ConfigurationEntry entry = new ConfigurationEntry(); License license = WindowsAPIUtils.getDeviceManagementService().getLicense( DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS, PluginConstants. @@ -124,7 +125,7 @@ public class ConfigurationMgtServiceImpl { entry.setName(PluginConstants.TenantConfigProperties.LICENSE_KEY); entry.setValue(license.getText()); configs.add(entry); - tenantConfiguration.setConfiguration(configs); + PlatformConfiguration.setConfiguration(configs); } } } catch (DeviceManagementException e) { @@ -132,7 +133,7 @@ public class ConfigurationMgtServiceImpl { log.error(msg, e); throw new WindowsConfigurationException(msg, e); } - return tenantConfiguration; + return PlatformConfiguration; } /** @@ -143,7 +144,7 @@ public class ConfigurationMgtServiceImpl { * @throws WindowsConfigurationException */ @PUT - public Message updateConfiguration(TenantConfiguration configuration) throws WindowsConfigurationException { + public Message updateConfiguration(PlatformConfiguration configuration) throws WindowsConfigurationException { String message; Message responseMsg = new Message(); ConfigurationEntry licenseEntry = null; diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/impl/CertificateEnrollmentServiceImpl.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/impl/CertificateEnrollmentServiceImpl.java index b4e7a54ec..b21304e8d 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/impl/CertificateEnrollmentServiceImpl.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/impl/CertificateEnrollmentServiceImpl.java @@ -32,7 +32,7 @@ import org.wso2.carbon.certificate.mgt.core.service.CertificateManagementService import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry; -import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration; +import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants; import org.wso2.carbon.mdm.mobileservices.windows.common.beans.CacheEntry; import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.CertificateGenerationException; @@ -372,7 +372,7 @@ public class CertificateEnrollmentServiceImpl implements CertificateEnrollmentSe */ private List getTenantConfigurationData() throws DeviceManagementException { if (WindowsAPIUtils.getTenantConfiguration() != null) { - TenantConfiguration configuration = WindowsAPIUtils.getTenantConfiguration(); + PlatformConfiguration configuration = WindowsAPIUtils.getTenantConfiguration(); return configuration.getConfiguration(); } else { return null; diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.type-view/public/css/styles.css b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.type-view/public/css/styles.css new file mode 100644 index 000000000..04e2a2611 --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.type-view/public/css/styles.css @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2016, 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. + */ +.circle { + background: none repeat scroll 0 0 #191919; + border-radius: 50px; + height: 50px; + padding: 10px; + width: 50px; + color: #fff; +} +.padding-top-double { + padding-top: 20px; +} +.padding-double { + padding: 20px; +} +.grey { + color: #333; +} +hr { + display: block; + height: 1px; + border: 0; + border-top: 1px solid #7f7f7f; + margin: 1em 0; + padding: 0; + opacity: 0.2; +} +.light-grey { + color: #7c7c7c; +} +.uppercase { + text-transform: uppercase; +} +.grey-bg { + background-color: #f6f4f4; +} + +.doc-link { + background: #11375B; + padding: 20px; + color: white; + margin-top: 0; +} + +.doc-link a { + color: white; +} \ No newline at end of file diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.type-view/type-view.hbs b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.type-view/type-view.hbs index 1c310bdf2..638a5e26d 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.type-view/type-view.hbs +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.type-view/type-view.hbs @@ -16,7 +16,7 @@ under the License. }}
-

Windows Mobile

+

Windows Mobile


@@ -24,28 +24,26 @@
- +

What it Does

-
+

Connect and manage your Windows device with WSO2 IoT Server.


What You Need


    -
  • STEP 01   Windows - Mobile. -
  • -
  • STEP 02   Go ahead - and click [Enroll Device]. +
  • STEP 01   Windows Mobile.
  • +
  • STEP 02   Go ahead and click [Enroll + Device].
  • -
  • STEP 03   Proceed - to [Prepare] section. +
  • STEP 03   Proceed to [Prepare] + section.

@@ -53,7 +51,7 @@ Enroll Device -

+

@@ -61,11 +59,8 @@
  • 01 Scan QR code.
  • -
  • 02 Follow instructions in wizard. -
  • -
  • 03 Configure your workspace - account -
  • +
  • 02 Follow instructions in wizard.
  • +
  • 03 Configure your workspace account

@@ -80,12 +75,12 @@
-
+