revert-70aa11f8
Geeth Munasinghe 10 years ago
commit 38e1892333

@ -18,7 +18,6 @@ package org.wso2.carbon.device.mgt.common;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.List;
import java.util.Map;
@XmlRootElement
public class Device {
@ -35,7 +34,7 @@ public class Device {
private String deviceIdentifier;
private String owner;
private List<Feature> features;
private Map<String, String> properties;
private List<Device.Property> properties;
@XmlElement
public int getId() {
@ -146,12 +145,34 @@ public class Device {
}
@XmlElement
public Map<String, String> getProperties() {
public List<Device.Property> getProperties() {
return properties;
}
public void setProperties(Map<String, String> properties) {
public void setProperties(List<Device.Property> properties) {
this.properties = properties;
}
public static class Property {
private String name;
private String value;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
}

@ -18,6 +18,7 @@ package org.wso2.carbon.device.mgt.core.util;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Document;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.core.config.datasource.DataSourceConfig;
import org.wso2.carbon.device.mgt.core.config.datasource.JNDILookupDefinition;
@ -31,8 +32,10 @@ import javax.sql.DataSource;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import java.io.File;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
public final class DeviceManagerUtil {
@ -59,24 +62,22 @@ public final class DeviceManagerUtil {
public static DataSource resolveDataSource(DataSourceConfig config) {
DataSource dataSource = null;
if (config == null) {
throw new RuntimeException("Device Management Repository data source configuration " +
"is null and thus, is not initialized");
throw new RuntimeException(
"Device Management Repository data source configuration " + "is null and thus, is not initialized");
}
JNDILookupDefinition jndiConfig = config.getJndiLookupDefintion();
if (jndiConfig != null) {
if (log.isDebugEnabled()) {
log.debug("Initializing Device Management Repository data source using the JNDI " +
"Lookup Definition");
log.debug(
"Initializing Device Management Repository data source using the JNDI " + "Lookup Definition");
}
List<JNDILookupDefinition.JNDIProperty> jndiPropertyList =
jndiConfig.getJndiProperties();
List<JNDILookupDefinition.JNDIProperty> jndiPropertyList = jndiConfig.getJndiProperties();
if (jndiPropertyList != null) {
Hashtable<Object, Object> jndiProperties = new Hashtable<Object, Object>();
for (JNDILookupDefinition.JNDIProperty prop : jndiPropertyList) {
jndiProperties.put(prop.getName(), prop.getValue());
}
dataSource =
DeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), jndiProperties);
dataSource = DeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), jndiProperties);
} else {
dataSource = DeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), null);
}
@ -130,4 +131,12 @@ public final class DeviceManagerUtil {
}
}
public static Map<String, String> convertPropertiesToMap(List<Device.Property> properties) {
Map<String, String> propertiesMap = new HashMap<String, String>();
for (Device.Property prop : properties) {
propertiesMap.put(prop.getName(), prop.getValue());
}
return propertiesMap;
}
}

Loading…
Cancel
Save