From c13975191e84441c6800da28eccafda872ab81a1 Mon Sep 17 00:00:00 2001 From: prabathabey Date: Sat, 13 Jun 2015 00:44:21 +0530 Subject: [PATCH] Code cleanup --- .../carbon/device/mgt/common/Credential.java | 44 ---- .../mgt/common/{spi => }/DeviceManager.java | 2 +- .../common/app/mgt/AppManagerConnector.java | 77 ------ .../mgt/common/{ => app/mgt}/Application.java | 2 +- ...va => ApplicationManagementException.java} | 12 +- .../common/app/mgt/ApplicationManager.java | 71 ++++++ .../device/mgt/common/spi/AppManager.java | 33 --- .../common/spi/DeviceManagementService.java | 30 +++ .../mgt/common/spi/DeviceMgtService.java | 24 -- .../mgt/core/DeviceManagementRepository.java | 14 +- ... => ApplicationManagementServiceImpl.java} | 28 +-- ...ry.java => ApplicationManagerFactory.java} | 8 +- ...tor.java => RemoteApplicationManager.java} | 44 ++-- .../AppManagementConfigurationManager.java | 6 +- .../app/mgt/oauth/ServiceAuthenticator.java | 4 +- .../internal/DeviceManagementDataHolder.java | 40 ++-- .../DeviceManagementServiceComponent.java | 52 ++-- .../core/license/mgt/LicenseManagerImpl.java | 4 +- .../OperationManagementServiceProvider.java | 22 ++ .../operation/mgt/OperationManagerImpl.java | 113 +++++---- ...a => DeviceManagementProviderService.java} | 14 +- .../DeviceManagementProviderServiceImpl.java} | 70 ++---- .../service/DeviceManagementServiceImpl.java | 224 ------------------ .../core/DeviceManagementRepositoryTests.java | 8 +- .../core/DeviceOperationManagementTests.java | 3 +- .../device/mgt/core/TestDeviceManager.java | 29 ++- .../core/impl/PolicyInformationPointImpl.java | 6 +- .../internal/PolicyManagementDataHolder.java | 8 +- .../PolicyManagementServiceComponent.java | 8 +- 29 files changed, 347 insertions(+), 653 deletions(-) delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Credential.java rename components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/{spi => }/DeviceManager.java (99%) delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/AppManagerConnector.java rename components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/{ => app/mgt}/Application.java (97%) rename components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/{AppManagerConnectorException.java => ApplicationManagementException.java} (77%) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/ApplicationManager.java delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/AppManager.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManagementService.java delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceMgtService.java rename components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/{AppManagementServiceImpl.java => ApplicationManagementServiceImpl.java} (70%) rename components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/{AppManagerConnectorFactory.java => ApplicationManagerFactory.java} (82%) rename components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/{RemoteAppManagerConnector.java => RemoteApplicationManager.java} (78%) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagementServiceProvider.java rename components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/{DeviceManagementService.java => DeviceManagementProviderService.java} (87%) rename components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/{DeviceManagementServiceProviderImpl.java => service/DeviceManagementProviderServiceImpl.java} (91%) delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementServiceImpl.java diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Credential.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Credential.java deleted file mode 100644 index 1cb482ffe1..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Credential.java +++ /dev/null @@ -1,44 +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.device.mgt.common; - -/** - * DTO of the consumer key and secret - */ -public class Credential { - String consumerKey; - String consumerSecret; - - public String getConsumerKey() { - return consumerKey; - } - - public void setConsumerKey(String consumerKey) { - this.consumerKey = consumerKey; - } - - public String getConsumerSecret() { - return consumerSecret; - } - - public void setConsumerSecret(String consumerSecret) { - this.consumerSecret = consumerSecret; - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceManager.java similarity index 99% rename from components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManager.java rename to components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceManager.java index 0535062f30..3be92df393 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceManager.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.common.spi; +package org.wso2.carbon.device.mgt.common; import org.wso2.carbon.device.mgt.common.*; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/AppManagerConnector.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/AppManagerConnector.java deleted file mode 100644 index 07ab27e61a..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/AppManagerConnector.java +++ /dev/null @@ -1,77 +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.device.mgt.common.app.mgt; - -import org.wso2.carbon.device.mgt.common.Application; -import org.wso2.carbon.device.mgt.common.Credential; -import org.wso2.carbon.device.mgt.common.Device; -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; -import java.util.List; - -/** - * This will handle the Application management side of MDM by acting a bridge between - * MDM and App manager product. - */ -public interface AppManagerConnector { - - /** - * This will communicate with App manager and retrieve the list of apps in the store, when - * the domain is given. The list is broken down into pages and retrieved. - * - * @param domain Tenant domain of the app list to be retrieved. - * @param pageNumber Page number of the list. - * @param size Number of items in one page. - * @return The list of applications belongs to a domain. - * @throws AppManagerConnectorException - */ - - Application[] getApplicationList(String domain, int pageNumber, int size) throws AppManagerConnectorException; - - - /** - * Updates the application, install/uninstall status of the a certain application, on a device. - * - * @param deviceId Device id of the device that the status belongs to. - * @param application Application details of the app being updated. - * @param status Installed/Uninstalled - */ - void updateApplicationStatus(DeviceIdentifier deviceId, Application application, - String status) throws AppManagerConnectorException; - - /** - * Retrieve the status of an application on a device. Whether it is installed or not. - * - * @param deviceId Device id of the device that the status belongs to. - * @param application Application details of the app being searched. - * @return Status of the application on the device. - */ - String getApplicationStatus(DeviceIdentifier deviceId, Application application) throws AppManagerConnectorException; - - /** - * Create a new application and return client Id and secret. - * - * @return consumer Id and consumer key. - * * @throws AppManagerConnectorException - */ - Credential getClientCredentials() throws AppManagerConnectorException; - - void installApplication(Operation operation, List deviceIdentifiers) throws - AppManagerConnectorException; - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Application.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/Application.java similarity index 97% rename from components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Application.java rename to components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/Application.java index c4d4a91019..c6b27063ca 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Application.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/Application.java @@ -17,7 +17,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.common; +package org.wso2.carbon.device.mgt.common.app.mgt; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.Platform; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/AppManagerConnectorException.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/ApplicationManagementException.java similarity index 77% rename from components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/AppManagerConnectorException.java rename to components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/ApplicationManagementException.java index d6ba58a434..e70adf6d31 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/AppManagerConnectorException.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/ApplicationManagementException.java @@ -21,7 +21,7 @@ package org.wso2.carbon.device.mgt.common.app.mgt; /** * Handles the exceptions related to Application management. */ -public class AppManagerConnectorException extends Exception { +public class ApplicationManagementException extends Exception { private static final long serialVersionUID = -8933142342423122660L; private String errorMessage; @@ -34,26 +34,26 @@ public class AppManagerConnectorException extends Exception { this.errorMessage = errorMessage; } - public AppManagerConnectorException(String msg, Exception nestedEx) { + public ApplicationManagementException(String msg, Exception nestedEx) { super(msg, nestedEx); setErrorMessage(msg); } - public AppManagerConnectorException(String message, Throwable cause) { + public ApplicationManagementException(String message, Throwable cause) { super(message, cause); setErrorMessage(message); } - public AppManagerConnectorException(String msg) { + public ApplicationManagementException(String msg) { super(msg); setErrorMessage(msg); } - public AppManagerConnectorException() { + public ApplicationManagementException() { super(); } - public AppManagerConnectorException(Throwable cause) { + public ApplicationManagementException(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/app/mgt/ApplicationManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/ApplicationManager.java new file mode 100644 index 0000000000..4790de961f --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/ApplicationManager.java @@ -0,0 +1,71 @@ +/* + * + * 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.common.app.mgt; + +import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; + +import java.util.List; + +/** + * This will handle the Application management side of MDM by acting a bridge between + * MDM and App manager product. + */ +public interface ApplicationManager { + + /** + * This will communicate with App manager and retrieve the list of apps in the store, when + * the domain is given. The list is broken down into pages and retrieved. + * + * @param domain Tenant domain of the app list to be retrieved. + * @param pageNumber Page number of the list. + * @param size Number of items in one page. + * @return The list of applications belongs to a domain. + * @throws ApplicationManagementException + */ + + Application[] getApplications(String domain, int pageNumber, int size) throws ApplicationManagementException; + + + /** + * Updates the application, install/uninstall status of the a certain application, on a device. + * + * @param deviceId Device id of the device that the status belongs to. + * @param application Application details of the app being updated. + * @param status Installed/Uninstalled + */ + void updateApplicationStatus(DeviceIdentifier deviceId, Application application, + String status) throws ApplicationManagementException; + + /** + * Retrieve the status of an application on a device. Whether it is installed or not. + * + * @param deviceId Device id of the device that the status belongs to. + * @param application Application details of the app being searched. + * @return Status of the application on the device. + */ + String getApplicationStatus(DeviceIdentifier deviceId, + Application application) throws ApplicationManagementException; + + + void installApplication(Operation operation, + List deviceIdentifiers) throws ApplicationManagementException; + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/AppManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/AppManager.java deleted file mode 100644 index 148b6fb5dd..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/AppManager.java +++ /dev/null @@ -1,33 +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.device.mgt.common.spi; - -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.device.mgt.common.app.mgt.AppManagerConnectorException; -import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; - -import java.util.List; - -public interface AppManager { - - void installApplication(Operation operation, List deviceIdentifiers) - throws AppManagerConnectorException; - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManagementService.java new file mode 100644 index 0000000000..df97aede20 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManagementService.java @@ -0,0 +1,30 @@ +/* + * 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.common.spi; + +import org.wso2.carbon.device.mgt.common.DeviceManager; +import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager; + +/** + * Composite interface that acts as the SPI exposing all device management as well as application management + * functionalities + */ +public interface DeviceManagementService extends DeviceManager, ApplicationManager { + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceMgtService.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceMgtService.java deleted file mode 100644 index 8c247ffe44..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceMgtService.java +++ /dev/null @@ -1,24 +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.device.mgt.common.spi; - -public interface DeviceMgtService extends DeviceManager, AppManager { - -} 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 index 7633849ebd..bce9e024db 100644 --- 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 @@ -18,7 +18,7 @@ package org.wso2.carbon.device.mgt.core; import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.spi.DeviceMgtService; +import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; import java.util.Collection; @@ -27,13 +27,13 @@ import java.util.Map; public class DeviceManagementRepository { - private Map providers; + private Map providers; public DeviceManagementRepository() { - providers = new HashMap(); + providers = new HashMap(); } - public void addDeviceManagementProvider(DeviceMgtService provider) throws DeviceManagementException { + public void addDeviceManagementProvider(DeviceManagementService provider) throws DeviceManagementException { String deviceType = provider.getProviderType(); try { DeviceManagerUtil.registerDeviceType(deviceType); @@ -44,16 +44,16 @@ public class DeviceManagementRepository { providers.put(deviceType, provider); } - public void removeDeviceManagementProvider(DeviceMgtService provider) throws DeviceManagementException { + public void removeDeviceManagementProvider(DeviceManagementService provider) throws DeviceManagementException { String deviceType = provider.getProviderType(); providers.remove(deviceType); } - public DeviceMgtService getDeviceManagementProvider(String type) { + public DeviceManagementService getDeviceManagementProvider(String type) { return providers.get(type); } - public Collection getDeviceManagementProviders(){ + public Collection getDeviceManagementProviders(){ return providers.values(); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/AppManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/ApplicationManagementServiceImpl.java similarity index 70% rename from components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/AppManagementServiceImpl.java rename to components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/ApplicationManagementServiceImpl.java index 170134ee0d..d1aa9295d1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/AppManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/ApplicationManagementServiceImpl.java @@ -20,51 +20,47 @@ package org.wso2.carbon.device.mgt.core.app.mgt; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.*; -import org.wso2.carbon.device.mgt.common.app.mgt.AppManagerConnector; -import org.wso2.carbon.device.mgt.common.app.mgt.AppManagerConnectorException; +import org.wso2.carbon.device.mgt.common.app.mgt.Application; +import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException; +import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; -import java.util.ArrayList; import java.util.List; -public class AppManagementServiceImpl implements AppManagerConnector { +public class ApplicationManagementServiceImpl implements ApplicationManager { - private static final Log log = LogFactory.getLog(AppManagementServiceImpl.class); + private static final Log log = LogFactory.getLog(ApplicationManagementServiceImpl.class); @Override - public Application[] getApplicationList(String domain, int pageNumber, int size) throws AppManagerConnectorException { - return DeviceManagementDataHolder.getInstance().getAppManager().getApplicationList(domain, pageNumber, size); + public Application[] getApplications(String domain, int pageNumber, + int size) throws ApplicationManagementException { + return DeviceManagementDataHolder.getInstance().getAppManager().getApplications(domain, pageNumber, size); } @Override public void updateApplicationStatus( - DeviceIdentifier deviceId, Application application, String status) throws AppManagerConnectorException { + DeviceIdentifier deviceId, Application application, String status) throws ApplicationManagementException { DeviceManagementDataHolder.getInstance().getAppManager().updateApplicationStatus(deviceId, application, status); } @Override public String getApplicationStatus(DeviceIdentifier deviceId, - Application application) throws AppManagerConnectorException { + Application application) throws ApplicationManagementException { return null; } - @Override - public Credential getClientCredentials() throws AppManagerConnectorException { - return DeviceManagementDataHolder.getInstance().getAppManager().getClientCredentials(); - } - @Override public void installApplication(Operation operation, List deviceIdentifiers) - throws AppManagerConnectorException { + throws ApplicationManagementException { try { DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().addOperation(operation, deviceIdentifiers); } catch (OperationManagementException opMgtEx) { String errorMsg = "Error occurred when add operations at install application"; log.error(errorMsg, opMgtEx); - throw new AppManagerConnectorException(); + throw new ApplicationManagementException(); } DeviceManagementDataHolder.getInstance().getAppManager().installApplication(operation, deviceIdentifiers); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/AppManagerConnectorFactory.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/ApplicationManagerFactory.java similarity index 82% rename from components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/AppManagerConnectorFactory.java rename to components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/ApplicationManagerFactory.java index 884aa46dd5..0c8d4abb38 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/AppManagerConnectorFactory.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/ApplicationManagerFactory.java @@ -18,11 +18,11 @@ */ package org.wso2.carbon.device.mgt.core.app.mgt; -import org.wso2.carbon.device.mgt.common.app.mgt.AppManagerConnector; +import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager; import org.wso2.carbon.device.mgt.core.DeviceManagementRepository; import org.wso2.carbon.device.mgt.core.app.mgt.config.AppManagementConfig; -public class AppManagerConnectorFactory { +public class ApplicationManagerFactory { private static DeviceManagementRepository pluginRepository; @@ -36,8 +36,8 @@ public class AppManagerConnectorFactory { - public static AppManagerConnector getConnector(AppManagementConfig config) { - return new RemoteAppManagerConnector(config, pluginRepository); + public static ApplicationManager getConnector(AppManagementConfig config) { + return new RemoteApplicationManager(config, pluginRepository); } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/RemoteAppManagerConnector.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/RemoteApplicationManager.java similarity index 78% rename from components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/RemoteAppManagerConnector.java rename to components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/RemoteApplicationManager.java index 87c3cc0a13..a9d38c9904 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/RemoteAppManagerConnector.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/RemoteApplicationManager.java @@ -23,13 +23,12 @@ import org.apache.axis2.context.ConfigurationContext; import org.apache.axis2.context.ConfigurationContextFactory; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.common.Application; -import org.wso2.carbon.device.mgt.common.Credential; +import org.wso2.carbon.device.mgt.common.app.mgt.Application; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.device.mgt.common.app.mgt.AppManagerConnector; -import org.wso2.carbon.device.mgt.common.app.mgt.AppManagerConnectorException; +import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException; +import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; -import org.wso2.carbon.device.mgt.common.spi.DeviceMgtService; +import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; import org.wso2.carbon.device.mgt.core.DeviceManagementConstants; import org.wso2.carbon.device.mgt.core.DeviceManagementRepository; import org.wso2.carbon.device.mgt.core.app.mgt.config.AppManagementConfig; @@ -46,7 +45,7 @@ import java.util.List; /** * Implements AppManagerConnector interface */ -public class RemoteAppManagerConnector implements AppManagerConnector { +public class RemoteApplicationManager implements ApplicationManager { private ConfigurationContext configCtx; private ServiceAuthenticator authenticator; @@ -55,9 +54,9 @@ public class RemoteAppManagerConnector implements AppManagerConnector { private static final String GET_APP_LIST_URL = "store/apis/assets/mobileapp?domain=carbon.super&page=1"; - private static final Log log = LogFactory.getLog(RemoteAppManagerConnector.class); + private static final Log log = LogFactory.getLog(RemoteApplicationManager.class); - public RemoteAppManagerConnector(AppManagementConfig appManagementConfig, DeviceManagementRepository pluginRepository) { + public RemoteApplicationManager(AppManagementConfig appManagementConfig, DeviceManagementRepository pluginRepository) { IdentityConfigurations identityConfig = DeviceConfigurationManager.getInstance().getDeviceManagementConfig(). getDeviceManagementConfigRepository().getIdentityConfigurations(); @@ -75,44 +74,35 @@ public class RemoteAppManagerConnector implements AppManagerConnector { } @Override - public Application[] getApplicationList(String domain, int pageNumber, - int size) throws AppManagerConnectorException { + public Application[] getApplications(String domain, int pageNumber, + int size) throws ApplicationManagementException { return new Application[0]; } @Override public void updateApplicationStatus(DeviceIdentifier deviceId, Application application, - String status) throws AppManagerConnectorException{ + String status) throws ApplicationManagementException { } @Override public String getApplicationStatus(DeviceIdentifier deviceId, - Application application) throws AppManagerConnectorException { + Application application) throws ApplicationManagementException { return null; } - @Override - public Credential getClientCredentials() throws AppManagerConnectorException { - OAuthConsumerAppDTO appInfo = this.getAppInfo(); - - Credential credential = new Credential(); - credential.setConsumerKey(appInfo.getOauthConsumerKey()); - credential.setConsumerSecret(appInfo.getOauthConsumerSecret()); - return credential; - } - @Override public void installApplication(Operation operation, List deviceIdentifiers) - throws AppManagerConnectorException { + throws ApplicationManagementException { for(DeviceIdentifier deviceIdentifier:deviceIdentifiers){ - DeviceMgtService dms = this.getPluginRepository().getDeviceManagementProvider(deviceIdentifier.getType()); + DeviceManagementService dms = + this.getPluginRepository().getDeviceManagementProvider(deviceIdentifier.getType()); dms.installApplication(operation,deviceIdentifiers); } } - private OAuthConsumerAppDTO getAppInfo() throws AppManagerConnectorException { + private OAuthConsumerAppDTO getAppInfo() throws ApplicationManagementException { OAuthConsumerAppDTO appInfo = null; try { OAuthAdminServiceStub oAuthAdminServiceStub = @@ -147,9 +137,9 @@ public class RemoteAppManagerConnector implements AppManagerConnector { return appDTO; } - private void handleException(String msg, Exception e) throws AppManagerConnectorException { + private void handleException(String msg, Exception e) throws ApplicationManagementException { log.error(msg, e); - throw new AppManagerConnectorException(msg, e); + throw new ApplicationManagementException(msg, e); } public DeviceManagementRepository getPluginRepository() { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/config/AppManagementConfigurationManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/config/AppManagementConfigurationManager.java index 88ef88e717..4fd12ca2da 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/config/AppManagementConfigurationManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/config/AppManagementConfigurationManager.java @@ -19,7 +19,7 @@ package org.wso2.carbon.device.mgt.core.app.mgt.config; import org.w3c.dom.Document; -import org.wso2.carbon.device.mgt.common.app.mgt.AppManagerConnectorException; +import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException; import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; import org.wso2.carbon.utils.CarbonUtils; @@ -47,7 +47,7 @@ public class AppManagementConfigurationManager { return appManagementConfigManager; } - public synchronized void initConfig() throws AppManagerConnectorException { + public synchronized void initConfig() throws ApplicationManagementException { try { File appManagementConfig = new File(AppManagementConfigurationManager.APP_MANAGER_CONFIG_PATH); @@ -60,7 +60,7 @@ public class AppManagementConfigurationManager { } catch (Exception e) { /* Catches generic exception as there's no specific task to be carried out catching a particular exception */ - throw new AppManagerConnectorException( + throw new ApplicationManagementException( "Error occurred while initializing application management Configurations", e); } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/oauth/ServiceAuthenticator.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/oauth/ServiceAuthenticator.java index abe3d3ba3f..5508b572f3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/oauth/ServiceAuthenticator.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/oauth/ServiceAuthenticator.java @@ -21,7 +21,7 @@ package org.wso2.carbon.device.mgt.core.app.mgt.oauth; import org.apache.axis2.client.Options; import org.apache.axis2.client.ServiceClient; import org.apache.axis2.transport.http.HttpTransportProperties; -import org.wso2.carbon.device.mgt.common.app.mgt.AppManagerConnectorException; +import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException; /** * Authenticate a given service client. @@ -36,7 +36,7 @@ public class ServiceAuthenticator { this.password = password; } - public void authenticate(ServiceClient client) throws AppManagerConnectorException { + public void authenticate(ServiceClient client) throws ApplicationManagementException { Options option = client.getOptions(); HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator(); auth.setUsername(username); 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 index 3651a3f4d0..2677e7704c 100644 --- 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 @@ -19,29 +19,29 @@ package org.wso2.carbon.device.mgt.core.internal; +import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager; import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager; import org.wso2.carbon.device.mgt.core.api.mgt.APIPublisherService; -import org.wso2.carbon.device.mgt.common.app.mgt.AppManagerConnector; import org.wso2.carbon.device.mgt.core.app.mgt.config.AppManagementConfig; import org.wso2.carbon.device.mgt.core.config.license.LicenseConfig; -import org.wso2.carbon.device.mgt.core.service.DeviceManagementService; +import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; +import org.wso2.carbon.device.mgt.user.core.UserManager; import org.wso2.carbon.registry.core.service.RegistryService; import org.wso2.carbon.user.core.service.RealmService; import org.wso2.carbon.user.core.tenant.TenantManager; -import org.wso2.carbon.device.mgt.user.core.UserManager; public class DeviceManagementDataHolder { private RealmService realmService; private TenantManager tenantManager; - private DeviceManagementService deviceManagerProvider; + private DeviceManagementProviderService deviceManagerProvider; private LicenseManager licenseManager; private RegistryService registryService; private LicenseConfig licenseConfig; private APIPublisherService apiPublisherService; - private AppManagerConnector appManager; - private AppManagementConfig appManagerConfig; + private ApplicationManager appManager; + private AppManagementConfig appManagerConfig; private OperationManager operationManager; private UserManager userManager; @@ -74,11 +74,11 @@ public class DeviceManagementDataHolder { return tenantManager; } - public DeviceManagementService getDeviceManagementProvider() { + public DeviceManagementProviderService getDeviceManagementProvider() { return deviceManagerProvider; } - public void setDeviceManagementProvider(DeviceManagementService deviceManagerProvider) { + public void setDeviceManagementProvider(DeviceManagementProviderService deviceManagerProvider) { this.deviceManagerProvider = deviceManagerProvider; } @@ -114,21 +114,21 @@ public class DeviceManagementDataHolder { this.apiPublisherService = apiPublisherService; } - public AppManagerConnector getAppManager() { - return appManager; - } + public ApplicationManager getAppManager() { + return appManager; + } - public void setAppManager(AppManagerConnector appManager) { - this.appManager = appManager; - } + public void setAppManager(ApplicationManager appManager) { + this.appManager = appManager; + } - public AppManagementConfig getAppManagerConfig() { - return appManagerConfig; - } + public AppManagementConfig getAppManagerConfig() { + return appManagerConfig; + } - public void setAppManagerConfig(AppManagementConfig appManagerConfig) { - this.appManagerConfig = appManagerConfig; - } + public void setAppManagerConfig(AppManagementConfig appManagerConfig) { + this.appManagerConfig = appManagerConfig; + } public OperationManager getOperationManager() { return operationManager; 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 index 6d3aa4f022..e2d65269df 100644 --- 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 @@ -24,22 +24,21 @@ import org.osgi.service.component.ComponentContext; import org.wso2.carbon.apimgt.impl.APIManagerConfigurationService; import org.wso2.carbon.core.ServerStartupObserver; import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.app.mgt.AppManagerConnector; -import org.wso2.carbon.device.mgt.common.app.mgt.AppManagerConnectorException; +import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException; +import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager; import org.wso2.carbon.device.mgt.common.license.mgt.License; import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException; import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager; -import org.wso2.carbon.device.mgt.common.spi.DeviceMgtService; +import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; import org.wso2.carbon.device.mgt.core.DeviceManagementConstants; import org.wso2.carbon.device.mgt.core.DeviceManagementRepository; -import org.wso2.carbon.device.mgt.core.DeviceManagementServiceProviderImpl; import org.wso2.carbon.device.mgt.core.api.mgt.APIPublisherService; import org.wso2.carbon.device.mgt.core.api.mgt.APIPublisherServiceImpl; import org.wso2.carbon.device.mgt.core.api.mgt.APIRegistrationStartupObserver; -import org.wso2.carbon.device.mgt.core.app.mgt.AppManagementServiceImpl; -import org.wso2.carbon.device.mgt.core.app.mgt.RemoteAppManagerConnector; +import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementServiceImpl; +import org.wso2.carbon.device.mgt.core.app.mgt.RemoteApplicationManager; import org.wso2.carbon.device.mgt.core.app.mgt.config.AppManagementConfig; import org.wso2.carbon.device.mgt.core.app.mgt.config.AppManagementConfigurationManager; import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager; @@ -51,11 +50,10 @@ import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory; import org.wso2.carbon.device.mgt.core.license.mgt.LicenseManagerImpl; import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerImpl; import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory; -import org.wso2.carbon.device.mgt.core.service.DeviceManagementService; -import org.wso2.carbon.device.mgt.core.service.DeviceManagementServiceImpl; +import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; +import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl; import org.wso2.carbon.device.mgt.core.util.DeviceManagementSchemaInitializer; import org.wso2.carbon.device.mgt.user.core.UserManager; -import org.wso2.carbon.device.mgt.user.core.service.UserManagementService; import org.wso2.carbon.ndatasource.core.DataSourceService; import org.wso2.carbon.registry.core.service.RegistryService; import org.wso2.carbon.user.core.service.RealmService; @@ -72,7 +70,7 @@ import java.util.List; * bind="setRealmService" * unbind="unsetRealmService" * @scr.reference name="device.manager.service" - * interface="org.wso2.carbon.device.mgt.common.spi.DeviceMgtService" + * interface="org.wso2.carbon.device.mgt.common.spi.DeviceManagementService" * cardinality="0..n" * policy="dynamic" * bind="setDeviceManager" @@ -109,7 +107,7 @@ public class DeviceManagementServiceComponent { private static final Object LOCK = new Object(); private boolean isInitialized; - private List deviceManagers = new ArrayList(); + private List deviceManagementServices = new ArrayList(); protected void activate(ComponentContext componentContext) { try { @@ -131,8 +129,8 @@ public class DeviceManagementServiceComponent { /* Initializing app manager connector */ this.initAppManagerConnector(); - DeviceManagementService deviceManagementProvider = - new DeviceManagementServiceProviderImpl(this.getPluginRepository()); + DeviceManagementProviderService deviceManagementProvider = + new DeviceManagementProviderServiceImpl(this.getPluginRepository()); DeviceManagementDataHolder.getInstance().setDeviceManagementProvider(deviceManagementProvider); OperationManagementDAOFactory.init(dsConfig); @@ -149,8 +147,8 @@ public class DeviceManagementServiceComponent { } synchronized (LOCK) { - for (DeviceMgtService deviceManager : deviceManagers) { - this.registerDeviceManagementProvider(deviceManager); + for (DeviceManagementService deviceManagementService : deviceManagementServices) { + this.registerDeviceManagementProvider(deviceManagementService); } this.isInitialized = true; } @@ -185,23 +183,23 @@ public class DeviceManagementServiceComponent { DeviceManagementDataHolder.getInstance().setOperationManager(operationManager); } - private void initAppManagerConnector() throws AppManagerConnectorException { + private void initAppManagerConnector() throws ApplicationManagementException { AppManagementConfigurationManager.getInstance().initConfig(); AppManagementConfig appConfig = AppManagementConfigurationManager.getInstance().getAppManagementConfig(); DeviceManagementDataHolder.getInstance().setAppManagerConfig(appConfig); - RemoteAppManagerConnector appManager = new RemoteAppManagerConnector(appConfig, this.getPluginRepository()); + RemoteApplicationManager appManager = new RemoteApplicationManager(appConfig, this.getPluginRepository()); DeviceManagementDataHolder.getInstance().setAppManager(appManager); } private void registerServices(ComponentContext componentContext) { if (log.isDebugEnabled()) { - log.debug("Registering OSGi service DeviceManagementServiceImpl"); + log.debug("Registering OSGi service DeviceManagementProviderServiceImpl"); } /* Registering Device Management Service */ BundleContext bundleContext = componentContext.getBundleContext(); - bundleContext.registerService(DeviceManagementService.class.getName(), - new DeviceManagementServiceImpl(), null); + bundleContext.registerService(DeviceManagementProviderService.class.getName(), + new DeviceManagementProviderServiceImpl(), null); APIPublisherService publisher = new APIPublisherServiceImpl(); DeviceManagementDataHolder.getInstance().setApiPublisherService(publisher); @@ -210,7 +208,7 @@ public class DeviceManagementServiceComponent { bundleContext.registerService(ServerStartupObserver.class, new APIRegistrationStartupObserver(), null); /* Registering App Management service */ - bundleContext.registerService(AppManagerConnector.class.getName(), new AppManagementServiceImpl(), null); + bundleContext.registerService(ApplicationManager.class.getName(), new ApplicationManagementServiceImpl(), null); } private void setupDeviceManagementSchema(DataSourceConfig config) @@ -241,12 +239,12 @@ public class DeviceManagementServiceComponent { } } - private void registerDeviceManagementProvider(DeviceMgtService deviceManager) { + private void registerDeviceManagementProvider(DeviceManagementService deviceManagementService) { try { - this.getPluginRepository().addDeviceManagementProvider(deviceManager); + this.getPluginRepository().addDeviceManagementProvider(deviceManagementService); } catch (DeviceManagementException e) { log.error("Error occurred while adding device management provider '" + - deviceManager.getProviderType() + "'"); + deviceManagementService.getProviderType() + "'"); } } @@ -255,7 +253,7 @@ public class DeviceManagementServiceComponent { * * @param deviceManager An instance of DeviceManager */ - protected void setDeviceManager(DeviceMgtService deviceManager) { + protected void setDeviceManager(DeviceManagementService deviceManager) { if (log.isDebugEnabled()) { log.debug("Setting Device Management Service Provider: '" + deviceManager.getProviderType() + "'"); } @@ -263,7 +261,7 @@ public class DeviceManagementServiceComponent { if (isInitialized) { this.registerDeviceManagementProvider(deviceManager); } - deviceManagers.add(deviceManager); + deviceManagementServices.add(deviceManager); } } @@ -272,7 +270,7 @@ public class DeviceManagementServiceComponent { * * @param deviceManager An Instance of DeviceManager */ - protected void unsetDeviceManager(DeviceMgtService deviceManager) { + protected void unsetDeviceManager(DeviceManagementService deviceManager) { if (log.isDebugEnabled()) { log.debug("Un setting Device Management Service Provider : '" + deviceManager.getProviderType() + "'"); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/license/mgt/LicenseManagerImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/license/mgt/LicenseManagerImpl.java index e1ded0d3ee..97f3245cc7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/license/mgt/LicenseManagerImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/license/mgt/LicenseManagerImpl.java @@ -24,7 +24,7 @@ import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException; import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager; -import org.wso2.carbon.device.mgt.core.DeviceManagementServiceProviderImpl; +import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl; import org.wso2.carbon.device.mgt.common.license.mgt.License; import org.wso2.carbon.governance.api.exception.GovernanceException; import org.wso2.carbon.governance.api.generic.GenericArtifactFilter; @@ -39,7 +39,7 @@ import java.util.Locale; public class LicenseManagerImpl implements LicenseManager { - private static Log log = LogFactory.getLog(DeviceManagementServiceProviderImpl.class); + private static Log log = LogFactory.getLog(DeviceManagementProviderServiceImpl.class); private static final DateFormat format = new SimpleDateFormat("dd-mm-yyyy", Locale.ENGLISH); @Override diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagementServiceProvider.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagementServiceProvider.java new file mode 100644 index 0000000000..844abe6801 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagementServiceProvider.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 interface OperationManagementServiceProvider { +} 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 index 88113bc4bb..b79b711dbe 100644 --- 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 @@ -20,20 +20,21 @@ package org.wso2.carbon.device.mgt.core.operation.mgt; import org.apache.commons.logging.Log; 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.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager; +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.dto.Device; 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 org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationMappingDAO; import org.wso2.carbon.device.mgt.core.operation.mgt.dao.util.OperationDAOUtil; import org.wso2.carbon.device.mgt.core.operation.mgt.util.OperationCreateTimeComparator; -import org.wso2.carbon.device.mgt.core.service.DeviceManagementService; -import org.wso2.carbon.device.mgt.core.service.DeviceManagementServiceImpl; import java.util.ArrayList; import java.util.Collections; @@ -54,7 +55,7 @@ public class OperationManagerImpl implements OperationManager { private OperationDAO policyOperationDAO; private OperationMappingDAO operationMappingDAO; private OperationDAO operationDAO; - private DeviceManagementService deviceManagementService; + private DeviceDAO deviceDAO; public OperationManagerImpl() { commandOperationDAO = OperationManagementDAOFactory.getCommandOperationDAO(); @@ -63,16 +64,16 @@ public class OperationManagerImpl implements OperationManager { policyOperationDAO = OperationManagementDAOFactory.getPolicyOperationDAO(); operationMappingDAO = OperationManagementDAOFactory.getOperationMappingDAO(); operationDAO = OperationManagementDAOFactory.getOperationDAO(); - deviceManagementService = new DeviceManagementServiceImpl(); + deviceDAO = DeviceManagementDAOFactory.getDeviceDAO(); } @Override - public boolean addOperation(Operation operation, List devices) throws - OperationManagementException { + public boolean addOperation(Operation operation, + List deviceIdentifiers) throws OperationManagementException { if (log.isDebugEnabled()) { log.debug("operation:[" + operation.toString() + "]"); - for (DeviceIdentifier deviceIdentifier : devices) { + for (DeviceIdentifier deviceIdentifier : deviceIdentifiers) { log.debug("device identifier id:[" + deviceIdentifier.getId() + "] type:[" + deviceIdentifier.getType() + "]"); } @@ -83,10 +84,10 @@ public class OperationManagerImpl implements OperationManager { OperationDAOUtil.convertOperation(operation); int operationId = this.lookupOperationDAO(operation).addOperation(operationDto); - org.wso2.carbon.device.mgt.common.Device device; - for (DeviceIdentifier deviceIdentifier : devices) { - device = deviceManagementService.getCoreDevice(deviceIdentifier); + Device device; + for (DeviceIdentifier deviceIdentifier : deviceIdentifiers) { + device = deviceDAO.getDevice(deviceIdentifier); if (device == null) { String errorMsg = "The operation not added for device.The device not found for " + "device Identifier type -'" + deviceIdentifier.getType() + "' and device Id '" + @@ -99,22 +100,19 @@ public class OperationManagerImpl implements OperationManager { OperationManagementDAOFactory.commitTransaction(); return true; } catch (OperationManagementDAOException e) { - log.error("Error occurred while adding operation: ", e); try { OperationManagementDAOFactory.rollbackTransaction(); } catch (OperationManagementDAOException e1) { log.warn("Error occurred while roll-backing the transaction", e1); } throw new OperationManagementException("Error occurred while adding operation", e); - } catch (DeviceManagementException deviceMgtEx) { + } catch (DeviceManagementDAOException e) { try { OperationManagementDAOFactory.rollbackTransaction(); } catch (OperationManagementDAOException e1) { log.warn("Error occurred while roll-backing the transaction", e1); } - String errorMsg = "Error occurred fetching devices "; - log.error(deviceMgtEx.getErrorMessage(), deviceMgtEx); - throw new OperationManagementException(errorMsg, deviceMgtEx); + throw new OperationManagementException("Error occurred while retrieving device metadata", e); } } @@ -124,16 +122,12 @@ public class OperationManagerImpl implements OperationManager { try { List operations = new ArrayList(); - org.wso2.carbon.device.mgt.common.Device device; + Device device = null; try { - device = deviceManagementService.getCoreDevice(deviceIdentifier); - } catch (DeviceManagementException deviceMgtEx) { - String errorMsg = "Error occurred while retrieving the device " + - "for device Identifier type -'" + deviceIdentifier.getType() + "' and device Id '" + - deviceIdentifier.getId(); - log.error(errorMsg, deviceMgtEx); - throw new OperationManagementException(errorMsg, deviceMgtEx); + device = deviceDAO.getDevice(deviceIdentifier); + } catch (DeviceManagementDAOException e) { + e.printStackTrace(); } if (device == null) { throw new OperationManagementException("Device not found for given device " + @@ -163,7 +157,7 @@ public class OperationManagerImpl implements OperationManager { + "]"); } - org.wso2.carbon.device.mgt.common.Device device; + Device device; List operations = new ArrayList(); List dtoOperationList = @@ -171,7 +165,7 @@ public class OperationManagerImpl implements OperationManager { try { - device = deviceManagementService.getCoreDevice(deviceIdentifier); + device = deviceDAO.getDevice(deviceIdentifier); if (device == null) { throw new OperationManagementException("Device not found for given device " + @@ -197,16 +191,16 @@ public class OperationManagerImpl implements OperationManager { } Collections.sort(operations, new OperationCreateTimeComparator()); return operations; - } catch (DeviceManagementException deviceMgtException) { - String errorMsg = "Error occurred while retrieving the device " + - "for device Identifier type -'" + deviceIdentifier.getType() + "' and device Id '" - + deviceIdentifier.getId(); - log.error(errorMsg, deviceMgtException); - throw new OperationManagementException(errorMsg, deviceMgtException); } catch (OperationManagementDAOException e) { throw new OperationManagementException("Error occurred while retrieving the list of " + "pending operations assigned for '" + deviceIdentifier.getType() + "' device '" + deviceIdentifier.getId() + "'", e); + } catch (DeviceManagementDAOException e) { + String errorMsg = "Error occurred while retrieving the device " + + "for device Identifier type -'" + deviceIdentifier.getType() + "' and device Id '" + + deviceIdentifier.getId(); + log.error(errorMsg, e); + throw new OperationManagementException(errorMsg, e); } } @@ -220,7 +214,7 @@ public class OperationManagerImpl implements OperationManager { Operation operation = null; Device device; try { - device = deviceManagementService.getCoreDevice(deviceIdentifier); + device = deviceDAO.getDevice(deviceIdentifier); if (device == null) { throw new OperationManagementException("Device not found for given device " + @@ -234,7 +228,7 @@ public class OperationManagerImpl implements OperationManager { org.wso2.carbon.device.mgt.core.dto.operation.mgt.CommandOperation commandOperation; commandOperation = (org.wso2.carbon.device.mgt.core.dto.operation.mgt.CommandOperation) commandOperationDAO - .getOperation(dtoOperation.getId()); + .getOperation(dtoOperation.getId()); dtoOperation.setEnabled(commandOperation.isEnabled()); } else if (org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.CONFIG .equals(dtoOperation.getType())) { @@ -249,14 +243,14 @@ public class OperationManagerImpl implements OperationManager { operation = OperationDAOUtil.convertOperation(dtoOperation); } return operation; - } catch (DeviceManagementException deviceMgtException) { + } catch (OperationManagementDAOException e) { + throw new OperationManagementException("Error occurred while retrieving next pending operation", e); + } catch (DeviceManagementDAOException e) { String errorMsg = "Error occurred while retrieving the device " + "for device Identifier type -'" + deviceIdentifier.getType() + "' and device Id '" + deviceIdentifier.getId(); - log.error(errorMsg, deviceMgtException); - throw new OperationManagementException(errorMsg, deviceMgtException); - } catch (OperationManagementDAOException e) { - throw new OperationManagementException("Error occurred while retrieving next pending operation", e); + log.error(errorMsg, e); + throw new OperationManagementException(errorMsg, e); } } @@ -277,7 +271,7 @@ public class OperationManagerImpl implements OperationManager { } dtoOperation.setStatus(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status.valueOf (operationStatus.toString())); - Device device = deviceManagementService.getCoreDevice(deviceIdentifier); + Device device = deviceDAO.getDevice(deviceIdentifier); OperationManagementDAOFactory.beginTransaction(); operationDAO.updateOperation(dtoOperation); @@ -285,11 +279,6 @@ public class OperationManagerImpl implements OperationManager { org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status .valueOf(operationStatus.toString())); OperationManagementDAOFactory.commitTransaction(); - } catch (DeviceManagementException ex) { - log.error("Error occurred while fetch the device for device identifier: " + deviceIdentifier.getId() + " " + - "type:" + deviceIdentifier.getType(), ex); - throw new OperationManagementException("Error occurred while update operation", ex); - } catch (OperationManagementDAOException ex) { try { OperationManagementDAOFactory.rollbackTransaction(); @@ -298,6 +287,10 @@ public class OperationManagerImpl implements OperationManager { } log.error("Error occurred while updating the operation: " + operationId + " status:" + operationStatus, ex); throw new OperationManagementException("Error occurred while update operation", ex); + } catch (DeviceManagementDAOException e) { + log.error("Error occurred while fetch the device for device identifier: " + deviceIdentifier.getId() + " " + + "type:" + deviceIdentifier.getType(), e); + throw new OperationManagementException("Error occurred while update operation", e); } } @@ -331,7 +324,7 @@ public class OperationManagerImpl implements OperationManager { public Operation getOperationByDeviceAndOperationId(DeviceIdentifier deviceIdentifier, int operationId) throws OperationManagementException { - org.wso2.carbon.device.mgt.common.Device device; + Device device; Operation operation; if (log.isDebugEnabled()) { @@ -342,7 +335,7 @@ public class OperationManagerImpl implements OperationManager { } try { - device = deviceManagementService.getCoreDevice(deviceIdentifier); + device = deviceDAO.getDevice(deviceIdentifier); if (device == null) { throw new OperationManagementException("Device not found for given device identifier:" + deviceIdentifier.getId() + " type:" + deviceIdentifier.getType()); @@ -373,30 +366,30 @@ public class OperationManagerImpl implements OperationManager { " device" + " Id:" + device.getId()); } operation = OperationDAOUtil.convertOperation(dtoOperation); - } catch (DeviceManagementException deviceMgtException) { - String errorMsg = "Error occurred while retrieving the device " + - "for device Identifier type -'" + deviceIdentifier.getType() + "' and device Id '" - + deviceIdentifier.getId(); - log.error(errorMsg, deviceMgtException); - throw new OperationManagementException(errorMsg, deviceMgtException); } catch (OperationManagementDAOException e) { throw new OperationManagementException("Error occurred while retrieving the list of " + "operations assigned for '" + deviceIdentifier.getType() + "' device '" + deviceIdentifier.getId() + "'", e); + } catch (DeviceManagementDAOException e) { + String errorMsg = "Error occurred while retrieving the device " + + "for device Identifier type -'" + deviceIdentifier.getType() + "' and device Id '" + + deviceIdentifier.getId(); + log.error(errorMsg, e); + throw new OperationManagementException(errorMsg, e); } return operation; } @Override public List getOperationsByDeviceAndStatus(DeviceIdentifier identifier, - Operation.Status status) throws OperationManagementException, DeviceManagementException { + Operation.Status status) throws OperationManagementException, DeviceManagementException { try { List operations = new ArrayList(); List dtoOperationList = new ArrayList(); - org.wso2.carbon.device.mgt.common.Device device = deviceManagementService.getCoreDevice(identifier); + Device device = deviceDAO.getDevice(identifier); if (device == null) { throw new DeviceManagementException("Device not found for device id:" + identifier.getId() + " " + @@ -423,15 +416,15 @@ public class OperationManagerImpl implements OperationManager { operations.add(operation); } return operations; - } catch (DeviceManagementException deviceMgtException) { - String errorMsg = "Error occurred while retrieving the device " + - "for device Identifier type -'" + identifier.getType() + "' and device Id '" + identifier.getId(); - log.error(errorMsg, deviceMgtException); - throw new OperationManagementException(errorMsg, deviceMgtException); } catch (OperationManagementDAOException e) { throw new OperationManagementException("Error occurred while retrieving the list of " + "operations assigned for '" + identifier.getType() + "' device '" + identifier.getId() + "' and status:" + status.toString(), e); + } catch (DeviceManagementDAOException e) { + String errorMsg = "Error occurred while retrieving the device " + + "for device Identifier type -'" + identifier.getType() + "' and device Id '" + identifier.getId(); + log.error(errorMsg, e); + throw new OperationManagementException(errorMsg, e); } } 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/DeviceManagementProviderService.java similarity index 87% 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/DeviceManagementProviderService.java index 27b0d700c9..7fa01e5cc9 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/DeviceManagementProviderService.java @@ -18,8 +18,7 @@ package org.wso2.carbon.device.mgt.core.service; import org.wso2.carbon.device.mgt.common.*; -import org.wso2.carbon.device.mgt.common.app.mgt.AppManagerConnector; -import org.wso2.carbon.device.mgt.common.spi.DeviceManager; +import org.wso2.carbon.device.mgt.common.DeviceManager; import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager; import java.util.List; @@ -28,7 +27,7 @@ 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 extends DeviceManager, LicenseManager, OperationManager { +public interface DeviceManagementProviderService extends DeviceManager, LicenseManager, OperationManager { List getAllDevices(String type) throws DeviceManagementException; @@ -42,14 +41,6 @@ public interface DeviceManagementService extends DeviceManager, LicenseManager, FeatureManager getFeatureManager(String type) throws DeviceManagementException; - /** - * This method returns core device details. - * @param deviceId - * @return - * @throws DeviceManagementException - */ - Device getCoreDevice(DeviceIdentifier deviceId) throws DeviceManagementException; - /** * Method to get the list of devices owned by an user. * @@ -87,4 +78,5 @@ public interface DeviceManagementService extends DeviceManager, LicenseManager, * device list */ List getDevicesByName(String deviceName, int tenantId) throws DeviceManagementException; + } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementServiceProviderImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java similarity index 91% rename from components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementServiceProviderImpl.java rename to components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 595b25b3e2..85b10f679d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementServiceProviderImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -15,16 +15,17 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.core; +package org.wso2.carbon.device.mgt.core.service; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.*; +import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.license.mgt.License; import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; -import org.wso2.carbon.device.mgt.common.spi.DeviceManager; +import org.wso2.carbon.device.mgt.core.DeviceManagementRepository; import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager; import org.wso2.carbon.device.mgt.core.config.email.NotificationMessages; import org.wso2.carbon.device.mgt.core.dao.DeviceDAO; @@ -32,11 +33,10 @@ 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 org.wso2.carbon.device.mgt.core.dto.*; import org.wso2.carbon.device.mgt.core.email.EmailConstants; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; import org.wso2.carbon.device.mgt.core.internal.EmailServiceDataHolder; -import org.wso2.carbon.device.mgt.core.service.DeviceManagementService; import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; import java.io.IOException; @@ -45,21 +45,21 @@ import java.net.URLEncoder; import java.util.ArrayList; import java.util.List; -public class DeviceManagementServiceProviderImpl implements DeviceManagementService { +public class DeviceManagementProviderServiceImpl implements DeviceManagementProviderService { private DeviceDAO deviceDAO; private DeviceTypeDAO deviceTypeDAO; private DeviceManagementRepository pluginRepository; - private static Log log = LogFactory.getLog(DeviceManagementServiceProviderImpl.class); + private static Log log = LogFactory.getLog(DeviceManagementProviderServiceImpl.class); - public DeviceManagementServiceProviderImpl(DeviceManagementRepository pluginRepository) { + public DeviceManagementProviderServiceImpl(DeviceManagementRepository pluginRepository) { this.pluginRepository = pluginRepository; this.deviceDAO = DeviceManagementDAOFactory.getDeviceDAO(); this.deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO(); } - public DeviceManagementServiceProviderImpl() { + public DeviceManagementProviderServiceImpl() { this.deviceDAO = DeviceManagementDAOFactory.getDeviceDAO(); this.deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO(); } @@ -81,24 +81,6 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ return dms.getFeatureManager(); } - @Override - public Device getCoreDevice(DeviceIdentifier deviceId) throws DeviceManagementException { - - Device convertedDevice = null; - try { - DeviceType deviceType = this.getDeviceTypeDAO().getDeviceType(deviceId.getType()); - org.wso2.carbon.device.mgt.core.dto.Device device = this.getDeviceDAO().getDevice(deviceId); - if (device != null) { - convertedDevice = DeviceManagementDAOUtil.convertDevice(device, - this.getDeviceTypeDAO().getDeviceType(deviceType.getId())); - } - } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while obtaining the device for id " + - "'" + deviceId.getId() + "' and type:" + deviceId.getType(), e); - } - return convertedDevice; - } - @Override public boolean enrollDevice(Device device) throws DeviceManagementException { DeviceManager dms = @@ -253,8 +235,8 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ public void sendEnrolmentInvitation(EmailMessageProperties emailMessageProperties) throws DeviceManagementException { - List notificationMessages = DeviceConfigurationManager.getInstance() - .getNotificationMessagesConfig().getNotificationMessagesList(); + List notificationMessages = + DeviceConfigurationManager.getInstance().getNotificationMessagesConfig().getNotificationMessagesList(); String messageHeader = ""; String messageBody = ""; @@ -265,13 +247,13 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ String subject = ""; for (NotificationMessages notificationMessage : notificationMessages) { - if (DeviceManagementConstants.EmailNotifications.ENROL_NOTIFICATION_TYPE. - equals(notificationMessage.getType())) { + if (org.wso2.carbon.device.mgt.core.DeviceManagementConstants.EmailNotifications.ENROL_NOTIFICATION_TYPE.equals( + notificationMessage.getType())) { messageHeader = notificationMessage.getHeader(); messageBody = notificationMessage.getBody(); messageFooter1 = notificationMessage.getFooterLine1(); messageFooter2 = notificationMessage.getFooterLine2(); - messageFooter3 = notificationMessage.getFooterLine3(); + messageFooter3 = notificationMessage.getFooterLine3(); url = notificationMessage.getUrl(); subject = notificationMessage.getSubject(); break; @@ -286,7 +268,7 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ EmailConstants.EnrolmentEmailConstants.ENCODED_SCHEME)); messageBody = messageBody.trim() + System.getProperty("line.separator") + System.getProperty("line.separator") + url.replaceAll("\\{" - + EmailConstants.EnrolmentEmailConstants.DOWNLOAD_URL + "\\}", + + EmailConstants.EnrolmentEmailConstants.DOWNLOAD_URL + "\\}", URLDecoder.decode(emailMessageProperties.getEnrolmentUrl(), EmailConstants.EnrolmentEmailConstants.ENCODED_SCHEME)); @@ -322,7 +304,7 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ String subject = ""; for (NotificationMessages notificationMessage : notificationMessages) { - if (DeviceManagementConstants.EmailNotifications.USER_REGISTRATION_NOTIFICATION_TYPE. + if (org.wso2.carbon.device.mgt.core.DeviceManagementConstants.EmailNotifications.USER_REGISTRATION_NOTIFICATION_TYPE. equals(notificationMessage.getType())) { messageHeader = notificationMessage.getHeader(); messageBody = notificationMessage.getBody(); @@ -343,8 +325,8 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ EmailConstants.EnrolmentEmailConstants.ENCODED_SCHEME)); messageBody = messageBody.trim().replaceAll("\\{" + EmailConstants.EnrolmentEmailConstants - .USERNAME - + "\\}", + .USERNAME + + "\\}", URLEncoder.encode(emailMessageProperties.getUserName(), EmailConstants.EnrolmentEmailConstants .ENCODED_SCHEME)); @@ -353,7 +335,7 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ .ENCODED_SCHEME)); messageBody = messageBody + System.getProperty("line.separator") + url.replaceAll("\\{" - + EmailConstants.EnrolmentEmailConstants.DOWNLOAD_URL + "\\}", + + EmailConstants.EnrolmentEmailConstants.DOWNLOAD_URL + "\\}", URLDecoder.decode(emailMessageProperties.getEnrolmentUrl(), EmailConstants.EnrolmentEmailConstants.ENCODED_SCHEME)); @@ -467,7 +449,7 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ @Override public void updateOperation(DeviceIdentifier deviceId, int operationId, Operation.Status operationStatus) throws OperationManagementException { - DeviceManagementDataHolder.getInstance().getOperationManager().updateOperation(deviceId,operationId, + DeviceManagementDataHolder.getInstance().getOperationManager().updateOperation(deviceId, operationId, operationStatus); } @@ -485,7 +467,7 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ @Override public List getOperationsByDeviceAndStatus(DeviceIdentifier identifier, - Operation.Status status) throws OperationManagementException, DeviceManagementException { + Operation.Status status) throws OperationManagementException, DeviceManagementException { return DeviceManagementDataHolder.getInstance().getOperationManager().getOperationsByDeviceAndStatus(identifier, status); } @@ -499,7 +481,7 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ public List getAllDevicesOfUser(String userName) throws DeviceManagementException { List devicesOfUser = new ArrayList(); - List devicesList; + List devices; Device convertedDevice; DeviceIdentifier deviceIdentifier; DeviceManager dms; @@ -508,15 +490,15 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ int tenantId = DeviceManagerUtil.getTenantId(); //Fetch the DeviceList from Core try { - devicesList = this.getDeviceDAO().getDeviceListOfUser(userName, tenantId); + devices = this.getDeviceDAO().getDeviceListOfUser(userName, tenantId); } catch (DeviceManagementDAOException e) { throw new DeviceManagementException("Error occurred while obtaining the devices of user '" + userName + "'", e); } //Fetch the DeviceList from device plugin dbs & append the properties - for (int x = 0; x < devicesList.size(); x++) { - device = devicesList.get(x); + for (org.wso2.carbon.device.mgt.core.dto.Device aDevicesList : devices) { + device = aDevicesList; try { //TODO : Possible improvement if DeviceTypes have been cached device.setDeviceType(deviceTypeDAO.getDeviceType(device.getDeviceTypeId())); @@ -620,7 +602,7 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ devicesList = this.getDeviceDAO().getDevicesByName(deviceName, tenantId); } catch (DeviceManagementDAOException e) { throw new DeviceManagementException("Error occurred while fetching the list of devices that matches to '" - + deviceName + "'", e); + + deviceName + "'", e); } for (int x = 0; x < devicesList.size(); x++) { @@ -640,7 +622,7 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ devicesOfUser.add(convertedDevice); } catch (DeviceManagementDAOException e) { log.error("Error occurred while obtaining the device type of DeviceTypeId '" + - device.getDeviceTypeId() + "'", e); + device.getDeviceTypeId() + "'", e); } } return devicesOfUser; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementServiceImpl.java deleted file mode 100644 index f79ebf0981..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementServiceImpl.java +++ /dev/null @@ -1,224 +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.service; - -import org.wso2.carbon.device.mgt.common.*; -import org.wso2.carbon.device.mgt.common.license.mgt.License; -import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException; -import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; -import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; -import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; - -import java.util.List; - -public class DeviceManagementServiceImpl implements DeviceManagementService { - - @Override - public String getProviderType() { - return null; - } - - @Override - public FeatureManager getFeatureManager() { - return null; - } - - @Override - public boolean enrollDevice(Device device) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().enrollDevice(device); - } - - @Override - public boolean modifyEnrollment(Device device) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().modifyEnrollment(device); - } - - @Override - public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().disenrollDevice(deviceId); - } - - @Override - public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().isEnrolled(deviceId); - } - - @Override - public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().isActive(deviceId); - } - - @Override - public boolean setActive(DeviceIdentifier deviceId, boolean status) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().setActive(deviceId, status); - } - - @Override - public List getAllDevices() throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getAllDevices(); - } - - @Override - public List getAllDevices(String type) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getAllDevices(type); - } - - public List getDeviceListOfUser(String username) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getDeviceListOfUser(username); - } - - public FeatureManager getFeatureManager(String type) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getFeatureManager(type); - } - - @Override - public Device getCoreDevice(DeviceIdentifier deviceId) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getCoreDevice(deviceId); - } - - @Override - public org.wso2.carbon.device.mgt.common.Device getDevice(DeviceIdentifier deviceId) - throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getDevice(deviceId); - } - - @Override - public boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider(). - updateDeviceInfo(deviceIdentifier, device); - - } - - @Override - public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().setOwnership(deviceId, - ownershipType); - } - - @Override - public boolean isClaimable(DeviceIdentifier deviceId) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().isClaimable(deviceId); - } - - @Override - public License getLicense(String deviceType, String languageCode) throws LicenseManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getLicense(deviceType, - languageCode); - } - - @Override - public boolean addLicense(String type, License license) throws LicenseManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().addLicense(type, license); - } - - @Override - public boolean addOperation(Operation operation, List devices) - throws OperationManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().addOperation(operation, devices); - } - - @Override - public List getOperations(DeviceIdentifier deviceId) throws OperationManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getOperations(deviceId); - } - - @Override - public List getPendingOperations( - DeviceIdentifier deviceId) throws OperationManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getPendingOperations(deviceId); - } - - @Override - public Operation getNextPendingOperation(DeviceIdentifier deviceId) throws OperationManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getNextPendingOperation(deviceId); - } - - @Override - public void updateOperation(DeviceIdentifier deviceId, int operationId, Operation.Status operationStatus) throws - OperationManagementException { - DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().updateOperation(deviceId, operationId, - operationStatus); - } - - @Override - public void deleteOperation(int operationId) throws OperationManagementException { - DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().deleteOperation(operationId); - } - - @Override - public Operation getOperationByDeviceAndOperationId(DeviceIdentifier deviceId, - int operationId) throws OperationManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider() - .getOperationByDeviceAndOperationId(deviceId, operationId); - } - - @Override - public List getOperationsByDeviceAndStatus(DeviceIdentifier identifier, - Operation.Status status) throws OperationManagementException, DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getOperationsByDeviceAndStatus - (identifier, status); - } - - @Override - public Operation getOperation(int operationId) throws OperationManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getOperation(operationId); - } - - - @Override - public void sendEnrolmentInvitation(EmailMessageProperties emailMessageProperties) - throws DeviceManagementException { - DeviceManagementDataHolder.getInstance().getDeviceManagementProvider() - .sendEnrolmentInvitation(emailMessageProperties); - } - - @Override - public void sendRegistrationEmail(EmailMessageProperties emailMessageProperties) throws DeviceManagementException { - DeviceManagementDataHolder.getInstance().getDeviceManagementProvider() - .sendRegistrationEmail(emailMessageProperties); - } - - @Override - public List getAllDevicesOfUser(String userName) - throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider() - .getAllDevicesOfUser(userName); - } - - @Override - public List getAllDevicesOfRole(String roleName) - throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider() - .getAllDevicesOfRole(roleName); - } - - @Override - public int getDeviceCount() throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider() - .getDeviceCount(); - } - - @Override - public List getDevicesByName(String deviceName, int tenantId) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider() - .getDevicesByName(deviceName, tenantId); - } - - - -} 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 index fdfd98ed28..10c7563253 100644 --- 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 @@ -21,8 +21,8 @@ import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.spi.DeviceManager; -import org.wso2.carbon.device.mgt.common.spi.DeviceMgtService; +import org.wso2.carbon.device.mgt.common.DeviceManager; +import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; public class DeviceManagementRepositoryTests { @@ -35,7 +35,7 @@ public class DeviceManagementRepositoryTests { @Test public void testAddDeviceManagementService() { - DeviceMgtService sourceProvider = new TestDeviceManager(); + DeviceManagementService sourceProvider = new TestDeviceManager(); try { this.getRepository().addDeviceManagementProvider(sourceProvider); } catch (DeviceManagementException e) { @@ -48,7 +48,7 @@ public class DeviceManagementRepositoryTests { @Test(dependsOnMethods = "testAddDeviceManagementService") public void testRemoveDeviceManagementService() { - DeviceMgtService sourceProvider = new TestDeviceManager(); + DeviceManagementService sourceProvider = new TestDeviceManager(); try { this.getRepository().removeDeviceManagementProvider(sourceProvider); } catch (DeviceManagementException e) { 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 index 2772ac8ee9..b55cc7b556 100644 --- 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 @@ -31,6 +31,7 @@ import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation; import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerImpl; import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory; +import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl; import java.util.ArrayList; import java.util.List; @@ -59,7 +60,7 @@ public class DeviceOperationManagementTests extends DeviceManagementBaseTest { private void initOperationManager() { this.operationManager = new OperationManagerImpl(); - DeviceManagementDataHolder.getInstance().setDeviceManagementProvider(new DeviceManagementServiceProviderImpl()); + DeviceManagementDataHolder.getInstance().setDeviceManagementProvider(new DeviceManagementProviderServiceImpl()); } @Test diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManager.java index 4812e6cd08..3d8f36df2b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManager.java @@ -18,13 +18,16 @@ package org.wso2.carbon.device.mgt.core; import org.wso2.carbon.device.mgt.common.*; -import org.wso2.carbon.device.mgt.common.app.mgt.AppManagerConnectorException; +import org.wso2.carbon.device.mgt.common.app.mgt.Application; +import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; -import org.wso2.carbon.device.mgt.common.spi.DeviceMgtService; +import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager; +import org.wso2.carbon.device.mgt.common.DeviceManager; +import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; import java.util.List; -public class TestDeviceManager implements DeviceMgtService { +public class TestDeviceManager implements DeviceManagementService { public static final String DEVICE_TYPE_TEST = "Test"; @@ -93,9 +96,27 @@ public class TestDeviceManager implements DeviceMgtService { return false; } + @Override + public Application[] getApplications(String domain, int pageNumber, + int size) throws ApplicationManagementException { + return new Application[0]; + } + + @Override + public void updateApplicationStatus(DeviceIdentifier deviceId, Application application, + String status) throws ApplicationManagementException { + + } + + @Override + public String getApplicationStatus(DeviceIdentifier deviceId, + Application application) throws ApplicationManagementException { + return null; + } + @Override public void installApplication(Operation operation, List deviceIdentifiers) - throws AppManagerConnectorException { + throws ApplicationManagementException { } } diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyInformationPointImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyInformationPointImpl.java index b80854b798..aa4482e5f4 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyInformationPointImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyInformationPointImpl.java @@ -25,7 +25,7 @@ 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.dto.DeviceType; -import org.wso2.carbon.device.mgt.core.service.DeviceManagementService; +import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.common.Feature; import org.wso2.carbon.policy.mgt.common.*; import org.wso2.carbon.policy.mgt.core.internal.PolicyManagementDataHolder; @@ -46,7 +46,7 @@ public class PolicyInformationPointImpl implements PolicyInformationPoint { PolicyManager policyManager; FeatureManager featureManager; - DeviceManagementService deviceManagementService; + DeviceManagementProviderService deviceManagementService; public PolicyInformationPointImpl() { deviceManagementService = @@ -143,7 +143,7 @@ public class PolicyInformationPointImpl implements PolicyInformationPoint { return finalPolicies; } - private DeviceManagementService getDeviceManagementService() { + private DeviceManagementProviderService getDeviceManagementService() { return PolicyManagementDataHolder.getInstance().getDeviceManagementService(); } 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 index be2cb8a62f..506488f762 100644 --- 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 @@ -18,7 +18,7 @@ package org.wso2.carbon.policy.mgt.core.internal; -import org.wso2.carbon.device.mgt.core.service.DeviceManagementService; +import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.policy.mgt.common.PolicyEvaluationPoint; import org.wso2.carbon.policy.mgt.common.PolicyInformationPoint; import org.wso2.carbon.user.core.service.RealmService; @@ -30,7 +30,7 @@ public class PolicyManagementDataHolder { private TenantManager tenantManager; private PolicyEvaluationPoint policyEvaluationPoint; private PolicyInformationPoint policyInformationPoint; - private DeviceManagementService deviceManagementService; + private DeviceManagementProviderService deviceManagementService; private static PolicyManagementDataHolder thisInstance = new PolicyManagementDataHolder(); private PolicyManagementDataHolder() {} @@ -75,11 +75,11 @@ public class PolicyManagementDataHolder { this.policyInformationPoint = policyInformationPoint; } - public DeviceManagementService getDeviceManagementService() { + public DeviceManagementProviderService getDeviceManagementService() { return deviceManagementService; } - public void setDeviceManagementService(DeviceManagementService deviceManagementService) { + public void setDeviceManagementService(DeviceManagementProviderService deviceManagementService) { this.deviceManagementService = deviceManagementService; } } 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 index fcf9247d03..c0f8450ac1 100644 --- 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 @@ -21,7 +21,7 @@ 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.device.mgt.core.service.DeviceManagementService; +import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.policy.mgt.common.PolicyEvaluationPoint; import org.wso2.carbon.policy.mgt.core.PolicyManagerService; import org.wso2.carbon.policy.mgt.core.PolicyManagerServiceImpl; @@ -46,7 +46,7 @@ import org.wso2.carbon.user.core.service.RealmService; * bind="setPEPService" * unbind="unsetPEPService" * @scr.reference name="org.wso2.carbon.device.manager" - * interface="org.wso2.carbon.device.mgt.core.service.DeviceManagementService" + * interface="org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService" * cardinality="1..1" * policy="dynamic" * bind="setDeviceManagementService" @@ -129,14 +129,14 @@ public class PolicyManagementServiceComponent { PolicyManagementDataHolder.getInstance().setPolicyEvaluationPoint(null); } - protected void setDeviceManagementService(DeviceManagementService deviceManagerService) { + protected void setDeviceManagementService(DeviceManagementProviderService deviceManagerService) { if (log.isDebugEnabled()) { log.debug("Setting Device Management Service"); } PolicyManagementDataHolder.getInstance().setDeviceManagementService(deviceManagerService); } - protected void unsetDeviceManagementService(DeviceManagementService deviceManagementService) { + protected void unsetDeviceManagementService(DeviceManagementProviderService deviceManagementService) { if (log.isDebugEnabled()) { log.debug("Unsetting Device Management Service"); }