From ee76f6cb0fc0f738fc9c57ff0b0e869aead4b576 Mon Sep 17 00:00:00 2001 From: amalhub Date: Wed, 6 Sep 2017 09:07:23 +0530 Subject: [PATCH] Adding app-mgt store interface methods and implementations --- .../impl/SubscriptionManagementAPIImpl.java | 8 +++++++ .../common/services/SubscriptionManager.java | 18 +++++++++++++++ .../core/impl/SubscriptionManagerImpl.java | 22 ++++++++++++++++++- 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/SubscriptionManagementAPIImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/SubscriptionManagementAPIImpl.java index 8a6040b385..e5128e1388 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/SubscriptionManagementAPIImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/SubscriptionManagementAPIImpl.java @@ -52,6 +52,14 @@ public class SubscriptionManagementAPIImpl implements SubscriptionManagementAPI{ if (!installationDetails.getDeviceIdentifiers().isEmpty()) { List deviceList = installationDetails.getDeviceIdentifiers(); response = subscriptionManager.installApplicationForDevices(applicationUUTD, deviceList); + } else if (!installationDetails.getUserNameList().isEmpty()) { + List userList = installationDetails.getUserNameList(); + response = subscriptionManager.installApplicationForUsers(applicationUUTD, userList); + } else if (!installationDetails.getRoleNameList().isEmpty()) { + List roleList = installationDetails.getRoleNameList(); + response = subscriptionManager.installApplicationForRoles(applicationUUTD, roleList); + } else { + response = "Missing request data!"; } return Response.status(Response.Status.OK).entity(response).build(); } catch (ApplicationManagementException e) { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/SubscriptionManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/SubscriptionManager.java index 16647e41d3..cb555606d9 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/SubscriptionManager.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/SubscriptionManager.java @@ -36,6 +36,24 @@ public interface SubscriptionManager { */ List installApplicationForDevices(String applicationUUID, List deviceList) throws ApplicationManagementException; + /** + * To install an application to given list of users. + * @param applicationUUID Application ID + * @param userList User list + * @return User list which the application has been installed + * @throws ApplicationManagementException Application Management Exception + */ + List installApplicationForUsers(String applicationUUID, List userList) throws ApplicationManagementException; + + /** + * To install an application to given list of users. + * @param applicationUUID Application ID + * @param roleList Role list + * @return Role list which the application has been installed + * @throws ApplicationManagementException Application Management Exception + */ + List installApplicationForRoles(String applicationUUID, List roleList) throws ApplicationManagementException; + /** * To uninstall an application from a given list of devices. * @param applicationUUID Application ID diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java index 621e0d2642..29adbbab6c 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -34,11 +34,31 @@ public class SubscriptionManagerImpl implements SubscriptionManager { log.info("Install application: " + applicationUUID + " to: " + deviceList.size() + " devices."); for (DeviceIdentifier device : deviceList) { String deviceId = device.getId(); - + //Todo: implementation, validations + //Todo: generating one time download link for the application and put install operation to device. + //Todo: Store the mappings in DB. } return deviceList; } + @Override + public List installApplicationForUsers(String applicationUUID, List userList) throws ApplicationManagementException { + log.info("Install application: " + applicationUUID + " to: " + userList.size() + " users."); + for (String user : userList) { + //Todo: implementation + } + return userList; + } + + @Override + public List installApplicationForRoles(String applicationUUID, List roleList) throws ApplicationManagementException { + log.info("Install application: " + applicationUUID + " to: " + roleList.size() + " users."); + for (String role : roleList) { + //Todo: implementation + } + return roleList; + } + @Override public List uninstallApplication(String applicationUUID, List deviceList) throws ApplicationManagementException { return null;