From 1db2b40790b4ce67ed5556599884bc7414e7eff4 Mon Sep 17 00:00:00 2001 From: manoj Date: Tue, 13 Jan 2015 10:43:59 +0530 Subject: [PATCH] Android Services Refactor --- .../carbon/device/mgt/core/DeviceManager.java | 1 + .../device/mgt/core/DeviceManagerImpl.java | 3 +- .../config/DeviceConfigurationManager.java | 4 - .../core/service/DeviceManagementService.java | 110 +++++++++--------- .../src/main/java/cdm/api/android/Device.java | 4 +- .../main/java/cdm/api/android/Enrollment.java | 6 +- product/modules/p2-profile-gen/pom.xml | 19 ++- 7 files changed, 74 insertions(+), 73 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManager.java index 124939f8bd7..ad95758d323 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManager.java @@ -21,6 +21,7 @@ import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.OperationManager; +import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException; import java.util.List; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagerImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagerImpl.java index a2b6496747b..a242e3df31f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagerImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagerImpl.java @@ -58,8 +58,7 @@ public class DeviceManagerImpl implements DeviceManager { this.getDeviceDAO().addDevice(deviceDto); } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while enrolling the device '" + device.getId() + "'", - e); + throw new DeviceManagementException("Error occurred while enrolling the device '" + device.getId() + "'", e); } return status; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceConfigurationManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceConfigurationManager.java index 3c5a6073a2c..f9f99ffba94 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceConfigurationManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceConfigurationManager.java @@ -71,8 +71,4 @@ public class DeviceConfigurationManager { return currentDeviceConfig; } - public DataSourceConfig getDataSourceConfig() { - return currentDeviceConfig.getDeviceMgtRepository().getDataSourceConfig(); - } - } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementService.java index 0cbb3a1cdf4..8ddebb57409 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementService.java @@ -19,7 +19,6 @@ import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.OperationManager; -import org.wso2.carbon.device.mgt.common.spi.DeviceManagerService; import org.wso2.carbon.device.mgt.core.DeviceManager; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; @@ -27,60 +26,61 @@ import java.util.List; public class DeviceManagementService implements DeviceManager { - @Override - public boolean enrollDevice(Device device) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManager().enrollDevice(device); - } - - @Override - public boolean modifyEnrollment(Device device) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManager().modifyEnrollment(device); - } - - @Override - public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManager() - .disenrollDevice(deviceId); - } - - @Override - public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManager().isEnrolled(deviceId); - } - - @Override - public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManager().isActive(deviceId); - } - - @Override - public boolean setActive(DeviceIdentifier deviceId, boolean status) - throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManager() - .setActive(deviceId, status); - } - - @Override - public List getAllDevices(String type) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManager().getAllDevices(type); - } - - @Override - public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManager().getDevice(deviceId); - } - - @Override - public boolean updateDeviceInfo(Device device) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManager().updateDeviceInfo(device); - } - - @Override - public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) - throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManager() - .setOwnership(deviceId, ownershipType); - } + @Override + public boolean enrollDevice(Device device) throws DeviceManagementException { + return DeviceManagementDataHolder.getInstance().getDeviceManager().enrollDevice(device); + } + + @Override + public boolean modifyEnrollment(Device device) throws DeviceManagementException { + return DeviceManagementDataHolder.getInstance().getDeviceManager().modifyEnrollment(device); + } + + @Override + public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException { + return DeviceManagementDataHolder.getInstance().getDeviceManager() + .disenrollDevice(deviceId); + } + + @Override + public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException { + return DeviceManagementDataHolder.getInstance().getDeviceManager().isEnrolled(deviceId); + } + + @Override + public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException { + return DeviceManagementDataHolder.getInstance().getDeviceManager().isActive(deviceId); + } + + @Override + public boolean setActive(DeviceIdentifier deviceId, boolean status) throws DeviceManagementException { + return DeviceManagementDataHolder.getInstance().getDeviceManager().setActive(deviceId, status); + } + + @Override + public List getAllDevices(String type) throws DeviceManagementException { + return DeviceManagementDataHolder.getInstance().getDeviceManager().getAllDevices(type); + } + + @Override + public org.wso2.carbon.device.mgt.common.Device getDevice(DeviceIdentifier deviceId) + throws DeviceManagementException { + + Device device = DeviceManagementDataHolder.getInstance().getDeviceManager().getDevice(deviceId); + return device; + } + + @Override + public boolean updateDeviceInfo(Device device) throws DeviceManagementException { + return DeviceManagementDataHolder.getInstance().getDeviceManager().updateDeviceInfo(device); + } + + @Override + public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) + throws DeviceManagementException { + return DeviceManagementDataHolder.getInstance().getDeviceManager() + .setOwnership(deviceId, ownershipType); + } @Override public OperationManager getOperationManager(String type) throws DeviceManagementException { diff --git a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Device.java b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Device.java index f1cdfc64f48..19a67b99599 100644 --- a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Device.java +++ b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Device.java @@ -15,6 +15,7 @@ * specific language governing permissions and limitations * under the License. */ +//org.wso2.carbon.... package cdm.api.android; import cdm.api.android.common.AndroidAgentException; @@ -65,7 +66,6 @@ public class Device { } catch (DeviceManagementException e) { msg = "Error occurred while fetching the device list."; LOG.error(msg, e); - Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR); throw new AndroidAgentException(msg, e); } } @@ -80,7 +80,6 @@ public class Device { try { dmService = AndroidAPIUtils.getDeviceManagementService(); - } catch (DeviceManagementServiceException deviceMgtServiceEx) { String errorMsg = "Device management service error"; LOG.error(errorMsg, deviceMgtServiceEx); @@ -94,7 +93,6 @@ public class Device { Response.status(HttpStatus.SC_NOT_FOUND); } return device; - } catch (DeviceManagementException deviceMgtEx) { msg = "Error occurred while fetching the device information."; LOG.error(msg, deviceMgtEx); diff --git a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Enrollment.java b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Enrollment.java index 5c93765f525..6a4e00079e7 100644 --- a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Enrollment.java +++ b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Enrollment.java @@ -101,9 +101,9 @@ public class Enrollment { } return responseMsg; } catch (DeviceManagementException deviceMgtEx) { - String errormsg = "Error occurred while enrollment of the device."; - log.error(errormsg, deviceMgtEx); - throw new AndroidAgentException(errormsg, deviceMgtEx); + String errorMsg = "Error occurred while enrollment of the device."; + log.error(errorMsg, deviceMgtEx); + throw new AndroidAgentException(errorMsg, deviceMgtEx); } } diff --git a/product/modules/p2-profile-gen/pom.xml b/product/modules/p2-profile-gen/pom.xml index f1524dbb38b..95a5e55d257 100644 --- a/product/modules/p2-profile-gen/pom.xml +++ b/product/modules/p2-profile-gen/pom.xml @@ -153,12 +153,19 @@ org.wso2.carbon:org.wso2.carbon.identity.provider.server.feature:${carbon.platform.version} - - org.wso2.carbon:org.wso2.carbon.governance.metadata.server.feature:${carbon.platform.version} - - - org.wso2.carbon:org.wso2.carbon.registry.extensions.server.feature:${carbon.platform.version} - + + + org.wso2.carbon:org.wso2.carbon.registry.extensions.feature:${carbon.platform.version} + org.wso2.carbon:org.wso2.carbon.registry.ws.feature:${carbon.platform.version} + org.wso2.carbon:org.wso2.carbon.registry.ui.menu.governance.feature:${carbon.platform.version} + + + + + org.wso2.carbon:org.wso2.carbon.governance.metadata.feature:4.2.2 + org.wso2.carbon:org.wso2.carbon.governance.lifecycle.management.feature:4.2.1 + org.wso2.carbon:org.wso2.carbon.identity.core.server.feature:${carbon.platform.version}