diff --git a/README.md b/README.md index 9e552c224c..0789eca2b4 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ product-cdm =========== -WSO2 CONNECTED DEVICE MANAGER +WSO2 MOBILE DEVICE MANAGER -WSO2 Enterprise Mobility Manager (WSO2 EMM) is a comprehensive platform that helps solve mobile computing challenges enterprises face today when dealing with both corporate owned, personally enabled (COPE) devices and employee owned devices as part of a bring your own device (BYOD) program. +WSO2 Mobile Device Manager (WSO2 MDM) is a comprehensive platform that helps solve mobile computing challenges enterprises face today when dealing with both corporate owned, personally enabled (COPE) devices and employee owned devices as part of a bring your own device (BYOD) program. Whether it is device provisioning, device configuration management, policy enforcement, mobile application management, device data security, or compliance monitoring, WSO2 EMM offers a single enterprise-grade platform. 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 deleted file mode 100644 index ad7e005500..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - 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-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 deleted file mode 100644 index 94786b4191..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Device.java +++ /dev/null @@ -1,178 +0,0 @@ -/** - * 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; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import java.util.List; - -@XmlRootElement -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 - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - @XmlElement - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - @XmlElement - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @XmlElement - public Long getDateOfEnrolment() { - return dateOfEnrolment; - } - - public void setDateOfEnrolment(Long dateOfEnrolment) { - this.dateOfEnrolment = dateOfEnrolment; - } - - @XmlElement - public Long getDateOfLastUpdate() { - return dateOfLastUpdate; - } - - public void setDateOfLastUpdate(Long dateOfLastUpdate) { - this.dateOfLastUpdate = dateOfLastUpdate; - } - - @XmlElement - public String getOwnership() { - return ownership; - } - - public void setOwnership(String ownership) { - this.ownership = ownership; - } - - @XmlElement - public boolean isStatus() { - return status; - } - - public void setStatus(boolean status) { - this.status = status; - } - - @XmlElement - public int getDeviceTypeId() { - return deviceTypeId; - } - - public void setDeviceTypeId(int deviceTypeId) { - this.deviceTypeId = deviceTypeId; - } - - @XmlElement - public String getDeviceIdentifier() { - return deviceIdentifier; - } - - public void setDeviceIdentifier(String deviceIdentifier) { - this.deviceIdentifier = deviceIdentifier; - } - - @XmlElement - public String getOwner() { - return owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - @XmlElement - public List getFeatures() { - return features; - } - - public void setFeatures(List features) { - this.features = features; - } - - @XmlElement - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - @XmlElement - public List getProperties() { - return properties; - } - - public void setProperties(List properties) { - this.properties = properties; - } - - public static class Property { - - private String name; - private String value; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getValue() { - return value; - } - - public void setValue(String 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/DeviceIdentifier.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceIdentifier.java deleted file mode 100644 index e9f7ca5110..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceIdentifier.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * 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/DeviceManagementConstants.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceManagementConstants.java deleted file mode 100644 index 9802fe30fe..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceManagementConstants.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * 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 final class DeviceManagementConstants { - - public static final class DataSourceProperties { - private DataSourceProperties() { - throw new AssertionError(); - } - public static final String DB_CHECK_QUERY = "SELECT * FROM DM_DEVICE"; - public static final String SECURE_VAULT_NS = "http://org.wso2.securevault/configuration"; - public static final String DEVICE_CONFIG_XML_NAME = "cdm-config.xml"; - } - - public static final class SecureValueProperties { - private SecureValueProperties() { - throw new AssertionError(); - } - public static final String SECRET_ALIAS_ATTRIBUTE_NAME_WITH_NAMESPACE = "secretAlias"; - public static final String SECURE_VAULT_NS = "http://org.wso2.securevault/configuration"; - } - - public static final class MobileDeviceTypes { - private MobileDeviceTypes() { - throw new AssertionError(); - } - public final static String MOBILE_DEVICE_TYPE_ANDROID = "android"; - public final static String MOBILE_DEVICE_TYPE_IOS = "ios"; - public final static String MOBILE_DEVICE_TYPE_WINDOWS = "windows"; - } - -} 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 deleted file mode 100644 index 48c409b894..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceManagementException.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * 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; - -@SuppressWarnings("unused") -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/DeviceManagementServiceException.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceManagementServiceException.java deleted file mode 100644 index d350a13910..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceManagementServiceException.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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.device.mgt.common; - -public class DeviceManagementServiceException extends Exception { - - private static final long serialVersionUID = -8933146283800122640L; - private String errorMessage; - - public String getErrorMessage() { - return errorMessage; - } - - public void setErrorMessage(String errorMessage) { - this.errorMessage = errorMessage; - } - - public DeviceManagementServiceException(String msg, Exception nestedEx) { - super(msg, nestedEx); - setErrorMessage(msg); - } - - public DeviceManagementServiceException(String message, Throwable cause) { - super(message, cause); - setErrorMessage(message); - } - - public DeviceManagementServiceException(String msg) { - super(msg); - setErrorMessage(msg); - } - - public DeviceManagementServiceException() { - super(); - } - - public DeviceManagementServiceException(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 deleted file mode 100644 index 388edbb402..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Feature.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * 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; - -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/License.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/License.java deleted file mode 100644 index b72605baed..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/License.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * - * * 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.device.mgt.common; - -public class License { - - private String licenseName; - private String licenseText; - private String licenseVersion; - - public String getLicenseName() { - return licenseName; - } - - public void setLicenseName(String licenseName) { - this.licenseName = licenseName; - } - - public String getLicenseText() { - return licenseText; - } - - public void setLicenseText(String licenseText) { - this.licenseText = licenseText; - } - - public String getLicenseVersion() { - return licenseVersion; - } - - public void setLicenseVersion(String licenseVersion) { - this.licenseVersion = licenseVersion; - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Operation.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Operation.java deleted file mode 100644 index 755be0b5cc..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Operation.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2015, 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 javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import java.util.Properties; - -@XmlRootElement -public class Operation { - - public enum Type { - CONFIG, MESSAGE, INFO - } - - private String code; - private Properties properties; - private Type type; - - @XmlElement - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - @XmlElement - public Properties getProperties() { - return properties; - } - - public void setProperties(Properties properties) { - this.properties = properties; - } - - @XmlElement - public Type getType() { - return type; - } - - public void setType(Type type) { - this.type = type; - } -} \ 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/OperationExecutionException.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/OperationExecutionException.java deleted file mode 100644 index 5090a33922..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/OperationExecutionException.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * 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 OperationExecutionException extends Exception { - - private static final long serialVersionUID = -3151279311929070299L; - - private String errorMessage; - - public String getErrorMessage() { - return errorMessage; - } - - public void setErrorMessage(String errorMessage) { - this.errorMessage = errorMessage; - } - - public OperationExecutionException(String msg, Exception nestedEx) { - super(msg, nestedEx); - setErrorMessage(msg); - } - - public OperationExecutionException(String message, Throwable cause) { - super(message, cause); - setErrorMessage(message); - } - - public OperationExecutionException(String msg) { - super(msg); - setErrorMessage(msg); - } - - public OperationExecutionException() { - super(); - } - - public OperationExecutionException(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/OperationManagementException.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/OperationManagementException.java deleted file mode 100644 index 0ed2f9585c..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/OperationManagementException.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * 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 class OperationManagementException extends Exception { - - private static final long serialVersionUID = -3151279311929070298L; - - private String errorMessage; - - public String getErrorMessage() { - return errorMessage; - } - - public void setErrorMessage(String errorMessage) { - this.errorMessage = errorMessage; - } - - public OperationManagementException(String msg, Exception nestedEx) { - super(msg, nestedEx); - setErrorMessage(msg); - } - - public OperationManagementException(String message, Throwable cause) { - super(message, cause); - setErrorMessage(message); - } - - public OperationManagementException(String msg) { - super(msg); - setErrorMessage(msg); - } - - public OperationManagementException() { - super(); - } - - public OperationManagementException(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/OperationManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/OperationManager.java deleted file mode 100644 index e11f5740a3..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/OperationManager.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * 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; - -import java.util.List; - -/** - * This represents the Device Operation management functionality which should be implemented by - * the device type plugins. - */ -public interface OperationManager { - - /** - * Method to add a operation to a device or a set of devices. - * - * @param operation Operation to be added - * @param devices List of DeviceIdentifiers to execute the operation - * @throws OperationManagementException If some unusual behaviour is observed while adding the - * operation - */ - public boolean addOperation(Operation operation, List devices) - throws OperationManagementException; - - /** - * Method to retrieve the list of available operations to a device. - * - * @param deviceId DeviceIdentifier of the device - * @throws OperationManagementException If some unusual behaviour is observed while fetching the - * operation list. - */ - public List getOperations(DeviceIdentifier deviceId) - throws OperationManagementException; - -} \ 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/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 deleted file mode 100644 index bfbc43922e..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManagerService.java +++ /dev/null @@ -1,137 +0,0 @@ -/** - * 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 org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.OperationManager; - -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 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 - * @throws DeviceManagementException If some unusual behaviour is observed while enrolling a device - */ - boolean 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 - */ - boolean modifyEnrollment(Device device) throws DeviceManagementException; - - /** - * Method to disenroll a particular device from CDM. - * - * @param deviceId Fully qualified device identifier - * @throws DeviceManagementException If some unusual behaviour is observed while disenrolling a device - */ - boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException; - - /** - * Method to retrieve the status of the registration process of a particular device. - * - * @param deviceId Fully qualified device identifier - * @return Status of enrollment - * @throws DeviceManagementException If some unusual behaviour is observed while checking the enrollment - * status of the device - */ - boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException; - - /** - * Method to retrieve the status of a particular device. - * - * @param deviceId Fully qualified device identifier - * @return Returns if the device is active - * @throws DeviceManagementException If some unusual behaviour is observed while checking the status - * of the device - */ - boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException; - - /** - * Method to set the status indicating whether a particular device registered within CDM is enabled at a given - * moment. - * - * @param deviceId Fully qualified device identifier - * @param status Indicates whether the device is active - * @throws DeviceManagementException If some unusual behaviour is observed while updating the active status - * of the device - */ - boolean setActive(DeviceIdentifier deviceId, boolean status) throws DeviceManagementException; - - /** - * Method to retrieve metadata of all devices registered within CDM corresponding to a particular device type. - * - * @return List of metadata corresponding to all devices registered within CDM - * @throws DeviceManagementException If some unusual behaviour is observed while obtaining the enrolled device list - */ - List getAllDevices() throws DeviceManagementException; - - /** - * Method to retrieve metadata of a device corresponding to a particular type that carries a specific identifier. - * - * @param deviceId Fully qualified device identifier - * @return Metadata corresponding to a particular device - * @throws DeviceManagementException If some unusual behaviour is observed obtaining the device object - */ - Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException; - - /** - * Method to update device information. - * - * @param device Updated device information related data - * @throws DeviceManagementException If some unusual behaviour is observed while updating the device info - */ - boolean updateDeviceInfo(Device device) 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 setting the ownership - * of the device - */ - boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) throws DeviceManagementException; - - /** - * Method to retrieve the Operation manager implementation associated with a given plugin. - * - * @return An appropriate instance of the underlying operation management implementation - * @throws DeviceManagementException - */ - OperationManager getOperationManager() 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 deleted file mode 100644 index f5406926b3..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml +++ /dev/null @@ -1,127 +0,0 @@ - - - - - - org.wso2.carbon - device-mgt - 2.0.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon - org.wso2.carbon.device.mgt.core - 2.0.0-SNAPSHOT - bundle - WSO2 Carbon - Device Management Core - WSO2 Carbon - Device Management Core - 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 Core Bundle - org.wso2.carbon.device.mgt.core.internal - - org.apache.axis2.*;version="${axis2.osgi.version.range}", - org.osgi.framework, - org.osgi.service.component, - org.apache.commons.logging, - javax.transaction.*, - - - !org.wso2.carbon.device.mgt.core.internal, - org.wso2.carbon.device.mgt.core.* - - * - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.18 - - - src/test/resources/testng.xml - - - - - - - - - - org.eclipse.osgi - org.eclipse.osgi - - - org.wso2.carbon - org.wso2.carbon.device.mgt.common - - - org.wso2.carbon - org.wso2.carbon.logging - - - org.wso2.carbon - org.wso2.carbon.utils - - - org.wso2.carbon - org.wso2.carbon.core - - - com.h2database.wso2 - h2-database-engine - test - - - org.testng - testng - - - org.wso2.carbon - org.wso2.carbon.user.core - - - org.wso2.carbon - org.wso2.carbon.user.api - - - - - diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java deleted file mode 100644 index 8af1724de7..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) 2015, 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 final class DeviceManagementConstants { - - public static final class Common { - private Common() { - throw new AssertionError(); - } - public static final String PROPERTY_SETUP = "setup"; - } - -} 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 deleted file mode 100644 index d3caebb963..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepository.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * 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; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.spi.DeviceManagerService; -import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; - -import java.util.HashMap; -import java.util.Map; - -public class DeviceManagementRepository { - - private static final Log log = LogFactory.getLog(DeviceManagerUtil.class); - private Map providers; - - public DeviceManagementRepository() { - providers = new HashMap(); - } - - public void addDeviceManagementProvider(DeviceManagerService provider) { - String deviceType = provider.getProviderType(); - try { - DeviceManagerUtil.registerDeviceType(deviceType); - } catch (DeviceManagementException e) { - log.error("Exception occurred while registering the device type.", e); - } - providers.put(deviceType, provider); - } - - public void removeDeviceManagementProvider(DeviceManagerService provider) { - String deviceType = provider.getProviderType(); - - try { - DeviceManagerUtil.unregisterDeviceType(deviceType); - } catch (DeviceManagementException e) { - log.error("Exception occurred while registering the device type.", e); - } - 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/DeviceManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManager.java deleted file mode 100644 index ad95758d32..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManager.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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.device.mgt.core; - -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; - -/** - * Proxy class for all Device Management related operations that take the corresponding plugin type in - * and resolve the appropriate plugin implementation - */ -public interface DeviceManager { - - public boolean enrollDevice(Device device) throws DeviceManagementException; - - public boolean modifyEnrollment(Device device) throws DeviceManagementException; - - public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException; - - public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException; - - public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException; - - public boolean setActive(DeviceIdentifier deviceId, boolean status) throws DeviceManagementException; - - public List getAllDevices(String type) throws DeviceManagementException; - - public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException; - - public boolean updateDeviceInfo(Device device) throws DeviceManagementException; - - public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) throws DeviceManagementException; - - public OperationManager getOperationManager(String type) throws DeviceManagementException; - -} 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 deleted file mode 100644 index 37b49b32b0..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagerImpl.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * 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.device.mgt.core; - -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.config.DeviceManagementConfig; -import org.wso2.carbon.device.mgt.core.dao.DeviceDAO; -import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException; -import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory; -import org.wso2.carbon.device.mgt.core.dao.DeviceTypeDAO; -import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil; - -import java.util.ArrayList; -import java.util.List; - -public class DeviceManagerImpl implements DeviceManager { - - private DeviceDAO deviceDAO; - private DeviceTypeDAO deviceTypeDAO; - private DeviceManagementConfig config; - private DeviceManagementRepository pluginRepository; - - public DeviceManagerImpl(DeviceManagementConfig config, DeviceManagementRepository pluginRepository) { - this.config = config; - this.pluginRepository = pluginRepository; - this.deviceDAO = DeviceManagementDAOFactory.getDeviceDAO(); - this.deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO(); - } - - @Override - public boolean enrollDevice(Device device) throws DeviceManagementException { - DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(device.getType()); - boolean status = dms.enrollDevice(device); - - try { - org.wso2.carbon.device.mgt.core.dto.Device deviceDto = DeviceManagementDAOUtil.convertDevice(device); - Integer deviceTypeId = this.getDeviceTypeDAO().getDeviceTypeIdByDeviceTypeName(device.getType()); - deviceDto.setDeviceTypeId(deviceTypeId); - this.getDeviceDAO().addDevice(deviceDto); - - } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while enrolling the device '" + device.getId() + "'", e); - } - return status; - } - - @Override - public boolean modifyEnrollment(Device device) throws DeviceManagementException { - DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(device.getType()); - boolean status = dms.modifyEnrollment(device); - try { - this.getDeviceDAO().updateDevice(DeviceManagementDAOUtil.convertDevice(device)); - } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while modifying the device '" + device.getId() + "'", - e); - } - return status; - } - - @Override - public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException { - DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType()); - return dms.disenrollDevice(deviceId); - } - - @Override - public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException { - DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType()); - return dms.isEnrolled(deviceId); - } - - @Override - public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException { - DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType()); - return dms.isActive(deviceId); - } - - @Override - public boolean setActive(DeviceIdentifier deviceId, boolean status) - throws DeviceManagementException { - DeviceManagerService dms = - this.getPluginRepository().getDeviceManagementProvider(deviceId.getType()); - return dms.setActive(deviceId, status); - } - - @Override - public List getAllDevices(String type) throws DeviceManagementException { - DeviceManagerService dms = - this.getPluginRepository().getDeviceManagementProvider(type); - List devicesList = new ArrayList(); - try { - Integer deviceTypeId = this.getDeviceTypeDAO().getDeviceTypeIdByDeviceTypeName(type); - List devices = - this.getDeviceDAO().getDevices(deviceTypeId); - - for (org.wso2.carbon.device.mgt.core.dto.Device device : devices) { - Device convertedDevice = DeviceManagementDAOUtil.convertDevice(device); - DeviceIdentifier deviceIdentifier = DeviceManagementDAOUtil - .createDeviceIdentifier(device, this.deviceTypeDAO - .getDeviceType(device.getDeviceTypeId())); - Device dmsDevice = dms.getDevice(deviceIdentifier); - convertedDevice.setProperties(dmsDevice.getProperties()); - convertedDevice.setFeatures(dmsDevice.getFeatures()); - devicesList.add(convertedDevice); - } - } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while obtaining the device for type '" + type + "'", - e); - } - return devicesList; - } - - @Override - public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException { - DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType()); - return dms.getDevice(deviceId); - } - - @Override - public boolean updateDeviceInfo(Device device) throws DeviceManagementException { - DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(device.getType()); - return dms.updateDeviceInfo(device); - } - - @Override - public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) throws DeviceManagementException { - DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType()); - return dms.setOwnership(deviceId, ownershipType); - } - - public OperationManager getOperationManager(String type) throws DeviceManagementException { - DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(type); - return dms.getOperationManager(); - } - - public DeviceDAO getDeviceDAO() { - return deviceDAO; - } - - public DeviceTypeDAO getDeviceTypeDAO() { - return deviceTypeDAO; - } - - public DeviceManagementRepository getPluginRepository() { - return pluginRepository; - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/LicenseManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/LicenseManager.java deleted file mode 100644 index 0275a1bc20..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/LicenseManager.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * - * * 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.device.mgt.core; - -import org.wso2.carbon.device.mgt.core.dto.DeviceType; - -public class LicenseManager { - -/* public void addLicense(DeviceType deviceType,String langCode, String - );*/ - -} 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 deleted file mode 100644 index f9f99ffba9..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceConfigurationManager.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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.device.mgt.core.config; - -import org.w3c.dom.Document; -import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.core.config.datasource.DataSourceConfig; -import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; -import org.wso2.carbon.utils.CarbonUtils; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.Unmarshaller; -import java.io.File; - -/** - * Class responsible for the cdm manager configuration initialization - */ -public class DeviceConfigurationManager { - - private DeviceManagementConfig currentDeviceConfig; - private static DeviceConfigurationManager deviceConfigManager; - - private static final String deviceMgtConfigXMLPath = CarbonUtils.getCarbonConfigDirPath() + File.separator + - DeviceManagementConstants.DataSourceProperties.DEVICE_CONFIG_XML_NAME; - - public static DeviceConfigurationManager getInstance() { - if (deviceConfigManager == null) { - synchronized (DeviceConfigurationManager.class) { - if (deviceConfigManager == null) { - deviceConfigManager = new DeviceConfigurationManager(); - } - } - } - return deviceConfigManager; - } - - public synchronized void initConfig() throws DeviceManagementException { - - //catch generic exception.if any exception occurs wrap and throw DeviceManagementException - try { - File deviceMgtConfig = new File(deviceMgtConfigXMLPath); - Document doc = DeviceManagerUtil.convertToDocument(deviceMgtConfig); - - /* Un-marshaling Device Management configuration */ - JAXBContext cdmContext = JAXBContext.newInstance(DeviceManagementConfig.class); - Unmarshaller unmarshaller = cdmContext.createUnmarshaller(); - this.currentDeviceConfig = (DeviceManagementConfig) unmarshaller.unmarshal(doc); - } catch (Exception e) { - throw new DeviceManagementException("Error occurred while initializing RSS config", e); - } - } - - public DeviceManagementConfig getDeviceManagementConfig() { - return currentDeviceConfig; - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfig.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfig.java deleted file mode 100644 index 678f20d8f0..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfig.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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.device.mgt.core.config; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * Represents Device Mgt configuration. - */ -@XmlRootElement(name = "DeviceMgtConfiguration") -public final class DeviceManagementConfig { - - private DeviceManagementRepository deviceMgtRepository; - - @XmlElement(name = "ManagementRepository", required = true) - public DeviceManagementRepository getDeviceMgtRepository() { - return deviceMgtRepository; - } - - public void setDeviceMgtRepository(DeviceManagementRepository deviceMgtRepository) { - this.deviceMgtRepository = deviceMgtRepository; - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementRepository.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementRepository.java deleted file mode 100644 index a6bd91a519..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementRepository.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.device.mgt.core.config; - -import org.wso2.carbon.device.mgt.core.config.datasource.DataSourceConfig; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * Class for holding management repository data - */ -@XmlRootElement(name = "ManagementRepository") -public class DeviceManagementRepository { - - private DataSourceConfig dataSourceConfig; - - @XmlElement(name = "DataSourceConfiguration", required = false) - public DataSourceConfig getDataSourceConfig() { - return dataSourceConfig; - } - - public void setDataSourceConfig(DataSourceConfig dataSourceConfig) { - this.dataSourceConfig = dataSourceConfig; - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/datasource/DataSourceConfig.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/datasource/DataSourceConfig.java deleted file mode 100644 index bc7f98e925..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/datasource/DataSourceConfig.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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.device.mgt.core.config.datasource; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * Class for holding data source configuration in malformed-cdm-config-no-mgt-repo.xml at parsing with JAXB - */ -@XmlRootElement(name = "DataSourceConfiguration") -public class DataSourceConfig { - - private JNDILookupDefinition jndiLookupDefintion; - - @XmlElement(name = "JndiLookupDefinition", required = true) - public JNDILookupDefinition getJndiLookupDefintion() { - return jndiLookupDefintion; - } - - public void setJndiLookupDefintion(JNDILookupDefinition jndiLookupDefintion) { - this.jndiLookupDefintion = jndiLookupDefintion; - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/datasource/JNDILookupDefinition.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/datasource/JNDILookupDefinition.java deleted file mode 100644 index bc85ffb143..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/datasource/JNDILookupDefinition.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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. - * 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.config.datasource; - -import javax.xml.bind.annotation.*; -import java.util.List; - -/** - * Class for hold JndiLookupDefinition of rss-manager.xml at parsing with JAXB - */ -@XmlRootElement(name = "JndiLookupDefinition") -public class JNDILookupDefinition { - - private String jndiName; - private List jndiProperties; - - @XmlElement(name = "Name", required = false) - public String getJndiName() { - return jndiName; - } - - public void setJndiName(String jndiName) { - this.jndiName = jndiName; - } - - @XmlElementWrapper(name = "Environment", required = false) - @XmlElement(name = "Property", nillable = false) - public List getJndiProperties() { - return jndiProperties; - } - - public void setJndiProperties(List jndiProperties) { - this.jndiProperties = jndiProperties; - } - - @XmlRootElement(name = "Property") - public static class JNDIProperty { - - private String name; - - private String value; - - @XmlAttribute(name = "Name") - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @XmlValue - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - } - -} - diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java deleted file mode 100644 index d99db291a2..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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.device.mgt.core.dao; - -import org.wso2.carbon.device.mgt.core.dto.Device; -import org.wso2.carbon.device.mgt.core.dto.Status; - -import java.util.List; - -/** - * This class represents the key operations associated with persisting device related information - */ -public interface DeviceDAO { - - void addDevice(Device device) throws DeviceManagementDAOException; - - void updateDevice(Device device) throws DeviceManagementDAOException; - - void updateDeviceStatus(Long deviceId, Status status) throws DeviceManagementDAOException; - - void deleteDevice(Long deviceId) throws DeviceManagementDAOException; - - Device getDeviceByDeviceId(Long deviceId) throws DeviceManagementDAOException; - - List getDevices() throws DeviceManagementDAOException; - - /** - * @param type - The device type id. - * @return a list of devices based on the type id. - * @throws DeviceManagementDAOException - */ - List getDevices(Integer type) throws DeviceManagementDAOException; -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceManagementDAOException.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceManagementDAOException.java deleted file mode 100644 index cb48c3320c..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceManagementDAOException.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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.device.mgt.core.dao; - -/** - * Custom exception class for data access related exceptions - */ -public class DeviceManagementDAOException extends Exception { - - private String message; - private static final long serialVersionUID = 2021891706072918864L; - - /** - * Constructs a new exception with the specified detail message and nested exception. - * - * @param message error message - * @param nestedException exception - */ - public DeviceManagementDAOException(String message, Exception nestedException) { - super(message, nestedException); - setErrorMessage(message); - } - - /** - * Constructs a new exception with the specified detail message and cause. - * - * @param message the detail message. - * @param cause the cause of this exception. - */ - public DeviceManagementDAOException(String message, Throwable cause) { - super(message, cause); - setErrorMessage(message); - } - - /** - * Constructs a new exception with the specified detail message - * - * @param message the detail message. - */ - public DeviceManagementDAOException(String message) { - super(message); - setErrorMessage(message); - } - - /** - * Constructs a new exception with the specified and cause. - * - * @param cause the cause of this exception. - */ - public DeviceManagementDAOException(Throwable cause) { - super(cause); - } - - public String getMessage() { - return message; - } - - public void setErrorMessage(String errorMessage) { - this.message = errorMessage; - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceManagementDAOFactory.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceManagementDAOFactory.java deleted file mode 100644 index ae12417d62..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceManagementDAOFactory.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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.device.mgt.core.dao; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.core.config.datasource.DataSourceConfig; -import org.wso2.carbon.device.mgt.core.config.datasource.JNDILookupDefinition; -import org.wso2.carbon.device.mgt.core.dao.impl.DeviceDAOImpl; -import org.wso2.carbon.device.mgt.core.dao.impl.DeviceTypeDAOImpl; -import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil; -import javax.sql.DataSource; -import java.util.Hashtable; -import java.util.List; - -public class DeviceManagementDAOFactory { - - private static DataSource dataSource; - private static final Log log = LogFactory.getLog(DeviceManagementDAOFactory.class); - - public static DeviceDAO getDeviceDAO() { - return new DeviceDAOImpl(dataSource); - } - - public static DeviceTypeDAO getDeviceTypeDAO() { - return new DeviceTypeDAOImpl(dataSource); - } - - public static void init(DataSourceConfig config) { - dataSource = resolveDataSource(config); - } - - public static void init(DataSource dtSource) { - dataSource = dtSource; - } - - /** - * Resolve data source from the data source definition - * - * @param config data source configuration - * @return data source resolved from the data source definition - */ - private static DataSource resolveDataSource(DataSourceConfig config) { - DataSource dataSource = null; - if (config == null) { - throw new RuntimeException("Device Management Repository data source configuration " + "is null and " + - "thus, is not initialized"); - } - JNDILookupDefinition jndiConfig = config.getJndiLookupDefintion(); - if (jndiConfig != null) { - if (log.isDebugEnabled()) { - log.debug("Initializing Device Management Repository data source using the JNDI " + - "Lookup Definition"); - } - List jndiPropertyList = jndiConfig.getJndiProperties(); - if (jndiPropertyList != null) { - Hashtable jndiProperties = new Hashtable(); - for (JNDILookupDefinition.JNDIProperty prop : jndiPropertyList) { - jndiProperties.put(prop.getName(), prop.getValue()); - } - dataSource = DeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), jndiProperties); - } else { - dataSource = DeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), null); - } - } - return dataSource; - } - - public static DataSource getDataSource() { - return dataSource; - } -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceTypeDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceTypeDAO.java deleted file mode 100644 index f2666bab9d..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceTypeDAO.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.device.mgt.core.dao; - -import org.wso2.carbon.device.mgt.core.dto.DeviceType; - -import java.util.List; - -/** - * This class represents the key operations associated with persisting device type related information - */ -public interface DeviceTypeDAO { - - void addDeviceType(DeviceType deviceType) throws DeviceManagementDAOException; - - void updateDeviceType(DeviceType deviceType) throws DeviceManagementDAOException; - - List getDeviceTypes() throws DeviceManagementDAOException; - - DeviceType getDeviceType(Integer id) throws DeviceManagementDAOException; - - Integer getDeviceTypeIdByDeviceTypeName(String type) throws DeviceManagementDAOException; - - void removeDeviceType(DeviceType deviceType) throws DeviceManagementDAOException; - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java deleted file mode 100644 index 97fa8e25b3..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * 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.device.mgt.core.dao.impl; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.core.dao.DeviceDAO; -import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil; -import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException; -import org.wso2.carbon.device.mgt.core.dto.Device; -import org.wso2.carbon.device.mgt.core.dto.Status; - -import javax.sql.DataSource; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -public class DeviceDAOImpl implements DeviceDAO { - - private DataSource dataSource; - private static final Log log = LogFactory.getLog(DeviceDAOImpl.class); - - - public DeviceDAOImpl(DataSource dataSource) { - this.dataSource = dataSource; - } - - @Override - public void addDevice(Device device) throws DeviceManagementDAOException { - Connection conn = null; - PreparedStatement stmt = null; - try { - conn = this.getConnection(); - String createDBQuery = - "INSERT INTO DM_DEVICE(DESCRIPTION, NAME, DATE_OF_ENROLLMENT, DATE_OF_LAST_UPDATE, OWNERSHIP," + - "STATUS, DEVICE_TYPE_ID, DEVICE_IDENTIFICATION, OWNER, TENANT_ID) VALUES " + - "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; - - stmt = conn.prepareStatement(createDBQuery); - stmt.setString(1, device.getDescription()); - stmt.setString(2, device.getName()); - stmt.setLong(3, new Date().getTime()); - stmt.setLong(4, new Date().getTime()); - stmt.setString(5, device.getOwnerShip()); - stmt.setString(6, device.getStatus().toString()); - stmt.setInt(7, device.getDeviceTypeId()); - stmt.setString(8, device.getDeviceIdentificationId()); - stmt.setString(9, device.getOwnerId()); - stmt.setInt(10, device.getTenantId()); - stmt.executeUpdate(); - } catch (SQLException e) { - String msg = "Error occurred while enrolling device '" + device.getName() + "'"; - log.error(msg, e); - throw new DeviceManagementDAOException(msg, e); - } finally { - DeviceManagementDAOUtil.cleanupResources(conn, stmt, null); - } - } - - @Override - public void updateDevice(Device device) throws DeviceManagementDAOException { - - } - - @Override - public void updateDeviceStatus(Long deviceId, Status status) throws DeviceManagementDAOException { - - } - - @Override - public void deleteDevice(Long deviceId) throws DeviceManagementDAOException { - - } - - @Override - public Device getDeviceByDeviceId(Long deviceId) - throws DeviceManagementDAOException { - return null; - } - - @Override - public List getDevices() throws DeviceManagementDAOException { - return null; - } - - @Override public List getDevices(Integer type) throws DeviceManagementDAOException { - Connection conn = null; - PreparedStatement stmt = null; - ResultSet resultSet = null; - List devicesList = null; - try { - conn = this.getConnection(); - String selectDBQueryForType = "SELECT ID, DESCRIPTION, NAME, DATE_OF_ENROLLMENT, " + - "DATE_OF_LAST_UPDATE, OWNERSHIP, STATUS, DEVICE_TYPE_ID, " + - "DEVICE_IDENTIFICATION, OWNER, TENANT_ID FROM DM_DEVICE " + - "WHERE DM_DEVICE.DEVICE_TYPE_ID=?"; - stmt = conn.prepareStatement(selectDBQueryForType); - stmt.setInt(1, type); - resultSet = stmt.executeQuery(); - devicesList = new ArrayList(); - while (resultSet.next()) { - Device device = new Device(); - device.setId(resultSet.getInt(1)); - device.setDescription(resultSet.getString(2)); - device.setName(resultSet.getString(3)); - device.setDateOfEnrollment(resultSet.getLong(4)); - device.setDateOfLastUpdate(resultSet.getLong(5)); - //TODO:- Ownership is not a enum in DeviceDAO - device.setOwnerShip(resultSet.getString(6)); - device.setStatus(Status.valueOf(resultSet.getString(7))); - device.setDeviceTypeId(resultSet.getInt(8)); - device.setDeviceIdentificationId(resultSet.getString(9)); - device.setOwnerId(resultSet.getString(10)); - device.setTenantId(resultSet.getInt(11)); - devicesList.add(device); - } - } catch (SQLException e) { - String msg = "Error occurred while listing devices for type '" + type + "'"; - log.error(msg, e); - throw new DeviceManagementDAOException(msg, e); - } finally { - DeviceManagementDAOUtil.cleanupResources(conn, stmt, resultSet); - } - return devicesList; - } - - private Connection getConnection() throws DeviceManagementDAOException { - try { - return dataSource.getConnection(); - } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while obtaining a connection from the device " + - "management metadata repository datasource", e); - } - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceTypeDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceTypeDAOImpl.java deleted file mode 100644 index a7bf9d3802..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceTypeDAOImpl.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * 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.device.mgt.core.dao.impl; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException; -import org.wso2.carbon.device.mgt.core.dao.DeviceTypeDAO; -import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil; -import org.wso2.carbon.device.mgt.core.dto.DeviceType; - -import javax.sql.DataSource; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; - -public class DeviceTypeDAOImpl implements DeviceTypeDAO { - - private DataSource dataSource; - private static final Log log = LogFactory.getLog(DeviceTypeDAOImpl.class); - - public DeviceTypeDAOImpl(DataSource dataSource) { - this.dataSource = dataSource; - } - - @Override - public void addDeviceType(DeviceType deviceType) throws DeviceManagementDAOException { - Connection conn = this.getConnection(); - PreparedStatement stmt = null; - try { - stmt = conn.prepareStatement("INSERT INTO DM_DEVICE_TYPE (NAME) VALUES (?)"); - stmt.setString(1, deviceType.getName()); - stmt.execute(); - } catch (SQLException e) { - String msg = "Error occurred while registering the device type '" + deviceType.getName() + "'"; - log.error(msg, e); - throw new DeviceManagementDAOException(msg, e); - } finally { - DeviceManagementDAOUtil.cleanupResources(conn, stmt, null); - } - } - - @Override - public void updateDeviceType(DeviceType deviceType) throws DeviceManagementDAOException { - - } - - @Override - public List getDeviceTypes() throws DeviceManagementDAOException { - Connection conn = this.getConnection(); - PreparedStatement stmt = null; - List deviceTypes = new ArrayList(); - try { - stmt = conn.prepareStatement("SELECT ID AS DEVICE_TYPE_ID, NAME AS DEVICE_TYPE FROM DM_DEVICE_TYPE"); - ResultSet results = stmt.executeQuery(); - - while (results.next()) { - DeviceType deviceType = new DeviceType(); - deviceType.setId(results.getLong("DEVICE_TYPE_ID")); - deviceType.setName(results.getString("DEVICE_TYPE")); - deviceTypes.add(deviceType); - } - } catch (SQLException e) { - String msg = "Error occurred while fetching the registered device types"; - log.error(msg, e); - throw new DeviceManagementDAOException(msg, e); - } finally { - DeviceManagementDAOUtil.cleanupResources(conn, stmt, null); - } - return deviceTypes; - } - - @Override - public DeviceType getDeviceType(Integer id) throws DeviceManagementDAOException { - Connection conn = this.getConnection(); - PreparedStatement stmt = null; - DeviceType deviceType = null; - try { - stmt = conn.prepareStatement("SELECT ID AS DEVICE_TYPE_ID, NAME AS DEVICE_TYPE FROM DM_DEVICE_TYPE WHERE ID=?"); - stmt.setInt(1, id); - ResultSet results = stmt.executeQuery(); - - while (results.next()) { - deviceType = new DeviceType(); - deviceType.setId(results.getLong("DEVICE_TYPE_ID")); - deviceType.setName(results.getString("DEVICE_TYPE")); - } - } catch (SQLException e) { - String msg = "Error occurred while fetching the registered device type"; - log.error(msg, e); - throw new DeviceManagementDAOException(msg, e); - } finally { - DeviceManagementDAOUtil.cleanupResources(conn, stmt, null); - } - return deviceType; - } - - @Override - public Integer getDeviceTypeIdByDeviceTypeName(String type) throws DeviceManagementDAOException { - - Connection conn = this.getConnection(); - PreparedStatement stmt = null; - ResultSet resultSet = null; - Integer deviceTypeId = null; - - try { - String createDBQuery = "SELECT * From DM_DEVICE_TYPE DT WHERE DT.NAME=?"; - stmt = conn.prepareStatement(createDBQuery); - stmt.setString(1, type); - resultSet = stmt.executeQuery(); - - while (resultSet.next()) { - deviceTypeId = resultSet.getInt(1); - } - - } catch (SQLException e) { - String msg = "Error occurred while fetch device type id for device type '" + type + "'"; - log.error(msg, e); - throw new DeviceManagementDAOException(msg, e); - } finally { - DeviceManagementDAOUtil.cleanupResources(conn, stmt, null); - } - - return deviceTypeId; - } - - @Override - public void removeDeviceType(DeviceType deviceType) throws DeviceManagementDAOException { - - } - - private Connection getConnection() throws DeviceManagementDAOException { - try { - return dataSource.getConnection(); - } catch (SQLException e) { - String msg = "Error occurred while obtaining a connection from the device " + - "management metadata repository datasource"; - log.error(msg, e); - throw new DeviceManagementDAOException(msg, e); - } - } -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/util/DeviceManagementDAOUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/util/DeviceManagementDAOUtil.java deleted file mode 100644 index 951d33dae9..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/util/DeviceManagementDAOUtil.java +++ /dev/null @@ -1,172 +0,0 @@ -/** - * 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.dao.util; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.CarbonContext; -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException; -import org.wso2.carbon.device.mgt.core.dto.Device; -import org.wso2.carbon.device.mgt.core.dto.DeviceType; -import org.wso2.carbon.device.mgt.core.dto.Status; -import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; -import org.wso2.carbon.user.api.UserStoreException; -import org.wso2.carbon.user.core.tenant.TenantManager; -import org.wso2.carbon.utils.multitenancy.MultitenantConstants; - -import javax.naming.InitialContext; -import javax.sql.DataSource; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Hashtable; -import java.util.List; - -public final class DeviceManagementDAOUtil { - - private static final Log log = LogFactory.getLog(DeviceManagementDAOUtil.class); - - public static void cleanupResources(Connection conn, PreparedStatement stmt, ResultSet rs) { - if (rs != null) { - try { - rs.close(); - } catch (SQLException e) { - log.warn("Error occurred while closing result set", e); - } - } - if (stmt != null) { - try { - stmt.close(); - } catch (SQLException e) { - log.warn("Error occurred while closing prepared statement", e); - } - } - if (conn != null) { - try { - conn.close(); - } catch (SQLException e) { - log.warn("Error occurred while closing database connection", e); - } - } - } - - /** - * Get id of the current tenant. - * - * @return tenant id - * @throws DeviceManagementDAOException if an error is observed when getting tenant id - */ - public static int getTenantId() throws DeviceManagementDAOException { - CarbonContext context = CarbonContext.getThreadLocalCarbonContext(); - int tenantId = context.getTenantId(); - if (tenantId != MultitenantConstants.INVALID_TENANT_ID) { - return tenantId; - } - String tenantDomain = context.getTenantDomain(); - if (tenantDomain == null) { - String msg = "Tenant domain is not properly set and thus, is null"; - throw new DeviceManagementDAOException(msg); - } - TenantManager tenantManager = DeviceManagementDataHolder.getInstance().getTenantManager(); - try { - tenantId = tenantManager.getTenantId(tenantDomain); - } catch (UserStoreException e) { - String msg = "Error occurred while retrieving id from the domain of tenant " + tenantDomain; - throw new DeviceManagementDAOException(msg); - } - return tenantId; - } - - public static DataSource lookupDataSource(String dataSourceName, final Hashtable jndiProperties) { - try { - if (jndiProperties == null || jndiProperties.isEmpty()) { - return (DataSource) InitialContext.doLookup(dataSourceName); - } - final InitialContext context = new InitialContext(jndiProperties); - return (DataSource) context.lookup(dataSourceName); - } catch (Exception e) { - throw new RuntimeException("Error in looking up data source: " + e.getMessage(), e); - } - } - - /** - * @param device - The DTO device object. - * @return A Business Object. - */ - public static org.wso2.carbon.device.mgt.common.Device convertDevice(Device device){ - org.wso2.carbon.device.mgt.common.Device deviceBO = - new org.wso2.carbon.device.mgt.common.Device(); - deviceBO.setDateOfEnrolment(device.getDateOfEnrollment()); - deviceBO.setDateOfLastUpdate(device.getDateOfLastUpdate()); - deviceBO.setDescription(device.getDescription()); - deviceBO.setDeviceIdentifier(device.getDeviceIdentificationId()); - deviceBO.setDeviceTypeId(device.getDeviceTypeId()); - deviceBO.setName(device.getName()); - deviceBO.setId(device.getId()); - deviceBO.setOwner(device.getOwnerId()); - deviceBO.setOwnership(device.getOwnerShip()); - if (device.getStatus() == Status.ACTIVE) { - deviceBO.setStatus(true); - } else if (device.getStatus() == Status.INACTIVE) { - deviceBO.setStatus(false); - } - return null; - } - - /** - * @param devices - DTO Device Object list. - * @return converted Business Object list. - */ - public static List convertDevices( - List devices) { - List deviceBOList = - new ArrayList(); - for (Device device : devices) { - deviceBOList.add(convertDevice(device)); - } - return deviceBOList; - } - - public static Device convertDevice(org.wso2.carbon.device.mgt.common.Device - device) throws DeviceManagementDAOException { - Device deviceBO = new Device(); - deviceBO.setDescription(device.getDescription()); - deviceBO.setName(device.getName()); - deviceBO.setDateOfEnrollment(device.getDateOfEnrolment()); - deviceBO.setDateOfLastUpdate(device.getDateOfLastUpdate()); - - if (!device.isStatus()){ - deviceBO.setStatus(Status.INACTIVE); - }else{ - deviceBO.setStatus(Status.ACTIVE); - } - deviceBO.setOwnerId(device.getOwner()); - deviceBO.setOwnerShip(device.getOwnership()); - deviceBO.setTenantId(DeviceManagementDAOUtil.getTenantId()); - deviceBO.setDeviceIdentificationId(device.getDeviceIdentifier()); - return deviceBO; - } - - public static DeviceIdentifier createDeviceIdentifier(Device device, DeviceType deviceType) { - DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); - deviceIdentifier.setType(deviceType.getName()); - deviceIdentifier.setId(device.getDeviceIdentificationId()); - return deviceIdentifier; - } -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/Device.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/Device.java deleted file mode 100644 index fae390ac6b..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/Device.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * 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.device.mgt.core.dto; - -import java.io.Serializable; - -public class Device implements Serializable { - - private static final long serialVersionUID = -8101106997837486245L; - private Integer id; - private String description; - private String name; - private Long dateOfEnrollment; - private Long dateOfLastUpdate; - private String deviceIdentificationId; - private Status status; - private String ownerId; - private String ownerShip; - private int tenantId; - private Integer deviceTypeId; - - public Integer getDeviceTypeId() { - return deviceTypeId; - } - - public void setDeviceTypeId(Integer deviceTypeId) { - this.deviceTypeId = deviceTypeId; - } - - public Integer getId() { - return id; - } - - public void setId(Integer 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 Long getDateOfEnrollment() { - return dateOfEnrollment; - } - - public void setDateOfEnrollment(Long dateOfEnrollment) { - this.dateOfEnrollment = dateOfEnrollment; - } - - public Long getDateOfLastUpdate() { - return dateOfLastUpdate; - } - - public void setDateOfLastUpdate(Long dateOfLastUpdate) { - this.dateOfLastUpdate = dateOfLastUpdate; - } - - public String getDeviceIdentificationId() { - return deviceIdentificationId; - } - - public void setDeviceIdentificationId(String deviceIdentificationId) { - this.deviceIdentificationId = deviceIdentificationId; - } - - public void setOwnerShip(String ownerShip) { - this.ownerShip = ownerShip; - } - - public String getOwnerShip() { - return ownerShip; - } - - public Status getStatus() { - return status; - } - - public String getOwnerId() { - return ownerId; - } - - public void setStatus(Status status) { - this.status = status; - } - - public void setOwnerId(String ownerId) { - this.ownerId = ownerId; - } - - public int getTenantId() { - return tenantId; - } - - public void setTenantId(int tenantId) { - this.tenantId = tenantId; - } -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/DeviceType.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/DeviceType.java deleted file mode 100644 index cd23498202..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/DeviceType.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.device.mgt.core.dto; - -import java.io.Serializable; - -public class DeviceType implements Serializable { - - private static final long serialVersionUID = 7927802716452548282L; - private Long id; - private String name; - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/OwnerShip.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/OwnerShip.java deleted file mode 100644 index a317568410..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/OwnerShip.java +++ /dev/null @@ -1,6 +0,0 @@ -package org.wso2.carbon.device.mgt.core.dto; - - -public enum OwnerShip { - BYOD,COPE -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/Status.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/Status.java deleted file mode 100644 index f315a24027..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/Status.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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.device.mgt.core.dto; - -public enum Status { - ACTIVE, INACTIVE -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java deleted file mode 100644 index 8c8bf62bca..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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.device.mgt.core.internal; - -import org.wso2.carbon.device.mgt.core.DeviceManager; -import org.wso2.carbon.user.core.service.RealmService; -import org.wso2.carbon.user.core.tenant.TenantManager; - -public class DeviceManagementDataHolder { - - private RealmService realmService; - private TenantManager tenantManager; - private DeviceManager deviceManager; - private static DeviceManagementDataHolder thisInstance = new DeviceManagementDataHolder(); - - private DeviceManagementDataHolder() { - } - - public static DeviceManagementDataHolder getInstance() { - return thisInstance; - } - - public RealmService getRealmService() { - return realmService; - } - - public void setRealmService(RealmService realmService) { - this.realmService = realmService; - this.setTenantManager(realmService); - } - - private void setTenantManager(RealmService realmService) { - if (realmService == null) { - throw new IllegalStateException("Realm service is not initialized properly"); - } - this.tenantManager = realmService.getTenantManager(); - } - - public TenantManager getTenantManager() { - return tenantManager; - } - - public DeviceManager getDeviceManager() { - return deviceManager; - } - - public void setDeviceManager(DeviceManager deviceManager) { - this.deviceManager = deviceManager; - } - -} 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 deleted file mode 100644 index 311e59d961..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * 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.device.mgt.core.internal; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.osgi.framework.BundleContext; -import org.osgi.service.component.ComponentContext; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.spi.DeviceManagerService; -import org.wso2.carbon.device.mgt.core.DeviceManagementConstants; -import org.wso2.carbon.device.mgt.core.DeviceManagementRepository; -import org.wso2.carbon.device.mgt.core.DeviceManager; -import org.wso2.carbon.device.mgt.core.DeviceManagerImpl; -import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager; -import org.wso2.carbon.device.mgt.core.config.DeviceManagementConfig; -import org.wso2.carbon.device.mgt.core.config.datasource.DataSourceConfig; -import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory; -import org.wso2.carbon.device.mgt.core.service.DeviceManagementService; -import org.wso2.carbon.device.mgt.core.util.DeviceManagementSchemaInitializer; -import org.wso2.carbon.user.core.service.RealmService; - -/** - * @scr.component name="org.wso2.carbon.device.manager" immediate="true" - * @scr.reference name="user.realmservice.default" - * interface="org.wso2.carbon.user.core.service.RealmService" - * cardinality="1..1" - * policy="dynamic" - * bind="setRealmService" - * unbind="unsetRealmService" - * @scr.reference name="device.manager.service" - * interface="org.wso2.carbon.device.mgt.common.spi.DeviceManagerService" - * cardinality="0..n" - * policy="dynamic" - * bind="setDeviceManagerService" - * unbind="unsetDeviceManagerService" - */ -@SuppressWarnings("unused") -public class DeviceManagementServiceComponent { - - private static Log log = LogFactory.getLog(DeviceManagementServiceComponent.class); - private DeviceManagementRepository pluginRepository = new DeviceManagementRepository(); - - protected void activate(ComponentContext componentContext) { - try { - if (log.isDebugEnabled()) { - log.debug("Initializing device management core bundle"); - } - /* Initializing Device Management Configuration */ - DeviceConfigurationManager.getInstance().initConfig(); - DeviceManagementConfig config = DeviceConfigurationManager.getInstance().getDeviceManagementConfig(); - - DataSourceConfig dsConfig = config.getDeviceMgtRepository().getDataSourceConfig(); - DeviceManagementDAOFactory.init(dsConfig); - - DeviceManager deviceManager = new DeviceManagerImpl(config, this.getPluginRepository()); - DeviceManagementDataHolder.getInstance().setDeviceManager(deviceManager); - - /* If -Dsetup option enabled then create device management database schema */ - String setupOption = System.getProperty(DeviceManagementConstants.Common.PROPERTY_SETUP); - if (setupOption != null) { - if (log.isDebugEnabled()) { - log.debug("-Dsetup is enabled. Device management repository schema initialization is about " + - "to begin"); - } - this.setupDeviceManagementSchema(dsConfig); - } - - if (log.isDebugEnabled()) { - log.debug("Registering OSGi service DeviceManagementService"); - } - BundleContext bundleContext = componentContext.getBundleContext(); - bundleContext.registerService(DeviceManagementService.class.getName(), - new DeviceManagementService(), null); - if (log.isDebugEnabled()) { - log.debug("Device management core bundle has been successfully initialized"); - } - } catch (Throwable e) { - String msg = "Error occurred while initializing device management core bundle"; - log.error(msg, e); - } - } - - private void setupDeviceManagementSchema(DataSourceConfig config) throws DeviceManagementException { - DeviceManagementSchemaInitializer initializer = new DeviceManagementSchemaInitializer(config); - log.info("Initializing device management repository database schema"); - - try { - initializer.createRegistryDatabase(); - } catch (Exception e) { - throw new DeviceManagementException("Error occurred while initializing Device Management " + - "database schema", e); - } - if (log.isDebugEnabled()) { - log.debug("Device management metadata repository schema has been successfully initialized"); - } - } - - /** - * Sets Device Manager service. - * @param deviceManagerService An instance of DeviceManagerService - */ - protected void setDeviceManagerService(DeviceManagerService deviceManagerService) { - if (log.isDebugEnabled()) { - log.debug("Setting Device Management Service Provider : '" + - deviceManagerService.getProviderType() + "'"); - } - this.getPluginRepository().addDeviceManagementProvider(deviceManagerService); - } - - /** - * Unsets Device Management service. - * @param deviceManagerService An Instance of DeviceManagerService - */ - protected void unsetDeviceManagerService(DeviceManagerService deviceManagerService) { - if (log.isDebugEnabled()) { - log.debug("Unsetting Device Management Service Provider : '" + - deviceManagerService.getProviderType() + "'"); - } - this.getPluginRepository().removeDeviceManagementProvider(deviceManagerService); - } - - /** - * Sets Realm Service. - * @param realmService An instance of RealmService - */ - protected void setRealmService(RealmService realmService) { - if (log.isDebugEnabled()) { - log.debug("Setting Realm Service"); - } - DeviceManagementDataHolder.getInstance().setRealmService(realmService); - } - - /** - * Unsets Realm Service. - * @param realmService An instance of RealmService - */ - protected void unsetRealmService(RealmService realmService) { - if (log.isDebugEnabled()) { - log.debug("Unsetting Realm Service"); - } - DeviceManagementDataHolder.getInstance().setRealmService(null); - } - - private DeviceManagementRepository getPluginRepository() { - return pluginRepository; - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementAdminService.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementAdminService.java deleted file mode 100644 index 245be1a689..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementAdminService.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * 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.service; - -import org.wso2.carbon.core.AbstractAdmin; - -public class DeviceManagementAdminService extends AbstractAdmin { - - - -} 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 deleted file mode 100644 index 8ddebb5740..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementService.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * 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.service; - -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.DeviceManager; -import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; - -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 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 { - return DeviceManagementDataHolder.getInstance().getDeviceManager(). - getOperationManager(type); - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagementSchemaInitializer.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagementSchemaInitializer.java deleted file mode 100644 index 448ae42007..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagementSchemaInitializer.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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. - * 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.util; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.core.config.datasource.DataSourceConfig; -import org.wso2.carbon.utils.CarbonUtils; -import org.wso2.carbon.utils.dbcreator.DatabaseCreator; - -import javax.sql.DataSource; -import java.io.File; - -public final class DeviceManagementSchemaInitializer extends DatabaseCreator { - - private static final Log log = LogFactory.getLog(DeviceManagementSchemaInitializer.class); - private static final String setupSQLScriptBaseLocation = - CarbonUtils.getCarbonHome() + File.separator + "dbscripts" + File.separator + "cdm" + File.separator; - - public DeviceManagementSchemaInitializer(DataSourceConfig config) { - super(DeviceManagerUtil.resolveDataSource(config)); - } - - protected String getDbScriptLocation(String databaseType) { - String scriptName = databaseType + ".sql"; - if (log.isDebugEnabled()) { - log.debug("Loading database script from :" + scriptName); - } - return setupSQLScriptBaseLocation.replaceFirst("DBTYPE", databaseType) + scriptName; - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java deleted file mode 100644 index b973ebd06e..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * 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.util; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.w3c.dom.Document; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.core.config.datasource.DataSourceConfig; -import org.wso2.carbon.device.mgt.core.config.datasource.JNDILookupDefinition; -import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException; -import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory; -import org.wso2.carbon.device.mgt.core.dao.DeviceTypeDAO; -import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil; -import org.wso2.carbon.device.mgt.core.dto.DeviceType; - -import javax.sql.DataSource; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import java.io.File; -import java.util.Hashtable; -import java.util.List; - -public final class DeviceManagerUtil { - - private static final Log log = LogFactory.getLog(DeviceManagerUtil.class); - - public static Document convertToDocument(File file) throws DeviceManagementException { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - factory.setNamespaceAware(true); - try { - DocumentBuilder docBuilder = factory.newDocumentBuilder(); - return docBuilder.parse(file); - } catch (Exception e) { - throw new DeviceManagementException("Error occurred while parsing file, while converting " + - "to a org.w3c.dom.Document : " + e.getMessage(), e); - } - } - - /** - * Resolve data source from the data source definition. - * - * @param config data source configuration - * @return data source resolved from the data source definition - */ - public static DataSource resolveDataSource(DataSourceConfig config) { - DataSource dataSource = null; - if (config == null) { - throw new RuntimeException("Device Management Repository data source configuration " + - "is null and thus, is not initialized"); - } - JNDILookupDefinition jndiConfig = config.getJndiLookupDefintion(); - if (jndiConfig != null) { - if (log.isDebugEnabled()) { - log.debug("Initializing Device Management Repository data source using the JNDI " + - "Lookup Definition"); - } - List jndiPropertyList = - jndiConfig.getJndiProperties(); - if (jndiPropertyList != null) { - Hashtable jndiProperties = new Hashtable(); - for (JNDILookupDefinition.JNDIProperty prop : jndiPropertyList) { - jndiProperties.put(prop.getName(), prop.getValue()); - } - dataSource = - DeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), jndiProperties); - } else { - dataSource = DeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), null); - } - } - return dataSource; - } - - /** - * Adds a new device type to the database if it does not exists. - * - * @param deviceType device type - * @return status of the operation - */ - public static boolean registerDeviceType(String deviceType) throws DeviceManagementException { - boolean status; - try { - DeviceTypeDAO deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO(); - Integer deviceTypeId = deviceTypeDAO.getDeviceTypeIdByDeviceTypeName(deviceType); - if (deviceTypeId == null) { - DeviceType dt = new DeviceType(); - dt.setName(deviceType); - deviceTypeDAO.addDeviceType(dt); - } - status = true; - } catch (DeviceManagementDAOException e) { - String msg = "Error occurred while registering the device type " + deviceType; - throw new DeviceManagementException(msg, e); - } - return status; - } - - /** - * Unregisters an existing device type from the device management metadata repository. - * - * @param deviceType device type - * @return status of the operation - */ - public static boolean unregisterDeviceType(String deviceType) throws DeviceManagementException { - try { - DeviceTypeDAO deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO(); - Integer deviceTypeId = deviceTypeDAO.getDeviceTypeIdByDeviceTypeName(deviceType); - if (deviceTypeId == null) { - DeviceType dt = new DeviceType(); - dt.setName(deviceType); - deviceTypeDAO.removeDeviceType(dt); - } - return true; - } catch (DeviceManagementDAOException e) { - String msg = "Error occurred while registering the device type " + deviceType; - throw new DeviceManagementException(msg, e); - } - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementConfigTests.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementConfigTests.java deleted file mode 100644 index 15a6b5ccd9..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementConfigTests.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Copyright (c) 2015, 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; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.wso2.carbon.device.mgt.core.config.DeviceManagementConfig; -import org.xml.sax.SAXException; - -import javax.xml.XMLConstants; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; -import javax.xml.validation.Schema; -import javax.xml.validation.SchemaFactory; -import java.io.File; - -public class DeviceManagementConfigTests { - - private static final Log log = LogFactory.getLog(DeviceManagementConfigTests.class); - private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_MGT_REPOSITORY = - "./src/test/resources/config/malformed-cdm-config-no-mgt-repo.xml"; - private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_DS_CONFIG = - "./src/test/resources/config/malformed-cdm-config-no-ds-config.xml"; - private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_JNDI_CONFIG = - "./src/test/resources/config/malformed-cdm-config-no-jndi-config.xml"; - private static final String TEST_CONFIG_SCHEMA_LOCATION = - "./src/test/resources/config/schema/DeviceManagementConfigSchema.xsd"; - - private Schema schema; - - @BeforeClass - private void initSchema() { - File deviceManagementSchemaConfig = new File(DeviceManagementConfigTests.TEST_CONFIG_SCHEMA_LOCATION); - SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); - try { - schema = factory.newSchema(deviceManagementSchemaConfig); - } catch (SAXException e) { - Assert.fail("Invalid schema found", e); - } - } - - @Test() - public void testMandateManagementRepositoryElement() { - File malformedConfig = - new File(DeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_MGT_REPOSITORY); - this.validateMalformedConfig(malformedConfig); - } - - @Test - public void testMandateDataSourceConfigurationElement() { - File malformedConfig = new File(DeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_DS_CONFIG); - this.validateMalformedConfig(malformedConfig); - } - - @Test - public void testMandateJndiLookupDefinitionElement() { - File malformedConfig = new File(DeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_JNDI_CONFIG); - this.validateMalformedConfig(malformedConfig); - } - - private void validateMalformedConfig(File malformedConfig) { - try { - JAXBContext ctx = JAXBContext.newInstance(DeviceManagementConfig.class); - Unmarshaller um = ctx.createUnmarshaller(); - um.setSchema(this.getSchema()); - um.unmarshal(malformedConfig); - Assert.assertTrue(false); - } catch (JAXBException e) { - log.error("Error occurred while unmarsharlling device management config", e); - Assert.assertTrue(true); - } - } - - private Schema getSchema() { - return schema; - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepositoryTests.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepositoryTests.java deleted file mode 100644 index c6cfc919d4..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepositoryTests.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Copyright (c) 2015, 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; - -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.wso2.carbon.device.mgt.common.spi.DeviceManagerService; - -public class DeviceManagementRepositoryTests { - - private DeviceManagementRepository repository; - - @BeforeClass - public void initRepository() { - this.repository = new DeviceManagementRepository(); - } - - @Test - public void testAddDeviceManagementService() { - DeviceManagerService sourceProvider = new TestDeviceManagerService(); - this.getRepository().addDeviceManagementProvider(sourceProvider); - - DeviceManagerService targetProvider = - this.getRepository().getDeviceManagementProvider(TestDeviceManagerService.DEVICE_TYPE_TEST); - - Assert.assertEquals(targetProvider.getProviderType(), sourceProvider.getProviderType()); - } - - @Test(dependsOnMethods = "testAddDeviceManagementService") - public void testRemoveDeviceManagementService() { - DeviceManagerService sourceProvider = new TestDeviceManagerService(); - this.getRepository().removeDeviceManagementProvider(sourceProvider); - - DeviceManagerService targetProvider = - this.getRepository().getDeviceManagementProvider(TestDeviceManagerService.DEVICE_TYPE_TEST); - - Assert.assertNull(targetProvider); - } - - private DeviceManagementRepository getRepository() { - return repository; - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementTestCase.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementTestCase.java deleted file mode 100644 index 0162f11a0e..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementTestCase.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.device.mgt.core; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.testng.Assert; -import org.testng.annotations.Test; - - -public class DeviceManagementTestCase { - - private static final Log log = LogFactory.getLog(DeviceManagementTestCase.class); - - @Test(groups = "device.mgt.test", description = "Testing the first test case with testng.") - public void setUp() throws Exception { - log.info("Testing started."); - Assert.assertEquals("A", "A"); - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManagerService.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManagerService.java deleted file mode 100644 index 8d217b5eb4..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManagerService.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * 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.core; - -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 java.util.List; - -public class TestDeviceManagerService implements DeviceManagerService { - - public static final String DEVICE_TYPE_TEST = "Test"; - - @Override - public String getProviderType() { - return TestDeviceManagerService.DEVICE_TYPE_TEST; - } - - @Override - public boolean enrollDevice(Device device) throws DeviceManagementException { - return false; - } - - @Override - public boolean modifyEnrollment(Device device) throws DeviceManagementException { - return false; - } - - @Override - public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException { - return false; - } - - @Override - public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException { - return false; - } - - @Override - public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException { - return false; - } - - @Override - public boolean setActive(DeviceIdentifier deviceId, boolean status) throws DeviceManagementException { - return false; - } - - @Override - public List getAllDevices() throws DeviceManagementException { - return null; - } - - @Override - public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException { - return null; - } - - @Override - public boolean updateDeviceInfo(Device device) throws DeviceManagementException { - return false; - } - - @Override - public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) throws DeviceManagementException { - return false; - } - - @Override - public OperationManager getOperationManager() throws DeviceManagementException { - return null; - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestUtils.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestUtils.java deleted file mode 100644 index a12560cc33..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestUtils.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * 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.core; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; - -public class TestUtils { - - private static final Log log = LogFactory.getLog(TestUtils.class); - - public static void cleanupResources(Connection conn, Statement stmt, ResultSet rs) { - if (rs != null) { - try { - rs.close(); - } catch (SQLException e) { - log.warn("Error occurred while closing result set", e); - } - } - if (stmt != null) { - try { - stmt.close(); - } catch (SQLException e) { - log.warn("Error occurred while closing prepared statement", e); - } - } - if (conn != null) { - try { - conn.close(); - } catch (SQLException e) { - log.warn("Error occurred while closing database connection", e); - } - } - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/DBTypes.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/DBTypes.java deleted file mode 100644 index 89c5683ff6..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/DBTypes.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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.device.mgt.core.common; - - -public enum DBTypes { - Oracle("Oracle"),H2("H2"),MySql("MySql"); - - String dbName ; - DBTypes(String dbStrName) { - dbName = dbStrName; - } -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/TestDBConfiguration.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/TestDBConfiguration.java deleted file mode 100644 index d33bfeba94..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/TestDBConfiguration.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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.device.mgt.core.common; - -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "DBType") -public class TestDBConfiguration { - - private String connectionUrl; - private String driverClass; - private String userName; - private String pwd; - - @Override public String toString() { - return "TestDBConfiguration{" + - "connectionUrl='" + connectionUrl + '\'' + - ", driverClass='" + driverClass + '\'' + - ", userName='" + userName + '\'' + - ", pwd='" + pwd + '\'' + - ", dbType='" + dbType + '\'' + - '}'; - } - - private String dbType; - - @XmlElement(name = "connectionurl", nillable = false) - public String getConnectionUrl() { - return connectionUrl; - } - - public void setConnectionUrl(String connectionUrl) { - this.connectionUrl = connectionUrl; - } - - @XmlElement(name = "driverclass", nillable = false) - public String getDriverClass() { - return driverClass; - } - - public void setDriverClass(String driverClass) { - this.driverClass = driverClass; - } - - @XmlElement(name = "userName", nillable = false) - public String getUserName() { - return userName; - } - - public void setUserName(String userName) { - this.userName = userName; - } - - @XmlElement(name = "pwd", nillable = false) - public String getPwd() { - return pwd; - } - - public void setPwd(String pwd) { - this.pwd = pwd; - } - - @XmlAttribute(name = "typeName") - public String getDbType() { - return dbType; - } - - public void setDbType(String dbType) { - this.dbType = dbType; - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/TestDBConfigurations.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/TestDBConfigurations.java deleted file mode 100644 index d1551cca0e..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/TestDBConfigurations.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.device.mgt.core.common; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import java.util.List; - -@XmlRootElement(name = "DeviceMgtTestDBConfigurations") -public class TestDBConfigurations { - - private List dbTypesList; - - @XmlElement(name = "DBType") - public List getDbTypesList() { - return dbTypesList; - } - - public void setDbTypesList(List dbTypesList) { - this.dbTypesList = dbTypesList; - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/DeviceManagementDAOTests.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/DeviceManagementDAOTests.java deleted file mode 100644 index abde92ae30..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/DeviceManagementDAOTests.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * 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.device.mgt.core.dao; - -import org.apache.commons.dbcp.BasicDataSource; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Parameters; -import org.testng.annotations.Test; -import org.w3c.dom.Document; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.core.TestUtils; -import org.wso2.carbon.device.mgt.core.common.DBTypes; -import org.wso2.carbon.device.mgt.core.common.TestDBConfiguration; -import org.wso2.carbon.device.mgt.core.common.TestDBConfigurations; -import org.wso2.carbon.device.mgt.core.dto.Device; -import org.wso2.carbon.device.mgt.core.dto.DeviceType; -import org.wso2.carbon.device.mgt.core.dto.OwnerShip; -import org.wso2.carbon.device.mgt.core.dto.Status; -import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; -import java.io.File; -import java.sql.*; -import java.util.Date; - -public class DeviceManagementDAOTests { - - @BeforeClass - @Parameters("dbType") - public void setUpDB(String dbTypeStr) throws Exception { - DBTypes dbType = DBTypes.valueOf(dbTypeStr); - TestDBConfiguration dbConfig = getTestDBConfiguration(dbType); - - switch (dbType) { - case H2: - createH2DB(dbConfig); - BasicDataSource testDataSource = new BasicDataSource(); - testDataSource.setDriverClassName(dbConfig.getDriverClass()); - testDataSource.setUrl(dbConfig.getConnectionUrl()); - testDataSource.setUsername(dbConfig.getUserName()); - testDataSource.setPassword(dbConfig.getPwd()); - DeviceManagementDAOFactory.init(testDataSource); - default: - } - } - - private TestDBConfiguration getTestDBConfiguration(DBTypes dbType) throws DeviceManagementDAOException, - DeviceManagementException { - File deviceMgtConfig = new File("src/test/resources/testdbconfig.xml"); - Document doc; - TestDBConfigurations dbConfigs; - - doc = DeviceManagerUtil.convertToDocument(deviceMgtConfig); - JAXBContext testDBContext = null; - - try { - testDBContext = JAXBContext.newInstance(TestDBConfigurations.class); - Unmarshaller unmarshaller = testDBContext.createUnmarshaller(); - dbConfigs = (TestDBConfigurations) unmarshaller.unmarshal(doc); - } catch (JAXBException e) { - throw new DeviceManagementDAOException("Error parsing test db configurations", e); - } - - for (TestDBConfiguration config : dbConfigs.getDbTypesList()) { - if (config.getDbType().equals(dbType.toString())) { - return config; - } - } - return null; - } - - private void createH2DB(TestDBConfiguration testDBConf) throws Exception { - Connection conn = null; - Statement stmt = null; - try { - Class.forName(testDBConf.getDriverClass()); - conn = DriverManager.getConnection(testDBConf.getConnectionUrl()); - stmt = conn.createStatement(); - stmt.executeUpdate("RUNSCRIPT FROM './src/test/resources/sql/CreateH2TestDB.sql'"); - } finally { - TestUtils.cleanupResources(conn, stmt, null); - } - } - - @Test - public void addDeviceTypeTest() throws DeviceManagementDAOException, DeviceManagementException { - DeviceTypeDAO deviceTypeMgtDAO = DeviceManagementDAOFactory.getDeviceTypeDAO(); - - DeviceType deviceType = new DeviceType(); - deviceType.setName("IOS"); - - deviceTypeMgtDAO.addDeviceType(deviceType); - Long deviceTypeId = null; - - Connection conn = null; - Statement stmt = null; - try { - conn = DeviceManagementDAOFactory.getDataSource().getConnection(); - stmt = conn.createStatement(); - ResultSet resultSet = - stmt.executeQuery("SELECT ID,NAME from DM_DEVICE_TYPE DType where DType.NAME='IOS'"); - - while (resultSet.next()) { - deviceTypeId = resultSet.getLong(1); - } - } catch (SQLException sqlEx) { - throw new DeviceManagementDAOException("error in fetch device type by name IOS", sqlEx); - } finally { - TestUtils.cleanupResources(conn, stmt, null); - } - - Assert.assertNotNull(deviceTypeId, "Device Type Id is null"); - deviceType.setId(deviceTypeId); - - } - - @Test(dependsOnMethods = {"addDeviceTypeTest"}) - public void addDeviceTest() throws DeviceManagementDAOException, DeviceManagementException { - DeviceDAO deviceMgtDAO = DeviceManagementDAOFactory.getDeviceDAO(); - - Device device = new Device(); - device.setDateOfEnrollment(new Date().getTime()); - device.setDateOfLastUpdate(new Date().getTime()); - device.setDescription("test description"); - device.setStatus(Status.ACTIVE); - device.setDeviceIdentificationId("111"); - - DeviceType deviceType = new DeviceType(); - deviceType.setId(Long.parseLong("1")); - - device.setDeviceTypeId(deviceType.getId().intValue()); - device.setOwnerShip(OwnerShip.BYOD.toString()); - device.setOwnerId("111"); - device.setTenantId(-1234); - deviceMgtDAO.addDevice(device); - - Long deviceId = null; - Connection conn = null; - PreparedStatement stmt = null; - ResultSet rs = null; - try { - conn = DeviceManagementDAOFactory.getDataSource().getConnection(); - stmt = conn.prepareStatement("SELECT ID from DM_DEVICE DEVICE where DEVICE.DEVICE_IDENTIFICATION='111'"); - rs = stmt.executeQuery(); - - while (rs.next()) { - deviceId = rs.getLong(1); - } - } catch (SQLException e) { - throw new DeviceManagementDAOException("error in fetch device by device identification id", e); - } finally { - TestUtils.cleanupResources(conn, stmt, rs); - } - - Assert.assertNotNull(deviceId, "Device Id is null"); - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/malformed-cdm-config-no-ds-config.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/malformed-cdm-config-no-ds-config.xml deleted file mode 100644 index a2a20ccd46..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/malformed-cdm-config-no-ds-config.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - jdbc/DEVICE_MGT_DS - - - - - diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/malformed-cdm-config-no-jndi.config.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/malformed-cdm-config-no-jndi.config.xml deleted file mode 100644 index 5a4e934dc5..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/malformed-cdm-config-no-jndi.config.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - jdbc/DEVICE_MGT_DS - - - - - diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/malformed-cdm-config-no-mgt-repo.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/malformed-cdm-config-no-mgt-repo.xml deleted file mode 100644 index 6f2b60631c..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/malformed-cdm-config-no-mgt-repo.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - jdbc/DEVICE_MGT_DS - - - - - diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/schema/DeviceManagementConfigSchema.xsd b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/schema/DeviceManagementConfigSchema.xsd deleted file mode 100644 index 31337c4260..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/schema/DeviceManagementConfigSchema.xsd +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/sql/CreateH2TestDB.sql b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/sql/CreateH2TestDB.sql deleted file mode 100644 index afcd19ca06..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/sql/CreateH2TestDB.sql +++ /dev/null @@ -1,24 +0,0 @@ -CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE -( - ID INT auto_increment NOT NULL, - NAME VARCHAR(300) NULL DEFAULT NULL, - PRIMARY KEY (ID) -); - -CREATE TABLE IF NOT EXISTS DM_DEVICE -( - ID INT auto_increment NOT NULL, - DESCRIPTION TEXT NULL DEFAULT NULL, - NAME VARCHAR(100) NULL DEFAULT NULL, - DATE_OF_ENROLLMENT BIGINT NULL DEFAULT NULL, - DATE_OF_LAST_UPDATE BIGINT NULL DEFAULT NULL, - OWNERSHIP VARCHAR(45) NULL DEFAULT NULL, - STATUS VARCHAR(15) NULL DEFAULT NULL, - DEVICE_TYPE_ID INT(11) NULL DEFAULT NULL, - DEVICE_IDENTIFICATION VARCHAR(300) NULL DEFAULT NULL, - OWNER VARCHAR(45) NULL DEFAULT NULL, - TENANT_ID INTEGER DEFAULT 0, - PRIMARY KEY (ID), - CONSTRAINT fk_DM_DEVICE_DM_DEVICE_TYPE2 FOREIGN KEY (DEVICE_TYPE_ID ) - REFERENCES DM_DEVICE_TYPE (ID ) ON DELETE NO ACTION ON UPDATE NO ACTION -); \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testdbconfig.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testdbconfig.xml deleted file mode 100644 index 34e89a1392..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testdbconfig.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - jdbc:h2:mem:cdm-test-db;DB_CLOSE_DELAY=-1 - org.h2.Driver - - - - diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testng.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testng.xml deleted file mode 100644 index 2c5fe6fe7d..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testng.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index 0254ac2687..ea411b77f3 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon - wso2cdm-parent + wso2mdm-parent 2.0.0-SNAPSHOT ../../pom.xml @@ -37,65 +37,9 @@ http://wso2.org - org.wso2.carbon.device.mgt.core - org.wso2.carbon.device.mgt.common org.wso2.carbon.device.mgt.mobile.impl - diff --git a/components/key-mgt/pom.xml b/components/key-mgt/pom.xml index 67b910014f..f00b618ce4 100644 --- a/components/key-mgt/pom.xml +++ b/components/key-mgt/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon - wso2cdm-parent + wso2mdm-parent 2.0.0-SNAPSHOT ../../pom.xml diff --git a/components/policy-mgt/org.wso2.carbon.policy.evalutor/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.evalutor/pom.xml deleted file mode 100644 index 5688d817a7..0000000000 --- a/components/policy-mgt/org.wso2.carbon.policy.evalutor/pom.xml +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - org.wso2.carbon - policy-mgt - 2.0.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon - org.wso2.carbon.policy.evaluator - 2.0.0-SNAPSHOT - bundle - WSO2 Carbon - Policy Decision Point - WSO2 Carbon - Policy Decision Point - 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} - Policy Management Common Bundle - org.wso2.carbon.policy.evaluator - - org.apache.commons.logging - - - org.wso2.carbon.policy.evaluator.* - - * - - - - - - - - - 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.policy.mgt.common - - - - - diff --git a/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/FeatureFilter.java b/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/FeatureFilter.java deleted file mode 100644 index 0636e1689a..0000000000 --- a/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/FeatureFilter.java +++ /dev/null @@ -1,49 +0,0 @@ -/* -* Copyright (c) 2015 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.evaluator; - -import org.wso2.carbon.policy.mgt.common.Feature; -import org.wso2.carbon.policy.mgt.common.Policy; - -import java.util.List; -import java.util.Map; - -public interface FeatureFilter { - - List evaluate(List policyList, List featureRulesList); - - List extractFeatures(List policyList); - - List evaluateFeatures(List featureList, List featureRulesList); - - void getDenyOverridesFeatures(String featureName, List featureList, List effectiveFeatureList); - - void getPermitOverridesFeatures(String featureName, List featureList, List effectiveFeatureList); - - void getFirstApplicableFeatures(String featureName, List featureList, List effectiveFeatureList); - - void getLastApplicableFeatures(String featureName, List featureList, List effectiveFeatureList); - - void getAllApplicableFeatures(String featureName, List featureList, List effectiveFeatureList); - - void getHighestApplicableFeatures(String featureName, List featureList, List effectiveFeatureList); - - void getLowestApplicableFeatures(String featureName, List featureList, List effectiveFeatureList); -} diff --git a/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/FeatureFilterImpl.java b/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/FeatureFilterImpl.java deleted file mode 100644 index 04faae5f03..0000000000 --- a/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/FeatureFilterImpl.java +++ /dev/null @@ -1,250 +0,0 @@ -/* -* Copyright (c) 2015 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.evaluator; - -import org.wso2.carbon.policy.evaluator.utils.Constants; -import org.wso2.carbon.policy.mgt.common.Feature; -import org.wso2.carbon.policy.mgt.common.Policy; - -import java.util.ArrayList; -import java.util.List; - -/** - * This class is responsible for evaluating the policy (Configurations sets) and returning - * the effective features set. - */ - -public class FeatureFilterImpl implements FeatureFilter { - - /** - * This method returns the effective feature list when policy list and feature aggregation rules are supplied. - * @param policyList - * @param featureRulesList - * @return - */ - @Override - public List evaluate(List policyList, List featureRulesList) { - return evaluateFeatures(extractFeatures(policyList), featureRulesList); - } - - /** - * This method extract the features from the given policy list in the order they are provided in the list. - * @param policyList - * @return - */ - public List extractFeatures(List policyList) { - List featureList = new ArrayList(); - for (Policy policy : policyList) { - featureList.addAll(policy.getFeaturesList()); - } - return featureList; - } - - /** - * This method is responsible for supplying tasks to other methods to evaluate given features. - * @param featureList - * @param featureRulesList - * @return - */ - public List evaluateFeatures(List featureList, List featureRulesList) { - List effectiveFeatureList = new ArrayList(); - for (FeatureRules rule : featureRulesList) { - String ruleName = rule.getEvaluationCriteria(); - String featureName = rule.getName(); - if (ruleName.equalsIgnoreCase(Constants.DENY_OVERRIDES)) { - getDenyOverridesFeatures(featureName, featureList, effectiveFeatureList); - } - if (ruleName.equalsIgnoreCase(Constants.PERMIT_OVERRIDES)) { - getPermitOverridesFeatures(featureName, featureList, effectiveFeatureList); - } - if (ruleName.equalsIgnoreCase(Constants.FIRST_APPLICABLE)) { - getFirstApplicableFeatures(featureName, featureList, effectiveFeatureList); - } - if (ruleName.equalsIgnoreCase(Constants.LAST_APPLICABLE)) { - getLastApplicableFeatures(featureName, featureList, effectiveFeatureList); - } - if (ruleName.equalsIgnoreCase(Constants.ALL_APPLICABLE)) { - getAllApplicableFeatures(featureName, featureList, effectiveFeatureList); - } - if (ruleName.equalsIgnoreCase(Constants.HIGHEST_APPLICABLE)) { - getHighestApplicableFeatures(featureName, featureList, effectiveFeatureList); - } - if (ruleName.equalsIgnoreCase(Constants.LOWEST_APPLICABLE)) { - getLowestApplicableFeatures(featureName, featureList, effectiveFeatureList); - } - } - return effectiveFeatureList; - } - - /** - * This method picks up denied features, if there is no denied features it will add to the list, the final permitted feature. - * But if given policies do not have features of given type, it will not add anything. - * - * @param featureName - * @param featureList - * @param effectiveFeatureList - */ - public void getDenyOverridesFeatures(String featureName, List featureList, List effectiveFeatureList) { - Feature evaluatedFeature = null; - for (Feature feature : featureList) { - if (feature.getName().equalsIgnoreCase(featureName)) { - if (feature.getRuleValue().equalsIgnoreCase("Deny")) { - evaluatedFeature = feature; - effectiveFeatureList.add(evaluatedFeature); - return; - } else { - evaluatedFeature = feature; - } - } - } - if (evaluatedFeature != null) { - effectiveFeatureList.add(evaluatedFeature); - } - - } - - /** - * This method picks up permitted features, if there is no permitted features it will add to the list, the final denied feature. - * But if given policies do not have features of given type, it will not add anything. - * - * @param featureName - * @param featureList - * @param effectiveFeatureList - */ - public void getPermitOverridesFeatures(String featureName, List featureList, List effectiveFeatureList) { - Feature evaluatedFeature = null; - for (Feature feature : featureList) { - if (feature.getName().equalsIgnoreCase(featureName)) { - if (feature.getRuleValue().equalsIgnoreCase("Permit")) { - evaluatedFeature = feature; - effectiveFeatureList.add(evaluatedFeature); - return; - } else { - evaluatedFeature = feature; - } - } - } - if (evaluatedFeature != null) { - effectiveFeatureList.add(evaluatedFeature); - } - - } - - /** - * This method picks the first features of the give type. - * But if given policies do not have features of given type, it will not add anything. - * - * @param featureName - * @param featureList - * @param effectiveFeatureList - */ - public void getFirstApplicableFeatures(String featureName, List featureList, List effectiveFeatureList) { - for (Feature feature : featureList) { - if (feature.getName().equalsIgnoreCase(featureName)) { - effectiveFeatureList.add(feature); - return; - - } - } - } - - /** - * This method picks the last features of the give type. - * But if given policies do not have features of given type, it will not add anything. - * - * @param featureName - * @param featureList - * @param effectiveFeatureList - */ - public void getLastApplicableFeatures(String featureName, List featureList, List effectiveFeatureList) { - Feature evaluatedFeature = null; - for (Feature feature : featureList) { - if (feature.getName().equalsIgnoreCase(featureName)) { - evaluatedFeature = feature; - } - } - if (evaluatedFeature != null) { - effectiveFeatureList.add(evaluatedFeature); - } - } - - /** - * This method picks the all features of the give type. - * But if given policies do not have features of given type, it will not add anything. - * - * @param featureName - * @param featureList - * @param effectiveFeatureList - */ - public void getAllApplicableFeatures(String featureName, List featureList, List effectiveFeatureList) { - for (Feature feature : featureList) { - if (feature.getName().equalsIgnoreCase(featureName)) { - effectiveFeatureList.add(feature); - } - } - } - - /** - * This method picks the feature with the highest value of given type. - * But if given policies do not have features of given type, it will not add anything. - * - * @param featureName - * @param featureList - * @param effectiveFeatureList - */ - public void getHighestApplicableFeatures(String featureName, List featureList, List effectiveFeatureList) { - Feature evaluatedFeature = null; - int intValve = 0; - for (Feature feature : featureList) { - if (feature.getName().equalsIgnoreCase(featureName)) { - if (Integer.parseInt(feature.getRuleValue()) > intValve) { - intValve = Integer.parseInt(feature.getRuleValue()); - evaluatedFeature = feature; - } - } - } - if (evaluatedFeature != null) { - effectiveFeatureList.add(evaluatedFeature); - } - } - - /** - * This method picks the feature with the lowest value of given type. - * But if given policies do not have features of given type, it will not add anything. - * - * @param featureName - * @param featureList - * @param effectiveFeatureList - */ - public void getLowestApplicableFeatures(String featureName, List featureList, List effectiveFeatureList) { - Feature evaluatedFeature = null; - int intValve = 0; - for (Feature feature : featureList) { - if (feature.getName().equalsIgnoreCase(featureName)) { - if (Integer.parseInt(feature.getRuleValue()) < intValve) { - intValve = Integer.parseInt(feature.getRuleValue()); - evaluatedFeature = feature; - } - } - } - if (evaluatedFeature != null) { - effectiveFeatureList.add(evaluatedFeature); - } - } -} diff --git a/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/FeatureRules.java b/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/FeatureRules.java deleted file mode 100644 index f706cf947f..0000000000 --- a/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/FeatureRules.java +++ /dev/null @@ -1,41 +0,0 @@ -/* -* Copyright (c) 2015 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.evaluator; - -public class FeatureRules { - - private String name; - private String evaluationCriteria; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getEvaluationCriteria() { - return evaluationCriteria; - } - - public void setEvaluationCriteria(String evaluationCriteria) { - this.evaluationCriteria = evaluationCriteria; - } -} 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 deleted file mode 100644 index 88c2094463..0000000000 --- a/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/PDPException.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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.policy.evaluator; - -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.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/PDPServiceImpl.java b/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/PDPServiceImpl.java deleted file mode 100644 index 04c9b47288..0000000000 --- a/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/PDPServiceImpl.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2015, 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.evaluator; - -import org.wso2.carbon.policy.evaluator.spi.PDPService; -import org.wso2.carbon.policy.mgt.common.Feature; -import org.wso2.carbon.policy.mgt.common.Policy; - -import java.util.List; - -public class PDPServiceImpl implements PDPService { - @Override - public List getEffectivePolicyList(List policies, List roles, String deviceType) { - return null; - } - - @Override - public List getEffectiveFeatureList(List policies, List featureRulesList) { - return null; - } -} diff --git a/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/PolicyFilter.java b/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/PolicyFilter.java deleted file mode 100644 index 6a32448793..0000000000 --- a/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/PolicyFilter.java +++ /dev/null @@ -1,43 +0,0 @@ -/* -* Copyright (c) 2015 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.evaluator; - -import org.wso2.carbon.policy.mgt.common.Policy; - -import java.util.List; - -public interface PolicyFilter { - - /** - * This method will extract the policies related a given roles list from the policy list available. - * @param policyList - * @param roles - * @return - */ - public List extractPoliciesRelatedToRoles(List policyList, List roles); - - /** - * This mehtod extract the policies related to a given device type from policy list. - * @param policyList - * @param deviceType - * @return - */ - public List extractPoliciesRelatedToDeviceType(List policyList, String deviceType); -} diff --git a/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/PolicyFilterImpl.java b/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/PolicyFilterImpl.java deleted file mode 100644 index 92775e7ce8..0000000000 --- a/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/PolicyFilterImpl.java +++ /dev/null @@ -1,72 +0,0 @@ -/* -* Copyright (c) 2015 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.evaluator; - -import org.wso2.carbon.policy.mgt.common.Policy; - -import java.util.ArrayList; -import java.util.List; - -public class PolicyFilterImpl implements PolicyFilter { - - - /** - * This method will extract the policies related a given roles list from the policy list available. - * - * @param policyList - * @param roles - * @return - */ - @Override - public List extractPoliciesRelatedToRoles(List policyList, List roles) { - - List policies = new ArrayList(); - - for (Policy policy : policyList) { - List roleList = policy.getRoleList(); - - for (String role : roleList) { - if (roles.contains(role)) { - policies.add(policy); - break; - } - } - } - return policies; - } - - /** - * This mehtod extract the policies related to a given device type from policy list. - * - * @param policyList - * @param deviceType - * @return - */ - @Override - public List extractPoliciesRelatedToDeviceType(List policyList, String deviceType) { - List policies = new ArrayList(); - - for (Policy policy : policyList) { - if (policy.getDeviceType().equalsIgnoreCase(deviceType)) { - policies.add(policy); - } - } - return policies; - } -} diff --git a/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/spi/PDPService.java b/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/spi/PDPService.java deleted file mode 100644 index 0b2b65d444..0000000000 --- a/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/spi/PDPService.java +++ /dev/null @@ -1,34 +0,0 @@ -/* -* 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.evaluator.spi; - - -import org.wso2.carbon.policy.evaluator.FeatureRules; -import org.wso2.carbon.policy.mgt.common.Feature; -import org.wso2.carbon.policy.mgt.common.Policy; - -import java.util.List; - -public interface PDPService { - - List getEffectivePolicyList(List policies, List roles, String deviceType); - - List getEffectiveFeatureList(List policies, List featureRulesList); - -} diff --git a/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/utils/Constants.java b/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/utils/Constants.java deleted file mode 100644 index eb5326b15f..0000000000 --- a/components/policy-mgt/org.wso2.carbon.policy.evalutor/src/main/java/org/wso2/carbon/policy/evaluator/utils/Constants.java +++ /dev/null @@ -1,30 +0,0 @@ -/* -* Copyright (c) 2015 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.evaluator.utils; - -public class Constants { - - public static final String DENY_OVERRIDES="deny_overrides"; - public static final String PERMIT_OVERRIDES="permit_overrides"; - public static final String FIRST_APPLICABLE="first_applicable"; - public static final String LAST_APPLICABLE="last_applicable"; - public static final String ALL_APPLICABLE="all_applicable"; - public static final String HIGHEST_APPLICABLE="highest_applicable"; - public static final String LOWEST_APPLICABLE="lowest_applicable"; -} diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml deleted file mode 100644 index f6384a31b6..0000000000 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - org.wso2.carbon - policy-mgt - 2.0.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon - org.wso2.carbon.policy.mgt.common - 2.0.0-SNAPSHOT - bundle - WSO2 Carbon - Policy Management Common - WSO2 Carbon - Policy Management Common - 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} - Policy Management Common Bundle - org.wso2.carbon.policy.mgt.common.internal - - org.apache.commons.logging - - - org.wso2.carbon.policy.mgt.common.* - - * - - - - - - - - - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.equinox - org.eclipse.equinox.common - - - org.wso2.carbon - org.wso2.carbon.logging - - - org.testng - testng - - - - - 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 deleted file mode 100644 index ef962b937c..0000000000 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Feature.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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.policy.mgt.common; - -public class Feature { - - private int id; - private String code; - private String name; - private Object attribute; - private String ruleValue; - - public String getRuleValue() { - return ruleValue; - } - - public void setRuleValue(String ruleValue) { - this.ruleValue = ruleValue; - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Object getAttribute() { - return attribute; - } - - public void setAttribute(Object attribute) { - this.attribute = 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 deleted file mode 100644 index a870eba718..0000000000 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/FeatureManagementException.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.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/FeatureManagerService.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/FeatureManagerService.java deleted file mode 100644 index 405625697e..0000000000 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/FeatureManagerService.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.policy.mgt.common; - -import java.util.List; - -public interface FeatureManagerService { - - void addFeature(Feature feature) throws FeatureManagementException; - - void editFeature(Feature feature) throws FeatureManagementException; - - void removeFeature(int featureId) throws FeatureManagementException; - - List getFeatures() throws FeatureManagementException; - - List getFeaturesOfPolicy(int policyId) throws FeatureManagementException; -} 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 deleted file mode 100644 index 3f3d580aa1..0000000000 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Policy.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * 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.policy.mgt.common; - -import java.util.List; - -public class Policy { - private int id; - private String policyName; - private List featuresList; - private boolean generic; - private List roleList; - private List DeviceList; - private String deviceType; - - public List getRoleList() { - return roleList; - } - - public void setRoleList(List roleList) { - this.roleList = roleList; - } - - public List getDeviceList() { - return DeviceList; - } - - public void setDeviceList(List deviceList) { - DeviceList = deviceList; - } - - public String getDeviceType() { - return deviceType; - } - - public void setDeviceType(String deviceType) { - this.deviceType = deviceType; - } - - public boolean isGeneric() { - return generic; - } - - public void setGeneric(boolean generic) { - this.generic = generic; - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getPolicyName() { - return policyName; - } - - public void setPolicyName(String policyName) { - this.policyName = policyName; - } - - public List getFeaturesList() { - return featuresList; - } - - public void setFeaturesList(List featuresList) { - this.featuresList = featuresList; - } -} 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 deleted file mode 100644 index a5d45dc269..0000000000 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyManagementException.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.policy.mgt.common; - -public class PolicyManagementException extends Exception { - - private String policyErrorMessage; - - public String getPolicyErrorMessage() { - return policyErrorMessage; - } - - public void setPolicyErrorMessage(String policyErrorMessage) { - this.policyErrorMessage = policyErrorMessage; - } - - public PolicyManagementException(String message) { - super(message); - setPolicyErrorMessage(message); - } - - public PolicyManagementException(String message, Exception ex) { - super(message, ex); - setPolicyErrorMessage(message); - } - - public PolicyManagementException(String message, Throwable cause) { - super(message, cause); - setPolicyErrorMessage(message); - } - - public PolicyManagementException() { - super(); - } - - public PolicyManagementException(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/PolicyManagerService.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyManagerService.java deleted file mode 100644 index db21219687..0000000000 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyManagerService.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * 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.policy.mgt.common; - -/** - * This interface defines the policy management which should be implemented by the plugins - */ - -public interface PolicyManagerService { - - /** - * This method adds a policy to the platform - * - * @param policy - * @return primary key (generated key) - */ - - int addPolicy(Policy policy); - - /** - * This method adds a policy per device which should be implemented by the related plugins. - * - * @param deviceId - * @param deviceType - * @param policy - * @return primary key (generated key) - */ - - int addPolicyToDevice(String deviceId, String deviceType, Policy policy) throws FeatureManagementException, PolicyManagementException; - - /** - * This method adds a policy to device type by the related device type plugins. - * - * @param deviceType - * @param policy - * @return primary key (generated key) - */ - - int addPolicyToDeviceType(String deviceType, Policy policy) throws FeatureManagementException, PolicyManagementException; - - /** - * This method adds the policy to specific role. - * - * @param roleName - * @param policy - * @return primary key (generated key) - */ - int addPolicyToRole(String roleName, Policy policy) throws FeatureManagementException, PolicyManagementException; - - /** - * This method returns the policy of whole platform - * - * @return - */ - - Policy getPolicy(); - - /** - * This method gives the device specific policy. - * - * @param deviceId - * @param deviceType - * @return Policy - */ - - Policy getPolicyOfDevice(String deviceId, String deviceType) throws FeatureManagementException, PolicyManagementException; - - /** - * This method returns the device type specific policy. - * - * @param deviceType - * @return Policy - */ - - Policy getPolicyOfDeviceType(String deviceType) throws FeatureManagementException, PolicyManagementException; - - /** - * This method returns the role specific policy. - * - * @param roleName - * @return - */ - - Policy getPolicyOfRole(String roleName) throws FeatureManagementException, PolicyManagementException; - - - boolean isPolicyAvailableForDevice(String deviceId, String deviceType) throws PolicyManagementException; - - - boolean isPolicyUsed(String deviceId, String deviceType) throws PolicyManagementException; - - - void setPolicyUsed(String deviceId, String deviceType, Policy policy) throws PolicyManagementException; -} diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/impl/PolicyManagement.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/impl/PolicyManagement.java deleted file mode 100644 index 8fd5e24d24..0000000000 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/impl/PolicyManagement.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2015, 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.policy.mgt.common.impl; - -import org.wso2.carbon.policy.mgt.common.FeatureManagementException; -import org.wso2.carbon.policy.mgt.common.Policy; -import org.wso2.carbon.policy.mgt.common.PolicyManagementException; -import org.wso2.carbon.policy.mgt.common.PolicyManagerService; - -public class PolicyManagement implements PolicyManagerService { - @Override - public int addPolicy(Policy policy) { - return 0; - } - - @Override - public int addPolicyToDevice(String deviceId, String deviceType, Policy policy) throws FeatureManagementException, PolicyManagementException { - return 0; - } - - @Override - public int addPolicyToDeviceType(String deviceType, Policy policy) throws FeatureManagementException, PolicyManagementException { - return 0; - } - - @Override - public int addPolicyToRole(String roleName, Policy policy) throws FeatureManagementException, PolicyManagementException { - return 0; - } - - @Override - public Policy getPolicy() { - return null; - } - - @Override - public Policy getPolicyOfDevice(String deviceId, String deviceType) throws FeatureManagementException, PolicyManagementException { - return null; - } - - @Override - public Policy getPolicyOfDeviceType(String deviceType) throws FeatureManagementException, PolicyManagementException { - return null; - } - - @Override - public Policy getPolicyOfRole(String roleName) throws FeatureManagementException, PolicyManagementException { - return null; - } - - @Override - public boolean isPolicyAvailableForDevice(String deviceId, String deviceType) throws PolicyManagementException { - return false; - } - - @Override - public boolean isPolicyUsed(String deviceId, String deviceType) throws PolicyManagementException { - return false; - } - - @Override - public void setPolicyUsed(String deviceId, String deviceType, Policy policy) throws PolicyManagementException { - - } -} diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/test/java/org/wos2/carbon/policy/mgt/common/PolicyManagementTestCase.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/test/java/org/wos2/carbon/policy/mgt/common/PolicyManagementTestCase.java deleted file mode 100644 index 456614089e..0000000000 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/test/java/org/wos2/carbon/policy/mgt/common/PolicyManagementTestCase.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2015, 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.wos2.carbon.policy.mgt.common; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.testng.Assert; -import org.testng.annotations.Test; -import org.wos2.carbon.policy.mgt.common.utils.PolicyCreator; -import org.wso2.carbon.policy.mgt.common.FeatureManagementException; -import org.wso2.carbon.policy.mgt.common.Policy; -import org.wso2.carbon.policy.mgt.common.PolicyManagementException; -import org.wso2.carbon.policy.mgt.common.impl.PolicyManagement; - -public class PolicyManagementTestCase { - - private static final Log log = LogFactory.getLog(PolicyManagementTestCase.class); - - Policy policy = PolicyCreator.createPolicy(); - - private PolicyManagement policyManagement = new PolicyManagement(); - - @Test(groups = "policy.mgt.test", description = "Testing the adding policy to a device") - public void testAddPolicy() throws FeatureManagementException, PolicyManagementException { - Assert.assertEquals(policyManagement.addPolicyToDevice("1212-ESDD-12ER-7890", "MD", policy), 0); - } - - @Test(groups = "policy.mgt.test", description = "Testing the adding policy to a device type") - public void testAddPolicyToDeviceType() throws FeatureManagementException, PolicyManagementException { - Assert.assertEquals(policyManagement.addPolicyToDeviceType("MD", policy), 0); - } - - @Test(groups = "policy.mgt.test", description = "Testing the adding policy to a user Role") - public void testAddPolicyToRole() throws FeatureManagementException, PolicyManagementException { - Assert.assertEquals(policyManagement.addPolicyToRole("Admin", policy), 0); - } - -} diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/test/java/org/wos2/carbon/policy/mgt/common/utils/PolicyCreator.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/test/java/org/wos2/carbon/policy/mgt/common/utils/PolicyCreator.java deleted file mode 100644 index 5141919e01..0000000000 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/test/java/org/wos2/carbon/policy/mgt/common/utils/PolicyCreator.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2015, 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.wos2.carbon.policy.mgt.common.utils; - -import org.wso2.carbon.policy.mgt.common.Feature; -import org.wso2.carbon.policy.mgt.common.Policy; - -import java.util.ArrayList; -import java.util.List; - -public class PolicyCreator { - - private static Policy policy = new Policy(); - - public static Policy createPolicy() { - - Feature feature = new Feature(); - feature.setName("Camera"); - feature.setCode("502A"); - feature.setAttribute("disable"); - - List featureList = new ArrayList(); - featureList.add(feature); - - policy.setFeaturesList(featureList); - policy.setPolicyName("Camera_related_policy"); - - return policy; - } - - -} diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml deleted file mode 100644 index 1918eebf9b..0000000000 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - - org.wso2.carbon - policy-mgt - 2.0.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon - org.wso2.carbon.policy.mgt.core - 2.0.0-SNAPSHOT - bundle - WSO2 Carbon - Policy Management Core - WSO2 Carbon - Policy Management Core - 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} - Policy Management Core Bundle - org.wso2.carbon.policy.mgt.core.internal - - org.apache.axis2.*; - version="${axis2.osgi.version.range}", - org.osgi.framework, - org.osgi.service.component, - org.apache.commons.logging, - - - !org.wso2.carbon.policy.mgt.core.internal, - org.wso2.carbon.policy.mgt.core.* - - * - - - - - - - - - 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.policy.mgt.common - - - - org.wso2.carbon - org.wso2.carbon.utils - - - org.wso2.carbon - org.wso2.carbon.core - - - org.wso2.carbon - org.wso2.carbon.ndatasource.core - - - org.wso2.carbon - org.wso2.carbon.ndatasource.rdbms - - - org.wso2.carbon - org.wso2.carbon.logging - ${carbon.kernel.version} - - - - - diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/PolicyConfigurationManager.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/PolicyConfigurationManager.java deleted file mode 100644 index 1dd6558e1a..0000000000 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/PolicyConfigurationManager.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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.policy.mgt.core.config; - -import org.w3c.dom.Document; -import org.wso2.carbon.policy.mgt.common.PolicyManagementException; -import org.wso2.carbon.policy.mgt.core.config.datasource.DataSourceConfig; -import org.wso2.carbon.policy.mgt.core.util.PolicyManagementConstants; -import org.wso2.carbon.policy.mgt.core.util.PolicyManagerUtil; -import org.wso2.carbon.utils.CarbonUtils; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.Unmarshaller; -import java.io.File; - -/** - * Class responsible for the rss manager configuration initialization - */ -public class PolicyConfigurationManager { - - private PolicyManagementConfig currentPolicyConfig; - private static PolicyConfigurationManager policyConfigurationManager; - - private final String deviceMgtConfigXMLPath = CarbonUtils.getCarbonConfigDirPath() + File.separator + - PolicyManagementConstants.DEVICE_CONFIG_XML_NAME; - - public static PolicyConfigurationManager getInstance() { - if (policyConfigurationManager == null) { - synchronized (PolicyConfigurationManager.class) { - if (policyConfigurationManager == null) { - policyConfigurationManager = new PolicyConfigurationManager(); - } - } - } - return policyConfigurationManager; - } - - public synchronized void initConfig() throws PolicyManagementException { - try { - File deviceMgtConfig = new File(deviceMgtConfigXMLPath); - Document doc = PolicyManagerUtil.convertToDocument(deviceMgtConfig); - - /* Un-marshaling Device Management configuration */ - JAXBContext rssContext = JAXBContext.newInstance(PolicyManagementConfig.class); - Unmarshaller unmarshaller = rssContext.createUnmarshaller(); - this.currentPolicyConfig = (PolicyManagementConfig) unmarshaller.unmarshal(doc); - } catch (Exception e) { - throw new PolicyManagementException("Error occurred while initializing RSS config", e); - } - } - - public PolicyManagementConfig getPolicyManagementConfig() { - return currentPolicyConfig; - } - - public DataSourceConfig getDataSourceConfig() { - return currentPolicyConfig.getPolicyManagementRepository().getDataSourceConfig(); - } - - -} diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/PolicyManagementConfig.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/PolicyManagementConfig.java deleted file mode 100644 index d73f37f0c0..0000000000 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/PolicyManagementConfig.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.policy.mgt.core.config; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * Represents Device Mgt configuration. - */ -@XmlRootElement(name = "DeviceMgtConfiguration") -public final class PolicyManagementConfig { - - public void setPolicyManagementRepository(PolicyManagementRepository policyManagementRepository) { - this.policyManagementRepository = policyManagementRepository; - } - - private PolicyManagementRepository policyManagementRepository; - - @XmlElement(name = "ManagementRepository", nillable = false) - public PolicyManagementRepository getPolicyManagementRepository() { - return policyManagementRepository; - } - -} diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/PolicyManagementRepository.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/PolicyManagementRepository.java deleted file mode 100644 index 9b7b8aa767..0000000000 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/PolicyManagementRepository.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.policy.mgt.core.config; - -import org.wso2.carbon.policy.mgt.core.config.datasource.DataSourceConfig; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * Class for holding management repository data - */ -@XmlRootElement(name = "ManagementRepository") -public class PolicyManagementRepository { - - private DataSourceConfig dataSourceConfig; - - @XmlElement(name = "DataSourceConfiguration", nillable = false) - public DataSourceConfig getDataSourceConfig() { - return dataSourceConfig; - } - - public void setDataSourceConfig(DataSourceConfig dataSourceConfig) { - this.dataSourceConfig = dataSourceConfig; - } - -} diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/datasource/DataSourceConfig.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/datasource/DataSourceConfig.java deleted file mode 100644 index b15fd65c6d..0000000000 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/datasource/DataSourceConfig.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.policy.mgt.core.config.datasource; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * Class for holding data source configuration in rss-config.xml at parsing with JAXB - */ -@XmlRootElement(name = "DataSourceConfiguration") -public class DataSourceConfig { - - private JNDILookupDefinition jndiLookupDefinition; - - @XmlElement(name = "JndiLookupDefinition", nillable = true) - public JNDILookupDefinition getJndiLookupDefinition() { - return jndiLookupDefinition; - } - - public void setJndiLookupDefinition(JNDILookupDefinition jndiLookupDefinition) { - this.jndiLookupDefinition = jndiLookupDefinition; - } -} diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/datasource/JNDILookupDefinition.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/datasource/JNDILookupDefinition.java deleted file mode 100644 index 40fdc5d17b..0000000000 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/config/datasource/JNDILookupDefinition.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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.policy.mgt.core.config.datasource; - -import javax.xml.bind.annotation.*; -import java.util.List; - -/** - * Class for hold JndiLookupDefinition of rss-manager.xml at parsing with JAXB - */ -@XmlRootElement(name = "JndiLookupDefinition") -public class JNDILookupDefinition { - - private String jndiName; - private List jndiProperties; - - @XmlElement(name = "Name", nillable = false) - public String getJndiName() { - return jndiName; - } - - public void setJndiName(String jndiName) { - this.jndiName = jndiName; - } - - @XmlElementWrapper(name = "Environment", nillable = false) - @XmlElement(name = "Property", nillable = false) - public List getJndiProperties() { - return jndiProperties; - } - - public void setJndiProperties(List jndiProperties) { - this.jndiProperties = jndiProperties; - } - - @XmlRootElement(name = "Property") - public static class JNDIProperty { - - private String name; - - private String value; - - @XmlAttribute(name = "Name") - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @XmlValue - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - } - -} - diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyDAO.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyDAO.java deleted file mode 100644 index 09c7c9ee99..0000000000 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyDAO.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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.policy.mgt.core.dao; - -import org.wso2.carbon.policy.mgt.common.Policy; - -public interface PolicyDAO { - - int addPolicy(Policy policy) throws PolicyManagerDAOException; - - int addPolicy(String deviceType, Policy policy) throws PolicyManagerDAOException; - - int addPolicy(String deviceID, String deviceType, Policy policy) throws PolicyManagerDAOException; - - void updatePolicy(int id, Policy policy) throws PolicyManagerDAOException; - - Policy getPolicy() throws PolicyManagerDAOException; - - Policy getPolicy(String deviceType) throws PolicyManagerDAOException; - - Policy getPolicy(String deviceID, String deviceType) throws PolicyManagerDAOException; -} diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyManagementDAOFactory.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyManagementDAOFactory.java deleted file mode 100644 index f91dd4ffeb..0000000000 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyManagementDAOFactory.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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.policy.mgt.core.dao; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.policy.mgt.core.config.datasource.DataSourceConfig; -import org.wso2.carbon.policy.mgt.core.config.datasource.JNDILookupDefinition; -import org.wso2.carbon.policy.mgt.core.dao.impl.PolicyDAOImpl; -import org.wso2.carbon.policy.mgt.core.dao.util.PolicyManagementDAOUtil; - -import javax.sql.DataSource; -import java.util.Hashtable; -import java.util.List; - -public class PolicyManagementDAOFactory { - - private static DataSource dataSource; - private static final Log log = LogFactory.getLog(PolicyManagementDAOFactory.class); - - - public static PolicyDAO getDeviceTypeDAO() { - return new PolicyDAOImpl(dataSource); - } - - public static void init(DataSourceConfig config) { - dataSource = resolveDataSource(config); - } - - /** - * Resolve data source from the data source definition - * - * @param config data source configuration - * @return data source resolved from the data source definition - */ - private static DataSource resolveDataSource(DataSourceConfig config) { - DataSource dataSource = null; - if (config == null) { - throw new RuntimeException("Device Management Repository data source configuration " + - "is null and thus, is not initialized"); - } - JNDILookupDefinition jndiConfig = config.getJndiLookupDefinition(); - if (jndiConfig != null) { - if (log.isDebugEnabled()) { - log.debug("Initializing Device Management Repository data source using the JNDI " + - "Lookup Definition"); - } - List jndiPropertyList = - jndiConfig.getJndiProperties(); - if (jndiPropertyList != null) { - Hashtable jndiProperties = new Hashtable(); - for (JNDILookupDefinition.JNDIProperty prop : jndiPropertyList) { - jndiProperties.put(prop.getName(), prop.getValue()); - } - dataSource = - PolicyManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), jndiProperties); - } else { - dataSource = PolicyManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), null); - } - } - return dataSource; - } - -} diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyManagerDAOException.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyManagerDAOException.java deleted file mode 100644 index 89a85870a7..0000000000 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyManagerDAOException.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.policy.mgt.core.dao; - -public class PolicyManagerDAOException extends Exception{ - - private String policyDAOErrorMessage; - - public String getPolicyDAOErrorMessage() { - return policyDAOErrorMessage; - } - - public void setPolicyDAOErrorMessage(String policyDAOErrorMessage) { - this.policyDAOErrorMessage = policyDAOErrorMessage; - } - - public PolicyManagerDAOException(String message) { - super(message); - setPolicyDAOErrorMessage(message); - } - - public PolicyManagerDAOException(String message, Exception ex) { - super(message, ex); - setPolicyDAOErrorMessage(message); - } - - public PolicyManagerDAOException(String message, Throwable cause) { - super(message, cause); - setPolicyDAOErrorMessage(message); - } - - public PolicyManagerDAOException() { - super(); - } - - public PolicyManagerDAOException(Throwable cause) { - super(cause); - } -} diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java deleted file mode 100644 index 6d94f02e8a..0000000000 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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.policy.mgt.core.dao.impl; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.policy.mgt.common.Policy; -import org.wso2.carbon.policy.mgt.core.dao.PolicyDAO; -import org.wso2.carbon.policy.mgt.core.dao.PolicyManagerDAOException; - -import javax.sql.DataSource; -import java.sql.Connection; -import java.sql.SQLException; - -public class PolicyDAOImpl implements PolicyDAO { - - private static DataSource dataSource; - private static final Log log = LogFactory.getLog(PolicyDAOImpl.class); - - public PolicyDAOImpl(DataSource dataSource) { - this.dataSource = dataSource; - } - - @Override - public int addPolicy(Policy policy) throws PolicyManagerDAOException { - return 0; - } - - @Override - public int addPolicy(String deviceType, Policy policy) throws PolicyManagerDAOException { - return 0; - } - - @Override - public int addPolicy(String deviceID, String deviceType, Policy policy) throws PolicyManagerDAOException { - return 0; - } - - @Override - public void updatePolicy(int id, Policy policy) throws PolicyManagerDAOException { - - } - - @Override - public Policy getPolicy() throws PolicyManagerDAOException { - return null; - } - - @Override - public Policy getPolicy(String deviceType) throws PolicyManagerDAOException { - return null; - } - - @Override - public Policy getPolicy(String deviceID, String deviceType) throws PolicyManagerDAOException { - return null; - } - - private Connection getConnection() throws PolicyManagerDAOException { - try { - return dataSource.getConnection(); - } catch (SQLException e) { - throw new PolicyManagerDAOException("Error occurred while obtaining a connection from the policy " + - "management metadata repository datasource", e); - } - } -} diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/util/PolicyManagementDAOUtil.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/util/PolicyManagementDAOUtil.java deleted file mode 100644 index b8e978491a..0000000000 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/util/PolicyManagementDAOUtil.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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.policy.mgt.core.dao.util; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.naming.InitialContext; -import javax.sql.DataSource; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.Hashtable; - -public class PolicyManagementDAOUtil { - - private static final Log log = LogFactory.getLog(PolicyManagementDAOUtil.class); - - public static DataSource lookupDataSource(String dataSourceName, final Hashtable jndiProperties) { - try { - if (jndiProperties == null || jndiProperties.isEmpty()) { - return (DataSource) InitialContext.doLookup(dataSourceName); - } - final InitialContext context = new InitialContext(jndiProperties); - return (DataSource) context.doLookup(dataSourceName); - } catch (Exception e) { - throw new RuntimeException("Error in looking up data source: " + e.getMessage(), e); - } - } - - public static void cleanupResources(Connection conn, PreparedStatement stmt, ResultSet rs) { - if (rs != null) { - try { - rs.close(); - } catch (SQLException e) { - log.warn("Error occurred while closing result set", e); - } - } - if (stmt != null) { - try { - stmt.close(); - } catch (SQLException e) { - log.warn("Error occurred while closing prepared statement", e); - } - } - if (conn != null) { - try { - conn.close(); - } catch (SQLException e) { - log.warn("Error occurred while closing database connection", e); - } - } - } - -} diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementDataHolder.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementDataHolder.java deleted file mode 100644 index fc0770f5d0..0000000000 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementDataHolder.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.policy.mgt.core.internal; - -import org.wso2.carbon.user.core.service.RealmService; -import org.wso2.carbon.user.core.tenant.TenantManager; - -public class PolicyManagementDataHolder { - - private RealmService realmService; - private TenantManager tenantManager; - private static PolicyManagementDataHolder thisInstance = new PolicyManagementDataHolder(); - - private PolicyManagementDataHolder() {} - - public static PolicyManagementDataHolder getInstance() { - return thisInstance; - } - - public RealmService getRealmService() { - return realmService; - } - - public void setRealmService(RealmService realmService) { - this.realmService = realmService; - this.setTenantManager(realmService); - } - - private void setTenantManager(RealmService realmService) { - if (realmService == null) { - throw new IllegalStateException("Realm service is not initialized properly"); - } - this.tenantManager = realmService.getTenantManager(); - } - - public TenantManager getTenantManager() { - return tenantManager; - } - - -} diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementServiceComponent.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementServiceComponent.java deleted file mode 100644 index 8fadd5e858..0000000000 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementServiceComponent.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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.policy.mgt.core.internal; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.osgi.service.component.ComponentContext; -import org.wso2.carbon.policy.mgt.core.config.PolicyConfigurationManager; -import org.wso2.carbon.policy.mgt.core.config.PolicyManagementConfig; -import org.wso2.carbon.policy.mgt.core.config.datasource.DataSourceConfig; -import org.wso2.carbon.policy.mgt.core.dao.PolicyManagementDAOFactory; -import org.wso2.carbon.user.core.service.RealmService; - -/** - * @scr.component name="org.wso2.carbon.policy.manager" immediate="true" - * @scr.reference name="user.realmservice.default" - * interface="org.wso2.carbon.user.core.service.RealmService" - * cardinality="1..1" - * policy="dynamic" - * bind="setRealmService" - * unbind="unsetRealmService" - */ - -public class PolicyManagementServiceComponent { - - private static Log log = LogFactory.getLog(PolicyManagementServiceComponent.class); - - protected void activate(ComponentContext componentContext) { - - try { - PolicyConfigurationManager.getInstance().initConfig(); - PolicyManagementConfig config = PolicyConfigurationManager.getInstance().getPolicyManagementConfig(); - DataSourceConfig dsConfig = config.getPolicyManagementRepository().getDataSourceConfig(); - PolicyManagementDAOFactory.init(dsConfig); - - } catch (Throwable t) { - String msg = "Error occurred while initializing the Policy management core."; - log.error(msg, t); - } - } - - - /** - * Sets Realm Service - * - * @param realmService An instance of RealmService - */ - protected void setRealmService(RealmService realmService) { - - if (log.isDebugEnabled()) { - log.debug("Setting Realm Service"); - } - PolicyManagementDataHolder.getInstance().setRealmService(realmService); - } - - /** - * Unsets Realm Service - * - * @param realmService An instance of RealmService - */ - protected void unsetRealmService(RealmService realmService) { - if (log.isDebugEnabled()) { - log.debug("Unsetting Realm Service"); - } - PolicyManagementDataHolder.getInstance().setRealmService(null); - } - -} diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagementConstants.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagementConstants.java deleted file mode 100644 index 4c387fc4b9..0000000000 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagementConstants.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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.policy.mgt.core.util; - -public final class PolicyManagementConstants { - public static final String DEVICE_CONFIG_XML_NAME = "cdm-config.xml"; -} diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagerUtil.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagerUtil.java deleted file mode 100644 index 558e53c929..0000000000 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagerUtil.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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.policy.mgt.core.util; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.w3c.dom.Document; -import org.wso2.carbon.policy.mgt.common.PolicyManagementException; -import org.wso2.carbon.policy.mgt.core.config.datasource.DataSourceConfig; -import org.wso2.carbon.policy.mgt.core.config.datasource.JNDILookupDefinition; -import org.wso2.carbon.policy.mgt.core.dao.util.PolicyManagementDAOUtil; - -import javax.sql.DataSource; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import java.io.File; -import java.util.Hashtable; -import java.util.List; - -public class PolicyManagerUtil { - - private static final Log log = LogFactory.getLog(PolicyManagerUtil.class); - - public static Document convertToDocument(File file) throws PolicyManagementException { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - factory.setNamespaceAware(true); - try { - DocumentBuilder docBuilder = factory.newDocumentBuilder(); - return docBuilder.parse(file); - } catch (Exception e) { - throw new PolicyManagementException("Error occurred while parsing file, while converting " + - "to a org.w3c.dom.Document : " + e.getMessage(), e); - } - } - - /** - * Resolve data source from the data source definition - * - * @param config data source configuration - * @return data source resolved from the data source definition - */ - public static DataSource resolveDataSource(DataSourceConfig config) { - DataSource dataSource = null; - if (config == null) { - throw new RuntimeException("Device Management Repository data source configuration " + - "is null and thus, is not initialized"); - } - JNDILookupDefinition jndiConfig = config.getJndiLookupDefinition(); - if (jndiConfig != null) { - if (log.isDebugEnabled()) { - log.debug("Initializing Device Management Repository data source using the JNDI " + - "Lookup Definition"); - } - List jndiPropertyList = - jndiConfig.getJndiProperties(); - if (jndiPropertyList != null) { - Hashtable jndiProperties = new Hashtable(); - for (JNDILookupDefinition.JNDIProperty prop : jndiPropertyList) { - jndiProperties.put(prop.getName(), prop.getValue()); - } - dataSource = - PolicyManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), jndiProperties); - } else { - dataSource = PolicyManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), null); - } - } - return dataSource; - } -} diff --git a/components/policy-mgt/pom.xml b/components/policy-mgt/pom.xml deleted file mode 100644 index 05e9bd4613..0000000000 --- a/components/policy-mgt/pom.xml +++ /dev/null @@ -1,84 +0,0 @@ - - - - - - - - org.wso2.carbon - wso2cdm-parent - 2.0.0-SNAPSHOT - ../../pom.xml - - - 4.0.0 - org.wso2.carbon - policy-mgt - 2.0.0-SNAPSHOT - pom - WSO2 Carbon - Policy Management Component - http://wso2.org - - - org.wso2.carbon.policy.mgt.core - org.wso2.carbon.policy.mgt.common - org.wso2.carbon.policy.evalutor - - - - - - - - - org.apache.felix - maven-scr-plugin - 1.7.2 - - - generate-scr-scrdescriptor - - scr - - - - - - - - - diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/pom.xml index 2da85a8dbb..5dd10889c7 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/pom.xml @@ -98,8 +98,6 @@ org.wso2.carbon:org.wso2.carbon.device.mgt.mobile.impl:${project.version} - org.wso2.carbon:org.wso2.carbon.device.mgt.common:${project.version} - org.wso2.carbon.core.server:${carbon.kernel.version} diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml deleted file mode 100644 index ba36238a26..0000000000 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - org.wso2.carbon - device-mgt-feature - 2.0.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.device.mgt.server.feature - pom - 2.0.0-SNAPSHOT - WSO2 Carbon - Device Management Server Feature - http://wso2.org - This feature contains the core bundles required for Back-end Devvice Management functionality - - - - - 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.core - - - org.wso2.carbon - org.wso2.carbon.device.mgt.common - - - - - - - maven-resources-plugin - 2.6 - - - copy-resources - generate-resources - - copy-resources - - - src/main/resources - - - resources - - build.properties - p2.inf - - - - - - - - - org.wso2.maven - carbon-p2-plugin - ${carbon.p2.plugin.version} - - - p2-feature-generation - package - - p2-feature-gen - - - org.wso2.carbon.device.mgt.server - ../../../features/etc/feature.properties - - - org.wso2.carbon.p2.category.type:server - org.eclipse.equinox.p2.type.group:false - - - - org.wso2.carbon:org.wso2.carbon.device.mgt.core:${project.version} - - org.wso2.carbon:org.wso2.carbon.device.mgt.common:${project.version} - - - - org.wso2.carbon.core.server:${carbon.kernel.version} - - - - - - - - - diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/build.properties b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/build.properties deleted file mode 100644 index 9c86577d76..0000000000 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/build.properties +++ /dev/null @@ -1 +0,0 @@ -custom = true diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/cdm-config.xml b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/cdm-config.xml deleted file mode 100644 index 49d19d69fd..0000000000 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/cdm-config.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - jdbc/DM_DS - - - - - diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/h2.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/h2.sql deleted file mode 100644 index 783acaa8de..0000000000 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/h2.sql +++ /dev/null @@ -1,26 +0,0 @@ -CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE -( - ID INT(11) auto_increment NOT NULL, - NAME VARCHAR(300) NULL DEFAULT NULL, - PRIMARY KEY (ID) -); - -CREATE TABLE IF NOT EXISTS DM_DEVICE -( - ID INT auto_increment NOT NULL, - DESCRIPTION TEXT NULL DEFAULT NULL, - NAME VARCHAR(100) NULL DEFAULT NULL, - DATE_OF_ENROLLMENT BIGINT NULL DEFAULT NULL, - DATE_OF_LAST_UPDATE BIGINT NULL DEFAULT NULL, - OWNERSHIP VARCHAR(45) NULL DEFAULT NULL, - STATUS VARCHAR(15) NULL DEFAULT NULL, - DEVICE_TYPE_ID INT(11) NULL DEFAULT NULL, - DEVICE_IDENTIFICATION VARCHAR(300) NULL DEFAULT NULL, - OWNER VARCHAR(45) NULL DEFAULT NULL, - TENANT_ID INTEGER DEFAULT 0, - PRIMARY KEY (ID), - CONSTRAINT fk_DM_DEVICE_DM_DEVICE_TYPE2 FOREIGN KEY (DEVICE_TYPE_ID ) - REFERENCES DM_DEVICE_TYPE (ID ) ON DELETE NO ACTION ON UPDATE NO ACTION -); --- TO:DO - Remove this INSERT sql statement. -Insert into DM_DEVICE_TYPE (ID,NAME) VALUES (1, 'android'); diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mysql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mysql.sql deleted file mode 100644 index bc04de8732..0000000000 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mysql.sql +++ /dev/null @@ -1,35 +0,0 @@ --- ----------------------------------------------------- --- Table `DM_DEVICE_TYPE` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `DM_DEVICE_TYPE` ( - `ID` INT(11) NOT NULL , - `NAME` VARCHAR(300) NULL DEFAULT NULL , - PRIMARY KEY (`ID`) ) -ENGINE = InnoDB -DEFAULT CHARACTER SET = latin1; - - --- ----------------------------------------------------- --- Table `DM_DEVICE` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `DM_DEVICE` ( - `ID` VARCHAR(20) NOT NULL , - `DESCRIPTION` TEXT NULL DEFAULT NULL , - `NAME` VARCHAR(100) NULL DEFAULT NULL , - `DATE_OF_ENROLLMENT` DATETIME NULL DEFAULT NULL , - `DATE_OF_LAST_UPDATE` DATETIME NULL DEFAULT NULL , - `OWNERSHIP` VARCHAR(45) NULL DEFAULT NULL , - `STATUS` VARCHAR(15) NULL DEFAULT NULL , - `DEVICE_TYPE_ID` INT(11) NULL DEFAULT NULL , - `DEVICE_IDENTIFICATION` VARCHAR(300) NULL DEFAULT NULL , - `OWNER` VARCHAR(45) NULL DEFAULT NULL , - TENANT_ID INTEGER DEFAULT 0, - PRIMARY KEY (`ID`) , - INDEX `fk_DM_DEVICE_DM_DEVICE_TYPE2_idx` (`DEVICE_TYPE_ID` ASC) , - CONSTRAINT `fk_DM_DEVICE_DM_DEVICE_TYPE2` - FOREIGN KEY (`DEVICE_TYPE_ID` ) - REFERENCES `DM_DEVICE_TYPE` (`ID` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION) -ENGINE = InnoDB -DEFAULT CHARACTER SET = latin1; diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/p2.inf b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/p2.inf deleted file mode 100644 index eabcf094d8..0000000000 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/p2.inf +++ /dev/null @@ -1,3 +0,0 @@ -instructions.configure = \ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${feature.version}/conf/cdm-config.xml,target:${installFolder}/../../conf/cdm-config.xml,overwrite:true);\ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${feature.version}/dbscripts/cdm,target:${installFolder}/../../../dbscripts/cdm,overwrite:true);\ diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml index f456019e67..b120629c32 100644 --- a/features/device-mgt/pom.xml +++ b/features/device-mgt/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon - wso2cdm-parent + wso2mdm-parent 2.0.0-SNAPSHOT ../../pom.xml @@ -37,7 +37,6 @@ http://wso2.org - org.wso2.carbon.device.mgt.server.feature org.wso2.carbon.device.mgt.mobile.feature diff --git a/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml b/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml deleted file mode 100644 index 91b074c7ef..0000000000 --- a/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml +++ /dev/null @@ -1,125 +0,0 @@ - - - - - - - - org.wso2.carbon - policy-mgt-feature - 2.0.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.policy.mgt.server.feature - pom - 2.0.0-SNAPSHOT - WSO2 Carbon - Policy Management Server Feature - http://wso2.org - This feature contains the core bundles required for Back-end Devvice Management functionality - - - - - 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.policy.mgt.core - - - org.wso2.carbon - org.wso2.carbon.policy.mgt.common - - - - - - - maven-resources-plugin - 2.6 - - - copy-resources - generate-resources - - copy-resources - - - src/main/resources - - - resources - - build.properties - p2.inf - - - - - - - - - org.wso2.maven - carbon-p2-plugin - ${carbon.p2.plugin.version} - - - p2-feature-generation - package - - p2-feature-gen - - - org.wso2.carbon.policy.mgt.server - ../../../features/etc/feature.properties - - - org.wso2.carbon.p2.category.type:server - org.eclipse.equinox.p2.type.group:false - - - - org.wso2.carbon:org.wso2.carbon.policy.mgt.core:${project.version} - - org.wso2.carbon:org.wso2.carbon.policy.mgt.common:${project.version} - - - - org.wso2.carbon.core.server:${carbon.kernel.version} - - - - - - - - - diff --git a/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/src/main/resources/build.properties b/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/src/main/resources/build.properties deleted file mode 100644 index 9c86577d76..0000000000 --- a/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/src/main/resources/build.properties +++ /dev/null @@ -1 +0,0 @@ -custom = true diff --git a/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/src/main/resources/p2.inf b/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/src/main/resources/p2.inf deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/features/policy-mgt/pom.xml b/features/policy-mgt/pom.xml deleted file mode 100644 index b500e800d2..0000000000 --- a/features/policy-mgt/pom.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - org.wso2.carbon - wso2cdm-parent - 2.0.0-SNAPSHOT - ../../pom.xml - - - 4.0.0 - org.wso2.carbon - policy-mgt-feature - 2.0.0-SNAPSHOT - pom - WSO2 Carbon - Policy Management Feature - http://wso2.org - - - org.wso2.carbon.policy.mgt.server.feature - - - diff --git a/pom.xml b/pom.xml index 2f703b17a4..a583f57d6b 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ 4.0.0 org.wso2.carbon - wso2cdm-parent + wso2mdm-parent pom 2.0.0-SNAPSHOT WSO2 CDM - Parent @@ -38,9 +38,7 @@ components/device-mgt - components/policy-mgt features/device-mgt - features/policy-mgt product diff --git a/product/modules/p2-profile-gen/pom.xml b/product/modules/p2-profile-gen/pom.xml index 46bb0c0f39..ce4f57f58c 100644 --- a/product/modules/p2-profile-gen/pom.xml +++ b/product/modules/p2-profile-gen/pom.xml @@ -467,7 +467,4 @@ - - 1.2.1 - diff --git a/product/pom.xml b/product/pom.xml index c449865097..479f83daeb 100644 --- a/product/pom.xml +++ b/product/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon - wso2cdm-parent + wso2mdm-parent 2.0.0-SNAPSHOT ../pom.xml