From e41742b7779d40ed49f5903fc4c0eccd74b32701 Mon Sep 17 00:00:00 2001 From: lasanthaDLPDS Date: Wed, 29 May 2019 15:32:40 +0530 Subject: [PATCH] Improve app subscription functionality Further integrate app management component with device mgt --- .../mgt/common/AndroidApplication.java | 51 ----- .../ApplicationReleaseArtifactPaths.java | 42 ---- .../application/mgt/common/SubAction.java | 22 +++ .../common/services/SubscriptionManager.java | 4 +- .../mgt/core/impl/ApplicationManagerImpl.java | 2 +- .../core/impl/SubscriptionManagerImpl.java | 179 +++++++++++------- .../react-app/.env | 0 .../services/SubscriptionManagementAPI.java | 10 +- .../admin/ReviewManagementAdminAPI.java | 2 +- .../impl/SubscriptionManagementAPIImpl.java | 9 +- .../jaxrs/util/MDMAndroidOperationUtil.java | 8 +- .../mgt/jaxrs/util/MDMIOSOperationUtil.java | 8 +- .../app/mgt}/android/AppStoreApplication.java | 2 +- .../mgt}/android/EnterpriseApplication.java | 2 +- .../app/mgt}/android/WebApplication.java | 2 +- .../app/mgt}/ios/AppStoreApplication.java | 2 +- .../app/mgt}/ios/EnterpriseApplication.java | 2 +- .../app/mgt}/ios/RemoveApplication.java | 2 +- .../mgt/common/app/mgt}/ios/WebClip.java | 2 +- 19 files changed, 165 insertions(+), 186 deletions(-) delete mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/AndroidApplication.java delete mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/ApplicationReleaseArtifactPaths.java create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/SubAction.java delete mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/.env rename components/device-mgt/{org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans => org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt}/android/AppStoreApplication.java (95%) rename components/device-mgt/{org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans => org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt}/android/EnterpriseApplication.java (96%) rename components/device-mgt/{org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans => org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt}/android/WebApplication.java (95%) rename components/device-mgt/{org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans => org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt}/ios/AppStoreApplication.java (97%) rename components/device-mgt/{org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans => org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt}/ios/EnterpriseApplication.java (97%) rename components/device-mgt/{org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans => org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt}/ios/RemoveApplication.java (95%) rename components/device-mgt/{org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans => org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt}/ios/WebClip.java (96%) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/AndroidApplication.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/AndroidApplication.java deleted file mode 100644 index 139c74b79b0..00000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/AndroidApplication.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2018, 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.application.mgt.common; - -import com.google.gson.Gson; -import org.wso2.carbon.device.application.mgt.common.exception.DeviceConnectorException; - -public class AndroidApplication { - private String type; - private String appIdentifier; - - private static final long serialVersionUID = 760343716452548282L; - - public String getAppIdentifier() { - return appIdentifier; - } - - public void setAppIdentifier(String appIdentifier) { - this.appIdentifier = appIdentifier; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String toJSON() throws DeviceConnectorException { - Gson gson = new Gson(); - return gson.toJson(this); - } - -} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/ApplicationReleaseArtifactPaths.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/ApplicationReleaseArtifactPaths.java deleted file mode 100644 index 8692d7d11f2..00000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/ApplicationReleaseArtifactPaths.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.wso2.carbon.device.application.mgt.common;/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. - * - * Entgra (Pvt) Ltd. 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. - */ - -import java.util.List; - -public class ApplicationReleaseArtifactPaths { - - private String installerPath; - private String iconPath; - private String bannerPath; - private List screenshotPaths; - - public String getInstallerPath() { return installerPath; } - - public void setInstallerPath(String installerPath) { this.installerPath = installerPath; } - - public String getIconPath() { return iconPath; } - - public void setIconPath(String iconPath) { this.iconPath = iconPath; } - - public String getBannerPath() { return bannerPath; } - - public void setBannerPath(String bannerPath) { this.bannerPath = bannerPath; } - - public List getScreenshotPaths() { return screenshotPaths; } - - public void setScreenshotPaths(List screenshotPaths) { this.screenshotPaths = screenshotPaths; } -} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/SubAction.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/SubAction.java new file mode 100644 index 00000000000..fde06081efd --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/SubAction.java @@ -0,0 +1,22 @@ +/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. 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.application.mgt.common; + +public enum SubAction { + INSTALL, UNINSTALL +} 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 1a21c601832..1f0e86b5842 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 @@ -39,8 +39,8 @@ public interface SubscriptionManager { ApplicationInstallResponse installApplicationForDevices(String applicationUUID, List deviceList) throws ApplicationManagementException; - ApplicationInstallResponse addBulkApInstallation(String applicationUUID, List subscriberList, - String subType) throws ApplicationManagementException; + ApplicationInstallResponse performBulkAppInstallation(String applicationUUID, List params, String subType) + throws ApplicationManagementException; /** * To install an application to given list of users. diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java index 21f4331363f..e458bbf5a26 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java @@ -619,7 +619,7 @@ public class ApplicationManagerImpl implements ApplicationManager { @Override public ApplicationList getApplications(Filter filter) throws ApplicationManagementException { - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); ApplicationList applicationList = new ApplicationList(); List appDTOs; 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 2288f30310c..7dabbe941ce 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 @@ -24,6 +24,8 @@ import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.application.mgt.common.AppOperation; import org.wso2.carbon.device.application.mgt.common.ApplicationInstallResponse; import org.wso2.carbon.device.application.mgt.common.ApplicationType; +import org.wso2.carbon.device.application.mgt.common.DeviceTypes; +import org.wso2.carbon.device.application.mgt.common.SubAction; import org.wso2.carbon.device.application.mgt.common.SubsciptionType; import org.wso2.carbon.device.application.mgt.common.SubscribingDeviceIdHolder; import org.wso2.carbon.device.application.mgt.common.dto.ApplicationDTO; @@ -65,6 +67,7 @@ import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService; import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -87,7 +90,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { this.applicationDAO = ApplicationManagementDAOFactory.getApplicationDAO(); } - @Override public ApplicationInstallResponse installApplicationForDevices(String applicationUUID, + @Override + public ApplicationInstallResponse installApplicationForDevices(String applicationUUID, List deviceIdentifiers) throws ApplicationManagementException { if (log.isDebugEnabled()) { log.debug("Install application which has UUID: " + applicationUUID + " to " + deviceIdentifiers.size() @@ -99,102 +103,94 @@ public class SubscriptionManagerImpl implements SubscriptionManager { log.error(msg); throw new BadRequestException(msg); } - DeviceManagementProviderService deviceManagementProviderService = HelperUtil - .getDeviceManagementProviderService(); ApplicationDTO applicationDTO = getApplicationDTO(applicationUUID); DeviceIDHolder filteredDeviceHolder = filterDeviceIdentifiers(applicationDTO, deviceIdentifiers); List errorDeviceIdentifiers = filteredDeviceHolder.getErrorDeviceIdList(); - List filteredDeviceObjs = new ArrayList<>(); - - //getting device objects by using device identifiers - for (DeviceIdentifier deviceIdentifier : filteredDeviceHolder.getValidDeviceIDList()) { - try { - Device device = deviceManagementProviderService.getDevice(deviceIdentifier, false); - if (device == null) { - String msg = "Couldn't found an device for device identifier " + deviceIdentifier.getId() - + " and device type: " + deviceIdentifier.getType(); - log.warn(msg); - errorDeviceIdentifiers.add(deviceIdentifier); - } else { - filteredDeviceObjs.add(device); - } - } catch (DeviceManagementException e) { - String msg = "Error occurred when getting device data for device identifier " + deviceIdentifier.getId() - + " and device type " + deviceIdentifier.getType(); - log.warn(msg); - errorDeviceIdentifiers.add(deviceIdentifier); - throw new ApplicationManagementException(msg, e); - } - } - - if (!ApplicationType.WEB_CLIP.toString().equals(applicationDTO.getType())) { - DeviceType deviceType = APIUtil.getDeviceTypeData(applicationDTO.getDeviceTypeId()); - String deviceTypeName = deviceType.getName(); - ApplicationInstallResponse applicationInstallResponse = installToDevices(deviceTypeName, filteredDeviceObjs, - applicationDTO, SubsciptionType.DEVICE.toString(), null); - applicationInstallResponse.setErrorDevices(errorDeviceIdentifiers); - return applicationInstallResponse; - } else { - //todo improve thos - ApplicationInstallResponse applicationInstallResponse = installToDevices(null, filteredDeviceObjs, - applicationDTO, SubsciptionType.DEVICE.toString(), null); - applicationInstallResponse.setErrorDevices(errorDeviceIdentifiers); - return applicationInstallResponse; - } + ApplicationInstallResponse applicationInstallResponse = performBulkAppInstallation(applicationUUID, + filteredDeviceHolder.getValidDeviceIDList(), SubsciptionType.DEVICE.toString()); + applicationInstallResponse.setErrorDevices(errorDeviceIdentifiers); + return applicationInstallResponse; } + @Override - public ApplicationInstallResponse addBulkApInstallation(String applicationUUID, List subscriberList, + public ApplicationInstallResponse performBulkAppInstallation(String applicationUUID, List params, String subType) throws ApplicationManagementException { if (log.isDebugEnabled()) { - log.debug("Install application release which has UUID " + applicationUUID + " to " + subscriberList.size() + log.debug("Install application release which has UUID " + applicationUUID + " to " + params.size() + " users."); } - try { - if (subscriberList.isEmpty()) { - String msg = "In order to install application release which has UUID " + applicationUUID + ", you shou" - + "ld provide list of subscribers. But found an empty list of users."; + if (params.isEmpty()) { + String msg = "In order to install application release which has UUID " + applicationUUID + ", you should" + + " provide list of subscribers. But found an empty list of users."; log.error(msg); throw new BadRequestException(msg); } - if (SubsciptionType.USER.toString().equals(subType) && !SubsciptionType.ROLE.toString().equals(subType) - && SubsciptionType.GROUP.toString().equals(subType)) { + + boolean isValidSubType = Arrays.stream(SubsciptionType.values()) + .anyMatch(sub -> sub.name().equalsIgnoreCase(subType)); + if (!isValidSubType) { String msg = "Found invalid subscription type to install application release witch has UUID: " + applicationUUID + ". Subscription type is " + subType; log.error(msg); throw new BadRequestException(msg); } - ApplicationDTO applicationDTO = getApplicationDTO(applicationUUID); DeviceManagementProviderService deviceManagementProviderService = HelperUtil .getDeviceManagementProviderService(); GroupManagementProviderService groupManagementProviderService = HelperUtil .getGroupManagementProviderService(); List filteredDevices = new ArrayList<>(); - List subscriberDevices = new ArrayList<>(); - for (String subscriber : subscriberList) { - if (SubsciptionType.USER.toString().equals(subType)) { - subscriberDevices.addAll(deviceManagementProviderService.getDevicesOfUser(subscriber)); - } else if (SubsciptionType.ROLE.toString().equals(subType)) { - subscriberDevices.addAll(deviceManagementProviderService.getAllDevicesOfRole(subscriber)); - } else if (SubsciptionType.GROUP.toString().equals(subType)) { - subscriberDevices.addAll(groupManagementProviderService.getAllDevicesOfGroup(subscriber)); + List devices = new ArrayList<>(); + List subscribers = new ArrayList<>(); + + ApplicationDTO applicationDTO = getApplicationDTO(applicationUUID); + + if (SubsciptionType.DEVICE.toString().equals(subType)) { + for (T param : params) { + DeviceIdentifier deviceIdentifier = (DeviceIdentifier) param; + devices.add(deviceManagementProviderService.getDevice(deviceIdentifier, false)); + } + } else if (SubsciptionType.USER.toString().equals(subType)) { + for (T param : params) { + String username = (String) param; + subscribers.add(username); + devices.addAll(deviceManagementProviderService.getDevicesOfUser(username)); + } + } else if (SubsciptionType.ROLE.toString().equals(subType)) { + for (T param : params) { + String roleName = (String) param; + subscribers.add(roleName); + devices.addAll(deviceManagementProviderService.getAllDevicesOfRole(roleName)); + } + } else if (SubsciptionType.GROUP.toString().equals(subType)) { + for (T param : params) { + String groupName = (String) param; + subscribers.add(groupName); + devices.addAll(groupManagementProviderService.getAllDevicesOfGroup(groupName)); } } if (!ApplicationType.WEB_CLIP.toString().equals(applicationDTO.getType())) { DeviceType deviceType = APIUtil.getDeviceTypeData(applicationDTO.getDeviceTypeId()); String deviceTypeName = deviceType.getName(); - for (Device device : subscriberDevices) { + for (Device device : devices) { if (deviceTypeName.equals(device.getType())) { filteredDevices.add(device); } } - return installToDevices(deviceTypeName, filteredDevices, applicationDTO, subType, subscriberList); +// if (SubsciptionType.DEVICE.toString().equals(subType)) { +// return installToDevices(deviceTypeName, filteredDevices, applicationDTO, subType, null); +// +// } + return installToDevices(deviceTypeName, filteredDevices, applicationDTO, subType, subscribers); } else { //todo improve this - return installToDevices(null, subscriberDevices, applicationDTO, subType, subscriberList); +// if (SubsciptionType.DEVICE.toString().equals(subType)) { +// return installToDevices(null, filteredDevices, applicationDTO, subType, null); +// } + return installToDevices(null, devices, applicationDTO, subType, subscribers); } } catch (DeviceManagementException e) { String msg = "Error occurred while getting devices of given users or given roles."; @@ -207,6 +203,12 @@ public class SubscriptionManagerImpl implements SubscriptionManager { } } + @Override + public List uninstallApplication(String applicationUUID, + List deviceList) throws ApplicationManagementException { + return null; + } + private ApplicationInstallResponse installToDevices(String deviceType, List devices, ApplicationDTO applicationDTO, String subType, List subscribers) throws ApplicationManagementException { @@ -566,17 +568,12 @@ public class SubscriptionManagerImpl implements SubscriptionManager { return response; } - @Override public List uninstallApplication(String applicationUUID, - List deviceList) throws ApplicationManagementException { - return null; - } - private Activity addAppInstallOperationToDevices(ApplicationDTO application, List deviceIdentifierList, String deviceType) throws ApplicationManagementException { DeviceManagementProviderService deviceManagementProviderService = HelperUtil .getDeviceManagementProviderService(); try { - Operation operation = generateOperationPayloadByDeviceType(deviceType, application); + Operation operation = generateOperationPayloadByDeviceType(deviceType, application, null); //todo refactor add operation code to get successful operations return deviceManagementProviderService.addOperation(deviceType, operation, deviceIdentifierList); } catch (OperationManagementException e) { @@ -602,7 +599,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { .collect(Collectors.groupingBy(DeviceIdentifier::getType)); for (Map.Entry> entry : deviceTypeIdentifierMap.entrySet()) { - Operation operation = generateOperationPayloadByDeviceType(entry.getKey(), application); + Operation operation = generateOperationPayloadByDeviceType(entry.getKey(), application, null); try { Activity activity = deviceManagementProviderService .addOperation(entry.getKey(), operation, entry.getValue()); @@ -643,11 +640,57 @@ public class SubscriptionManagerImpl implements SubscriptionManager { return response; } - private Operation generateOperationPayloadByDeviceType(String deviceType, ApplicationDTO application) { + private Operation generateOperationPayloadByDeviceType(String deviceType, ApplicationDTO application, String action) { ProfileOperation operation = new ProfileOperation(); operation.setCode(INSTALL_APPLICATION); operation.setType(Operation.Type.PROFILE); +// if (DeviceTypes.ANDROID.toString().equalsIgnoreCase(deviceType)) { +// if (ApplicationType.ENTERPRISE.toString().equalsIgnoreCase(application.getType())) { +// if (SubAction.INSTALL.toString().equalsIgnoreCase(action)) { +// log.error("aaaa"); +// } else if (SubAction.UNINSTALL.toString().equalsIgnoreCase(action)) { +// log.error("aaaa"); +// } +// } else if (ApplicationType.PUBLIC.toString().equalsIgnoreCase(application.getType())) { +// if (SubAction.INSTALL.toString().equalsIgnoreCase(action)) { +// log.error("aaaa"); +// } else if (SubAction.UNINSTALL.toString().equalsIgnoreCase(action)) { +// log.error("aaaa"); +// } +// +// } else if (ApplicationType.WEB_CLIP.toString().equalsIgnoreCase(application.getType())) { +// if (SubAction.INSTALL.toString().equalsIgnoreCase(action)) { +// log.error("aaaa"); +// } else if (SubAction.UNINSTALL.toString().equalsIgnoreCase(action)) { +// log.error("aaaa"); +// } +// } +// } else if (DeviceTypes.IOS.toString().equalsIgnoreCase(deviceType)) { +// if (ApplicationType.ENTERPRISE.toString().equalsIgnoreCase(application.getType())) { +// if (SubAction.INSTALL.toString().equalsIgnoreCase(action)) { +// log.error("aaaa"); +// } else if (SubAction.UNINSTALL.toString().equalsIgnoreCase(action)) { +// log.error("aaaa"); +// } +// } else if (ApplicationType.PUBLIC.toString().equalsIgnoreCase(application.getType())) { +// if (SubAction.INSTALL.toString().equalsIgnoreCase(action)) { +// log.error("aaaa"); +// } else if (SubAction.UNINSTALL.toString().equalsIgnoreCase(action)) { +// log.error("aaaa"); +// } +// } else if (ApplicationType.WEB_CLIP.toString().equalsIgnoreCase()) +// application.getType() { +// if (SubAction.INSTALL.toString().equalsIgnoreCase(action)) { +// log.error("aaaa"); +// } else if (SubAction.UNINSTALL.toString().equalsIgnoreCase(action)) { +// log.error("aaaa"); +// } +// } +// +// } + + //todo: generate operation payload correctly for all types of devices. operation.setPayLoad( "{'type':'enterprise', 'url':'" + application.getApplicationReleaseDTOs().get(0).getInstallerName() diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/.env b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/.env deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/SubscriptionManagementAPI.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/SubscriptionManagementAPI.java index 53e84b37699..8ced8ef49ed 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/SubscriptionManagementAPI.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/SubscriptionManagementAPI.java @@ -129,7 +129,7 @@ public interface SubscriptionManagementAPI { ); @POST - @Path("/install/{uuid}/{subType}") + @Path("/install/{uuid}/{subType}/{action}") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @ApiOperation( @@ -149,7 +149,7 @@ public interface SubscriptionManagementAPI { value = { }) - Response addBulkAppInstalltion( + Response performBulkAppInstallation( @ApiParam( name = "uuid", value = "The application release UUID", @@ -162,6 +162,12 @@ public interface SubscriptionManagementAPI { required = true ) @PathParam("subType") String subType, + @ApiParam( + name = "action", + value = "Performing action.", + required = true + ) + @PathParam("action") String action, @ApiParam( name = "subscribers", value = "Subscriber list of the application release.", diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/admin/ReviewManagementAdminAPI.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/admin/ReviewManagementAdminAPI.java index 765419cf220..471924a1228 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/admin/ReviewManagementAdminAPI.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/admin/ReviewManagementAdminAPI.java @@ -49,7 +49,7 @@ import javax.ws.rs.core.Response; @SwaggerDefinition( info = @Info( version = "1.0.0", - title = "Admin Review Management Admin Service", + title = "Review Management Admin Service", extensions = { @Extension(properties = { @ExtensionProperty(name = "name", value = "ReviewManagementAdminService"), diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/SubscriptionManagementAPIImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/SubscriptionManagementAPIImpl.java index a009b83fa9f..0a50229615b 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/SubscriptionManagementAPIImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/SubscriptionManagementAPIImpl.java @@ -80,14 +80,15 @@ public class SubscriptionManagementAPIImpl implements SubscriptionManagementAPI{ @Override @POST - @Path("/install/{uuid}/{subType}") - public Response addBulkAppInstalltion( + @Path("/install/{uuid}/{subType}/{action}") + public Response performBulkAppInstallation( @PathParam("uuid") String uuid, - @PathParam("uuid") String subType, + @PathParam("subType") String subType, + @PathParam("action") String sction, @Valid List subscribers) { try { SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager(); - ApplicationInstallResponse response = subscriptionManager.addBulkApInstallation(uuid, subscribers, subType); + ApplicationInstallResponse response = subscriptionManager.performBulkAppInstallation(uuid, subscribers, subType); return Response.status(Response.Status.OK).entity(response).build(); } catch (NotFoundException e) { String msg = "Couldn't found an application release for UUID: " + uuid + ". Hence, verify the payload"; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/MDMAndroidOperationUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/MDMAndroidOperationUtil.java index ce04cdc1374..64b215162c3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/MDMAndroidOperationUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/MDMAndroidOperationUtil.java @@ -18,12 +18,12 @@ package org.wso2.carbon.device.mgt.jaxrs.util; -import org.wso2.carbon.device.mgt.jaxrs.beans.MobileApp; -import org.wso2.carbon.device.mgt.jaxrs.beans.android.AppStoreApplication; -import org.wso2.carbon.device.mgt.jaxrs.beans.android.EnterpriseApplication; +import org.wso2.carbon.device.mgt.common.app.mgt.android.AppStoreApplication; +import org.wso2.carbon.device.mgt.common.app.mgt.android.EnterpriseApplication; +import org.wso2.carbon.device.mgt.common.app.mgt.android.WebApplication; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation; -import org.wso2.carbon.device.mgt.jaxrs.beans.android.WebApplication; +import org.wso2.carbon.device.mgt.jaxrs.beans.MobileApp; import org.wso2.carbon.device.mgt.jaxrs.exception.UnknownApplicationTypeException; /** diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/MDMIOSOperationUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/MDMIOSOperationUtil.java index 91ad342e5e8..cebe68a5a54 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/MDMIOSOperationUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/MDMIOSOperationUtil.java @@ -18,11 +18,11 @@ package org.wso2.carbon.device.mgt.jaxrs.util; +import org.wso2.carbon.device.mgt.common.app.mgt.ios.AppStoreApplication; +import org.wso2.carbon.device.mgt.common.app.mgt.ios.EnterpriseApplication; +import org.wso2.carbon.device.mgt.common.app.mgt.ios.RemoveApplication; +import org.wso2.carbon.device.mgt.common.app.mgt.ios.WebClip; import org.wso2.carbon.device.mgt.jaxrs.beans.MobileApp; -import org.wso2.carbon.device.mgt.jaxrs.beans.ios.AppStoreApplication; -import org.wso2.carbon.device.mgt.jaxrs.beans.ios.EnterpriseApplication; -import org.wso2.carbon.device.mgt.jaxrs.beans.ios.RemoveApplication; -import org.wso2.carbon.device.mgt.jaxrs.beans.ios.WebClip; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/android/AppStoreApplication.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/android/AppStoreApplication.java similarity index 95% rename from components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/android/AppStoreApplication.java rename to components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/android/AppStoreApplication.java index 951ab365e2a..50126814ca3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/android/AppStoreApplication.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/android/AppStoreApplication.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.jaxrs.beans.android; +package org.wso2.carbon.device.mgt.common.app.mgt.android; import com.google.gson.Gson; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/android/EnterpriseApplication.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/android/EnterpriseApplication.java similarity index 96% rename from components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/android/EnterpriseApplication.java rename to components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/android/EnterpriseApplication.java index 2bd8633d92d..f087013a186 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/android/EnterpriseApplication.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/android/EnterpriseApplication.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.jaxrs.beans.android; +package org.wso2.carbon.device.mgt.common.app.mgt.android; import com.google.gson.Gson; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/android/WebApplication.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/android/WebApplication.java similarity index 95% rename from components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/android/WebApplication.java rename to components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/android/WebApplication.java index 7cb7243753d..32574292694 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/android/WebApplication.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/android/WebApplication.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.jaxrs.beans.android; +package org.wso2.carbon.device.mgt.common.app.mgt.android; import com.google.gson.Gson; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/ios/AppStoreApplication.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/ios/AppStoreApplication.java similarity index 97% rename from components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/ios/AppStoreApplication.java rename to components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/ios/AppStoreApplication.java index 1925d6db772..23c514710b8 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/ios/AppStoreApplication.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/ios/AppStoreApplication.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.jaxrs.beans.ios; +package org.wso2.carbon.device.mgt.common.app.mgt.ios; import com.google.gson.Gson; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/ios/EnterpriseApplication.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/ios/EnterpriseApplication.java similarity index 97% rename from components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/ios/EnterpriseApplication.java rename to components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/ios/EnterpriseApplication.java index 2ac2879b743..8bf36b46024 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/ios/EnterpriseApplication.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/ios/EnterpriseApplication.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.jaxrs.beans.ios; +package org.wso2.carbon.device.mgt.common.app.mgt.ios; import com.google.gson.Gson; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/ios/RemoveApplication.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/ios/RemoveApplication.java similarity index 95% rename from components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/ios/RemoveApplication.java rename to components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/ios/RemoveApplication.java index 95f85984a07..c723812d48e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/ios/RemoveApplication.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/ios/RemoveApplication.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.jaxrs.beans.ios; +package org.wso2.carbon.device.mgt.common.app.mgt.ios; import com.google.gson.Gson; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/ios/WebClip.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/ios/WebClip.java similarity index 96% rename from components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/ios/WebClip.java rename to components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/ios/WebClip.java index 3e73197d08c..f78577432c1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/ios/WebClip.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/app/mgt/ios/WebClip.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.jaxrs.beans.ios; +package org.wso2.carbon.device.mgt.common.app.mgt.ios; import com.google.gson.Gson;