From 983ca1562f960d3d6aab0e4a2c35d7cba9ded37f Mon Sep 17 00:00:00 2001 From: prabathabey Date: Fri, 5 Dec 2014 13:26:42 +0530 Subject: [PATCH] Introducing DeviceIdentifier bean wrapping id and the type of a particular device. This includes other formatting related improvments too brought up during the code reviews --- .../device/mgt/common/DeviceIdentifier.java | 40 +++++++++++++++++++ .../mgt/common/spi/DeviceManagerService.java | 29 +++++++------- .../mgt/core/DeviceManagementRepository.java | 22 ++++++++++ 3 files changed, 76 insertions(+), 15 deletions(-) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceIdentifier.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepository.java diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceIdentifier.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceIdentifier.java new file mode 100644 index 0000000000..e9f7ca5110 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceIdentifier.java @@ -0,0 +1,40 @@ +/** + * 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 + * + * 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.common; + +public class DeviceIdentifier { + + private String type; + + private String id; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + +} 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 c64c0ad0f5..50ccacfc9e 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 @@ -16,6 +16,7 @@ package org.wso2.carbon.device.mgt.common.spi; 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 java.util.List; @@ -31,6 +32,7 @@ public interface DeviceManagerService { * @return Returns provider type */ String getProviderType(); + /** * Method to enrolling a particular device of type mobile, IoT, etc within CDM. * @@ -51,31 +53,28 @@ public interface DeviceManagerService { /** * Method to disenroll a particular device from CDM. * - * @param type Device Type - * @param deviceId Device Identifier - * @throws DeviceManagementException + * @param deviceId Fully qualified device identifier + * @throws DeviceManagementException If some unusual behaviour is observed while disenrolling a device */ - void disEnrollDevice(String type, String deviceId) throws DeviceManagementException; + void disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException; /** * Method to retrieve the status of the registration process of a particular device. * - * @param type Device Type - * @param deviceId Device Identifier + * @param deviceId Fully qualified device identifier * @return Status of enrollment * @throws DeviceManagementException If some unusual behaviour is observed while enrolling a device */ - boolean isRegistered(String type, String deviceId) throws DeviceManagementException; + boolean isRegistered(DeviceIdentifier deviceId) throws DeviceManagementException; /** * Method to retrieve the status of a particular device. * - * @param type Device Type - * @param deviceId Device Identifier + * @param deviceId Fully qualified device identifier * @return Returns if the device is active * @throws DeviceManagementException If some unusual behaviour is observed while enrolling a device */ - boolean isActive(String type, String deviceId) throws DeviceManagementException; + boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException; /** * Method to set the status indicating whether a particular device registered within CDM is enabled at a given @@ -92,24 +91,24 @@ public interface DeviceManagerService { * @param type Device Type * @return List of metadata corresponding to all devices registered within CDM */ - List getAllDeviceInfo(String type) throws DeviceManagementException; + List getAllDevices(String type) throws DeviceManagementException; /** * 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 + * @param deviceId Fully qualified device identifier * @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; + Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException; /** * Method to set the ownership type of a particular device. i.e. BYOD, COPE * + * @param deviceId Fully qualified device identifier * @param ownershipType Type of ownership * @throws DeviceManagementException If some unusual behaviour is observed while enrolling a device */ - void setOwnership(String ownershipType) throws DeviceManagementException; + void setOwnership(DeviceIdentifier deviceId, String ownershipType) throws DeviceManagementException; } 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 new file mode 100644 index 0000000000..fb7e0a32e9 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepository.java @@ -0,0 +1,22 @@ +/** + * 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 + * + * 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.core; + +public class DeviceManagementRepository { + + + +}