From 3589804ede179af57591596495031f8326268727 Mon Sep 17 00:00:00 2001 From: manoj Date: Mon, 18 May 2015 02:31:10 +0530 Subject: [PATCH] Installation APP service --- .../mgt/common/app/mgt/AppManagerConnector.java | 1 + .../device/mgt/common/spi/DeviceManager.java | 7 ++----- .../DeviceManagementServiceProviderImpl.java | 4 ++-- .../core/app/mgt/AppManagementServiceImpl.java | 17 ++++++++++++++--- .../service/DeviceManagementServiceImpl.java | 5 +++-- .../device/mgt/core/TestDeviceManager.java | 2 +- 6 files changed, 23 insertions(+), 13 deletions(-) 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 index 7a0b0ead5a..07ab27e61a 100644 --- 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 @@ -19,6 +19,7 @@ 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; 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/spi/DeviceManager.java index b90d04f550..aeb84c669e 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/spi/DeviceManager.java @@ -18,10 +18,7 @@ package org.wso2.carbon.device.mgt.common.spi; -import org.wso2.carbon.device.mgt.common.Device; -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.FeatureManager; +import org.wso2.carbon.device.mgt.common.*; import java.util.List; @@ -124,7 +121,7 @@ public interface DeviceManager { * @param device Updated device information related data * @throws DeviceManagementException If some unusual behaviour is observed while updating the device info */ - boolean updateDeviceInfo(Device device) throws DeviceManagementException; + boolean updateDeviceInfo(Device device, List applicationList) throws DeviceManagementException; /** * Method to set the ownership type of a particular device. i.e. BYOD, COPE. 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/DeviceManagementServiceProviderImpl.java index de39d9fbf3..71855742e0 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/DeviceManagementServiceProviderImpl.java @@ -378,10 +378,10 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ } @Override - public boolean updateDeviceInfo(Device device) throws DeviceManagementException { + public boolean updateDeviceInfo(Device device, List applicationList) throws DeviceManagementException { DeviceManager dms = this.getPluginRepository().getDeviceManagementProvider(device.getType()); - return dms.updateDeviceInfo(device); + return dms.updateDeviceInfo(device,applicationList); } @Override 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/AppManagementServiceImpl.java index ca774b901b..170134ee0d 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/AppManagementServiceImpl.java @@ -17,18 +17,21 @@ */ package org.wso2.carbon.device.mgt.core.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.DeviceIdentifier; +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.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 { + private static final Log log = LogFactory.getLog(AppManagementServiceImpl.class); @Override public Application[] getApplicationList(String domain, int pageNumber, int size) throws AppManagerConnectorException { return DeviceManagementDataHolder.getInstance().getAppManager().getApplicationList(domain, pageNumber, size); @@ -55,6 +58,14 @@ public class AppManagementServiceImpl implements AppManagerConnector { @Override public void installApplication(Operation operation, List deviceIdentifiers) throws AppManagerConnectorException { + 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(); + } 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/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 index 582fbe7214..56cf5d5a12 100644 --- 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 @@ -98,8 +98,9 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { } @Override - public boolean updateDeviceInfo(Device device) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().updateDeviceInfo(device); + public boolean updateDeviceInfo(Device device, List applicationList) throws DeviceManagementException { + return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider(). + updateDeviceInfo(device, applicationList); } @Override 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 f0d64f389a..24bd9f77f3 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 @@ -79,7 +79,7 @@ public class TestDeviceManager implements DeviceMgtService { } @Override - public boolean updateDeviceInfo(Device device) throws DeviceManagementException { + public boolean updateDeviceInfo(Device device, sList applicationList) throws DeviceManagementException { return false; }