From 3ebb14acdd5950fd2949e5c2e4b843b0ab8ddf9f Mon Sep 17 00:00:00 2001 From: prabathabey Date: Thu, 4 Dec 2014 10:00:37 +0530 Subject: [PATCH] Adding initial key SPIs and other related dependencies --- .../org.wso2.carbon.device.mgt.common/pom.xml | 51 +++++++ .../wso2/carbon/device/mgt/common/Device.java | 133 ++++++++++++++++++ .../mgt/common/DeviceManagementConstants.java | 19 +++ .../mgt/common/DeviceManagementException.java | 55 ++++++++ .../carbon/device/mgt/common/Feature.java | 72 ++++++++++ .../mgt/common/spi/DeviceManagerService.java | 49 +++++++ .../org.wso2.carbon.device.mgt.core/pom.xml | 34 ++--- .../internal/DeviceMgtServiceComponent.java | 25 ++++ components/device-mgt/pom.xml | 26 ++++ 9 files changed, 448 insertions(+), 16 deletions(-) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Device.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceManagementConstants.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceManagementException.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Feature.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManagerService.java 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 new file mode 100644 index 00000000000..80fd2aa7ab3 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml @@ -0,0 +1,51 @@ + + + + device-mgt + org.wso2.carbon + 2.0.0-SNAPSHOT + ../pom.xml + + + 4.0.0 + org.wso2.carbon.device.mgt.common + 2.0.0-SNAPSHOT + bundle + WSO2 Carbon - Device Management Commons + WSO2 Carbon - Device Management Commons + http://wso2.org + + + + + org.apache.felix + maven-scr-plugin + + + org.apache.felix + maven-bundle-plugin + 1.4.0 + true + + + ${project.artifactId} + ${project.artifactId} + ${project.version} + Device Management Common Bundle + org.wso2.carbon.device.mgt.common + + org.apache.commons.logging + + + org.wso2.carbon.device.mgt.common.* + + * + + + + + + + \ No newline at end of file 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 new file mode 100644 index 00000000000..6c6d0f50651 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Device.java @@ -0,0 +1,133 @@ +/** + * Copyright (c) 2012, 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; + +import java.util.Date; +import java.util.List; + +public class Device { + + private int id; + + private String description; + + private String name; + + private Date dateOfEnrolment; + + private Date dateOfLastUpdate; + + private String ownership; + + private boolean status; + + private int deviceTypeId; + + private String deviceIdentifier; + + private String owner; + + private List features; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Date getDateOfEnrolment() { + return dateOfEnrolment; + } + + public void setDateOfEnrolment(Date dateOfEnrolment) { + this.dateOfEnrolment = dateOfEnrolment; + } + + public Date getDateOfLastUpdate() { + return dateOfLastUpdate; + } + + public void setDateOfLastUpdate(Date dateOfLastUpdate) { + this.dateOfLastUpdate = dateOfLastUpdate; + } + + public String getOwnership() { + return ownership; + } + + public void setOwnership(String ownership) { + this.ownership = ownership; + } + + public boolean isStatus() { + return status; + } + + public void setStatus(boolean status) { + this.status = status; + } + + public int getDeviceTypeId() { + return deviceTypeId; + } + + public void setDeviceTypeId(int deviceTypeId) { + this.deviceTypeId = deviceTypeId; + } + + public String getDeviceIdentifier() { + return deviceIdentifier; + } + + public void setDeviceIdentifier(String deviceIdentifier) { + this.deviceIdentifier = deviceIdentifier; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public List getFeatures() { + return features; + } + + public void setFeatures(List features) { + this.features = features; + } + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceManagementConstants.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceManagementConstants.java new file mode 100644 index 00000000000..2493dd3cca9 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceManagementConstants.java @@ -0,0 +1,19 @@ +/** + * Copyright (c) 2012, 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 final class DeviceManagementConstants { +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceManagementException.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceManagementException.java new file mode 100644 index 00000000000..4d261973e7d --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceManagementException.java @@ -0,0 +1,55 @@ +/** + * 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 DeviceManagementException extends Exception { + + private static final long serialVersionUID = -3151279311929070297L; + + private String errorMessage; + + public String getErrorMessage() { + return errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + + public DeviceManagementException(String msg, Exception nestedEx) { + super(msg, nestedEx); + setErrorMessage(msg); + } + + public DeviceManagementException(String message, Throwable cause) { + super(message, cause); + setErrorMessage(message); + } + + public DeviceManagementException(String msg) { + super(msg); + setErrorMessage(msg); + } + + public DeviceManagementException() { + super(); + } + + public DeviceManagementException(Throwable cause) { + super(cause); + } + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Feature.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Feature.java new file mode 100644 index 00000000000..084b4fba568 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Feature.java @@ -0,0 +1,72 @@ +/** + * Copyright (c) 2012, 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; + +import java.util.List; + +public class Feature { + + private int id; + private String name; + private List metadataEntries; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List getMetadataEntries() { + return metadataEntries; + } + + public void setMetadataEntries(List metadataEntries) { + this.metadataEntries = metadataEntries; + } + + public static class MetadataEntry { + + private int id; + private Object value; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public Object getValue() { + return value; + } + + public void setValue(Object value) { + this.value = value; + } + } + +} 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 new file mode 100644 index 00000000000..18b819706ec --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManagerService.java @@ -0,0 +1,49 @@ +/** + * 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.spi; + +import org.wso2.carbon.device.mgt.common.Device; + +import java.util.List; + +/** + * This represents the service provider interface that has to be implemented by any of new + * device type plugin implementation intended to be managed through CDM. + */ +public interface DeviceManagerService { + + /* + Method corresponding to enrolling a particular device of type mobile, IoT, etc within CDM + */ + void enrolDevice(); + + void modifyEnrolment(); + + void disEnrollDevice(); + + boolean isRegistered(); + + boolean isActive(); + + boolean setActive(); + + List getAllDeviceInfo(); + + Device getDeviceInfo(); + + void setOwnership(); + +} 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 75240f3df74..4b01db648ed 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 @@ -36,22 +36,6 @@ - - org.apache.felix maven-scr-plugin @@ -86,6 +70,24 @@ + + + org.eclipse.osgi + org.eclipse.osgi + + + org.eclipse.equinox + org.eclipse.equinox.common + + + org.wso2.carbon + org.wso2.carbon.logging + + + org.wso2.carbon + org.wso2.carbon.device.mgt.common + + 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 1ebf85302c2..ce9f77cdfb5 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 @@ -15,6 +15,31 @@ */ package org.wso2.carbon.device.mgt.core.internal; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +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" + * policy="dynamic" bind="setDeviceManagerService" unbind="unsetDeviceManagerService" + */ public class DeviceMgtServiceComponent { + private static Log log = LogFactory.getLog(DeviceMgtServiceComponent.class); + + protected void setDeviceManagerService(DeviceManagerService deviceManager) { + if (log.isDebugEnabled()) { + log.debug("Setting Data Sources Service"); + } + } + + protected void unsetDeviceManagerService(DeviceManagerService deviceManager) { + if (log.isDebugEnabled()) { + log.debug("Unsetting Data Sources Service"); + } + } + + } diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index 7e9fe17b30e..8ec21df4bb1 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -38,6 +38,32 @@ org.wso2.carbon.device.mgt.core + org.wso2.carbon.device.mgt.common + + + + org.eclipse.osgi + org.eclipse.osgi + 3.8.1.v20120830-144521 + + + org.eclipse.equinox + org.eclipse.equinox.common + 3.6.100.v20120522-1841 + + + org.wso2.carbon + org.wso2.carbon.logging + 4.3.0-SNAPSHOT + + + org.wso2.carbon + org.wso2.carbon.device.mgt.common + 2.0.0-SNAPSHOT + + + +