refactored device type deployer

4.x.x
ayyoob 8 years ago
parent f7729b51ae
commit 4292442aa5

@ -104,6 +104,7 @@
org.wso2.carbon.registry.core, org.wso2.carbon.registry.core,
org.wso2.carbon.registry.core.*, org.wso2.carbon.registry.core.*,
org.wso2.carbon.utils.*, org.wso2.carbon.utils.*,
javax.xml.namespace
</Import-Package> </Import-Package>
<Axis2Deployer>DeviceTypeDeployer</Axis2Deployer> <Axis2Deployer>DeviceTypeDeployer</Axis2Deployer>
</instructions> </instructions>

@ -29,7 +29,7 @@ import org.osgi.framework.ServiceRegistration;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; 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.DeviceTypeConfiguration;
import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.exception.DeviceTypeConfigurationException; import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.exception.DeviceTypeConfigurationException;
import org.wso2.carbon.device.mgt.extensions.device.type.deployer.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.DeviceTypeConfigIdentifier;
@ -72,16 +72,16 @@ public class DeviceTypeDeployer extends AbstractDeployer {
@Override @Override
public void deploy(DeploymentFileData deploymentFileData) throws DeploymentException { public void deploy(DeploymentFileData deploymentFileData) throws DeploymentException {
try { try {
DeviceManagementConfiguration deviceManagementConfiguration = getDeviceTypeConfiguration( DeviceTypeConfiguration deviceTypeConfiguration = getDeviceTypeConfiguration(
deploymentFileData.getFile().getAbsoluteFile()); deploymentFileData.getFile().getAbsoluteFile());
String deviceType = deviceManagementConfiguration.getDeviceType(); String deviceType = deviceTypeConfiguration.getName();
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true); String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true);
if (deviceType != null && !deviceType.isEmpty() && tenantDomain != null if (deviceType != null && !deviceType.isEmpty() && tenantDomain != null
&& !tenantDomain.isEmpty()) { && !tenantDomain.isEmpty()) {
DeviceTypeConfigIdentifier deviceTypeConfigIdentifier = new DeviceTypeConfigIdentifier(deviceType, DeviceTypeConfigIdentifier deviceTypeConfigIdentifier = new DeviceTypeConfigIdentifier(deviceType,
tenantDomain); tenantDomain);
ServiceRegistration serviceRegistration = registerDeviceType(deviceTypeConfigIdentifier, ServiceRegistration serviceRegistration = registerDeviceType(deviceTypeConfigIdentifier,
deviceManagementConfiguration); deviceTypeConfiguration);
this.deviceTypeServiceRegistrations.put(deploymentFileData.getAbsolutePath(), serviceRegistration); this.deviceTypeServiceRegistrations.put(deploymentFileData.getAbsolutePath(), serviceRegistration);
this.deviceTypeConfigurationDataMap.put(deploymentFileData.getAbsolutePath(), this.deviceTypeConfigurationDataMap.put(deploymentFileData.getAbsolutePath(),
deviceTypeConfigIdentifier); deviceTypeConfigIdentifier);
@ -102,16 +102,16 @@ public class DeviceTypeDeployer extends AbstractDeployer {
+ deviceTypeConfigIdentifier.getTenantDomain()); + deviceTypeConfigIdentifier.getTenantDomain());
} }
private DeviceManagementConfiguration getDeviceTypeConfiguration(File configurationFile) private DeviceTypeConfiguration getDeviceTypeConfiguration(File configurationFile)
throws DeviceTypeConfigurationException { throws DeviceTypeConfigurationException {
try { try {
Document doc = DeviceTypeConfigUtil.convertToDocument(configurationFile); Document doc = DeviceTypeConfigUtil.convertToDocument(configurationFile);
/* Un-marshaling Webapp Authenticator configuration */ /* Un-marshaling Webapp Authenticator configuration */
JAXBContext ctx = JAXBContext.newInstance(DeviceManagementConfiguration.class); JAXBContext ctx = JAXBContext.newInstance(DeviceTypeConfiguration.class);
Unmarshaller unmarshaller = ctx.createUnmarshaller(); Unmarshaller unmarshaller = ctx.createUnmarshaller();
//unmarshaller.setSchema(getSchema()); //unmarshaller.setSchema(getSchema());
return (DeviceManagementConfiguration) unmarshaller.unmarshal(doc); return (DeviceTypeConfiguration) unmarshaller.unmarshal(doc);
} catch (JAXBException e) { } catch (JAXBException e) {
throw new DeviceTypeConfigurationException("Error occurred while un-marshalling the file " + throw new DeviceTypeConfigurationException("Error occurred while un-marshalling the file " +
configurationFile.getAbsolutePath(), e); configurationFile.getAbsolutePath(), e);
@ -119,7 +119,7 @@ public class DeviceTypeDeployer extends AbstractDeployer {
} }
private ServiceRegistration registerDeviceType(DeviceTypeConfigIdentifier deviceTypeConfigIdentifier, private ServiceRegistration registerDeviceType(DeviceTypeConfigIdentifier deviceTypeConfigIdentifier,
DeviceManagementConfiguration deviceManagementConfiguration) { DeviceTypeConfiguration deviceManagementConfiguration) {
DeviceTypeManagerService deviceTypeManagerService = new DeviceTypeManagerService(deviceTypeConfigIdentifier, DeviceTypeManagerService deviceTypeManagerService = new DeviceTypeManagerService(deviceTypeConfigIdentifier,
deviceManagementConfiguration); deviceManagementConfiguration);
BundleContext bundleContext = DeviceTypeManagementDataHolder.getInstance().getBundleContext(); BundleContext bundleContext = DeviceTypeManagementDataHolder.getInstance().getBundleContext();

@ -36,7 +36,14 @@ import javax.xml.bind.annotation.XmlType;
* &lt;complexContent> * &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence> * &lt;sequence>
* &lt;element name="Attribute" type="{}Attribute" maxOccurs="unbounded" minOccurs="0"/> * &lt;element name="Attribute" maxOccurs="unbounded" minOccurs="0">
* &lt;simpleType>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}string">
* &lt;enumeration value="column1"/>
* &lt;enumeration value="column2"/>
* &lt;/restriction>
* &lt;/simpleType>
* &lt;/element>
* &lt;/sequence> * &lt;/sequence>
* &lt;/restriction> * &lt;/restriction>
* &lt;/complexContent> * &lt;/complexContent>
@ -52,7 +59,7 @@ import javax.xml.bind.annotation.XmlType;
public class Attributes { public class Attributes {
@XmlElement(name = "Attribute") @XmlElement(name = "Attribute")
protected List<Attribute> attribute; protected List<String> attribute;
/** /**
* Gets the value of the attribute property. * Gets the value of the attribute property.
@ -72,13 +79,13 @@ public class Attributes {
* *
* <p> * <p>
* Objects of the following type(s) are allowed in the list * Objects of the following type(s) are allowed in the list
* {@link Attribute } * {@link String }
* *
* *
*/ */
public List<Attribute> getAttribute() { public List<String> getAttribute() {
if (attribute == null) { if (attribute == null) {
attribute = new ArrayList<Attribute>(); attribute = new ArrayList<String>();
} }
return this.attribute; return this.attribute;
} }

@ -27,12 +27,12 @@ import javax.xml.bind.annotation.XmlType;
/** /**
* <p>Java class for Properties complex type. * <p>Java class for ConfigProperties complex type.
* *
* <p>The following schema fragment specifies the expected content contained within this class. * <p>The following schema fragment specifies the expected content contained within this class.
* *
* <pre> * <pre>
* &lt;complexType name="Properties"> * &lt;complexType name="ConfigProperties">
* &lt;complexContent> * &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence> * &lt;sequence>
@ -46,10 +46,10 @@ import javax.xml.bind.annotation.XmlType;
* *
*/ */
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Properties", propOrder = { @XmlType(name = "ConfigProperties", propOrder = {
"property" "property"
}) })
public class Properties { public class ConfigProperties {
@XmlElement(name = "Property") @XmlElement(name = "Property")
protected List<Property> property; protected List<Property> property;

@ -0,0 +1,107 @@
/*
* 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.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for DataSource complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="DataSource">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="jndiConfig" type="{}jndiConfig"/>
* &lt;element name="tableConfig" type="{}tableConfig"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "DataSource", propOrder = {
"jndiConfig",
"tableConfig"
})
public class DataSource {
@XmlElement(required = true)
protected JndiConfig jndiConfig;
@XmlElement(required = true)
protected TableConfig tableConfig;
/**
* Gets the value of the jndiConfig property.
*
* @return
* possible object is
* {@link JndiConfig }
*
*/
public JndiConfig getJndiConfig() {
return jndiConfig;
}
/**
* Sets the value of the jndiConfig property.
*
* @param value
* allowed object is
* {@link JndiConfig }
*
*/
public void setJndiConfig(JndiConfig value) {
this.jndiConfig = value;
}
/**
* Gets the value of the tableConfig property.
*
* @return
* possible object is
* {@link TableConfig }
*
*/
public TableConfig getTableConfig() {
return tableConfig;
}
/**
* Sets the value of the tableConfig property.
*
* @param value
* allowed object is
* {@link TableConfig }
*
*/
public void setTableConfig(TableConfig value) {
this.tableConfig = value;
}
}

@ -26,15 +26,15 @@ import javax.xml.bind.annotation.XmlValue;
/** /**
* <p>Java class for Attribute complex type. * <p>Java class for DeviceDetails complex type.
* *
* <p>The following schema fragment specifies the expected content contained within this class. * <p>The following schema fragment specifies the expected content contained within this class.
* *
* <pre> * <pre>
* &lt;complexType name="Attribute"> * &lt;complexType name="DeviceDetails">
* &lt;simpleContent> * &lt;simpleContent>
* &lt;extension base="&lt;http://www.w3.org/2001/XMLSchema>string"> * &lt;extension base="&lt;http://www.w3.org/2001/XMLSchema>string">
* &lt;attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" /> * &lt;attribute name="table-id" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;/extension> * &lt;/extension>
* &lt;/simpleContent> * &lt;/simpleContent>
* &lt;/complexType> * &lt;/complexType>
@ -43,11 +43,15 @@ import javax.xml.bind.annotation.XmlValue;
* *
*/ */
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class Attribute { @XmlType(name = "DeviceDetails", propOrder = {
"value"
})
public class DeviceDetails {
@XmlValue @XmlValue
protected String value; protected String value;
@XmlAttribute(name = "table-id")
protected String tableId;
/** /**
* Gets the value of the value property. * Gets the value of the value property.
@ -73,4 +77,28 @@ public class Attribute {
this.value = value; this.value = value;
} }
/**
* Gets the value of the tableId property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getTableId() {
return tableId;
}
/**
* Sets the value of the tableId property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setTableId(String value) {
this.tableId = value;
}
} }

@ -1,141 +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.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;
/**
* <p>Java class for DeviceManagementConfiguration complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="DeviceManagementConfiguration">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="Device" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;element name="ManagementRepository" type="{}ManagementRepository"/>
* &lt;element name="PushNotificationConfiguration" type="{}PushNotificationConfiguration"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
//@XmlType(name = "DeviceManagementConfiguration", propOrder = {
// "deviceType",
// "managementRepository",
// "pushNotificationConfiguration"
//})
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "DeviceManagementConfiguration")
public class 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;
private DeviceManagementConfiguration() {
}
/**
* Gets the value of the device property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getDeviceType() {
return deviceType;
}
/**
* Sets the value of the device property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setDeviceType(String value) {
this.deviceType = value;
}
/**
* Gets the value of the managementRepository property.
*
* @return
* possible object is
* {@link ManagementRepository }
*
*/
public ManagementRepository getManagementRepository() {
return managementRepository;
}
/**
* Sets the value of the managementRepository property.
*
* @param value
* allowed object is
* {@link ManagementRepository }
*
*/
public void setManagementRepository(ManagementRepository value) {
this.managementRepository = value;
}
/**
* Gets the value of the pushNotificationConfiguration property.
*
* @return
* possible object is
* {@link PushNotificationConfiguration }
*
*/
public PushNotificationConfiguration getPushNotificationConfiguration() {
return pushNotificationConfiguration;
}
/**
* Sets the value of the pushNotificationConfiguration property.
*
* @param value
* allowed object is
* {@link PushNotificationConfiguration }
*
*/
public void setPushNotificationConfiguration(PushNotificationConfiguration value) {
this.pushNotificationConfiguration = value;
}
}

@ -0,0 +1,240 @@
/*
* 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.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
/**
* <p>Java class for DeviceTypeConfiguration complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="DeviceTypeConfiguration">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="DeviceDetails" type="{}DeviceDetails"/>
* &lt;element name="Features" type="{}Features"/>
* &lt;element name="ProvisioningConfig" type="{}ProvisioningConfig"/>
* &lt;element name="PushNotificationProvider" type="{}PushNotificationProvider"/>
* &lt;element name="License" type="{}License"/>
* &lt;element name="DataSource" type="{}DataSource"/>
* &lt;/sequence>
* &lt;attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "DeviceTypeConfiguration")
public class DeviceTypeConfiguration {
@XmlElement(name = "DeviceDetails", required = true)
protected DeviceDetails deviceDetails;
@XmlElement(name = "Features", required = true)
protected Features features;
@XmlElement(name = "ProvisioningConfig", required = true)
protected ProvisioningConfig provisioningConfig;
@XmlElement(name = "PushNotificationProvider", required = true)
protected PushNotificationProvider pushNotificationProvider;
@XmlElement(name = "License", required = true)
protected License license;
@XmlElement(name = "DataSource", required = true)
protected DataSource dataSource;
@XmlAttribute(name = "name")
protected String name;
/**
* Gets the value of the deviceDetails property.
*
* @return
* possible object is
* {@link DeviceDetails }
*
*/
public DeviceDetails getDeviceDetails() {
return deviceDetails;
}
/**
* Sets the value of the deviceDetails property.
*
* @param value
* allowed object is
* {@link DeviceDetails }
*
*/
public void setDeviceDetails(DeviceDetails value) {
this.deviceDetails = 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;
}
/**
* 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;
}
/**
* Gets the value of the pushNotificationProvider property.
*
* @return
* possible object is
* {@link PushNotificationProvider }
*
*/
public PushNotificationProvider getPushNotificationProvider() {
return pushNotificationProvider;
}
/**
* Sets the value of the pushNotificationProvider property.
*
* @param value
* allowed object is
* {@link PushNotificationProvider }
*
*/
public void setPushNotificationProvider(PushNotificationProvider value) {
this.pushNotificationProvider = 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 dataSource property.
*
* @return
* possible object is
* {@link DataSource }
*
*/
public DataSource getDataSource() {
return dataSource;
}
/**
* Sets the value of the dataSource property.
*
* @param value
* allowed object is
* {@link DataSource }
*
*/
public void setDataSource(DataSource value) {
this.dataSource = 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;
}
}

@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.extensions.device.type.deployer.config;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;
@ -34,10 +35,11 @@ import javax.xml.bind.annotation.XmlType;
* &lt;complexContent> * &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence> * &lt;sequence>
* &lt;element name="Code" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;element name="Name" type="{http://www.w3.org/2001/XMLSchema}string"/> * &lt;element name="Name" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;element name="Description" type="{http://www.w3.org/2001/XMLSchema}string"/> * &lt;element name="Description" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;element name="Operation" type="{}Operation"/>
* &lt;/sequence> * &lt;/sequence>
* &lt;attribute name="code" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;/restriction> * &lt;/restriction>
* &lt;/complexContent> * &lt;/complexContent>
* &lt;/complexType> * &lt;/complexType>
@ -47,89 +49,115 @@ import javax.xml.bind.annotation.XmlType;
*/ */
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Feature", propOrder = { @XmlType(name = "Feature", propOrder = {
"code",
"name", "name",
"description" "description",
"operation"
}) })
public class Feature { public class Feature {
@XmlElement(name = "Code", required = true)
protected String code;
@XmlElement(name = "Name", required = true) @XmlElement(name = "Name", required = true)
protected String name; protected String name;
@XmlElement(name = "Description", required = true) @XmlElement(name = "Description", required = true)
protected String description; protected String description;
@XmlElement(name = "Operation", required = true)
protected Operation operation;
@XmlAttribute(name = "code")
protected String code;
/** /**
* Gets the value of the code property. * Gets the value of the name property.
* *
* @return * @return
* possible object is * possible object is
* {@link String } * {@link String }
* *
*/ */
public String getCode() { public String getName() {
return code; return name;
} }
/** /**
* Sets the value of the code property. * Sets the value of the name property.
* *
* @param value * @param value
* allowed object is * allowed object is
* {@link String } * {@link String }
* *
*/ */
public void setCode(String value) { public void setName(String value) {
this.code = value; this.name = value;
} }
/** /**
* Gets the value of the name property. * Gets the value of the description property.
* *
* @return * @return
* possible object is * possible object is
* {@link String } * {@link String }
* *
*/ */
public String getName() { public String getDescription() {
return name; return description;
} }
/** /**
* Sets the value of the name property. * Sets the value of the description property.
* *
* @param value * @param value
* allowed object is * allowed object is
* {@link String } * {@link String }
* *
*/ */
public void setName(String value) { public void setDescription(String value) {
this.name = value; this.description = value;
} }
/** /**
* Gets the value of the description property. * Gets the value of the operation property.
*
* @return
* possible object is
* {@link Operation }
*
*/
public Operation getOperation() {
return operation;
}
/**
* Sets the value of the operation property.
*
* @param value
* allowed object is
* {@link Operation }
*
*/
public void setOperation(Operation value) {
this.operation = value;
}
/**
* Gets the value of the code property.
* *
* @return * @return
* possible object is * possible object is
* {@link String } * {@link String }
* *
*/ */
public String getDescription() { public String getCode() {
return description; return code;
} }
/** /**
* Sets the value of the description property. * Sets the value of the code property.
* *
* @param value * @param value
* allowed object is * allowed object is
* {@link String } * {@link String }
* *
*/ */
public void setDescription(String value) { public void setCode(String value) {
this.description = value; this.code = value;
} }
} }

@ -18,13 +18,12 @@
*/ */
package org.wso2.carbon.device.mgt.extensions.device.type.deployer.config; 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.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;
import java.util.ArrayList;
import java.util.List;
/** /**
@ -37,9 +36,8 @@ import javax.xml.bind.annotation.XmlType;
* &lt;complexContent> * &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence> * &lt;sequence>
* &lt;element name="Feature" type="{}Feature" maxOccurs="unbounded" minOccurs="0"/> * &lt;element name="Feature" type="{}Feature"/>
* &lt;/sequence> * &lt;/sequence>
* &lt;attribute name="generate" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;/restriction> * &lt;/restriction>
* &lt;/complexContent> * &lt;/complexContent>
* &lt;/complexType> * &lt;/complexType>
@ -55,30 +53,14 @@ public class Features {
@XmlElement(name = "Feature") @XmlElement(name = "Feature")
protected List<Feature> feature; protected List<Feature> feature;
@XmlAttribute(name = "generate")
protected boolean generate;
/** /**
* Gets the value of the feature property. * Gets the value of the feature property.
* *
* <p> * @return
* This accessor method returns a reference to the live list, * possible object is
* 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 <CODE>set</CODE> method for the feature property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getFeature().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Feature } * {@link Feature }
* *
*
*/ */
public List<Feature> getFeature() { public List<Feature> getFeature() {
if (feature == null) { if (feature == null) {
@ -87,28 +69,4 @@ public class Features {
return this.feature; 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;
}
} }

@ -22,19 +22,21 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;
import java.util.ArrayList;
import java.util.List;
/** /**
* <p>Java class for DataSourceConfiguration complex type. * <p>Java class for FormParameters complex type.
* *
* <p>The following schema fragment specifies the expected content contained within this class. * <p>The following schema fragment specifies the expected content contained within this class.
* *
* <pre> * <pre>
* &lt;complexType name="DataSourceConfiguration"> * &lt;complexType name="FormParameters">
* &lt;complexContent> * &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence> * &lt;sequence>
* &lt;element name="JndiLookupDefinition" type="{}JndiLookupDefinition"/> * &lt;element name="Parameter" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;/sequence> * &lt;/sequence>
* &lt;/restriction> * &lt;/restriction>
* &lt;/complexContent> * &lt;/complexContent>
@ -44,36 +46,19 @@ import javax.xml.bind.annotation.XmlType;
* *
*/ */
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "DataSourceConfiguration", propOrder = { @XmlType(name = "FormParameters", propOrder = {
"jndiLookupDefinition" "parameter"
}) })
public class DataSourceConfiguration { public class FormParameters {
@XmlElement(name = "JndiLookupDefinition", required = true) @XmlElement(name = "Parameter")
protected JndiLookupDefinition jndiLookupDefinition; protected List<String> parameter;
/** public List<String> getParameter() {
* Gets the value of the jndiLookupDefinition property. if (parameter == null) {
* parameter = new ArrayList<String>();
* @return
* possible object is
* {@link JndiLookupDefinition }
*
*/
public JndiLookupDefinition getJndiLookupDefinition() {
return jndiLookupDefinition;
} }
return this.parameter;
/**
* Sets the value of the jndiLookupDefinition property.
*
* @param value
* allowed object is
* {@link JndiLookupDefinition }
*
*/
public void setJndiLookupDefinition(JndiLookupDefinition value) {
this.jndiLookupDefinition = value;
} }
} }

@ -25,16 +25,16 @@ import javax.xml.bind.annotation.XmlType;
/** /**
* <p>Java class for JndiLookupDefinition complex type. * <p>Java class for jndiConfig complex type.
* *
* <p>The following schema fragment specifies the expected content contained within this class. * <p>The following schema fragment specifies the expected content contained within this class.
* *
* <pre> * <pre>
* &lt;complexType name="JndiLookupDefinition"> * &lt;complexType name="jndiConfig">
* &lt;complexContent> * &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence> * &lt;sequence>
* &lt;element name="Name" type="{http://www.w3.org/2001/XMLSchema}string"/> * &lt;element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;/sequence> * &lt;/sequence>
* &lt;/restriction> * &lt;/restriction>
* &lt;/complexContent> * &lt;/complexContent>
@ -44,12 +44,12 @@ import javax.xml.bind.annotation.XmlType;
* *
*/ */
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "JndiLookupDefinition", propOrder = { @XmlType(name = "jndiConfig", propOrder = {
"name" "name"
}) })
public class JndiLookupDefinition { public class JndiConfig {
@XmlElement(name = "Name", required = true) @XmlElement(required = true)
protected String name; protected String name;
/** /**

@ -1,135 +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.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for ManagementRepository complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="ManagementRepository">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="DataSourceConfiguration" type="{}DataSourceConfiguration"/>
* &lt;element name="DeviceDefinition" type="{}DeviceDefinition"/>
* &lt;element name="ProvisioningConfig" type="{}ProvisioningConfig"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@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;
}
}

@ -0,0 +1,198 @@
/*
* 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.JAXBElement;
import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.bind.annotation.XmlRegistry;
import javax.xml.namespace.QName;
/**
* This object contains factory methods for each
* Java content interface and Java element interface
* generated in the org.wso2.carbon package.
* <p>An ObjectFactory allows you to programatically
* construct new instances of the Java representation
* for XML content. The Java representation of XML
* content can consist of schema derived interfaces
* and classes representing the binding of schema
* type definitions, element declarations and model
* groups. Factory methods for each of these are
* provided in this class.
*
*/
@XmlRegistry
public class ObjectFactory {
private final static QName _DeviceTypeConfiguration_QNAME = new QName("", "DeviceTypeConfiguration");
/**
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.wso2.carbon
*
*/
public ObjectFactory() {
}
/**
* Create an instance of {@link DeviceTypeConfiguration }
*
*/
public DeviceTypeConfiguration createDeviceTypeConfiguration() {
return new DeviceTypeConfiguration();
}
/**
* Create an instance of {@link Operation }
*
*/
public Operation createOperation() {
return new Operation();
}
/**
* Create an instance of {@link Attributes }
*
*/
public Attributes createAttributes() {
return new Attributes();
}
/**
* Create an instance of {@link ProvisioningConfig }
*
*/
public ProvisioningConfig createProvisioningConfig() {
return new ProvisioningConfig();
}
/**
* Create an instance of {@link TableConfig }
*
*/
public TableConfig createTableConfig() {
return new TableConfig();
}
/**
* Create an instance of {@link Table }
*
*/
public Table createTable() {
return new Table();
}
/**
* Create an instance of {@link Property }
*
*/
public Property createProperty() {
return new Property();
}
/**
* Create an instance of {@link JndiConfig }
*
*/
public JndiConfig createJndiConfig() {
return new JndiConfig();
}
/**
* Create an instance of {@link FormParameters }
*
*/
public FormParameters createFormParameters() {
return new FormParameters();
}
/**
* Create an instance of {@link Features }
*
*/
public Features createFeatures() {
return new Features();
}
/**
* Create an instance of {@link Feature }
*
*/
public Feature createFeature() {
return new Feature();
}
/**
* Create an instance of {@link PushNotificationProvider }
*
*/
public PushNotificationProvider createPushNotificationProvider() {
return new PushNotificationProvider();
}
/**
* Create an instance of {@link DataSource }
*
*/
public DataSource createDataSource() {
return new DataSource();
}
/**
* Create an instance of {@link ConfigProperties }
*
*/
public ConfigProperties createConfigProperties() {
return new ConfigProperties();
}
/**
* Create an instance of {@link License }
*
*/
public License createLicense() {
return new License();
}
/**
* Create an instance of {@link DeviceDetails }
*
*/
public DeviceDetails createDeviceDetails() {
return new DeviceDetails();
}
/**
* Create an instance of {@link QueryParameters }
*
*/
public QueryParameters createQueryParameters() {
return new QueryParameters();
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link DeviceTypeConfiguration }{@code >}}
*
*/
@XmlElementDecl(namespace = "", name = "DeviceTypeConfiguration")
public JAXBElement<DeviceTypeConfiguration> createDeviceTypeConfiguration(DeviceTypeConfiguration value) {
return new JAXBElement<DeviceTypeConfiguration>(_DeviceTypeConfiguration_QNAME, DeviceTypeConfiguration.class, null, value);
}
}

@ -0,0 +1,162 @@
/*
* 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.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;
/**
* <p>Java class for Operation complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="Operation">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="QueryParameters" type="{}QueryParameters"/>
* &lt;element name="FormParameters" type="{}FormParameters"/>
* &lt;/sequence>
* &lt;attribute name="context" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;attribute name="method" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Operation", propOrder = {
"queryParameters",
"formParameters"
})
public class Operation {
@XmlElement(name = "QueryParameters")
protected QueryParameters queryParameters;
@XmlElement(name = "FormParameters")
protected FormParameters formParameters;
@XmlAttribute(name = "context")
protected String context;
@XmlAttribute(name = "method")
protected String method;
/**
* Gets the value of the queryParameters property.
*
* @return
* possible object is
* {@link QueryParameters }
*
*/
public QueryParameters getQueryParameters() {
return queryParameters;
}
/**
* Sets the value of the queryParameters property.
*
* @param value
* allowed object is
* {@link QueryParameters }
*
*/
public void setQueryParameters(QueryParameters value) {
this.queryParameters = value;
}
/**
* Gets the value of the formParameters property.
*
* @return
* possible object is
* {@link FormParameters }
*
*/
public FormParameters getFormParameters() {
return formParameters;
}
/**
* Sets the value of the formParameters property.
*
* @param value
* allowed object is
* {@link FormParameters }
*
*/
public void setFormParameters(FormParameters value) {
this.formParameters = value;
}
/**
* Gets the value of the context property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getContext() {
return context;
}
/**
* Sets the value of the context property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setContext(String value) {
this.context = value;
}
/**
* Gets the value of the method property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getMethod() {
return method;
}
/**
* Sets the value of the method property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setMethod(String value) {
this.method = value;
}
}

@ -34,7 +34,7 @@ import javax.xml.bind.annotation.XmlType;
* &lt;complexContent> * &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence> * &lt;sequence>
* &lt;element name="SharedWithAllTenants" type="{http://www.w3.org/2001/XMLSchema}string"/> * &lt;element name="SharedWithAllTenants" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
* &lt;/sequence> * &lt;/sequence>
* &lt;/restriction> * &lt;/restriction>
* &lt;/complexContent> * &lt;/complexContent>
@ -49,16 +49,12 @@ import javax.xml.bind.annotation.XmlType;
}) })
public class ProvisioningConfig { public class ProvisioningConfig {
@XmlElement(name = "SharedWithAllTenants", required = true) @XmlElement(name = "SharedWithAllTenants")
protected boolean sharedWithAllTenants; protected boolean sharedWithAllTenants;
/** /**
* Gets the value of the sharedWithAllTenants property. * Gets the value of the sharedWithAllTenants property.
* *
* @return
* possible object is
* {@link boolean }
*
*/ */
public boolean isSharedWithAllTenants() { public boolean isSharedWithAllTenants() {
return sharedWithAllTenants; return sharedWithAllTenants;
@ -67,10 +63,6 @@ public class ProvisioningConfig {
/** /**
* Sets the value of the sharedWithAllTenants property. * Sets the value of the sharedWithAllTenants property.
* *
* @param value
* allowed object is
* {@link String }
*
*/ */
public void setSharedWithAllTenants(boolean value) { public void setSharedWithAllTenants(boolean value) {
this.sharedWithAllTenants = value; this.sharedWithAllTenants = value;

@ -20,24 +20,25 @@ package org.wso2.carbon.device.mgt.extensions.device.type.deployer.config;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;
/** /**
* <p>Java class for PushNotificationConfiguration complex type. * <p>Java class for PushNotificationProvider complex type.
* *
* <p>The following schema fragment specifies the expected content contained within this class. * <p>The following schema fragment specifies the expected content contained within this class.
* *
* <pre> * <pre>
* &lt;complexType name="PushNotificationConfiguration"> * &lt;complexType name="PushNotificationProvider">
* &lt;complexContent> * &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence> * &lt;sequence>
* &lt;element name="PushNotificationProvider" type="{http://www.w3.org/2001/XMLSchema}string"/> * &lt;element name="FileBasedProperties" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
* &lt;element name="FileBasedProperties" type="{http://www.w3.org/2001/XMLSchema}string"/> * &lt;element name="ConfigProperties" type="{}ConfigProperties"/>
* &lt;element name="Properties" type="{}Properties"/>
* &lt;/sequence> * &lt;/sequence>
* &lt;attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;/restriction> * &lt;/restriction>
* &lt;/complexContent> * &lt;/complexContent>
* &lt;/complexType> * &lt;/complexType>
@ -46,90 +47,81 @@ import javax.xml.bind.annotation.XmlType;
* *
*/ */
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "PushNotificationConfiguration", propOrder = { @XmlType(name = "PushNotificationProvider", propOrder = {
"pushNotificationProvider",
"fileBasedProperties", "fileBasedProperties",
"properties" "configProperties"
}) })
public class PushNotificationConfiguration { public class PushNotificationProvider {
@XmlElement(name = "PushNotificationProvider", required = true) @XmlElement(name = "FileBasedProperties")
protected String pushNotificationProvider;
@XmlElement(name = "FileBasedProperties", required = true)
protected boolean fileBasedProperties; protected boolean fileBasedProperties;
@XmlElement(name = "Properties", required = true) @XmlElement(name = "ConfigProperties", required = true)
protected Properties properties; protected ConfigProperties configProperties;
@XmlAttribute(name = "type")
protected String type;
/** /**
* Gets the value of the pushNotificationProvider property. * Gets the value of the fileBasedProperties property.
*
* @return
* possible object is
* {@link String }
* *
*/ */
public String getPushNotificationProvider() { public boolean isFileBasedProperties() {
return pushNotificationProvider; return fileBasedProperties;
} }
/** /**
* Sets the value of the pushNotificationProvider property. * Sets the value of the fileBasedProperties property.
*
* @param value
* allowed object is
* {@link String }
* *
*/ */
public void setPushNotificationProvider(String value) { public void setFileBasedProperties(boolean value) {
this.pushNotificationProvider = value; this.fileBasedProperties = value;
} }
/** /**
* Gets the value of the fileBasedProperties property. * Gets the value of the configProperties property.
* *
* @return * @return
* possible object is * possible object is
* {@link String } * {@link ConfigProperties }
* *
*/ */
public boolean isFileBasedProperties() { public ConfigProperties getConfigProperties() {
return fileBasedProperties; return configProperties;
} }
/** /**
* Sets the value of the fileBasedProperties property. * Sets the value of the configProperties property.
* *
* @param value * @param value
* allowed object is * allowed object is
* {@link String } * {@link ConfigProperties }
* *
*/ */
public void setFileBasedProperties(boolean value) { public void setConfigProperties(ConfigProperties value) {
this.fileBasedProperties = value; this.configProperties = value;
} }
/** /**
* Gets the value of the properties property. * Gets the value of the type property.
* *
* @return * @return
* possible object is * possible object is
* {@link Properties } * {@link String }
* *
*/ */
public Properties getProperties() { public String getType() {
return properties; return type;
} }
/** /**
* Sets the value of the properties property. * Sets the value of the type property.
* *
* @param value * @param value
* allowed object is * allowed object is
* {@link Properties } * {@link String }
* *
*/ */
public void setProperties(Properties value) { public void setType(String value) {
this.properties = value; this.type = value;
} }
} }

@ -0,0 +1,64 @@
/*
* 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.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import java.util.ArrayList;
import java.util.List;
/**
* <p>Java class for QueryParameters complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="QueryParameters">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="Parameter" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "QueryParameters", propOrder = {
"parameter"
})
public class QueryParameters {
@XmlElement(name = "Parameter")
protected List<String> parameter;
public List<String> getParameter() {
if (parameter == null) {
parameter = new ArrayList<String>();
}
return this.parameter;
}
}

@ -20,26 +20,25 @@ package org.wso2.carbon.device.mgt.extensions.device.type.deployer.config;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;
/** /**
* <p>Java class for DeviceDefinition complex type. * <p>Java class for Table complex type.
* *
* <p>The following schema fragment specifies the expected content contained within this class. * <p>The following schema fragment specifies the expected content contained within this class.
* *
* <pre> * <pre>
* &lt;complexType name="DeviceDefinition"> * &lt;complexType name="Table">
* &lt;complexContent> * &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence> * &lt;sequence>
* &lt;element name="TableName" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;element name="PrimaryKey" type="{http://www.w3.org/2001/XMLSchema}string"/> * &lt;element name="PrimaryKey" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;element name="Attributes" type="{}Attributes"/> * &lt;element name="Attributes" type="{}Attributes"/>
* &lt;element name="License" type="{}License"/>
* &lt;element name="Features" type="{}Features"/>
* &lt;/sequence> * &lt;/sequence>
* &lt;attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;/restriction> * &lt;/restriction>
* &lt;/complexContent> * &lt;/complexContent>
* &lt;/complexType> * &lt;/complexType>
@ -48,49 +47,18 @@ import javax.xml.bind.annotation.XmlType;
* *
*/ */
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "DeviceDefinition", propOrder = { @XmlType(name = "Table", propOrder = {
"tableName",
"primaryKey", "primaryKey",
"attributes", "attributes"
"license",
"features"
}) })
public class DeviceDefinition { public class Table {
@XmlElement(name = "TableName", required = true)
protected String tableName;
@XmlElement(name = "PrimaryKey", required = true) @XmlElement(name = "PrimaryKey", required = true)
protected String primaryKey; protected String primaryKey;
@XmlElement(name = "Attributes", required = true) @XmlElement(name = "Attributes", required = true)
protected Attributes attributes; protected Attributes attributes;
@XmlElement(name = "License", required = true) @XmlAttribute(name = "name")
protected License license; protected String name;
@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. * Gets the value of the primaryKey property.
@ -141,51 +109,27 @@ public class DeviceDefinition {
} }
/** /**
* Gets the value of the license property. * Gets the value of the name property.
* *
* @return * @return
* possible object is * possible object is
* {@link License } * {@link String }
*
*/
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() { public String getName() {
return features; return name;
} }
/** /**
* Sets the value of the features property. * Sets the value of the name property.
* *
* @param value * @param value
* allowed object is * allowed object is
* {@link Features } * {@link String }
* *
*/ */
public void setFeatures(Features value) { public void setName(String value) {
this.features = value; this.name = value;
} }
} }

@ -0,0 +1,86 @@
/*
* 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 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;
/**
* <p>Java class for tableConfig complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="tableConfig">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="Table" type="{}Table" maxOccurs="unbounded" minOccurs="0"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "tableConfig", propOrder = {
"table"
})
public class TableConfig {
@XmlElement(name = "Table")
protected List<Table> table;
/**
* Gets the value of the table property.
*
* <p>
* 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 <CODE>set</CODE> method for the table property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getTable().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Table }
*
*
*/
public List<Table> getTable() {
if (table == null) {
table = new ArrayList<Table>();
}
return this.table;
}
}

@ -20,28 +20,25 @@ package org.wso2.carbon.device.mgt.extensions.device.type.deployer.template;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.DeviceManager; import org.wso2.carbon.device.mgt.common.DeviceManager;
import org.wso2.carbon.device.mgt.common.DeviceTypeIdentifier;
import org.wso2.carbon.device.mgt.common.EnrolmentInfo; import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
import org.wso2.carbon.device.mgt.common.FeatureManager; import org.wso2.carbon.device.mgt.common.FeatureManager;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
import org.wso2.carbon.device.mgt.common.license.mgt.License; import org.wso2.carbon.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.LicenseManagementException;
import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager; import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager;
import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.DeviceDetails;
import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.DeviceTypeConfiguration;
import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.Table;
import org.wso2.carbon.device.mgt.extensions.device.type.deployer.util.DeviceTypePluginConstants; import org.wso2.carbon.device.mgt.extensions.device.type.deployer.util.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.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.DeviceTypeDeployerFileException;
import org.wso2.carbon.device.mgt.extensions.device.type.deployer.exception.DeviceTypeMgtPluginException; 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.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.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.feature.ConfigurationBasedFeatureManager;
import org.wso2.carbon.device.mgt.extensions.device.type.deployer.template.util.DeviceTypeUtils; 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.device.mgt.extensions.license.mgt.registry.RegistryBasedLicenseManager;
@ -71,44 +68,25 @@ public class DeviceTypeManager implements DeviceManager {
private FeatureManager featureManager; private FeatureManager featureManager;
public DeviceTypeManager(DeviceTypeConfigIdentifier deviceTypeConfigIdentifier, public DeviceTypeManager(DeviceTypeConfigIdentifier deviceTypeConfigIdentifier,
DeviceManagementConfiguration deviceManagementConfiguration) { DeviceTypeConfiguration deviceTypeConfiguration) {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
boolean isSharedWithAllTenants = deviceManagementConfiguration.getManagementRepository().getProvisioningConfig()
.isSharedWithAllTenants();
DeviceTypeIdentifier deviceTypeIdentifier;
deviceType = deviceTypeConfigIdentifier.getDeviceType(); deviceType = deviceTypeConfigIdentifier.getDeviceType();
if (isSharedWithAllTenants) { if (deviceTypeConfiguration.getFeatures() != null && deviceTypeConfiguration.getFeatures().getFeature() != null ) {
deviceTypeIdentifier = new DeviceTypeIdentifier(deviceType); List<Feature> features = deviceTypeConfiguration.getFeatures().getFeature();
} else {
deviceTypeIdentifier = new DeviceTypeIdentifier(deviceType, tenantId);
}
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<Feature> features = deviceDefinition.getFeatures().getFeature();
if (features != null) { if (features != null) {
featureManager = new ConfigurationBasedFeatureManager(features); featureManager = new ConfigurationBasedFeatureManager(features);
} }
} }
}
//add license to registry. //add license to registry.
this.licenseManager = new RegistryBasedLicenseManager(); this.licenseManager = new RegistryBasedLicenseManager();
try { try {
if (licenseManager.getLicense(deviceType, DeviceTypePluginConstants.LANGUAGE_CODE_ENGLISH_US) == null) { if (licenseManager.getLicense(deviceType, DeviceTypePluginConstants.LANGUAGE_CODE_ENGLISH_US) == null) {
if (deviceDefinition.getLicense() != null) { if (deviceTypeConfiguration.getLicense() != null) {
License defaultLicense = new License(); License defaultLicense = new License();
defaultLicense.setLanguage(deviceDefinition.getLicense().getLanguage()); defaultLicense.setLanguage(deviceTypeConfiguration.getLicense().getLanguage());
defaultLicense.setVersion(deviceDefinition.getLicense().getVersion()); defaultLicense.setVersion(deviceTypeConfiguration.getLicense().getVersion());
defaultLicense.setText(deviceDefinition.getLicense().getText()); defaultLicense.setText(deviceTypeConfiguration.getLicense().getText());
licenseManager.addLicense(deviceType, defaultLicense); licenseManager.addLicense(deviceType, defaultLicense);
} }
} }
@ -117,15 +95,26 @@ public class DeviceTypeManager implements DeviceManager {
throw new DeviceTypeDeployerFileException(msg, e); throw new DeviceTypeDeployerFileException(msg, e);
} }
//Check whether device dao definition exist. DeviceDetails deviceDetails = deviceTypeConfiguration.getDeviceDetails();
if (deviceDetails != null) {
String tableName = deviceManagementConfiguration.getManagementRepository().getDeviceDefinition() //Check whether device dao definition exist.
.getTableName(); String tableName = deviceTypeConfiguration.getDeviceDetails().getTableId();
if (tableName != null && !tableName.isEmpty()) { if (tableName != null && !tableName.isEmpty()) {
List<Table> tables = deviceTypeConfiguration.getDataSource().getTableConfig().getTable();
Table deviceDefinitionTable = null;
for (Table table : tables) {
if (tableName.equals(table.getName())) {
deviceDefinitionTable = table;
break;
}
}
if (deviceDefinitionTable == null) {
throw new DeviceTypeDeployerFileException("Could not find definition for table: " + tableName);
}
propertiesExist = true; propertiesExist = true;
DeviceDAODefinition deviceDAODefinition = new DeviceDAODefinition(deviceDefinition); DeviceDAODefinition deviceDAODefinition = new DeviceDAODefinition(deviceDefinitionTable);
String datasourceName = deviceManagementConfiguration.getManagementRepository() String datasourceName = deviceTypeConfiguration.getDataSource().getJndiConfig().getName();
.getDataSourceConfiguration().getJndiLookupDefinition().getName();
if (datasourceName != null && !datasourceName.isEmpty()) { if (datasourceName != null && !datasourceName.isEmpty()) {
String setupOption = System.getProperty("setup"); String setupOption = System.getProperty("setup");
if (setupOption != null) { if (setupOption != null) {

@ -28,9 +28,9 @@ import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig; 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.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.DeviceTypeConfiguration;
import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.Property; 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 org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.PushNotificationProvider;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -50,11 +50,11 @@ public class DeviceTypeManagerService implements DeviceManagementService {
private String type; private String type;
public DeviceTypeManagerService(DeviceTypeConfigIdentifier deviceTypeConfigIdentifier, public DeviceTypeManagerService(DeviceTypeConfigIdentifier deviceTypeConfigIdentifier,
DeviceManagementConfiguration deviceManagementConfiguration) { DeviceTypeConfiguration deviceTypeConfiguration) {
this.setProvisioningConfig(deviceTypeConfigIdentifier.getTenantDomain(), deviceManagementConfiguration); this.setProvisioningConfig(deviceTypeConfigIdentifier.getTenantDomain(), deviceTypeConfiguration);
this.deviceManager = new DeviceTypeManager(deviceTypeConfigIdentifier, deviceManagementConfiguration); this.deviceManager = new DeviceTypeManager(deviceTypeConfigIdentifier, deviceTypeConfiguration);
this.setType(deviceManagementConfiguration.getDeviceType()); this.setType(deviceTypeConfiguration.getName());
this.populatePushNotificationConfig(deviceManagementConfiguration.getPushNotificationConfiguration()); this.populatePushNotificationConfig(deviceTypeConfiguration.getPushNotificationProvider());
} }
@Override @Override
@ -66,15 +66,14 @@ public class DeviceTypeManagerService implements DeviceManagementService {
public void init() throws DeviceManagementException { public void init() throws DeviceManagementException {
} }
private void populatePushNotificationConfig(PushNotificationConfiguration sourceConfig) { private void populatePushNotificationConfig(PushNotificationProvider pushNotificationProvider) {
if (sourceConfig != null) { if (pushNotificationProvider != null) {
if (sourceConfig.isFileBasedProperties()) { if (pushNotificationProvider.isFileBasedProperties()) {
Map<String, String> staticProps = new HashMap<>(); Map<String, String> staticProps = new HashMap<>();
for (Property property : sourceConfig.getProperties().getProperty()) { for (Property property : pushNotificationProvider.getConfigProperties().getProperty()) {
staticProps.put(property.getName(), property.getValue()); staticProps.put(property.getName(), property.getValue());
} }
pushNotificationConfig = new PushNotificationConfig(sourceConfig.getPushNotificationProvider(), pushNotificationConfig = new PushNotificationConfig(pushNotificationProvider.getType(), staticProps);
staticProps);
} else { } else {
try { try {
PlatformConfiguration deviceTypeConfig = deviceManager.getConfiguration(); PlatformConfiguration deviceTypeConfig = deviceManager.getConfiguration();
@ -83,7 +82,7 @@ public class DeviceTypeManagerService implements DeviceManagementService {
if (configuration.size() > 0) { if (configuration.size() > 0) {
Map<String, String> properties = this.getConfigProperty(configuration); Map<String, String> properties = this.getConfigProperty(configuration);
pushNotificationConfig = new PushNotificationConfig( pushNotificationConfig = new PushNotificationConfig(
sourceConfig.getPushNotificationProvider(), properties); pushNotificationProvider.getType(), properties);
} }
} }
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
@ -113,10 +112,13 @@ public class DeviceTypeManagerService implements DeviceManagementService {
return pushNotificationConfig; return pushNotificationConfig;
} }
private void setProvisioningConfig(String tenantDomain, DeviceManagementConfiguration deviceManagementConfiguration) { private void setProvisioningConfig(String tenantDomain, DeviceTypeConfiguration deviceTypeConfiguration) {
boolean sharedWithAllTenants = deviceManagementConfiguration if (deviceTypeConfiguration.getProvisioningConfig() != null) {
.getManagementRepository().getProvisioningConfig().isSharedWithAllTenants(); boolean sharedWithAllTenants = deviceTypeConfiguration.getProvisioningConfig().isSharedWithAllTenants();
provisioningConfig = new ProvisioningConfig(tenantDomain, sharedWithAllTenants); provisioningConfig = new ProvisioningConfig(tenantDomain, sharedWithAllTenants);
} else {
provisioningConfig = new ProvisioningConfig(tenantDomain, false);
}
} }
private void setType(String type) { private void setType(String type) {

@ -18,8 +18,7 @@
*/ */
package org.wso2.carbon.device.mgt.extensions.device.type.deployer.template.dao; 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.Table;
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 org.wso2.carbon.device.mgt.extensions.device.type.deployer.exception.DeviceTypeDeployerFileException;
import java.util.ArrayList; import java.util.ArrayList;
@ -32,7 +31,7 @@ import java.util.List;
public class DeviceDAODefinition { public class DeviceDAODefinition {
private String deviceTableName; private String deviceTableName;
private String primarkey; private String primarykey;
public List<String> getColumnNames() { public List<String> getColumnNames() {
return columnNames; return columnNames;
@ -41,26 +40,26 @@ public class DeviceDAODefinition {
private List<String> columnNames = new ArrayList<>(); private List<String> columnNames = new ArrayList<>();
public DeviceDAODefinition(DeviceDefinition deviceDefinition) { public DeviceDAODefinition(Table table) {
deviceTableName = deviceDefinition.getTableName(); deviceTableName = table.getName();
primarkey = deviceDefinition.getPrimaryKey(); primarykey = table.getPrimaryKey();
List<Attribute> attributes = deviceDefinition.getAttributes().getAttribute(); List<String> attributes = table.getAttributes().getAttribute();
if (deviceTableName == null || deviceTableName.isEmpty()) { if (deviceTableName == null || deviceTableName.isEmpty()) {
throw new DeviceTypeDeployerFileException("Missing deviceTableName"); throw new DeviceTypeDeployerFileException("Missing deviceTableName");
} }
if (primarkey == null || primarkey.isEmpty()) { if (primarykey == null || primarykey.isEmpty()) {
throw new DeviceTypeDeployerFileException("Missing primaryKey "); throw new DeviceTypeDeployerFileException("Missing primaryKey ");
} }
if (attributes == null || attributes.size() == 0) { if (attributes == null || attributes.size() == 0) {
throw new DeviceTypeDeployerFileException("Missing Attributes "); throw new DeviceTypeDeployerFileException("Missing Attributes ");
} }
for (Attribute attribute : attributes) { for (String attribute : attributes) {
if (attribute.getValue() == null ||attribute.getValue().isEmpty()) { if (attribute.isEmpty()) {
throw new DeviceTypeDeployerFileException("Unsupported attribute format for device definition"); throw new DeviceTypeDeployerFileException("Unsupported attribute format for device definition");
} }
columnNames.add(attribute.getValue()); columnNames.add(attribute);
} }
} }
@ -68,8 +67,8 @@ public class DeviceDAODefinition {
return deviceTableName; return deviceTableName;
} }
public String getPrimarkey() { public String getPrimaryKey() {
return primarkey; return primarykey;
} }

@ -56,7 +56,7 @@ public class DeviceTypePluginDAO {
try { try {
conn = deviceTypeDAOHandler.getConnection(); conn = deviceTypeDAOHandler.getConnection();
String selectDBQuery = "SELECT " + getDeviceTableColumnNames() + " FROM " + String selectDBQuery = "SELECT " + getDeviceTableColumnNames() + " FROM " +
deviceDAODefinition.getDeviceTableName() + " WHERE " + deviceDAODefinition.getPrimarkey() + " = ?"; deviceDAODefinition.getDeviceTableName() + " WHERE " + deviceDAODefinition.getPrimaryKey() + " = ?";
stmt = conn.prepareStatement(selectDBQuery); stmt = conn.prepareStatement(selectDBQuery);
stmt.setString(1, deviceId); stmt.setString(1, deviceId);
resultSet = stmt.executeQuery(); resultSet = stmt.executeQuery();
@ -97,7 +97,7 @@ public class DeviceTypePluginDAO {
try { try {
conn = deviceTypeDAOHandler.getConnection(); conn = deviceTypeDAOHandler.getConnection();
String createDBQuery = "INSERT INTO " + deviceDAODefinition.getDeviceTableName() + "(" String createDBQuery = "INSERT INTO " + deviceDAODefinition.getDeviceTableName() + "("
+ deviceDAODefinition.getPrimarkey() + " , " + getDeviceTableColumnNames() + ") VALUES (" + deviceDAODefinition.getPrimaryKey() + " , " + getDeviceTableColumnNames() + ") VALUES ("
+ getPreparedInputString(deviceDAODefinition.getColumnNames().size() + 1) + ")"; + getPreparedInputString(deviceDAODefinition.getColumnNames().size() + 1) + ")";
stmt = conn.prepareStatement(createDBQuery); stmt = conn.prepareStatement(createDBQuery);
stmt.setString(1, device.getDeviceIdentifier()); stmt.setString(1, device.getDeviceIdentifier());
@ -132,7 +132,7 @@ public class DeviceTypePluginDAO {
try { try {
conn = deviceTypeDAOHandler.getConnection(); conn = deviceTypeDAOHandler.getConnection();
String updateDBQuery = "UPDATE " + deviceDAODefinition.getDeviceTableName() + " SET " String updateDBQuery = "UPDATE " + deviceDAODefinition.getDeviceTableName() + " SET "
+ getDeviceTableColumnNamesForUpdateQuery()+ " WHERE " + deviceDAODefinition.getPrimarkey() + getDeviceTableColumnNamesForUpdateQuery()+ " WHERE " + deviceDAODefinition.getPrimaryKey()
+ " = ?"; + " = ?";
stmt = conn.prepareStatement(updateDBQuery); stmt = conn.prepareStatement(updateDBQuery);
@ -167,7 +167,7 @@ public class DeviceTypePluginDAO {
try { try {
conn = deviceTypeDAOHandler.getConnection(); conn = deviceTypeDAOHandler.getConnection();
String deleteDBQuery = "DELETE FROM " + deviceDAODefinition.getDeviceTableName() String deleteDBQuery = "DELETE FROM " + deviceDAODefinition.getDeviceTableName()
+ " WHERE " + deviceDAODefinition.getPrimarkey() + " = ?"; + " WHERE " + deviceDAODefinition.getPrimaryKey() + " = ?";
stmt = conn.prepareStatement(deleteDBQuery); stmt = conn.prepareStatement(deleteDBQuery);
stmt.setString(1, deviceId); stmt.setString(1, deviceId);
int rows = stmt.executeUpdate(); int rows = stmt.executeUpdate();
@ -203,7 +203,7 @@ public class DeviceTypePluginDAO {
resultSet = stmt.executeQuery(); resultSet = stmt.executeQuery();
while (resultSet.next()) { while (resultSet.next()) {
device = new Device(); device = new Device();
device.setDeviceIdentifier(resultSet.getString(deviceDAODefinition.getPrimarkey())); device.setDeviceIdentifier(resultSet.getString(deviceDAODefinition.getPrimaryKey()));
List<Device.Property> properties = new ArrayList<>(); List<Device.Property> properties = new ArrayList<>();
for (String columnName : deviceDAODefinition.getColumnNames()) { for (String columnName : deviceDAODefinition.getColumnNames()) {
Device.Property property = new Device.Property(); Device.Property property = new Device.Property();

@ -1,65 +0,0 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wso2.carbon.device.mgt.extensions.device.type.deployer.template.feature;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.DeviceTypeIdentifier;
import org.wso2.carbon.device.mgt.common.Feature;
import org.wso2.carbon.device.mgt.common.FeatureManager;
import org.wso2.carbon.device.mgt.extensions.feature.mgt.GenericFeatureManager;
import java.util.List;
/**
* This feature manager implementation reads the annotation @Feature and creates a feature manager.
*/
public class AnnotationBasedFeatureManager implements FeatureManager {
private DeviceTypeIdentifier deviceType;
public AnnotationBasedFeatureManager(DeviceTypeIdentifier deviceTypeIdentifier) {
this.deviceType = deviceTypeIdentifier;
}
@Override
public boolean addFeature(Feature feature) throws DeviceManagementException {
return false;
}
@Override
public boolean addFeatures(List<Feature> features) throws DeviceManagementException {
return false;
}
@Override
public Feature getFeature(String name) throws DeviceManagementException {
return GenericFeatureManager.getInstance().getFeature(deviceType, name);
}
@Override
public List<Feature> getFeatures() throws DeviceManagementException {
return GenericFeatureManager.getInstance().getFeatures(deviceType);
}
@Override
public boolean removeFeature(String name) throws DeviceManagementException {
return false;
}
@Override
public boolean addSupportedFeaturesToDB() throws DeviceManagementException {
return false;
}
}

@ -21,15 +21,27 @@ package org.wso2.carbon.device.mgt.extensions.device.type.deployer.template.feat
import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.Feature; import org.wso2.carbon.device.mgt.common.Feature;
import org.wso2.carbon.device.mgt.common.FeatureManager; import org.wso2.carbon.device.mgt.common.FeatureManager;
import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.Operation;
import javax.ws.rs.HttpMethod;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/** /**
* This implementation retreives the features that are configured through the deployer. * This implementation retreives the features that are configured through the deployer.
*/ */
public class ConfigurationBasedFeatureManager implements FeatureManager { public class ConfigurationBasedFeatureManager implements FeatureManager {
private List<Feature> features = new ArrayList<>(); private List<Feature> features = new ArrayList<>();
private static final String METHOD = "method";
private static final String URI = "uri";
private static final String PATH_PARAMS = "pathParams";
private static final String QUERY_PARAMS = "queryParams";
private static final String FORM_PARAMS = "formParams";
private static final Pattern PATH_PARAM_REGEX = Pattern.compile("\\{(.*?)\\}");
public ConfigurationBasedFeatureManager( public ConfigurationBasedFeatureManager(
List<org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.Feature> features) { List<org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.Feature> features) {
@ -38,6 +50,29 @@ public class ConfigurationBasedFeatureManager implements FeatureManager {
deviceFeature.setCode(feature.getCode()); deviceFeature.setCode(feature.getCode());
deviceFeature.setName(feature.getName()); deviceFeature.setName(feature.getName());
deviceFeature.setDescription(feature.getDescription()); deviceFeature.setDescription(feature.getDescription());
Operation operation = feature.getOperation();
if (operation != null) {
Map<String, Object> apiParams = new HashMap<>();
apiParams.put(METHOD, operation.getMethod().toUpperCase());
apiParams.put(URI, operation.getContext());
List<String> pathParams = getPathParams(operation.getContext());
if (!pathParams.isEmpty()) {
apiParams.put(PATH_PARAMS, pathParams);
}
if (operation.getQueryParameters() != null) {
apiParams.put(QUERY_PARAMS, operation.getQueryParameters().getParameter());
}
if (operation.getFormParameters() != null) {
apiParams.put(FORM_PARAMS, operation.getFormParameters().getParameter());
}
List<Feature.MetadataEntry> metadataEntries = new ArrayList<>();
Feature.MetadataEntry metadataEntry = new Feature.MetadataEntry();
metadataEntry.setId(-1);
metadataEntry.setValue(apiParams);
metadataEntries.add(metadataEntry);
deviceFeature.setMetadataEntries(metadataEntries);
}
this.features.add(deviceFeature); this.features.add(deviceFeature);
} }
} }
@ -77,4 +112,13 @@ public class ConfigurationBasedFeatureManager implements FeatureManager {
public boolean addSupportedFeaturesToDB() throws DeviceManagementException { public boolean addSupportedFeaturesToDB() throws DeviceManagementException {
return false; return false;
} }
private List<String> getPathParams(String context) {
List<String> matchList = new ArrayList<String>();
Matcher regexMatcher = PATH_PARAM_REGEX.matcher(context);
while (regexMatcher.find()) {
matchList.add(regexMatcher.group(1));
}
return matchList;
}
} }

@ -21,7 +21,6 @@ package org.wso2.carbon.device.mgt.extensions.device.type.deployer.template.util
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext;
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.exception.DeviceTypeMgtPluginException;
import org.wso2.carbon.device.mgt.extensions.device.type.deployer.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.RegistryException;
@ -30,7 +29,6 @@ import org.wso2.carbon.registry.core.Registry;
import javax.naming.Context; import javax.naming.Context;
import javax.naming.InitialContext; import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource; import javax.sql.DataSource;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
@ -89,8 +87,6 @@ public class DeviceTypeUtils {
} else { } else {
log.info("Device management repository database already exists. Not creating a new database."); log.info("Device management repository database already exists. Not creating a new database.");
} }
} catch (NamingException e) {
log.error("Error while looking up the data source: " + datasourceName, e);
} catch (Exception e) { } catch (Exception e) {
throw new DeviceTypeMgtPluginException("Error occurred while initializing Device " + throw new DeviceTypeMgtPluginException("Error occurred while initializing Device " +
"Management database schema", e); "Management database schema", e);

@ -17,48 +17,52 @@
~ specific language governing permissions and limitations ~ specific language governing permissions and limitations
~ under the License. ~ under the License.
--> -->
<DeviceManagementConfiguration name="samples"> <DeviceTypeConfiguration name="samples">
<License> <DeviceDetails table-id="SAMPLE_DEVICE_1"/>
<Language>en_US</Language>
<Version>1.0.0</Version>
<Text>This is license text</Text>
</License>
<DataSource>
<jndiConfig>
<name>jdbc/SampleDM_DB</name>
</jndiConfig>
<tableDefinitions>
<Table name="SAMPLE_DEVICE">
<PrimaryKey>SAMPLE_DEVICE_ID</PrimaryKey>
<Attributes>
<Attribute>column1</Attribute>
<Attribute>column2</Attribute>
</Attributes>
</Table>
</tableDefinitions>
</DataSource>
<!--if generate is set to true then the feature information will be picked up from the annotation in the api-->
<Features> <Features>
<Feature code="abc"> <Feature code="abc">
<Name>abc</Name> <Name>abc</Name>
<affectedVersion>5.0.0</affectedVersion>
<Description>this is a feature</Description> <Description>this is a feature</Description>
<FeatureProperties> <Operation context="/bulb/{state}" method="PUT">
<Property name="prop1">place_holder</Property> <QueryParameters>
<Property name="prop2">place_holder</Property> <Parameter>deviceId</Parameter>
<Property name="prop3">place_holder</Property> </QueryParameters>
</FeatureProperties> <FormParameters>
<Parameter>test</Parameter>
</FormParameters>
</Operation>
</Feature> </Feature>
</Features> </Features>
<!-- <Sensors table-id="SAMPLE_DEVICE_2">
<Sensor code="CPU_Temperature">
<Name>temperature sensor fitted</Name>
<StreamDefinition>org.wso2.temperature.stream<StreamDefinition>
<Description>this is a sensor</Description>
<SensorStaticProperties>
<Property name="unit">celcius</Property>
<Property name="model_number">atmeggga11234</Property>
</SensorStaticProperties>
</Sensor>
<Sensor code="DHT11_Temperature">
<Name>temperature sensor fitted</Name>
<StreamDefinition>org.wso2.temperature.stream<StreamDefinition>
<Description>this is a sensor</Description>
<SensorStaticProperties>
<Property name="unit">celcius</Property>
</SensorStaticProperties>
<SensorDynamicProperties>
<Property name="model_number"/>
</SensorDynamicProperties>
</Sensor>
</Sensors> -->
<ProvisioningConfig> <ProvisioningConfig>
<SharedWithAllTenants>false</SharedWithAllTenants> <SharedWithAllTenants>false</SharedWithAllTenants>
</ProvisioningConfig> </ProvisioningConfig>
<NotificationProviders>
<PushNotificationProvider type="MQTT"> <PushNotificationProvider type="MQTT">
<FileBasedProperties>true</FileBasedProperties> <FileBasedProperties>true</FileBasedProperties>
<!--if file based properties is set to false then the configuration will be picked from platform configuration--> <!--if file based properties is set to false then the configuration will be picked from platform configuration-->
@ -72,6 +76,26 @@
<Property Name="clearSession">true</Property> <Property Name="clearSession">true</Property>
</ConfigProperties> </ConfigProperties>
</PushNotificationProvider> </PushNotificationProvider>
</NotificationProviders>
</DeviceManagementConfiguration> <License>
<Language>en_US</Language>
<Version>1.0.0</Version>
<Text>This is license text</Text>
</License>
<DataSource>
<jndiConfig>
<name>jdbc/SampleDM_DB</name>
</jndiConfig>
<tableConfig>
<Table name="SAMPLE_DEVICE_1">
<PrimaryKey>SAMPLE_DEVICE_ID</PrimaryKey>
<Attributes>
<Attribute>column1</Attribute>
<Attribute>column2</Attribute>
</Attributes>
</Table>
</tableConfig>
</DataSource>
</DeviceTypeConfiguration>
Loading…
Cancel
Save