diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/DeviceTypeDeployer.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/DeviceTypeDeployer.java index 2ace9f49703..5bfe3e5f9c9 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/DeviceTypeDeployer.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/DeviceTypeDeployer.java @@ -31,7 +31,7 @@ import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.DeviceManagementConfiguration; import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.exception.DeviceTypeConfigurationException; -import org.wso2.carbon.device.mgt.extensions.push.notification.provider.internal.DeviceTypeManagementDataHolder; +import org.wso2.carbon.device.mgt.extensions.device.type.deployer.internal.DeviceTypeManagementDataHolder; import org.wso2.carbon.device.mgt.extensions.device.type.deployer.template.DeviceTypeConfigIdentifier; import org.wso2.carbon.device.mgt.extensions.device.type.deployer.template.DeviceTypeManagerService; import org.wso2.carbon.device.mgt.extensions.device.type.deployer.util.DeviceTypeConfigUtil; @@ -125,7 +125,7 @@ public class DeviceTypeDeployer extends AbstractDeployer { private void unregisterDeviceType(String filePath) { if (log.isDebugEnabled()) { - log.debug("De-activating Virtual Firealarm Device Management Service Component"); + log.debug("De-activating Device Management Service."); } try { if (this.deviceTypeServiceRegistrations.get(filePath) != null) { diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Attribute.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Attribute.java new file mode 100644 index 00000000000..d57ea91feea --- /dev/null +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Attribute.java @@ -0,0 +1,59 @@ + +package org.wso2.carbon.device.mgt.extensions.device.type.deployer.config; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlValue; + + +/** + *

Java class for Attribute complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="Attribute">
+ *   <simpleContent>
+ *     <extension base="<http://www.w3.org/2001/XMLSchema>string">
+ *       <attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     </extension>
+ *   </simpleContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +public class Attribute { + + @XmlValue + protected String value; + + + /** + * Gets the value of the value property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getValue() { + return value; + } + + /** + * Sets the value of the value property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setValue(String value) { + this.value = value; + } + +} diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Attributes.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Attributes.java new file mode 100644 index 00000000000..561f9c1d3d9 --- /dev/null +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Attributes.java @@ -0,0 +1,69 @@ + +package org.wso2.carbon.device.mgt.extensions.device.type.deployer.config; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for Attributes complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="Attributes">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="Attribute" type="{}Attribute" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "Attributes", propOrder = { + "attribute" +}) +public class Attributes { + + @XmlElement(name = "Attribute") + protected List attribute; + + /** + * Gets the value of the attribute property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the attribute property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getAttribute().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link Attribute } + * + * + */ + public List getAttribute() { + if (attribute == null) { + attribute = new ArrayList(); + } + return this.attribute; + } + +} diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/DataSourceConfig.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/DataSourceConfig.java deleted file mode 100644 index d51835aef31..00000000000 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/DataSourceConfig.java +++ /dev/null @@ -1,40 +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.extensions.device.type.deployer.config; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * Class for holding device type configuration and parsing with JAXB. - */ -@XmlRootElement(name = "DataSourceConfiguration") -public class DataSourceConfig { - - private JNDILookupDefinition jndiLookupDefinition; - - @XmlElement(name = "JndiLookupDefinition", required = true) - public JNDILookupDefinition getJndiLookupDefinition() { - return jndiLookupDefinition; - } - - public void setJndiLookupDefinition(JNDILookupDefinition jndiLookupDefinition) { - this.jndiLookupDefinition = jndiLookupDefinition; - } - -} diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/DataSourceConfiguration.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/DataSourceConfiguration.java new file mode 100644 index 00000000000..62d8750a70a --- /dev/null +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/DataSourceConfiguration.java @@ -0,0 +1,62 @@ + +package org.wso2.carbon.device.mgt.extensions.device.type.deployer.config; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for DataSourceConfiguration complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="DataSourceConfiguration">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="JndiLookupDefinition" type="{}JndiLookupDefinition"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "DataSourceConfiguration", propOrder = { + "jndiLookupDefinition" +}) +public class DataSourceConfiguration { + + @XmlElement(name = "JndiLookupDefinition", required = true) + protected JndiLookupDefinition jndiLookupDefinition; + + /** + * Gets the value of the jndiLookupDefinition property. + * + * @return + * possible object is + * {@link JndiLookupDefinition } + * + */ + public JndiLookupDefinition getJndiLookupDefinition() { + return jndiLookupDefinition; + } + + /** + * Sets the value of the jndiLookupDefinition property. + * + * @param value + * allowed object is + * {@link JndiLookupDefinition } + * + */ + public void setJndiLookupDefinition(JndiLookupDefinition value) { + this.jndiLookupDefinition = value; + } + +} diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/DeviceDefinition.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/DeviceDefinition.java new file mode 100644 index 00000000000..f66921f3296 --- /dev/null +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/DeviceDefinition.java @@ -0,0 +1,174 @@ + +package org.wso2.carbon.device.mgt.extensions.device.type.deployer.config; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for DeviceDefinition complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="DeviceDefinition">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="TableName" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="PrimaryKey" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="Attributes" type="{}Attributes"/>
+ *         <element name="License" type="{}License"/>
+ *         <element name="Features" type="{}Features"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "DeviceDefinition", propOrder = { + "tableName", + "primaryKey", + "attributes", + "license", + "features" +}) +public class DeviceDefinition { + + @XmlElement(name = "TableName", required = true) + protected String tableName; + @XmlElement(name = "PrimaryKey", required = true) + protected String primaryKey; + @XmlElement(name = "Attributes", required = true) + protected Attributes attributes; + @XmlElement(name = "License", required = true) + protected License license; + @XmlElement(name = "Features", required = true) + protected Features features; + + /** + * Gets the value of the tableName property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getTableName() { + return tableName; + } + + /** + * Sets the value of the tableName property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setTableName(String value) { + this.tableName = value; + } + + /** + * Gets the value of the primaryKey property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getPrimaryKey() { + return primaryKey; + } + + /** + * Sets the value of the primaryKey property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setPrimaryKey(String value) { + this.primaryKey = value; + } + + /** + * Gets the value of the attributes property. + * + * @return + * possible object is + * {@link Attributes } + * + */ + public Attributes getAttributes() { + return attributes; + } + + /** + * Sets the value of the attributes property. + * + * @param value + * allowed object is + * {@link Attributes } + * + */ + public void setAttributes(Attributes value) { + this.attributes = value; + } + + /** + * Gets the value of the license property. + * + * @return + * possible object is + * {@link License } + * + */ + public License getLicense() { + return license; + } + + /** + * Sets the value of the license property. + * + * @param value + * allowed object is + * {@link License } + * + */ + public void setLicense(License value) { + this.license = value; + } + + /** + * Gets the value of the features property. + * + * @return + * possible object is + * {@link Features } + * + */ + public Features getFeatures() { + return features; + } + + /** + * Sets the value of the features property. + * + * @param value + * allowed object is + * {@link Features } + * + */ + public void setFeatures(Features value) { + this.features = value; + } + +} diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/DeviceManagementConfigRepository.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/DeviceManagementConfigRepository.java deleted file mode 100644 index faafcfb02ee..00000000000 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/DeviceManagementConfigRepository.java +++ /dev/null @@ -1,50 +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.extensions.device.type.deployer.config; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * Class for holding management repository data. - */ -@XmlRootElement(name = "ManagementRepository") -public class DeviceManagementConfigRepository { - - private DataSourceConfig dataSourceConfig; - private ProvisioningConfig provisioningConfig; - - @XmlElement(name = "DataSourceConfiguration", required = true) - public DataSourceConfig getDataSourceConfig() { - return dataSourceConfig; - } - - public void setDataSourceConfig(DataSourceConfig dataSourceConfig) { - this.dataSourceConfig = dataSourceConfig; - } - - @XmlElement(name = "ProvisioningConfig", required = true) - public ProvisioningConfig getProvisioningConfig() { - return provisioningConfig; - } - - public void setProvisioningConfig( - ProvisioningConfig provisioningConfig) { - this.provisioningConfig = provisioningConfig; - } -} diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/DeviceManagementConfiguration.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/DeviceManagementConfiguration.java index 6f43af0ee5d..91bced5368e 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/DeviceManagementConfiguration.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/DeviceManagementConfiguration.java @@ -1,65 +1,120 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.wso2.carbon.device.mgt.extensions.device.type.deployer.config; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +package org.wso2.carbon.device.mgt.extensions.device.type.deployer.config; +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 javax.xml.bind.annotation.XmlType; + +/** + *

Java class for DeviceManagementConfiguration complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="DeviceManagementConfiguration">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="Device" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="ManagementRepository" type="{}ManagementRepository"/>
+ *         <element name="PushNotificationConfiguration" type="{}PushNotificationConfiguration"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +//@XmlAccessorType(XmlAccessType.FIELD) +//@XmlType(name = "DeviceManagementConfiguration", propOrder = { +// "deviceType", +// "managementRepository", +// "pushNotificationConfiguration" +//}) @XmlRootElement(name = "DeviceManagementConfiguration") public class DeviceManagementConfiguration { - private DeviceManagementConfigRepository deviceManagementConfigRepository; - private PushNotificationConfig pushNotificationConfig; - private String deviceType; - - private static final Log log = LogFactory.getLog(DeviceManagementConfiguration.class); - - private DeviceManagementConfiguration() { - } + @XmlElement(name = "DeviceType", required = true) + protected String deviceType; + @XmlElement(name = "ManagementRepository", required = true) + protected ManagementRepository managementRepository; + @XmlElement(name = "PushNotificationConfiguration", required = true) + protected PushNotificationConfiguration pushNotificationConfiguration; - @XmlElement(name = "DeviceType", required = false) + /** + * Gets the value of the device property. + * + * @return + * possible object is + * {@link String } + * + */ public String getDeviceType() { return deviceType; } - public void setDeviceType(String deviceType) { - this.deviceType = deviceType; + /** + * Sets the value of the device property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setDeviceType(String value) { + this.deviceType = value; } - @XmlElement(name = "ManagementRepository", required = true) - public DeviceManagementConfigRepository getDeviceManagementConfigRepository() { - return deviceManagementConfigRepository; + /** + * Gets the value of the managementRepository property. + * + * @return + * possible object is + * {@link ManagementRepository } + * + */ + public ManagementRepository getManagementRepository() { + return managementRepository; } - public void setDeviceManagementConfigRepository(DeviceManagementConfigRepository deviceManagementConfigRepository) { - this.deviceManagementConfigRepository = deviceManagementConfigRepository; + /** + * Sets the value of the managementRepository property. + * + * @param value + * allowed object is + * {@link ManagementRepository } + * + */ + public void setManagementRepository(ManagementRepository value) { + this.managementRepository = value; } - @XmlElement(name = "PushNotificationConfiguration", required = false) - public PushNotificationConfig getPushNotificationConfig() { - return pushNotificationConfig; + /** + * Gets the value of the pushNotificationConfiguration property. + * + * @return + * possible object is + * {@link PushNotificationConfiguration } + * + */ + public PushNotificationConfiguration getPushNotificationConfiguration() { + return pushNotificationConfiguration; } - public void setPushNotificationConfig(PushNotificationConfig pushNotificationConfig) { - this.pushNotificationConfig = pushNotificationConfig; + /** + * Sets the value of the pushNotificationConfiguration property. + * + * @param value + * allowed object is + * {@link PushNotificationConfiguration } + * + */ + public void setPushNotificationConfiguration(PushNotificationConfiguration value) { + this.pushNotificationConfiguration = value; } + } diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Feature.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Feature.java new file mode 100644 index 00000000000..4af79525485 --- /dev/null +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Feature.java @@ -0,0 +1,118 @@ + +package org.wso2.carbon.device.mgt.extensions.device.type.deployer.config; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for Feature complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="Feature">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="Code" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="Name" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="Description" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "Feature", propOrder = { + "code", + "name", + "description" +}) +public class Feature { + + @XmlElement(name = "Code", required = true) + protected String code; + @XmlElement(name = "Name", required = true) + protected String name; + @XmlElement(name = "Description", required = true) + protected String description; + + /** + * Gets the value of the code property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getCode() { + return code; + } + + /** + * Sets the value of the code property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setCode(String value) { + this.code = value; + } + + /** + * Gets the value of the name property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getName() { + return name; + } + + /** + * Sets the value of the name property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setName(String value) { + this.name = value; + } + + /** + * Gets the value of the description property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getDescription() { + return description; + } + + /** + * Sets the value of the description property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setDescription(String value) { + this.description = value; + } + +} diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Features.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Features.java new file mode 100644 index 00000000000..e105609347c --- /dev/null +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Features.java @@ -0,0 +1,97 @@ + +package org.wso2.carbon.device.mgt.extensions.device.type.deployer.config; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for Features complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="Features">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="Feature" type="{}Feature" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *       <attribute name="generate" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "Features", propOrder = { + "feature" +}) +public class Features { + + @XmlElement(name = "Feature") + protected List feature; + @XmlAttribute(name = "generate") + protected boolean generate; + + /** + * Gets the value of the feature property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the feature property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getFeature().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link Feature } + * + * + */ + public List getFeature() { + if (feature == null) { + feature = new ArrayList(); + } + return this.feature; + } + + /** + * Gets the value of the generate property. + * + * @return + * possible object is + * {@link String } + * + */ + public boolean isGenerate() { + return generate; + } + + /** + * Sets the value of the generate property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setGenerate(boolean value) { + this.generate = value; + } + +} diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/JNDILookupDefinition.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/JNDILookupDefinition.java deleted file mode 100644 index 19e5ff51c4d..00000000000 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/JNDILookupDefinition.java +++ /dev/null @@ -1,83 +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.extensions.device.type.deployer.config; - -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlValue; -import java.util.List; - -/** - * Class for hold JndiLookupDefinition parsing with JAXB. - */ -@XmlRootElement(name = "JndiLookupDefinition") -public class JNDILookupDefinition { - - private String jndiName; - private List jndiProperties; - - @XmlElement(name = "Name", required = false) - public String getJndiName() { - return jndiName; - } - - public void setJndiName(String jndiName) { - this.jndiName = jndiName; - } - - @XmlElementWrapper(name = "Environment", required = 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-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/JndiLookupDefinition.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/JndiLookupDefinition.java new file mode 100644 index 00000000000..dee938de0a1 --- /dev/null +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/JndiLookupDefinition.java @@ -0,0 +1,62 @@ + +package org.wso2.carbon.device.mgt.extensions.device.type.deployer.config; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for JndiLookupDefinition complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="JndiLookupDefinition">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="Name" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "JndiLookupDefinition", propOrder = { + "name" +}) +public class JndiLookupDefinition { + + @XmlElement(name = "Name", required = true) + protected String name; + + /** + * Gets the value of the name property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getName() { + return name; + } + + /** + * Sets the value of the name property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setName(String value) { + this.name = value; + } + +} diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/License.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/License.java new file mode 100644 index 00000000000..db88c3a6566 --- /dev/null +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/License.java @@ -0,0 +1,118 @@ + +package org.wso2.carbon.device.mgt.extensions.device.type.deployer.config; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for License complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="License">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="Language" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="Version" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="Text" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "License", propOrder = { + "language", + "version", + "text" +}) +public class License { + + @XmlElement(name = "Language", required = true) + protected String language; + @XmlElement(name = "Version", required = true) + protected String version; + @XmlElement(name = "Text", required = true) + protected String text; + + /** + * Gets the value of the language property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getLanguage() { + return language; + } + + /** + * Sets the value of the language property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setLanguage(String value) { + this.language = value; + } + + /** + * Gets the value of the version property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVersion() { + return version; + } + + /** + * Sets the value of the version property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVersion(String value) { + this.version = value; + } + + /** + * Gets the value of the text property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getText() { + return text; + } + + /** + * Sets the value of the text property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setText(String value) { + this.text = value; + } + +} diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/ManagementRepository.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/ManagementRepository.java new file mode 100644 index 00000000000..da2bdfede83 --- /dev/null +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/ManagementRepository.java @@ -0,0 +1,118 @@ + +package org.wso2.carbon.device.mgt.extensions.device.type.deployer.config; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for ManagementRepository complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="ManagementRepository">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="DataSourceConfiguration" type="{}DataSourceConfiguration"/>
+ *         <element name="DeviceDefinition" type="{}DeviceDefinition"/>
+ *         <element name="ProvisioningConfig" type="{}ProvisioningConfig"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "ManagementRepository", propOrder = { + "dataSourceConfiguration", + "deviceDefinition", + "provisioningConfig" +}) +public class ManagementRepository { + + @XmlElement(name = "DataSourceConfiguration", required = true) + protected DataSourceConfiguration dataSourceConfiguration; + @XmlElement(name = "DeviceDefinition", required = true) + protected DeviceDefinition deviceDefinition; + @XmlElement(name = "ProvisioningConfig", required = true) + protected ProvisioningConfig provisioningConfig; + + /** + * Gets the value of the dataSourceConfiguration property. + * + * @return + * possible object is + * {@link DataSourceConfiguration } + * + */ + public DataSourceConfiguration getDataSourceConfiguration() { + return dataSourceConfiguration; + } + + /** + * Sets the value of the dataSourceConfiguration property. + * + * @param value + * allowed object is + * {@link DataSourceConfiguration } + * + */ + public void setDataSourceConfiguration(DataSourceConfiguration value) { + this.dataSourceConfiguration = value; + } + + /** + * Gets the value of the deviceDefinition property. + * + * @return + * possible object is + * {@link DeviceDefinition } + * + */ + public DeviceDefinition getDeviceDefinition() { + return deviceDefinition; + } + + /** + * Sets the value of the deviceDefinition property. + * + * @param value + * allowed object is + * {@link DeviceDefinition } + * + */ + public void setDeviceDefinition(DeviceDefinition value) { + this.deviceDefinition = value; + } + + /** + * Gets the value of the provisioningConfig property. + * + * @return + * possible object is + * {@link ProvisioningConfig } + * + */ + public ProvisioningConfig getProvisioningConfig() { + return provisioningConfig; + } + + /** + * Sets the value of the provisioningConfig property. + * + * @param value + * allowed object is + * {@link ProvisioningConfig } + * + */ + public void setProvisioningConfig(ProvisioningConfig value) { + this.provisioningConfig = value; + } + +} diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Properties.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Properties.java new file mode 100644 index 00000000000..621f19b48c5 --- /dev/null +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Properties.java @@ -0,0 +1,69 @@ + +package org.wso2.carbon.device.mgt.extensions.device.type.deployer.config; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for Properties complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="Properties">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="Property" type="{}Property" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "Properties", propOrder = { + "property" +}) +public class Properties { + + @XmlElement(name = "Property") + protected List property; + + /** + * Gets the value of the property property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the property property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getProperty().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link Property } + * + * + */ + public List getProperty() { + if (property == null) { + property = new ArrayList(); + } + return this.property; + } + +} diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Property.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Property.java new file mode 100644 index 00000000000..daada0788a5 --- /dev/null +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Property.java @@ -0,0 +1,87 @@ + +package org.wso2.carbon.device.mgt.extensions.device.type.deployer.config; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlValue; + + +/** + *

Java class for Property complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="Property">
+ *   <simpleContent>
+ *     <extension base="<http://www.w3.org/2001/XMLSchema>string">
+ *       <attribute name="Name" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     </extension>
+ *   </simpleContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "Property", propOrder = { + "value" +}) +public class Property { + + @XmlValue + protected String value; + @XmlAttribute(name = "Name") + protected String name; + + /** + * Gets the value of the value property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getValue() { + return value; + } + + /** + * Sets the value of the value property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setValue(String value) { + this.value = value; + } + + /** + * Gets the value of the name property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getName() { + return name; + } + + /** + * Sets the value of the name property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setName(String value) { + this.name = value; + } + +} diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/ProvisioningConfig.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/ProvisioningConfig.java index 4ebf232a44e..6abb4c79c6d 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/ProvisioningConfig.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/ProvisioningConfig.java @@ -1,39 +1,62 @@ -/* - * 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.extensions.device.type.deployer.config; +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 javax.xml.bind.annotation.XmlType; + /** - * Class for holding device type configuration and parsing with JAXB. + *

Java class for ProvisioningConfig complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="ProvisioningConfig">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="SharedWithAllTenants" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * */ -@XmlRootElement(name = "ProvisioningConfig") +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "ProvisioningConfig", propOrder = { + "sharedWithAllTenants" +}) public class ProvisioningConfig { - private boolean sharedWithAllTenants; + @XmlElement(name = "SharedWithAllTenants", required = true) + protected boolean sharedWithAllTenants; + + /** + * Gets the value of the sharedWithAllTenants property. + * + * @return + * possible object is + * {@link boolean } + * + */ + public boolean isSharedWithAllTenants() { + return sharedWithAllTenants; + } - @XmlElement(name = "SharedWithAllTenants", required = true) - public boolean isSharedWithAllTenants() { - return sharedWithAllTenants; - } + /** + * Sets the value of the sharedWithAllTenants property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setSharedWithAllTenants(boolean value) { + this.sharedWithAllTenants = value; + } - public void setSharedWithAllTenants(boolean sharedWithAllTenants) { - this.sharedWithAllTenants = sharedWithAllTenants; - } -} \ No newline at end of file +} diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/PushNotificationConfig.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/PushNotificationConfig.java deleted file mode 100644 index 94955ff25f9..00000000000 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/PushNotificationConfig.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.wso2.carbon.device.mgt.extensions.device.type.deployer.config; - -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlValue; -import java.util.List; - -@XmlRootElement(name = "PushNotificationConfiguration") -public class PushNotificationConfig { - - private String pushNotificationProvider; - private List properties; - - @XmlElementWrapper(name = "Properties", required = true) - @XmlElement(name = "Property", required = true) - public List getProperties() { - return properties; - } - - public void setProperties(List properties) { - this.properties = properties; - } - - @XmlElement(name = "PushNotificationProvider", required = true) - public String getPushNotificationProvider() { - return pushNotificationProvider; - } - - public void setPushNotificationProvider(String pushNotificationProvider) { - this.pushNotificationProvider = pushNotificationProvider; - } - - @XmlRootElement(name = "Property") - public static class Property { - - private String name; - private String value; - - @XmlAttribute(name = "Name", required = true) - 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-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/PushNotificationConfiguration.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/PushNotificationConfiguration.java new file mode 100644 index 00000000000..1059d80ec14 --- /dev/null +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/PushNotificationConfiguration.java @@ -0,0 +1,118 @@ + +package org.wso2.carbon.device.mgt.extensions.device.type.deployer.config; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for PushNotificationConfiguration complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="PushNotificationConfiguration">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="PushNotificationProvider" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="FileBasedProperties" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="Properties" type="{}Properties"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "PushNotificationConfiguration", propOrder = { + "pushNotificationProvider", + "fileBasedProperties", + "properties" +}) +public class PushNotificationConfiguration { + + @XmlElement(name = "PushNotificationProvider", required = true) + protected String pushNotificationProvider; + @XmlElement(name = "FileBasedProperties", required = true) + protected boolean fileBasedProperties; + @XmlElement(name = "Properties", required = true) + protected Properties properties; + + /** + * Gets the value of the pushNotificationProvider property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getPushNotificationProvider() { + return pushNotificationProvider; + } + + /** + * Sets the value of the pushNotificationProvider property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setPushNotificationProvider(String value) { + this.pushNotificationProvider = value; + } + + /** + * Gets the value of the fileBasedProperties property. + * + * @return + * possible object is + * {@link String } + * + */ + public boolean isFileBasedProperties() { + return fileBasedProperties; + } + + /** + * Sets the value of the fileBasedProperties property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setFileBasedProperties(boolean value) { + this.fileBasedProperties = value; + } + + /** + * Gets the value of the properties property. + * + * @return + * possible object is + * {@link Properties } + * + */ + public Properties getProperties() { + return properties; + } + + /** + * Sets the value of the properties property. + * + * @param value + * allowed object is + * {@link Properties } + * + */ + public void setProperties(Properties value) { + this.properties = value; + } + +} diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/FeaturesConfig.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/exception/DeviceTypeDeployerFileException.java similarity index 50% rename from components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/FeaturesConfig.java rename to components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/exception/DeviceTypeDeployerFileException.java index b7baf064896..1d30952a9f3 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/FeaturesConfig.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/exception/DeviceTypeDeployerFileException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * 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 @@ -15,26 +15,29 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.extensions.device.type.deployer.config; +package org.wso2.carbon.device.mgt.extensions.device.type.deployer.exception; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -/** - * Class for holding device type configuration and parsing with JAXB. - */ -@XmlRootElement(name = "FeaturesConfig") -public class FeaturesConfig { +public class DeviceTypeDeployerFileException extends RuntimeException { + + public DeviceTypeDeployerFileException(String msg, Exception nestedEx) { + super(msg, nestedEx); + } - private JNDILookupDefinition jndiLookupDefinition; + public DeviceTypeDeployerFileException(String message, Throwable cause) { + super(message, cause); + } + + public DeviceTypeDeployerFileException(String msg) { + super(msg); + } - @XmlElement(name = "JndiLookupDefinition", required = true) - public JNDILookupDefinition getJndiLookupDefinition() { - return jndiLookupDefinition; + public DeviceTypeDeployerFileException() { + super(); } - public void setJndiLookupDefinition(JNDILookupDefinition jndiLookupDefinition) { - this.jndiLookupDefinition = jndiLookupDefinition; + public DeviceTypeDeployerFileException(Throwable cause) { + super(cause); } -} \ No newline at end of file +} diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManager.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManager.java index df81c24577e..d635e9192cd 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManager.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManager.java @@ -15,10 +15,16 @@ import org.wso2.carbon.device.mgt.common.license.mgt.License; import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException; import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager; import org.wso2.carbon.device.mgt.extensions.device.type.deployer.DeviceTypePluginConstants; +import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.DeviceDefinition; import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.DeviceManagementConfiguration; +import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.Feature; +import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.Features; +import org.wso2.carbon.device.mgt.extensions.device.type.deployer.exception.DeviceTypeDeployerFileException; import org.wso2.carbon.device.mgt.extensions.device.type.deployer.exception.DeviceTypeMgtPluginException; +import org.wso2.carbon.device.mgt.extensions.device.type.deployer.template.dao.DeviceDAODefinition; import org.wso2.carbon.device.mgt.extensions.device.type.deployer.template.dao.DeviceTypePluginDAOManager; import org.wso2.carbon.device.mgt.extensions.device.type.deployer.template.feature.AnnotationBasedFeatureManager; +import org.wso2.carbon.device.mgt.extensions.device.type.deployer.template.feature.ConfigurationBasedFeatureManager; import org.wso2.carbon.device.mgt.extensions.device.type.deployer.template.util.DeviceTypeUtils; import org.wso2.carbon.device.mgt.extensions.license.mgt.registry.RegistryBasedLicenseManager; import org.wso2.carbon.registry.api.RegistryException; @@ -39,14 +45,14 @@ public class DeviceTypeManager implements DeviceManager { private String deviceType; private DeviceTypePluginDAOManager deviceTypePluginDAOManager; private LicenseManager licenseManager; + private boolean propertiesExist; private FeatureManager featureManager; public DeviceTypeManager(DeviceTypeConfigIdentifier deviceTypeConfigIdentifier, DeviceManagementConfiguration deviceManagementConfiguration) { - deviceTypePluginDAOManager = new DeviceTypePluginDAOManager(deviceManagementConfiguration); + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); - boolean isSharedWithAllTenants = - deviceManagementConfiguration.getDeviceManagementConfigRepository().getProvisioningConfig() + boolean isSharedWithAllTenants = deviceManagementConfiguration.getManagementRepository().getProvisioningConfig() .isSharedWithAllTenants(); DeviceTypeIdentifier deviceTypeIdentifier; deviceType = deviceTypeConfigIdentifier.getDeviceType(); @@ -56,21 +62,54 @@ public class DeviceTypeManager implements DeviceManager { deviceTypeIdentifier = new DeviceTypeIdentifier(deviceType, tenantId); } - featureManager = new AnnotationBasedFeatureManager(deviceTypeIdentifier); + DeviceDefinition deviceDefinition = deviceManagementConfiguration.getManagementRepository().getDeviceDefinition(); + if (deviceDefinition != null) { + //generate features. + Features featuresList = deviceManagementConfiguration.getManagementRepository().getDeviceDefinition().getFeatures(); + if (featuresList != null) { + if (featuresList.isGenerate()) { + featureManager = new AnnotationBasedFeatureManager(deviceTypeIdentifier); + } else { + List features = deviceDefinition.getFeatures().getFeature(); + if (features != null) { + featureManager = new ConfigurationBasedFeatureManager(features); + } + } + } + + //add license to registry. + this.licenseManager = new RegistryBasedLicenseManager(); + try { + if (licenseManager.getLicense(deviceType, DeviceTypePluginConstants.LANGUAGE_CODE_ENGLISH_US) == null) { - this.licenseManager = new RegistryBasedLicenseManager(); - License defaultLicense; + if (deviceDefinition.getLicense() != null) { + License defaultLicense = new License(); + defaultLicense.setLanguage(deviceDefinition.getLicense().getLanguage()); + defaultLicense.setVersion(deviceDefinition.getLicense().getVersion()); + defaultLicense.setText(deviceDefinition.getLicense().getText()); + licenseManager.addLicense(deviceType, defaultLicense); + } + } + } catch (LicenseManagementException e) { + String msg = "Error occurred while adding default license for " + deviceType + " devices"; + throw new DeviceTypeDeployerFileException(msg, e); + } - try { - if (licenseManager.getLicense(deviceType, DeviceTypePluginConstants.LANGUAGE_CODE_ENGLISH_US) == null) { - defaultLicense = null; - licenseManager.addLicense(deviceType, defaultLicense); + //Check whether device dao definition exist. + + String tableName = deviceManagementConfiguration.getManagementRepository().getDeviceDefinition() + .getTableName(); + if (tableName != null && !tableName.isEmpty()) { + propertiesExist = true; + DeviceDAODefinition deviceDAODefinition = new DeviceDAODefinition(deviceDefinition); + String datasourceName = deviceManagementConfiguration.getManagementRepository() + .getDataSourceConfiguration().getJndiLookupDefinition().getName(); + if (datasourceName != null && !datasourceName.isEmpty()) { + deviceTypePluginDAOManager = new DeviceTypePluginDAOManager(datasourceName, deviceDAODefinition); + } else { + throw new DeviceTypeDeployerFileException("Invalid datasource name."); + } } - featureManager.addSupportedFeaturesToDB(); - } catch (LicenseManagementException e) { - log.error("Error occurred while adding default license for Android devices", e); - } catch (DeviceManagementException e) { - log.error("Error occurred while adding supported device features for Android platform", e); } } @@ -137,57 +176,63 @@ public class DeviceTypeManager implements DeviceManager { @Override public boolean enrollDevice(Device device) throws DeviceManagementException { - boolean status = false; - boolean isEnrolled = this.isEnrolled( - new DeviceIdentifier(device.getDeviceIdentifier(), device.getType())); - try { - if (log.isDebugEnabled()) { - log.debug("Enrolling a new Android device : " + device.getDeviceIdentifier()); - } - if (isEnrolled) { - this.modifyEnrollment(device); - } else { - deviceTypePluginDAOManager.beginTransaction(); - status = deviceTypePluginDAOManager.getDeviceDAO().addDevice(device); - deviceTypePluginDAOManager.commitTransaction(); - } - } catch (DeviceTypeMgtPluginException e) { + if (propertiesExist) { + boolean status = false; + boolean isEnrolled = this.isEnrolled( + new DeviceIdentifier(device.getDeviceIdentifier(), device.getType())); try { - deviceTypePluginDAOManager.rollbackTransaction(); - } catch (DeviceTypeMgtPluginException ex) { - String msg = "Error occurred while roll back the device enrol transaction :" + - device.toString(); - log.warn(msg, ex); + if (log.isDebugEnabled()) { + log.debug("Enrolling a new Android device : " + device.getDeviceIdentifier()); + } + if (isEnrolled) { + this.modifyEnrollment(device); + } else { + deviceTypePluginDAOManager.beginTransaction(); + status = deviceTypePluginDAOManager.getDeviceDAO().addDevice(device); + deviceTypePluginDAOManager.commitTransaction(); + } + } catch (DeviceTypeMgtPluginException e) { + try { + deviceTypePluginDAOManager.rollbackTransaction(); + } catch (DeviceTypeMgtPluginException ex) { + String msg = "Error occurred while roll back the device enrol transaction :" + + device.toString(); + log.warn(msg, ex); + } + String msg = "Error while enrolling the " + deviceType + " device : " + device.getDeviceIdentifier(); + throw new DeviceManagementException(msg, e); } - String msg = "Error while enrolling the " + deviceType + " device : " + device.getDeviceIdentifier(); - throw new DeviceManagementException(msg, e); + return status; } - return status; + return true; } @Override public boolean modifyEnrollment(Device device) throws DeviceManagementException { - boolean status; - try { - if (log.isDebugEnabled()) { - log.debug("Modifying the Android device enrollment data"); - } - deviceTypePluginDAOManager.beginTransaction(); - status = deviceTypePluginDAOManager.getDeviceDAO().updateDevice(device); - deviceTypePluginDAOManager.commitTransaction(); - } catch (DeviceTypeMgtPluginException e) { + if (propertiesExist) { + boolean status; try { - deviceTypePluginDAOManager.rollbackTransaction(); - } catch (DeviceTypeMgtPluginException mobileDAOEx) { - String msg = "Error occurred while roll back the update device transaction :" + - device.toString(); - log.warn(msg, mobileDAOEx); + if (log.isDebugEnabled()) { + log.debug("Modifying the Android device enrollment data"); + } + deviceTypePluginDAOManager.beginTransaction(); + status = deviceTypePluginDAOManager.getDeviceDAO().updateDevice(device); + deviceTypePluginDAOManager.commitTransaction(); + } catch (DeviceTypeMgtPluginException e) { + try { + deviceTypePluginDAOManager.rollbackTransaction(); + } catch (DeviceTypeMgtPluginException mobileDAOEx) { + String msg = "Error occurred while roll back the update device transaction :" + + device.toString(); + log.warn(msg, mobileDAOEx); + } + String msg = "Error while updating the enrollment of the " + deviceType + " device : " + + device.getDeviceIdentifier(); + throw new DeviceManagementException(msg, e); } - String msg = "Error while updating the enrollment of the " + deviceType + " device : " + - device.getDeviceIdentifier(); - throw new DeviceManagementException(msg, e); + return status; } - return status; + return true; } @Override @@ -198,22 +243,25 @@ public class DeviceTypeManager implements DeviceManager { @Override public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException { - boolean isEnrolled = false; - try { - if (log.isDebugEnabled()) { - log.debug("Checking the enrollment of Android device : " + deviceId.getId()); - } - Device device = - deviceTypePluginDAOManager.getDeviceDAO().getDevice(deviceId.getId()); - if (device != null) { - isEnrolled = true; + if (propertiesExist) { + boolean isEnrolled = false; + try { + if (log.isDebugEnabled()) { + log.debug("Checking the enrollment of Android device : " + deviceId.getId()); + } + Device device = + deviceTypePluginDAOManager.getDeviceDAO().getDevice(deviceId.getId()); + if (device != null) { + isEnrolled = true; + } + } catch (DeviceTypeMgtPluginException e) { + String msg = "Error while checking the enrollment status of " + deviceType + " device : " + + deviceId.getId(); + throw new DeviceManagementException(msg, e); } - } catch (DeviceTypeMgtPluginException e) { - String msg = "Error while checking the enrollment status of " + deviceType + " device : " + - deviceId.getId(); - throw new DeviceManagementException(msg, e); + return isEnrolled; } - return isEnrolled; + return true; } @Override @@ -229,17 +277,20 @@ public class DeviceTypeManager implements DeviceManager { @Override public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException { - Device device; - try { - if (log.isDebugEnabled()) { - log.debug("Getting the details of " + deviceType + " device : '" + deviceId.getId() + "'"); + if (propertiesExist) { + Device device; + try { + if (log.isDebugEnabled()) { + log.debug("Getting the details of " + deviceType + " device : '" + deviceId.getId() + "'"); + } + device = deviceTypePluginDAOManager.getDeviceDAO().getDevice(deviceId.getId()); + } catch (DeviceTypeMgtPluginException e) { + throw new DeviceManagementException( + "Error occurred while fetching the " + deviceType + " device: '" + deviceId.getId() + "'", e); } - device = deviceTypePluginDAOManager.getDeviceDAO().getDevice(deviceId.getId()); - } catch (DeviceTypeMgtPluginException e) { - throw new DeviceManagementException( - "Error occurred while fetching the " + deviceType + " device: '" + deviceId.getId() + "'", e); + return device; } - return device; + return null; } @Override @@ -277,44 +328,50 @@ public class DeviceTypeManager implements DeviceManager { @Override public boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device) throws DeviceManagementException { - boolean status; - Device existingDevice = this.getDevice(deviceIdentifier); - existingDevice.setProperties(device.getProperties()); + if (propertiesExist) { + boolean status; + Device existingDevice = this.getDevice(deviceIdentifier); + existingDevice.setProperties(device.getProperties()); - try { - if (log.isDebugEnabled()) { - log.debug( - "updating the details of " + deviceType + " device : " + device.getDeviceIdentifier()); - } - deviceTypePluginDAOManager.beginTransaction(); - status = deviceTypePluginDAOManager.getDeviceDAO().updateDevice(existingDevice); - deviceTypePluginDAOManager.commitTransaction(); - } catch (DeviceTypeMgtPluginException e) { try { - deviceTypePluginDAOManager.rollbackTransaction(); - } catch (DeviceTypeMgtPluginException e1) { - log.warn("Error occurred while roll back the update device info transaction : '" + - device.toString() + "'", e1); + if (log.isDebugEnabled()) { + log.debug( + "updating the details of " + deviceType + " device : " + device.getDeviceIdentifier()); + } + deviceTypePluginDAOManager.beginTransaction(); + status = deviceTypePluginDAOManager.getDeviceDAO().updateDevice(existingDevice); + deviceTypePluginDAOManager.commitTransaction(); + } catch (DeviceTypeMgtPluginException e) { + try { + deviceTypePluginDAOManager.rollbackTransaction(); + } catch (DeviceTypeMgtPluginException e1) { + log.warn("Error occurred while roll back the update device info transaction : '" + + device.toString() + "'", e1); + } + throw new DeviceManagementException( + "Error occurred while updating the " + deviceType + " device: '" + + device.getDeviceIdentifier() + "'", e); } - throw new DeviceManagementException( - "Error occurred while updating the " + deviceType + " device: '" + - device.getDeviceIdentifier() + "'", e); + return status; } - return status; + return true; } @Override public List getAllDevices() throws DeviceManagementException { - List devices = null; - try { - if (log.isDebugEnabled()) { - log.debug("Fetching the details of all " + deviceType + " devices"); + if (propertiesExist) { + List devices = null; + try { + if (log.isDebugEnabled()) { + log.debug("Fetching the details of all " + deviceType + " devices"); + } + devices = deviceTypePluginDAOManager.getDeviceDAO().getAllDevices(); + } catch (DeviceTypeMgtPluginException e) { + throw new DeviceManagementException("Error occurred while fetching all " + deviceType + " devices", e); } - devices = deviceTypePluginDAOManager.getDeviceDAO().getAllDevices(); - } catch (DeviceTypeMgtPluginException e) { - throw new DeviceManagementException("Error occurred while fetching all " + deviceType + " devices", e); + return devices; } - return devices; + return null; } } diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManagerService.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManagerService.java index 117fc8b0e28..986f71fdb8a 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManagerService.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManagerService.java @@ -11,6 +11,8 @@ import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig; import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.DeviceManagementConfiguration; +import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.Property; +import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.PushNotificationConfiguration; import java.util.HashMap; import java.util.List; @@ -29,9 +31,8 @@ public class DeviceTypeManagerService implements DeviceManagementService { DeviceManagementConfiguration deviceManagementConfiguration) { this.setProvisioningConfig(deviceTypeConfigIdentifier.getTenantDomain(), deviceManagementConfiguration); this.deviceManager = new DeviceTypeManager(deviceTypeConfigIdentifier, deviceManagementConfiguration); - this.setType(deviceManagementConfiguration); - this.populatePushNotificationConfig(deviceManagementConfiguration); - + this.setType(deviceManagementConfiguration.getDeviceType()); + this.populatePushNotificationConfig(deviceManagementConfiguration.getPushNotificationConfiguration()); } @Override @@ -43,14 +44,11 @@ public class DeviceTypeManagerService implements DeviceManagementService { public void init() throws DeviceManagementException { } - private void populatePushNotificationConfig(DeviceManagementConfiguration deviceManagementConfiguration) { - org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.PushNotificationConfig sourceConfig = - deviceManagementConfiguration.getPushNotificationConfig(); + private void populatePushNotificationConfig(PushNotificationConfiguration sourceConfig) { if (sourceConfig != null) { - if (true) { + if (sourceConfig.isFileBasedProperties()) { Map staticProps = new HashMap<>(); - for (org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.PushNotificationConfig.Property - property : sourceConfig.getProperties()) { + for (Property property : sourceConfig.getProperties().getProperty()) { staticProps.put(property.getName(), property.getValue()); } pushNotificationConfig = new PushNotificationConfig(sourceConfig.getPushNotificationProvider(), @@ -95,12 +93,12 @@ public class DeviceTypeManagerService implements DeviceManagementService { private void setProvisioningConfig(String tenantDomain, DeviceManagementConfiguration deviceManagementConfiguration) { boolean sharedWithAllTenants = deviceManagementConfiguration - .getDeviceManagementConfigRepository().getProvisioningConfig().isSharedWithAllTenants(); + .getManagementRepository().getProvisioningConfig().isSharedWithAllTenants(); provisioningConfig = new ProvisioningConfig(tenantDomain, sharedWithAllTenants); } - private void setType(DeviceManagementConfiguration deviceManagementConfiguration) { - type = deviceManagementConfiguration.getDeviceType(); + private void setType(String type) { + this.type = type; } private Map getConfigProperty(List configs) { diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/dao/DeviceDAODefinition.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/dao/DeviceDAODefinition.java new file mode 100644 index 00000000000..f14a3fb3253 --- /dev/null +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/dao/DeviceDAODefinition.java @@ -0,0 +1,54 @@ +package org.wso2.carbon.device.mgt.extensions.device.type.deployer.template.dao; + +import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.Attribute; +import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.DeviceDefinition; +import org.wso2.carbon.device.mgt.extensions.device.type.deployer.exception.DeviceTypeDeployerFileException; + +import java.util.ArrayList; +import java.util.List; + +public class DeviceDAODefinition { + + private String deviceTableName; + private String primarkey; + + public List getColumnNames() { + return columnNames; + } + + private List columnNames = new ArrayList<>(); + + + public DeviceDAODefinition(DeviceDefinition deviceDefinition) { + deviceTableName = deviceDefinition.getTableName(); + primarkey = deviceDefinition.getPrimaryKey(); + List attributes = deviceDefinition.getAttributes().getAttribute(); + if (deviceTableName == null || deviceTableName.isEmpty()) { + throw new DeviceTypeDeployerFileException("Missing deviceTableName"); + } + + if (primarkey == null || primarkey.isEmpty()) { + throw new DeviceTypeDeployerFileException("Missing primaryKey "); + } + + if (attributes == null || attributes.size() == 0) { + throw new DeviceTypeDeployerFileException("Missing Attributes "); + } + for (Attribute attribute : attributes) { + if (attribute.getValue() == null ||attribute.getValue().isEmpty()) { + throw new DeviceTypeDeployerFileException("Unsupported attribute format for device definition"); + } + columnNames.add(attribute.getValue()); + } + } + + public String getDeviceTableName() { + return deviceTableName; + } + + public String getPrimarkey() { + return primarkey; + } + + +} diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/dao/DeviceTypePluginDAO.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/dao/DeviceTypePluginDAO.java index 2996205cf5d..60aa16f4ccd 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/dao/DeviceTypePluginDAO.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/dao/DeviceTypePluginDAO.java @@ -18,10 +18,10 @@ package org.wso2.carbon.device.mgt.extensions.device.type.deployer.template.dao; +import org.apache.commons.lang.StringUtils; 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.extensions.device.type.deployer.config.DeviceManagementConfiguration; import org.wso2.carbon.device.mgt.extensions.device.type.deployer.exception.DeviceTypeMgtPluginException; import org.wso2.carbon.device.mgt.extensions.device.type.deployer.template.util.DeviceTypeUtils; @@ -37,163 +37,220 @@ import java.util.List; */ public class DeviceTypePluginDAO { - private static final Log log = LogFactory.getLog(DeviceTypePluginDAO.class); - private DeviceTypePluginDAOManager deviceTypePluginDAOManager; - public DeviceTypePluginDAO(DeviceManagementConfiguration deviceManagementConfiguration) { - deviceTypePluginDAOManager = new DeviceTypePluginDAOManager(deviceManagementConfiguration); - } - - public Device getDevice(String deviceId) throws DeviceTypeMgtPluginException { - Connection conn = null; - PreparedStatement stmt = null; - Device device = null; - ResultSet resultSet = null; - try { - conn = deviceTypePluginDAOManager.getConnection(); - String selectDBQuery = - "SELECT VIRTUAL_FIREALARM_DEVICE_ID, DEVICE_NAME" + - " FROM VIRTUAL_FIREALARM_DEVICE WHERE VIRTUAL_FIREALARM_DEVICE_ID = ?"; - stmt = conn.prepareStatement(selectDBQuery); - stmt.setString(1, deviceId); - resultSet = stmt.executeQuery(); - - if (resultSet.next()) { - device = new Device(); - if (log.isDebugEnabled()) { - log.debug("Virtual Firealarm device " + deviceId + " data has been fetched from " + - "Virtual Firealarm database."); - } - } - } catch (SQLException e) { - String msg = "Error occurred while fetching Virtual Firealarm device : '" + deviceId + "'"; - log.error(msg, e); - throw new DeviceTypeMgtPluginException(msg, e); - } finally { - DeviceTypeUtils.cleanupResources(stmt, resultSet); - deviceTypePluginDAOManager.closeConnection(); - } - - return device; - } - - public boolean addDevice(Device device) throws DeviceTypeMgtPluginException { - boolean status = false; - Connection conn = null; - PreparedStatement stmt = null; - try { - conn = deviceTypePluginDAOManager.getConnection(); - String createDBQuery = - "INSERT INTO VIRTUAL_FIREALARM_DEVICE(VIRTUAL_FIREALARM_DEVICE_ID, DEVICE_NAME) VALUES (?, ?)"; - - stmt = conn.prepareStatement(createDBQuery); - stmt.setString(1, device.getDeviceIdentifier()); - stmt.setString(2, device.getName()); - int rows = stmt.executeUpdate(); - if (rows > 0) { - status = true; - if (log.isDebugEnabled()) { - log.debug("Virtual Firealarm device " + device.getDeviceIdentifier() + " data has been" + - " added to the Virtual Firealarm database."); - } - } - } catch (SQLException e) { - String msg = "Error occurred while adding the Virtual Firealarm device '" + - device.getDeviceIdentifier() + "' to the Virtual Firealarm db."; - log.error(msg, e); - throw new DeviceTypeMgtPluginException(msg, e); - } finally { - DeviceTypeUtils.cleanupResources(stmt, null); - } - return status; - } - - public boolean updateDevice(Device device) throws DeviceTypeMgtPluginException { - boolean status = false; - Connection conn = null; - PreparedStatement stmt = null; - try { - conn = DeviceTypePluginDAOManager.getConnection(); - String updateDBQuery = - "UPDATE VIRTUAL_FIREALARM_DEVICE SET DEVICE_NAME = ? WHERE VIRTUAL_FIREALARM_DEVICE_ID = ?"; - - stmt = conn.prepareStatement(updateDBQuery); - stmt.setString(1, device.getName()); - stmt.setString(2, device.getDeviceIdentifier()); - int rows = stmt.executeUpdate(); - if (rows > 0) { - status = true; - if (log.isDebugEnabled()) { - log.debug("Virtualm Firealarm device " + device.getDeviceIdentifier() + " data has been" + - " modified."); - } - } - } catch (SQLException e) { - String msg = "Error occurred while modifying the Virtual Firealarm device '" + - device.getDeviceIdentifier() + "' data."; - log.error(msg, e); - throw new DeviceTypeMgtPluginException(msg, e); - } finally { - DeviceTypeUtils.cleanupResources(stmt, null); - } - return status; - } - - public boolean deleteDevice(String iotDeviceId) throws DeviceTypeMgtPluginException { - boolean status = false; - Connection conn = null; - PreparedStatement stmt = null; - try { - conn = deviceTypePluginDAOManager.getConnection(); - String deleteDBQuery = "DELETE FROM VIRTUAL_FIREALARM_DEVICE WHERE VIRTUAL_FIREALARM_DEVICE_ID = ?"; - stmt = conn.prepareStatement(deleteDBQuery); - stmt.setString(1, iotDeviceId); - int rows = stmt.executeUpdate(); - if (rows > 0) { - status = true; - if (log.isDebugEnabled()) { - log.debug("Virtual Firealarm device " + iotDeviceId + " data has deleted" + - " from the Virtual Firealarm database."); - } - } - } catch (SQLException e) { - String msg = "Error occurred while deleting Virtual Firealarm device " + iotDeviceId; - log.error(msg, e); - throw new DeviceTypeMgtPluginException(msg, e); - } finally { - DeviceTypeUtils.cleanupResources(stmt, null); - } - return status; - } - - public List getAllDevices() throws DeviceTypeMgtPluginException { - Connection conn; - PreparedStatement stmt = null; - ResultSet resultSet = null; - Device device; - List devices = new ArrayList<>(); - try { - conn = deviceTypePluginDAOManager.getConnection(); - String selectDBQuery = - "SELECT VIRTUAL_FIREALARM_DEVICE_ID, DEVICE_NAME FROM VIRTUAL_FIREALARM_DEVICE"; - stmt = conn.prepareStatement(selectDBQuery); - resultSet = stmt.executeQuery(); - while (resultSet.next()) { - device = new Device(); - device.setDeviceIdentifier(resultSet.getString(VirtualFireAlarmConstants.DEVICE_PLUGIN_DEVICE_ID)); - device.setName(resultSet.getString(VirtualFireAlarmConstants.DEVICE_PLUGIN_DEVICE_NAME)); - devices.add(device); - } - if (log.isDebugEnabled()) { - log.debug("All Virtual Firealarm device details have fetched from Firealarm database."); - } - return devices; - } catch (SQLException e) { - String msg = "Error occurred while fetching all Virtual Firealarm device data'"; - log.error(msg, e); - throw new DeviceTypeMgtPluginException(msg, e); - } finally { - DeviceTypeUtils.cleanupResources(stmt, resultSet); - deviceTypePluginDAOManager.closeConnection(); - } - } + private static final Log log = LogFactory.getLog(DeviceTypePluginDAO.class); + private DeviceTypePluginDAOManager deviceTypePluginDAOManager; + private DeviceDAODefinition deviceDAODefinition; + + public DeviceTypePluginDAO(DeviceDAODefinition deviceDAODefinition, + DeviceTypePluginDAOManager deviceTypePluginDAOManager) { + this.deviceTypePluginDAOManager = deviceTypePluginDAOManager; + this.deviceDAODefinition = deviceDAODefinition; + } + + public Device getDevice(String deviceId) throws DeviceTypeMgtPluginException { + Connection conn = null; + PreparedStatement stmt = null; + Device device = null; + ResultSet resultSet = null; + try { + conn = deviceTypePluginDAOManager.getConnection(); + String selectDBQuery = "SELECT " + getDeviceTableColumnNames() + " FROM " + + deviceDAODefinition.getDeviceTableName() + " WHERE " + deviceDAODefinition.getPrimarkey() + " = ?"; + stmt = conn.prepareStatement(selectDBQuery); + stmt.setString(1, deviceId); + resultSet = stmt.executeQuery(); + + if (resultSet.next()) { + device = new Device(); + if (log.isDebugEnabled()) { + log.debug(deviceId + " data has been fetched from " + deviceDAODefinition.getDeviceTableName() + + " database."); + } + List properties = new ArrayList<>(); + for (String columnName : deviceDAODefinition.getColumnNames()) { + Device.Property property = new Device.Property(); + property.setName(columnName); + property.setValue(resultSet.getString(columnName)); + properties.add(property); + } + device.setProperties(properties); + } + + } catch (SQLException e) { + String msg = "Error occurred while fetching device : '" + deviceId + "' from " + deviceDAODefinition + .getDeviceTableName(); + log.error(msg, e); + throw new DeviceTypeMgtPluginException(msg, e); + } finally { + DeviceTypeUtils.cleanupResources(stmt, resultSet); + deviceTypePluginDAOManager.closeConnection(); + } + + return device; + } + + public boolean addDevice(Device device) throws DeviceTypeMgtPluginException { + boolean status = false; + Connection conn = null; + PreparedStatement stmt = null; + try { + conn = deviceTypePluginDAOManager.getConnection(); + String createDBQuery = "INSERT INTO " + deviceDAODefinition.getDeviceTableName() + "(" + + deviceDAODefinition.getPrimarkey() + " , " + getDeviceTableColumnNames() + ") VALUES (" + + getPreparedInputString(deviceDAODefinition.getColumnNames().size() + 1) + ")"; + stmt = conn.prepareStatement(createDBQuery); + stmt.setString(1, device.getDeviceIdentifier()); + int columnIndex = 2; + for (String columnName : deviceDAODefinition.getColumnNames()) { + stmt.setString(columnIndex, getPropertString(device.getProperties(), columnName)); + columnIndex++; + } + int rows = stmt.executeUpdate(); + if (rows > 0) { + status = true; + if (log.isDebugEnabled()) { + log.debug("device " + device.getDeviceIdentifier() + " data has been" + + " added to the " + deviceDAODefinition.getDeviceTableName() + " database."); + } + } + } catch (SQLException e) { + String msg = "Error occurred while adding the device '" + + device.getDeviceIdentifier() + "' to the " + deviceDAODefinition.getDeviceTableName() + " db."; + log.error(msg, e); + throw new DeviceTypeMgtPluginException(msg, e); + } finally { + DeviceTypeUtils.cleanupResources(stmt, null); + } + return status; + } + + public boolean updateDevice(Device device) throws DeviceTypeMgtPluginException { + boolean status = false; + Connection conn = null; + PreparedStatement stmt = null; + try { + conn = deviceTypePluginDAOManager.getConnection(); + String updateDBQuery = "UPDATE " + deviceDAODefinition.getDeviceTableName() + " SET " + + getDeviceTableColumnNamesForUpdateQuery()+ " WHERE " + deviceDAODefinition.getPrimarkey() + + " = ?"; + + stmt = conn.prepareStatement(updateDBQuery); + int columnIndex = 1; + for (String columnName : deviceDAODefinition.getColumnNames()) { + stmt.setString(columnIndex, getPropertString(device.getProperties(), columnName)); + columnIndex++; + } + stmt.setString(columnIndex, device.getDeviceIdentifier()); + int rows = stmt.executeUpdate(); + if (rows > 0) { + status = true; + if (log.isDebugEnabled()) { + log.debug("device " + device.getDeviceIdentifier() + " data has been modified."); + } + } + } catch (SQLException e) { + String msg = "Error occurred while modifying the device '" + + device.getDeviceIdentifier() + "' data. " + deviceDAODefinition.getDeviceTableName(); + log.error(msg, e); + throw new DeviceTypeMgtPluginException(msg, e); + } finally { + DeviceTypeUtils.cleanupResources(stmt, null); + } + return status; + } + + public boolean deleteDevice(String deviceId) throws DeviceTypeMgtPluginException { + boolean status = false; + Connection conn = null; + PreparedStatement stmt = null; + try { + conn = deviceTypePluginDAOManager.getConnection(); + String deleteDBQuery = "DELETE FROM " + deviceDAODefinition.getDeviceTableName() + + " WHERE " + deviceDAODefinition.getPrimarkey() + " = ?"; + stmt = conn.prepareStatement(deleteDBQuery); + stmt.setString(1, deviceId); + int rows = stmt.executeUpdate(); + if (rows > 0) { + status = true; + if (log.isDebugEnabled()) { + log.debug("device " + deviceId + " data has deleted from the " + + deviceDAODefinition.getDeviceTableName() + " table."); + } + } + } catch (SQLException e) { + String msg = + "Error occurred while deleting " + deviceDAODefinition.getDeviceTableName() + " device " + deviceId; + log.error(msg, e); + throw new DeviceTypeMgtPluginException(msg, e); + } finally { + DeviceTypeUtils.cleanupResources(stmt, null); + } + return status; + } + + public List getAllDevices() throws DeviceTypeMgtPluginException { + Connection conn; + PreparedStatement stmt = null; + ResultSet resultSet = null; + Device device; + List devices = new ArrayList<>(); + try { + conn = deviceTypePluginDAOManager.getConnection(); + String selectDBQuery = "SELECT " + getDeviceTableColumnNames() + " FROM " + + deviceDAODefinition.getDeviceTableName(); + stmt = conn.prepareStatement(selectDBQuery); + resultSet = stmt.executeQuery(); + while (resultSet.next()) { + device = new Device(); + device.setDeviceIdentifier(resultSet.getString(deviceDAODefinition.getPrimarkey())); + List properties = new ArrayList<>(); + for (String columnName : deviceDAODefinition.getColumnNames()) { + Device.Property property = new Device.Property(); + property.setName(columnName); + property.setValue(resultSet.getString(columnName)); + properties.add(property); + } + device.setProperties(properties); + devices.add(device); + } + if (log.isDebugEnabled()) { + log.debug( + "All device details have fetched from " + deviceDAODefinition.getDeviceTableName() + " table."); + } + return devices; + } catch (SQLException e) { + String msg = + "Error occurred while fetching all " + deviceDAODefinition.getDeviceTableName() + " device data'"; + log.error(msg, e); + throw new DeviceTypeMgtPluginException(msg, e); + } finally { + DeviceTypeUtils.cleanupResources(stmt, resultSet); + deviceTypePluginDAOManager.closeConnection(); + } + } + + private String getDeviceTableColumnNames() { + return StringUtils.join(deviceDAODefinition.getColumnNames(), ", "); + } + + private String getDeviceTableColumnNamesForUpdateQuery() { + return StringUtils.join(deviceDAODefinition.getColumnNames(), "= ?,"); + } + + private String getPreparedInputString(int length) { + String preparedInput = "?"; + for (int i = 1; i < length; i++) { + preparedInput += ", ?"; + } + return preparedInput; + } + + private String getPropertString(List properties, String propertyName) { + for (Device.Property property : properties) { + if (property.getName().equals(propertyName)) { + return property.getValue(); + } + } + return null; + } } \ No newline at end of file diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/dao/DeviceTypePluginDAOManager.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/dao/DeviceTypePluginDAOManager.java index 1e7b23b3bc6..fd52d39cfad 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/dao/DeviceTypePluginDAOManager.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/dao/DeviceTypePluginDAOManager.java @@ -21,6 +21,7 @@ package org.wso2.carbon.device.mgt.extensions.device.type.deployer.template.dao; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.DeviceManagementConfiguration; +import org.wso2.carbon.device.mgt.extensions.device.type.deployer.exception.DeviceTypeDeployerFileException; import org.wso2.carbon.device.mgt.extensions.device.type.deployer.exception.DeviceTypeMgtPluginException; import javax.naming.Context; @@ -37,19 +38,17 @@ public class DeviceTypePluginDAOManager { private ThreadLocal currentConnection = new ThreadLocal(); private DeviceTypePluginDAO deviceTypePluginDAO; - public DeviceTypePluginDAOManager(DeviceManagementConfiguration deviceManagementConfiguration) { - initDAO(deviceManagementConfiguration); - deviceTypePluginDAO = new DeviceTypePluginDAO(deviceManagementConfiguration); + public DeviceTypePluginDAOManager(String datasourceName, DeviceDAODefinition deviceDAODefinition) { + initDAO(datasourceName); + deviceTypePluginDAO = new DeviceTypePluginDAO(deviceDAODefinition, this); } - public void initDAO(DeviceManagementConfiguration deviceManagementConfiguration) { - String datasourceName = deviceManagementConfiguration.getDeviceManagementConfigRepository() - .getDataSourceConfig().getJndiLookupDefinition().getJndiName(); + public void initDAO(String datasourceName) { try { Context ctx = new InitialContext(); dataSource = (DataSource) ctx.lookup(datasourceName); } catch (NamingException e) { - log.error("Error while looking up the data source: " + datasourceName, e); + throw new DeviceTypeDeployerFileException("Error while looking up the data source: " + datasourceName, e); } } diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/feature/ConfigurationBasedFeatureManager.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/feature/ConfigurationBasedFeatureManager.java index b918a66a8bf..7b9d9fcc6e4 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/feature/ConfigurationBasedFeatureManager.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/feature/ConfigurationBasedFeatureManager.java @@ -4,10 +4,21 @@ import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.Feature; import org.wso2.carbon.device.mgt.common.FeatureManager; +import java.util.ArrayList; import java.util.List; public class ConfigurationBasedFeatureManager implements FeatureManager { - + private List features = new ArrayList<>(); + + public ConfigurationBasedFeatureManager(List features) { + for (org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.Feature feature : features) { + Feature deviceFeature = new Feature(); + deviceFeature.setCode(feature.getCode()); + deviceFeature.setName(feature.getName()); + deviceFeature.setDescription(feature.getDescription()); + this.features.add(deviceFeature); + } + } @Override public boolean addFeature(Feature feature) throws DeviceManagementException { return false; @@ -20,12 +31,18 @@ public class ConfigurationBasedFeatureManager implements FeatureManager { @Override public Feature getFeature(String name) throws DeviceManagementException { - return null; + Feature extractedFeature = null; + for (Feature feature : features) { + if (feature.getName().equalsIgnoreCase(name)) { + extractedFeature = feature; + } + } + return extractedFeature; } @Override public List getFeatures() throws DeviceManagementException { - return null; + return features; } @Override diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/util/DeviceTypeUtils.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/util/DeviceTypeUtils.java index 4ecf0450365..a316f4eaeb0 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/util/DeviceTypeUtils.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/util/DeviceTypeUtils.java @@ -21,10 +21,9 @@ package org.wso2.carbon.device.mgt.extensions.device.type.deployer.template.util import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.common.license.mgt.License; import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.DeviceManagementConfiguration; import org.wso2.carbon.device.mgt.extensions.device.type.deployer.exception.DeviceTypeMgtPluginException; -import org.wso2.carbon.device.mgt.extensions.push.notification.provider.internal.DeviceTypeManagementDataHolder; +import org.wso2.carbon.device.mgt.extensions.device.type.deployer.internal.DeviceTypeManagementDataHolder; import org.wso2.carbon.registry.api.RegistryException; import org.wso2.carbon.registry.api.Resource; import org.wso2.carbon.registry.core.Registry; @@ -78,8 +77,8 @@ public class DeviceTypeUtils { */ public static void setupDeviceManagementSchema(DeviceManagementConfiguration deviceManagementConfiguration) throws DeviceTypeMgtPluginException { - String datasourceName = deviceManagementConfiguration.getDeviceManagementConfigRepository() - .getDataSourceConfig().getJndiLookupDefinition().getJndiName(); + String datasourceName = deviceManagementConfiguration.getManagementRepository().getDataSourceConfiguration() + .getJndiLookupDefinition().getName(); try { Context ctx = new InitialContext(); DataSource dataSource = (DataSource) ctx.lookup(datasourceName); @@ -135,33 +134,4 @@ public class DeviceTypeUtils { } } - public static License getDefaultLicense(String deviceType) { - License license = new License(); - license.setName(deviceType); - license.setLanguage("en_US"); - license.setVersion("1.0.0"); - license.setText("This End User License Agreement (\"Agreement\") is a legal agreement between you (\"You\") " + - "and WSO2, Inc., regarding the enrollment of Your personal mobile device (\"Device\") in SoR's " + - "mobile device management program, and the loading to and removal from Your Device and Your use " + - "of certain applications and any associated software and user documentation, whether provided in " + - "\"online\" or electronic format, used in connection with the operation of or provision of services " + - "to WSO2, Inc., BY SELECTING \"I ACCEPT\" DURING INSTALLATION, YOU ARE ENROLLING YOUR DEVICE, AND " + - "THEREBY AUTHORIZING SOR OR ITS AGENTS TO INSTALL, UPDATE AND REMOVE THE APPS FROM YOUR DEVICE AS " + - "DESCRIBED IN THIS AGREEMENT. YOU ARE ALSO EXPLICITLY ACKNOWLEDGING AND AGREEING THAT (1) THIS IS " + - "A BINDING CONTRACT AND (2) YOU HAVE READ AND AGREE TO THE TERMS OF THIS AGREEMENT.\n" + - "\n" + - "IF YOU DO NOT ACCEPT THESE TERMS, DO NOT ENROLL YOUR DEVICE AND DO NOT PROCEED ANY FURTHER.\n" + - "\n" + - "You agree that: (1) You understand and agree to be bound by the terms and conditions contained " + - "in this Agreement, and (2) You are at least 21 years old and have the legal capacity to enter " + - "into this Agreement as defined by the laws of Your jurisdiction. SoR shall have the right, " + - "without prior notice, to terminate or suspend (i) this Agreement, (ii) the enrollment of Your " + - "Device, or (iii) the functioning of the Apps in the event of a violation of this Agreement or " + - "the cessation of Your relationship with SoR (including termination of Your employment if You are " + - "an employee or expiration or termination of Your applicable franchise or supply agreement if You " + - "are a franchisee of or supplier to the WSO2 WSO2, Inc., system). SoR expressly reserves all " + - "rights not expressly granted herein."); - return license; - } - } diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/util/DeviceTypeConfigUtil.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/util/DeviceTypeConfigUtil.java index 63d4b855db3..54500d28913 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/util/DeviceTypeConfigUtil.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/util/DeviceTypeConfigUtil.java @@ -27,9 +27,6 @@ import java.io.File; public class DeviceTypeConfigUtil { - public static final String CARBON_HOME = "carbon.home"; - public static final String CARBON_HOME_ENTRY = "${carbon.home}"; - public static Document convertToDocument(File file) throws DeviceTypeConfigurationException { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/test/resources/sample.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/test/resources/sample.xml index dd68afbf7ee..9c196630b9d 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/test/resources/sample.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/test/resources/sample.xml @@ -25,46 +25,39 @@ jdbc/SampleDM_DB - - SAMPLE_DEVICE - - SAMPLE_DEVICE_ID - - - booleanColumn - byteColumn - dateColumn - doubleColumn - floatColumn - intColumn - longColumn - shortColumn - - - en_US - 1.0.0 - This is license text - - + + SAMPLE_DEVICE + + SAMPLE_DEVICE_ID + + column1 + column2 + + + en_US + 1.0.0 + This is license text + + + + + FEATURE_CODE_1 + feature name 1 + description + + + FEATURE_CODE_2 + feature name 2 + description + + + + false - - - - - FEATURE_CODE_1 - feature name 1 - description - - - FEATURE_CODE_2 - feature name 2 - description - - @@ -72,6 +65,7 @@ MQTT true + sample.mqtt.adapter tcp://localhost:1883