diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/pom.xml deleted file mode 100644 index c91d9b7df..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/pom.xml +++ /dev/null @@ -1,173 +0,0 @@ - - - - - - - device-mgt - org.wso2.carbon.devicemgt-plugins - 2.1.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.mobile.impl - 2.1.0-SNAPSHOT - bundle - WSO2 Carbon - Mobile Device Management Impl - WSO2 Carbon - Mobile Device Management Impl - http://wso2.org - - - - - org.apache.felix - maven-scr-plugin - - - org.apache.felix - maven-bundle-plugin - 1.4.0 - true - - - ${project.artifactId} - ${project.artifactId} - ${carbon.mobile.device.mgt.version} - Device Management Mobile Impl Bundle - org.wso2.carbon.device.mgt.mobile.internal - - org.osgi.framework, - org.osgi.service.component, - org.apache.commons.logging, - javax.xml.bind.*, - javax.naming, - javax.sql, - javax.xml.parsers, - org.w3c.dom, - org.wso2.carbon.context, - org.wso2.carbon.utils.*, - org.wso2.carbon.device.mgt.common.*, - org.wso2.carbon.ndatasource.core, - org.wso2.carbon.policy.mgt.common.*, - org.wso2.carbon.registry.core, - org.wso2.carbon.registry.core.service, - org.wso2.carbon.registry.core.session, - org.wso2.carbon.registry.api, - org.wso2.carbon.device.mgt.extensions.license.mgt.registry, - com.google.gson.*, - - - !org.wso2.carbon.device.mgt.mobile.internal, - !org.wso2.carbon.device.mgt.mobile.impl, - org.wso2.carbon.device.mgt.mobile.*, - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.18 - - - file:src/test/resources/log4j.properties - - - - src/test/resources/testng.xml - - - - - - - - - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.osgi - org.eclipse.osgi.services - - - org.wso2.carbon - org.wso2.carbon.core - - - org.wso2.carbon - org.wso2.carbon.logging - - - org.wso2.carbon - org.wso2.carbon.utils - - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.common - - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.extensions - - - org.wso2.carbon - org.wso2.carbon.ndatasource.core - - - org.wso2.carbon.devicemgt - org.wso2.carbon.policy.mgt.common - - - org.wso2.carbon.devicemgt - org.wso2.carbon.policy.mgt.core - - - org.wso2.carbon - org.wso2.carbon.registry.api - - - org.wso2.carbon - org.wso2.carbon.registry.core - - - org.testng - testng - - - org.apache.tomcat.wso2 - jdbc-pool - - - com.h2database.wso2 - h2-database-engine - test - - - com.google.code.gson - gson - - - com.google.android.gcm - gcm-server - - - diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/AbstractMobileOperationManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/AbstractMobileOperationManager.java deleted file mode 100644 index 1bf5322da..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/AbstractMobileOperationManager.java +++ /dev/null @@ -1,41 +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; - -import org.wso2.carbon.device.mgt.common.*; -import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; -import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; -import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager; - -import java.util.List; - -public abstract class AbstractMobileOperationManager implements OperationManager { - - @Override - public List getOperations(DeviceIdentifier deviceIdentifier) throws OperationManagementException { - return null; - } - - @Override - public int addOperation(Operation operation, List devices) throws - OperationManagementException { - return 1; - } - -} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/DataSourceNotAvailableException.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/DataSourceNotAvailableException.java deleted file mode 100644 index 5a9e5b8f4..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/DataSourceNotAvailableException.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * * - * * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * - */ -package org.wso2.carbon.device.mgt.mobile; - -public class DataSourceNotAvailableException extends RuntimeException { - - private String message; - private static final long serialVersionUID = 2021891706072918866L; - - public DataSourceNotAvailableException(String message, Exception nestedException) { - super(message, nestedException); - setErrorMessage(message); - } - - public DataSourceNotAvailableException(String message, Throwable cause) { - super(message, cause); - setErrorMessage(message); - } - - public DataSourceNotAvailableException(String message) { - super(message); - setErrorMessage(message); - } - - public DataSourceNotAvailableException(Throwable cause) { - super(cause); - } - - public String getMessage() { - return message; - } - - public void setErrorMessage(String errorMessage) { - this.message = errorMessage; - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/common/MobileDeviceMgtPluginException.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/common/MobileDeviceMgtPluginException.java deleted file mode 100644 index ef2871c28..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/common/MobileDeviceMgtPluginException.java +++ /dev/null @@ -1,57 +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.common; - - -public class MobileDeviceMgtPluginException extends Exception{ - - private static final long serialVersionUID = -2297311387874900305L; - private String errorMessage; - - public String getErrorMessage() { - return errorMessage; - } - - public void setErrorMessage(String errorMessage) { - this.errorMessage = errorMessage; - } - - public MobileDeviceMgtPluginException(String msg, Exception nestedEx) { - super(msg, nestedEx); - setErrorMessage(msg); - } - - public MobileDeviceMgtPluginException(String message, Throwable cause) { - super(message, cause); - setErrorMessage(message); - } - - public MobileDeviceMgtPluginException(String msg) { - super(msg); - setErrorMessage(msg); - } - - public MobileDeviceMgtPluginException() { - super(); - } - - public MobileDeviceMgtPluginException(Throwable cause) { - super(cause); - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/common/MobilePluginConstants.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/common/MobilePluginConstants.java deleted file mode 100644 index 67e793fa5..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/common/MobilePluginConstants.java +++ /dev/null @@ -1,29 +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.common; - -public class MobilePluginConstants { - public static final String MOBILE_DB_SCRIPTS_FOLDER = "cdm"; - public static final String MOBILE_CONFIG_REGISTRY_ROOT = "/_system/config"; - - public static final String MEDIA_TYPE_XML = "application/xml"; - public static final String CHARSET_UTF8 = "UTF8"; - public static final String LANGUAGE_CODE_ENGLISH_US = "en_US"; - public static final String LANGUAGE_CODE_ENGLISH_UK = "en_UK"; - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/MobileDeviceConfigurationManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/MobileDeviceConfigurationManager.java deleted file mode 100644 index 07123434d..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/MobileDeviceConfigurationManager.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2014, 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.config; - -import org.w3c.dom.Document; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil; -import org.wso2.carbon.device.mgt.mobile.config.datasource.MobileDataSourceConfig; -import org.wso2.carbon.utils.CarbonUtils; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.Unmarshaller; -import java.io.File; - -/** - * Class responsible for the mobile device manager configuration initialization. - */ -public class MobileDeviceConfigurationManager { - - private static final String MOBILE_DEVICE_CONFIG_XML_NAME = "mobile-config.xml"; - private static final String MOBILE_DEVICE_PLUGIN_DIRECTORY = "mobile"; - private static final String DEVICE_MGT_PLUGIN_CONFIGS_DIRECTORY = "device-mgt-plugin-configs"; - private MobileDeviceManagementConfig currentMobileDeviceConfig; - private static MobileDeviceConfigurationManager mobileDeviceConfigManager; - - private final String mobileDeviceMgtConfigXMLPath = - CarbonUtils.getEtcCarbonConfigDirPath() + File.separator + - DEVICE_MGT_PLUGIN_CONFIGS_DIRECTORY + - File.separator + - MOBILE_DEVICE_PLUGIN_DIRECTORY + File.separator + MOBILE_DEVICE_CONFIG_XML_NAME; - - public static MobileDeviceConfigurationManager getInstance() { - if (mobileDeviceConfigManager == null) { - synchronized (MobileDeviceConfigurationManager.class) { - if (mobileDeviceConfigManager == null) { - mobileDeviceConfigManager = new MobileDeviceConfigurationManager(); - } - } - } - return mobileDeviceConfigManager; - } - - public synchronized void initConfig() throws DeviceManagementException { - try { - File mobileDeviceMgtConfig = new File(mobileDeviceMgtConfigXMLPath); - Document doc = MobileDeviceManagementUtil.convertToDocument(mobileDeviceMgtConfig); - JAXBContext mobileDeviceMgmtContext = - JAXBContext.newInstance(MobileDeviceManagementConfig.class); - Unmarshaller unmarshaller = mobileDeviceMgmtContext.createUnmarshaller(); - this.currentMobileDeviceConfig = - (MobileDeviceManagementConfig) unmarshaller.unmarshal(doc); - } catch (Exception e) { - throw new DeviceManagementException( - "Error occurred while initializing Mobile Device Management config", e); - } - } - - public MobileDeviceManagementConfig getMobileDeviceManagementConfig() { - return currentMobileDeviceConfig; - } - - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/MobileDeviceManagementConfig.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/MobileDeviceManagementConfig.java deleted file mode 100644 index ced99f955..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/MobileDeviceManagementConfig.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2014, 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.config; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * Represents Mobile Device Mgt configuration. - */ -@XmlRootElement(name = "MobileDeviceMgtConfiguration") -public final class MobileDeviceManagementConfig { - - private MobileDeviceManagementRepository mobileDeviceMgtRepository; - - @XmlElement(name = "ManagementRepository", nillable = false) - public MobileDeviceManagementRepository getMobileDeviceMgtRepository() { - return mobileDeviceMgtRepository; - } - - public void setMobileDeviceMgtRepository( - MobileDeviceManagementRepository mobileDeviceMgtRepository) { - this.mobileDeviceMgtRepository = mobileDeviceMgtRepository; - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/MobileDeviceManagementRepository.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/MobileDeviceManagementRepository.java deleted file mode 100644 index 88369dd84..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/MobileDeviceManagementRepository.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2014, 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.config; - -import org.wso2.carbon.device.mgt.mobile.config.datasource.DataSourceConfigAdapter; -import org.wso2.carbon.device.mgt.mobile.config.datasource.MobileDataSourceConfig; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import java.util.List; -import java.util.Map; - -/** - * Class for holding management repository data. - */ -@XmlRootElement(name = "ManagementRepository") -public class MobileDeviceManagementRepository { - - private Map mobileDataSourceConfigMap; - private List mobileDataSourceConfigs; - - public MobileDataSourceConfig getMobileDataSourceConfig(String provider) { - return mobileDataSourceConfigMap.get(provider); - } - - @XmlElement(name = "DataSourceConfigurations") - @XmlJavaTypeAdapter(DataSourceConfigAdapter.class) - public Map getMobileDataSourceConfigMap() { - return mobileDataSourceConfigMap; - } - - public void setMobileDataSourceConfigMap(Map mobileDataSourceConfigMap) { - this.mobileDataSourceConfigMap = mobileDataSourceConfigMap; - } - - public List getMobileDataSourceConfigs() { - return (List) mobileDataSourceConfigMap.values(); - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/DataSourceConfigAdapter.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/DataSourceConfigAdapter.java deleted file mode 100644 index 71675785c..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/DataSourceConfigAdapter.java +++ /dev/null @@ -1,51 +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.config.datasource; - -import javax.xml.bind.annotation.adapters.XmlAdapter; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class DataSourceConfigAdapter - extends XmlAdapter> { - - @Override - public Map unmarshal(MobileDataSourceConfigurations mobileDataSourceConfigurations) - throws Exception { - - Map mobileDataSourceConfigMap = new HashMap(); - for (MobileDataSourceConfig mobileDataSourceConfig : mobileDataSourceConfigurations - .getMobileDataSourceConfigs()) { - mobileDataSourceConfigMap.put(mobileDataSourceConfig.getType(), mobileDataSourceConfig); - } - return mobileDataSourceConfigMap; - } - - @Override - public MobileDataSourceConfigurations marshal(Map mobileDataSourceConfigMap) - throws Exception { - - MobileDataSourceConfigurations mobileDataSourceConfigurations = new MobileDataSourceConfigurations(); - mobileDataSourceConfigurations.setMobileDataSourceConfigs( - (List) mobileDataSourceConfigMap.values()); - - return mobileDataSourceConfigurations; - } -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/JNDILookupDefinition.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/JNDILookupDefinition.java deleted file mode 100644 index 603adcedd..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/JNDILookupDefinition.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2014, 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.config.datasource; - -import javax.xml.bind.annotation.*; -import java.util.List; - -/** - * Class for hold JndiLookupDefinition of mobile-config.xml at parsing with JAXB. - */ -@XmlRootElement(name = "JndiLookupDefinition") -public class JNDILookupDefinition { - - private String jndiName; - private List jndiProperties; - - @XmlElement(name = "Name", nillable = false) - public String getJndiName() { - return jndiName; - } - - public void setJndiName(String jndiName) { - this.jndiName = jndiName; - } - - @XmlElementWrapper(name = "Environment", nillable = false) - @XmlElement(name = "Property", nillable = false) - public List getJndiProperties() { - return jndiProperties; - } - - public void setJndiProperties(List jndiProperties) { - this.jndiProperties = jndiProperties; - } - - @XmlRootElement(name = "Property") - public static class JNDIProperty { - - private String name; - - private String value; - - @XmlAttribute(name = "Name") - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @XmlValue - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - } - -} - diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/MobileDataSourceConfig.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/MobileDataSourceConfig.java deleted file mode 100644 index 869aaf12e..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/MobileDataSourceConfig.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2014, 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.config.datasource; - -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * Class for holding data source configuration in mobile-config.xml at parsing with JAXB. - */ -@XmlRootElement(name = "DataSourceConfiguration") -public class MobileDataSourceConfig { - - private JNDILookupDefinition jndiLookupDefinition; - private String type; - - @XmlElement(name = "JndiLookupDefinition", nillable = true) - public JNDILookupDefinition getJndiLookupDefinition() { - return jndiLookupDefinition; - } - - public void setJndiLookupDefinition(JNDILookupDefinition jndiLookupDefinition) { - this.jndiLookupDefinition = jndiLookupDefinition; - } - - @XmlAttribute(name = "type") - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/MobileDataSourceConfigurations.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/MobileDataSourceConfigurations.java deleted file mode 100644 index 17e80f5bf..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/MobileDataSourceConfigurations.java +++ /dev/null @@ -1,41 +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.config.datasource; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import java.util.List; - -@XmlRootElement(name = "DataSourceConfigurations") -@XmlAccessorType(XmlAccessType.FIELD) -public class MobileDataSourceConfigurations { - - @XmlElement(name = "DataSourceConfiguration", nillable = true) - private List mobileDataSourceConfigs; - - public List getMobileDataSourceConfigs() { - return mobileDataSourceConfigs; - } - - public void setMobileDataSourceConfigs(List mobileDataSourceConfigs) { - this.mobileDataSourceConfigs = mobileDataSourceConfigs; - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/AbstractMobileDeviceManagementDAOFactory.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/AbstractMobileDeviceManagementDAOFactory.java deleted file mode 100644 index 32bcb8de7..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/AbstractMobileDeviceManagementDAOFactory.java +++ /dev/null @@ -1,102 +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.dao; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.mobile.common.MobileDeviceMgtPluginException; -import org.wso2.carbon.device.mgt.mobile.config.datasource.JNDILookupDefinition; -import org.wso2.carbon.device.mgt.mobile.config.datasource.MobileDataSourceConfig; -import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil; - -import javax.sql.DataSource; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.List; -import java.util.Map; - -/** - * Factory class used to create MobileDeviceManagement related DAO objects. - */ -public abstract class AbstractMobileDeviceManagementDAOFactory implements MobileDeviceManagementDAOFactory { - - private static final Log log = LogFactory.getLog(AbstractMobileDeviceManagementDAOFactory.class); - private static Map dataSourceMap = new HashMap<>(); - private static boolean isInitialized; - - public static void init(Map mobileDataSourceConfigMap) - throws MobileDeviceMgtPluginException { - DataSource dataSource; - for (String pluginType : mobileDataSourceConfigMap.keySet()) { - if (dataSourceMap.get(pluginType) == null) { - dataSource = AbstractMobileDeviceManagementDAOFactory.resolveDataSource(mobileDataSourceConfigMap.get - (pluginType)); - dataSourceMap.put(pluginType, dataSource); - } - } - isInitialized = true; - } - - public static void init(String key, MobileDataSourceConfig mobileDataSourceConfig) throws - MobileDeviceMgtPluginException { - DataSource dataSource = AbstractMobileDeviceManagementDAOFactory.resolveDataSource(mobileDataSourceConfig); - dataSourceMap.put(key, dataSource); - } - - /** - * Resolve data source from the data source definition. - * - * @param config Mobile data source configuration - * @return data source resolved from the data source definition - */ - public static DataSource resolveDataSource(MobileDataSourceConfig config) { - DataSource dataSource = null; - if (config == null) { - throw new RuntimeException("Device Management Repository data source configuration " + - "is null and thus, is not initialized"); - } - JNDILookupDefinition jndiConfig = config.getJndiLookupDefinition(); - if (jndiConfig != null) { - if (log.isDebugEnabled()) { - log.debug("Initializing Device Management Repository data source using the JNDI " + - "Lookup Definition"); - } - List jndiPropertyList = - jndiConfig.getJndiProperties(); - if (jndiPropertyList != null) { - Hashtable jndiProperties = new Hashtable(); - for (JNDILookupDefinition.JNDIProperty prop : jndiPropertyList) { - jndiProperties.put(prop.getName(), prop.getValue()); - } - dataSource = - MobileDeviceManagementDAOUtil - .lookupDataSource(jndiConfig.getJndiName(), jndiProperties); - } else { - dataSource = MobileDeviceManagementDAOUtil - .lookupDataSource(jndiConfig.getJndiName(), null); - } - } - return dataSource; - } - - public static Map getDataSourceMap() { - return dataSourceMap; - } - -} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceDAO.java deleted file mode 100644 index 161594273..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceDAO.java +++ /dev/null @@ -1,74 +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.dao; - -import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice; -import java.util.List; - -/** - * This class represents the key operations associated with persisting mobile-device related - * information. - */ -public interface MobileDeviceDAO { - - /** - * Fetches a MobileDevice from MDM database. - * - * @param mblDeviceId Id of the Mobile-Device. - * @return MobileDevice corresponding to given device-id. - * @throws MobileDeviceManagementDAOException - */ - MobileDevice getMobileDevice(String mblDeviceId) throws MobileDeviceManagementDAOException; - - /** - * Adds a new MobileDevice to the MDM database. - * - * @param mobileDevice MobileDevice to be added. - * @return The status of the operation. - * @throws MobileDeviceManagementDAOException - */ - boolean addMobileDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException; - - /** - * Updates MobileDevice information in MDM database. - * - * @param mobileDevice MobileDevice to be updated. - * @return The status of the operation. - * @throws MobileDeviceManagementDAOException - */ - boolean updateMobileDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException; - - /** - * Deletes a given MobileDevice from MDM database. - * - * @param mblDeviceId Id of MobileDevice to be deleted. - * @return The status of the operation. - * @throws MobileDeviceManagementDAOException - */ - boolean deleteMobileDevice(String mblDeviceId) throws MobileDeviceManagementDAOException; - - /** - * Fetches all MobileDevices from MDM database. - * - * @return List of MobileDevices. - * @throws MobileDeviceManagementDAOException - */ - List getAllMobileDevices() throws MobileDeviceManagementDAOException; - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOException.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOException.java deleted file mode 100644 index 0b04818d9..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOException.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.dao; - -/** - * Custom exception class for mobile device specific data access related exceptions. - */ -public class MobileDeviceManagementDAOException extends Exception { - - 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 MobileDeviceManagementDAOException(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 MobileDeviceManagementDAOException(String message, Throwable cause) { - super(message, cause); - setErrorMessage(message); - } - - /** - * Constructs a new MobileDeviceManagementDAOException with the specified detail message. - * - * @param message the detail message. - */ - public MobileDeviceManagementDAOException(String message) { - super(message); - setErrorMessage(message); - } - - /** - * Constructs a new MobileDeviceManagementDAOException with the specified and cause. - * - * @param cause the cause of this exception. - */ - public MobileDeviceManagementDAOException(Throwable cause) { - super(cause); - } - - public String getMessage() { - return message; - } - - public void setErrorMessage(String errorMessage) { - this.message = errorMessage; - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileFeatureDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileFeatureDAO.java deleted file mode 100644 index 55c77424b..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileFeatureDAO.java +++ /dev/null @@ -1,110 +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.dao; - -import org.wso2.carbon.device.mgt.mobile.dto.MobileFeature; - -import java.util.List; - -/** - * This class represents the key operations associated with persisting mobile feature related - * information. - */ -public interface MobileFeatureDAO { - - /** - * Adds a new MobileFeature to Mobile-Feature table. - * - * @param mobileFeature MobileFeature object that holds data related to the feature to be inserted. - * @return boolean status of the operation. - * @throws MobileDeviceManagementDAOException - */ - boolean addFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException; - - /** - * Adda a list of MobileFeatures to Mobile-Feature table. - * - * @param mobileFeatures List of MobileFeature objects. - * @return boolean status of the operation. - * @throws MobileDeviceManagementDAOException - */ - boolean addFeatures(List mobileFeatures) throws MobileDeviceManagementDAOException; - - /** - * Updates a MobileFeature in Mobile-Feature table. - * - * @param mobileFeature MobileFeature object that holds data has to be updated. - * @return The status of the operation. - * @throws MobileDeviceManagementDAOException - */ - boolean updateFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException; - - /** - * Deletes a MobileFeature from Mobile-Feature table when the feature id is given. - * - * @param mblFeatureId MobileFeature id of the MobileFeature to be deleted. - * @return The status of the operation. - * @throws MobileDeviceManagementDAOException - */ - boolean deleteFeatureById(int mblFeatureId) throws MobileDeviceManagementDAOException; - - /** - * Deletes a MobileFeature from Mobile-Feature table when the feature code is given. - * - * @param mblFeatureCode MobileFeature code of the feature to be deleted. - * @return The status of the operation. - * @throws MobileDeviceManagementDAOException - */ - boolean deleteFeatureByCode(String mblFeatureCode) throws MobileDeviceManagementDAOException; - - /** - * Retrieves a given MobileFeature from Mobile-Feature table when the feature id is given. - * - * @param mblFeatureId Feature id of the feature to be retrieved. - * @return MobileFeature object that holds data of the feature represented by featureId. - * @throws MobileDeviceManagementDAOException - */ - MobileFeature getFeatureById(int mblFeatureId) throws MobileDeviceManagementDAOException; - - /** - * Retrieves a given MobileFeature from Mobile-Feature table when the feature code is given. - * - * @param mblFeatureCode Feature code of the feature to be retrieved. - * @return MobileFeature object that holds data of the feature represented by featureCode. - * @throws MobileDeviceManagementDAOException - */ - MobileFeature getFeatureByCode(String mblFeatureCode) throws MobileDeviceManagementDAOException; - - /** - * Retrieves all MobileFeatures of a MobileDevice type from Mobile-Feature table. - * - * @param deviceType MobileDevice type of the MobileFeatures to be retrieved - * @return MobileFeature object list. - * @throws MobileDeviceManagementDAOException - */ - List getFeatureByDeviceType(String deviceType) throws MobileDeviceManagementDAOException; - - /** - * Retrieve all the MobileFeatures from Mobile-Feature table. - * - * @return MobileFeature object list. - * @throws MobileDeviceManagementDAOException - */ - List getAllFeatures() throws MobileDeviceManagementDAOException; -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileFeatureDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileFeatureDAOImpl.java deleted file mode 100644 index 86a940fd6..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileFeatureDAOImpl.java +++ /dev/null @@ -1,336 +0,0 @@ -/* - * Copyright (c) 2014, 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.dao.impl; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -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 javax.sql.DataSource; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; - -/** - * Implementation of MobileFeatureDAO. - */ -public class MobileFeatureDAOImpl implements MobileFeatureDAO { - - private DataSource dataSource; - private static final Log log = LogFactory.getLog(MobileFeatureDAOImpl.class); - - public MobileFeatureDAOImpl(DataSource dataSource) { - this.dataSource = dataSource; - } - - @Override - public boolean addFeature(MobileFeature mobileFeature) - throws MobileDeviceManagementDAOException { - boolean status = false; - Connection conn = null; - PreparedStatement stmt = null; - try { - conn = this.getConnection(); - String createDBQuery = - "INSERT INTO AD_FEATURE(CODE, NAME, DESCRIPTION, DEVICE_TYPE) VALUES (?, ?, ?, ?)"; - - stmt = conn.prepareStatement(createDBQuery); - stmt.setString(1, mobileFeature.getCode()); - stmt.setString(2, mobileFeature.getName()); - stmt.setString(3, mobileFeature.getDescription()); - stmt.setString(4, mobileFeature.getDeviceType()); - int rows = stmt.executeUpdate(); - if (rows > 0) { - if (log.isDebugEnabled()) { - log.debug("Added a new MobileFeature " + mobileFeature.getCode() + " to the MDM database."); - } - status = true; - } - } catch (SQLException e) { - String msg = "Error occurred while adding feature code - '" + - mobileFeature.getCode() + "' to feature table"; - log.error(msg, e); - throw new MobileDeviceManagementDAOException(msg, e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null); - } - return status; - } - - @Override - public boolean addFeatures(List mobileFeatures) throws MobileDeviceManagementDAOException { - return false; - } - - @Override - public boolean updateFeature(MobileFeature mobileFeature) - throws MobileDeviceManagementDAOException { - boolean status = false; - Connection conn = null; - PreparedStatement stmt = null; - try { - conn = this.getConnection(); - String updateDBQuery = - "UPDATE AD_FEATURE SET CODE = ?, NAME = ?, DESCRIPTION = ?, DEVICE_TYPE = ?" + - " WHERE ID = ?"; - stmt = conn.prepareStatement(updateDBQuery); - stmt.setString(1, mobileFeature.getCode()); - stmt.setString(2, mobileFeature.getName()); - stmt.setString(3, mobileFeature.getDescription()); - stmt.setString(4, mobileFeature.getDeviceType()); - stmt.setInt(5, mobileFeature.getId()); - int rows = stmt.executeUpdate(); - if (rows > 0) { - status = true; - if (log.isDebugEnabled()) { - log.debug("Updated MobileFeature " + mobileFeature.getCode()); - } - } - } catch (SQLException e) { - String msg = "Error occurred while updating the feature with feature code - '" + - mobileFeature.getId() + "'"; - log.error(msg, e); - throw new MobileDeviceManagementDAOException(msg, e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null); - } - return status; - } - - @Override - public boolean deleteFeatureByCode(String mblFeatureCode) - throws MobileDeviceManagementDAOException { - boolean status = false; - Connection conn = null; - PreparedStatement stmt = null; - try { - conn = this.getConnection(); - String deleteDBQuery = - "DELETE FROM AD_FEATURE WHERE CODE = ?"; - stmt = conn.prepareStatement(deleteDBQuery); - stmt.setString(1, mblFeatureCode); - int rows = stmt.executeUpdate(); - if (rows > 0) { - status = true; - if (log.isDebugEnabled()) { - log.debug("Deleted MobileFeature code " + mblFeatureCode + " from the MDM database."); - } - } - } catch (SQLException e) { - String msg = "Error occurred while deleting feature with code - " + mblFeatureCode; - log.error(msg, e); - throw new MobileDeviceManagementDAOException(msg, e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null); - } - return status; - } - - @Override - public boolean deleteFeatureById(int mblFeatureId) - throws MobileDeviceManagementDAOException { - boolean status = false; - Connection conn = null; - PreparedStatement stmt = null; - try { - conn = this.getConnection(); - String deleteDBQuery = - "DELETE FROM AD_FEATURE WHERE ID = ?"; - stmt = conn.prepareStatement(deleteDBQuery); - stmt.setInt(1, mblFeatureId); - int rows = stmt.executeUpdate(); - if (rows > 0) { - status = true; - if (log.isDebugEnabled()) { - log.debug("Deleted MobileFeature id " + mblFeatureId + " from the MDM database."); - } - } - } catch (SQLException e) { - String msg = "Error occurred while deleting feature with id - " + mblFeatureId; - log.error(msg, e); - throw new MobileDeviceManagementDAOException(msg, e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null); - } - return status; - } - - @Override - public MobileFeature getFeatureByCode(String mblFeatureCode) - throws MobileDeviceManagementDAOException { - Connection conn = null; - PreparedStatement stmt = null; - MobileFeature mobileFeature = null; - ResultSet resultSet = null; - try { - conn = this.getConnection(); - String selectDBQuery = - "SELECT ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM AD_FEATURE " + - "WHERE CODE = ?"; - stmt = conn.prepareStatement(selectDBQuery); - stmt.setString(1, mblFeatureCode); - resultSet = stmt.executeQuery(); - if (resultSet.next()) { - mobileFeature = new MobileFeature(); - mobileFeature.setId(resultSet.getInt(1)); - mobileFeature.setCode(resultSet.getString(2)); - mobileFeature.setName(resultSet.getString(3)); - mobileFeature.setDescription(resultSet.getString(4)); - mobileFeature.setDeviceType(resultSet.getString(5)); - if (log.isDebugEnabled()) { - log.debug("Fetched MobileFeature " + mblFeatureCode + " from the MDM database."); - } - } - } catch (SQLException e) { - String msg = "Error occurred while fetching feature code - '" + mblFeatureCode + "'"; - log.error(msg, e); - throw new MobileDeviceManagementDAOException(msg, e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, resultSet); - } - return mobileFeature; - } - - @Override - public MobileFeature getFeatureById(int mblFeatureId) - throws MobileDeviceManagementDAOException { - Connection conn = null; - PreparedStatement stmt = null; - MobileFeature mobileFeature = null; - ResultSet resultSet = null; - try { - conn = this.getConnection(); - String selectDBQuery = - "SELECT ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM AD_FEATURE" + - " WHERE ID = ?"; - stmt = conn.prepareStatement(selectDBQuery); - stmt.setInt(1, mblFeatureId); - resultSet = stmt.executeQuery(); - if (resultSet.next()) { - mobileFeature = new MobileFeature(); - mobileFeature.setId(resultSet.getInt(1)); - mobileFeature.setCode(resultSet.getString(2)); - mobileFeature.setName(resultSet.getString(3)); - mobileFeature.setDescription(resultSet.getString(4)); - mobileFeature.setDeviceType(resultSet.getString(5)); - if (log.isDebugEnabled()) { - log.debug("Fetched MobileFeatureId" + mblFeatureId + " from the MDM database."); - } - } - } catch (SQLException e) { - String msg = "Error occurred while fetching feature id - '" + mblFeatureId + "'"; - log.error(msg, e); - throw new MobileDeviceManagementDAOException(msg, e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, resultSet); - } - return mobileFeature; - } - - @Override - public List getAllFeatures() throws MobileDeviceManagementDAOException { - Connection conn = null; - PreparedStatement stmt = null; - MobileFeature mobileFeature; - List mobileFeatures = new ArrayList(); - ResultSet resultSet = null; - try { - conn = this.getConnection(); - String selectDBQuery = - "SELECT ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM AD_FEATURE"; - stmt = conn.prepareStatement(selectDBQuery); - resultSet = stmt.executeQuery(); - while (resultSet.next()) { - mobileFeature = new MobileFeature(); - mobileFeature.setId(resultSet.getInt(1)); - mobileFeature.setCode(resultSet.getString(2)); - mobileFeature.setName(resultSet.getString(3)); - mobileFeature.setDescription(resultSet.getString(4)); - mobileFeature.setDeviceType(resultSet.getString(5)); - mobileFeatures.add(mobileFeature); - } - if (log.isDebugEnabled()) { - log.debug("Fetched all MobileFeatures from the MDM database."); - } - return mobileFeatures; - } catch (SQLException e) { - String msg = "Error occurred while fetching all features.'"; - log.error(msg, e); - throw new MobileDeviceManagementDAOException(msg, e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, resultSet); - } - } - - @Override - public List getFeatureByDeviceType(String deviceType) throws MobileDeviceManagementDAOException { - Connection conn = null; - PreparedStatement stmt = null; - MobileFeature mobileFeature; - List mobileFeatures = new ArrayList<>(); - ResultSet resultSet = null; - try { - conn = this.getConnection(); - String selectDBQuery = - "SELECT ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM AD_FEATURE" + - " WHERE DEVICE_TYPE = ?"; - stmt = conn.prepareStatement(selectDBQuery); - stmt.setString(1, deviceType); - resultSet = stmt.executeQuery(); - while (resultSet.next()) { - mobileFeature = new MobileFeature(); - mobileFeature.setId(resultSet.getInt(1)); - mobileFeature.setCode(resultSet.getString(2)); - mobileFeature.setName(resultSet.getString(3)); - mobileFeature.setDescription(resultSet.getString(4)); - mobileFeature.setDeviceType(resultSet.getString(5)); - mobileFeatures.add(mobileFeature); - } - if (log.isDebugEnabled()) { - log.debug("Fetched all MobileFeatures of type " + deviceType + " from the MDM" + - " database."); - } - return mobileFeatures; - } catch (SQLException e) { - String msg = "Error occurred while fetching all features.'"; - log.error(msg, e); - throw new MobileDeviceManagementDAOException(msg, e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, resultSet); - } - } - - private Connection getConnection() throws MobileDeviceManagementDAOException { - try { - return dataSource.getConnection(); - } catch (SQLException e) { - String msg = "Error occurred while obtaining a connection from the mobile specific " + - "datasource."; - log.error(msg, e); - throw new MobileDeviceManagementDAOException(msg, e); - } - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/util/MobileDeviceManagementDAOUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/util/MobileDeviceManagementDAOUtil.java deleted file mode 100644 index 0f72e82e9..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/util/MobileDeviceManagementDAOUtil.java +++ /dev/null @@ -1,139 +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.dao.util; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.mobile.common.MobileDeviceMgtPluginException; -import org.wso2.carbon.device.mgt.mobile.config.datasource.JNDILookupDefinition; -import org.wso2.carbon.device.mgt.mobile.config.datasource.MobileDataSourceConfig; -import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementSchemaInitializer; - -import javax.naming.InitialContext; -import javax.sql.DataSource; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.Hashtable; -import java.util.List; - -/** - * Utility method required by MobileDeviceManagement DAO classes. - */ -public class MobileDeviceManagementDAOUtil { - - private static final Log log = LogFactory.getLog(MobileDeviceManagementDAOUtil.class); - - public static DataSource lookupDataSource(String dataSourceName, - final Hashtable jndiProperties){ - - try { - if (jndiProperties == null || jndiProperties.isEmpty()) { - return (DataSource) InitialContext.doLookup(dataSourceName); - } - final InitialContext context = new InitialContext(jndiProperties); - return (DataSource) context.lookup(dataSourceName); - } catch (Exception e) { - String msg = "Error in looking up data source: " + e.getMessage(); - log.error(msg, e); - throw new RuntimeException(msg + e.getMessage(), e); - } - } - - public static void cleanupResources(Connection conn, PreparedStatement stmt, ResultSet rs) { - if (rs != null) { - try { - rs.close(); - } catch (SQLException e) { - log.warn("Error occurred while closing result set", e); - } - } - if (stmt != null) { - try { - stmt.close(); - } catch (SQLException e) { - log.warn("Error occurred while closing prepared statement", e); - } - } - if (conn != null) { - try { - conn.close(); - } catch (SQLException e) { - log.warn("Error occurred while closing database connection", e); - } - } - } - - public static void cleanupResources(PreparedStatement stmt, ResultSet rs) { - cleanupResources(null, stmt, rs); - } - - /** - * Creates the mobile device management schema. - * - * @param dataSource Mobile data source - */ - public static void setupMobileDeviceManagementSchema(DataSource dataSource, String pluginType) throws MobileDeviceMgtPluginException { - MobileDeviceManagementSchemaInitializer initializer = - new MobileDeviceManagementSchemaInitializer(dataSource, pluginType); - log.info("Initializing mobile device management repository database schema for : " + pluginType); - try { - initializer.createRegistryDatabase(); - } catch (Exception e) { - throw new MobileDeviceMgtPluginException("Error occurred while initializing Mobile Device " + - "Management database schema", e); - } - } - - - /** - * Resolve data source from the data source definition - * - * @param config data source configuration - * @return data source resolved from the data source definition - */ - private static DataSource resolveDataSource(MobileDataSourceConfig config) { - DataSource dataSource = null; - if (config == null) { - throw new RuntimeException( - "data source configuration " + "is null and " + - "thus, is not initialized"); - } - JNDILookupDefinition jndiConfig = config.getJndiLookupDefinition(); - if (jndiConfig != null) { - if (log.isDebugEnabled()) { - log.debug("Initializing data source using the JNDI " + - "Lookup Definition"); - } - List jndiPropertyList = - jndiConfig.getJndiProperties(); - if (jndiPropertyList != null) { - Hashtable jndiProperties = new Hashtable(); - for (JNDILookupDefinition.JNDIProperty prop : jndiPropertyList) { - jndiProperties.put(prop.getName(), prop.getValue()); - } - dataSource = MobileDeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), jndiProperties); - } else { - dataSource = MobileDeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), null); - } - } - return dataSource; - } -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileDevice.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileDevice.java deleted file mode 100644 index 185168da4..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileDevice.java +++ /dev/null @@ -1,125 +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.dto; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -/** - * DTO of MobileDevice. - */ -public class MobileDevice implements Serializable { - - private String mobileDeviceId; - private String osVersion; - private String model; - private String vendor; - private String latitude; - private String longitude; - private String imei; - private String imsi; - private String serial; - private Map deviceProperties; - - public MobileDevice() { - this.deviceProperties = new HashMap<>(); - } - - public String getMobileDeviceId() { - return mobileDeviceId; - } - - public void setMobileDeviceId(String mobileDeviceId) { - this.mobileDeviceId = mobileDeviceId; - } - - public String getOsVersion() { - return osVersion; - } - - public void setOsVersion(String osVersion) { - this.osVersion = osVersion; - } - - public String getModel() { - return model; - } - - public void setModel(String model) { - this.model = model; - } - - public String getVendor() { - return vendor; - } - - public void setVendor(String vendor) { - this.vendor = vendor; - } - - public String getLatitude() { - return latitude; - } - - public void setLatitude(String latitude) { - this.latitude = latitude; - } - - public String getLongitude() { - return longitude; - } - - public void setLongitude(String longitude) { - this.longitude = longitude; - } - - public String getImei() { - return imei; - } - - public void setImei(String imei) { - this.imei = imei; - } - - public String getImsi() { - return imsi; - } - - public void setImsi(String imsi) { - this.imsi = imsi; - } - - public String getSerial() { - return serial; - } - - public void setSerial(String serial) { - this.serial = serial; - } - - public Map getDeviceProperties() { - return deviceProperties; - } - - public void setDeviceProperties(Map deviceProperties) { - this.deviceProperties = deviceProperties; - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileDeviceOperationMapping.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileDeviceOperationMapping.java deleted file mode 100644 index 0ae7e68fa..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileDeviceOperationMapping.java +++ /dev/null @@ -1,86 +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.dto; - -/** - * DTO of Mobile Device Operation Mappings. - */ -public class MobileDeviceOperationMapping { - - private String deviceId; - private int operationId; - private long sentDate; - private long receivedDate; - private Status status; - - public enum Status { - NEW, INPROGRESS, COMPLETED - } - - public Status getStatus() { - return status; - } - - public void setStatus(Status status) { - this.status = status; - } - - public void setStatus(String status) { - if(Status.NEW.name().equals(status)){ - this.status = Status.NEW; - }else if(Status.INPROGRESS.name().equals(status)){ - this.status = Status.INPROGRESS; - }else if(Status.COMPLETED.name().equals(status)){ - this.status = Status.COMPLETED; - } - } - - public String getDeviceId() { - return deviceId; - } - - public void setDeviceId(String deviceId) { - this.deviceId = deviceId; - } - - public int getOperationId() { - return operationId; - } - - public void setOperationId(int operationId) { - this.operationId = operationId; - } - - public long getSentDate() { - return sentDate; - } - - public void setSentDate(long sentDate) { - this.sentDate = sentDate; - } - - public long getReceivedDate() { - return receivedDate; - } - - public void setReceivedDate(long receivedDate) { - this.receivedDate = receivedDate; - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileFeature.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileFeature.java deleted file mode 100644 index 9ec5d30b3..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileFeature.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.dto; - -import java.io.Serializable; - -/** - * DTO of Mobile features. - */ -public class MobileFeature implements Serializable { - - private int id; - private String deviceType; - private String code; - private String name; - private String description; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getDeviceType() { - return deviceType; - } - - public void setDeviceType(String deviceType) { - this.deviceType = deviceType; - } -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileFeatureProperty.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileFeatureProperty.java deleted file mode 100644 index cc99849de..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileFeatureProperty.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * you may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.device.mgt.mobile.dto; - -/** - * DTO of Mobile feature property. Represents a property of a mobile feature. - */ -public class MobileFeatureProperty { - - private String property; - private Integer featureID; - - public Integer getFeatureID() { - return featureID; - } - - public void setFeatureID(Integer featureID) { - this.featureID = featureID; - } - - public String getProperty() { - return property; - } - - public void setProperty(String property) { - this.property = property; - } - -} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileOperation.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileOperation.java deleted file mode 100644 index 7c0b9040c..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileOperation.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.dto; - -import java.util.List; - -/** - * DTO of MobileOperation. - */ -public class MobileOperation { - - private int operationId; - private String featureCode; - private long createdDate; - private List properties; - - public int getOperationId() { - return operationId; - } - - public void setOperationId(int operationId) { - this.operationId = operationId; - } - - public List getProperties() { - return properties; - } - - public void setProperties(List properties) { - this.properties = properties; - } - - public String getFeatureCode() { - return featureCode; - } - - public void setFeatureCode(String featureCode) { - this.featureCode = featureCode; - } - - public long getCreatedDate() { - return createdDate; - } - - public void setCreatedDate(long createdDate) { - this.createdDate = createdDate; - } -} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileOperationProperty.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileOperationProperty.java deleted file mode 100644 index d18126aff..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileOperationProperty.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * you may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.device.mgt.mobile.dto; - -/** - * DTO of Mobile Operation property. - */ -public class MobileOperationProperty { - - private int operationId; - private String property; - private String value; - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - public int getOperationId() { - return operationId; - } - - public void setOperationId(int operationId) { - this.operationId = operationId; - } - - public String getProperty() { - return property; - } - - public void setProperty(String property) { - this.property = property; - } - -} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementDataHolder.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementDataHolder.java deleted file mode 100644 index 869904e81..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementDataHolder.java +++ /dev/null @@ -1,67 +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.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; - -/** - * DataHolder class of Mobile plugins component. - */ -public class MobileDeviceManagementDataHolder { - - private RegistryService registryService; - private DeviceManagementService androidDeviceManagementService; - private GCMService gcmService; - - private static MobileDeviceManagementDataHolder thisInstance = new MobileDeviceManagementDataHolder(); - - private MobileDeviceManagementDataHolder() { - } - - public static MobileDeviceManagementDataHolder getInstance() { - return thisInstance; - } - - public RegistryService getRegistryService() { - return registryService; - } - - public void setRegistryService(RegistryService registryService) { - this.registryService = registryService; - } - - public DeviceManagementService getAndroidDeviceManagementService() { - return androidDeviceManagementService; - } - - public void setAndroidDeviceManagementService( - DeviceManagementService androidDeviceManagementService) { - this.androidDeviceManagementService = androidDeviceManagementService; - } - - public GCMService getGCMService() { - return gcmService; - } - - public void setGCMService(GCMService gcmService) { - this.gcmService = gcmService; - } -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java deleted file mode 100644 index 92404b67a..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java +++ /dev/null @@ -1,181 +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.internal; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceRegistration; -import org.osgi.service.component.ComponentContext; -import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; -import org.wso2.carbon.device.mgt.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; - -/** - * @scr.component name="org.wso2.carbon.device.mgt.mobile.impl.internal.MobileDeviceManagementServiceComponent" - * 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" - * @scr.reference name="registry.service" - * interface="org.wso2.carbon.registry.core.service.RegistryService" cardinality="0..1" - * policy="dynamic" bind="setRegistryService" unbind="unsetRegistryService" - *

- * Adding reference to API Manager Configuration service is an unavoidable hack to get rid of NPEs thrown while - * initializing APIMgtDAOs attempting to register APIs programmatically. APIMgtDAO needs to be proper cleaned up - * to avoid as an ideal fix - */ -public class MobileDeviceManagementServiceComponent { - - private ServiceRegistration androidServiceRegRef; - private ServiceRegistration windowsServiceRegRef; - private ServiceRegistration gcmServiceRegRef; - - private static final Log log = LogFactory.getLog(MobileDeviceManagementServiceComponent.class); - - protected void activate(ComponentContext ctx) { - - if (log.isDebugEnabled()) { - log.debug("Activating Mobile Device Management Service Component"); - } - try { - BundleContext bundleContext = ctx.getBundleContext(); - - /* Initialize the data source configuration */ - MobileDeviceConfigurationManager.getInstance().initConfig(); - MobileDeviceManagementConfig config = MobileDeviceConfigurationManager.getInstance() - .getMobileDeviceManagementConfig(); - Map dsConfigMap = - config.getMobileDeviceMgtRepository().getMobileDataSourceConfigMap(); - - AbstractMobileDeviceManagementDAOFactory.init(dsConfigMap); - - String setupOption = System.getProperty("setup"); - if (setupOption != null) { - if (log.isDebugEnabled()) { - log.debug( - "-Dsetup is enabled. Mobile Device management repository schema initialization is about " + - "to begin"); - } - try { - for (String pluginType : dsConfigMap.keySet()) { - MobileDeviceManagementDAOUtil - .setupMobileDeviceManagementSchema(AbstractMobileDeviceManagementDAOFactory.getDataSourceMap - ().get(pluginType), pluginType); - } - } catch (MobileDeviceMgtPluginException e) { - 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"); - } - } catch (Throwable e) { - log.error("Error occurred while activating Mobile Device Management Service Component", e); - } - } - - protected void deactivate(ComponentContext ctx) { - if (log.isDebugEnabled()) { - 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(); - } - if (log.isDebugEnabled()) { - log.debug( - "Mobile Device Management Service Component has been successfully de-activated"); - } - } catch (Throwable e) { - log.error("Error occurred while de-activating Mobile 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 mobile service component"); - } - } - - protected void unsetDataSourceService(DataSourceService dataSourceService) { - //do nothing - } - - protected void setRegistryService(RegistryService registryService) { - if (log.isDebugEnabled()) { - log.debug("RegistryService acquired"); - } - MobileDeviceManagementDataHolder.getInstance().setRegistryService(registryService); - } - - protected void unsetRegistryService(RegistryService registryService) { - MobileDeviceManagementDataHolder.getInstance().setRegistryService(null); - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementSchemaInitializer.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementSchemaInitializer.java deleted file mode 100644 index f0071a85f..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementSchemaInitializer.java +++ /dev/null @@ -1,62 +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.util; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.mobile.common.MobilePluginConstants; -import org.wso2.carbon.utils.CarbonUtils; -import org.wso2.carbon.utils.dbcreator.DatabaseCreator; - -import javax.sql.DataSource; -import java.io.File; - -/** - * - * Provides methods for initializing the database script. - * - */ -public final class MobileDeviceManagementSchemaInitializer extends DatabaseCreator { - - private static final Log log = LogFactory.getLog(MobileDeviceManagementSchemaInitializer.class); - private static final String setupSQLScriptBaseLocation = - CarbonUtils.getCarbonHome() + File.separator + "dbscripts" + File.separator - + MobilePluginConstants.MOBILE_DB_SCRIPTS_FOLDER + - File.separator + "plugins" + File.separator; - private String pluginType; - - public String getPluginType() { - return pluginType; - } - - public MobileDeviceManagementSchemaInitializer(DataSource dataSource, String pType) { - super(dataSource); - this.pluginType = pType; - } - - protected String getDbScriptLocation(String databaseType) { - String scriptName = databaseType + ".sql"; - String scriptLocation = setupSQLScriptBaseLocation + this.getPluginType() + File.separator + scriptName; - if (log.isDebugEnabled()) { - log.debug("Loading database script from :" + scriptLocation); - } - return scriptLocation; - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java deleted file mode 100644 index 73612a365..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java +++ /dev/null @@ -1,320 +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.util; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.w3c.dom.Document; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.common.Device; -import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.Feature; -import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; -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.dto.*; -import org.wso2.carbon.device.mgt.mobile.internal.MobileDeviceManagementDataHolder; -import org.wso2.carbon.registry.api.RegistryException; -import org.wso2.carbon.registry.api.Resource; -import org.wso2.carbon.registry.core.Registry; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import java.io.File; -import java.util.*; - -/** - * Provides utility methods required by the mobile device management bundle. - */ -public class MobileDeviceManagementUtil { - - private static final Log log = LogFactory.getLog(MobileDeviceManagementUtil.class); - private static final String MOBILE_DEVICE_IMEI = "IMEI"; - private static final String MOBILE_DEVICE_IMSI = "IMSI"; - private static final String MOBILE_DEVICE_VENDOR = "VENDOR"; - private static final String MOBILE_DEVICE_OS_VERSION = "OS_VERSION"; - private static final String MOBILE_DEVICE_MODEL = "DEVICE_MODEL"; - private static final String MOBILE_DEVICE_LATITUDE = "LATITUDE"; - private static final String MOBILE_DEVICE_LONGITUDE = "LONGITUDE"; - private static final String MOBILE_DEVICE_SERIAL = "SERIAL"; - - public static Document convertToDocument(File file) throws DeviceManagementException { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - factory.setNamespaceAware(true); - try { - DocumentBuilder docBuilder = factory.newDocumentBuilder(); - return docBuilder.parse(file); - } catch (Exception e) { - throw new DeviceManagementException( - "Error occurred while parsing file, while converting " + - "to a org.w3c.dom.Document : " + e.getMessage(), e); - } - } - - private static String getPropertyValue(Device device, String property) { - for (Device.Property prop : device.getProperties()) { - if (property.equals(prop.getName())) { - return prop.getValue(); - } - } - return null; - } - - private static Device.Property getProperty(String property, String value) { - if (property != null) { - Device.Property prop = new Device.Property(); - prop.setName(property); - prop.setValue(value); - return prop; - } - return null; - } - - public static MobileDevice convertToMobileDevice(Device device) { - MobileDevice mobileDevice = null; - if (device != null) { - mobileDevice = new MobileDevice(); - mobileDevice.setMobileDeviceId(device.getDeviceIdentifier()); - mobileDevice.setImei(getPropertyValue(device, MOBILE_DEVICE_IMEI)); - mobileDevice.setImsi(getPropertyValue(device, MOBILE_DEVICE_IMSI)); - mobileDevice.setModel(getPropertyValue(device, MOBILE_DEVICE_MODEL)); - mobileDevice.setOsVersion(getPropertyValue(device, MOBILE_DEVICE_OS_VERSION)); - mobileDevice.setVendor(getPropertyValue(device, MOBILE_DEVICE_VENDOR)); - mobileDevice.setLatitude(getPropertyValue(device, MOBILE_DEVICE_LATITUDE)); - mobileDevice.setLongitude(getPropertyValue(device, MOBILE_DEVICE_LONGITUDE)); - - if (device.getProperties() != null) { - Map deviceProperties = new HashMap(); - for (Device.Property deviceProperty : device.getProperties()) { - deviceProperties.put(deviceProperty.getName(), deviceProperty.getValue()); - } - - mobileDevice.setDeviceProperties(deviceProperties); - } else { - mobileDevice.setDeviceProperties(new HashMap()); - } - } - return mobileDevice; - } - - public static Device convertToDevice(MobileDevice mobileDevice) { - Device device = null; - if (mobileDevice != null) { - device = new Device(); - List propertyList = new ArrayList(); - propertyList.add(getProperty(MOBILE_DEVICE_IMEI, mobileDevice.getImei())); - propertyList.add(getProperty(MOBILE_DEVICE_IMSI, mobileDevice.getImsi())); - propertyList.add(getProperty(MOBILE_DEVICE_MODEL, mobileDevice.getModel())); - propertyList.add(getProperty(MOBILE_DEVICE_OS_VERSION, mobileDevice.getOsVersion())); - propertyList.add(getProperty(MOBILE_DEVICE_VENDOR, mobileDevice.getVendor())); - if(mobileDevice.getLatitude() != null) { - propertyList.add(getProperty(MOBILE_DEVICE_LATITUDE, mobileDevice.getLatitude())); - } - if(mobileDevice.getLongitude() != null) { - propertyList.add(getProperty(MOBILE_DEVICE_LONGITUDE, mobileDevice.getLongitude())); - } - propertyList.add(getProperty(MOBILE_DEVICE_SERIAL, mobileDevice.getSerial())); - - if (mobileDevice.getDeviceProperties() != null) { - for (Map.Entry deviceProperty : mobileDevice.getDeviceProperties() - .entrySet()) { - propertyList - .add(getProperty(deviceProperty.getKey(), deviceProperty.getValue())); - } - } - - device.setProperties(propertyList); - device.setDeviceIdentifier(mobileDevice.getMobileDeviceId()); - } - return device; - } - - public static MobileOperation convertToMobileOperation(Operation operation) { - MobileOperation mobileOperation = new MobileOperation(); - MobileOperationProperty operationProperty; - List properties = new LinkedList(); - mobileOperation.setFeatureCode(operation.getCode()); - mobileOperation.setCreatedDate(new Date().getTime()); - Properties operationProperties = operation.getProperties(); - for (String key : operationProperties.stringPropertyNames()) { - operationProperty = new MobileOperationProperty(); - operationProperty.setProperty(key); - operationProperty.setValue(operationProperties.getProperty(key)); - properties.add(operationProperty); - } - mobileOperation.setProperties(properties); - return mobileOperation; - } - - public static List getMobileOperationIdsFromMobileDeviceOperations( - List mobileDeviceOperationMappings) { - List mobileOperationIds = new ArrayList(mobileDeviceOperationMappings.size()); - for (MobileDeviceOperationMapping mobileDeviceOperationMapping : mobileDeviceOperationMappings) { - mobileOperationIds.add(mobileDeviceOperationMapping.getOperationId()); - } - return mobileOperationIds; - } - - public static Operation convertMobileOperationToOperation(MobileOperation mobileOperation) { - Operation operation = new Operation(); - Properties properties = new Properties(); - operation.setCode(mobileOperation.getFeatureCode()); - for (MobileOperationProperty mobileOperationProperty : mobileOperation.getProperties()) { - properties - .put(mobileOperationProperty.getProperty(), mobileOperationProperty.getValue()); - } - operation.setProperties(properties); - return operation; - } - - public static MobileFeature convertToMobileFeature(Feature feature) { - MobileFeature mobileFeature = new MobileFeature(); - mobileFeature.setName(feature.getName()); - mobileFeature.setCode(feature.getCode()); - mobileFeature.setDescription(feature.getDescription()); - mobileFeature.setDeviceType(feature.getDeviceType()); - return mobileFeature; - } - - public static Feature convertToFeature(MobileFeature mobileFeature) { - Feature feature = new Feature(); - feature.setDescription(mobileFeature.getDescription()); - feature.setDeviceType(mobileFeature.getDeviceType()); - feature.setCode(mobileFeature.getCode()); - feature.setName(mobileFeature.getName()); - return feature; - } - - public static Registry getConfigurationRegistry() throws MobileDeviceMgtPluginException { - try { - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); - return MobileDeviceManagementDataHolder.getInstance().getRegistryService() - .getConfigSystemRegistry( - tenantId); - } catch (RegistryException e) { - throw new MobileDeviceMgtPluginException( - "Error in retrieving conf registry instance: " + - e.getMessage(), e); - } - } - - public static Resource getRegistryResource(String path) throws MobileDeviceMgtPluginException { - try { - if(MobileDeviceManagementUtil.getConfigurationRegistry().resourceExists(path)){ - return MobileDeviceManagementUtil.getConfigurationRegistry().get(path); - } - return null; - } catch (RegistryException e) { - throw new MobileDeviceMgtPluginException("Error in retrieving registry resource : " + - e.getMessage(), e); - } - } - - public static boolean putRegistryResource(String path, - Resource resource) - throws MobileDeviceMgtPluginException { - boolean status; - try { - MobileDeviceManagementUtil.getConfigurationRegistry().beginTransaction(); - MobileDeviceManagementUtil.getConfigurationRegistry().put(path, resource); - MobileDeviceManagementUtil.getConfigurationRegistry().commitTransaction(); - status = true; - } catch (RegistryException e) { - throw new MobileDeviceMgtPluginException( - "Error occurred while persisting registry resource : " + - e.getMessage(), e); - } - return status; - } - - public static String getResourcePath(String resourceName, String platform) { - String regPath = ""; - switch (platform) { - case DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID: - regPath = MobilePluginConstants.MOBILE_CONFIG_REGISTRY_ROOT + "/" + - DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID + - "/" + resourceName; - break; - case DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS: - regPath = MobilePluginConstants.MOBILE_CONFIG_REGISTRY_ROOT + "/" + - DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS + - "/" + resourceName; - break; - case DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_IOS: - regPath = MobilePluginConstants.MOBILE_CONFIG_REGISTRY_ROOT + "/" + - DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_IOS + - "/" + resourceName; - break; - } - return regPath; - } - - public static String getPlatformConfigPath(String platform) { - String regPath = ""; - switch (platform) { - case DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID: - regPath = DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID; - break; - case DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS: - regPath = DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS; - break; - case DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_IOS: - regPath = DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_IOS; - break; - } - return regPath; - } - - public static boolean createRegistryCollection(String path) - throws MobileDeviceMgtPluginException { - try { - if (! MobileDeviceManagementUtil.getConfigurationRegistry().resourceExists(path)) { - Resource resource = MobileDeviceManagementUtil.getConfigurationRegistry().newCollection(); - MobileDeviceManagementUtil.getConfigurationRegistry().beginTransaction(); - MobileDeviceManagementUtil.getConfigurationRegistry().put(path, resource); - MobileDeviceManagementUtil.getConfigurationRegistry().commitTransaction(); - } - return true; - } catch (MobileDeviceMgtPluginException e) { - throw new MobileDeviceMgtPluginException( - "Error occurred while creating a registry collection : " + - e.getMessage(), e); - } catch (RegistryException e) { - throw new MobileDeviceMgtPluginException( - "Error occurred while creating a registry collection : " + - e.getMessage(), e); - } - } - - public static List getMissingFeatures(List supportedFeatures, List existingFeatures) { - HashMap featureHashMap = new HashMap(); - for (Feature feature: existingFeatures) { - featureHashMap.put(feature.getCode(),feature); - } - List missingFeatures = new ArrayList(); - for (Feature supportedFeature : supportedFeatures) { - if (featureHashMap.get(supportedFeature.getCode()) != null) { - continue; - } - missingFeatures.add(supportedFeature); - } - return missingFeatures; - } -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/MobileDeviceManagementConfigTests.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/MobileDeviceManagementConfigTests.java deleted file mode 100644 index 461de8a1a..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/MobileDeviceManagementConfigTests.java +++ /dev/null @@ -1,141 +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; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.wso2.carbon.device.mgt.mobile.config.MobileDeviceManagementConfig; -import org.xml.sax.SAXException; -import org.xml.sax.SAXParseException; - -import javax.xml.XMLConstants; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; -import javax.xml.validation.Schema; -import javax.xml.validation.SchemaFactory; -import java.io.File; - -/** - * Class for holding unit-tests related to MobileDeviceManagementConfig class. - */ - -public class MobileDeviceManagementConfigTests { - - private static final Log log = LogFactory.getLog(MobileDeviceManagementConfigTests.class); - private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_MGT_REPOSITORY = - "./src/test/resources/config/malformed-mobile-config-no-mgt-repo.xml"; - private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_DS_CONFIG = - "./src/test/resources/config/malformed-mobile-config-no-ds-config.xml"; - private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_JNDI_CONFIG = - "./src/test/resources/config/malformed-mobile-config-no-jndi-config.xml"; - private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_APIS_CONFIG = - "./src/test/resources/config/malformed-mobile-config-no-apis-config.xml"; - private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_API_CONFIG = - "./src/test/resources/config/malformed-mobile-config-no-api-config.xml"; - private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_API_PUBLISHER_CONFIG = - "./src/test/resources/config/malformed-mobile-config-no-api-publisher-config.xml"; - private static final String TEST_CONFIG_SCHEMA_LOCATION = - "./src/test/resources/config/schema/MobileDeviceManagementConfigSchema.xsd"; - - private Schema schema; - - @BeforeClass - private void initSchema() { - File deviceManagementSchemaConfig = - new File(MobileDeviceManagementConfigTests.TEST_CONFIG_SCHEMA_LOCATION); - SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); - try { - schema = factory.newSchema(deviceManagementSchemaConfig); - } catch (SAXException e) { - Assert.fail("Invalid schema found", e); - } - } - - @Test - public void testMandateManagementRepositoryElement() { - File malformedConfig = - new File( - MobileDeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_MGT_REPOSITORY); - this.validateMalformedConfig(malformedConfig); - } - - @Test - public void testMandateDataSourceConfigurationElement() { - File malformedConfig = new File( - MobileDeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_DS_CONFIG); - this.validateMalformedConfig(malformedConfig); - } - - @Test - public void testMandateJndiLookupDefinitionElement() { - File malformedConfig = new File( - MobileDeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_JNDI_CONFIG); - this.validateMalformedConfig(malformedConfig); - } - - @Test - public void testMandateAPIPublisherElement() { - File malformedConfig = new File( - MobileDeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_API_PUBLISHER_CONFIG); - this.validateMalformedConfig(malformedConfig); - } - - @Test - public void testMandateAPIsElement() { - File malformedConfig = new File( - MobileDeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_APIS_CONFIG); - this.validateMalformedConfig(malformedConfig); - } - - @Test - public void testMandateAPIElement() { - File malformedConfig = new File( - MobileDeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_API_CONFIG); - this.validateMalformedConfig(malformedConfig); - } - - /** - * Validates a given malformed-configuration file. - */ - private void validateMalformedConfig(File malformedConfig) { - try { - JAXBContext ctx = JAXBContext.newInstance(MobileDeviceManagementConfig.class); - Unmarshaller um = ctx.createUnmarshaller(); - um.setSchema(this.getSchema()); - um.unmarshal(malformedConfig); - Assert.assertTrue(false); - } catch (JAXBException e) { - Throwable linkedException = e.getLinkedException(); - if (!(linkedException instanceof SAXParseException)) { - log.error("Unexpected error occurred while unmarshalling mobile device management config", e); - Assert.assertTrue(false); - } - Assert.assertTrue(true); - } - } - - private Schema getSchema() { - return schema; - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/common/DBTypes.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/common/DBTypes.java deleted file mode 100644 index fa263f384..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/common/DBTypes.java +++ /dev/null @@ -1,29 +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.common; - - -public enum DBTypes { - Oracle("Oracle"),H2("H2"),MySql("MySql"); - - String dbName ; - DBTypes(String dbStrName) { - dbName = dbStrName; - } -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/common/TestDBConfiguration.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/common/TestDBConfiguration.java deleted file mode 100644 index 042e105bf..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/common/TestDBConfiguration.java +++ /dev/null @@ -1,90 +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.common; - -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "Type") -public class TestDBConfiguration { - - private String connectionURL; - private String driverClassName; - private String username; - private String password; - - @Override public String toString() { - return "TestDataSourceConfiguration{" + - "ConnectionURL='" + connectionURL + '\'' + - ", DriverClassName='" + driverClassName + '\'' + - ", Username='" + username + '\'' + - ", Password='" + password + '\'' + - ", Type='" + dbType + '\'' + - '}'; - } - - private String dbType; - - @XmlElement(name = "ConnectionURL", nillable = false) - public String getConnectionURL() { - return connectionURL; - } - - public void setConnectionURL(String connectionURL) { - this.connectionURL = connectionURL; - } - - @XmlElement(name = "DriverClassName", nillable = false) - public String getDriverClassName() { - return driverClassName; - } - - public void setDriverClassName(String driverClassName) { - this.driverClassName = driverClassName; - } - - @XmlElement(name = "Username", nillable = false) - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - @XmlElement(name = "Password", nillable = false) - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - @XmlAttribute(name = "name") - public String getType() { - return dbType; - } - - public void setType(String type) { - this.dbType = type; - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/common/TestDBConfigurations.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/common/TestDBConfigurations.java deleted file mode 100644 index 88092ea41..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/common/TestDBConfigurations.java +++ /dev/null @@ -1,39 +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.common; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import java.util.List; - -@XmlRootElement(name = "TestDataSourceConfigurations") -public class TestDBConfigurations { - - private List dbTypesList; - - @XmlElement(name = "Type") - public List getDbTypesList() { - return dbTypesList; - } - - public void setDbTypesList(List dbTypesList) { - this.dbTypesList = dbTypesList; - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/util/MobileDatabaseUtils.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/util/MobileDatabaseUtils.java deleted file mode 100644 index f454f6f06..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/util/MobileDatabaseUtils.java +++ /dev/null @@ -1,111 +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.dao.util; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.w3c.dom.Document; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; -import org.wso2.carbon.device.mgt.mobile.impl.common.DBTypes; -import org.wso2.carbon.device.mgt.mobile.impl.common.TestDBConfiguration; -import org.wso2.carbon.device.mgt.mobile.impl.common.TestDBConfigurations; -import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; -import java.io.File; -import java.sql.*; - -/** - * This class provides the utility methods needed for DAO related test executions. - */ -public class MobileDatabaseUtils { - - private static final Log log = LogFactory.getLog(MobileDatabaseUtils.class); - public static final String TEST_RESOURCES_DB_CONFIG_FILE = - "src/test/resources/testdbconfig.xml"; - - public static void cleanupResources(Connection conn, Statement stmt, ResultSet rs) { - if (rs != null) { - try { - rs.close(); - } catch (SQLException e) { - log.warn("Error occurred while closing result set", e); - } - } - if (stmt != null) { - try { - stmt.close(); - } catch (SQLException e) { - log.warn("Error occurred while closing prepared statement", e); - } - } - if (conn != null) { - try { - conn.close(); - } catch (SQLException e) { - log.warn("Error occurred while closing database connection", e); - } - } - } - - public static TestDBConfiguration getTestDBConfiguration(DBTypes dbType) throws - MobileDeviceManagementDAOException, - DeviceManagementException { - File deviceMgtConfig = new File(TEST_RESOURCES_DB_CONFIG_FILE); - Document doc; - TestDBConfiguration testDBConfiguration = null; - TestDBConfigurations testDBConfigurations; - - doc = MobileDeviceManagementUtil.convertToDocument(deviceMgtConfig); - JAXBContext testDBContext; - - try { - testDBContext = JAXBContext.newInstance(TestDBConfigurations.class); - Unmarshaller unmarshaller = testDBContext.createUnmarshaller(); - testDBConfigurations = (TestDBConfigurations) unmarshaller.unmarshal(doc); - } catch (JAXBException e) { - throw new MobileDeviceManagementDAOException("Error parsing test db configurations", e); - } - - for (TestDBConfiguration testDBConfiguration1 : testDBConfigurations.getDbTypesList()) { - testDBConfiguration = testDBConfiguration1; - if (testDBConfiguration.getType().equals(dbType.toString())) { - break; - } - } - - return testDBConfiguration; - } - - public static void createH2DB(TestDBConfiguration testDBConf) throws Exception { - Connection conn = null; - Statement stmt = null; - try { - Class.forName(testDBConf.getDriverClassName()); - conn = DriverManager.getConnection(testDBConf.getConnectionURL()); - stmt = conn.createStatement(); - stmt.executeUpdate("RUNSCRIPT FROM './src/test/resources/sql/h2.sql'"); - } finally { - cleanupResources(conn, stmt, null); - } - } -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-api-config.xml b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-api-config.xml deleted file mode 100644 index 3fad2eceb..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-api-config.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - jdbc/MobileIOSDM_DS - - - - - jdbc/MobileAndroidDM_DS - - - - - jdbc/MobileWindowsDM_DS - - - - - - diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-api-publisher-config.xml b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-api-publisher-config.xml deleted file mode 100644 index 94fb50462..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-api-publisher-config.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - jdbc/MobileDM_DS - - - - - - - - enrollment - admin - enrollment - 1.0.0 - http://localhost:9763/ - http,https - - - - - diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-apis-config.xml b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-apis-config.xml deleted file mode 100644 index 743fe6c24..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-apis-config.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - jdbc/MobileDM_DS - - - - - - - - enrollment - admin - enrollment - 1.0.0 - http://localhost:9763/ - http,https - - - - - diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-ds-config.xml b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-ds-config.xml deleted file mode 100644 index 1f1b5ef14..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-ds-config.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - jdbc/MobileDM_DS - - - - - - - - enrollment - admin - enrollment - 1.0.0 - http://localhost:9763/ - http,https - - - - - diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-jndi-config.xml b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-jndi-config.xml deleted file mode 100644 index 06dc33761..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-jndi-config.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - jdbc/MobileDM_DS - - - - - - - - enrollment - admin - enrollment - 1.0.0 - http://localhost:9763/ - http,https - - - - - diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-mgt-repo.xml b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-mgt-repo.xml deleted file mode 100644 index 617742635..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-mgt-repo.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - jdbc/MobileDM_DS - - - - - - - - enrollment - admin - enrollment - 1.0.0 - http://localhost:9763/ - http,https - - - - - diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/schema/MobileDeviceManagementConfigSchema.xsd b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/schema/MobileDeviceManagementConfigSchema.xsd deleted file mode 100644 index ff6435e50..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/schema/MobileDeviceManagementConfigSchema.xsd +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/log4j.properties b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/log4j.properties deleted file mode 100644 index 675d63149..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/log4j.properties +++ /dev/null @@ -1,33 +0,0 @@ -# -# Copyright 2015 WSO2, Inc. (http://wso2.com) -# -# WSO2 Inc. licenses this file to you under the Apache License, -# version 2.0 (the "License"); you may not use this file except -# in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# -# This is the log4j configuration file used by WSO2 Carbon -# -# IMPORTANT : Please do not remove or change the names of any -# of the Appenders defined here. The layout pattern & log file -# can be changed using the WSO2 Carbon Management Console, and those -# settings will override the settings in this file. -# - -log4j.rootLogger=DEBUG, STD_OUT - -# Redirect log messages to console -log4j.appender.STD_OUT=org.apache.log4j.ConsoleAppender -log4j.appender.STD_OUT.Target=System.out -log4j.appender.STD_OUT.layout=org.apache.log4j.PatternLayout -log4j.appender.STD_OUT.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/sql/h2.sql b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/sql/h2.sql deleted file mode 100644 index 78b5b7b8b..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/sql/h2.sql +++ /dev/null @@ -1,54 +0,0 @@ - --- ----------------------------------------------------- --- Table `AD_DEVICE` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `AD_DEVICE` ( - `DEVICE_ID` VARCHAR(45) NOT NULL , - `PUSH_TOKEN` VARCHAR(45) NULL DEFAULT NULL , - `IMEI` VARCHAR(45) NULL DEFAULT NULL , - `IMSI` VARCHAR(45) NULL DEFAULT NULL , - `OS_VERSION` VARCHAR(45) NULL DEFAULT NULL , - `DEVICE_MODEL` VARCHAR(45) NULL DEFAULT NULL , - `VENDOR` VARCHAR(45) NULL DEFAULT NULL , - `LATITUDE` VARCHAR(45) NULL DEFAULT NULL, - `LONGITUDE` VARCHAR(45) NULL DEFAULT NULL, - `CHALLENGE` VARCHAR(45) NULL DEFAULT NULL, - `TOKEN` VARCHAR(500) NULL DEFAULT NULL, - `UNLOCK_TOKEN` VARCHAR(500) NULL DEFAULT NULL, - `SERIAL` VARCHAR(45) NULL DEFAULT NULL, - PRIMARY KEY (`DEVICE_ID`) ); - - --- ----------------------------------------------------- --- Table `AD_FEATURE` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `AD_FEATURE` ( - `ID` INT NOT NULL AUTO_INCREMENT , - `CODE` VARCHAR(45) NOT NULL, - `NAME` VARCHAR(100) NULL , - `DESCRIPTION` VARCHAR(200) NULL , - `DEVICE_TYPE` VARCHAR(50) NULL , - PRIMARY KEY (`ID`) ); - --- ----------------------------------------------------- --- Table `AD_OPERATION` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `AD_OPERATION` ( - `OPERATION_ID` INT NOT NULL AUTO_INCREMENT , - `FEATURE_CODE` VARCHAR(45) NOT NULL , - `CREATED_DATE` BIGINT NULL , - PRIMARY KEY (`OPERATION_ID`)); - - --- ----------------------------------------------------- --- Table `AD_FEATURE_PROPERTY` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `AD_FEATURE_PROPERTY` ( - `PROPERTY` VARCHAR(45) NOT NULL , - `FEATURE_ID` INT NOT NULL , - PRIMARY KEY (`PROPERTY`) , - CONSTRAINT `fk_AD_FEATURE_PROPERTY_AD_FEATURE1` - FOREIGN KEY (`FEATURE_ID` ) - REFERENCES `AD_FEATURE` (`ID` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/testng.xml b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/testng.xml deleted file mode 100644 index f73ab880b..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/testng.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.url.printer/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.url.printer/pom.xml deleted file mode 100644 index e19a3f965..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.url.printer/pom.xml +++ /dev/null @@ -1,82 +0,0 @@ - - - - device-mgt - org.wso2.carbon.devicemgt-plugins - 2.1.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.mobile.url.printer - 2.1.0-SNAPSHOT - bundle - WSO2 Carbon - Startup Handler That Prints MDM End-User Web-App URL - WSO2 Carbon - Startup Handler That Prints MDM End-User Web-App URL - http://wso2.org - - - - - org.apache.felix - maven-scr-plugin - - - org.apache.felix - maven-bundle-plugin - 1.4.0 - true - - - ${project.artifactId} - ${project.artifactId} - ${carbon.mobile.device.mgt.version} - Bundle Containing The Startup Handler That Prints MDM End-User Web-App URL - org.wso2.carbon.device.mgt.mobile.url.printer.internal - - org.osgi.framework, - org.osgi.service.component, - org.apache.commons.logging, - org.apache.axis2.*;version="${axis2.osgi.version.range}", - org.wso2.carbon.core, - org.wso2.carbon.utils.*, - - - !org.wso2.carbon.device.mgt.mobile.url.printer.internal, - org.wso2.carbon.device.mgt.mobile.url.printer, - - - - - - - - - - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.osgi - org.eclipse.osgi.services - - - org.wso2.carbon - org.wso2.carbon.core - - - org.wso2.carbon - org.wso2.carbon.logging - - - org.wso2.carbon - org.wso2.carbon.utils - - - org.apache.axis2.wso2 - axis2 - - - - diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.url.printer/src/main/java/org/wso2/carbon/device/mgt/mobile/url/printer/URLPrinterStartupHandler.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.url.printer/src/main/java/org/wso2/carbon/device/mgt/mobile/url/printer/URLPrinterStartupHandler.java deleted file mode 100644 index 80aa39805..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.url.printer/src/main/java/org/wso2/carbon/device/mgt/mobile/url/printer/URLPrinterStartupHandler.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.url.printer; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.core.ServerStartupObserver; -import org.wso2.carbon.device.mgt.mobile.url.printer.internal.URLPrinterDataHolder; -import org.wso2.carbon.utils.CarbonUtils; -import org.wso2.carbon.utils.ConfigurationContextService; -import org.wso2.carbon.utils.NetworkUtils; - -public class URLPrinterStartupHandler implements ServerStartupObserver { - - private static final Log log = LogFactory.getLog(URLPrinterStartupHandler.class); - - @Override - public void completingServerStartup() { - - } - - @Override - public void completedServerStartup() { - log.info("EMM Console URL : " + this.getEmmUrl()); - } - - private String getEmmUrl() { - // Hostname - String hostName = "localhost"; - try { - hostName = NetworkUtils.getMgtHostName(); - } catch (Exception ignored) { - } - // HTTPS port - String mgtConsoleTransport = CarbonUtils.getManagementTransport(); - ConfigurationContextService configContextService = - URLPrinterDataHolder.getInstance().getConfigurationContextService(); - int port = CarbonUtils.getTransportPort(configContextService, mgtConsoleTransport); - int httpsProxyPort = - CarbonUtils.getTransportProxyPort(configContextService.getServerConfigContext(), - mgtConsoleTransport); - if (httpsProxyPort > 0) { - port = httpsProxyPort; - } - return "https://" + hostName + ":" + port + "/emm"; - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.url.printer/src/main/java/org/wso2/carbon/device/mgt/mobile/url/printer/internal/URLPrinterDataHolder.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.url.printer/src/main/java/org/wso2/carbon/device/mgt/mobile/url/printer/internal/URLPrinterDataHolder.java deleted file mode 100644 index 0dd8a459d..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.url.printer/src/main/java/org/wso2/carbon/device/mgt/mobile/url/printer/internal/URLPrinterDataHolder.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.wso2.carbon.device.mgt.mobile.url.printer.internal; - -import org.wso2.carbon.utils.ConfigurationContextService; - -public class URLPrinterDataHolder { - - private ConfigurationContextService configurationContextService; - private static URLPrinterDataHolder thisInstance = new URLPrinterDataHolder(); - - private URLPrinterDataHolder() {} - - public static URLPrinterDataHolder getInstance() { - return thisInstance; - } - - public ConfigurationContextService getConfigurationContextService() { - return configurationContextService; - } - - public void setConfigurationContextService(ConfigurationContextService configurationContextService) { - this.configurationContextService = configurationContextService; - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.url.printer/src/main/java/org/wso2/carbon/device/mgt/mobile/url/printer/internal/URLPrinterStartupHandlerServiceComponent.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.url.printer/src/main/java/org/wso2/carbon/device/mgt/mobile/url/printer/internal/URLPrinterStartupHandlerServiceComponent.java deleted file mode 100644 index 88a2b2dae..000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.url.printer/src/main/java/org/wso2/carbon/device/mgt/mobile/url/printer/internal/URLPrinterStartupHandlerServiceComponent.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.url.printer.internal; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.osgi.framework.BundleContext; -import org.osgi.service.component.ComponentContext; -import org.wso2.carbon.core.ServerStartupObserver; -import org.wso2.carbon.device.mgt.mobile.url.printer.URLPrinterStartupHandler; -import org.wso2.carbon.utils.ConfigurationContextService; - -/** - * @scr.component name="org.wso2.carbon.device.mgt.mobile.url.printer.URLPrinterStartupHandlerServiceComponent" - * immediate="true" - * @scr.reference name="config.context.service" - * interface="org.wso2.carbon.utils.ConfigurationContextService" - * cardinality="0..1" - * policy="dynamic" - * bind="setConfigurationContextService" - * unbind="unsetConfigurationContextService" - */ -public class URLPrinterStartupHandlerServiceComponent { - - private static final Log log = LogFactory.getLog(URLPrinterStartupHandlerServiceComponent.class); - - @SuppressWarnings("unused") - protected void activate(ComponentContext componentContext) { - try { - BundleContext bundleContext = componentContext.getBundleContext(); - /* Registering URL printer start-up handler */ - bundleContext.registerService(ServerStartupObserver.class, new URLPrinterStartupHandler(), null); - } catch (Throwable e) { - log.error("Error occurred while activating URL printer server start-up handler service component", e); - } - } - - @SuppressWarnings("unused") - protected void deactivate(ComponentContext componentContext) { - //do nothing - } - - protected void setConfigurationContextService(ConfigurationContextService configurationContextService) { - if (log.isDebugEnabled()) { - log.debug("Setting ConfigurationContextService"); - } - URLPrinterDataHolder.getInstance().setConfigurationContextService(configurationContextService); - } - - protected void unsetConfigurationContextService(ConfigurationContextService configurationContextService) { - if (log.isDebugEnabled()) { - log.debug("Un-setting ConfigurationContextService"); - } - URLPrinterDataHolder.getInstance().setConfigurationContextService(null); - } - -} diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml deleted file mode 100644 index 78a844e8d..000000000 --- a/components/device-mgt/pom.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - org.wso2.carbon.devicemgt-plugins - carbon-device-mgt-plugins-parent - 2.1.0-SNAPSHOT - ../../pom.xml - - - 4.0.0 - org.wso2.carbon.devicemgt-plugins - device-mgt - 2.1.0-SNAPSHOT - pom - WSO2 Carbon - Mobile Device Management Component - http://wso2.org - - - org.wso2.carbon.device.mgt.mobile.impl - org.wso2.carbon.device.mgt.mobile.url.printer - - - - - - - org.apache.felix - maven-scr-plugin - 1.7.2 - - - generate-scr-scrdescriptor - - scr - - - - - - - - diff --git a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.controller.service.impl/pom.xml b/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.controller.service.impl/pom.xml deleted file mode 100644 index b1930e8f0..000000000 --- a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.controller.service.impl/pom.xml +++ /dev/null @@ -1,261 +0,0 @@ - - - - - - camera-plugin - org.wso2.carbon.devicemgt-plugins - 2.1.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.device.mgt.iot.camera.controller.service.impl - war - WSO2 Carbon - IoT Server Camera API - WSO2 Carbon - Camera Service Controller API Implementation - http://wso2.org - - - - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.common - provided - - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.core - provided - - - org.apache.axis2.wso2 - axis2-client - - - - - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.analytics - provided - - - org.apache.axis2.wso2 - axis2-client - - - - - - org.wso2.carbon.devicemgt - org.wso2.carbon.certificate.mgt.core - provided - - - commons-codec.wso2 - commons-codec - - - - - - - - org.apache.cxf - cxf-rt-frontend-jaxws - provided - - - org.apache.cxf - cxf-rt-frontend-jaxrs - provided - - - org.apache.cxf - cxf-rt-transports-http - provided - - - - - org.eclipse.paho - org.eclipse.paho.client.mqttv3 - provided - - - - - org.apache.httpcomponents - httpasyncclient - 4.1 - provided - - - org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot - provided - - - org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.camera.plugin.impl - provided - - - - - org.codehaus.jackson - jackson-core-asl - - - org.codehaus.jackson - jackson-jaxrs - - - javax - javaee-web-api - provided - - - javax.ws.rs - jsr311-api - provided - - - commons-httpclient.wso2 - commons-httpclient - provided - - - - org.wso2.carbon - org.wso2.carbon.utils - provided - - - org.bouncycastle.wso2 - bcprov-jdk15on - - - org.wso2.carbon - org.wso2.carbon.user.api - - - org.wso2.carbon - org.wso2.carbon.queuing - - - org.wso2.carbon - org.wso2.carbon.base - - - org.apache.axis2.wso2 - axis2 - - - org.igniterealtime.smack.wso2 - smack - - - org.igniterealtime.smack.wso2 - smackx - - - jaxen - jaxen - - - commons-fileupload.wso2 - commons-fileupload - - - org.apache.ant.wso2 - ant - - - org.apache.ant.wso2 - ant - - - commons-httpclient.wso2 - commons-httpclient - - - org.eclipse.equinox - javax.servlet - - - org.wso2.carbon - org.wso2.carbon.registry.api - - - - - - commons-codec.wso2 - commons-codec - - - - org.wso2.carbon.devicemgt - org.wso2.carbon.apimgt.annotations - provided - - - - org.igniterealtime.smack.wso2 - smack - provided - - - org.igniterealtime.smack.wso2 - smackx - provided - - - org.wso2.carbon.devicemgt - org.wso2.carbon.apimgt.webapp.publisher - provided - - - - - - - - - maven-compiler-plugin - - UTF-8 - ${wso2.maven.compiler.source} - ${wso2.maven.compiler.target} - - - - maven-war-plugin - - camera - - - - - - diff --git a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.manager.service.impl/pom.xml b/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.manager.service.impl/pom.xml deleted file mode 100644 index 98667f028..000000000 --- a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.manager.service.impl/pom.xml +++ /dev/null @@ -1,261 +0,0 @@ - - - - - - camera-plugin - org.wso2.carbon.devicemgt-plugins - 2.1.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.device.mgt.iot.camera.manager.service.impl - war - WSO2 Carbon - IoT Server Camera API - WSO2 Carbon - Camera Service Management API Implementation - http://wso2.org - - - - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.common - provided - - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.core - provided - - - org.apache.axis2.wso2 - axis2-client - - - - - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.analytics - provided - - - org.apache.axis2.wso2 - axis2-client - - - - - - org.wso2.carbon.devicemgt - org.wso2.carbon.certificate.mgt.core - provided - - - commons-codec.wso2 - commons-codec - - - - - - - - org.apache.cxf - cxf-rt-frontend-jaxws - provided - - - org.apache.cxf - cxf-rt-frontend-jaxrs - provided - - - org.apache.cxf - cxf-rt-transports-http - provided - - - - - org.eclipse.paho - org.eclipse.paho.client.mqttv3 - provided - - - - - org.apache.httpcomponents - httpasyncclient - 4.1 - provided - - - org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot - provided - - - org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.camera.plugin.impl - provided - - - - - org.codehaus.jackson - jackson-core-asl - - - org.codehaus.jackson - jackson-jaxrs - - - javax - javaee-web-api - provided - - - javax.ws.rs - jsr311-api - provided - - - commons-httpclient.wso2 - commons-httpclient - provided - - - - org.wso2.carbon - org.wso2.carbon.utils - provided - - - org.bouncycastle.wso2 - bcprov-jdk15on - - - org.wso2.carbon - org.wso2.carbon.user.api - - - org.wso2.carbon - org.wso2.carbon.queuing - - - org.wso2.carbon - org.wso2.carbon.base - - - org.apache.axis2.wso2 - axis2 - - - org.igniterealtime.smack.wso2 - smack - - - org.igniterealtime.smack.wso2 - smackx - - - jaxen - jaxen - - - commons-fileupload.wso2 - commons-fileupload - - - org.apache.ant.wso2 - ant - - - org.apache.ant.wso2 - ant - - - commons-httpclient.wso2 - commons-httpclient - - - org.eclipse.equinox - javax.servlet - - - org.wso2.carbon - org.wso2.carbon.registry.api - - - - - - commons-codec.wso2 - commons-codec - - - - org.wso2.carbon.devicemgt - org.wso2.carbon.apimgt.annotations - provided - - - - org.igniterealtime.smack.wso2 - smack - provided - - - org.igniterealtime.smack.wso2 - smackx - provided - - - org.wso2.carbon.devicemgt - org.wso2.carbon.apimgt.webapp.publisher - provided - - - - - - - - - maven-compiler-plugin - - UTF-8 - ${wso2.maven.compiler.source} - ${wso2.maven.compiler.target} - - - - maven-war-plugin - - camera_mgt - - - - - - diff --git a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/pom.xml b/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/pom.xml deleted file mode 100644 index bd3c82af6..000000000 --- a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/pom.xml +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - camera-plugin - org.wso2.carbon.devicemgt-plugins - 2.1.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.device.mgt.iot.camera.plugin.impl - bundle - WSO2 Carbon - IoT Server Camera Management Plugin - WSO2 Carbon - Camera Management/Control Plugin Implementation - http://wso2.org - - - - - org.apache.felix - maven-scr-plugin - - - maven-compiler-plugin - - 1.7 - 1.7 - - 2.3.2 - - - org.apache.felix - maven-bundle-plugin - 1.4.0 - true - - - ${project.artifactId} - ${project.artifactId} - ${carbon.devicemgt.plugins.version} - IoT Server Camera Impl Bundle - org.wso2.carbon.device.mgt.iot.camera.plugin.internal - - org.osgi.framework, - org.osgi.service.component, - org.apache.commons.logging, - javax.xml.bind.*, - javax.naming, - javax.sql, - javax.xml.bind.annotation.*, - javax.xml.parsers, - javax.net, - javax.net.ssl, - org.w3c.dom, - org.wso2.carbon.device.mgt.common.*, - org.wso2.carbon.device.mgt.common, - org.wso2.carbon.context.*, - org.wso2.carbon.ndatasource.core, - org.wso2.carbon.device.mgt.iot.*, - - - - !org.wso2.carbon.device.mgt.iot.camera.plugin.internal, - org.wso2.carbon.device.mgt.iot.camera.plugin.* - - - - - - - - - - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.osgi - org.eclipse.osgi.services - - - - org.wso2.carbon - org.wso2.carbon.logging - - - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.common - - - org.wso2.carbon - org.wso2.carbon.ndatasource.core - - - - org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot - - - - - \ No newline at end of file diff --git a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/impl/CameraManager.java b/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/impl/CameraManager.java deleted file mode 100644 index 1498a4b58..000000000 --- a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/impl/CameraManager.java +++ /dev/null @@ -1,281 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.device.mgt.iot.camera.plugin.impl; - - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.common.Device; -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.DeviceManager; -import org.wso2.carbon.device.mgt.common.EnrolmentInfo; -import org.wso2.carbon.device.mgt.common.FeatureManager; -import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration; -import org.wso2.carbon.device.mgt.common.license.mgt.License; -import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException; -import org.wso2.carbon.device.mgt.iot.camera.plugin.impl.dao.CameraDAO; -import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceManagementDAOException; -import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceManagementDAOFactory; -import org.wso2.carbon.device.mgt.iot.util.iotdevice.dto.IotDevice; -import org.wso2.carbon.device.mgt.iot.util.iotdevice.util.IotDeviceManagementUtil; - -import java.util.ArrayList; -import java.util.List; - - -/** - * This represents the FireAlarm implementation of DeviceManagerService. - */ -public class CameraManager implements DeviceManager { - - private static final IotDeviceManagementDAOFactory iotDeviceManagementDAOFactory = new CameraDAO(); - private static final Log log = LogFactory.getLog(CameraManager.class); - - - @Override - public FeatureManager getFeatureManager() { - return null; - } - - @Override - public boolean saveConfiguration(TenantConfiguration tenantConfiguration) - throws DeviceManagementException { - //TODO implement this - return false; - } - - @Override - public TenantConfiguration getConfiguration() throws DeviceManagementException { - //TODO implement this - return null; - } - - @Override - public boolean enrollDevice(Device device) throws DeviceManagementException { - boolean status; - IotDevice iotDevice = IotDeviceManagementUtil.convertToIotDevice(device); - try { - if (log.isDebugEnabled()) { - log.debug("Enrolling a new Camera device : " + device.getDeviceIdentifier()); - } - CameraDAO.beginTransaction(); - status = iotDeviceManagementDAOFactory.getIotDeviceDAO().addIotDevice( - iotDevice); - CameraDAO.commitTransaction(); - } catch (IotDeviceManagementDAOException e) { - try { - CameraDAO.rollbackTransaction(); - } catch (IotDeviceManagementDAOException iotDAOEx) { - String msg = "Error occurred while roll back the device enrol transaction :" + device.toString(); - log.warn(msg, iotDAOEx); - } - String msg = "Error while enrolling the Camera device : " + device.getDeviceIdentifier(); - log.error(msg, e); - throw new DeviceManagementException(msg, e); - } - return status; - } - - @Override - public boolean modifyEnrollment(Device device) throws DeviceManagementException { - boolean status; - IotDevice iotDevice = IotDeviceManagementUtil.convertToIotDevice(device); - try { - if (log.isDebugEnabled()) { - log.debug("Modifying the Camera device enrollment data"); - } - CameraDAO.beginTransaction(); - status = iotDeviceManagementDAOFactory.getIotDeviceDAO() - .updateIotDevice(iotDevice); - CameraDAO.commitTransaction(); - } catch (IotDeviceManagementDAOException e) { - try { - CameraDAO.rollbackTransaction(); - } catch (IotDeviceManagementDAOException iotDAOEx) { - String msg = "Error occurred while roll back the update device transaction :" + device.toString(); - log.warn(msg, iotDAOEx); - } - String msg = "Error while updating the enrollment of the Camera device : " + - device.getDeviceIdentifier(); - log.error(msg, e); - throw new DeviceManagementException(msg, e); - } - return status; - } - - @Override - public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException { - boolean status; - try { - if (log.isDebugEnabled()) { - log.debug("Dis-enrolling Camera device : " + deviceId); - } - CameraDAO.beginTransaction(); - status = iotDeviceManagementDAOFactory.getIotDeviceDAO() - .deleteIotDevice(deviceId.getId()); - CameraDAO.commitTransaction(); - } catch (IotDeviceManagementDAOException e) { - try { - CameraDAO.rollbackTransaction(); - } catch (IotDeviceManagementDAOException iotDAOEx) { - String msg = "Error occurred while roll back the device dis enrol transaction :" + deviceId.toString(); - log.warn(msg, iotDAOEx); - } - String msg = "Error while removing the Camera device : " + deviceId.getId(); - log.error(msg, e); - throw new DeviceManagementException(msg, e); - } - return status; - } - - @Override - public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException { - boolean isEnrolled = false; - try { - if (log.isDebugEnabled()) { - log.debug("Checking the enrollment of Camera device : " + deviceId.getId()); - } - IotDevice iotDevice = - iotDeviceManagementDAOFactory.getIotDeviceDAO().getIotDevice( - deviceId.getId()); - if (iotDevice != null) { - isEnrolled = true; - } - } catch (IotDeviceManagementDAOException e) { - String msg = "Error while checking the enrollment status of Camera device : " + - deviceId.getId(); - log.error(msg, e); - throw new DeviceManagementException(msg, e); - } - return isEnrolled; - } - - @Override - public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException { - return true; - } - - @Override - public boolean setActive(DeviceIdentifier deviceId, boolean status) - throws DeviceManagementException { - return true; - } - - @Override - public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException { - Device device; - try { - if (log.isDebugEnabled()) { - log.debug("Getting the details of Camera device : " + deviceId.getId()); - } - IotDevice iotDevice = iotDeviceManagementDAOFactory.getIotDeviceDAO(). - getIotDevice(deviceId.getId()); - device = IotDeviceManagementUtil.convertToDevice(iotDevice); - } catch (IotDeviceManagementDAOException e) { - String msg = "Error while fetching the Camera device : " + deviceId.getId(); - log.error(msg, e); - throw new DeviceManagementException(msg, e); - } - return device; - } - - @Override - public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) - throws DeviceManagementException { - return true; - } - - public boolean isClaimable(DeviceIdentifier deviceIdentifier) throws DeviceManagementException { - return false; - } - - @Override - public boolean setStatus(DeviceIdentifier deviceId, String currentOwner, - EnrolmentInfo.Status status) throws DeviceManagementException { - return false; - } - - @Override - public License getLicense(String s) throws LicenseManagementException { - return null; - } - - @Override - public void addLicense(License license) throws LicenseManagementException { - - } - - @Override - public boolean requireDeviceAuthorization() { - return false; - } - - @Override - public boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device) throws DeviceManagementException { - boolean status; - IotDevice iotDevice = IotDeviceManagementUtil.convertToIotDevice(device); - try { - if (log.isDebugEnabled()) { - log.debug( - "updating the details of Camera device : " + deviceIdentifier); - } - CameraDAO.beginTransaction(); - status = iotDeviceManagementDAOFactory.getIotDeviceDAO() - .updateIotDevice(iotDevice); - CameraDAO.commitTransaction(); - } catch (IotDeviceManagementDAOException e) { - try { - CameraDAO.rollbackTransaction(); - } catch (IotDeviceManagementDAOException iotDAOEx) { - String msg = "Error occurred while roll back the update device info transaction :" + device.toString(); - log.warn(msg, iotDAOEx); - } - String msg = - "Error while updating the Camera device : " + deviceIdentifier; - log.error(msg, e); - throw new DeviceManagementException(msg, e); - } - return status; - } - - @Override - public List getAllDevices() throws DeviceManagementException { - List devices = null; - try { - if (log.isDebugEnabled()) { - log.debug("Fetching the details of all Camera devices"); - } - List iotDevices = - iotDeviceManagementDAOFactory.getIotDeviceDAO().getAllIotDevices(); - if (iotDevices != null) { - devices = new ArrayList(); - for (IotDevice iotDevice : iotDevices) { - devices.add(IotDeviceManagementUtil.convertToDevice(iotDevice)); - } - } - } catch (IotDeviceManagementDAOException e) { - String msg = "Error while fetching all Camera devices."; - log.error(msg, e); - throw new DeviceManagementException(msg, e); - } - return devices; - } - -} \ No newline at end of file diff --git a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/impl/CameraManagerService.java b/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/impl/CameraManagerService.java deleted file mode 100644 index a6241b940..000000000 --- a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/impl/CameraManagerService.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.device.mgt.iot.camera.plugin.impl; - -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.DeviceManager; -import org.wso2.carbon.device.mgt.common.app.mgt.Application; -import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException; -import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager; -import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; -import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; -import org.wso2.carbon.device.mgt.iot.camera.plugin.constants.CameraConstants; - -import java.util.List; - -public class CameraManagerService implements DeviceManagementService{ - private DeviceManager deviceManager; - @Override - public String getType() { - return CameraConstants.DEVICE_TYPE; - } - - - @Override - public String getProviderTenantDomain() { - return "carbon.super"; - } - - @Override - public boolean isSharedWithAllTenants() { - return true; - } - - @Override - public String[] getSharedTenantsDomain() { - return new String[0]; - } - - @Override - public void init() throws DeviceManagementException { - this.deviceManager=new CameraManager(); - } - - @Override - public DeviceManager getDeviceManager() { - return deviceManager; - } - - @Override - public ApplicationManager getApplicationManager() { - return null; - } - - @Override - public void notifyOperationToDevices(Operation operation, List deviceIds) - throws DeviceManagementException { - - } - - @Override - public Application[] getApplications(String domain, int pageNumber, int size) - throws ApplicationManagementException { - return new Application[0]; - } - - @Override - public void updateApplicationStatus(DeviceIdentifier deviceId, Application application, - String status) throws ApplicationManagementException { - - } - - @Override - public String getApplicationStatus(DeviceIdentifier deviceId, Application application) - throws ApplicationManagementException { - return null; - } - - @Override - public void installApplicationForDevices(Operation operation, List deviceIdentifiers) - throws ApplicationManagementException { - - } - - @Override - public void installApplicationForUsers(Operation operation, List userNameList) - throws ApplicationManagementException { - - } - - @Override - public void installApplicationForUserRoles(Operation operation, List userRoleList) - throws ApplicationManagementException { - - } -} diff --git a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/impl/dao/CameraDAO.java b/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/impl/dao/CameraDAO.java deleted file mode 100644 index 35571d851..000000000 --- a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/impl/dao/CameraDAO.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.device.mgt.iot.camera.plugin.impl.dao; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.iot.camera.plugin.constants.CameraConstants; -import org.wso2.carbon.device.mgt.iot.camera.plugin.impl.dao.impl.CameraDeviceDAOImpl; -import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceDAO; -import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceManagementDAOException; -import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceManagementDAOFactory; -import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceManagementDAOFactoryInterface; - -import javax.sql.DataSource; -import java.sql.Connection; -import java.sql.SQLException; - -public class CameraDAO extends IotDeviceManagementDAOFactory implements IotDeviceManagementDAOFactoryInterface { - - private static final Log log = LogFactory.getLog(CameraDAO.class); - static DataSource dataSource; - private static ThreadLocal currentConnection = new ThreadLocal(); - - public CameraDAO() { - initFireAlarmDAO(); - } - - public static void initFireAlarmDAO() { - dataSource = getDataSourceMap().get(CameraConstants.DEVICE_TYPE); - } - - @Override public IotDeviceDAO getIotDeviceDAO() { - return new CameraDeviceDAOImpl(); - } - - public static void beginTransaction() throws IotDeviceManagementDAOException { - try { - Connection conn = dataSource.getConnection(); - conn.setAutoCommit(false); - currentConnection.set(conn); - } catch (SQLException e) { - throw new IotDeviceManagementDAOException("Error occurred while retrieving datasource connection", e); - } - } - - public static Connection getConnection() throws IotDeviceManagementDAOException { - if (currentConnection.get() == null) { - try { - currentConnection.set(dataSource.getConnection()); - } catch (SQLException e) { - throw new IotDeviceManagementDAOException("Error occurred while retrieving data source connection", e); - } - } - return currentConnection.get(); - } - - public static void commitTransaction() throws IotDeviceManagementDAOException { - try { - Connection conn = currentConnection.get(); - if (conn != null) { - conn.commit(); - } else { - if (log.isDebugEnabled()) { - log.debug("Datasource connection associated with the current thread is null, hence commit " - + "has not been attempted"); - } - } - } catch (SQLException e) { - throw new IotDeviceManagementDAOException("Error occurred while committing the transaction", e); - } finally { - closeConnection(); - } - } - - public static void closeConnection() throws IotDeviceManagementDAOException { - - Connection con = currentConnection.get(); - if (con != null) { - try { - con.close(); - } catch (SQLException e) { - log.error("Error occurred while close the connection"); - } - } - currentConnection.remove(); - } - - public static void rollbackTransaction() throws IotDeviceManagementDAOException { - try { - Connection conn = currentConnection.get(); - if (conn != null) { - conn.rollback(); - } else { - if (log.isDebugEnabled()) { - log.debug("Datasource connection associated with the current thread is null, hence rollback " - + "has not been attempted"); - } - } - } catch (SQLException e) { - throw new IotDeviceManagementDAOException("Error occurred while rollback the transaction", e); - } finally { - closeConnection(); - } - } -} \ No newline at end of file diff --git a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/impl/dao/impl/CameraDeviceDAOImpl.java b/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/impl/dao/impl/CameraDeviceDAOImpl.java deleted file mode 100644 index 59e68335b..000000000 --- a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/impl/dao/impl/CameraDeviceDAOImpl.java +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.device.mgt.iot.camera.plugin.impl.dao.impl; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.iot.camera.plugin.constants.CameraConstants; -import org.wso2.carbon.device.mgt.iot.camera.plugin.impl.dao.CameraDAO; -import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceDAO; -import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceManagementDAOException; -import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.util.IotDeviceManagementDAOUtil; -import org.wso2.carbon.device.mgt.iot.util.iotdevice.dto.IotDevice; - -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Implements IotDeviceDAO for camera Devices. - */ -public class CameraDeviceDAOImpl implements IotDeviceDAO{ - - - private static final Log log = LogFactory.getLog(CameraDeviceDAOImpl.class); - - @Override - public IotDevice getIotDevice(String iotDeviceId) - throws IotDeviceManagementDAOException { - Connection conn = null; - PreparedStatement stmt = null; - IotDevice iotDevice = null; - ResultSet resultSet = null; - try { - conn = CameraDAO.getConnection(); - String selectDBQuery = - "SELECT CAMERA_DEVICE_ID, DEVICE_NAME" + - " FROM CAMERA_DEVICE WHERE CAMERA_DEVICE_ID = ?"; - stmt = conn.prepareStatement(selectDBQuery); - stmt.setString(1, iotDeviceId); - resultSet = stmt.executeQuery(); - - if (resultSet.next()) { - iotDevice = new IotDevice(); - iotDevice.setIotDeviceName(resultSet.getString( - CameraConstants.DEVICE_PLUGIN_DEVICE_NAME)); - Map propertyMap = new HashMap(); - - - - iotDevice.setDeviceProperties(propertyMap); - - if (log.isDebugEnabled()) { - log.debug("Camera device " + iotDeviceId + " data has been fetched from " + - "Camera database."); - } - } - } catch (SQLException e) { - String msg = "Error occurred while fetching Camera device : '" + iotDeviceId + "'"; - log.error(msg, e); - throw new IotDeviceManagementDAOException(msg, e); - } finally { - IotDeviceManagementDAOUtil.cleanupResources(stmt, resultSet); - CameraDAO.closeConnection(); - } - - return iotDevice; - } - - @Override - public boolean addIotDevice(IotDevice iotDevice) - throws IotDeviceManagementDAOException { - boolean status = false; - Connection conn = null; - PreparedStatement stmt = null; - try { - conn = CameraDAO.getConnection(); - String createDBQuery = - "INSERT INTO CAMERA_DEVICE(CAMERA_DEVICE_ID, DEVICE_NAME) VALUES (?, ?)"; - - stmt = conn.prepareStatement(createDBQuery); - stmt.setString(1, iotDevice.getIotDeviceId()); - stmt.setString(2,iotDevice.getIotDeviceName()); - if (iotDevice.getDeviceProperties() == null) { - iotDevice.setDeviceProperties(new HashMap()); - } - - - int rows = stmt.executeUpdate(); - if (rows > 0) { - status = true; - if (log.isDebugEnabled()) { - log.debug("Camera device " + iotDevice.getIotDeviceId() + " data has been" + - " added to the Camere database."); - } - } - } catch (SQLException e) { - String msg = "Error occurred while adding the Camera device '" + - iotDevice.getIotDeviceId() + "' to the Camera db."; - log.error(msg, e); - throw new IotDeviceManagementDAOException(msg, e); - } finally { - IotDeviceManagementDAOUtil.cleanupResources(stmt, null); - } - return status; - } - - @Override - public boolean updateIotDevice(IotDevice iotDevice) - throws IotDeviceManagementDAOException { - boolean status = false; - Connection conn = null; - PreparedStatement stmt = null; - try { - conn = CameraDAO.getConnection(); - String updateDBQuery = - "UPDATE CAMERA_DEVICE SET DEVICE_NAME = ? WHERE CAMERA_DEVICE_ID = ?"; - - stmt = conn.prepareStatement(updateDBQuery); - - if (iotDevice.getDeviceProperties() == null) { - iotDevice.setDeviceProperties(new HashMap()); - } - stmt.setString(1, iotDevice.getIotDeviceName()); - - stmt.setString(2, iotDevice.getIotDeviceId()); - int rows = stmt.executeUpdate(); - if (rows > 0) { - status = true; - if (log.isDebugEnabled()) { - log.debug("Camera device " + iotDevice.getIotDeviceId() + " data has been" + - " modified."); - } - } - } catch (SQLException e) { - String msg = "Error occurred while modifying the Camera device '" + - iotDevice.getIotDeviceId() + "' data."; - log.error(msg, e); - throw new IotDeviceManagementDAOException(msg, e); - } finally { - IotDeviceManagementDAOUtil.cleanupResources(stmt, null); - } - return status; - } - - @Override - public boolean deleteIotDevice(String iotDeviceId) - throws IotDeviceManagementDAOException { - boolean status = false; - Connection conn = null; - PreparedStatement stmt = null; - try { - conn = CameraDAO.getConnection(); - String deleteDBQuery = - "DELETE FROM CAMERA_DEVICE WHERE CAMERA_DEVICE_ID = ?"; - stmt = conn.prepareStatement(deleteDBQuery); - stmt.setString(1, iotDeviceId); - int rows = stmt.executeUpdate(); - if (rows > 0) { - status = true; - if (log.isDebugEnabled()) { - log.debug("Camera device " + iotDeviceId + " data has deleted from the Camera database."); - } - } - } catch (SQLException e) { - String msg = "Error occurred while deleting Camera device " + iotDeviceId; - log.error(msg, e); - throw new IotDeviceManagementDAOException(msg, e); - } finally { - IotDeviceManagementDAOUtil.cleanupResources(stmt, null); - } - return status; - } - - @Override - public List getAllIotDevices() - throws IotDeviceManagementDAOException { - - Connection conn = null; - PreparedStatement stmt = null; - ResultSet resultSet = null; - IotDevice iotDevice; - List iotDevices = new ArrayList(); - - try { - conn = CameraDAO.getConnection(); - String selectDBQuery = - "SELECT CAMERA_DEVICE_ID, DEVICE_NAME " + - "FROM CAMERA_DEVICE"; - stmt = conn.prepareStatement(selectDBQuery); - resultSet = stmt.executeQuery(); - while (resultSet.next()) { - iotDevice = new IotDevice(); - iotDevice.setIotDeviceId(resultSet.getString(CameraConstants.DEVICE_PLUGIN_DEVICE_ID)); - iotDevice.setIotDeviceName(resultSet.getString(CameraConstants.DEVICE_PLUGIN_DEVICE_NAME)); - - Map propertyMap = new HashMap(); - - iotDevice.setDeviceProperties(propertyMap); - iotDevices.add(iotDevice); - } - if (log.isDebugEnabled()) { - log.debug("All Camera device details have fetched from Firealarm database."); - } - return iotDevices; - } catch (SQLException e) { - String msg = "Error occurred while fetching all Camera device data'"; - log.error(msg, e); - throw new IotDeviceManagementDAOException(msg, e); - } finally { - IotDeviceManagementDAOUtil.cleanupResources(stmt, resultSet); - CameraDAO.closeConnection(); - } - - } - - } \ No newline at end of file diff --git a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/impl/util/VirtualFireAlarmUtils.java b/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/impl/util/VirtualFireAlarmUtils.java deleted file mode 100644 index b47c6d84a..000000000 --- a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/impl/util/VirtualFireAlarmUtils.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.device.mgt.iot.camera.plugin.impl.util; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.util.Map; - -/** - * Contains utility methods used by FireAlarm plugin. - */ -public class VirtualFireAlarmUtils { - - private static Log log = LogFactory.getLog(VirtualFireAlarmUtils.class); - - public static String getDeviceProperty(Map deviceProperties, String property) { - - String deviceProperty = deviceProperties.get(property); - - if (deviceProperty == null) { - return ""; - } - - return deviceProperty; - } - - -} diff --git a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/internal/CameraManagementServiceComponent.java b/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/internal/CameraManagementServiceComponent.java deleted file mode 100644 index 3546dd987..000000000 --- a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/internal/CameraManagementServiceComponent.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.device.mgt.iot.camera.plugin.internal; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceRegistration; -import org.osgi.service.component.ComponentContext; -import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; -import org.wso2.carbon.device.mgt.iot.camera.plugin.impl.CameraManagerService; -import org.wso2.carbon.device.mgt.iot.service.DeviceTypeService; - - -/** - * @scr.component name="org.wso2.carbon.device.mgt.iot.camera.plugin.internal - * .CameraManagementServiceComponent" - * immediate="true" - * @scr.reference name="org.wso2.carbon.device.mgt.iot.service.DeviceTypeServiceImpl" - * interface="org.wso2.carbon.device.mgt.iot.service.DeviceTypeService" - * cardinality="1..1" - * policy="dynamic" - * bind="setDeviceTypeService" - * unbind="unsetDeviceTypeService" - */ -public class CameraManagementServiceComponent { - - private static final Log log = LogFactory.getLog(CameraManagementServiceComponent.class); - private ServiceRegistration firealarmServiceRegRef; - - protected void activate(ComponentContext ctx) { - if (log.isDebugEnabled()) { - log.debug("Activating Camera Device Management Service Component"); - } - try { - BundleContext bundleContext = ctx.getBundleContext(); - firealarmServiceRegRef = - bundleContext.registerService(DeviceManagementService.class.getName(), - new CameraManagerService(), null); - - if (log.isDebugEnabled()) { - log.debug( - "Camera Device Management Service Component has been successfully activated"); - } - } catch (Throwable e) { - log.error( - "Error occurred while activating Camera Device Management Service Component", e); - } - } - - protected void deactivate(ComponentContext ctx) { - if (log.isDebugEnabled()) { - log.debug("De-activating Camera Device Management Service Component"); - } - try { - if (firealarmServiceRegRef != null) { - firealarmServiceRegRef.unregister(); - } - - if (log.isDebugEnabled()) { - log.debug( - "Camera Device Management Service Component has been successfully de-activated"); - } - } catch (Throwable e) { - log.error( - "Error occurred while de-activating Camera Device Management bundle", e); - } - } - - protected void setDeviceTypeService(DeviceTypeService deviceTypeService) { - /* This is to avoid this component getting initialized before the common registered */ - if (log.isDebugEnabled()) { - log.debug("Data source service set to mobile service component"); - } - } - - protected void unsetDeviceTypeService(DeviceTypeService deviceTypeService) { - //do nothing - } - - -} diff --git a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.ui/pom.xml b/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.ui/pom.xml deleted file mode 100644 index 89bc215a2..000000000 --- a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.ui/pom.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - camera-plugin - org.wso2.carbon.devicemgt-plugins - 2.1.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.device.mgt.iot.camera.ui - WSO2 Carbon - IoT Server Camera UI - pom - - - - - maven-assembly-plugin - 2.5.5 - - ${project.artifactId}-${carbon.device.mgt.version} - false - - src/assembly/src.xml - - - - - create-archive - package - - single - - - - - - - - \ No newline at end of file diff --git a/components/iot-plugins/camera-plugin/pom.xml b/components/iot-plugins/camera-plugin/pom.xml deleted file mode 100644 index ebeed88cc..000000000 --- a/components/iot-plugins/camera-plugin/pom.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - org.wso2.carbon.devicemgt-plugins - iot-plugins - 2.1.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.devicemgt-plugins - camera-plugin - pom - WSO2 Carbon - Arduino Plugin - http://wso2.org - - - org.wso2.carbon.device.mgt.iot.camera.controller.service.impl - org.wso2.carbon.device.mgt.iot.camera.manager.service.impl - org.wso2.carbon.device.mgt.iot.camera.plugin.impl - org.wso2.carbon.device.mgt.iot.camera.ui - - - - - - - org.apache.felix - maven-scr-plugin - 1.7.2 - - - generate-scr-scrdescriptor - - scr - - - - - - - - - diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.api/src/main/java/org/wso2/carbon/device/mgt/iot/api/DevicesManagerService.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.api/src/main/java/org/wso2/carbon/device/mgt/iot/api/DevicesManagerService.java index 58841062b..e1f8431bc 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.api/src/main/java/org/wso2/carbon/device/mgt/iot/api/DevicesManagerService.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.api/src/main/java/org/wso2/carbon/device/mgt/iot/api/DevicesManagerService.java @@ -22,7 +22,10 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.common.*; +import org.wso2.carbon.device.mgt.common.Device; +import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.EnrolmentInfo; import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration; import org.wso2.carbon.device.mgt.common.license.mgt.License; import org.wso2.carbon.device.mgt.core.dto.DeviceType; @@ -33,7 +36,17 @@ import org.wso2.carbon.device.mgt.iot.sensormgt.SensorRecord; import javax.jws.WebService; import javax.servlet.http.HttpServletResponse; -import javax.ws.rs.*; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.FormParam; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; import java.util.ArrayList; @@ -97,22 +110,6 @@ import java.util.List; } } - @Path("/device/user/{username}/ungrouped") - @GET - @Consumes("application/json") - @Produces("application/json") - public Device[] getUnGroupedDevices(@PathParam("username") String username){ - try{ - List devices = this.getServiceProvider().getUnGroupedDevices(username); - return this.getActiveDevices(devices); - } catch (DeviceManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return null; - } finally { - this.endTenantFlow(); - } - } - @Path("/device/user/{username}/all/count") @GET @Consumes("application/json") @@ -205,66 +202,6 @@ import java.util.List; } } - @Path("/device/enrollment/invitation") - @POST - @Consumes("application/json") - @Produces("application/json") - public void sendEnrolmentInvitation(@FormParam("messageBody") String messageBody, - @FormParam("mailTo") String[] mailTo, @FormParam("ccList") String[] ccList, - @FormParam("bccList") String[] bccList, @FormParam("subject") String subject, - @FormParam("firstName") String firstName, @FormParam("enrolmentUrl") String enrolmentUrl, - @FormParam("title") String title, @FormParam("password") String password, - @FormParam("userName") String userName){ - EmailMessageProperties config = new EmailMessageProperties(); - config.setMessageBody(messageBody); - config.setMailTo(mailTo); - config.setCcList(ccList); - config.setBccList(bccList); - config.setSubject(subject); - config.setFirstName(firstName); - config.setEnrolmentUrl(enrolmentUrl); - config.setTitle(title); - config.setUserName(userName); - config.setPassword(password); - try { - this.getServiceProvider().sendEnrolmentInvitation(config); - } catch (DeviceManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - } finally { - this.endTenantFlow(); - } - } - - @Path("/device/registration/invitation") - @POST - @Consumes("application/json") - @Produces("application/json") - public void sendRegistrationEmail(@FormParam("messageBody") String messageBody, - @FormParam("mailTo") String[] mailTo, @FormParam("ccList") String[] ccList, - @FormParam("bccList") String[] bccList, @FormParam("subject") String subject, - @FormParam("firstName") String firstName, @FormParam("enrolmentUrl") String enrolmentUrl, - @FormParam("title") String title, @FormParam("password") String password, - @FormParam("userName") String userName){ - EmailMessageProperties config = new EmailMessageProperties(); - config.setMessageBody(messageBody); - config.setMailTo(mailTo); - config.setCcList(ccList); - config.setBccList(bccList); - config.setSubject(subject); - config.setFirstName(firstName); - config.setEnrolmentUrl(enrolmentUrl); - config.setTitle(title); - config.setUserName(userName); - config.setPassword(password); - try { - this.getServiceProvider().sendRegistrationEmail(config); - } catch (DeviceManagementException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - } finally { - this.endTenantFlow(); - } - } - @Path("/device/type/{type}/config") @GET @Consumes("application/json") @@ -394,10 +331,12 @@ import java.util.List; @Produces("application/json") boolean modifyEnrollment(@PathParam("type") String type, @PathParam("identifier") String identifier, @FormParam("name") String name, @FormParam("description") String description, - @FormParam("groupId") int groupId, @FormParam("enrollmentId") int enrollmentId, - @FormParam("dateOfEnrolment") long dateOfEnrolment, @FormParam("dateOfLastUpdate") long dateOfLastUpdate, - @FormParam("ownership") EnrolmentInfo.OwnerShip ownership, @FormParam("status") EnrolmentInfo.Status status, - @FormParam("owner") String owner){ + @FormParam("enrollmentId") int enrollmentId, + @FormParam("dateOfEnrolment") long dateOfEnrolment, + @FormParam("dateOfLastUpdate") long dateOfLastUpdate, + @FormParam("ownership") EnrolmentInfo.OwnerShip ownership, + @FormParam("status") EnrolmentInfo.Status status, + @FormParam("owner") String owner) { EnrolmentInfo enrolmentInfo = new EnrolmentInfo(); enrolmentInfo.setId(enrollmentId); @@ -412,7 +351,6 @@ import java.util.List; device.setDeviceIdentifier(identifier); device.setName(name); device.setDescription(description); - device.setGroupId(groupId); device.setEnrolmentInfo(enrolmentInfo); try { return this.getServiceProvider().modifyEnrollment(device); @@ -430,10 +368,12 @@ import java.util.List; @Produces("application/json") boolean enrollDevice(@FormParam("type") String type, @FormParam("identifier") String identifier, @FormParam("name") String name, @FormParam("description") String description, - @FormParam("groupId") int groupId, @FormParam("enrollmentId") int enrollmentId, - @FormParam("dateOfEnrolment") long dateOfEnrolment, @FormParam("dateOfLastUpdate") long dateOfLastUpdate, - @FormParam("ownership") EnrolmentInfo.OwnerShip ownership, @FormParam("status") EnrolmentInfo.Status status, - @FormParam("owner") String owner){ + @FormParam("enrollmentId") int enrollmentId, + @FormParam("dateOfEnrolment") long dateOfEnrolment, + @FormParam("dateOfLastUpdate") long dateOfLastUpdate, + @FormParam("ownership") EnrolmentInfo.OwnerShip ownership, + @FormParam("status") EnrolmentInfo.Status status, + @FormParam("owner") String owner) { EnrolmentInfo enrolmentInfo = new EnrolmentInfo(); enrolmentInfo.setId(enrollmentId); @@ -448,7 +388,6 @@ import java.util.List; device.setDeviceIdentifier(identifier); device.setName(name); device.setDescription(description); - device.setGroupId(groupId); device.setEnrolmentInfo(enrolmentInfo); try { return this.getServiceProvider().enrollDevice(device); diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.api/src/main/java/org/wso2/carbon/device/mgt/iot/api/GroupManagerService.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.api/src/main/java/org/wso2/carbon/device/mgt/iot/api/GroupManagerService.java index 496410386..335a3c79e 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.api/src/main/java/org/wso2/carbon/device/mgt/iot/api/GroupManagerService.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.api/src/main/java/org/wso2/carbon/device/mgt/iot/api/GroupManagerService.java @@ -27,10 +27,10 @@ import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.PaginationRequest; import org.wso2.carbon.device.mgt.common.PaginationResult; -import org.wso2.carbon.device.mgt.group.common.DeviceGroup; -import org.wso2.carbon.device.mgt.group.common.GroupManagementException; -import org.wso2.carbon.device.mgt.group.common.GroupUser; -import org.wso2.carbon.device.mgt.group.core.providers.GroupManagementServiceProvider; +import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup; +import org.wso2.carbon.device.mgt.common.group.mgt.GroupManagementException; +import org.wso2.carbon.device.mgt.common.group.mgt.GroupUser; +import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService; import org.wso2.carbon.device.mgt.iot.util.ResponsePayload; import javax.jws.WebService; @@ -73,7 +73,7 @@ public class GroupManagerService { private HttpServletResponse response; private PrivilegedCarbonContext ctx; - private GroupManagementServiceProvider getServiceProvider() { + private GroupManagementProviderService getServiceProvider() { String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain(); String username = CarbonContext.getThreadLocalCarbonContext().getUsername(); PrivilegedCarbonContext.startTenantFlow(); @@ -82,7 +82,7 @@ public class GroupManagerService { if (log.isDebugEnabled()) { log.debug("Getting thread local carbon context for tenant domain: " + tenantDomain); } - return (GroupManagementServiceProvider) ctx.getOSGiService(GroupManagementServiceProvider.class, null); + return (GroupManagementProviderService) ctx.getOSGiService(GroupManagementProviderService.class, null); } private void endTenantFlow() { @@ -108,7 +108,7 @@ public class GroupManagerService { group.setDateOfLastUpdate(new Date().getTime()); boolean isAdded = false; try { - GroupManagementServiceProvider groupManagementService = this.getServiceProvider(); + GroupManagementProviderService groupManagementService = this.getServiceProvider(); int groupId = groupManagementService.createGroup(group, DEFAULT_ADMIN_ROLE, DEFAULT_ADMIN_PERMISSIONS); if (groupId == -2) { ResponsePayload responsePayload = new ResponsePayload(); @@ -151,7 +151,7 @@ public class GroupManagerService { return false; } try { - GroupManagementServiceProvider groupManagementService = this.getServiceProvider(); + GroupManagementProviderService groupManagementService = this.getServiceProvider(); DeviceGroup group = groupManagementService.getGroup(groupId); group.setName(name); group.setDescription(description); @@ -219,7 +219,7 @@ public class GroupManagerService { @FormParam("username") String username) { DeviceGroup[] deviceGroups = null; try { - List groups = this.getServiceProvider().findGroups(groupName, username); + List groups = this.getServiceProvider().findInGroups(groupName, username); deviceGroups = new DeviceGroup[groups.size()]; response.setStatus(Response.Status.OK.getStatusCode()); groups.toArray(deviceGroups); @@ -240,7 +240,7 @@ public class GroupManagerService { @QueryParam("permission") String permission) { DeviceGroup[] deviceGroups = null; try { - GroupManagementServiceProvider groupManagementService = this.getServiceProvider(); + GroupManagementProviderService groupManagementService = this.getServiceProvider(); List groups; if (permission != null) { groups = groupManagementService.getGroups(username, permission); @@ -475,7 +475,7 @@ public class GroupManagerService { @GET @Consumes("application/json") @Produces("application/json") - public PaginationResult getDevices(@PathParam("groupId") int groupId, + public List getDevices(@PathParam("groupId") int groupId, @QueryParam("index") int index, @QueryParam("limit") int limit) { try { diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.api/src/main/java/org/wso2/carbon/device/mgt/iot/api/StatsManagerService.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.api/src/main/java/org/wso2/carbon/device/mgt/iot/api/StatsManagerService.java deleted file mode 100644 index 4c696654a..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.api/src/main/java/org/wso2/carbon/device/mgt/iot/api/StatsManagerService.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.device.mgt.iot.api; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.analytics.common.AnalyticsDataRecord; -import org.wso2.carbon.device.mgt.analytics.exception.DeviceManagementAnalyticsException; -import org.wso2.carbon.device.mgt.analytics.service.DeviceAnalyticsService; -import javax.jws.WebService; -import javax.servlet.http.HttpServletResponse; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.Response; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -@WebService public class StatsManagerService { - - private static Log log = LogFactory.getLog(StatsManagerService.class); - - @Context //injected response proxy supporting multiple thread - private HttpServletResponse response; - //TODO THIS NEEDS TO BE REMOVED. - @Path("/stats/device/type/{type}/identifier/{identifier}") - @GET - @Consumes("application/json") - @Produces("application/json") - public DeviceUsageDTO[] getDeviceStats(@PathParam("type") String type, @PathParam("identifier") String identifier, - @QueryParam("table") String table, @QueryParam("column") String column, @QueryParam("username") String user, - @QueryParam("from") long from, @QueryParam("to") long to) { - - String fromDate = String.valueOf(from); - String toDate = String.valueOf(to); - - List deviceUsageDTOs = new ArrayList<>(); - PrivilegedCarbonContext.startTenantFlow(); - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - ctx.setTenantDomain("carbon.super", true); - DeviceAnalyticsService deviceAnalyticsService = (DeviceAnalyticsService) ctx - .getOSGiService(DeviceAnalyticsService.class, null); - String query = "owner:" + user + " AND deviceId:" + identifier + " AND deviceType:" + type + - " AND time : [" + fromDate + " TO " + toDate + "]"; - try { - List records = deviceAnalyticsService.getAllEventsForDevice(table, query); - - Collections.sort(records, new Comparator() { - @Override - public int compare(AnalyticsDataRecord o1, AnalyticsDataRecord o2) { - long t1 = (Long) o1.getValue("time"); - long t2 = (Long) o2.getValue("time"); - if (t1 < t2) { - return -1; - } else if (t1 > t2) { - return 1; - } else { - return 0; - } - } - }); - - for (AnalyticsDataRecord record : records) { - DeviceUsageDTO deviceUsageDTO = new DeviceUsageDTO(); - deviceUsageDTO.setTime("" + (long)record.getValue("time")); - deviceUsageDTO.setValue("" + (float) record.getValue(column.toLowerCase())); - deviceUsageDTOs.add(deviceUsageDTO); - } - return deviceUsageDTOs.toArray(new DeviceUsageDTO[deviceUsageDTOs.size()]); - } catch (DeviceManagementAnalyticsException e) { - String errorMsg= "Error on retrieving stats on table " + table + " with query " + query; - log.error(errorMsg); - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - return deviceUsageDTOs.toArray(new DeviceUsageDTO[deviceUsageDTOs.size()]); - } finally { - PrivilegedCarbonContext.endTenantFlow(); - } - } - -} diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.api/src/main/webapp/WEB-INF/cxf-servlet.xml index 1112d721e..739f0bee9 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.api/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.api/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -45,16 +45,6 @@ - - - - - - - - - - - - - - - - - - - diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/pom.xml b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/pom.xml index cfdc32dbc..fcfda42f8 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/pom.xml +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/pom.xml @@ -1,7 +1,7 @@ + @@ -66,24 +67,17 @@ javax.xml.namespace;resolution:=optional, javax.xml.validation;resolution:=optional, org.apache.commons.codec.binary, - org.apache.commons.collections.map, org.apache.http.*, org.apache.commons.io.*, org.apache.commons.logging.*, org.json;version="${commons-json.version}", org.wso2.carbon.base.*, org.wso2.carbon.databridge.*, - org.wso2.carbon.user.api, - org.wso2.carbon.user.core.service, org.osgi.framework, org.osgi.service.component, javax.xml.bind.*;resolution:=optional, - javax.naming;resolution:=optional, - javax.sql;resolution:=optional, javax.xml.bind.annotation.*;resolution:=optional, javax.xml.parsers.*;resolution:=optional, - javax.net;resolution:=optional, - javax.net.ssl;resolution:=optional, javax.crypto, org.apache.tomcat.util.codec.binary, org.w3c.dom;resolution:=optional, @@ -92,7 +86,6 @@ org.wso2.carbon.device.mgt.common.*, org.wso2.carbon.device.mgt.core.*, org.wso2.carbon.context.*;version="${carbon.kernel.version.range}", - org.wso2.carbon.ndatasource.core;version="${carbon.kernel.version.range}", org.eclipse.paho.client.mqttv3.*;version="${eclipse.paho.version}" @@ -144,6 +137,12 @@ org.wso2.carbon.devicemgt org.wso2.carbon.device.mgt.core + + + org.apache.httpcomponents.wso2 + httpclient + + org.wso2.carbon diff --git a/components/iot-plugins/pom.xml b/components/iot-plugins/pom.xml index 0020ee7f1..45e660e7c 100644 --- a/components/iot-plugins/pom.xml +++ b/components/iot-plugins/pom.xml @@ -27,20 +27,18 @@ 4.0.0 - org.wso2.carbon.devicemgt-plugins iot-plugins pom WSO2 Carbon - IoT Plugins http://wso2.org - androidsense-plugin - arduino-plugin - camera-plugin - digital-display-plugin - drone-analyzer-plugin - raspberrypi-plugin - virtual-fire-alarm-plugin + + + + + + iot-base-plugin diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.agent/pom.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml similarity index 97% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.agent/pom.xml rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml index 0da2c6395..867cac00e 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.agent/pom.xml +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml @@ -1,5 +1,5 @@ diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.agent/src/main/webapp/META-INF/webapp-classloading.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/META-INF/webapp-classloading.xml similarity index 91% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.agent/src/main/webapp/META-INF/webapp-classloading.xml rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/META-INF/webapp-classloading.xml index 46c211bb2..185de22d4 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.agent/src/main/webapp/META-INF/webapp-classloading.xml +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/META-INF/webapp-classloading.xml @@ -1,7 +1,7 @@ + --> + --> + + + + + android-plugin + org.wso2.carbon.devicemgt-plugins + 2.1.0-SNAPSHOT + ../pom.xml + + + 4.0.0 + org.wso2.carbon.device.mgt.mobile.android.ui + 2.1.0-SNAPSHOT + WSO2 Carbon - Mobile Android UI + pom + + + + + maven-assembly-plugin + 2.5.5 + + ${project.artifactId}-${carbon.device.mgt.version} + false + + src/assembly/src.xml + + + + + create-archive + package + + single + + + + + + + + \ No newline at end of file diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/assembly/src.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/assembly/src.xml new file mode 100644 index 000000000..2797034e0 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/assembly/src.xml @@ -0,0 +1,36 @@ + + + + src + + zip + + false + ${basedir}/src + + + ${basedir}/src/main/resources/jaggeryapps/devicemgt + / + true + + + \ 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.device-view/device-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.device-view/device-view.hbs new file mode 100644 index 000000000..bba71218c --- /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.device-view/device-view.hbs @@ -0,0 +1,174 @@ +{{#zone "device-opetations"}} +

+ Operations +
+
+ {{unit "mdm.unit.device.operation-bar"}} +
+{{/zone}} + +{{#zone "device-detail-properties"}} +
+ +
+
+ +
+ {{unit "cdmf.unit.device.details" device=device}} +
+
+
Policies
+
+ +
+
+ No policies found +
+
+
+
+ + + + + Add device specific policy +
+
+
Policy Compliance
+
+ +
+
+ Not available yet +
+
+
+
+
+
+
Device Location
+
+
+
+
+ Not available yet +
+
+
+
+
+
Installed Applications
+
+ +
+
+ Not available yet +
+
+
+
+
+
+
Operations Log
+
+ +
+
+ Not available yet +
+
+
+
+
+
+
+
+{{/zone}} + +{{#zone "bottomJs"}} + {{js "js/device-detail.js"}} + + {{js "js/load-map.js"}} +{{/zone}} \ 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.device-view/device-view.js 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.device-view/device-view.js new file mode 100644 index 000000000..da9c9809f --- /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.device-view/device-view.js @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +function onRequest(context) { + var log = new Log("detail.js"); + var deviceType = context.uriParams.deviceType; + var deviceId = request.getParameter("id"); + + if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) { + var deviceModule = require("/app/modules/device.js").deviceModule; + var device = deviceModule.viewDevice(deviceType, deviceId); + + if (device) { + var viewModel = {}; + var deviceInfo = device.properties.DEVICE_INFO; + if (deviceInfo != undefined && String(deviceInfo.toString()).length > 0) { + deviceInfo = parse(stringify(deviceInfo)); + viewModel.imei = device.properties.IMEI; + viewModel.model = device.properties.DEVICE_MODEL; + viewModel.vendor = device.properties.VENDOR; + viewModel.internal_memory = {}; + viewModel.external_memory = {}; + viewModel.location = { + latitude: device.properties.LATITUDE, + longitude: device.properties.LONGITUDE + }; + var info = {}; + var infoList = parse(deviceInfo); + if (infoList != null && infoList != undefined) { + for (var j = 0; j < infoList.length; j++) { + info[infoList[j].name] = infoList[j].value; + } + } + deviceInfo = info; + viewModel.BatteryLevel = deviceInfo.BATTERY_LEVEL; + viewModel.internal_memory.FreeCapacity = Math.round(deviceInfo.INTERNAL_AVAILABLE_MEMORY * 100) / 100; + viewModel.internal_memory.DeviceCapacityPercentage = Math.round(deviceInfo.INTERNAL_AVAILABLE_MEMORY + / deviceInfo.INTERNAL_TOTAL_MEMORY * 10000) / 100; + viewModel.external_memory.FreeCapacity = Math.round(deviceInfo.EXTERNAL_AVAILABLE_MEMORY * 100) / 100; + viewModel.external_memory.DeviceCapacityPercentage = Math.round(deviceInfo.EXTERNAL_AVAILABLE_MEMORY + / deviceInfo.EXTERNAL_TOTAL_MEMORY * 10000) / 100; + device.viewModel = viewModel; + } + } + + log.info(device); + var utility = require("/app/modules/utility.js").utility; + var configs = utility.getDeviceTypeConfig(deviceType); + return {"device": device, "label": configs["deviceType"]["label"]}; + } +} \ 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.device-view/device-view.json 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.device-view/device-view.json new file mode 100644 index 000000000..9eecd8f5b --- /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.device-view/device-view.json @@ -0,0 +1,3 @@ +{ + "version": "1.0.0" +} \ 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.device-view/public/js/device-detail.js 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.device-view/public/js/device-detail.js new file mode 100644 index 000000000..49c3512b9 --- /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.device-view/public/js/device-detail.js @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +(function () { + var deviceId = $(".device-id"); + var deviceIdentifier = deviceId.data("deviceid"); + var deviceType = deviceId.data("type"); + var payload = [deviceIdentifier]; + var serviceUrl = "/mdm-android-agent/operation/device-info"; + invokerUtil.post(serviceUrl, payload, + function (message) { + console.log(message); + }, function (message) { + console.log(message); + }); + $(document).ready(function () { + $(".panel-body").removeClass("hidden"); + $("#loading-content").remove(); + loadApplicationsList(); + + $("#refresh-apps").click(function () { + $('#apps-spinner').removeClass('hidden'); + loadApplicationsList(); + }); + loadOperationBar(deviceType); + }); + + function loadApplicationsList() { + var applicationsList = $("#applications-list"); + var deviceListingSrc = applicationsList.attr("src"); + var deviceId = applicationsList.data("device-id"); + var deviceType = applicationsList.data("device-type"); + + $.template("application-list", deviceListingSrc, function (template) { + var serviceURL = "/devicemgt_admin/operations/" + deviceType + "/" + deviceId + "/apps"; + + var successCallback = function (data) { + data = JSON.parse(data); + $('#apps-spinner').addClass('hidden'); + var viewModel = {}; + if (data != null && data.length > 0) { + for (var i = 0; i < data.length; i++) { + data[i].name = data[i].name.replace(/[^\w\s]/gi, ' '); + data[i].name = data[i].name.replace(/[0-9]/g, ' '); + } + } + viewModel.applications = data; + viewModel.deviceType = deviceType; + if (data.length > 0) { + var content = template(viewModel); + $("#applications-list-container").html(content); + } + + }; + invokerUtil.get(serviceURL, + successCallback, function (message) { + console.log(message); + }); + }); + } + +}()); 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.device-view/public/js/load-map.js 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.device-view/public/js/load-map.js new file mode 100644 index 000000000..a2a322f8c --- /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.device-view/public/js/load-map.js @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +$(document).ready(function () { + if (document.getElementById('device-location')) { + loadMap(); + } +}); + +function loadMap() { + var map; + + function initialize() { + var mapOptions = { + zoom: 18 + }; + var lat = $("#device-location").data("lat"); + var long = $("#device-location").data("long"); + + if (lat != null && lat != undefined && lat != "" && long != null && long != undefined && long != "") { + $("#map-error").hide(); + $("#device-location").show(); + map = new google.maps.Map(document.getElementById('device-location'), + mapOptions); + + var pos = new google.maps.LatLng(lat, long); + var marker = new google.maps.Marker({ + position: pos, + map: map + }); + + map.setCenter(pos); + } else { + $("#device-location").hide(); + $("#map-error").show(); + } + + } + + google.maps.event.addDomListener(window, 'load', initialize); +} \ 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.policy-edit/policy-edit.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.policy-edit/policy-edit.hbs new file mode 100644 index 000000000..c4bb415a1 --- /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.policy-edit/policy-edit.hbs @@ -0,0 +1 @@ +{{unit "mdm.unit.policy.edit"}} \ 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.policy-edit/policy-edit.json 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.policy-edit/policy-edit.json new file mode 100644 index 000000000..9eecd8f5b --- /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.policy-edit/policy-edit.json @@ -0,0 +1,3 @@ +{ + "version": "1.0.0" +} \ 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.policy-view/policy-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.policy-view/policy-view.hbs new file mode 100644 index 000000000..12cffe6bd --- /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.policy-view/policy-view.hbs @@ -0,0 +1 @@ +{{unit "mdm.unit.policy.view"}} \ 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.policy-view/policy-view.json 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.policy-view/policy-view.json new file mode 100644 index 000000000..9eecd8f5b --- /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.policy-view/policy-view.json @@ -0,0 +1,3 @@ +{ + "version": "1.0.0" +} \ 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.policy-wizard/policy-wizard.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.policy-wizard/policy-wizard.hbs new file mode 100644 index 000000000..0669d1ca6 --- /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.policy-wizard/policy-wizard.hbs @@ -0,0 +1 @@ +{{unit "mdm.unit.policy.wizard"}} \ 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.policy-wizard/policy-wizard.json 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.policy-wizard/policy-wizard.json new file mode 100644 index 000000000..9eecd8f5b --- /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.policy-wizard/policy-wizard.json @@ -0,0 +1,3 @@ +{ + "version": "1.0.0" +} \ 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/public/asset/android-agent.apk 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/asset/android-agent.apk new file mode 100644 index 000000000..a1d4ebfdb Binary files /dev/null and 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/asset/android-agent.apk differ 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/images/android-icon.png 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/images/android-icon.png new file mode 100644 index 000000000..580a92410 Binary files /dev/null and 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/images/android-icon.png differ 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/images/android_device.png 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/images/android_device.png new file mode 100644 index 000000000..c4c37b641 Binary files /dev/null and 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/images/android_device.png differ 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/images/thumb.png 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/images/thumb.png new file mode 100644 index 000000000..851000178 Binary files /dev/null and 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/images/thumb.png differ 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 new file mode 100644 index 000000000..09c98431b --- /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/type-view.hbs @@ -0,0 +1,146 @@ +
+

Android Mobile

+
+
+
+ +
+ +
+ +
+ +
+ +

What it Does

+
+

Connect and manage your Android device with WSO2 IoT Server.

+
+ +

What You Need

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

+
+ +
+

Prepare


+
    +
  • 01 Download Device Agent into your Android Mobile.
  • +
  • 02 Install Agent APK file.
  • +
  • 03 Configure Agent App
  • +
+
+ +
+ +
+

Click on the image to zoom

+
+ + + +
+
+ +
+ + + +{{#zone "topCss"}} + +{{/zone}} + +{{#zone "bottomJs"}} + +{{/zone}} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOFactory.java 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.js similarity index 52% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOFactory.java rename to 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.js index 37a5c311c..ad4f0ec9c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOFactory.java +++ 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.js @@ -1,27 +1,24 @@ /* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * WSO2 Inc. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except * in compliance with the License. - * you may obtain a copy of the License at + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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 + * 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.dao; - -public interface MobileDeviceManagementDAOFactory { - - MobileDeviceDAO getMobileDeviceDAO(); - - MobileFeatureDAO getMobileFeatureDAO(); - -} +function onRequest(context){ + var viewModel = {}; + var devicemgtProps = require('/app/conf/devicemgt-props.js').config(); + viewModel.hostName = devicemgtProps["httpsURL"]; + return viewModel; +} \ 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.json 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.json new file mode 100644 index 000000000..9eecd8f5b --- /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/type-view.json @@ -0,0 +1,3 @@ +{ + "version": "1.0.0" +} \ 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/mdm.unit.device.operation-bar/public/templates/hidden-operations-android.hbs b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-bar/public/templates/hidden-operations-android.hbs new file mode 100644 index 000000000..8e1900d48 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-bar/public/templates/hidden-operations-android.hbs @@ -0,0 +1,246 @@ +
+ +
+ + +
+
+ +
+
+ +
+ Configure +
+
+
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
+ +
+ +
+ +
+ + Configure +
+
+
+ + + +
+
+ + +
+ +
+ + + +
+ +
+ Configure +
+ +
+ + +
+
+ +
+ + +
+ +
+
+ +
+ + +
+ +
+ Install +
+
+
+ +
+ + +
+ +
+ + +
+ +
+ Install +
+
+
+ +
+ + +
+ +
+ Uninstall +
+
+
+ + + +
+
+ +
+
+ +
+ Configure +
+
+
+ +
+
\ No newline at end of file diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManagementService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManagementService.java index 60c29fec9..9949b69ae 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManagementService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManagementService.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * WSO2 Inc. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except * in compliance with the License. - * you may obtain a copy of the License at + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -36,23 +36,12 @@ public class AndroidDeviceManagementService implements DeviceManagementService { private DeviceManager deviceManager; public static final String DEVICE_TYPE_ANDROID = "android"; - public static final String DEVICE_TYPE_TENANT = "carbon.super"; @Override public String getType() { return AndroidDeviceManagementService.DEVICE_TYPE_ANDROID; } - @Override - public String getProviderTenantDomain() { - return DEVICE_TYPE_TENANT; - } - - @Override - public boolean isSharedWithAllTenants() { - return true; - } - @Override public void init() throws DeviceManagementException { this.deviceManager = new AndroidDeviceManager(); diff --git a/components/mobile-plugins/android-plugin/pom.xml b/components/mobile-plugins/android-plugin/pom.xml index 0dbcdff77..788433cf8 100644 --- a/components/mobile-plugins/android-plugin/pom.xml +++ b/components/mobile-plugins/android-plugin/pom.xml @@ -1,21 +1,21 @@ + ~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + ~ + ~ WSO2 Inc. licenses this file to you under the Apache License, + ~ Version 2.0 (the "License"); you may not use this file except + ~ in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> @@ -34,7 +34,8 @@ org.wso2.carbon.device.mgt.mobile.android - org.wso2.carbon.device.mgt.mobile.android.agent + org.wso2.carbon.device.mgt.mobile.android.api + org.wso2.carbon.device.mgt.mobile.android.ui diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/pom.xml b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/pom.xml index bd997683e..ec1bca777 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/pom.xml +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/pom.xml @@ -1,18 +1,20 @@ commons-codec provided + + org.wso2.carbon.devicemgt + org.wso2.carbon.certificate.mgt.core + provided + diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/Certificate.java b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/Certificate.java new file mode 100644 index 000000000..e7ba2fd3e --- /dev/null +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/Certificate.java @@ -0,0 +1,192 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.mdm.api; + +import org.apache.commons.httpclient.HttpStatus; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.certificate.mgt.core.dao.CertificateManagementDAOException; +import org.wso2.carbon.certificate.mgt.core.dto.CertificateResponse; +import org.wso2.carbon.certificate.mgt.core.exception.KeystoreException; +import org.wso2.carbon.certificate.mgt.core.service.CertificateManagementService; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.device.mgt.common.PaginationRequest; +import org.wso2.carbon.device.mgt.common.PaginationResult; +import org.wso2.carbon.mdm.api.common.MDMAPIException; +import org.wso2.carbon.mdm.api.util.MDMAPIUtils; +import org.wso2.carbon.mdm.api.util.ResponsePayload; +import org.wso2.carbon.mdm.beans.EnrollmentCertificate; +import org.wso2.carbon.mdm.exception.*; +import org.wso2.carbon.mdm.exception.BadRequestException; +import org.wso2.carbon.mdm.util.MDMUtil; + +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.util.ArrayList; +import java.util.List; + +/** + * All the certificate related tasks such as saving certificates, can be done through this endpoint. + */ +@Produces({ "application/json", "application/xml" }) +@Consumes({ "application/json", "application/xml" }) +public class Certificate { + + private static Log log = LogFactory.getLog(Operation.class); + + /** + * Save a list of certificates and relevant information in the database. + * + * @param enrollmentCertificates List of all the certificates which includes the tenant id, certificate as + * a pem and a serial number. + * @return Status of the data persist operation. + * @throws MDMAPIException + */ + @POST + @Path("saveCertificate") + public Response saveCertificate(@HeaderParam("Accept") String acceptHeader, + EnrollmentCertificate[] enrollmentCertificates) throws MDMAPIException { + MediaType responseMediaType = MDMAPIUtils.getResponseMediaType(acceptHeader); + CertificateManagementService certificateService; + List certificates = new ArrayList(); + org.wso2.carbon.certificate.mgt.core.bean.Certificate certificate; + certificateService = MDMAPIUtils.getCertificateManagementService(); + try { + for (EnrollmentCertificate enrollmentCertificate : enrollmentCertificates) { + certificate = new org.wso2.carbon.certificate.mgt.core.bean.Certificate(); + certificate.setTenantId(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); + certificate.setSerial(enrollmentCertificate.getSerial()); + certificate.setCertificate(certificateService.pemToX509Certificate(enrollmentCertificate.getPem())); + certificates.add(certificate); + } + certificateService.saveCertificate(certificates); + return Response.status(Response.Status.CREATED).entity("Added successfully."). + type(responseMediaType).build(); + } catch (KeystoreException e) { + String msg = "Error occurred while converting PEM file to X509Certificate."; + log.error(msg, e); + throw new MDMAPIException(msg, e); + } + } + + /** + * Get a certificate when the serial number is given. + * + * @param serialNumber serial of the certificate needed. + * @return certificate response. + * @throws MDMAPIException + */ + @GET + @Path("{serialNumber}") + public Response getCertificate(@HeaderParam("Accept") String acceptHeader, + @PathParam("serialNumber") String serialNumber) throws MDMAPIException { + MediaType responseMediaType = MDMAPIUtils.getResponseMediaType(acceptHeader); + Message message = new Message(); + + if (serialNumber == null || serialNumber.isEmpty()) { + message.setErrorMessage("Invalid serial number"); + message.setDiscription("Serial number is missing or invalid."); + throw new BadRequestException(message, responseMediaType); + } + + CertificateManagementService certificateService = MDMAPIUtils.getCertificateManagementService(); + CertificateResponse certificateResponse; + try { + certificateResponse = certificateService.getCertificateBySerial(serialNumber); + if(certificateResponse != null) { + certificateResponse.setCertificate(null); //avoid sending byte array in response. + } + return Response.status(Response.Status.OK).entity(certificateResponse).type(responseMediaType).build(); + } catch (KeystoreException e) { + String msg = "Error occurred while converting PEM file to X509Certificate"; + log.error(msg, e); + return Response.serverError().build(); + } + } + + /** + * Get all certificates in a paginated manner. + * + * @param startIndex index of the first record to be fetched + * @param length number of records to be fetched starting from the start index. + * @return paginated result of certificate. + * @throws MDMAPIException + */ + @GET + @Path("paginate") + public Response getAllCertificates(@HeaderParam("Accept") String acceptHeader, + @QueryParam("start") int startIndex, + @QueryParam("length") int length) + throws MDMAPIException { + MediaType responseMediaType = MDMAPIUtils.getResponseMediaType(acceptHeader); + Message message = new Message(); + + if (startIndex < 0) { + message.setErrorMessage("Invalid start index."); + message.setDiscription("Start index cannot be less that 0."); + throw new BadRequestException(message, responseMediaType); + } else if (length <= 0) { + message.setErrorMessage("Invalid length value."); + message.setDiscription("Length should be a positive integer."); + throw new BadRequestException(message, responseMediaType); + } + + CertificateManagementService certificateService = MDMAPIUtils.getCertificateManagementService(); + PaginationRequest paginationRequest = new PaginationRequest(startIndex, length); + try { + PaginationResult certificates = certificateService.getAllCertificates(paginationRequest); + return Response.status(Response.Status.OK).entity(certificates).type(responseMediaType).build(); + } catch (CertificateManagementDAOException e) { + String msg = "Error occurred while fetching all certificates."; + log.error(msg, e); + throw new MDMAPIException(msg, e); + } + } + + @DELETE + @Path("{serialNumber}") + public Response removeCertificate(@HeaderParam("Accept") String acceptHeader, + @PathParam("serialNumber") String serialNumber) throws MDMAPIException { + MediaType responseMediaType = MDMAPIUtils.getResponseMediaType(acceptHeader); + Message message = new Message(); + + if (serialNumber == null || serialNumber.isEmpty()) { + message.setErrorMessage("Invalid serial number"); + message.setDiscription("Serial number is missing or invalid."); + throw new BadRequestException(message, responseMediaType); + } + + CertificateManagementService certificateService = MDMAPIUtils.getCertificateManagementService(); + boolean deleted; + try { + deleted = certificateService.removeCertificate(serialNumber); + if(deleted){ + return Response.status(Response.Status.OK).entity(deleted).type(responseMediaType).build(); + } else { + return Response.status(Response.Status.GONE).entity(deleted).type(responseMediaType).build(); + } + } catch (CertificateManagementDAOException e) { + String msg = "Error occurred while converting PEM file to X509Certificate"; + log.error(msg, e); + return Response.serverError().build(); + } + } +} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/Configuration.java b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/Configuration.java index 8acf4efe9..eb8a5e138 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/Configuration.java +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/Configuration.java @@ -21,16 +21,20 @@ package org.wso2.carbon.mdm.api; import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry; import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationManagementException; import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration; import org.wso2.carbon.mdm.api.common.MDMAPIException; import org.wso2.carbon.mdm.api.util.MDMAPIUtils; import org.wso2.carbon.mdm.api.util.MDMAppConstants; import org.wso2.carbon.mdm.api.util.ResponsePayload; +import org.wso2.carbon.policy.mgt.core.util.PolicyManagerUtil; import javax.jws.WebService; import javax.ws.rs.*; import javax.ws.rs.core.Response; +import java.util.ArrayList; +import java.util.List; /** * General Tenant Configuration REST-API implementation. @@ -67,8 +71,19 @@ public class Configuration { public TenantConfiguration getConfiguration() throws MDMAPIException { String msg; try { - return MDMAPIUtils.getTenantConfigurationManagementService().getConfiguration(MDMAppConstants. - RegistryConstants.GENERAL_CONFIG_RESOURCE_PATH); + TenantConfiguration tenantConfiguration = MDMAPIUtils.getTenantConfigurationManagementService(). + getConfiguration(MDMAppConstants.RegistryConstants.GENERAL_CONFIG_RESOURCE_PATH); + ConfigurationEntry configurationEntry = new ConfigurationEntry(); + configurationEntry.setContentType("text"); + configurationEntry.setName("notifierFrequency"); + configurationEntry.setValue(PolicyManagerUtil.getMonitoringFequency()); + List configList = tenantConfiguration.getConfiguration(); + if (configList == null) { + configList = new ArrayList(); + } + configList.add(configurationEntry); + tenantConfiguration.setConfiguration(configList); + return tenantConfiguration; } catch (ConfigurationManagementException e) { msg = "Error occurred while retrieving the tenant configuration."; log.error(msg, e); diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/DeviceInformation.java b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/DeviceInformation.java new file mode 100644 index 000000000..c8503d32f --- /dev/null +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/DeviceInformation.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +package org.wso2.carbon.mdm.api; + +import org.apache.commons.httpclient.HttpStatus; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo; +import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation; +import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceDetailsMgtException; +import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager; +import org.wso2.carbon.mdm.api.common.MDMAPIException; +import org.wso2.carbon.mdm.api.util.MDMAPIUtils; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.Response; + +public class DeviceInformation { + + private static Log log = LogFactory.getLog(DeviceInformation.class); + + @GET + @Path("{type}/{id}") + public Response getDeviceInfo(@PathParam("type") String type, @PathParam("id") String id) throws MDMAPIException { + DeviceInformationManager informationManager; + DeviceInfo deviceInfo; + try { + DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); + deviceIdentifier.setId(id); + deviceIdentifier.setType(type); + informationManager = MDMAPIUtils.getDeviceInformationManagerService(); + deviceInfo = informationManager.getDeviceInfo(deviceIdentifier); + + } catch (DeviceDetailsMgtException e) { + String msg = "Error occurred while getting the device information."; + log.error(msg, e); + throw new MDMAPIException(msg, e); + } + return Response.status(HttpStatus.SC_OK).entity(deviceInfo).build(); + } + + + @GET + @Path("location/{type}/{id}") + public Response getDeviceLocation(@PathParam("type") String type, @PathParam("id") String id) throws MDMAPIException { + DeviceInformationManager informationManager; + DeviceLocation deviceLocation; + try { + DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); + deviceIdentifier.setId(id); + deviceIdentifier.setType(type); + informationManager = MDMAPIUtils.getDeviceInformationManagerService(); + deviceLocation = informationManager.getDeviceLocation(deviceIdentifier); + + } catch (DeviceDetailsMgtException e) { + String msg = "Error occurred while getting the device location."; + log.error(msg, e); + throw new MDMAPIException(msg, e); + } + return Response.status(HttpStatus.SC_OK).entity(deviceLocation).build(); + } +} + diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/DeviceSearch.java b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/DeviceSearch.java new file mode 100644 index 000000000..ab1bf5194 --- /dev/null +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/DeviceSearch.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +package org.wso2.carbon.mdm.api; + +import org.apache.commons.httpclient.HttpStatus; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.common.device.details.DeviceWrapper; +import org.wso2.carbon.device.mgt.common.search.SearchContext; +import org.wso2.carbon.device.mgt.core.search.mgt.SearchManagerService; +import org.wso2.carbon.device.mgt.core.search.mgt.SearchMgtException; +import org.wso2.carbon.mdm.api.common.MDMAPIException; +import org.wso2.carbon.mdm.api.util.MDMAPIUtils; + +import javax.ws.rs.GET; +import javax.ws.rs.core.Response; +import java.util.List; + +public class DeviceSearch { + + private static Log log = LogFactory.getLog(DeviceSearch.class); + + @GET + public Response getDeviceInfo(SearchContext searchContext) throws MDMAPIException { + SearchManagerService searchManagerService; + List devices; + try { + searchManagerService = MDMAPIUtils.getSearchManagerService(); + devices = searchManagerService.search(searchContext); + + } catch (SearchMgtException e) { + String msg = "Error occurred while searching the device information."; + log.error(msg, e); + throw new MDMAPIException(msg, e); + } + return Response.status(HttpStatus.SC_OK).entity(devices).build(); + } +} + diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/Feature.java b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/Feature.java index 1cd357b94..b98baab48 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/Feature.java +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/Feature.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * WSO2 Inc. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except @@ -11,10 +11,11 @@ * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ + package org.wso2.carbon.mdm.api; import org.apache.commons.logging.Log; @@ -39,7 +40,7 @@ public class Feature { * Get all features for Mobile Device Type * * @return Feature - * @throws org.wso2.carbon.mdm.api.common.MDMAPIException + * @throws MDMAPIException * */ @GET diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/MobileDevice.java b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/MobileDevice.java index be7c9bda3..f37781747 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/MobileDevice.java +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/MobileDevice.java @@ -133,7 +133,7 @@ public class MobileDevice { * @param user User Name * @param tenantDomain tenant domain * @return Device - * @throws org.wso2.carbon.mdm.api.common.MDMAPIException + * @throws MDMAPIException */ @GET @Path("user/{user}/{tenantDomain}") @@ -184,7 +184,7 @@ public class MobileDevice { public List getDevicesByName(@PathParam("name") String deviceName, @PathParam("tenantDomain") String tenantDomain) throws MDMAPIException { - List devices; + List devices; try { devices = MDMAPIUtils.getDeviceManagementService().getDevicesByName(deviceName); } catch (DeviceManagementException e) { diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/Operation.java b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/Operation.java index a775318dd..84e88c92a 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/Operation.java +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/Operation.java @@ -54,7 +54,7 @@ import java.util.List; public class Operation { private static Log log = LogFactory.getLog(Operation.class); - + /* @deprecated */ @GET public List getAllOperations() throws MDMAPIException { @@ -115,6 +115,7 @@ public class Operation { return operations; } + /* @deprecated */ @POST public ResponsePayload addOperation(DeviceOperationContext operationContext) throws MDMAPIException { DeviceManagementProviderService dmService; @@ -182,6 +183,8 @@ public class Operation { } appManagerConnector.installApplicationForDevices(operation, applicationWrapper.getDeviceIdentifiers()); } + Response.status(HttpStatus.SC_CREATED); + responseMsg.setMessageFromServer("Application installation request has been sent to the device."); return responseMsg; } catch (ApplicationManagementException e) { String msg = "Error occurred while saving the operation"; @@ -215,6 +218,8 @@ public class Operation { } appManagerConnector.installApplicationForDevices(operation, applicationWrapper.getDeviceIdentifiers()); } + Response.status(HttpStatus.SC_CREATED); + responseMsg.setMessageFromServer("Application removal request has been sent to the device."); return responseMsg; } catch (ApplicationManagementException e) { String msg = "Error occurred while saving the operation"; diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/Policy.java b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/Policy.java index dea04d31b..c0dd24d14 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/Policy.java +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/Policy.java @@ -173,24 +173,6 @@ public class Policy { @Path("{id}") public ResponsePayload updatePolicy(PolicyWrapper policyWrapper, @PathParam("id") int policyId) throws MDMAPIException { -// PolicyManagerService policyManagementService = MDMAPIUtils.getPolicyManagementService(); -// ResponsePayload responseMsg = new ResponsePayload(); -// try { -// PolicyAdministratorPoint pap = policyManagementService.getPAP(); -// org.wso2.carbon.policy.mgt.common.Policy previousPolicy = pap.getPolicy(policyId); -// policy.setProfile(pap.getProfile(previousPolicy.getProfileId())); -// policy.setId(previousPolicy.getId()); -// pap.updatePolicy(policy); -// Response.status(HttpStatus.SC_OK); -// responseMsg.setMessageFromServer("Policy has been updated successfully."); -// return responseMsg; -// } catch (PolicyManagementException e) { -// String error = "Policy Management related exception"; -// log.error(error, e); -// throw new MDMAPIException(error, e); -// } - - PolicyManagerService policyManagementService = MDMAPIUtils.getPolicyManagementService(); ResponsePayload responseMsg = new ResponsePayload(); @@ -205,16 +187,12 @@ public class Policy { policy.setUsers(policyWrapper.getUsers()); policy.setTenantId(policyWrapper.getTenantId()); policy.setCompliance(policyWrapper.getCompliance()); - // policy.setActive(true); try { PolicyAdministratorPoint pap = policyManagementService.getPAP(); -// pap.addPolicy(policy); pap.updatePolicy(policy); -// Response.status(HttpStatus.SC_CREATED); Response.status(HttpStatus.SC_OK); responseMsg.setStatusCode(HttpStatus.SC_CREATED); -// responseMsg.setMessageFromServer("Policy has been added successfully."); responseMsg.setMessageFromServer("Policy has been updated successfully."); return responseMsg; } catch (PolicyManagementException e) { @@ -293,23 +271,6 @@ public class Policy { } } -// @GET -// @Path("task/{mf}") -// public int taskService(@PathParam("mf") int monitoringFrequency) throws MDMAPIException { -// int policyCount = 0; -// PolicyManagerService policyManagementService = MDMAPIUtils.getPolicyManagementService(); -// try { -// TaskScheduleService taskScheduleService = policyManagementService.getTaskScheduleService(); -// taskScheduleService.startTask(monitoringFrequency); -// return policyCount; -// } catch (PolicyMonitoringTaskException e) { -// String error = "Policy Management related exception"; -// log.error(error, e); -// throw new MDMAPIException(error, e); -// } -// } - - @PUT @Produces("application/json") @Path("activate") @@ -333,7 +294,6 @@ public class Policy { } - @PUT @Produces("application/json") @Path("inactivate") @@ -356,7 +316,6 @@ public class Policy { return Response.status(HttpStatus.SC_OK).entity(responsePayload).build(); } - @PUT @Produces("application/json") @Path("apply-changes") @@ -400,7 +359,6 @@ public class Policy { return Response.status(HttpStatus.SC_OK).entity(responsePayload).build(); } - @GET @Path("update-task/{milliseconds}") public Response updateTaskService(@PathParam("milliseconds") int monitoringFrequency) throws MDMAPIException { @@ -421,7 +379,6 @@ public class Policy { return Response.status(HttpStatus.SC_OK).entity(responsePayload).build(); } - @GET @Path("stop-task") public Response stopTaskService() throws MDMAPIException { @@ -442,7 +399,6 @@ public class Policy { return Response.status(HttpStatus.SC_OK).entity(responsePayload).build(); } - @GET @Path("{type}/{id}") public ComplianceData getComplianceDataOfDevice(@PathParam("type") String type, @PathParam("id") String id) throws diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/Role.java b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/Role.java index a0adeed6a..f0157ef4e 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/Role.java +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/Role.java @@ -49,7 +49,7 @@ public class Role { * Get user roles (except all internal roles) from system. * * @return A list of users - * @throws org.wso2.carbon.mdm.api.common.MDMAPIException + * @throws MDMAPIException */ @GET @Produces ({MediaType.APPLICATION_JSON}) @@ -85,7 +85,7 @@ public class Role { * Get user roles by user store(except all internal roles) from system. * * @return A list of users - * @throws org.wso2.carbon.mdm.api.common.MDMAPIException + * @throws MDMAPIException */ @GET @Path ("{userStore}") @@ -122,7 +122,7 @@ public class Role { * Get user roles by providing a filtering criteria(except all internal roles & system roles) from system. * * @return A list of users - * @throws org.wso2.carbon.mdm.api.common.MDMAPIException + * @throws MDMAPIException */ @GET @Path ("search") @@ -205,7 +205,7 @@ public class Role { * Get user role of the system * * @return user role - * @throws org.wso2.carbon.mdm.api.common.MDMAPIException + * @throws MDMAPIException */ @GET @Path("role") @@ -419,4 +419,36 @@ public class Role { } return list; } + + /** + * This method is used to retrieve the role count of the system. + * + * @return returns the count. + * @throws MDMAPIException + */ + @GET + @Path("count") + public int getRoleCount() throws MDMAPIException { + UserStoreManager userStoreManager = MDMAPIUtils.getUserStoreManager(); + String[] roles; + try { + if (log.isDebugEnabled()) { + log.debug("Getting the list of user roles"); + } + roles = userStoreManager.getRoleNames(); + + } catch (UserStoreException e) { + String msg = "Error occurred while retrieving the list of user roles."; + log.error(msg, e); + throw new MDMAPIException(msg, e); + } + // removing all internal roles and roles created for Service-providers + List filteredRoles = new ArrayList(); + for (String role : roles) { + if (!(role.startsWith("Internal/") || role.startsWith("Application/"))) { + filteredRoles.add(role); + } + } + return filteredRoles.size(); + } } diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/User.java b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/User.java index 16c9ee7ca..e1e065c1b 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/User.java +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/User.java @@ -25,10 +25,11 @@ 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.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.EmailMessageProperties; import org.wso2.carbon.device.mgt.common.PaginationRequest; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; +import org.wso2.carbon.device.mgt.core.service.EmailMetaInfo; import org.wso2.carbon.mdm.api.common.MDMAPIException; +import org.wso2.carbon.mdm.api.util.CredentialManagementResponseBuilder; import org.wso2.carbon.mdm.api.util.MDMAPIUtils; import org.wso2.carbon.mdm.api.util.ResponsePayload; import org.wso2.carbon.mdm.beans.UserCredentialWrapper; @@ -37,6 +38,7 @@ import org.wso2.carbon.mdm.util.Constants; import org.wso2.carbon.mdm.util.SetReferenceTransformer; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.api.UserStoreManager; +import org.wso2.carbon.utils.multitenancy.MultitenantConstants; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; @@ -50,14 +52,7 @@ import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.io.UnsupportedEncodingException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.TreeSet; +import java.util.*; /** * This class represents the JAX-RS services of User related functionality. @@ -65,7 +60,7 @@ import java.util.TreeSet; public class User { private static Log log = LogFactory.getLog(User.class); - private String ROLE_EVERYONE = "Internal/everyone"; + private static final String ROLE_EVERYONE = "Internal/everyone"; /** * Method to add user to emm-user-store. @@ -85,22 +80,22 @@ public class User { // if user already exists if (log.isDebugEnabled()) { log.debug("User by username: " + userWrapper.getUsername() + - " already exists. Therefore, request made to add user was refused."); + " already exists. Therefore, request made to add user was refused."); } // returning response with bad request state responsePayload.setStatusCode(HttpStatus.SC_CONFLICT); responsePayload. setMessageFromServer("User by username: " + userWrapper.getUsername() + - " already exists. Therefore, request made to add user was refused."); + " already exists. Therefore, request made to add user was refused."); return Response.status(HttpStatus.SC_CONFLICT).entity(responsePayload).build(); } else { String initialUserPassword = generateInitialUserPassword(); Map defaultUserClaims = buildDefaultUserClaims(userWrapper.getFirstname(), userWrapper.getLastname(), - userWrapper.getEmailAddress()); + userWrapper.getEmailAddress()); // calling addUser method of carbon user api userStoreManager.addUser(userWrapper.getUsername(), initialUserPassword, - userWrapper.getRoles(), defaultUserClaims, null); + userWrapper.getRoles(), defaultUserClaims, null); // invite newly added user to enroll device inviteNewlyAddedUserToEnrollDevice(userWrapper.getUsername(), initialUserPassword); // Outputting debug message upon successful addition of user @@ -110,17 +105,13 @@ public class User { // returning response with success state responsePayload.setStatusCode(HttpStatus.SC_CREATED); responsePayload.setMessageFromServer("User by username: " + userWrapper.getUsername() + - " was successfully added."); + " was successfully added."); return Response.status(HttpStatus.SC_CREATED).entity(responsePayload).build(); } } catch (UserStoreException e) { - String errorMsg = "Exception in trying to add user by username: " + userWrapper.getUsername(); - log.error(errorMsg, e); - throw new MDMAPIException(errorMsg, e); - } catch (DeviceManagementException e) { - String errorMsg = "Exception in trying to add user by username: " + userWrapper.getUsername(); - log.error(errorMsg, e); - throw new MDMAPIException(errorMsg, e); + String msg = "Exception in trying to add user by username: " + userWrapper.getUsername(); + log.error(msg, e); + throw new MDMAPIException(msg, e); } } @@ -164,9 +155,9 @@ public class User { return Response.status(HttpStatus.SC_NOT_FOUND).entity(responsePayload).build(); } } catch (UserStoreException e) { - String errorMsg = "Exception in trying to retrieve user by username: " + username; - log.error(errorMsg, e); - throw new MDMAPIException(errorMsg, e); + String msg = "Exception in trying to retrieve user by username: " + username; + log.error(msg, e); + throw new MDMAPIException(msg, e); } } @@ -188,12 +179,12 @@ public class User { if (userStoreManager.isExistingUser(userWrapper.getUsername())) { Map defaultUserClaims = buildDefaultUserClaims(userWrapper.getFirstname(), userWrapper.getLastname(), - userWrapper.getEmailAddress()); + userWrapper.getEmailAddress()); if (StringUtils.isNotEmpty(userWrapper.getPassword())) { // Decoding Base64 encoded password byte[] decodedBytes = Base64.decodeBase64(userWrapper.getPassword()); userStoreManager.updateCredentialByAdmin(userWrapper.getUsername(), - new String(decodedBytes, "UTF-8")); + new String(decodedBytes, "UTF-8")); log.debug("User credential of username: " + userWrapper.getUsername() + " has been changed"); } List listofFilteredRoles = getFilteredRoles(userStoreManager, userWrapper.getUsername()); @@ -204,16 +195,16 @@ public class User { The difference of roles in existingRolesSet and newRolesSet needed to be deleted new roles to add = newRolesSet - The intersection of roles in existingRolesSet and newRolesSet */ - final TreeSet existingRolesSet = new TreeSet(); + final TreeSet existingRolesSet = new TreeSet<>(); Collections.addAll(existingRolesSet, existingRoles); - final TreeSet newRolesSet = new TreeSet(); + final TreeSet newRolesSet = new TreeSet<>(); Collections.addAll(newRolesSet, userWrapper.getRoles()); existingRolesSet.removeAll(newRolesSet); // Now we have the roles to delete String[] rolesToDelete = existingRolesSet.toArray(new String[existingRolesSet.size()]); - List roles = new ArrayList(Arrays.asList(rolesToDelete)); + List roles = new ArrayList<>(Arrays.asList(rolesToDelete)); roles.remove(ROLE_EVERYONE); - rolesToDelete = roles.toArray(new String[0]); + rolesToDelete = new String[0]; // Clearing and re-initializing the set existingRolesSet.clear(); Collections.addAll(existingRolesSet, existingRoles); @@ -229,28 +220,24 @@ public class User { // returning response with success state responsePayload.setStatusCode(HttpStatus.SC_CREATED); responsePayload.setMessageFromServer("User by username: " + userWrapper.getUsername() + - " was successfully updated."); + " was successfully updated."); return Response.status(HttpStatus.SC_CREATED).entity(responsePayload).build(); } else { if (log.isDebugEnabled()) { log.debug("User by username: " + userWrapper.getUsername() + - " doesn't exists. Therefore, request made to update user was refused."); + " doesn't exists. Therefore, request made to update user was refused."); } // returning response with bad request state responsePayload.setStatusCode(HttpStatus.SC_CONFLICT); responsePayload. setMessageFromServer("User by username: " + userWrapper.getUsername() + - " doesn't exists. Therefore, request made to update user was refused."); + " doesn't exists. Therefore, request made to update user was refused."); return Response.status(HttpStatus.SC_CONFLICT).entity(responsePayload).build(); } - } catch (UserStoreException e) { - String errorMsg = "Exception in trying to update user by username: " + userWrapper.getUsername(); - log.error(errorMsg, e); - throw new MDMAPIException(errorMsg, e); - } catch (UnsupportedEncodingException e) { - String errorMsg = "Exception in trying to update user by username: " + userWrapper.getUsername(); - log.error(errorMsg, e); - throw new MDMAPIException(errorMsg, e); + } catch (UserStoreException | UnsupportedEncodingException e) { + String msg = "Exception in trying to update user by username: " + userWrapper.getUsername(); + log.error(msg, e); + throw new MDMAPIException(msg, e); } } @@ -270,7 +257,7 @@ public class User { Random randomGenerator = new Random(); String totalCharset = lowerCaseCharset + upperCaseCharset + numericCharset; int totalCharsetLength = totalCharset.length(); - StringBuffer initialUserPassword = new StringBuffer(); + StringBuilder initialUserPassword = new StringBuilder(); for (int i = 0; i < passwordLength; i++) { initialUserPassword .append(totalCharset.charAt(randomGenerator.nextInt(totalCharsetLength))); @@ -290,7 +277,7 @@ public class User { * @return {Object} Default user claims to be provided */ private Map buildDefaultUserClaims(String firstname, String lastname, String emailAddress) { - Map defaultUserClaims = new HashMap(); + Map defaultUserClaims = new HashMap<>(); defaultUserClaims.put(Constants.USER_CLAIM_FIRST_NAME, firstname); defaultUserClaims.put(Constants.USER_CLAIM_LAST_NAME, lastname); defaultUserClaims.put(Constants.USER_CLAIM_EMAIL_ADDRESS, emailAddress); @@ -337,24 +324,24 @@ public class User { return Response.status(HttpStatus.SC_BAD_REQUEST).entity(responsePayload).build(); } } catch (UserStoreException e) { - String errorMsg = "Exception in trying to remove user by username: " + username; - log.error(errorMsg, e); - throw new MDMAPIException(errorMsg, e); + String msg = "Exception in trying to remove user by username: " + username; + log.error(msg, e); + throw new MDMAPIException(msg, e); } } /** * get all the roles except for the internal/xxx and application/xxx * - * @param userStoreManager - * @param username + * @param userStoreManager User Store Manager associated with the currently logged in user + * @param username Username of the currently logged in user * @return the list of filtered roles * @throws UserStoreException */ private List getFilteredRoles(UserStoreManager userStoreManager, String username) throws UserStoreException { String[] roleListOfUser = userStoreManager.getRoleListOfUser(username); - List filteredRoles = new ArrayList(); + List filteredRoles = new ArrayList<>(); for (String role : roleListOfUser) { if (!(role.startsWith("Internal/") || role.startsWith("Application/"))) { filteredRoles.add(role); @@ -400,9 +387,9 @@ public class User { return Response.status(HttpStatus.SC_BAD_REQUEST).entity(responsePayload).build(); } } catch (UserStoreException e) { - String errorMsg = "Exception in trying to retrieve roles for user by username: " + username; - log.error(errorMsg, e); - throw new MDMAPIException(errorMsg, e); + String msg = "Exception in trying to retrieve roles for user by username: " + username; + log.error(msg, e); + throw new MDMAPIException(msg, e); } } @@ -419,10 +406,10 @@ public class User { log.debug("Getting the list of users with all user-related information"); } UserStoreManager userStoreManager = MDMAPIUtils.getUserStoreManager(); - ArrayList userList; + List userList; try { String[] users = userStoreManager.listUsers("*", -1); - userList = new ArrayList(users.length); + userList = new ArrayList<>(users.length); UserWrapper user; for (String username : users) { user = new UserWrapper(); @@ -439,12 +426,10 @@ public class User { } ResponsePayload responsePayload = new ResponsePayload(); responsePayload.setStatusCode(HttpStatus.SC_OK); - int count = 0; - if (userList != null) { - count = userList.size(); - } + int count; + count = userList.size(); responsePayload.setMessageFromServer("All users were successfully retrieved. " + - "Obtained user count: " + count); + "Obtained user count: " + count); responsePayload.setResponseContent(userList); return Response.status(HttpStatus.SC_OK).entity(responsePayload).build(); } @@ -463,10 +448,10 @@ public class User { log.debug("Getting the list of users with all user-related information using the filter : " + filter); } UserStoreManager userStoreManager = MDMAPIUtils.getUserStoreManager(); - ArrayList userList; + List userList; try { String[] users = userStoreManager.listUsers(filter + "*", -1); - userList = new ArrayList(users.length); + userList = new ArrayList<>(users.length); UserWrapper user; for (String username : users) { user = new UserWrapper(); @@ -483,12 +468,10 @@ public class User { } ResponsePayload responsePayload = new ResponsePayload(); responsePayload.setStatusCode(HttpStatus.SC_OK); - int count = 0; - if (userList != null) { - count = userList.size(); - } + int count; + count = userList.size(); responsePayload.setMessageFromServer("All users were successfully retrieved. " + - "Obtained user count: " + count); + "Obtained user count: " + count); responsePayload.setResponseContent(userList); return Response.status(HttpStatus.SC_OK).entity(responsePayload).build(); } @@ -506,10 +489,10 @@ public class User { log.debug("Getting the list of users by name"); } UserStoreManager userStoreManager = MDMAPIUtils.getUserStoreManager(); - ArrayList userList; + List userList; try { String[] users = userStoreManager.listUsers("*" + userName + "*", -1); - userList = new ArrayList(users.length); + userList = new ArrayList<>(users.length); UserWrapper user; for (String username : users) { user = new UserWrapper(); @@ -526,12 +509,10 @@ public class User { } ResponsePayload responsePayload = new ResponsePayload(); responsePayload.setStatusCode(HttpStatus.SC_OK); - int count = 0; - if (userList != null) { - count = userList.size(); - } + int count; + count = userList.size(); responsePayload.setMessageFromServer("All users by username were successfully retrieved. " + - "Obtained user count: " + count); + "Obtained user count: " + count); responsePayload.setResponseContent(userList); return Response.status(HttpStatus.SC_OK).entity(responsePayload).build(); } @@ -549,14 +530,11 @@ public class User { log.debug("Getting the list of users by name"); } UserStoreManager userStoreManager = MDMAPIUtils.getUserStoreManager(); - ArrayList userList; + List userList; try { String[] users = userStoreManager.listUsers("*" + userName + "*", -1); - userList = new ArrayList(users.length); - UserWrapper user; - for (String username : users) { - userList.add(username); - } + userList = new ArrayList<>(users.length); + Collections.addAll(userList, users); } catch (UserStoreException e) { String msg = "Error occurred while retrieving the list of users"; log.error(msg, e); @@ -564,12 +542,10 @@ public class User { } ResponsePayload responsePayload = new ResponsePayload(); responsePayload.setStatusCode(HttpStatus.SC_OK); - int count = 0; - if (userList != null) { - count = userList.size(); - } + int count; + count = userList.size(); responsePayload.setMessageFromServer("All users by username were successfully retrieved. " + - "Obtained user count: " + count); + "Obtained user count: " + count); responsePayload.setResponseContent(userList); return Response.status(HttpStatus.SC_OK).entity(responsePayload).build(); } @@ -582,9 +558,14 @@ public class User { * @return A list of usernames * @throws MDMAPIException, UserStoreException */ - private String getClaimValue(String username, String claimUri) throws MDMAPIException, UserStoreException { + private String getClaimValue(String username, String claimUri) throws MDMAPIException { UserStoreManager userStoreManager = MDMAPIUtils.getUserStoreManager(); - return userStoreManager.getUserClaimValue(username, claimUri, null); + try { + return userStoreManager.getUserClaimValue(username, claimUri, null); + } catch (UserStoreException e) { + throw new MDMAPIException("Error occurred while retrieving value assigned to the claim '" + + claimUri + "'", e); + } } /** @@ -593,31 +574,37 @@ public class User { * @param username Username of the user * @throws MDMAPIException, UserStoreException, DeviceManagementException */ - private void inviteNewlyAddedUserToEnrollDevice(String username, String password) throws - MDMAPIException, - UserStoreException, - DeviceManagementException { + private void inviteNewlyAddedUserToEnrollDevice( + String username, String password) throws MDMAPIException { if (log.isDebugEnabled()) { log.debug("Sending invitation mail to user by username: " + username); } - String tennentDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain(); - if (tennentDomain.equalsIgnoreCase("carbon.super")) { - tennentDomain = ""; + String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain(); + if (MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equalsIgnoreCase(tenantDomain)) { + tenantDomain = ""; } if (!username.contains("/")) { username = "/" + username; } String[] usernameBits = username.split("/"); DeviceManagementProviderService deviceManagementProviderService = MDMAPIUtils.getDeviceManagementService(); - EmailMessageProperties emailMessageProperties = new EmailMessageProperties(); - emailMessageProperties.setUserName(usernameBits[1]); - emailMessageProperties.setDomainName(tennentDomain); - emailMessageProperties.setFirstName(getClaimValue(username, Constants.USER_CLAIM_FIRST_NAME)); - emailMessageProperties.setPassword(password); - String[] mailAddress = new String[1]; - mailAddress[0] = getClaimValue(username, Constants.USER_CLAIM_EMAIL_ADDRESS); - emailMessageProperties.setMailTo(mailAddress); - deviceManagementProviderService.sendRegistrationEmail(emailMessageProperties); + + Properties props = new Properties(); + props.setProperty("username", usernameBits[1]); + props.setProperty("domain-name", tenantDomain); + props.setProperty("first-name", getClaimValue(username, Constants.USER_CLAIM_FIRST_NAME)); + props.setProperty("password", password); + + String recipient = getClaimValue(username, Constants.USER_CLAIM_EMAIL_ADDRESS); + + EmailMetaInfo metaInfo = new EmailMetaInfo(recipient, props); + try { + deviceManagementProviderService.sendRegistrationEmail(metaInfo); + } catch (DeviceManagementException e) { + String msg = "Error occurred while sending registration email to user '" + username + "'"; + log.error(msg, e); + throw new MDMAPIException(msg, e); + } } /** @@ -635,26 +622,20 @@ public class User { } DeviceManagementProviderService deviceManagementProviderService = MDMAPIUtils.getDeviceManagementService(); try { - for (int i = 0; i < usernames.size(); i++) { - EmailMessageProperties emailMessageProperties = new EmailMessageProperties(); - emailMessageProperties - .setFirstName(getClaimValue(usernames.get(i), Constants.USER_CLAIM_FIRST_NAME)); - emailMessageProperties.setUserName(usernames.get(i)); - String[] mailAddress = new String[1]; - mailAddress[0] = getClaimValue(usernames.get(i), Constants.USER_CLAIM_EMAIL_ADDRESS); - if (StringUtils.isNotEmpty(mailAddress[0])) { - emailMessageProperties.setMailTo(mailAddress); - deviceManagementProviderService.sendEnrolmentInvitation(emailMessageProperties); - } + for (String username : usernames) { + String recipient = getClaimValue(username, Constants.USER_CLAIM_EMAIL_ADDRESS); + + Properties props = new Properties(); + props.setProperty("first-name", getClaimValue(username, Constants.USER_CLAIM_FIRST_NAME)); + props.setProperty("username", username); + + EmailMetaInfo metaInfo = new EmailMetaInfo(recipient, props); + deviceManagementProviderService.sendEnrolmentInvitation(metaInfo); } - } catch (UserStoreException e) { - String errorMsg = "Exception in trying to invite user."; - log.error(errorMsg, e); - throw new MDMAPIException(errorMsg, e); } catch (DeviceManagementException e) { - String errorMsg = "Exception in trying to invite user."; - log.error(errorMsg, e); - throw new MDMAPIException(errorMsg, e); + String msg = "Error occurred while inviting user to enrol their device"; + log.error(msg, e); + throw new MDMAPIException(msg, e); } ResponsePayload responsePayload = new ResponsePayload(); responsePayload.setStatusCode(HttpStatus.SC_OK); @@ -685,9 +666,9 @@ public class User { } return dmService.getDevicesOfUser(username); } catch (DeviceManagementException e) { - String errorMsg = "Device management error"; - log.error(errorMsg, e); - throw new MDMAPIException(errorMsg, e); + String msg = "Device management error"; + log.error(msg, e); + throw new MDMAPIException(msg, e); } } @@ -734,7 +715,7 @@ public class User { } SetReferenceTransformer transformer = new SetReferenceTransformer(); transformer.transform(Arrays.asList(userStoreManager.getRoleListOfUser(username)), - userList); + userList); final String[] rolesToAdd = (String[]) transformer.getObjectsToAdd().toArray(new String[transformer.getObjectsToAdd().size()]); final String[] rolesToDelete = (String[]) @@ -757,30 +738,26 @@ public class User { * @throws MDMAPIException */ @POST - @Path("reset-password") + @Path("change-password") @Consumes({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON}) public Response resetPassword(UserCredentialWrapper credentials) throws MDMAPIException { - UserStoreManager userStoreManager = MDMAPIUtils.getUserStoreManager(); - ResponsePayload responsePayload = new ResponsePayload(); - try { - byte[] decodedNewPassword = Base64.decodeBase64(credentials.getNewPassword()); - userStoreManager.updateCredentialByAdmin(credentials.getUsername(), new String( - decodedNewPassword, "UTF-8")); - responsePayload.setStatusCode(HttpStatus.SC_CREATED); - responsePayload.setMessageFromServer("User password by username: " + credentials.getUsername() + - " was successfully changed."); - return Response.status(HttpStatus.SC_CREATED).entity(responsePayload).build(); - } catch (UserStoreException e) { - String errorMsg = "Exception in trying to change the password by username: " + credentials.getUsername(); - log.error(errorMsg, e); - responsePayload.setStatusCode(HttpStatus.SC_BAD_REQUEST); - responsePayload.setMessageFromServer("Old password does not match."); - return Response.status(HttpStatus.SC_BAD_REQUEST).entity(responsePayload).build(); - } catch (UnsupportedEncodingException e) { - String errorMsg = "Exception in trying to change the password by username: " + credentials.getUsername(); - log.error(errorMsg, e); - throw new MDMAPIException(errorMsg, e); - } + return CredentialManagementResponseBuilder.buildChangePasswordResponse(credentials); } -} + + /** + * Method to change the user password. + * + * @param credentials Wrapper object representing user credentials. + * @return {Response} Status of the request wrapped inside Response object. + * @throws MDMAPIException + */ + @POST + @Path("reset-password") + @Consumes({MediaType.APPLICATION_JSON}) + @Produces({MediaType.APPLICATION_JSON}) + public Response resetPasswordByAdmin(UserCredentialWrapper credentials) throws MDMAPIException { + return CredentialManagementResponseBuilder.buildResetPasswordResponse(credentials); + } + +} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/util/CredentialManagementResponseBuilder.java b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/util/CredentialManagementResponseBuilder.java new file mode 100644 index 000000000..640036758 --- /dev/null +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/util/CredentialManagementResponseBuilder.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.mdm.api.util; + +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.httpclient.HttpStatus; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.mdm.api.common.MDMAPIException; +import org.wso2.carbon.mdm.beans.UserCredentialWrapper; +import org.wso2.carbon.user.api.UserStoreException; +import org.wso2.carbon.user.api.UserStoreManager; + +import javax.ws.rs.core.Response; +import java.io.UnsupportedEncodingException; + +/** + * This class builds Credential modification related Responses + */ +public class CredentialManagementResponseBuilder { + + private static Log log = LogFactory.getLog(CredentialManagementResponseBuilder.class); + + private ResponsePayload responsePayload; + + /** + * Builds the response to change the password of a user + * @param credentials - User credentials + * @return Response Object + * @throws MDMAPIException + */ + public static Response buildChangePasswordResponse(UserCredentialWrapper credentials) throws MDMAPIException { + UserStoreManager userStoreManager = MDMAPIUtils.getUserStoreManager(); + ResponsePayload responsePayload = new ResponsePayload(); + + try { + byte[] decodedNewPassword = Base64.decodeBase64(credentials.getNewPassword()); + byte[] decodedOldPassword = Base64.decodeBase64(credentials.getOldPassword()); + userStoreManager.updateCredential(credentials.getUsername(), new String( + decodedNewPassword, "UTF-8"), new String(decodedOldPassword, "UTF-8")); + responsePayload.setStatusCode(HttpStatus.SC_CREATED); + responsePayload.setMessageFromServer("User password by username: " + credentials.getUsername() + + " was successfully changed."); + return Response.status(HttpStatus.SC_CREATED).entity(responsePayload).build(); + } catch (UserStoreException e) { + log.error(e.getMessage(), e); + responsePayload.setStatusCode(HttpStatus.SC_BAD_REQUEST); + responsePayload.setMessageFromServer("Old password does not match."); + return Response.status(HttpStatus.SC_BAD_REQUEST).entity(responsePayload).build(); + } catch (UnsupportedEncodingException e) { + String errorMsg = "Could not change the password of the user: " + credentials.getUsername() + + ". The Character Encoding is not supported."; + log.error(errorMsg, e); + throw new MDMAPIException(errorMsg, e); + } + + } + + /** + * Builds the response to reset the password of a user + * @param credentials - User credentials + * @return Response Object + * @throws MDMAPIException + */ + public static Response buildResetPasswordResponse(UserCredentialWrapper credentials) throws MDMAPIException { + UserStoreManager userStoreManager = MDMAPIUtils.getUserStoreManager(); + ResponsePayload responsePayload = new ResponsePayload(); + try { + byte[] decodedNewPassword = Base64.decodeBase64(credentials.getNewPassword()); + userStoreManager.updateCredentialByAdmin(credentials.getUsername(), new String( + decodedNewPassword, "UTF-8")); + responsePayload.setStatusCode(HttpStatus.SC_CREATED); + responsePayload.setMessageFromServer("User password by username: " + credentials.getUsername() + + " was successfully changed."); + return Response.status(HttpStatus.SC_CREATED).entity(responsePayload).build(); + } catch (UserStoreException e) { + log.error(e.getMessage(), e); + responsePayload.setStatusCode(HttpStatus.SC_BAD_REQUEST); + responsePayload.setMessageFromServer("Could not change the password."); + return Response.status(HttpStatus.SC_BAD_REQUEST).entity(responsePayload).build(); + } catch (UnsupportedEncodingException e) { + String errorMsg = "Could not change the password of the user: " + credentials.getUsername() + + ". The Character Encoding is not supported."; + log.error(errorMsg, e); + throw new MDMAPIException(errorMsg, e); + } + } + +} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/util/MDMAPIUtils.java b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/util/MDMAPIUtils.java index 0c474818a..d2a3fb9d2 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/util/MDMAPIUtils.java +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/util/MDMAPIUtils.java @@ -20,6 +20,7 @@ package org.wso2.carbon.mdm.api.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.certificate.mgt.core.service.CertificateManagementService; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; @@ -29,6 +30,8 @@ import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration; import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfigurationManagementService; import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementService; import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderService; +import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager; +import org.wso2.carbon.device.mgt.core.search.mgt.SearchManagerService; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.mdm.api.common.MDMAPIException; import org.wso2.carbon.ntask.core.TaskManager; @@ -43,6 +46,7 @@ import org.wso2.carbon.user.api.UserStoreManager; import org.wso2.carbon.user.core.service.RealmService; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; +import javax.ws.rs.core.MediaType; import java.util.List; /** @@ -51,6 +55,7 @@ import java.util.List; public class MDMAPIUtils { private static final String NOTIFIER_FREQUENCY = "notifierFrequency"; + public static final MediaType DEFAULT_CONTENT_TYPE = MediaType.APPLICATION_JSON_TYPE; private static Log log = LogFactory.getLog(MDMAPIUtils.class); @@ -252,4 +257,57 @@ public class MDMAPIUtils { pagingResponse.setData(data); return pagingResponse; } + + public static CertificateManagementService getCertificateManagementService() { + + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + CertificateManagementService certificateManagementService = (CertificateManagementService) + ctx.getOSGiService(CertificateManagementService.class, null); + + if (certificateManagementService == null) { + String msg = "Certificate Management service not initialized."; + log.error(msg); + throw new IllegalStateException(msg); + } + + return certificateManagementService; + } + + + public static MediaType getResponseMediaType(String acceptHeader) { + MediaType responseMediaType; + if (acceptHeader == null || MediaType.WILDCARD.equals(acceptHeader)) { + responseMediaType = DEFAULT_CONTENT_TYPE; + } else { + responseMediaType = MediaType.valueOf(acceptHeader); + } + + return responseMediaType; + } + + public static DeviceInformationManager getDeviceInformationManagerService() { + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + DeviceInformationManager deviceInformationManager = + (DeviceInformationManager) ctx.getOSGiService(DeviceInformationManager.class, null); + if (deviceInformationManager == null) { + String msg = "Device information Manager service has not initialized."; + log.error(msg); + throw new IllegalStateException(msg); + } + return deviceInformationManager; + } + + + + public static SearchManagerService getSearchManagerService() { + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + SearchManagerService searchManagerService = + (SearchManagerService) ctx.getOSGiService(SearchManagerService.class, null); + if (searchManagerService == null) { + String msg = "Device search manager service has not initialized."; + log.error(msg); + throw new IllegalStateException(msg); + } + return searchManagerService; + } } diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/util/ResponsePayload.java b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/util/ResponsePayload.java index 8cc7d3591..629400066 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/util/ResponsePayload.java +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/api/util/ResponsePayload.java @@ -15,6 +15,7 @@ * specific language governing permissions and limitations * under the License. */ + package org.wso2.carbon.mdm.api.util; import javax.xml.bind.annotation.XmlElement; @@ -54,21 +55,21 @@ public class ResponsePayload { this.responseContent = responseContent; } - private ResponsePayload.ResponsePayloadBuilder getBuilder() { - return new ResponsePayload.ResponsePayloadBuilder(); + private ResponsePayloadBuilder getBuilder() { + return new ResponsePayloadBuilder(); } - public static ResponsePayload.ResponsePayloadBuilder statusCode(int statusCode) { + public static ResponsePayloadBuilder statusCode(int statusCode) { ResponsePayload message = new ResponsePayload(); return message.getBuilder().statusCode(statusCode); } - public static ResponsePayload.ResponsePayloadBuilder messageFromServer(String messageFromServer) { + public static ResponsePayloadBuilder messageFromServer(String messageFromServer) { ResponsePayload message = new ResponsePayload(); return message.getBuilder().messageFromServer(messageFromServer); } - public static ResponsePayload.ResponsePayloadBuilder responseContent(String responseContent) { + public static ResponsePayloadBuilder responseContent(String responseContent) { ResponsePayload message = new ResponsePayload(); return message.getBuilder().responseContent(responseContent); } diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/beans/EnrollmentCertificate.java b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/beans/EnrollmentCertificate.java new file mode 100644 index 000000000..bde1cf1a7 --- /dev/null +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/beans/EnrollmentCertificate.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.mdm.beans; + +public class EnrollmentCertificate { + String serial; + String pem; + int tenantId; + + public int getTenantId() { + return tenantId; + } + + public void setTenantId(int tenantId) { + this.tenantId = tenantId; + } + + public String getSerial() { + return serial; + } + + public void setSerial(String serial) { + this.serial = serial; + } + + public String getPem() { + return pem; + } + + public void setPem(String pem) { + this.pem = pem; + } + +} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/beans/UserWrapper.java b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/beans/UserWrapper.java index 0e4778d23..acdb9efca 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/beans/UserWrapper.java +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/beans/UserWrapper.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * WSO2 Inc. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except * in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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 + * "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. */ @@ -84,4 +84,4 @@ public class UserWrapper { public void setPassword(String password) { this.password = password; } -} +} \ No newline at end of file diff --git a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/constants/CameraConstants.java b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/exception/BadRequestException.java similarity index 56% rename from components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/constants/CameraConstants.java rename to components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/exception/BadRequestException.java index fa9b91d83..adbe78069 100644 --- a/components/iot-plugins/camera-plugin/org.wso2.carbon.device.mgt.iot.camera.plugin.impl/src/main/java/org/wso2/carbon/device/mgt/iot/camera/plugin/constants/CameraConstants.java +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/exception/BadRequestException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * WSO2 Inc. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except @@ -16,12 +16,16 @@ * under the License. */ -package org.wso2.carbon.device.mgt.iot.camera.plugin.constants; +package org.wso2.carbon.mdm.exception; -public class CameraConstants { - public final static String DEVICE_TYPE = "camera"; - public final static String DEVICE_PLUGIN_DEVICE_NAME = "DEVICE_NAME"; - public final static String DEVICE_PLUGIN_DEVICE_ID = "CAMERA_DEVICE_ID"; - public final static String STATE_ON = "ON"; - public final static String STATE_OFF = "OFF"; -} +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +public class BadRequestException extends WebApplicationException { + + public BadRequestException(Message message, MediaType mediaType) { + super(Response.status(Response.Status.BAD_REQUEST).entity(message).type(mediaType).build()); + } + +} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/exception/Message.java b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/exception/Message.java new file mode 100644 index 000000000..4d5ee2ded --- /dev/null +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/java/org/wso2/carbon/mdm/exception/Message.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.mdm.exception; + +public class Message { + + private String errorMessage; + private String discription; + + public String getErrorMessage() { + return errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + + public String getDiscription() { + return discription; + } + + public void setDiscription(String discription) { + this.discription = discription; + } +} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/webapp/META-INF/permissions.xml b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/webapp/META-INF/permissions.xml index 0e11fe9ba..d2442641f 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/webapp/META-INF/permissions.xml +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/webapp/META-INF/permissions.xml @@ -30,165 +30,305 @@ + - Get all devices - /device-mgt/devices/list - /devices + Device Management + /device-mgt + / GET - emm_admin - Get all device types - /device-mgt/devices/types + Device Management Admin + /device-mgt/emm-admin + / + GET + + + + Device Management User + /device-mgt/user + / + GET + + + + Devices + /device-mgt/emm-admin/devices + / + GET + + + + Policies + /device-mgt/emm-admin/policies + / + GET + + + + Notifications + /device-mgt/emm-admin/notifications + / + GET + + + + Users + /device-mgt/emm-admin/users + / + GET + + + + Operations + /device-mgt/emm-admin/operations + / + GET + + + + Applications + /device-mgt/emm-admin/operations/applications + / + GET + + + + Roles + /device-mgt/emm-admin/roles + / + GET + + + + Configurations + /device-mgt/emm-admin/platform-configs + / + GET + + + + View Dashboard + /device-mgt/emm-admin/dashboard + / + GET + + + + List devices + /device-mgt/emm-admin/devices/list + /devices + GET + + + + List devices + /device-mgt/emm-admin/devices/list + /devices/types + GET + + + + Add policy + /device-mgt/emm-admin/policies/add + /devices/types + GET + + + + Edit policy + /device-mgt/emm-admin/policies/update /devices/types GET - emm_admin View device - /device-mgt/devices/view + /device-mgt/emm-admin/devices/view /devices/view GET - emm_admin - Get device - /device-mgt/devices/view - /devices/*/* + View device + /device-mgt/user/devices/view + /devices/view GET - emm_admin,emm_user + + + + + + + + - Get users' devices - /device-mgt/devices/view + View device + /device-mgt/emm-admin/devices/view /devices/user/*/* GET - emm_admin,emm_user - Get device count - /device-mgt/devices/count + List devices + /device-mgt/emm-admin/devices/list /devices/count GET - emm_admin - Get all users' devices - /device-mgt/devices/list + List devices + /device-mgt/emm-admin/devices/list /devices/name/*/* GET - emm_admin,emm_user - Get all notifications - /device-mgt/notifications/view + View notifications + /device-mgt/emm-admin/notifications/view /notifications GET - emm_admin Add notification - /device-mgt/notifications/add + /device-mgt/emm-admin/notifications/add /notifications POST - emm_admin Update notification - /device-mgt/notifications/view + /device-mgt/emm-admin/notifications/update /notifications/*/* PUT - emm_admin - Get new notifications - /device-mgt/notifications/view + View notifications + /device-mgt/emm-admin/notifications/view /notifications/* GET - emm_admin - Get all operations - /device-mgt/operations/view + View user + /device-mgt/emm-admin/users/view /operations GET - emm_admin - Add Operation - /device-mgt/operations/add + Install application + /device-mgt/emm-admin/operations/applications/install-applications /operations POST - emm_admin - Install Application - /device-mgt/operations/application/install + Install application + /device-mgt/emm-admin/operations/applications/install-applications /operations/installApp/* POST - emm_admin,emm_user - Uninstall Application - /device-mgt/operations/application/uninstall + Uninstall application + /device-mgt/emm-admin/operations/applications/uninstall-applications /operations/uninstallApp/* POST - emm_admin,emm_user - Get Applications For Devices - /device-mgt/operations/application/view + View application + /device-mgt/emm-admin/operations/applications/view-applications /operations/*/*/* GET - emm_admin,emm_user - - - Get Device Operations - /device-mgt/operations/view - /operations/*/* - GET - emm_admin,emm_user - Get Applications For Device Type - /device-mgt/operations/application/view - /operations/* + View devices + /device-mgt/user/devices/view + /operations/*/*/* GET - emm_admin,emm_user + + + View device + /device-mgt/emm-admin/devices/view + /operations/*/*/* + GET + + + + View device + /device-mgt/emm-admin/devices/view + /operations/*/* + GET + + + + View device + /device-mgt/emm-admin/devices/view + /operations/paginate/*/* + GET + + + + View device + /device-mgt/user/devices/view + /operations/*/* + GET + + + + View device + /device-mgt/user/devices/view + /operations/paginate/*/* + GET + + + + + + + + + - Get features - /device-mgt/features/view + List policies + /device-mgt/emm-admin/policies/list /features/* GET - emm_admin + - Get all features - /device-mgt/features/view + View device + /device-mgt/emm-admin/devices/view + /features/* + GET + + + + View device + /device-mgt/user/devices/view + /features/* + GET + + + + View device + /device-mgt/user/devices/view /features GET emm_admin @@ -197,331 +337,460 @@ - Get all roles - /device-mgt/roles + List roles + /device-mgt/emm-admin/roles/list /roles GET - emm_admin + - Get role permissions - /device-mgt/roles + View user + /device-mgt/emm-admin/users/view + /roles + GET + + + + Add policy + /device-mgt/emm-admin/policies/add + /roles + GET + + + + Update policy + /device-mgt/emm-admin/policies/update + /roles + GET + + + + List roles + /device-mgt/emm-admin/roles/list /roles/permissions GET - emm_admin + - Get User roles - /device-mgt/roles + List roles + /device-mgt/emm-admin/roles/list /roles/* GET - emm_admin + - Update User roles - /device-mgt/roles/update + Add user + /device-mgt/emm-admin/users/add + /roles/* + GET + + + + Update role + /device-mgt/emm-admin/roles/update /roles PUT - emm_admin + + + + + + + + + - Update a specific role - /device-mgt/roles/update - /roles/* + Update role + /device-mgt/emm-admin/roles/update + /roles/users PUT - emm_admin + - Update User roles - /device-mgt/roles - /roles/*/users - PUT - emm_admin - - - Save User roles - /device-mgt/roles/add + Add role + /device-mgt/emm-admin/roles/add /roles POST - emm_admin + - Delete User roles - /device-mgt/roles/delete + Remove role + /device-mgt/emm-admin/roles/remove /roles DELETE - emm_admin + + + + List roles + /device-mgt/emm-admin/roles/list + /roles/count + GET - Get all users - /device-mgt/users/view + List users + /device-mgt/emm-admin/users/list /users GET - emm_admin + Add user - /device-mgt/users/add + /device-mgt/emm-admin/users/add /users POST - emm_admin + - Get user - /device-mgt/users/view + View user + /device-mgt/emm-admin/users/view /users/view GET - emm_admin + Update user - /device-mgt/users/update + /device-mgt/emm-admin/users/update /users PUT - emm_admin + Change user password - /device-mgt/users/reset-password + /login + /users/change-password + POST + emm_admin + + + + Reset password + /device-mgt/emm-admin/users/password-reset /users/reset-password POST - emm_admin + - Delete user - /device-mgt/users/delete + Remove user + /device-mgt/emm-admin/users/remove /users DELETE - emm_admin + - Get user roles by name - /device-mgt/users/roles + View user + /device-mgt/emm-admin/users/view /users/roles GET - emm_admin + + + + + + + + - Get user roles by name - /device-mgt/users/roles - /roles - GET - emm_admin - - - Save Roles - /device-mgt/users/roles + Add user + /device-mgt/emm-admin/users/add /roles POST - emm_admin + - Get all devices of user - /device-mgt/users/devices + List devices + /device-mgt/user/devices/list /users/devices GET - emm_admin + - Get user roles - /device-mgt/users/roles + List devices + /device-mgt/emm-admin/devices/list + /users/devices + GET + + + + View user + /device-mgt/emm-admin/users/view /users/*/* GET - emm_admin + - Get user count - /device-mgt/users/view + List users + /device-mgt/emm-admin/users/list /users/count GET - emm_admin + - Get all user names - /device-mgt/users/view + List users + /device-mgt/emm-admin/users/list /users/view-users GET - emm_admin + - Get all usernames - /device-mgt/users/view + Add role + /device-mgt/emm-admin/roles/add + /users/view-users + GET + + + + Update role + /device-mgt/emm-admin/roles/update + /users/view-users + GET + + + + Add policy + /device-mgt/emm-admin/policies/add + /users/view-users + GET + + + + Update policy + /device-mgt/emm-admin/policies/update + /users/view-users + GET + + + + List users + /device-mgt/emm-admin/users/list /users/users-by-username GET - emm_admin + - Get filtered usernames - /device-mgt/users/view + List users + /device-mgt/emm-admin/users/list /users/users-by-username/* GET - emm_admin + - Send invitation - /device-mgt/users/invite + Invite user + /device-mgt/emm-admin/users/invite /users/email-invitation POST - emm_admin + + + + Authorize user + /login + /users/authorize + POST Add Policy - /device-mgt/policies/add + /device-mgt/emm-admin/policies/add /policies/inactive-policy POST - emm_admin + - Get Policy For Device - /device-mgt/policies/view + List policies + /device-mgt/emm-admin/policies/list /policies/*/* POST - emm_admin + - Get Policy For Device By Type - /device-mgt/policies/view + List policies + /device-mgt/emm-admin/policies/list /policies/*/*/* GET - emm_admin + - Add Active Policy - /device-mgt/policies/add + View device + /device-mgt/emm-admin/devices/view + /policies/*/*/* + GET + + + + View device + /device-mgt/user/devices/view + /policies/*/*/* + GET + + + + Add policy + /device-mgt/emm-admin/policies/add /policies/active-policy POST - emm_admin + - Bulk Policy Removal - /device-mgt/policies/bulk-remove + Remove policy + /device-mgt/emm-admin/policies/remove /policies/bulk-remove POST - emm_admin + - Get Policies - /device-mgt/policies/view + List policies + /device-mgt/emm-admin/policies/list /policies GET - emm_admin + - Get Policy - /device-mgt/policies/view + List policies + /device-mgt/emm-admin/policies/list /policies/* GET - emm_admin + - Update Policy - /device-mgt/policies/update + Update policy + /device-mgt/emm-admin/policies/update /policies/* PUT - emm_admin + - Delete Policy - /device-mgt/policies/delete + Remove policy + /device-mgt/emm-admin/policies/remove /policies DELETE - emm_admin + - Policy Count - /device-mgt/policies/view + List policies + /device-mgt/emm-admin/policies/list /policies/count GET - emm_admin + - Policy priorities - /device-mgt/policies/update + Edit policy + /device-mgt/emm-admin/policies/update /policies/priorities PUT - emm_admin + - Activate Policy - /device-mgt/policies/update + Edit policy + /device-mgt/emm-admin/policies/update /policies/activate PUT - emm_admin + - Inactivate Policy - /device-mgt/policies/update + Add policy + /device-mgt/emm-admin/policies/add + /policies/activate + PUT + + + + Edit policy + /device-mgt/emm-admin/policies/update /policies/inactivate PUT - emm_admin + - Apply Policy changes - /device-mgt/policies/update + Add policy + /device-mgt/emm-admin/policies/add + /policies/inactivate + PUT + + + + Edit policy + /device-mgt/emm-admin/policies/update /policies/apply-changes PUT - emm_admin + - Start Task - /device-mgt/policies/task + Add policy + /device-mgt/emm-admin/policies/add /policies/start-task/* GET - emm_admin + - Update Task - /device-mgt/policies/task + Add policy + /device-mgt/emm-admin/policies/add /policies/update-task/* GET - emm_admin + - Stop Task - /device-mgt/policies/task + Add policy + /device-mgt/emm-admin/policies/add /policies/stop-task GET - emm_admin + - Get Policy Compliance - /device-mgt/policies/compliance + List policies + /device-mgt/emm-admin/policies/list /policies/*/* GET - emm_admin - Add profile - /device-mgt/profiles/add + Add policy + /device-mgt/emm-admin/policies/add /profiles POST - emm_admin + - Update profile - /device-mgt/profiles/update + Edit policy + /device-mgt/emm-admin/policies/update /profiles/* PUT - emm_admin + - Add profile - /device-mgt/profiles/delete + Remove policy + /device-mgt/emm-admin/policies/remove /profiles/* DELETE - emm_admin + + + + Device Information + /device-mgt/emm-admin/information/get + /information/*/* + GET + + + + Device Search + /device-mgt/emm-admin/search + /information/* + GET + + + + + @@ -541,25 +810,49 @@ - Get configuration - /device-mgt/tenant/configuration/view + View configuration + /device-mgt/emm-admin/platform-configs/view /configuration GET - emm_admin + Add configuration - /device-mgt/tenant/configuration/modify + /device-mgt/emm-admin/platform-configs/add /configuration POST + + + + Update configuration + /device-mgt/emm-admin/platform-configs/modify + /configuration + PUT + + + + + + + Save certificate in the database + /device-mgt/android/certificate/save + /certificates/saveCertificate + POST emm_admin - Update configuration - /device-mgt/tenant/configuration/modify - /configuration - PUT + get certificate in the database + /device-mgt/android/certificate/Get + /certificates/* + GET emm_admin - + + get certificate in the database + /device-mgt/android/certificate/Get + /certificates/* + DELETE + emm_admin + + \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/webapp/WEB-INF/cxf-servlet.xml index dc53a029b..e4b794b8a 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.api/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -1,6 +1,6 @@ @@ -105,6 +105,15 @@ + + + + + + + + + @@ -114,6 +123,26 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.url.printer/src/main/java/org/wso2/carbon/device/mgt/mobile/url/printer/URLPrinterStartupHandler.java b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.url.printer/src/main/java/org/wso2/carbon/device/mgt/mobile/url/printer/URLPrinterStartupHandler.java index 1eaad8ad4..80aa39805 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.url.printer/src/main/java/org/wso2/carbon/device/mgt/mobile/url/printer/URLPrinterStartupHandler.java +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.url.printer/src/main/java/org/wso2/carbon/device/mgt/mobile/url/printer/URLPrinterStartupHandler.java @@ -37,7 +37,7 @@ public class URLPrinterStartupHandler implements ServerStartupObserver { @Override public void completedServerStartup() { - log.info("Device Management Console URL : " + this.getEmmUrl()); + log.info("EMM Console URL : " + this.getEmmUrl()); } private String getEmmUrl() { @@ -58,7 +58,7 @@ public class URLPrinterStartupHandler implements ServerStartupObserver { if (httpsProxyPort > 0) { port = httpsProxyPort; } - return "https://" + hostName + ":" + port + "/devicemgt"; + return "https://" + hostName + ":" + port + "/emm"; } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/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 similarity index 100% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManagementService.java rename to 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 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/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 similarity index 100% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManager.java rename to 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 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/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 similarity index 100% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidFeatureManager.java rename to 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 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/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 similarity index 100% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidPolicyMonitoringService.java rename to 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 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/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 similarity index 100% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/AndroidDAOFactory.java rename to 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 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/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 similarity index 100% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/AndroidFeatureManagementDAOException.java rename to 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 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/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 similarity index 100% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/impl/AndroidDeviceDAOImpl.java rename to 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 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/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 similarity index 100% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/impl/AndroidFeatureDAOImpl.java rename to 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 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/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 similarity index 100% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMResult.java rename to 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 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/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 similarity index 100% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMService.java rename to 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 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/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 similarity index 100% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMUtil.java rename to 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 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/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 similarity index 100% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/util/AndroidPluginConstants.java rename to 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 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/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 similarity index 100% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/util/AndroidPluginUtils.java rename to 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 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/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 similarity index 100% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/util/AndroidUtils.java rename to 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 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/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 similarity index 100% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManagementService.java rename to 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 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/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 similarity index 100% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java rename to 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 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/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 similarity index 100% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsFeatureManager.java rename to 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 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/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 similarity index 100% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsPolicyMonitoringService.java rename to 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 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/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 similarity index 100% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/dao/WindowsDAOFactory.java rename to 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 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/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 similarity index 100% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/dao/WindowsFeatureManagementDAOException.java rename to 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 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/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 similarity index 100% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/dao/impl/WindowsDeviceDAOImpl.java rename to 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 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/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 similarity index 100% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/dao/impl/WindowsFeatureDAOImpl.java rename to 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 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/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 similarity index 100% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsPluginConstants.java rename to 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 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/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 similarity index 100% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsPluginUtils.java rename to 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 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/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 similarity index 100% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsUtils.java rename to 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 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 d8943def1..869904e81 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,6 +19,7 @@ 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; /** @@ -27,6 +28,8 @@ import org.wso2.carbon.registry.core.service.RegistryService; public class MobileDeviceManagementDataHolder { private RegistryService registryService; + private DeviceManagementService androidDeviceManagementService; + private GCMService gcmService; private static MobileDeviceManagementDataHolder thisInstance = new MobileDeviceManagementDataHolder(); @@ -45,4 +48,20 @@ public class MobileDeviceManagementDataHolder { this.registryService = registryService; } + public DeviceManagementService getAndroidDeviceManagementService() { + return androidDeviceManagementService; + } + + public void setAndroidDeviceManagementService( + DeviceManagementService androidDeviceManagementService) { + 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 e08771b3b..92404b67a 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,13 +23,20 @@ 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; @@ -53,6 +60,10 @@ 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); protected void activate(ComponentContext ctx) { @@ -89,6 +100,30 @@ 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"); } @@ -102,6 +137,15 @@ 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(); + } if (log.isDebugEnabled()) { log.debug( "Mobile Device Management Service Component has been successfully de-activated"); diff --git a/components/mobile-plugins/mobile-base-plugin/pom.xml b/components/mobile-plugins/mobile-base-plugin/pom.xml index b2912b562..212c8f78b 100644 --- a/components/mobile-plugins/mobile-base-plugin/pom.xml +++ b/components/mobile-plugins/mobile-base-plugin/pom.xml @@ -1,21 +1,21 @@ + ~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + ~ + ~ WSO2 Inc. licenses this file to you under the Apache License, + ~ Version 2.0 (the "License"); you may not use this file except + ~ in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> diff --git a/components/mobile-plugins/pom.xml b/components/mobile-plugins/pom.xml index 7c62f920b..fd8749a3e 100644 --- a/components/mobile-plugins/pom.xml +++ b/components/mobile-plugins/pom.xml @@ -1,21 +1,21 @@ + ~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + ~ + ~ WSO2 Inc. licenses this file to you under the Apache License, + ~ Version 2.0 (the "License"); you may not use this file except + ~ in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> @@ -27,7 +27,6 @@ 4.0.0 - org.wso2.carbon.devicemgt-plugins mobile-plugins pom WSO2 Carbon - Mobile Plugins diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.agent/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/discovery/beans/package-info.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.agent/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/discovery/beans/package-info.java deleted file mode 100644 index df5d15392..000000000 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.agent/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/discovery/beans/package-info.java +++ /dev/null @@ -1,22 +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. -*/ - -@javax.xml.bind.annotation.XmlSchema(namespace = - "http://schemas.microsoft.com/windows/management/2012/01/enrollment", - elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) -package org.wso2.carbon.mdm.mobileservices.windows.services.discovery.beans; diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.agent/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/beans/package-info.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.agent/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/beans/package-info.java deleted file mode 100644 index 47dd02949..000000000 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.agent/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/beans/package-info.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -@XmlSchema(namespace = "http://www.w3.org/2003/05/soap-envelope", - xmlns = { - @XmlNs(prefix = "", namespaceURI = "http://www.w3.org/2003/05/soap-envelope") - }, elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) - -package org.wso2.carbon.mdm.mobileservices.windows.services.wstep.beans; - -import javax.xml.bind.annotation.XmlNs; -import javax.xml.bind.annotation.XmlSchema; \ No newline at end of file diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.agent/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/package-info.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.agent/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/package-info.java deleted file mode 100644 index f3c0f5b58..000000000 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.agent/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/package-info.java +++ /dev/null @@ -1,23 +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. - */ - -@javax.xml.bind.annotation.XmlSchema(namespace = "http://schemas.microsoft" + - ".com/windows/pki/2009/01/enrollmentpolicy", - elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) - -package org.wso2.carbon.mdm.mobileservices.windows.services.xcep.beans; diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.agent/src/main/resources/properties.xml b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.agent/src/main/resources/properties.xml deleted file mode 100644 index 7df287f68..000000000 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.agent/src/main/resources/properties.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - Federated - wso2carbon - cacert - CN=mdmcn - 3 - 300 - wso2.com - \ No newline at end of file diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.agent/pom.xml b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/pom.xml similarity index 98% rename from components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.agent/pom.xml rename to components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/pom.xml index 8ee9a2c23..f5f7dcabd 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.agent/pom.xml +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/pom.xml @@ -1,5 +1,5 @@ - - - - jdbc:h2:mem:cdm-mobile-test-db;DB_CLOSE_DELAY=-1 - org.h2.Driver - - - - + + Federated + wso2carbon + cacert + CN=mdmcn + 3 + 300 + wso2.com + \ No newline at end of file diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.agent/src/main/resources/wap-provisioning.xml b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/resources/wap-provisioning.xml similarity index 86% rename from components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.agent/src/main/resources/wap-provisioning.xml rename to components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/resources/wap-provisioning.xml index e6729e0f4..9a6561b45 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.agent/src/main/resources/wap-provisioning.xml +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/resources/wap-provisioning.xml @@ -1,19 +1,19 @@ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.agent/src/main/resources/wso2mdm.jks b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/resources/wso2mdm.jks similarity index 100% rename from components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.agent/src/main/resources/wso2mdm.jks rename to components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/resources/wso2mdm.jks diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.agent/src/main/webapp/META-INF/permissions.xml b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/webapp/META-INF/permissions.xml similarity index 95% rename from components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.agent/src/main/webapp/META-INF/permissions.xml rename to components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/webapp/META-INF/permissions.xml index feb34b098..1a69d570d 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.agent/src/main/webapp/META-INF/permissions.xml +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/webapp/META-INF/permissions.xml @@ -1,18 +1,18 @@ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.agent/src/main/webapp/META-INF/webapp-classloading.xml b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/webapp/META-INF/webapp-classloading.xml similarity index 55% rename from components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.agent/src/main/webapp/META-INF/webapp-classloading.xml rename to components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/webapp/META-INF/webapp-classloading.xml index 0371f7c29..c90403cc6 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.agent/src/main/webapp/META-INF/webapp-classloading.xml +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/webapp/META-INF/webapp-classloading.xml @@ -1,21 +1,21 @@ + + + + + + + windows-plugin + org.wso2.carbon.devicemgt-plugins + 2.1.0-SNAPSHOT + ../pom.xml + + + 4.0.0 + org.wso2.carbon.device.mgt.mobile.windows.ui + 2.1.0-SNAPSHOT + WSO2 Carbon - Mobile Windows UI + pom + + + + + maven-assembly-plugin + 2.5.5 + + ${project.artifactId}-${carbon.device.mgt.version} + false + + src/assembly/src.xml + + + + + create-archive + package + + single + + + + + + + + \ No newline at end of file diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/assembly/src.xml b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/assembly/src.xml new file mode 100644 index 000000000..2797034e0 --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/assembly/src.xml @@ -0,0 +1,36 @@ + + + + src + + zip + + false + ${basedir}/src + + + ${basedir}/src/main/resources/jaggeryapps/devicemgt + / + true + + + \ 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.device-view/device-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.device-view/device-view.hbs new file mode 100644 index 000000000..cfdb0ed54 --- /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.device-view/device-view.hbs @@ -0,0 +1,14 @@ +{{#zone "device-opetations"}} +
+ Operations +
+
+ {{unit "mdm.unit.device.operation-bar"}} +
+{{/zone}} + +{{#zone "bottomJs"}} + {{js "js/device-detail.js"}} + + {{js "js/load-map.js"}} +{{/zone}} \ 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.device-view/device-view.json 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.device-view/device-view.json new file mode 100644 index 000000000..9eecd8f5b --- /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.device-view/device-view.json @@ -0,0 +1,3 @@ +{ + "version": "1.0.0" +} \ 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.device-view/public/js/device-detail.js 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.device-view/public/js/device-detail.js new file mode 100644 index 000000000..aa2384fc3 --- /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.device-view/public/js/device-detail.js @@ -0,0 +1,197 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +(function () { + var deviceId = $(".device-id"); + var deviceIdentifier = deviceId.data("deviceid"); + var deviceType = deviceId.data("type"); + var payload = [deviceIdentifier]; + var operationTable; + if (deviceType == "ios") { + var serviceUrl = "/ios/operation/deviceinfo"; + } else if (deviceType == "android") { + var serviceUrl = "/mdm-android-agent/operation/device-info"; + } + if (serviceUrl) { + invokerUtil.post(serviceUrl, payload, + function (message) { + console.log(message); + }, function (message) { + console.log(message); + }); + } + $(document).ready(function () { + $(".panel-body").removeClass("hidden"); + $("#loading-content").remove(); + + loadOperationsLog(); + loadApplicationsList(); + loadPolicyCompliance(); + + $("#refresh-policy").click(function () { + $('#policy-spinner').removeClass('hidden'); + loadPolicyCompliance(); + }); + + $("#refresh-apps").click(function () { + $('#apps-spinner').removeClass('hidden'); + loadApplicationsList(); + }); + + $("#refresh-operations").click(function () { + $('#operations-spinner').removeClass('hidden'); + loadOperationsLog(true); + }); + loadOperationBar(deviceType); + }); + + function loadOperationsLog(update) { + var operationsLog = $("#operations-log"); + var deviceListingSrc = operationsLog.attr("src"); + var deviceId = operationsLog.data("device-id"); + var deviceType = operationsLog.data("device-type"); + + $.template("operations-log", deviceListingSrc, function (template) { + var serviceURL = "/devicemgt_admin/operations/" + deviceType + "/" + deviceId; + + var successCallback = function (data) { + data = JSON.parse(data); + $('#operations-spinner').addClass('hidden'); + var viewModel = {}; + viewModel.operations = data; + if (data.length > 0) { + var content = template(viewModel); + if (!update) { + $("#operations-log-container").html(content); + operationTable = $('#operations-log-table').datatables_extended(); + } else { + $('#operations-log-table').dataTable().fnClearTable(); + for (var i = 0; i < data.length; i++) { + var status; + if (data[i].status == "COMPLETED") { + status = " Completed"; + } else if (data[i].status == "PENDING") { + status = " Pending"; + } else if (data[i].status == "ERROR") { + status = " Error"; + } else if (data[i].status == "IN_PROGRESS") { + status = " In Progress"; + } + + $('#operations-log-table').dataTable().fnAddData([ + data[i].code, + status, + data[i].createdTimeStamp + ]); + } + } + } + + }; + invokerUtil.get(serviceURL, + successCallback, function (message) { + console.log(message); + }); + }); + + } + + function loadApplicationsList() { + var applicationsList = $("#applications-list"); + var deviceListingSrc = applicationsList.attr("src"); + var deviceId = applicationsList.data("device-id"); + var deviceType = applicationsList.data("device-type"); + + $.template("application-list", deviceListingSrc, function (template) { + var serviceURL = "/devicemgt_admin/operations/" + deviceType + "/" + deviceId + "/apps"; + + var successCallback = function (data) { + data = JSON.parse(data); + $('#apps-spinner').addClass('hidden'); + var viewModel = {}; + if (data != null && data.length > 0) { + for (var i = 0; i < data.length; i++) { + data[i].name = data[i].name.replace(/[^\w\s]/gi, ' '); + data[i].name = data[i].name.replace(/[0-9]/g, ' '); + } + } + viewModel.applications = data; + viewModel.deviceType = deviceType; + if (data.length > 0) { + var content = template(viewModel); + $("#applications-list-container").html(content); + } + + }; + invokerUtil.get(serviceURL, + successCallback, function (message) { + console.log(message); + }); + }); + } + + function loadPolicyCompliance() { + var policyCompliance = $("#policy-view"); + var policySrc = policyCompliance.attr("src"); + var deviceId = policyCompliance.data("device-id"); + var deviceType = policyCompliance.data("device-type"); + var activePolicy = null; + + $.template("policy-view", policySrc, function (template) { + var serviceURLPolicy = "/devicemgt_admin/policies/" + deviceType + "/" + deviceId + "/active-policy" + var serviceURLCompliance = "/devicemgt_admin/policies/" + deviceType + "/" + deviceId; + + var successCallbackCompliance = function (data) { + var viewModel = {}; + viewModel.policy = activePolicy; + viewModel.deviceType = deviceType; + if (data != null && data.complianceFeatures != null && data.complianceFeatures != undefined && data.complianceFeatures.length > 0) { + viewModel.compliance = "NON-COMPLIANT"; + viewModel.complianceFeatures = data.complianceFeatures; + var content = template(viewModel); + $("#policy-list-container").html(content); + } else { + viewModel.compliance = "COMPLIANT"; + var content = template(viewModel); + $("#policy-list-container").html(content); + $("#policy-compliance-table").addClass("hidden"); + } + + }; + + var successCallbackPolicy = function (data) { + data = JSON.parse(data); + $('#policy-spinner').addClass('hidden'); + if (data != null && data.active == true) { + activePolicy = data; + invokerUtil.get(serviceURLCompliance, + successCallbackCompliance, function (message) { + console.log(message); + }); + } + }; + + invokerUtil.get(serviceURLPolicy, + successCallbackPolicy, function (message) { + console.log(message); + }); + }); + + } + +}()); 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.device-view/public/js/load-map.js 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.device-view/public/js/load-map.js new file mode 100644 index 000000000..a2a322f8c --- /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.device-view/public/js/load-map.js @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +$(document).ready(function () { + if (document.getElementById('device-location')) { + loadMap(); + } +}); + +function loadMap() { + var map; + + function initialize() { + var mapOptions = { + zoom: 18 + }; + var lat = $("#device-location").data("lat"); + var long = $("#device-location").data("long"); + + if (lat != null && lat != undefined && lat != "" && long != null && long != undefined && long != "") { + $("#map-error").hide(); + $("#device-location").show(); + map = new google.maps.Map(document.getElementById('device-location'), + mapOptions); + + var pos = new google.maps.LatLng(lat, long); + var marker = new google.maps.Marker({ + position: pos, + map: map + }); + + map.setCenter(pos); + } else { + $("#device-location").hide(); + $("#map-error").show(); + } + + } + + google.maps.event.addDomListener(window, 'load', initialize); +} \ 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.policy-edit/policy-edit.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.policy-edit/policy-edit.hbs new file mode 100644 index 000000000..c4bb415a1 --- /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.policy-edit/policy-edit.hbs @@ -0,0 +1 @@ +{{unit "mdm.unit.policy.edit"}} \ 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.policy-edit/policy-edit.json 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.policy-edit/policy-edit.json new file mode 100644 index 000000000..9eecd8f5b --- /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.policy-edit/policy-edit.json @@ -0,0 +1,3 @@ +{ + "version": "1.0.0" +} \ 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.policy-view/policy-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.policy-view/policy-view.hbs new file mode 100644 index 000000000..12cffe6bd --- /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.policy-view/policy-view.hbs @@ -0,0 +1 @@ +{{unit "mdm.unit.policy.view"}} \ 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.policy-view/policy-view.json 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.policy-view/policy-view.json new file mode 100644 index 000000000..9eecd8f5b --- /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.policy-view/policy-view.json @@ -0,0 +1,3 @@ +{ + "version": "1.0.0" +} \ 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.policy-wizard/policy-wizard.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.policy-wizard/policy-wizard.hbs new file mode 100644 index 000000000..0669d1ca6 --- /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.policy-wizard/policy-wizard.hbs @@ -0,0 +1 @@ +{{unit "mdm.unit.policy.wizard"}} \ 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.policy-wizard/policy-wizard.json 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.policy-wizard/policy-wizard.json new file mode 100644 index 000000000..9eecd8f5b --- /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.policy-wizard/policy-wizard.json @@ -0,0 +1,3 @@ +{ + "version": "1.0.0" +} \ 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/public/images/thumb.png 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/images/thumb.png new file mode 100644 index 000000000..f4541a6ec Binary files /dev/null and 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/images/thumb.png differ 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/images/windows-icon.png 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/images/windows-icon.png new file mode 100644 index 000000000..d7cd5ecef Binary files /dev/null and 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/images/windows-icon.png differ 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/images/windows_enrollment.png 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/images/windows_enrollment.png new file mode 100644 index 000000000..17b2102e3 Binary files /dev/null and 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/images/windows_enrollment.png differ 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 new file mode 100644 index 000000000..ad002615c --- /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/type-view.hbs @@ -0,0 +1,151 @@ +
+

Windows Mobile

+
+
+
+ +
+ +
+ +
+ +
+ +

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 03   Proceed + to [Prepare] section. +
  • +
+
+ + + Enroll Device + +

+
+ +
+

Prepare

+
+
    +
  • 01 Scan QR code.
  • +
  • 02 Follow instructions in wizard. +
  • +
  • 03 Configure your workspace + account +
  • +
+
+ +
+ +
+

Click on the image to zoom

+
+ + + +
+
+ +
+ + + +{{#zone "topCss"}} + +{{/zone}} + +{{#zone "bottomJs"}} + +{{/zone}} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/DataSourceListener.java 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.js similarity index 52% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/DataSourceListener.java rename to 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.js index 649786c43..ad4f0ec9c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/DataSourceListener.java +++ 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.js @@ -1,25 +1,24 @@ /* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * WSO2 Inc. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except * in compliance with the License. - * you may obtain a copy of the License at + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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 + * 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; - -public interface DataSourceListener { - - void notifyObserver(); - -} +function onRequest(context){ + var viewModel = {}; + var devicemgtProps = require('/app/conf/devicemgt-props.js').config(); + viewModel.hostName = devicemgtProps["httpsURL"]; + return viewModel; +} \ 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.json 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.json new file mode 100644 index 000000000..9eecd8f5b --- /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/type-view.json @@ -0,0 +1,3 @@ +{ + "version": "1.0.0" +} \ No newline at end of file diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsDeviceManagementService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsDeviceManagementService.java index 36d3bb963..366fda747 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsDeviceManagementService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsDeviceManagementService.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * WSO2 Inc. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except * in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -36,23 +36,12 @@ public class WindowsDeviceManagementService implements DeviceManagementService { private DeviceManager deviceManager; public static final String DEVICE_TYPE_WINDOWS = "windows"; - public static final String DEVICE_TYPE_TENANT = "carbon.super"; @Override public String getType() { return WindowsDeviceManagementService.DEVICE_TYPE_WINDOWS; } - @Override - public String getProviderTenantDomain() { - return DEVICE_TYPE_TENANT; - } - - @Override - public boolean isSharedWithAllTenants() { - return true; - } - @Override public void init() throws DeviceManagementException { this.deviceManager = new WindowsDeviceManager(); diff --git a/components/mobile-plugins/windows-plugin/pom.xml b/components/mobile-plugins/windows-plugin/pom.xml index e5de76e61..17507c4ca 100644 --- a/components/mobile-plugins/windows-plugin/pom.xml +++ b/components/mobile-plugins/windows-plugin/pom.xml @@ -1,21 +1,21 @@ + ~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + ~ + ~ WSO2 Inc. licenses this file to you under the Apache License, + ~ Version 2.0 (the "License"); you may not use this file except + ~ in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> @@ -27,7 +27,6 @@ 4.0.0 - org.wso2.carbon.devicemgt-plugins windows-plugin pom WSO2 Carbon - Mobile Plugins @@ -35,7 +34,8 @@ org.wso2.carbon.device.mgt.mobile.windows - org.wso2.carbon.device.mgt.mobile.windows.agent + org.wso2.carbon.device.mgt.mobile.windows.api + org.wso2.carbon.device.mgt.mobile.windows.ui diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/p2.inf b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/p2.inf deleted file mode 100644 index 0dab9e7d2..000000000 --- a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/p2.inf +++ /dev/null @@ -1,3 +0,0 @@ -instructions.configure = \ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile_${feature.version}/conf/mobile-config.xml,target:${installFolder}/../../conf/mobile-config.xml,overwrite:true);\ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile_${feature.version}/dbscripts/plugins/,target:${installFolder}/../../../dbscripts/cdm/plugins,overwrite:true);\ diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml deleted file mode 100644 index bebd11623..000000000 --- a/features/device-mgt/pom.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - org.wso2.carbon.devicemgt-plugins - carbon-device-mgt-plugins-parent - 2.1.0-SNAPSHOT - ../../pom.xml - - - 4.0.0 - org.wso2.carbon.devicemgt-plugins - device-mgt-feature - 2.1.0-SNAPSHOT - pom - WSO2 Carbon - Device Management Feature - http://wso2.org - - - org.wso2.carbon.device.mgt.mobile.feature - - - diff --git a/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.feature/pom.xml b/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.feature/pom.xml new file mode 100644 index 000000000..7d94f16e3 --- /dev/null +++ b/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.feature/pom.xml @@ -0,0 +1,192 @@ + + + + + + + + org.wso2.carbon.devicemgt-plugins + iot-base-plugin-feature + 2.1.0-SNAPSHOT + ../pom.xml + + + 4.0.0 + org.wso2.carbon.device.mgt.iot.feature + pom + 2.1.0-SNAPSHOT + WSO2 Carbon - IoT Device Management Feature + http://wso2.org + This feature contains the core bundles required for IoT Server + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.api + war + + + org.json.wso2 + json + + + + org.igniterealtime.smack.wso2 + smack + + + org.igniterealtime.smack.wso2 + smackx + + + net.sf.ehcache.wso2 + ehcache + 1.5.0.wso2v3 + + + + + + + maven-resources-plugin + + + copy-resources + generate-resources + + copy-resources + + + src/main/resources + + + resources + + build.properties + p2.inf + + + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + unpack + package + + unpack + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.ui + + ${project.version} + zip + true + + ${project.build.directory}/maven-shared-archive-resources/jaggeryapps/devicemgt + + **/* + + + + + + copy + package + + copy + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.api + war + true + ${project.build.directory}/maven-shared-archive-resources/webapps/ + common.war + + + + + + + + org.wso2.maven + carbon-p2-plugin + ${carbon.p2.plugin.version} + + + p2-feature-generation + package + + p2-feature-gen + + + org.wso2.carbon.device.mgt.iot + ../../../features/etc/feature.properties + + + org.wso2.carbon.p2.category.type:server + org.eclipse.equinox.p2.type.group:false + + + + + org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot:${carbon.devicemgt.plugins.version} + + + org.json.wso2:json:${commons-json.version} + + + org.eclipse.paho:org.eclipse.paho.client.mqttv3:${eclipse.paho.version} + + + org.igniterealtime.smack.wso2:smack:${smack.wso2.version} + + + org.igniterealtime.smack.wso2:smackx:${smackx.wso2.version} + + + + org.wso2.carbon.core.server:${carbon.kernel.version} + + org.wso2.carbon.device.mgt.server:${carbon.device.mgt.version} + + + + + + + + + diff --git a/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.feature/src/main/resources/build.properties b/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.feature/src/main/resources/build.properties new file mode 100644 index 000000000..33bb0980d --- /dev/null +++ b/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.feature/src/main/resources/build.properties @@ -0,0 +1,19 @@ +# +# Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +# +# WSO2 Inc. licenses this file to you under the Apache License, +# Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +custom = true diff --git a/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.feature/src/main/resources/conf/devicemgt-config.xml b/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.feature/src/main/resources/conf/devicemgt-config.xml new file mode 100644 index 000000000..b245214be --- /dev/null +++ b/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.feature/src/main/resources/conf/devicemgt-config.xml @@ -0,0 +1,45 @@ + + + + + + + MQTT + true + org.wso2.carbon.device.mgt.iot.controlqueue.mqtt.MqttControlPublisher + MQTT + + tcp://localhost + 1883 + admin + admin + + + + XMPP + false + org.wso2.carbon.device.mgt.iot.controlqueue.xmpp.XmppServerClient + XMPP + http://204.232.188.215 + 9090 + admin + wso2iot123 + + + diff --git a/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.feature/src/main/resources/conf/devicemgt-config.xsd b/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.feature/src/main/resources/conf/devicemgt-config.xsd new file mode 100644 index 000000000..99b00269e --- /dev/null +++ b/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.feature/src/main/resources/conf/devicemgt-config.xsd @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.feature/src/main/resources/p2.inf b/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.feature/src/main/resources/p2.inf new file mode 100644 index 000000000..77c750196 --- /dev/null +++ b/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.feature/src/main/resources/p2.inf @@ -0,0 +1,8 @@ +instructions.configure = \ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot_${feature.version}/webapps/,target:${installFolder}/../../deployment/server/webapps/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/jaggeryapps/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot_${feature.version}/jaggeryapps/,target:${installFolder}/../../deployment/server/jaggeryapps/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../conf/iot/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot_${feature.version}/conf/devicemgt-config.xml,target:${installFolder}/../../conf/iot/devicemgt-config.xml,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot_${feature.version}/conf/devicemgt-config.xsd,target:${installFolder}/../../conf/iot/devicemgt-config.xsd,overwrite:true);\ \ No newline at end of file diff --git a/features/iot-plugins-feature/iot-base-plugin-feature/pom.xml b/features/iot-plugins-feature/iot-base-plugin-feature/pom.xml new file mode 100644 index 000000000..040202a90 --- /dev/null +++ b/features/iot-plugins-feature/iot-base-plugin-feature/pom.xml @@ -0,0 +1,40 @@ + + + + + + + org.wso2.carbon.devicemgt-plugins + iot-plugins-feature + 2.1.0-SNAPSHOT + ../pom.xml + + + 4.0.0 + iot-base-plugin-feature + 2.1.0-SNAPSHOT + pom + WSO2 Carbon - Device Management IoT Base Plugin Feature + http://wso2.org + + + org.wso2.carbon.device.mgt.iot.feature + + + diff --git a/features/iot-plugins-feature/pom.xml b/features/iot-plugins-feature/pom.xml new file mode 100644 index 000000000..c1ebe4604 --- /dev/null +++ b/features/iot-plugins-feature/pom.xml @@ -0,0 +1,40 @@ + + + + + + + org.wso2.carbon.devicemgt-plugins + carbon-device-mgt-plugins-parent + 2.1.0-SNAPSHOT + ../../pom.xml + + + 4.0.0 + iot-plugins-feature + 2.1.0-SNAPSHOT + pom + WSO2 Carbon - Device Management IoT Plugins Feature + http://wso2.org + + + iot-base-plugin-feature + + + diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/pom.xml b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/pom.xml new file mode 100644 index 000000000..364d32830 --- /dev/null +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/pom.xml @@ -0,0 +1,213 @@ + + + + + + + org.wso2.carbon.devicemgt-plugins + android-plugin-feature + 2.1.0-SNAPSHOT + ../pom.xml + + + 4.0.0 + org.wso2.carbon.device.mgt.mobile.android.feature + pom + 2.1.0-SNAPSHOT + WSO2 Carbon - Android Device Management Feature + http://wso2.org + This feature contains the core bundles required for Android Device Management + functionality + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.mobile.android + + + com.h2database.wso2 + h2-database-engine + + + + + + + maven-resources-plugin + 2.6 + + + copy-resources + generate-resources + + copy-resources + + + src/main/resources + + + resources + + build.properties + p2.inf + + + + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + unpack + package + + unpack + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.mobile.android.ui + + ${project.version} + zip + true + + ${project.build.directory}/maven-shared-archive-resources/jaggeryapps/devicemgt + + **/* + + + + + + copy-jaxrs-war + package + + copy + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.mobile.android.api + + war + true + ${project.build.directory}/maven-shared-archive-resources/webapps/ + + mdm-android-agent.war + + + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + + create-android-mobile-plugin-mgt-schema + package + + run + + + + + + + + + + + + + + + + + + + + + + + + + + + org.wso2.maven + carbon-p2-plugin + ${carbon.p2.plugin.version} + + + p2-feature-generation + package + + p2-feature-gen + + + org.wso2.carbon.device.mgt.mobile.android + ../../../../features/etc/feature.properties + + + + org.wso2.carbon.p2.category.type:server + + org.eclipse.equinox.p2.type.group:false + + + + + + org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.mobile.android:${carbon.mobile.device.mgt.version} + + + + + org.wso2.carbon.core.server:${carbon.kernel.version} + + + org.wso2.carbon.device.mgt.server:${carbon.device.mgt.version} + + + + + + + + + + diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/build.properties b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/build.properties new file mode 100644 index 000000000..33bb0980d --- /dev/null +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/build.properties @@ -0,0 +1,19 @@ +# +# Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +# +# WSO2 Inc. licenses this file to you under the Apache License, +# Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +custom = true diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/conf/mobile-config.xml b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/conf/mobile-config.xml new file mode 100644 index 000000000..39abe6e01 --- /dev/null +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/conf/mobile-config.xml @@ -0,0 +1,71 @@ + + + + + + + + + jdbc/MobileAndroidDM_DS + + + + + jdbc/MobileWindowsDM_DS + + + + + + + + appmanager + admin + /devices + 1.0.0 + http://localhost:9763/test/app + http,https + + + enrol + admin + /enroll + 1.0.0 + http://localhost:9763/mdm-android-agent/enrollment + http,https + + + license + admin + /license + 1.0.0 + http://localhost:9763/mdm-android-agent/devices/license + http,https + + + operation + admin + /operation + 1.0.0 + http://localhost:9763/mdm-android-agent/operations + http,https + + + + diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/configs/android.json b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/configs/android.json new file mode 100644 index 000000000..3601ecb51 --- /dev/null +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/configs/android.json @@ -0,0 +1,6 @@ +{ + "deviceType": { + "label": "Android", + "category" : "mobile" + } +} diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/h2.sql b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/h2.sql similarity index 100% rename from features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/h2.sql rename to features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/h2.sql diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/mssql.sql b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/mssql.sql similarity index 100% rename from features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/mssql.sql rename to features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/mssql.sql diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/mysql.sql b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/mysql.sql similarity index 100% rename from features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/mysql.sql rename to features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/mysql.sql diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/oracle.sql b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/oracle.sql similarity index 100% rename from features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/oracle.sql rename to features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/oracle.sql diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/postgresql.sql b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/postgresql.sql similarity index 100% rename from features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/postgresql.sql rename to features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/postgresql.sql diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/p2.inf b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/p2.inf new file mode 100644 index 000000000..e22961638 --- /dev/null +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/p2.inf @@ -0,0 +1,10 @@ +instructions.configure = \ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../conf/device-types/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/configs/,target:${installFolder}/../../conf/device-types/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/webapps/,target:${installFolder}/../../deployment/server/webapps/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/jaggeryapps/,target:${installFolder}/../../deployment/server/jaggeryapps/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/conf/mobile-config.xml,target:${installFolder}/../../conf/mobile-config.xml,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/dbscripts/plugins/,target:${installFolder}/../../../dbscripts/cdm/plugins/android,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../database/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/database/,target:${installFolder}/../../database/,overwrite:true);\ diff --git a/features/mobile-plugins-feature/android-plugin-feature/pom.xml b/features/mobile-plugins-feature/android-plugin-feature/pom.xml new file mode 100644 index 000000000..ec8d6fab3 --- /dev/null +++ b/features/mobile-plugins-feature/android-plugin-feature/pom.xml @@ -0,0 +1,40 @@ + + + + + + + org.wso2.carbon.devicemgt-plugins + mobile-plugins-feature + 2.1.0-SNAPSHOT + ../pom.xml + + + 4.0.0 + android-plugin-feature + 2.1.0-SNAPSHOT + pom + WSO2 Carbon - Device Management Android Plugin Feature + http://wso2.org + + + org.wso2.carbon.device.mgt.mobile.android.feature + + + diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/pom.xml b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/pom.xml similarity index 59% rename from features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/pom.xml rename to features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/pom.xml index 6e07d9f97..04a5dff15 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/pom.xml +++ b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/pom.xml @@ -1,27 +1,27 @@ + ~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + ~ + ~ WSO2 Inc. licenses this file to you under the Apache License, + ~ Version 2.0 (the "License"); you may not use this file except + ~ in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> org.wso2.carbon.devicemgt-plugins - device-mgt-feature + mobile-base-plugin-feature 2.1.0-SNAPSHOT ../pom.xml @@ -38,7 +38,7 @@ org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.mobile.impl + org.wso2.carbon.device.mgt.mobile org.wso2.carbon.devicemgt @@ -91,6 +91,55 @@ + + org.apache.maven.plugins + maven-dependency-plugin + + + unpack + package + + unpack + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.mobile.ui + + ${project.version} + zip + true + + ${project.build.directory}/maven-shared-archive-resources/jaggeryapps/devicemgt + + **/* + + + + + + copy + package + + copy + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.mobile.api + war + true + ${project.build.directory}/maven-shared-archive-resources/webapps/ + + mdm-admin.war + + + + + + org.wso2.maven carbon-p2-plugin @@ -104,7 +153,7 @@ org.wso2.carbon.device.mgt.mobile - ../../../features/etc/feature.properties + ../../../../features/etc/feature.properties org.wso2.carbon.p2.category.type:server diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/build.properties b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/build.properties similarity index 100% rename from features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/build.properties rename to features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/build.properties diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/conf/mobile-config.xml b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/conf/mobile-config.xml similarity index 100% rename from features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/conf/mobile-config.xml rename to features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/conf/mobile-config.xml diff --git a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/h2.sql b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/h2.sql new file mode 100644 index 000000000..3673fd122 --- /dev/null +++ b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/h2.sql @@ -0,0 +1,30 @@ + +-- ----------------------------------------------------- +-- Table `AD_DEVICE` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `AD_DEVICE` ( + `DEVICE_ID` VARCHAR(45) NOT NULL, + `GCM_TOKEN` VARCHAR(1000) NULL DEFAULT NULL, + `DEVICE_INFO` VARCHAR(8000) NULL DEFAULT NULL, + `IMEI` VARCHAR(45) NULL DEFAULT NULL, + `IMSI` VARCHAR(45) NULL DEFAULT NULL, + `OS_VERSION` VARCHAR(45) NULL DEFAULT NULL, + `DEVICE_MODEL` VARCHAR(45) NULL DEFAULT NULL, + `VENDOR` VARCHAR(45) NULL DEFAULT NULL, + `LATITUDE` VARCHAR(45) NULL DEFAULT NULL, + `LONGITUDE` VARCHAR(45) NULL DEFAULT NULL, + `SERIAL` VARCHAR(45) NULL DEFAULT NULL, + `MAC_ADDRESS` VARCHAR(45) NULL DEFAULT NULL, + `DEVICE_NAME` VARCHAR(100) NULL DEFAULT NULL, + PRIMARY KEY (`DEVICE_ID`)); + +-- ----------------------------------------------------- +-- Table `AD_FEATURE` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `AD_FEATURE` ( + `ID` INT NOT NULL AUTO_INCREMENT, + `CODE` VARCHAR(45) NOT NULL, + `NAME` VARCHAR(100) NULL, + `DESCRIPTION` VARCHAR(200) NULL, + PRIMARY KEY (`ID`)); + diff --git a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/mssql.sql b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/mssql.sql new file mode 100644 index 000000000..be8caf6c4 --- /dev/null +++ b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/mssql.sql @@ -0,0 +1,29 @@ +-- ----------------------------------------------------- +-- Table `AD_DEVICE` +-- ----------------------------------------------------- +CREATE TABLE AD_DEVICE ( + DEVICE_ID VARCHAR(45) NOT NULL, + GCM_TOKEN VARCHAR(1000) NULL DEFAULT NULL, + DEVICE_INFO VARCHAR(8000) NULL DEFAULT NULL, + IMEI VARCHAR(45) NULL DEFAULT NULL, + IMSI VARCHAR(45) NULL DEFAULT NULL, + OS_VERSION VARCHAR(45) NULL DEFAULT NULL, + DEVICE_MODEL VARCHAR(45) NULL DEFAULT NULL, + VENDOR VARCHAR(45) NULL DEFAULT NULL, + LATITUDE VARCHAR(45) NULL DEFAULT NULL, + LONGITUDE VARCHAR(45) NULL DEFAULT NULL, + SERIAL VARCHAR(45) NULL DEFAULT NULL, + MAC_ADDRESS VARCHAR(45) NULL DEFAULT NULL, + DEVICE_NAME VARCHAR(100) NULL DEFAULT NULL, + PRIMARY KEY (DEVICE_ID)); + +-- ----------------------------------------------------- +-- Table `AD_FEATURE` +-- ----------------------------------------------------- +CREATE TABLE AD_FEATURE ( + ID INT NOT NULL IDENTITY, + CODE VARCHAR(45) NOT NULL, + NAME VARCHAR(100) NULL, + DESCRIPTION VARCHAR(200) NULL, + PRIMARY KEY (ID) +); diff --git a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/mysql.sql b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/mysql.sql new file mode 100644 index 000000000..8e85b92c2 --- /dev/null +++ b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/mysql.sql @@ -0,0 +1,31 @@ +-- ----------------------------------------------------- +-- Table `AD_DEVICE` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `AD_DEVICE` ( + `DEVICE_ID` VARCHAR(45) NOT NULL, + `GCM_TOKEN` VARCHAR(1000) NULL DEFAULT NULL, + `DEVICE_INFO` VARCHAR(8000) NULL DEFAULT NULL, + `IMEI` VARCHAR(45) NULL DEFAULT NULL, + `IMSI` VARCHAR(45) NULL DEFAULT NULL, + `OS_VERSION` VARCHAR(45) NULL DEFAULT NULL, + `DEVICE_MODEL` VARCHAR(45) NULL DEFAULT NULL, + `VENDOR` VARCHAR(45) NULL DEFAULT NULL, + `LATITUDE` VARCHAR(45) NULL DEFAULT NULL, + `LONGITUDE` VARCHAR(45) NULL DEFAULT NULL, + `SERIAL` VARCHAR(45) NULL DEFAULT NULL, + `MAC_ADDRESS` VARCHAR(45) NULL DEFAULT NULL, + `DEVICE_NAME` VARCHAR(100) NULL DEFAULT NULL, + PRIMARY KEY (`DEVICE_ID`)) + ENGINE = InnoDB; + +-- ----------------------------------------------------- +-- Table `AD_FEATURE` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `AD_FEATURE` ( + `ID` INT NOT NULL AUTO_INCREMENT, + `CODE` VARCHAR(45) NOT NULL, + `NAME` VARCHAR(100) NULL, + `DESCRIPTION` VARCHAR(200) NULL, + PRIMARY KEY (`ID`) + ) ENGINE = InnoDB; + diff --git a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/oracle.sql b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/oracle.sql new file mode 100644 index 000000000..1331581e7 --- /dev/null +++ b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/oracle.sql @@ -0,0 +1,50 @@ +-- ----------------------------------------------------- +-- Table `AD_DEVICE` +-- ----------------------------------------------------- +CREATE TABLE AD_DEVICE ( + DEVICE_ID VARCHAR(45) NOT NULL , + DEVICE_INFO VARCHAR(4000) DEFAULT NULL, + GCM_TOKEN VARCHAR(1000) DEFAULT NULL, + IMEI VARCHAR(45) DEFAULT NULL, + IMSI VARCHAR(45) DEFAULT NULL, + OS_VERSION VARCHAR(45) DEFAULT NULL, + DEVICE_MODEL VARCHAR(45) DEFAULT NULL, + VENDOR VARCHAR(45) DEFAULT NULL, + LATITUDE VARCHAR(45) DEFAULT NULL, + LONGITUDE VARCHAR(45) DEFAULT NULL, + SERIAL VARCHAR(45) DEFAULT NULL, + MAC_ADDRESS VARCHAR(45) DEFAULT NULL, + DEVICE_NAME VARCHAR(100) DEFAULT NULL, + CONSTRAINT PK_AD_DEVICE PRIMARY KEY (DEVICE_ID) +) +/ + +-- ----------------------------------------------------- +-- Table `AD_FEATURE` +-- ----------------------------------------------------- +CREATE TABLE AD_FEATURE ( + ID INT NOT NULL, + CODE VARCHAR(45) NOT NULL, + NAME VARCHAR(100) NOT NULL, + DESCRIPTION VARCHAR(200) DEFAULT NULL, + CONSTRAINT AD_FEATURE PRIMARY KEY (ID) +) +/ + +-- ----------------------------------------------------- +-- Sequence `AD_FEATURE_ID_INC_SEQ` +-- ----------------------------------------------------- +CREATE SEQUENCE AD_FEATURE_ID_INC_SEQ START WITH 1 INCREMENT BY 1 NOCACHE +/ +-- ----------------------------------------------------- +-- Trigger `AD_FEATURE_ID_INC_TRIG` +-- ----------------------------------------------------- +CREATE OR REPLACE TRIGGER AD_FEATURE_ID_INC_TRIG +BEFORE INSERT +ON AD_FEATURE +REFERENCING NEW AS NEW +FOR EACH ROW + BEGIN + SELECT AD_FEATURE_ID_INC_SEQ.NEXTVAL INTO :NEW.ID FROM DUAL; + END; +/ \ No newline at end of file diff --git a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/postgresql.sql b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/postgresql.sql new file mode 100644 index 000000000..e4512c53f --- /dev/null +++ b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/postgresql.sql @@ -0,0 +1,29 @@ +-- ----------------------------------------------------- +-- Table AD_DEVICE +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS AD_DEVICE ( + DEVICE_ID VARCHAR(45) NOT NULL , + DEVICE_INFO TEXT NULL DEFAULT NULL, + GCM_TOKEN VARCHAR(1000) NULL DEFAULT NULL, + IMEI VARCHAR(45) NULL DEFAULT NULL, + IMSI VARCHAR(45) NULL DEFAULT NULL, + OS_VERSION VARCHAR(45) NULL DEFAULT NULL, + DEVICE_MODEL VARCHAR(45) NULL DEFAULT NULL, + VENDOR VARCHAR(45) NULL DEFAULT NULL, + LATITUDE VARCHAR(45) NULL DEFAULT NULL, + LONGITUDE VARCHAR(45) NULL DEFAULT NULL, + SERIAL VARCHAR(45) NULL DEFAULT NULL, + MAC_ADDRESS VARCHAR(45) NULL DEFAULT NULL, + DEVICE_NAME VARCHAR(100) NULL DEFAULT NULL, + PRIMARY KEY (DEVICE_ID) + ); + +-- ----------------------------------------------------- +-- Table AD_FEATURE +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS AD_FEATURE ( + ID BIGSERIAL NOT NULL PRIMARY KEY, + CODE VARCHAR(45) NOT NULL, + NAME VARCHAR(100) NULL, + DESCRIPTION VARCHAR(200) NULL +); diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/h2.sql b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/h2.sql similarity index 100% rename from features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/h2.sql rename to features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/h2.sql diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/mssql.sql b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/mssql.sql similarity index 100% rename from features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/mssql.sql rename to features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/mssql.sql diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/mysql.sql b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/mysql.sql similarity index 100% rename from features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/mysql.sql rename to features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/mysql.sql diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/oracle.sql b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/oracle.sql similarity index 100% rename from features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/oracle.sql rename to features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/oracle.sql diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/postgresql.sql b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/postgresql.sql similarity index 100% rename from features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/postgresql.sql rename to features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/postgresql.sql diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/h2.sql b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/h2.sql similarity index 100% rename from features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/h2.sql rename to features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/h2.sql diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/mssql.sql b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/mssql.sql similarity index 100% rename from features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/mssql.sql rename to features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/mssql.sql diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/mysql.sql b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/mysql.sql similarity index 100% rename from features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/mysql.sql rename to features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/mysql.sql diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/oracle.sql b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/oracle.sql similarity index 100% rename from features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/oracle.sql rename to features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/oracle.sql diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/postgresql.sql b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/postgresql.sql similarity index 100% rename from features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/postgresql.sql rename to features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/postgresql.sql diff --git a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/p2.inf b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/p2.inf new file mode 100644 index 000000000..3beddd74a --- /dev/null +++ b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/p2.inf @@ -0,0 +1,7 @@ +instructions.configure = \ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile_${feature.version}/webapps/,target:${installFolder}/../../deployment/server/webapps/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile_${feature.version}/conf/mobile-config.xml,target:${installFolder}/../../conf/mobile-config.xml,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile_${feature.version}/dbscripts/plugins/,target:${installFolder}/../../../dbscripts/cdm/plugins,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/jaggeryapps/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile_${feature.version}/jaggeryapps/,target:${installFolder}/../../deployment/server/jaggeryapps/,overwrite:true);\ diff --git a/features/mobile-plugins-feature/mobile-base-plugin-feature/pom.xml b/features/mobile-plugins-feature/mobile-base-plugin-feature/pom.xml new file mode 100644 index 000000000..d259b41c9 --- /dev/null +++ b/features/mobile-plugins-feature/mobile-base-plugin-feature/pom.xml @@ -0,0 +1,40 @@ + + + + + + + org.wso2.carbon.devicemgt-plugins + mobile-plugins-feature + 2.1.0-SNAPSHOT + ../pom.xml + + + 4.0.0 + mobile-base-plugin-feature + 2.1.0-SNAPSHOT + pom + WSO2 Carbon - Device Management EMM Base Plugin Feature + http://wso2.org + + + org.wso2.carbon.device.mgt.mobile.feature + + + diff --git a/features/mobile-plugins-feature/pom.xml b/features/mobile-plugins-feature/pom.xml new file mode 100644 index 000000000..4a8b51c32 --- /dev/null +++ b/features/mobile-plugins-feature/pom.xml @@ -0,0 +1,42 @@ + + + + + + + org.wso2.carbon.devicemgt-plugins + carbon-device-mgt-plugins-parent + 2.1.0-SNAPSHOT + ../../pom.xml + + + 4.0.0 + mobile-plugins-feature + 2.1.0-SNAPSHOT + pom + WSO2 Carbon - Device Management EMM Plugins Feature + http://wso2.org + + + mobile-base-plugin-feature + android-plugin-feature + windows-plugin-feature + + + diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/pom.xml b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/pom.xml new file mode 100644 index 000000000..27feffe58 --- /dev/null +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/pom.xml @@ -0,0 +1,213 @@ + + + + + + + org.wso2.carbon.devicemgt-plugins + windows-plugin-feature + 2.1.0-SNAPSHOT + ../pom.xml + + + 4.0.0 + org.wso2.carbon.device.mgt.mobile.windows.feature + pom + 2.1.0-SNAPSHOT + WSO2 Carbon - Windows Device Management Feature + http://wso2.org + This feature contains the core bundles required for Windows Device Management + functionality + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.mobile.windows + + + com.h2database.wso2 + h2-database-engine + + + + + + + maven-resources-plugin + 2.6 + + + copy-resources + generate-resources + + copy-resources + + + src/main/resources + + + resources + + build.properties + p2.inf + + + + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + unpack + package + + unpack + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.mobile.windows.ui + + ${project.version} + zip + true + + ${project.build.directory}/maven-shared-archive-resources/jaggeryapps/devicemgt + + **/* + + + + + + copy-jaxrs-war + package + + copy + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.mobile.windows.api + + war + true + ${project.build.directory}/maven-shared-archive-resources/webapps/ + + mdm-windows-agent.war + + + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + + create-windows-mobile-plugin-mgt-schema + package + + run + + + + + + + + + + + + + + + + + + + + + + + + + + + org.wso2.maven + carbon-p2-plugin + ${carbon.p2.plugin.version} + + + p2-feature-generation + package + + p2-feature-gen + + + org.wso2.carbon.device.mgt.mobile.windows + ../../../../features/etc/feature.properties + + + + org.wso2.carbon.p2.category.type:server + + org.eclipse.equinox.p2.type.group:false + + + + + + org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.mobile.windows:${carbon.mobile.device.mgt.version} + + + + + org.wso2.carbon.core.server:${carbon.kernel.version} + + + org.wso2.carbon.device.mgt.server:${carbon.device.mgt.version} + + + + + + + + + + diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/build.properties b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/build.properties new file mode 100644 index 000000000..33bb0980d --- /dev/null +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/build.properties @@ -0,0 +1,19 @@ +# +# Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +# +# WSO2 Inc. licenses this file to you under the Apache License, +# Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +custom = true diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/configs/windows.json b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/configs/windows.json new file mode 100644 index 000000000..33823e665 --- /dev/null +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/configs/windows.json @@ -0,0 +1,6 @@ +{ + "deviceType": { + "label": "Windows", + "category" : "mobile" + } +} diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/dbscripts/plugins/h2.sql b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/dbscripts/plugins/h2.sql new file mode 100644 index 000000000..f1749a8a8 --- /dev/null +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/dbscripts/plugins/h2.sql @@ -0,0 +1,30 @@ +-- ----------------------------------------------------- +-- Table `WIN_DEVICE` +-- ----------------------------------------------------- + CREATE TABLE IF NOT EXISTS `WIN_DEVICE` ( + `DEVICE_ID` VARCHAR(45) NOT NULL, + `CHANNEL_URI` VARCHAR(100) NULL DEFAULT NULL, + `DEVICE_INFO` TEXT NULL DEFAULT NULL, + `IMEI` VARCHAR(45) NULL DEFAULT NULL, + `IMSI` VARCHAR(45) NULL DEFAULT NULL, + `OS_VERSION` VARCHAR(45) NULL DEFAULT NULL, + `DEVICE_MODEL` VARCHAR(45) NULL DEFAULT NULL, + `VENDOR` VARCHAR(45) NULL DEFAULT NULL, + `LATITUDE` VARCHAR(45) NULL DEFAULT NULL, + `LONGITUDE` VARCHAR(45) NULL DEFAULT NULL, + `SERIAL` VARCHAR(45) NULL DEFAULT NULL, + `MAC_ADDRESS` VARCHAR(45) NULL DEFAULT NULL, + `DEVICE_NAME` VARCHAR(100) NULL DEFAULT NULL, + PRIMARY KEY (`DEVICE_ID`) +); + +-- ----------------------------------------------------- +-- Table `WIN_FEATURE` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `WIN_FEATURE` ( + `ID` INT NOT NULL AUTO_INCREMENT, + `CODE` VARCHAR(45) NOT NULL, + `NAME` VARCHAR(100) NULL, + `DESCRIPTION` VARCHAR(200) NULL, + PRIMARY KEY (`ID`) +); diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/dbscripts/plugins/mssql.sql b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/dbscripts/plugins/mssql.sql new file mode 100644 index 000000000..593515185 --- /dev/null +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/dbscripts/plugins/mssql.sql @@ -0,0 +1,30 @@ +-- ----------------------------------------------------- +-- Table `WINDOWS_FEATURE` +-- ----------------------------------------------------- +CREATE TABLE WIN_FEATURE ( + ID INT NOT NULL IDENTITY, + CODE VARCHAR(45) NOT NULL, + NAME VARCHAR(100) NULL, + DESCRIPTION VARCHAR(200) NULL, + PRIMARY KEY (ID) +); + +-- ----------------------------------------------------- +-- Table `WINDOWS_DEVICE` +-- ----------------------------------------------------- + CREATE TABLE WIN_DEVICE ( + DEVICE_ID VARCHAR(45) NOT NULL, + CHANNEL_URI VARCHAR(100) NULL DEFAULT NULL, + DEVICE_INFO TEXT NULL DEFAULT NULL, + IMEI VARCHAR(45) NULL DEFAULT NULL, + IMSI VARCHAR(45) NULL DEFAULT NULL, + OS_VERSION VARCHAR(45) NULL DEFAULT NULL, + DEVICE_MODEL VARCHAR(45) NULL DEFAULT NULL, + VENDOR VARCHAR(45) NULL DEFAULT NULL, + LATITUDE VARCHAR(45) NULL DEFAULT NULL, + LONGITUDE VARCHAR(45) NULL DEFAULT NULL, + SERIAL VARCHAR(45) NULL DEFAULT NULL, + MAC_ADDRESS VARCHAR(45) NULL DEFAULT NULL, + DEVICE_NAME VARCHAR(100) NULL DEFAULT NULL, + PRIMARY KEY (DEVICE_ID) +); diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/dbscripts/plugins/mysql.sql b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/dbscripts/plugins/mysql.sql new file mode 100644 index 000000000..2ebcc80f7 --- /dev/null +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/dbscripts/plugins/mysql.sql @@ -0,0 +1,34 @@ +-- ----------------------------------------------------- +-- Table `WIN_DEVICE` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `WIN_DEVICE` ( + `DEVICE_ID` VARCHAR(45) NOT NULL, + `CHANNEL_URI` VARCHAR(100) NULL DEFAULT NULL, + `DEVICE_INFO` TEXT NULL DEFAULT NULL, + `IMEI` VARCHAR(45) NULL DEFAULT NULL, + `IMSI` VARCHAR(45) NULL DEFAULT NULL, + `OS_VERSION` VARCHAR(45) NULL DEFAULT NULL, + `DEVICE_MODEL` VARCHAR(45) NULL DEFAULT NULL, + `VENDOR` VARCHAR(45) NULL DEFAULT NULL, + `LATITUDE` VARCHAR(45) NULL DEFAULT NULL, + `LONGITUDE` VARCHAR(45) NULL DEFAULT NULL, + `SERIAL` VARCHAR(45) NULL DEFAULT NULL, + `MAC_ADDRESS` VARCHAR(45) NULL DEFAULT NULL, + `DEVICE_NAME` VARCHAR(100) NULL DEFAULT NULL, + PRIMARY KEY (`DEVICE_ID`)) +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `WIN_FEATURE` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `WIN_FEATURE` ( + `ID` INT NOT NULL AUTO_INCREMENT, + `CODE` VARCHAR(45) NULL, + `NAME` VARCHAR(100) NULL, + `DESCRIPTION` VARCHAR(200) NULL, + PRIMARY KEY (`ID`)) +ENGINE = InnoDB; + + + diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/dbscripts/plugins/oracle.sql b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/dbscripts/plugins/oracle.sql new file mode 100644 index 000000000..a7a389264 --- /dev/null +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/dbscripts/plugins/oracle.sql @@ -0,0 +1,51 @@ +-- ----------------------------------------------------- +-- Table `WIN_DEVICE` +-- ----------------------------------------------------- +CREATE TABLE WIN_DEVICE ( + DEVICE_ID VARCHAR(45) NOT NULL, + CHANNEL_URI VARCHAR(100) DEFAULT NULL, + DEVICE_INFO VARCHAR2(4000) DEFAULT NULL, + IMEI VARCHAR(45) DEFAULT NULL, + IMSI VARCHAR(45) DEFAULT NULL, + OS_VERSION VARCHAR(45) DEFAULT NULL, + DEVICE_MODEL VARCHAR(45) DEFAULT NULL, + VENDOR VARCHAR(45) DEFAULT NULL, + LATITUDE VARCHAR(45) DEFAULT NULL, + LONGITUDE VARCHAR(45) DEFAULT NULL, + SERIAL VARCHAR(45) DEFAULT NULL, + MAC_ADDRESS VARCHAR(45) DEFAULT NULL, + DEVICE_NAME VARCHAR(100) DEFAULT NULL, + CONSTRAINT PK_WIN_DEVICE PRIMARY KEY (DEVICE_ID) +) +/ + +-- ----------------------------------------------------- +-- Table `WIN_FEATURE` +-- ----------------------------------------------------- +CREATE TABLE WIN_FEATURE ( + ID INT NOT NULL, + CODE VARCHAR(45) NOT NULL, + NAME VARCHAR(100) NOT NULL, + DESCRIPTION VARCHAR(200) NULL, + PRIMARY KEY (ID) +) +/ + +-- ----------------------------------------------------- +-- Sequence `WIN_FEATURE_ID_INC_SEQ` +-- ----------------------------------------------------- +CREATE SEQUENCE WIN_FEATURE_ID_INC_SEQ START WITH 1 INCREMENT BY 1 NOCACHE +/ + +-- ----------------------------------------------------- +-- Trigger `WIN_FEATURE_ID_INC_TRIG` +-- ----------------------------------------------------- +CREATE OR REPLACE TRIGGER WIN_FEATURE_ID_INC_TRIG +BEFORE INSERT +ON WIN_FEATURE +REFERENCING NEW AS NEW +FOR EACH ROW + BEGIN + SELECT WIN_FEATURE_ID_INC_SEQ.NEXTVAL INTO :NEW.ID FROM DUAL; + END; +/ \ No newline at end of file diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/dbscripts/plugins/postgresql.sql b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/dbscripts/plugins/postgresql.sql new file mode 100644 index 000000000..d7444757d --- /dev/null +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/dbscripts/plugins/postgresql.sql @@ -0,0 +1,31 @@ +-- ----------------------------------------------------- +-- Table WIN_DEVICE +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS WIN_DEVICE ( + DEVICE_ID VARCHAR(45) NOT NULL, + CHANNEL_URI VARCHAR(100) NULL DEFAULT NULL, + DEVICE_INFO TEXT NULL DEFAULT NULL, + IMEI VARCHAR(45) NULL DEFAULT NULL, + IMSI VARCHAR(45) NULL DEFAULT NULL, + OS_VERSION VARCHAR(45) NULL DEFAULT NULL, + DEVICE_MODEL VARCHAR(45) NULL DEFAULT NULL, + VENDOR VARCHAR(45) NULL DEFAULT NULL, + LATITUDE VARCHAR(45) NULL DEFAULT NULL, + LONGITUDE VARCHAR(45) NULL DEFAULT NULL, + SERIAL VARCHAR(45) NULL DEFAULT NULL, + MAC_ADDRESS VARCHAR(45) NULL DEFAULT NULL, + DEVICE_NAME VARCHAR(100) NULL DEFAULT NULL, + PRIMARY KEY (DEVICE_ID) + ); + +-- ----------------------------------------------------- +-- Table WIN_FEATURE +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS WIN_FEATURE ( + ID SERIAL NOT NULL, + CODE VARCHAR(45) NULL, + NAME VARCHAR(100) NULL, + DESCRIPTION VARCHAR(200) NULL, + PRIMARY KEY (ID) + ); + diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/p2.inf b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/p2.inf new file mode 100644 index 000000000..09f27767d --- /dev/null +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/p2.inf @@ -0,0 +1,9 @@ +instructions.configure = \ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../conf/device-types/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.windows_${feature.version}/configs/,target:${installFolder}/../../conf/device-types/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.windows_${feature.version}/jaggeryapps/,target:${installFolder}/../../deployment/server/jaggeryapps/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.windows_${feature.version}/webapps/,target:${installFolder}/../../deployment/server/webapps/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.windows_${feature.version}/dbscripts/plugins/,target:${installFolder}/../../../dbscripts/cdm/plugins/windows,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../database/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.windows_${feature.version}/database/,target:${installFolder}/../../database/,overwrite:true);\ diff --git a/features/mobile-plugins-feature/windows-plugin-feature/pom.xml b/features/mobile-plugins-feature/windows-plugin-feature/pom.xml new file mode 100644 index 000000000..f00b2874a --- /dev/null +++ b/features/mobile-plugins-feature/windows-plugin-feature/pom.xml @@ -0,0 +1,40 @@ + + + + + + + org.wso2.carbon.devicemgt-plugins + mobile-plugins-feature + 2.1.0-SNAPSHOT + ../pom.xml + + + 4.0.0 + windows-plugin-feature + 2.1.0-SNAPSHOT + pom + WSO2 Carbon - Device Management Windows Plugin Feature + http://wso2.org + + + org.wso2.carbon.device.mgt.mobile.windows.feature + + + diff --git a/pom.xml b/pom.xml index 0848df962..bcaf766c7 100644 --- a/pom.xml +++ b/pom.xml @@ -1,22 +1,21 @@ - + ~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + ~ + ~ WSO2 Inc. licenses this file to you under the Apache License, + ~ Version 2.0 (the "License"); you may not use this file except + ~ in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> @@ -37,10 +36,10 @@ - components/device-mgt - - - features/device-mgt + components/mobile-plugins + components/iot-plugins + features/mobile-plugins-feature + features/iot-plugins-feature @@ -499,6 +498,11 @@ org.wso2.carbon.device.mgt.mobile.impl ${carbon.mobile.device.mgt.version} + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.mobile.api + ${carbon.mobile.device.mgt.version} + org.wso2.carbon.devicemgt-plugins org.wso2.carbon.device.mgt.mobile.url.printer @@ -509,11 +513,30 @@ org.wso2.carbon.device.mgt.mobile ${carbon.mobile.device.mgt.version} + + org.wso2.carbon.devicemgt-plugins org.wso2.carbon.device.mgt.mobile.android ${carbon.mobile.device.mgt.version} + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.mobile.android.api + ${carbon.mobile.device.mgt.version} + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.mobile.windows + ${carbon.mobile.device.mgt.version} + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.mobile.windows.api + ${carbon.mobile.device.mgt.version} + @@ -1031,6 +1054,10 @@ + + 1.7 + 1.7 + 4.4.3 [4.4.0, 4.5.0)