mirror of
https://repository.entgra.net/community/device-mgt-plugins.git
synced 2025-09-16 23:42:15 +00:00
Added tenant configuration related changes
This commit is contained in:
parent
87073ffc5c
commit
d07c226dd5
@ -65,11 +65,17 @@
|
|||||||
javax.xml.parsers,
|
javax.xml.parsers,
|
||||||
org.w3c.dom,
|
org.w3c.dom,
|
||||||
org.wso2.carbon.core,
|
org.wso2.carbon.core,
|
||||||
|
org.wso2.carbon.context,
|
||||||
org.wso2.carbon.utils.*,
|
org.wso2.carbon.utils.*,
|
||||||
org.wso2.carbon.device.mgt.common.*,
|
org.wso2.carbon.device.mgt.common.*,
|
||||||
org.wso2.carbon.ndatasource.core,
|
org.wso2.carbon.ndatasource.core,
|
||||||
org.wso2.carbon.policy.mgt.common.*,
|
org.wso2.carbon.policy.mgt.common.*,
|
||||||
org.wso2.carbon.policy.mgt.core.*
|
org.wso2.carbon.policy.mgt.core.*,
|
||||||
|
org.wso2.carbon.registry.core,
|
||||||
|
org.wso2.carbon.registry.core.exceptions,
|
||||||
|
org.wso2.carbon.registry.core.service,
|
||||||
|
org.wso2.carbon.registry.core.session,
|
||||||
|
org.wso2.carbon.registry.api,
|
||||||
</Import-Package>
|
</Import-Package>
|
||||||
<Export-Package>
|
<Export-Package>
|
||||||
!org.wso2.carbon.device.mgt.mobile.internal,
|
!org.wso2.carbon.device.mgt.mobile.internal,
|
||||||
@ -133,6 +139,14 @@
|
|||||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
<artifactId>org.wso2.carbon.policy.mgt.core</artifactId>
|
<artifactId>org.wso2.carbon.policy.mgt.core</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.registry.api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.registry.core</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.testng</groupId>
|
<groupId>org.testng</groupId>
|
||||||
<artifactId>testng</artifactId>
|
<artifactId>testng</artifactId>
|
||||||
|
|||||||
@ -19,5 +19,6 @@ package org.wso2.carbon.device.mgt.mobile.common;
|
|||||||
|
|
||||||
public class MobilePluginConstants {
|
public class MobilePluginConstants {
|
||||||
public static final String MOBILE_DB_SCRIPTS_FOLDER = "cdm";
|
public static final String MOBILE_DB_SCRIPTS_FOLDER = "cdm";
|
||||||
|
public static final String MOBILE_CONFIG_REGISTRY_ROOT = "/_system/config";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,239 +21,313 @@ package org.wso2.carbon.device.mgt.mobile.impl.android;
|
|||||||
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.device.mgt.common.*;
|
import org.wso2.carbon.device.mgt.common.*;
|
||||||
|
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
|
||||||
|
import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration;
|
||||||
import org.wso2.carbon.device.mgt.common.license.mgt.License;
|
import org.wso2.carbon.device.mgt.common.license.mgt.License;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.common.MobileDeviceMgtPluginException;
|
||||||
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
|
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
|
||||||
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory;
|
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory;
|
||||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice;
|
import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice;
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.android.dao.AndroidDAOFactory;
|
import org.wso2.carbon.device.mgt.mobile.impl.android.dao.AndroidDAOFactory;
|
||||||
import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil;
|
import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil;
|
||||||
|
import org.wso2.carbon.registry.api.Collection;
|
||||||
|
import org.wso2.carbon.registry.api.Resource;
|
||||||
|
import org.wso2.carbon.registry.api.RegistryException;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class AndroidDeviceManager implements DeviceManager {
|
public class AndroidDeviceManager implements DeviceManager {
|
||||||
|
|
||||||
private MobileDeviceManagementDAOFactory mobileDeviceManagementDAOFactory;
|
private MobileDeviceManagementDAOFactory mobileDeviceManagementDAOFactory;
|
||||||
private static final Log log = LogFactory.getLog(AndroidDeviceManagementService.class);
|
private static final Log log = LogFactory.getLog(AndroidDeviceManagementService.class);
|
||||||
private FeatureManager featureManager = new AndroidFeatureManager();
|
private FeatureManager featureManager = new AndroidFeatureManager();
|
||||||
private License license;
|
private License license;
|
||||||
|
|
||||||
public AndroidDeviceManager() {
|
public AndroidDeviceManager() {
|
||||||
mobileDeviceManagementDAOFactory = new AndroidDAOFactory();
|
mobileDeviceManagementDAOFactory = new AndroidDAOFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FeatureManager getFeatureManager() {
|
public FeatureManager getFeatureManager() {
|
||||||
return featureManager;
|
return featureManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean enrollDevice(Device device) throws DeviceManagementException {
|
public boolean saveConfiguration(TenantConfiguration tenantConfiguration)
|
||||||
boolean status;
|
throws DeviceManagementException {
|
||||||
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
|
boolean status = false;
|
||||||
try {
|
Resource resource;
|
||||||
if (log.isDebugEnabled()) {
|
try {
|
||||||
log.debug("Enrolling a new Android device : " + device.getDeviceIdentifier());
|
if (log.isDebugEnabled()) {
|
||||||
}
|
log.debug("Persisting android configurations in Registry");
|
||||||
AndroidDAOFactory.beginTransaction();
|
}
|
||||||
status = mobileDeviceManagementDAOFactory.getMobileDeviceDAO().addMobileDevice(
|
String resourcePath = MobileDeviceManagementUtil.getPlatformConfigPath(
|
||||||
mobileDevice);
|
DeviceManagementConstants.
|
||||||
AndroidDAOFactory.commitTransaction();
|
MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||||
} catch (MobileDeviceManagementDAOException e) {
|
MobileDeviceManagementUtil.createRegistryCollection(resourcePath);
|
||||||
try {
|
for (ConfigurationEntry configEntry : tenantConfiguration.getConfiguration()) {
|
||||||
AndroidDAOFactory.rollbackTransaction();
|
resource = MobileDeviceManagementUtil.getRegistry().newResource();
|
||||||
} catch (MobileDeviceManagementDAOException mobileDAOEx) {
|
resource.setContent(configEntry.getValue());
|
||||||
String msg = "Error occurred while roll back the device enrol transaction :" + device.toString();
|
MobileDeviceManagementUtil.putRegistryResource(resourcePath + "/" + configEntry.getName(), resource);
|
||||||
log.warn(msg, mobileDAOEx);
|
}
|
||||||
}
|
status = true;
|
||||||
String msg = "Error while enrolling the Android device : " + device.getDeviceIdentifier();
|
} catch (MobileDeviceMgtPluginException e) {
|
||||||
log.error(msg, e);
|
throw new DeviceManagementException(
|
||||||
throw new DeviceManagementException(msg, e);
|
"Error occurred while retrieving the Registry instance : " + e.getMessage(), e);
|
||||||
}
|
} catch (RegistryException e) {
|
||||||
return status;
|
throw new DeviceManagementException(
|
||||||
}
|
"Error occurred while persisting the Registry resource : " + e.getMessage(), e);
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean modifyEnrollment(Device device) throws DeviceManagementException {
|
public TenantConfiguration getConfiguration() throws DeviceManagementException {
|
||||||
boolean status;
|
Collection dsCollection = null;
|
||||||
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
|
TenantConfiguration tenantConfiguration;
|
||||||
try {
|
List<ConfigurationEntry> configs = new ArrayList<ConfigurationEntry>();
|
||||||
if (log.isDebugEnabled()) {
|
ConfigurationEntry entry;
|
||||||
log.debug("Modifying the Android device enrollment data");
|
Resource resource;
|
||||||
}
|
try {
|
||||||
AndroidDAOFactory.beginTransaction();
|
String androidRegPath = MobileDeviceManagementUtil.getPlatformConfigPath(DeviceManagementConstants.
|
||||||
status = mobileDeviceManagementDAOFactory.getMobileDeviceDAO()
|
MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||||
.updateMobileDevice(mobileDevice);
|
dsCollection = (Collection) MobileDeviceManagementUtil.getRegistryResource(androidRegPath);
|
||||||
AndroidDAOFactory.commitTransaction();
|
String[] dsmPaths = dsCollection.getChildren();
|
||||||
} catch (MobileDeviceManagementDAOException e) {
|
for (String dsmPath : dsmPaths) {
|
||||||
try {
|
entry = new ConfigurationEntry();
|
||||||
AndroidDAOFactory.rollbackTransaction();
|
resource = MobileDeviceManagementUtil.getRegistryResource(dsmPath);
|
||||||
} catch (MobileDeviceManagementDAOException mobileDAOEx) {
|
entry.setValue(resource.getContent());
|
||||||
String msg = "Error occurred while roll back the update device transaction :" + device.toString();
|
entry.setName(resource.getId());
|
||||||
log.warn(msg, mobileDAOEx);
|
configs.add(entry);
|
||||||
}
|
}
|
||||||
String msg = "Error while updating the enrollment of the Android device : " +
|
tenantConfiguration = new TenantConfiguration();
|
||||||
device.getDeviceIdentifier();
|
tenantConfiguration.setConfiguration(configs);
|
||||||
log.error(msg, e);
|
tenantConfiguration.setType(DeviceManagementConstants.
|
||||||
throw new DeviceManagementException(msg, e);
|
MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||||
}
|
} catch (MobileDeviceMgtPluginException e) {
|
||||||
return status;
|
throw new DeviceManagementException(
|
||||||
}
|
"Error occurred while retrieving the Registry instance : " + e.getMessage(), e);
|
||||||
|
} catch (RegistryException e) {
|
||||||
|
throw new DeviceManagementException(
|
||||||
|
"Error occurred while retrieving the Registry data : " + e.getMessage(), e);
|
||||||
|
}
|
||||||
|
return tenantConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
|
public boolean enrollDevice(Device device) throws DeviceManagementException {
|
||||||
boolean status;
|
boolean status;
|
||||||
try {
|
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
|
||||||
if (log.isDebugEnabled()) {
|
try {
|
||||||
log.debug("Dis-enrolling Android device : " + deviceId);
|
if (log.isDebugEnabled()) {
|
||||||
}
|
log.debug("Enrolling a new Android device : " + device.getDeviceIdentifier());
|
||||||
AndroidDAOFactory.beginTransaction();
|
}
|
||||||
status = mobileDeviceManagementDAOFactory.getMobileDeviceDAO()
|
AndroidDAOFactory.beginTransaction();
|
||||||
.deleteMobileDevice(deviceId.getId());
|
status = mobileDeviceManagementDAOFactory.getMobileDeviceDAO().addMobileDevice(
|
||||||
AndroidDAOFactory.commitTransaction();
|
mobileDevice);
|
||||||
} catch (MobileDeviceManagementDAOException e) {
|
AndroidDAOFactory.commitTransaction();
|
||||||
try {
|
} catch (MobileDeviceManagementDAOException e) {
|
||||||
AndroidDAOFactory.rollbackTransaction();
|
try {
|
||||||
} catch (MobileDeviceManagementDAOException mobileDAOEx) {
|
AndroidDAOFactory.rollbackTransaction();
|
||||||
String msg = "Error occurred while roll back the device dis enrol transaction :" + deviceId.toString();
|
} catch (MobileDeviceManagementDAOException mobileDAOEx) {
|
||||||
log.warn(msg, mobileDAOEx);
|
String msg = "Error occurred while roll back the device enrol transaction :" +
|
||||||
}
|
device.toString();
|
||||||
String msg = "Error while removing the Android device : " + deviceId.getId();
|
log.warn(msg, mobileDAOEx);
|
||||||
log.error(msg, e);
|
}
|
||||||
throw new DeviceManagementException(msg, e);
|
String msg =
|
||||||
}
|
"Error while enrolling the Android device : " + device.getDeviceIdentifier();
|
||||||
return status;
|
log.error(msg, e);
|
||||||
}
|
throw new DeviceManagementException(msg, e);
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
|
public boolean modifyEnrollment(Device device) throws DeviceManagementException {
|
||||||
boolean isEnrolled = false;
|
boolean status;
|
||||||
try {
|
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
|
||||||
if (log.isDebugEnabled()) {
|
try {
|
||||||
log.debug("Checking the enrollment of Android device : " + deviceId.getId());
|
if (log.isDebugEnabled()) {
|
||||||
}
|
log.debug("Modifying the Android device enrollment data");
|
||||||
MobileDevice mobileDevice =
|
}
|
||||||
mobileDeviceManagementDAOFactory.getMobileDeviceDAO().getMobileDevice(
|
AndroidDAOFactory.beginTransaction();
|
||||||
deviceId.getId());
|
status = mobileDeviceManagementDAOFactory.getMobileDeviceDAO()
|
||||||
if (mobileDevice != null) {
|
.updateMobileDevice(mobileDevice);
|
||||||
isEnrolled = true;
|
AndroidDAOFactory.commitTransaction();
|
||||||
}
|
} catch (MobileDeviceManagementDAOException e) {
|
||||||
} catch (MobileDeviceManagementDAOException e) {
|
try {
|
||||||
String msg = "Error while checking the enrollment status of Android device : " +
|
AndroidDAOFactory.rollbackTransaction();
|
||||||
deviceId.getId();
|
} catch (MobileDeviceManagementDAOException mobileDAOEx) {
|
||||||
log.error(msg, e);
|
String msg = "Error occurred while roll back the update device transaction :" +
|
||||||
throw new DeviceManagementException(msg, e);
|
device.toString();
|
||||||
}
|
log.warn(msg, mobileDAOEx);
|
||||||
return isEnrolled;
|
}
|
||||||
}
|
String msg = "Error while updating the enrollment of the Android device : " +
|
||||||
|
device.getDeviceIdentifier();
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new DeviceManagementException(msg, e);
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException {
|
public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
|
||||||
return true;
|
boolean status;
|
||||||
}
|
try {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Dis-enrolling Android device : " + deviceId);
|
||||||
|
}
|
||||||
|
AndroidDAOFactory.beginTransaction();
|
||||||
|
status = mobileDeviceManagementDAOFactory.getMobileDeviceDAO()
|
||||||
|
.deleteMobileDevice(deviceId.getId());
|
||||||
|
AndroidDAOFactory.commitTransaction();
|
||||||
|
} catch (MobileDeviceManagementDAOException e) {
|
||||||
|
try {
|
||||||
|
AndroidDAOFactory.rollbackTransaction();
|
||||||
|
} catch (MobileDeviceManagementDAOException mobileDAOEx) {
|
||||||
|
String msg = "Error occurred while roll back the device dis enrol transaction :" +
|
||||||
|
deviceId.toString();
|
||||||
|
log.warn(msg, mobileDAOEx);
|
||||||
|
}
|
||||||
|
String msg = "Error while removing the Android device : " + deviceId.getId();
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new DeviceManagementException(msg, e);
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setActive(DeviceIdentifier deviceId, boolean status)
|
public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
|
||||||
throws DeviceManagementException {
|
boolean isEnrolled = false;
|
||||||
return true;
|
try {
|
||||||
}
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Checking the enrollment of Android device : " + deviceId.getId());
|
||||||
|
}
|
||||||
|
MobileDevice mobileDevice =
|
||||||
|
mobileDeviceManagementDAOFactory.getMobileDeviceDAO().getMobileDevice(
|
||||||
|
deviceId.getId());
|
||||||
|
if (mobileDevice != null) {
|
||||||
|
isEnrolled = true;
|
||||||
|
}
|
||||||
|
} catch (MobileDeviceManagementDAOException e) {
|
||||||
|
String msg = "Error while checking the enrollment status of Android device : " +
|
||||||
|
deviceId.getId();
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new DeviceManagementException(msg, e);
|
||||||
|
}
|
||||||
|
return isEnrolled;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
|
public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException {
|
||||||
Device device;
|
return true;
|
||||||
try {
|
}
|
||||||
if (log.isDebugEnabled()) {
|
|
||||||
log.debug("Getting the details of Android device : " + deviceId.getId());
|
|
||||||
}
|
|
||||||
MobileDevice mobileDevice = mobileDeviceManagementDAOFactory.getMobileDeviceDAO().
|
|
||||||
getMobileDevice(deviceId.getId());
|
|
||||||
device = MobileDeviceManagementUtil.convertToDevice(mobileDevice);
|
|
||||||
} catch (MobileDeviceManagementDAOException e) {
|
|
||||||
String msg = "Error while fetching the Android device : " + deviceId.getId();
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new DeviceManagementException(msg, e);
|
|
||||||
}
|
|
||||||
return device;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType)
|
public boolean setActive(DeviceIdentifier deviceId, boolean status)
|
||||||
throws DeviceManagementException {
|
throws DeviceManagementException {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isClaimable(DeviceIdentifier deviceIdentifier) throws DeviceManagementException {
|
public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
|
||||||
return false;
|
Device device;
|
||||||
}
|
try {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Getting the details of Android device : " + deviceId.getId());
|
||||||
|
}
|
||||||
|
MobileDevice mobileDevice = mobileDeviceManagementDAOFactory.getMobileDeviceDAO().
|
||||||
|
getMobileDevice(deviceId.getId());
|
||||||
|
device = MobileDeviceManagementUtil.convertToDevice(mobileDevice);
|
||||||
|
} catch (MobileDeviceManagementDAOException e) {
|
||||||
|
String msg = "Error while fetching the Android device : " + deviceId.getId();
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new DeviceManagementException(msg, e);
|
||||||
|
}
|
||||||
|
return device;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setStatus(DeviceIdentifier deviceIdentifier, String currentUser,
|
public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType)
|
||||||
EnrolmentInfo.Status status) throws DeviceManagementException {
|
throws DeviceManagementException {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device) throws DeviceManagementException {
|
public boolean isClaimable(DeviceIdentifier deviceIdentifier) throws DeviceManagementException {
|
||||||
boolean status;
|
return false;
|
||||||
Device deviceDB = this.getDevice(deviceIdentifier);
|
}
|
||||||
// This object holds the current persisted device object
|
|
||||||
MobileDevice mobileDeviceDB = MobileDeviceManagementUtil.convertToMobileDevice(deviceDB);
|
|
||||||
|
|
||||||
// This object holds the newly received device object from response
|
@Override
|
||||||
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
|
public boolean setStatus(DeviceIdentifier deviceIdentifier, String currentUser,
|
||||||
|
EnrolmentInfo.Status status) throws DeviceManagementException {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Updating current object features using newer ones
|
@Override
|
||||||
mobileDeviceDB.setLatitude(mobileDevice.getLatitude());
|
public boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device)
|
||||||
mobileDeviceDB.setLongitude(mobileDevice.getLongitude());
|
throws DeviceManagementException {
|
||||||
mobileDeviceDB.setDeviceProperties(mobileDevice.getDeviceProperties());
|
boolean status;
|
||||||
|
Device deviceDB = this.getDevice(deviceIdentifier);
|
||||||
|
// This object holds the current persisted device object
|
||||||
|
MobileDevice mobileDeviceDB = MobileDeviceManagementUtil.convertToMobileDevice(deviceDB);
|
||||||
|
|
||||||
try {
|
// This object holds the newly received device object from response
|
||||||
if (log.isDebugEnabled()) {
|
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
|
||||||
log.debug(
|
|
||||||
"updating the details of Android device : " + device.getDeviceIdentifier());
|
|
||||||
}
|
|
||||||
AndroidDAOFactory.beginTransaction();
|
|
||||||
status = mobileDeviceManagementDAOFactory.getMobileDeviceDAO()
|
|
||||||
.updateMobileDevice(mobileDeviceDB);
|
|
||||||
AndroidDAOFactory.commitTransaction();
|
|
||||||
} catch (MobileDeviceManagementDAOException e) {
|
|
||||||
try {
|
|
||||||
AndroidDAOFactory.rollbackTransaction();
|
|
||||||
} catch (MobileDeviceManagementDAOException mobileDAOEx) {
|
|
||||||
String msg = "Error occurred while roll back the update device info transaction :" + device.toString();
|
|
||||||
log.warn(msg, mobileDAOEx);
|
|
||||||
}
|
|
||||||
String msg =
|
|
||||||
"Error while updating the Android device : " + device.getDeviceIdentifier();
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new DeviceManagementException(msg, e);
|
|
||||||
}
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
// Updating current object features using newer ones
|
||||||
public List<Device> getAllDevices() throws DeviceManagementException {
|
mobileDeviceDB.setLatitude(mobileDevice.getLatitude());
|
||||||
List<Device> devices = null;
|
mobileDeviceDB.setLongitude(mobileDevice.getLongitude());
|
||||||
try {
|
mobileDeviceDB.setDeviceProperties(mobileDevice.getDeviceProperties());
|
||||||
if (log.isDebugEnabled()) {
|
|
||||||
log.debug("Fetching the details of all Android devices");
|
try {
|
||||||
}
|
if (log.isDebugEnabled()) {
|
||||||
List<MobileDevice> mobileDevices =
|
log.debug(
|
||||||
mobileDeviceManagementDAOFactory.getMobileDeviceDAO().
|
"updating the details of Android device : " + device.getDeviceIdentifier());
|
||||||
getAllMobileDevices();
|
}
|
||||||
if (mobileDevices != null) {
|
AndroidDAOFactory.beginTransaction();
|
||||||
devices = new ArrayList<Device>();
|
status = mobileDeviceManagementDAOFactory.getMobileDeviceDAO()
|
||||||
for (MobileDevice mobileDevice : mobileDevices) {
|
.updateMobileDevice(mobileDeviceDB);
|
||||||
devices.add(MobileDeviceManagementUtil.convertToDevice(mobileDevice));
|
AndroidDAOFactory.commitTransaction();
|
||||||
}
|
} catch (MobileDeviceManagementDAOException e) {
|
||||||
}
|
try {
|
||||||
} catch (MobileDeviceManagementDAOException e) {
|
AndroidDAOFactory.rollbackTransaction();
|
||||||
String msg = "Error while fetching all Android devices.";
|
} catch (MobileDeviceManagementDAOException mobileDAOEx) {
|
||||||
log.error(msg, e);
|
String msg = "Error occurred while roll back the update device info transaction :" +
|
||||||
throw new DeviceManagementException(msg, e);
|
device.toString();
|
||||||
}
|
log.warn(msg, mobileDAOEx);
|
||||||
return devices;
|
}
|
||||||
}
|
String msg =
|
||||||
|
"Error while updating the Android device : " + device.getDeviceIdentifier();
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new DeviceManagementException(msg, e);
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Device> getAllDevices() throws DeviceManagementException {
|
||||||
|
List<Device> devices = null;
|
||||||
|
try {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Fetching the details of all Android devices");
|
||||||
|
}
|
||||||
|
List<MobileDevice> mobileDevices =
|
||||||
|
mobileDeviceManagementDAOFactory.getMobileDeviceDAO().
|
||||||
|
getAllMobileDevices();
|
||||||
|
if (mobileDevices != null) {
|
||||||
|
devices = new ArrayList<Device>();
|
||||||
|
for (MobileDevice mobileDevice : mobileDevices) {
|
||||||
|
devices.add(MobileDeviceManagementUtil.convertToDevice(mobileDevice));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (MobileDeviceManagementDAOException e) {
|
||||||
|
String msg = "Error while fetching all Android devices.";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new DeviceManagementException(msg, e);
|
||||||
|
}
|
||||||
|
return devices;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,6 +21,8 @@ package org.wso2.carbon.device.mgt.mobile.impl.windows;
|
|||||||
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.device.mgt.common.*;
|
import org.wso2.carbon.device.mgt.common.*;
|
||||||
|
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
|
||||||
|
import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration;
|
||||||
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
|
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
|
||||||
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory;
|
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory;
|
||||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice;
|
import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice;
|
||||||
@ -28,6 +30,7 @@ import org.wso2.carbon.device.mgt.mobile.impl.windows.dao.WindowsDAOFactory;
|
|||||||
import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil;
|
import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class WindowsDeviceManager implements DeviceManager {
|
public class WindowsDeviceManager implements DeviceManager {
|
||||||
|
|
||||||
@ -43,6 +46,17 @@ public class WindowsDeviceManager implements DeviceManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean saveConfiguration(TenantConfiguration tenantConfiguration)
|
||||||
|
throws DeviceManagementException {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TenantConfiguration getConfiguration() throws DeviceManagementException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean modifyEnrollment(Device device) throws DeviceManagementException {
|
public boolean modifyEnrollment(Device device) throws DeviceManagementException {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -36,6 +36,7 @@ import org.wso2.carbon.device.mgt.mobile.impl.windows.WindowsDeviceManagementSer
|
|||||||
import org.wso2.carbon.device.mgt.mobile.impl.windows.WindowsPolicyMonitoringService;
|
import org.wso2.carbon.device.mgt.mobile.impl.windows.WindowsPolicyMonitoringService;
|
||||||
import org.wso2.carbon.ndatasource.core.DataSourceService;
|
import org.wso2.carbon.ndatasource.core.DataSourceService;
|
||||||
import org.wso2.carbon.policy.mgt.common.spi.PolicyMonitoringService;
|
import org.wso2.carbon.policy.mgt.common.spi.PolicyMonitoringService;
|
||||||
|
import org.wso2.carbon.registry.core.service.RegistryService;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -48,6 +49,9 @@ import java.util.Map;
|
|||||||
* policy="dynamic"
|
* policy="dynamic"
|
||||||
* bind="setDataSourceService"
|
* bind="setDataSourceService"
|
||||||
* unbind="unsetDataSourceService"
|
* unbind="unsetDataSourceService"
|
||||||
|
* @scr.reference name="registry.service"
|
||||||
|
* interface="org.wso2.carbon.registry.core.service.RegistryService" cardinality="0..1"
|
||||||
|
* policy="dynamic" bind="setRegistryService" unbind="unsetRegistryService"
|
||||||
* <p/>
|
* <p/>
|
||||||
* Adding reference to API Manager Configuration service is an unavoidable hack to get rid of NPEs thrown while
|
* Adding reference to API Manager Configuration service is an unavoidable hack to get rid of NPEs thrown while
|
||||||
* initializing APIMgtDAOs attempting to register APIs programmatically. APIMgtDAO needs to be proper cleaned up
|
* initializing APIMgtDAOs attempting to register APIs programmatically. APIMgtDAO needs to be proper cleaned up
|
||||||
@ -149,4 +153,15 @@ public class MobileDeviceManagementServiceComponent {
|
|||||||
//do nothing
|
//do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void setRegistryService(RegistryService registryService) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("RegistryService acquired");
|
||||||
|
}
|
||||||
|
MobileDeviceManagementServiceDataHolder.getInstance().setRegistryService(registryService);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void unsetRegistryService(RegistryService registryService) {
|
||||||
|
MobileDeviceManagementServiceDataHolder.getInstance().setRegistryService(null);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* you may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.wso2.carbon.device.mgt.mobile.internal;
|
||||||
|
|
||||||
|
import org.wso2.carbon.registry.core.service.RegistryService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DataHolder class of Mobile plugins component.
|
||||||
|
*/
|
||||||
|
public class MobileDeviceManagementServiceDataHolder {
|
||||||
|
|
||||||
|
private RegistryService registryService;
|
||||||
|
|
||||||
|
private static MobileDeviceManagementServiceDataHolder thisInstance = new MobileDeviceManagementServiceDataHolder();
|
||||||
|
|
||||||
|
private MobileDeviceManagementServiceDataHolder() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MobileDeviceManagementServiceDataHolder getInstance() {
|
||||||
|
return thisInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RegistryService getRegistryService() {
|
||||||
|
return registryService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRegistryService(RegistryService registryService) {
|
||||||
|
this.registryService = registryService;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -21,11 +21,19 @@ package org.wso2.carbon.device.mgt.mobile.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.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||||
import org.wso2.carbon.device.mgt.common.Device;
|
import org.wso2.carbon.device.mgt.common.Device;
|
||||||
|
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
|
||||||
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.operation.mgt.Operation;
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.common.MobileDeviceMgtPluginException;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.common.MobilePluginConstants;
|
||||||
import org.wso2.carbon.device.mgt.mobile.dto.*;
|
import org.wso2.carbon.device.mgt.mobile.dto.*;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.internal.MobileDeviceManagementServiceDataHolder;
|
||||||
|
import org.wso2.carbon.registry.api.RegistryException;
|
||||||
|
import org.wso2.carbon.registry.api.Resource;
|
||||||
|
import org.wso2.carbon.registry.core.Registry;
|
||||||
|
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
@ -54,8 +62,9 @@ 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("Error occurred while parsing file, while converting " +
|
throw new DeviceManagementException(
|
||||||
"to a org.w3c.dom.Document : " + e.getMessage(), e);
|
"Error occurred while parsing file, while converting " +
|
||||||
|
"to a org.w3c.dom.Document : " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,16 +100,16 @@ public class MobileDeviceManagementUtil {
|
|||||||
mobileDevice.setLatitude(getPropertyValue(device, MOBILE_DEVICE_LATITUDE));
|
mobileDevice.setLatitude(getPropertyValue(device, MOBILE_DEVICE_LATITUDE));
|
||||||
mobileDevice.setLongitude(getPropertyValue(device, MOBILE_DEVICE_LONGITUDE));
|
mobileDevice.setLongitude(getPropertyValue(device, MOBILE_DEVICE_LONGITUDE));
|
||||||
|
|
||||||
if (device.getProperties() != null) {
|
if (device.getProperties() != null) {
|
||||||
Map<String, String> deviceProperties = new HashMap<String, String>();
|
Map<String, String> deviceProperties = new HashMap<String, String>();
|
||||||
for (Device.Property deviceProperty : device.getProperties()) {
|
for (Device.Property deviceProperty : device.getProperties()) {
|
||||||
deviceProperties.put(deviceProperty.getName(), deviceProperty.getValue());
|
deviceProperties.put(deviceProperty.getName(), deviceProperty.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
mobileDevice.setDeviceProperties(deviceProperties);
|
mobileDevice.setDeviceProperties(deviceProperties);
|
||||||
} else {
|
} else {
|
||||||
mobileDevice.setDeviceProperties(new HashMap<String, String>());
|
mobileDevice.setDeviceProperties(new HashMap<String, String>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return mobileDevice;
|
return mobileDevice;
|
||||||
}
|
}
|
||||||
@ -119,13 +128,15 @@ public class MobileDeviceManagementUtil {
|
|||||||
propertyList.add(getProperty(MOBILE_DEVICE_LONGITUDE, mobileDevice.getLongitude()));
|
propertyList.add(getProperty(MOBILE_DEVICE_LONGITUDE, mobileDevice.getLongitude()));
|
||||||
propertyList.add(getProperty(MOBILE_DEVICE_SERIAL, mobileDevice.getSerial()));
|
propertyList.add(getProperty(MOBILE_DEVICE_SERIAL, mobileDevice.getSerial()));
|
||||||
|
|
||||||
if (mobileDevice.getDeviceProperties() != null) {
|
if (mobileDevice.getDeviceProperties() != null) {
|
||||||
for (Map.Entry<String, String> deviceProperty : mobileDevice.getDeviceProperties().entrySet()) {
|
for (Map.Entry<String, String> deviceProperty : mobileDevice.getDeviceProperties()
|
||||||
propertyList.add(getProperty(deviceProperty.getKey(), deviceProperty.getValue()));
|
.entrySet()) {
|
||||||
}
|
propertyList
|
||||||
}
|
.add(getProperty(deviceProperty.getKey(), deviceProperty.getValue()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
device.setProperties(propertyList);
|
device.setProperties(propertyList);
|
||||||
device.setDeviceIdentifier(mobileDevice.getMobileDeviceId());
|
device.setDeviceIdentifier(mobileDevice.getMobileDeviceId());
|
||||||
}
|
}
|
||||||
return device;
|
return device;
|
||||||
@ -162,27 +173,121 @@ public class MobileDeviceManagementUtil {
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MobileFeature convertToMobileFeature(Feature feature) {
|
public static MobileFeature convertToMobileFeature(Feature feature) {
|
||||||
MobileFeature mobileFeature = new MobileFeature();
|
MobileFeature mobileFeature = new MobileFeature();
|
||||||
mobileFeature.setName(feature.getName());
|
mobileFeature.setName(feature.getName());
|
||||||
mobileFeature.setCode(feature.getCode());
|
mobileFeature.setCode(feature.getCode());
|
||||||
mobileFeature.setDescription(feature.getDescription());
|
mobileFeature.setDescription(feature.getDescription());
|
||||||
mobileFeature.setDeviceType(feature.getDeviceType());
|
mobileFeature.setDeviceType(feature.getDeviceType());
|
||||||
return mobileFeature;
|
return mobileFeature;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Feature convertToFeature(MobileFeature mobileFeature) {
|
public static Feature convertToFeature(MobileFeature mobileFeature) {
|
||||||
Feature feature = new Feature();
|
Feature feature = new Feature();
|
||||||
feature.setDescription(mobileFeature.getDescription());
|
feature.setDescription(mobileFeature.getDescription());
|
||||||
feature.setDeviceType(mobileFeature.getDeviceType());
|
feature.setDeviceType(mobileFeature.getDeviceType());
|
||||||
feature.setCode(mobileFeature.getCode());
|
feature.setCode(mobileFeature.getCode());
|
||||||
feature.setName(mobileFeature.getName());
|
feature.setName(mobileFeature.getName());
|
||||||
return feature;
|
return feature;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Registry getRegistry() throws MobileDeviceMgtPluginException {
|
||||||
|
try {
|
||||||
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||||
|
return MobileDeviceManagementServiceDataHolder.getInstance().getRegistryService()
|
||||||
|
.getConfigSystemRegistry(
|
||||||
|
tenantId);
|
||||||
|
} catch (RegistryException e) {
|
||||||
|
throw new MobileDeviceMgtPluginException(
|
||||||
|
"Error in retrieving conf registry instance: " +
|
||||||
|
e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Resource getRegistryResource(String path) throws MobileDeviceMgtPluginException {
|
||||||
|
try {
|
||||||
|
return MobileDeviceManagementUtil.getRegistry().get(path);
|
||||||
|
|
||||||
|
} catch (RegistryException e) {
|
||||||
|
throw new MobileDeviceMgtPluginException("Error in retrieving registry resource : " +
|
||||||
|
e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean putRegistryResource(String path,
|
||||||
|
Resource resource)
|
||||||
|
throws MobileDeviceMgtPluginException {
|
||||||
|
boolean status = false;
|
||||||
|
try {
|
||||||
|
MobileDeviceManagementUtil.getRegistry().beginTransaction();
|
||||||
|
MobileDeviceManagementUtil.getRegistry().put(path, resource);
|
||||||
|
MobileDeviceManagementUtil.getRegistry().commitTransaction();
|
||||||
|
status = true;
|
||||||
|
} catch (RegistryException e) {
|
||||||
|
throw new MobileDeviceMgtPluginException(
|
||||||
|
"Error occurred while persisting registry resource : " +
|
||||||
|
e.getMessage(), e);
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getResourcePath(String resourceName, String platform) {
|
||||||
|
String regPath = "";
|
||||||
|
switch (platform) {
|
||||||
|
case DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID:
|
||||||
|
regPath = MobilePluginConstants.MOBILE_CONFIG_REGISTRY_ROOT + "/" +
|
||||||
|
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID +
|
||||||
|
"/" + resourceName;
|
||||||
|
break;
|
||||||
|
case DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS:
|
||||||
|
regPath = MobilePluginConstants.MOBILE_CONFIG_REGISTRY_ROOT + "/" +
|
||||||
|
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS +
|
||||||
|
"/" + resourceName;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return regPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getPlatformConfigPath(String platform) {
|
||||||
|
String regPath = "";
|
||||||
|
switch (platform) {
|
||||||
|
case DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID:
|
||||||
|
regPath = MobilePluginConstants.MOBILE_CONFIG_REGISTRY_ROOT + "/" +
|
||||||
|
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID;
|
||||||
|
break;
|
||||||
|
case DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS:
|
||||||
|
regPath = MobilePluginConstants.MOBILE_CONFIG_REGISTRY_ROOT + "/" +
|
||||||
|
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return regPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean createRegistryCollection(String path)
|
||||||
|
throws MobileDeviceMgtPluginException {
|
||||||
|
try {
|
||||||
|
if (! MobileDeviceManagementUtil.getRegistry().resourceExists(path)) {
|
||||||
|
Resource resource = MobileDeviceManagementUtil.getRegistry().newCollection();
|
||||||
|
MobileDeviceManagementUtil.getRegistry().beginTransaction();
|
||||||
|
MobileDeviceManagementUtil.getRegistry().put(path, resource);
|
||||||
|
MobileDeviceManagementUtil.getRegistry().commitTransaction();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} catch (MobileDeviceMgtPluginException e) {
|
||||||
|
throw new MobileDeviceMgtPluginException(
|
||||||
|
"Error occurred while creating a registry collection : " +
|
||||||
|
e.getMessage(), e);
|
||||||
|
} catch (RegistryException e) {
|
||||||
|
throw new MobileDeviceMgtPluginException(
|
||||||
|
"Error occurred while creating a registry collection : " +
|
||||||
|
e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
70
pom.xml
70
pom.xml
@ -419,6 +419,72 @@
|
|||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Governance dependencies -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.registry.api</artifactId>
|
||||||
|
<version>${carbon.kernel.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.registry.core</artifactId>
|
||||||
|
<version>${carbon.kernel.version}</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>commons-io.wso2</groupId>
|
||||||
|
<artifactId>commons-io</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>net.sourceforge.findbugs</groupId>
|
||||||
|
<artifactId>annotations</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.eclipse.osgi</groupId>
|
||||||
|
<artifactId>org.eclipse.osgi.services</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.apache.ws.commons.schema.wso2</groupId>
|
||||||
|
<artifactId>XmlSchema</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.wso2.carbon</groupId>
|
||||||
|
<artifactId>javax.cache.wso2</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.wso2.carbon</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.registry.xboot</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.wso2.securevault</groupId>
|
||||||
|
<artifactId>org.wso2.securevault</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.compass-project.wso2</groupId>
|
||||||
|
<artifactId>compass</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.apache.abdera.wso2</groupId>
|
||||||
|
<artifactId>abdera</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.wso2.carbon</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.ndatasource.rdbms</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.apache.poi.wso2</groupId>
|
||||||
|
<artifactId>poi-scratchpad</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>commons-httpclient.wso2</groupId>
|
||||||
|
<artifactId>commons-httpclient</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>commons-pool.wso2</groupId>
|
||||||
|
<artifactId>commons-pool</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
@ -521,8 +587,8 @@
|
|||||||
<version>2.3.1</version>
|
<version>2.3.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<encoding>UTF-8</encoding>
|
<encoding>UTF-8</encoding>
|
||||||
<source>1.6</source>
|
<source>1.7</source>
|
||||||
<target>1.6</target>
|
<target>1.7</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user