From 50a17eb33d34d1afd4684cc67b9fcc90ac6f6c69 Mon Sep 17 00:00:00 2001 From: manoj Date: Mon, 19 Jan 2015 21:38:41 +0530 Subject: [PATCH] Refactor add new mobile service module to as parent to agent module --- .../wso2/carbon/device/mgt/common/Device.java | 24 +++++++++---------- .../mgt/core/DeviceManagementRepository.java | 5 ++++ .../DeviceManagementServiceComponent.java | 6 ++--- .../agents/android/jax-rs/pom.xml | 5 ++-- .../mobileservices/android/Device.java | 6 ++--- .../mobileservices/android/Enrollment.java | 6 ++--- .../src/main/webapp/WEB-INF/cxf-servlet.xml | 6 ++--- .../agents/windows/jax-rs/pom.xml | 3 +-- product/pom.xml | 7 +----- 9 files changed, 32 insertions(+), 36 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Device.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Device.java index 5d24754ab..94786b419 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Device.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Device.java @@ -23,29 +23,17 @@ import java.util.List; public class Device { private int id; - private String type; - private String description; - private String name; - private Long dateOfEnrolment; - private Long dateOfLastUpdate; - private String ownership; - private boolean status; - private int deviceTypeId; - private String deviceIdentifier; - private String owner; - private List features; - private List properties; @XmlElement @@ -56,6 +44,7 @@ public class Device { public void setId(int id) { this.id = id; } + @XmlElement public String getDescription() { return description; @@ -64,6 +53,7 @@ public class Device { public void setDescription(String description) { this.description = description; } + @XmlElement public String getName() { return name; @@ -72,6 +62,7 @@ public class Device { public void setName(String name) { this.name = name; } + @XmlElement public Long getDateOfEnrolment() { return dateOfEnrolment; @@ -80,6 +71,7 @@ public class Device { public void setDateOfEnrolment(Long dateOfEnrolment) { this.dateOfEnrolment = dateOfEnrolment; } + @XmlElement public Long getDateOfLastUpdate() { return dateOfLastUpdate; @@ -88,6 +80,7 @@ public class Device { public void setDateOfLastUpdate(Long dateOfLastUpdate) { this.dateOfLastUpdate = dateOfLastUpdate; } + @XmlElement public String getOwnership() { return ownership; @@ -96,6 +89,7 @@ public class Device { public void setOwnership(String ownership) { this.ownership = ownership; } + @XmlElement public boolean isStatus() { return status; @@ -104,6 +98,7 @@ public class Device { public void setStatus(boolean status) { this.status = status; } + @XmlElement public int getDeviceTypeId() { return deviceTypeId; @@ -112,6 +107,7 @@ public class Device { public void setDeviceTypeId(int deviceTypeId) { this.deviceTypeId = deviceTypeId; } + @XmlElement public String getDeviceIdentifier() { return deviceIdentifier; @@ -120,6 +116,7 @@ public class Device { public void setDeviceIdentifier(String deviceIdentifier) { this.deviceIdentifier = deviceIdentifier; } + @XmlElement public String getOwner() { return owner; @@ -128,6 +125,7 @@ public class Device { public void setOwner(String owner) { this.owner = owner; } + @XmlElement public List getFeatures() { return features; @@ -136,6 +134,7 @@ public class Device { public void setFeatures(List features) { this.features = features; } + @XmlElement public String getType() { return type; @@ -144,6 +143,7 @@ public class Device { public void setType(String type) { this.type = type; } + @XmlElement public List getProperties() { return properties; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepository.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepository.java index 3f3340c1f..8df667be2 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepository.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepository.java @@ -43,6 +43,11 @@ public class DeviceManagementRepository { } } + public void removeDeviceManagementProvider(DeviceManagerService provider) { + String deviceType = provider.getProviderType(); + providers.remove(deviceType); + } + public DeviceManagerService getDeviceManagementProvider(String type) { return providers.get(type); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java index daa67845b..525a9233b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java @@ -75,11 +75,8 @@ public class DeviceManagementServiceComponent { } setupDeviceManagementSchema(dsConfig); } - BundleContext bundleContext = componentContext.getBundleContext(); - bundleContext.registerService(DeviceManagementService.class.getName(), - new DeviceManagementService(), null); - + bundleContext.registerService(DeviceManagementService.class.getName(), new DeviceManagementService(), null); } catch (Throwable e) { String msg = "Error occurred while initializing device management core bundle"; log.error(msg, e); @@ -118,6 +115,7 @@ public class DeviceManagementServiceComponent { if (log.isDebugEnabled()) { log.debug("Unsetting Device Management Service"); } + this.getPluginRepository().removeDeviceManagementProvider(deviceManager); } /** diff --git a/product/modules/mobileservices/agents/android/jax-rs/pom.xml b/product/modules/mobileservices/agents/android/jax-rs/pom.xml index 6ee8f104b..43564dae7 100644 --- a/product/modules/mobileservices/agents/android/jax-rs/pom.xml +++ b/product/modules/mobileservices/agents/android/jax-rs/pom.xml @@ -22,15 +22,14 @@ org.wso2.cdmserver - wso2cdmserver-product + wso2cdmserver-product-mobileservices 2.0.0-SNAPSHOT - ../../../../pom.xml + ../../../pom.xml 4.0.0 org.wso2.carbon cdm-android-api - 1.0.0-SNAPSHOT JAX-RS Android API JAX-RS Android API war diff --git a/product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/Device.java b/product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/Device.java index cd1451fff..34b8b8a37 100644 --- a/product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/Device.java +++ b/product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/Device.java @@ -18,9 +18,9 @@ //org.wso2.carbon.... package org.wso2.cdmserver.mobileservices.android; -import cdm.api.android.common.AndroidAgentException; -import cdm.api.android.util.AndroidAPIUtils; -import cdm.api.android.util.Message; +import org.wso2.cdmserver.mobileservices.android.common.AndroidAgentException; +import org.wso2.cdmserver.mobileservices.android.util.AndroidAPIUtils; +import org.wso2.cdmserver.mobileservices.android.util.Message; import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/Enrollment.java b/product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/Enrollment.java index 0e337653a..5a53cfd61 100644 --- a/product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/Enrollment.java +++ b/product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/Enrollment.java @@ -18,9 +18,9 @@ package org.wso2.cdmserver.mobileservices.android; -import cdm.api.android.common.AndroidAgentException; -import cdm.api.android.util.AndroidAPIUtils; -import cdm.api.android.util.Message; +import org.wso2.cdmserver.mobileservices.android.common.AndroidAgentException; +import org.wso2.cdmserver.mobileservices.android.util.AndroidAPIUtils; +import org.wso2.cdmserver.mobileservices.android.util.Message; import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/product/modules/mobileservices/agents/android/jax-rs/src/main/webapp/WEB-INF/cxf-servlet.xml b/product/modules/mobileservices/agents/android/jax-rs/src/main/webapp/WEB-INF/cxf-servlet.xml index ac8cda0d7..a58b5fc25 100644 --- a/product/modules/mobileservices/agents/android/jax-rs/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/product/modules/mobileservices/agents/android/jax-rs/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -51,9 +51,9 @@ - - + + - + diff --git a/product/modules/mobileservices/agents/windows/jax-rs/pom.xml b/product/modules/mobileservices/agents/windows/jax-rs/pom.xml index 1b3963e4b..ec7b11099 100644 --- a/product/modules/mobileservices/agents/windows/jax-rs/pom.xml +++ b/product/modules/mobileservices/agents/windows/jax-rs/pom.xml @@ -22,13 +22,12 @@ org.wso2.cdmserver wso2cdmserver-product 2.0.0-SNAPSHOT - ../../../../pom.xml + ../../../pom.xml 4.0.0 org.wso2.carbon cdm-windows-api - 1.0.0-SNAPSHOT JAX-RS Windows API JAX-RS Windows API war diff --git a/product/pom.xml b/product/pom.xml index 0d2fdedd5..6df2ce31d 100644 --- a/product/pom.xml +++ b/product/pom.xml @@ -34,11 +34,6 @@ WSO2 Connected Device Manager (CDM) - Parent - - modules/agents/windows/jax-rs - modules/agents/android/jax-rs - modules/p2-profile-gen - modules/distribution - modules/integration + modules/mobileservices