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 7a0b0ead5a2..07ab27e61a9 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 b90d04f550c..aeb84c669e5 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 db05ae66b3c..0463c16d531 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 @@ -571,4 +571,4 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ } return devicesOfRole; } -} \ No newline at end of file +} 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 ca774b901b7..170134ee0d0 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 a0c363854df..621cea3669f 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 f0d64f389af..ea8ad2e2f9b 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, List applicationList) throws DeviceManagementException { return false; }