From 1ed02a5c01e0106787dfbbf7ab974539cbd02bbb Mon Sep 17 00:00:00 2001 From: prabathabey Date: Thu, 4 Dec 2014 18:18:30 +0530 Subject: [PATCH 1/6] Adding an interface method "getProviderType" to identify a particular implementation of DeviceManagerService and pom cleanup --- .../org.wso2.carbon.device.mgt.common/pom.xml | 4 --- .../mgt/common/spi/DeviceManagerService.java | 36 +++++++++++++------ .../org.wso2.carbon.device.mgt.core/pom.xml | 4 +-- .../internal/DeviceMgtServiceComponent.java | 2 +- 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml index 80fd2aa7ab3..ad7e005500e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml @@ -19,10 +19,6 @@ - - org.apache.felix - maven-scr-plugin - org.apache.felix maven-bundle-plugin diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManagerService.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManagerService.java index e73a0af7666..c64c0ad0f56 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManagerService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManagerService.java @@ -1,12 +1,12 @@ /** * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - *

+ * * Licensed 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 - *

+ * + * 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. @@ -26,23 +26,31 @@ import java.util.List; */ public interface DeviceManagerService { + /** + * Method to retrieve the provider type that implements DeviceManagerService interface + * @return Returns provider type + */ + String getProviderType(); /** * Method to enrolling a particular device of type mobile, IoT, etc within CDM. - * @param device Metadata corresponding to the device being enrolled + * + * @param device Metadata corresponding to the device being enrolled * @throws DeviceManagementException If some unusual behaviour is observed while enrolling a device */ - void enrolDevice(Device device) throws DeviceManagementException; + void enrollDevice(Device device) throws DeviceManagementException; /** * Method to modify the metadata corresponding to device enrollment + * * @param device Modified device enrollment related metadata - * @throws DeviceManagementException If some unusual behaviour is observed while modify the enrollment of a - * device + * @throws DeviceManagementException If some unusual behaviour is observed while modify the enrollment of a + * device */ - void modifyEnrolment(Device device) throws DeviceManagementException; + void modifyEnrollment(Device device) throws DeviceManagementException; /** * Method to disenroll a particular device from CDM. + * * @param type Device Type * @param deviceId Device Identifier * @throws DeviceManagementException @@ -51,6 +59,7 @@ public interface DeviceManagerService { /** * Method to retrieve the status of the registration process of a particular device. + * * @param type Device Type * @param deviceId Device Identifier * @return Status of enrollment @@ -60,6 +69,7 @@ public interface DeviceManagerService { /** * Method to retrieve the status of a particular device. + * * @param type Device Type * @param deviceId Device Identifier * @return Returns if the device is active @@ -70,6 +80,7 @@ public interface DeviceManagerService { /** * Method to set the status indicating whether a particular device registered within CDM is enabled at a given * moment. + * * @param status Indicates whether the device is active * @throws DeviceManagementException If some unusual behaviour is observed while enrolling a device */ @@ -77,6 +88,7 @@ public interface DeviceManagerService { /** * Method to retrieve metadata of all devices registered within CDM corresponding to a particular device type. + * * @param type Device Type * @return List of metadata corresponding to all devices registered within CDM */ @@ -84,16 +96,18 @@ public interface DeviceManagerService { /** * Method to retrieve metadata of a device corresponding to a particular type that carries a specific identifier. + * * @param type Device Type * @param deviceId Device Identifier - * @return Metadata corresponding to a particular device + * @return Metadata corresponding to a particular device * @throws DeviceManagementException If some unusual behaviour is observed while enrolling a device */ Device getDeviceInfo(String type, String deviceId) throws DeviceManagementException; /** * Method to set the ownership type of a particular device. i.e. BYOD, COPE - * @param ownershipType Type of ownership + * + * @param ownershipType Type of ownership * @throws DeviceManagementException If some unusual behaviour is observed while enrolling a device */ void setOwnership(String ownershipType) throws DeviceManagementException; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml index aa5f4e9a548..a1995bcceec 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml @@ -53,8 +53,7 @@ Device Management Core Bundle org.wso2.carbon.device.mgt.core.internal - org.apache.axis2.*; - version="${axis2.osgi.version.range}", + org.apache.axis2.*;version="${axis2.osgi.version.range}", org.osgi.framework, org.osgi.service.component, org.apache.commons.logging, @@ -90,7 +89,6 @@ org.wso2.carbon org.wso2.carbon.logging - ${carbon.kernel.version} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceMgtServiceComponent.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceMgtServiceComponent.java index 1703d23fd54..557de2cf94b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceMgtServiceComponent.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceMgtServiceComponent.java @@ -22,7 +22,7 @@ import org.wso2.carbon.device.mgt.common.spi.DeviceManagerService; /** * @scr.component name="org.wso2.carbon.device.manager" immediate="true" * @scr.reference name="device.manager.service" - * interface="org.wso2.carbon.device.mgt.common.spi.DeviceManager" cardinality="1..n" + * interface="org.wso2.carbon.device.mgt.common.spi.DeviceManagerService" cardinality="1..n" * policy="dynamic" bind="setDeviceManagerService" unbind="unsetDeviceManagerService" */ public class DeviceMgtServiceComponent { From 6e9366bfbfb09bcf29ec267ab512f6696a4cbff1 Mon Sep 17 00:00:00 2001 From: prabathabey Date: Thu, 4 Dec 2014 18:20:17 +0530 Subject: [PATCH 2/6] Adding SCR plugin info --- components/device-mgt/pom.xml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index 8ec21df4bb1..bcfbf8edfd9 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -39,6 +39,7 @@ org.wso2.carbon.device.mgt.core org.wso2.carbon.device.mgt.common + org.wso2.carbon.device.mgt.mobile.impl @@ -63,7 +64,32 @@ org.wso2.carbon.device.mgt.common 2.0.0-SNAPSHOT + + org.eclipse.osgi + org.eclipse.osgi.services + 3.3.100.v20120522-1822 + + + + + + org.apache.felix + maven-scr-plugin + 1.7.2 + + + generate-scr-scrdescriptor + + scr + + + + + + + + From 95b555b11c5764694fb4bc9621872b956e05406f Mon Sep 17 00:00:00 2001 From: Geeth Munasinghe Date: Thu, 4 Dec 2014 18:20:57 +0530 Subject: [PATCH 3/6] Adding Constructors to the PDP exceptioon class --- .../org.wso2.carbon.policy.evalutor/pom.xml | 5 --- .../carbon/policy/evaluator/PDPException.java | 34 ++++++++++++++++++- .../wso2/carbon/policy/mgt/common/Policy.java | 3 ++ 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/components/policy-mgt/org.wso2.carbon.policy.evalutor/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.evalutor/pom.xml index 3d72835c751..790e2952733 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.evalutor/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.evalutor/pom.xml @@ -78,11 +78,6 @@ org.wso2.carbon org.wso2.carbon.logging - - org.wso2.carbon - org.wso2.carbon.logging - ${carbon.kernel.version} - diff --git a/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/PDPException.java b/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/PDPException.java index 799efadeb00..c650e371a43 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/PDPException.java +++ b/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/PDPException.java @@ -18,5 +18,37 @@ package org.wso2.carbon.policy.evaluator; -public class PDPException { +public class PDPException extends Exception { + + private String pdpErrorMessage; + + public String getPdpErrorMessage() { + return pdpErrorMessage; + } + + public void setPdpErrorMessage(String pdpErrorMessage) { + this.pdpErrorMessage = pdpErrorMessage; + } + + public PDPException(String message) { + setPdpErrorMessage(message); + } + + public PDPException(String message, Exception ex) { + super(message, ex); + setPdpErrorMessage(message); + } + + public PDPException(String message, Throwable cause) { + super(message, cause); + setPdpErrorMessage(message); + } + + public PDPException(Throwable cause) { + super(cause); + } + + public PDPException(){ + super(); + } } diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Policy.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Policy.java index ddebf9e1e1a..29184b24bdf 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Policy.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Policy.java @@ -18,9 +18,12 @@ package org.wso2.carbon.policy.mgt.common; +import java.util.List; + public class Policy { private int id; private String policyName; + private List featuresList; public static class Features { From 7ebb6fba4d8d458eece79d1dfe9986d459d01d58 Mon Sep 17 00:00:00 2001 From: prabathabey Date: Thu, 4 Dec 2014 18:29:59 +0530 Subject: [PATCH 4/6] Fixing mobile related implementations of DeviceManagerService SPI to be able to support newly added getProviderType method --- .../impl/android/AndroidDeviceManagerService.java | 9 ++++++++- .../mgt/mobile/impl/ios/IOSDeviceManagerService.java | 10 +++++++++- .../impl/windows/WindowsDeviceManagerService.java | 12 ++++++++++-- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManagerService.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManagerService.java index 74a046cba3d..aa10e188695 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManagerService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManagerService.java @@ -27,7 +27,14 @@ import java.util.List; */ public class AndroidDeviceManagerService implements DeviceManagerService { - @Override + private static final String DEVICE_MANAGER_ANDROID = "android"; + + @Override + public String getProviderType() { + return DEVICE_MANAGER_ANDROID; + } + + @Override public void enrollDevice(Device device) throws DeviceManagementException { } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/IOSDeviceManagerService.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/IOSDeviceManagerService.java index 1907f2636ea..cf174c5cf21 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/IOSDeviceManagerService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/IOSDeviceManagerService.java @@ -26,7 +26,15 @@ import java.util.List; * This represents the iOS implementation of DeviceManagerService. * */ public class IOSDeviceManagerService implements DeviceManagerService { - @Override + + private static final String DEVICE_MANAGER_IOS = "ios"; + + @Override + public String getProviderType() { + return DEVICE_MANAGER_IOS; + } + + @Override public void enrollDevice(Device device) throws DeviceManagementException { } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManagerService.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManagerService.java index 98a339448bd..9efa62bb02d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManagerService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManagerService.java @@ -25,8 +25,16 @@ import java.util.List; /** * This represents the Windows implementation of DeviceManagerService. */ -public class WindowsDeviceManagerService implements DeviceManagerService{ - @Override +public class WindowsDeviceManagerService implements DeviceManagerService { + + private static final String DEVICE_MANAGER_WINDOWS = "windows"; + + @Override + public String getProviderType() { + return DEVICE_MANAGER_WINDOWS; + } + + @Override public void enrollDevice(Device device) throws DeviceManagementException { } From 5fb3dec2ab1c8c4a4839c3d8a0e81f27fec716a2 Mon Sep 17 00:00:00 2001 From: Geeth Munasinghe Date: Fri, 5 Dec 2014 10:32:22 +0530 Subject: [PATCH 5/6] Fixing Exception class in Policy Mgt --- .../wso2/carbon/policy/mgt/common/PolicyManagementException.java | 1 - 1 file changed, 1 deletion(-) diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyManagementException.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyManagementException.java index 9e087ff3d81..524f669d6a1 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyManagementException.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyManagementException.java @@ -45,7 +45,6 @@ public class PolicyManagementException extends Exception { setPolicyErrorMessage(message); } - public PolicyManagementException() { super(); } From 63360243532c7c751b7bfeffcf5c99f867e0f9dd Mon Sep 17 00:00:00 2001 From: Geeth Munasinghe Date: Fri, 5 Dec 2014 10:48:12 +0530 Subject: [PATCH 6/6] Adding the feature and exception class to repo --- .../carbon/policy/mgt/common/Feature.java | 27 +++++++++ .../common/FeatureManagementException.java | 55 +++++++++++++++++++ .../wso2/carbon/policy/mgt/common/Policy.java | 9 +-- 3 files changed, 83 insertions(+), 8 deletions(-) create mode 100644 components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Feature.java create mode 100644 components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/FeatureManagementException.java diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Feature.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Feature.java new file mode 100644 index 00000000000..b06a59e940c --- /dev/null +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Feature.java @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2005-2014, 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.policy.mgt.common; + +public class Feature { + + private String code; + private String name; + private Object attribute; + +} diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/FeatureManagementException.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/FeatureManagementException.java new file mode 100644 index 00000000000..cd87922b6e8 --- /dev/null +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/FeatureManagementException.java @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2014, 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.policy.mgt.common; + +public class FeatureManagementException extends Exception{ + + private String errorMessage; + + public String getErrorMessage() { + return errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + + public FeatureManagementException(String message) { + super(message); + setErrorMessage(message); + } + + public FeatureManagementException(String message, Exception ex) { + super(message, ex); + setErrorMessage(message); + } + + public FeatureManagementException(String message, Throwable cause) { + super(message, cause); + setErrorMessage(message); + } + + public FeatureManagementException() { + super(); + } + + public FeatureManagementException(Throwable cause) { + super(cause); + } +} diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Policy.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Policy.java index 29184b24bdf..192745c1ec8 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Policy.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Policy.java @@ -23,13 +23,6 @@ import java.util.List; public class Policy { private int id; private String policyName; - private List featuresList; + private List featuresList; - - public static class Features { - - private String code; - private String name; - private Object attribute; - } }