|
|
@ -54,25 +54,44 @@ public class MobileDeviceManagementUtil {
|
|
|
|
DocumentBuilder docBuilder = factory.newDocumentBuilder();
|
|
|
|
DocumentBuilder docBuilder = factory.newDocumentBuilder();
|
|
|
|
return docBuilder.parse(file);
|
|
|
|
return docBuilder.parse(file);
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
throw new DeviceManagementException(
|
|
|
|
throw new DeviceManagementException("Error occurred while parsing file, while converting " +
|
|
|
|
"Error occurred while parsing file, while converting " +
|
|
|
|
"to a org.w3c.dom.Document : " + e.getMessage(), e);
|
|
|
|
"to a org.w3c.dom.Document : " + e.getMessage(), e);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static String getPropertyValue(Device device, String property) {
|
|
|
|
|
|
|
|
for (Device.Property prop : device.getProperties()) {
|
|
|
|
|
|
|
|
if (property.equals(prop.getName())) {
|
|
|
|
|
|
|
|
return prop.getValue();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static Device.Property getProperty(String property, String value) {
|
|
|
|
|
|
|
|
Device.Property prop = null;
|
|
|
|
|
|
|
|
if (property != null) {
|
|
|
|
|
|
|
|
prop = new Device.Property();
|
|
|
|
|
|
|
|
prop.setName(property);
|
|
|
|
|
|
|
|
prop.setValue(value);
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static MobileDevice convertToMobileDevice(Device device) {
|
|
|
|
public static MobileDevice convertToMobileDevice(Device device) {
|
|
|
|
MobileDevice mobileDevice = null;
|
|
|
|
MobileDevice mobileDevice = null;
|
|
|
|
if (device != null) {
|
|
|
|
if (device != null) {
|
|
|
|
mobileDevice = new MobileDevice();
|
|
|
|
mobileDevice = new MobileDevice();
|
|
|
|
mobileDevice.setMobileDeviceId(device.getDeviceIdentifier());
|
|
|
|
mobileDevice.setMobileDeviceId(device.getDeviceIdentifier());
|
|
|
|
mobileDevice.setImei(device.getProperties().get(MOBILE_DEVICE_IMEI));
|
|
|
|
mobileDevice.setImei(getPropertyValue(device, MOBILE_DEVICE_IMEI));
|
|
|
|
mobileDevice.setImsi(device.getProperties().get(MOBILE_DEVICE_IMSI));
|
|
|
|
mobileDevice.setImsi(getPropertyValue(device, MOBILE_DEVICE_IMSI));
|
|
|
|
mobileDevice.setRegId(device.getProperties().get(MOBILE_DEVICE_REG_ID));
|
|
|
|
mobileDevice.setRegId(getPropertyValue(device, MOBILE_DEVICE_REG_ID));
|
|
|
|
mobileDevice.setModel(device.getProperties().get(MOBILE_DEVICE_MODEL));
|
|
|
|
mobileDevice.setModel(getPropertyValue(device, MOBILE_DEVICE_MODEL));
|
|
|
|
mobileDevice.setOsVersion(device.getProperties().get(MOBILE_DEVICE_OS_VERSION));
|
|
|
|
mobileDevice.setOsVersion(getPropertyValue(device, MOBILE_DEVICE_OS_VERSION));
|
|
|
|
mobileDevice.setVendor(device.getProperties().get(MOBILE_DEVICE_VENDOR));
|
|
|
|
mobileDevice.setVendor(getPropertyValue(device, MOBILE_DEVICE_VENDOR));
|
|
|
|
mobileDevice.setLatitude(device.getProperties().get(MOBILE_DEVICE_LATITUDE));
|
|
|
|
mobileDevice.setLatitude(getPropertyValue(device, MOBILE_DEVICE_LATITUDE));
|
|
|
|
mobileDevice.setLongitude(device.getProperties().get(MOBILE_DEVICE_LONGITUDE));
|
|
|
|
mobileDevice.setLongitude(getPropertyValue(device, MOBILE_DEVICE_LONGITUDE));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return mobileDevice;
|
|
|
|
return mobileDevice;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -81,23 +100,22 @@ public class MobileDeviceManagementUtil {
|
|
|
|
Device device = null;
|
|
|
|
Device device = null;
|
|
|
|
if (mobileDevice != null) {
|
|
|
|
if (mobileDevice != null) {
|
|
|
|
device = new Device();
|
|
|
|
device = new Device();
|
|
|
|
Map<String, String> propertyMap = new HashMap<String, String>();
|
|
|
|
List<Device.Property> propertyList = new ArrayList<Device.Property>();
|
|
|
|
propertyMap.put(MOBILE_DEVICE_IMEI, mobileDevice.getImei());
|
|
|
|
propertyList.add(getProperty(MOBILE_DEVICE_IMEI, mobileDevice.getImei()));
|
|
|
|
propertyMap.put(MOBILE_DEVICE_IMSI, mobileDevice.getImsi());
|
|
|
|
propertyList.add(getProperty(MOBILE_DEVICE_IMSI, mobileDevice.getImsi()));
|
|
|
|
propertyMap.put(MOBILE_DEVICE_REG_ID, mobileDevice.getRegId());
|
|
|
|
propertyList.add(getProperty(MOBILE_DEVICE_REG_ID, mobileDevice.getRegId()));
|
|
|
|
propertyMap.put(MOBILE_DEVICE_MODEL, mobileDevice.getModel());
|
|
|
|
propertyList.add(getProperty(MOBILE_DEVICE_MODEL, mobileDevice.getModel()));
|
|
|
|
propertyMap.put(MOBILE_DEVICE_OS_VERSION, mobileDevice.getOsVersion());
|
|
|
|
propertyList.add(getProperty(MOBILE_DEVICE_OS_VERSION, mobileDevice.getOsVersion()));
|
|
|
|
propertyMap.put(MOBILE_DEVICE_VENDOR, mobileDevice.getVendor());
|
|
|
|
propertyList.add(getProperty(MOBILE_DEVICE_VENDOR, mobileDevice.getVendor()));
|
|
|
|
propertyMap.put(MOBILE_DEVICE_LATITUDE, mobileDevice.getLatitude());
|
|
|
|
propertyList.add(getProperty(MOBILE_DEVICE_LATITUDE, mobileDevice.getLatitude()));
|
|
|
|
propertyMap.put(MOBILE_DEVICE_LONGITUDE, mobileDevice.getLongitude());
|
|
|
|
propertyList.add(getProperty(MOBILE_DEVICE_LONGITUDE, mobileDevice.getLongitude()));
|
|
|
|
device.setProperties(propertyMap);
|
|
|
|
device.setProperties(propertyList);
|
|
|
|
device.setDeviceIdentifier(mobileDevice.getMobileDeviceId());
|
|
|
|
device.setDeviceIdentifier(mobileDevice.getMobileDeviceId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return device;
|
|
|
|
return device;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static MobileOperation convertToMobileOperation(
|
|
|
|
public static MobileOperation convertToMobileOperation(org.wso2.carbon.device.mgt.common.Operation operation) {
|
|
|
|
org.wso2.carbon.device.mgt.common.Operation operation) {
|
|
|
|
|
|
|
|
MobileOperation mobileOperation = new MobileOperation();
|
|
|
|
MobileOperation mobileOperation = new MobileOperation();
|
|
|
|
MobileOperationProperty operationProperty = null;
|
|
|
|
MobileOperationProperty operationProperty = null;
|
|
|
|
List<MobileOperationProperty> properties = new LinkedList<MobileOperationProperty>();
|
|
|
|
List<MobileOperationProperty> properties = new LinkedList<MobileOperationProperty>();
|
|
|
@ -117,18 +135,18 @@ public class MobileDeviceManagementUtil {
|
|
|
|
public static List<Integer> getMobileOperationIdsFromMobileDeviceOperations(
|
|
|
|
public static List<Integer> getMobileOperationIdsFromMobileDeviceOperations(
|
|
|
|
List<MobileDeviceOperationMapping> mobileDeviceOperationMappings) {
|
|
|
|
List<MobileDeviceOperationMapping> mobileDeviceOperationMappings) {
|
|
|
|
List<Integer> mobileOperationIds = new ArrayList<Integer>();
|
|
|
|
List<Integer> mobileOperationIds = new ArrayList<Integer>();
|
|
|
|
for(MobileDeviceOperationMapping mobileDeviceOperationMapping : mobileDeviceOperationMappings){
|
|
|
|
for (MobileDeviceOperationMapping mobileDeviceOperationMapping : mobileDeviceOperationMappings) {
|
|
|
|
mobileOperationIds.add(mobileDeviceOperationMapping.getOperationId());
|
|
|
|
mobileOperationIds.add(mobileDeviceOperationMapping.getOperationId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return mobileOperationIds;
|
|
|
|
return mobileOperationIds;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static Operation convertMobileOperationToOperation(MobileOperation mobileOperation){
|
|
|
|
public static Operation convertMobileOperationToOperation(MobileOperation mobileOperation) {
|
|
|
|
Operation operation = new Operation();
|
|
|
|
Operation operation = new Operation();
|
|
|
|
Properties properties = new Properties();
|
|
|
|
Properties properties = new Properties();
|
|
|
|
operation.setCode(mobileOperation.getFeatureCode());
|
|
|
|
operation.setCode(mobileOperation.getFeatureCode());
|
|
|
|
for(MobileOperationProperty mobileOperationProperty:mobileOperation.getProperties()){
|
|
|
|
for (MobileOperationProperty mobileOperationProperty : mobileOperation.getProperties()) {
|
|
|
|
properties.put(mobileOperationProperty.getProperty(),mobileOperationProperty.getValue());
|
|
|
|
properties.put(mobileOperationProperty.getProperty(), mobileOperationProperty.getValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
operation.setProperties(properties);
|
|
|
|
operation.setProperties(properties);
|
|
|
|
return operation;
|
|
|
|
return operation;
|
|
|
|