From 8662eb36e44c17bf91756052a4f6c804a91c8b2a Mon Sep 17 00:00:00 2001 From: prabathabey Date: Tue, 17 Mar 2015 17:27:41 +0530 Subject: [PATCH] Adding operation manager related changes --- ...ManagerService.java => DeviceManager.java} | 13 +--- .../mgt/core/DeviceManagementService.java | 62 +++++++++++++++++ ... DeviceManagementServiceProviderImpl.java} | 66 ++++++++++++------ .../carbon/device/mgt/core/DeviceManager.java | 58 ---------------- .../mgt/GenericArtifactManagerFactory.java | 22 ++++++ .../core/operation/mgt/CommandOperation.java | 27 ++++++++ .../core/operation/mgt/ConfigOperation.java | 22 ++++++ .../mgt/core/operation/mgt}/Operation.java | 2 +- .../mgt}/OperationExecutionException.java | 2 +- .../mgt}/OperationManagementException.java | 2 +- .../core/operation/mgt}/OperationManager.java | 8 ++- .../operation/mgt/OperationManagerImpl.java | 69 +++++++++++++++++++ .../core/operation/mgt/SimpleOperation.java | 22 ++++++ .../core/operation/mgt/dao/OperationDAO.java | 22 ++++++ .../dao/OperationManagementDAOException.java | 23 +++++++ .../dao/OperationManagementDAOFactory.java | 22 ++++++ .../mgt/dao/OperationManagementDAOUtil.java | 22 ++++++ .../mgt/dao/OperationMappingDAO.java | 22 ++++++ .../mgt/dao/impl/AbstractOperationDAO.java | 22 ++++++ .../mgt/dao/impl/CommandOperationDAOImpl.java | 61 ++++++++++++++++ .../mgt/dao/impl/ConfigOperationDAOImpl.java | 22 ++++++ .../mgt/dao/impl/OperationMappingDAOImpl.java | 22 ++++++ .../mgt/dao/impl/SimpleOperationDAOImpl.java | 22 ++++++ ....java => DeviceManagementServiceImpl.java} | 27 +++----- .../mgt/core/DeviceManagementBaseTest.java | 22 ++++++ .../core/DeviceOperationManagementTests.java | 22 ++++++ ...gerService.java => TestDeviceManager.java} | 12 +--- .../src/test/resources/sql/h2.sql | 0 28 files changed, 595 insertions(+), 123 deletions(-) rename components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/{DeviceManagerService.java => DeviceManager.java} (92%) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementService.java rename components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/{DeviceManagerImpl.java => DeviceManagementServiceProviderImpl.java} (75%) delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManager.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/license/mgt/GenericArtifactManagerFactory.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/CommandOperation.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/ConfigOperation.java rename components/device-mgt/{org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common => org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt}/Operation.java (96%) rename components/device-mgt/{org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common => org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt}/OperationExecutionException.java (96%) rename components/device-mgt/{org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common => org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt}/OperationManagementException.java (96%) rename components/device-mgt/{org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common => org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt}/OperationManager.java (87%) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/SimpleOperation.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationDAO.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationManagementDAOException.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationManagementDAOFactory.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationManagementDAOUtil.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationMappingDAO.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/AbstractOperationDAO.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/CommandOperationDAOImpl.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/ConfigOperationDAOImpl.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/OperationMappingDAOImpl.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/SimpleOperationDAOImpl.java rename components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/{DeviceManagementService.java => DeviceManagementServiceImpl.java} (83%) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementBaseTest.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceOperationManagementTests.java rename components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/{TestDeviceManagerService.java => TestDeviceManager.java} (86%) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/sql/h2.sql 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/DeviceManager.java similarity index 92% rename from components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManagerService.java rename to components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManager.java index 2002520ca1..808c39347c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManagerService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManager.java @@ -21,7 +21,6 @@ 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; @@ -29,10 +28,10 @@ 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 { +public interface DeviceManager { /** - * Method to retrieve the provider type that implements DeviceManagerService interface. + * Method to retrieve the provider type that implements DeviceManager interface. * * @return Returns provider type */ @@ -129,12 +128,4 @@ public interface DeviceManagerService { */ 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/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementService.java new file mode 100644 index 0000000000..bef3adf5d5 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementService.java @@ -0,0 +1,62 @@ +/* + * 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.core.config.license.License; +import org.wso2.carbon.device.mgt.core.license.mgt.LicenseManager; +import org.wso2.carbon.device.mgt.core.operation.mgt.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 DeviceManagementService { + + boolean enrollDevice(Device device) throws DeviceManagementException; + + boolean modifyEnrollment(Device device) throws DeviceManagementException; + + boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException; + + boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException; + + boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException; + + boolean setActive(DeviceIdentifier deviceId, boolean status) throws DeviceManagementException; + + List getAllDevices(String type) throws DeviceManagementException; + + Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException; + + boolean updateDeviceInfo(Device device) throws DeviceManagementException; + + boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) throws DeviceManagementException; + + OperationManager getOperationManager(String type) throws DeviceManagementException; + + License getLicense(String type) throws DeviceManagementException; + + boolean addLicense(String type, License license) 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/DeviceManagementServiceProviderImpl.java similarity index 75% rename from components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagerImpl.java rename to components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementServiceProviderImpl.java index 64ebbf0e46..0c21ccd7e4 100644 --- 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/DeviceManagementServiceProviderImpl.java @@ -22,7 +22,11 @@ import org.apache.commons.logging.LogFactory; 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.config.license.License; +import org.wso2.carbon.device.mgt.core.license.mgt.LicenseManagementException; +import org.wso2.carbon.device.mgt.core.license.mgt.LicenseManager; +import org.wso2.carbon.device.mgt.core.license.mgt.LicenseManagerImpl; +import org.wso2.carbon.device.mgt.core.operation.mgt.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; @@ -32,24 +36,26 @@ 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 org.wso2.carbon.device.mgt.core.dto.Status; +import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerImpl; import java.util.ArrayList; import java.util.List; +import java.util.Locale; -public class DeviceManagerImpl implements DeviceManager { +public class DeviceManagementServiceProviderImpl implements DeviceManager { - private static Log log = LogFactory.getLog(DeviceManagerImpl.class); private DeviceDAO deviceDAO; private DeviceTypeDAO deviceTypeDAO; - private DeviceManagementConfig config; private DeviceManagementRepository pluginRepository; + private OperationManager operationManager; + private LicenseManager licenseManager; - public DeviceManagerImpl(DeviceManagementConfig config, - DeviceManagementRepository pluginRepository) { - this.config = config; + public DeviceManagementServiceProviderImpl(DeviceManagementRepository pluginRepository) { this.pluginRepository = pluginRepository; this.deviceDAO = DeviceManagementDAOFactory.getDeviceDAO(); this.deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO(); + this.operationManager = new OperationManagerImpl(); + this.licenseManager = new LicenseManagerImpl(); } @Override @@ -66,9 +72,8 @@ public class DeviceManagerImpl implements DeviceManager { deviceDto.setDeviceTypeId(deviceTypeId); this.getDeviceDAO().addDevice(deviceDto); } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException( - "Error occurred while enrolling the device '" + device.getId() + "'", - e); + throw new DeviceManagementException("Error occurred while enrolling the device '" + device.getId() + + "'", e); } return status; } @@ -81,9 +86,8 @@ public class DeviceManagerImpl implements DeviceManager { try { this.getDeviceDAO().updateDevice(DeviceManagementDAOUtil.convertDevice(device)); } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException( - "Error occurred while modifying the device '" + device.getId() + "'", - e); + throw new DeviceManagementException("Error occurred while modifying the device '" + device.getId() + + "'", e); } return status; } @@ -139,8 +143,8 @@ public class DeviceManagerImpl implements DeviceManager { devicesList.add(convertedDevice); } } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException( - "Error occurred while obtaining the device for type '" + type + "'", e); + throw new DeviceManagementException("Error occurred while obtaining the device for type '" + type + + "'", e); } return devicesList; } @@ -165,9 +169,8 @@ public class DeviceManagerImpl implements DeviceManager { } } } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException( - "Error occurred while obtaining the device for id '" + deviceId.getId() + "'", - e); + throw new DeviceManagementException("Error occurred while obtaining the device for id '" + + deviceId.getId() + "'", e); } return convertedDevice; } @@ -188,11 +191,31 @@ public class DeviceManagerImpl implements DeviceManager { } public OperationManager getOperationManager(String type) throws DeviceManagementException { - DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(type); - return dms.getOperationManager(); + return operationManager; } - public DeviceDAO getDeviceDAO() { + @Override + public License getLicense(String type) throws DeviceManagementException { + try { + return licenseManager.getLicense(type, Locale.ENGLISH.getLanguage()); + } catch (LicenseManagementException e) { + throw new DeviceManagementException("Error occurred while retrieving license configured for " + + "device type '" + type + "'", e); + } + } + + @Override + public boolean addLicense(String type, License license) throws DeviceManagementException { + try { + return licenseManager.addLicense(type, license); + } catch (LicenseManagementException e) { + throw new DeviceManagementException("Error occurred while adding license for device type '" + + type + "'", e); + + } + } + + public DeviceDAO getDeviceDAO() { return deviceDAO; } @@ -203,4 +226,5 @@ public class DeviceManagerImpl implements DeviceManager { 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/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 1f2c4df376..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,58 +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/license/mgt/GenericArtifactManagerFactory.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/license/mgt/GenericArtifactManagerFactory.java new file mode 100644 index 0000000000..8d07b6343c --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/license/mgt/GenericArtifactManagerFactory.java @@ -0,0 +1,22 @@ +/* + * 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.device.mgt.core.license.mgt; + +public class GenericArtifactManagerFactory { +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/CommandOperation.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/CommandOperation.java new file mode 100644 index 0000000000..37e65a8352 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/CommandOperation.java @@ -0,0 +1,27 @@ +/* + * 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.device.mgt.core.operation.mgt; + +import org.wso2.carbon.device.mgt.common.Operation; + +public class CommandOperation extends Operation { + + + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/ConfigOperation.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/ConfigOperation.java new file mode 100644 index 0000000000..ec94611279 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/ConfigOperation.java @@ -0,0 +1,22 @@ +/* + * 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.device.mgt.core.operation.mgt; + +public class ConfigOperation { +} 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.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/Operation.java similarity index 96% rename from components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Operation.java rename to components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/Operation.java index 82f18f7068..a424180260 100644 --- 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.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/Operation.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.common; +package org.wso2.carbon.device.mgt.core.operation.mgt; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; 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.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationExecutionException.java similarity index 96% rename from components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/OperationExecutionException.java rename to components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationExecutionException.java index 1df7c95de4..94e870a440 100644 --- 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.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationExecutionException.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.common; +package org.wso2.carbon.device.mgt.core.operation.mgt; public class OperationExecutionException extends Exception { 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.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagementException.java similarity index 96% rename from components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/OperationManagementException.java rename to components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagementException.java index ceace67fd3..cdf8f79c93 100644 --- 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.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagementException.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.common; +package org.wso2.carbon.device.mgt.core.operation.mgt; public class OperationManagementException extends Exception { 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.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManager.java similarity index 87% rename from components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/OperationManager.java rename to components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManager.java index b3a5b2a347..98b521c988 100644 --- 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.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManager.java @@ -15,7 +15,9 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.common; +package org.wso2.carbon.device.mgt.core.operation.mgt; + +import org.wso2.carbon.device.mgt.common.*; import java.util.List; @@ -30,7 +32,7 @@ public interface OperationManager { * * @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 + * @throws org.wso2.carbon.device.mgt.common.OperationManagementException If some unusual behaviour is observed while adding the * operation */ public boolean addOperation(Operation operation, List devices) @@ -60,7 +62,7 @@ public interface OperationManager { * TODO: Move this into a separate FeatureManager * @param deviceType - Device type * @return a list of Feature objects. - * @throws FeatureManagementException + * @throws org.wso2.carbon.device.mgt.common.FeatureManagementException */ public List getFeaturesForDeviceType(String deviceType) throws FeatureManagementException; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java new file mode 100644 index 0000000000..9d9923e0eb --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java @@ -0,0 +1,69 @@ +/* + * 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.device.mgt.core.operation.mgt; + +import org.wso2.carbon.device.mgt.common.*; +import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationDAO; +import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOException; +import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory; + +import java.util.List; + +public class OperationManagerImpl implements OperationManager { + + private OperationDAO commandOperationDAO = OperationManagementDAOFactory.getCommandOperationDAO(); + private OperationDAO configOperationDAO = OperationManagementDAOFactory.getConfigOperationDAO(); + private OperationDAO simpleOperationDAO = OperationManagementDAOFactory.getSimpleOperationDAO(); + + @Override + public boolean addOperation(Operation operation, + List devices) throws OperationManagementException { + try { + return this.lookupOperationDAO(operation).addOperation(operation); + } catch (OperationManagementDAOException e) { + throw new OperationManagementException("Error occurred while adding operation", e); + } + } + + @Override + public List getOperations(DeviceIdentifier deviceId) throws OperationManagementException { + return null; + } + + @Override + public List getPendingOperations(DeviceIdentifier deviceId) throws OperationManagementException { + return null; + } + + @Override + public List getFeaturesForDeviceType(String deviceType) throws FeatureManagementException { + return null; + } + + private OperationDAO lookupOperationDAO(Operation operation) { + if (operation instanceof CommandOperation) { + return commandOperationDAO; + } else if (operation instanceof ConfigOperation) { + return configOperationDAO; + } else { + return simpleOperationDAO; + } + } + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/SimpleOperation.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/SimpleOperation.java new file mode 100644 index 0000000000..2b967cd2a1 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/SimpleOperation.java @@ -0,0 +1,22 @@ +/* + * 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.device.mgt.core.operation.mgt; + +public class SimpleOperation { +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationDAO.java new file mode 100644 index 0000000000..0833f05981 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationDAO.java @@ -0,0 +1,22 @@ +/* + * 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.device.mgt.core.operation.mgt.dao; + +public class OperationDAO { +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationManagementDAOException.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationManagementDAOException.java new file mode 100644 index 0000000000..918259ebb1 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationManagementDAOException.java @@ -0,0 +1,23 @@ +/* + * 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.device.mgt.core.operation.mgt.dao; + +public class OperationManagementDAOException extends Exception { + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationManagementDAOFactory.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationManagementDAOFactory.java new file mode 100644 index 0000000000..b3d52caf3d --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationManagementDAOFactory.java @@ -0,0 +1,22 @@ +/* + * 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.device.mgt.core.operation.mgt.dao; + +public class OperationManagementDAOFactory { +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationManagementDAOUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationManagementDAOUtil.java new file mode 100644 index 0000000000..266c664d18 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationManagementDAOUtil.java @@ -0,0 +1,22 @@ +/* + * 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.device.mgt.core.operation.mgt.dao; + +public class OperationManagementDAOUtil { +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationMappingDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationMappingDAO.java new file mode 100644 index 0000000000..f4405a5813 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationMappingDAO.java @@ -0,0 +1,22 @@ +/* + * 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.device.mgt.core.operation.mgt.dao; + +public class OperationMappingDAO { +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/AbstractOperationDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/AbstractOperationDAO.java new file mode 100644 index 0000000000..c89087fbef --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/AbstractOperationDAO.java @@ -0,0 +1,22 @@ +/* + * 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.device.mgt.core.operation.mgt.dao.impl; + +public class AbstractOperationDAO { +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/CommandOperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/CommandOperationDAOImpl.java new file mode 100644 index 0000000000..bfb95d7034 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/CommandOperationDAOImpl.java @@ -0,0 +1,61 @@ +/* + * 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.device.mgt.core.operation.mgt.dao.impl; + +import org.wso2.carbon.device.mgt.common.Operation; +import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation; +import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOException; + +import javax.sql.DataSource; +import java.util.List; + +public class CommandOperationDAOImpl extends AbstractOperationDAO { + + public CommandOperationDAOImpl(DataSource dataSource) { + super(dataSource); + } + + @Override + public boolean addOperation(Operation operation) throws OperationManagementDAOException { + CommandOperation booleanOp = (CommandOperation) operation; + addOperationMetadata(); + return false; + } + + @Override + public boolean updateOperation(Operation operation) throws OperationManagementDAOException { + return false; + } + + @Override + public boolean deleteOperation(int id) throws OperationManagementDAOException { + return false; + } + + @Override + public Operation getOperation(int id) throws OperationManagementDAOException { + return null; + } + + @Override + public List getOperations() throws OperationManagementDAOException { + return null; + } + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/ConfigOperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/ConfigOperationDAOImpl.java new file mode 100644 index 0000000000..9a3a351138 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/ConfigOperationDAOImpl.java @@ -0,0 +1,22 @@ +/* + * 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.device.mgt.core.operation.mgt.dao.impl; + +public class ConfigOperationDAOImpl { +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/OperationMappingDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/OperationMappingDAOImpl.java new file mode 100644 index 0000000000..c98367ca00 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/OperationMappingDAOImpl.java @@ -0,0 +1,22 @@ +/* + * 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.device.mgt.core.operation.mgt.dao.impl; + +public class OperationMappingDAOImpl { +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/SimpleOperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/SimpleOperationDAOImpl.java new file mode 100644 index 0000000000..107d08953d --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/SimpleOperationDAOImpl.java @@ -0,0 +1,22 @@ +/* + * 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.device.mgt.core.operation.mgt.dao.impl; + +public class SimpleOperationDAOImpl { +} 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/DeviceManagementServiceImpl.java similarity index 83% rename from components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementService.java rename to components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementServiceImpl.java index cb908edd7e..9b742f7054 100644 --- 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/DeviceManagementServiceImpl.java @@ -20,13 +20,13 @@ 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.operation.mgt.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 { +public class DeviceManagementServiceImpl implements DeviceManager { @Override public boolean enrollDevice(Device device) throws DeviceManagementException { @@ -40,8 +40,7 @@ public class DeviceManagementService implements DeviceManager { @Override public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManager() - .disenrollDevice(deviceId); + return DeviceManagementDataHolder.getInstance().getDeviceManager().disenrollDevice(deviceId); } @Override @@ -55,10 +54,8 @@ public class DeviceManagementService implements DeviceManager { } @Override - public boolean setActive(DeviceIdentifier deviceId, boolean status) - throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManager() - .setActive(deviceId, status); + public boolean setActive(DeviceIdentifier deviceId, boolean status) throws DeviceManagementException { + return DeviceManagementDataHolder.getInstance().getDeviceManager().setActive(deviceId, status); } @Override @@ -69,10 +66,7 @@ public class DeviceManagementService implements DeviceManager { @Override public org.wso2.carbon.device.mgt.common.Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException { - - Device device = - DeviceManagementDataHolder.getInstance().getDeviceManager().getDevice(deviceId); - return device; + return DeviceManagementDataHolder.getInstance().getDeviceManager().getDevice(deviceId); } @Override @@ -81,16 +75,13 @@ public class DeviceManagementService implements DeviceManager { } @Override - public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) - throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManager() - .setOwnership(deviceId, ownershipType); + 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); + return DeviceManagementDataHolder.getInstance().getDeviceManager().getOperationManager(type); } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementBaseTest.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementBaseTest.java new file mode 100644 index 0000000000..d2a329f503 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementBaseTest.java @@ -0,0 +1,22 @@ +/* + * 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.device.mgt.core; + +public class DeviceManagementBaseTest { +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceOperationManagementTests.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceOperationManagementTests.java new file mode 100644 index 0000000000..8fa8d1dca9 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceOperationManagementTests.java @@ -0,0 +1,22 @@ +/* + * 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.device.mgt.core; + +public class DeviceOperationManagementTests { +} 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/TestDeviceManager.java similarity index 86% rename from components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManagerService.java rename to components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManager.java index 0870b10307..9e93d33c32 100644 --- 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/TestDeviceManager.java @@ -20,18 +20,17 @@ 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.common.spi.DeviceManager; import java.util.List; -public class TestDeviceManagerService implements DeviceManagerService { +public class TestDeviceManager implements DeviceManager { public static final String DEVICE_TYPE_TEST = "Test"; @Override public String getProviderType() { - return TestDeviceManagerService.DEVICE_TYPE_TEST; + return TestDeviceManager.DEVICE_TYPE_TEST; } @Override @@ -84,9 +83,4 @@ public class TestDeviceManagerService implements DeviceManagerService { return false; } - @Override - public OperationManager getOperationManager() throws DeviceManagementException { - return null; - } - } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/sql/h2.sql b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/sql/h2.sql new file mode 100644 index 0000000000..e69de29bb2