From e25e9fd4a1d82cdfdb1ced8567bf7621bb8338fe Mon Sep 17 00:00:00 2001 From: inoshperera Date: Wed, 16 Nov 2016 09:33:43 +0530 Subject: [PATCH] adding support for webclip uninstallation for ios --- .../ApplicationOperationsImpl.java | 10 +++++++--- .../mdmmgt/beans/ios/RemoveApplication.java | 9 +++++++++ .../util/IOSApplicationOperationUtil.java | 18 ++++++++++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/ApplicationOperationsImpl.java b/components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/ApplicationOperationsImpl.java index 766698c9c..f0c92c31f 100644 --- a/components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/ApplicationOperationsImpl.java +++ b/components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/ApplicationOperationsImpl.java @@ -73,7 +73,8 @@ public class ApplicationOperationsImpl implements ApplicationOperations { getDevicesOfUser(userName); for (org.wso2.carbon.device.mgt.common.Device device : deviceList) { - if(applicationOperationAction.getApp().getPlatform().equalsIgnoreCase(device.getType())){ + if(MDMAppConstants.WEBAPP.equals(applicationOperationAction.getApp().getPlatform()) || + applicationOperationAction.getApp().getPlatform().equalsIgnoreCase(device.getType())){ deviceIdentifiers.add(getDeviceIdentifierByDevice(device)); } } @@ -176,8 +177,11 @@ public class ApplicationOperationsImpl implements ApplicationOperations { operation = IOSApplicationOperationUtil.createInstallAppOperation(mobileApp); } else { - operation = - IOSApplicationOperationUtil.createAppUninstallOperation(mobileApp); + if (MDMAppConstants.WEBAPP.equals(app.getPlatform())) { + operation = IOSApplicationOperationUtil.createWebClipUninstallOperation(mobileApp); + } else { + operation = IOSApplicationOperationUtil.createAppUninstallOperation(mobileApp); + } } } activity = MDMServiceAPIUtils.getAppManagementService(applicationOperationAction.getTenantId()) diff --git a/components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/ios/RemoveApplication.java b/components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/ios/RemoveApplication.java index 22c7963de..d5ae92170 100644 --- a/components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/ios/RemoveApplication.java +++ b/components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/ios/RemoveApplication.java @@ -23,6 +23,15 @@ import java.io.Serializable; public class RemoveApplication implements Serializable { private String bundleId; + private String url; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } public String getBundleId() { return bundleId; diff --git a/components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/util/IOSApplicationOperationUtil.java b/components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/util/IOSApplicationOperationUtil.java index 5b2dec4eb..5e73a5775 100644 --- a/components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/util/IOSApplicationOperationUtil.java +++ b/components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/util/IOSApplicationOperationUtil.java @@ -111,4 +111,22 @@ public class IOSApplicationOperationUtil { return operation; } + /** + * Create uninstall operations for webclip. + * + * @param application + * @return Uninstall operation + * @throws DeviceApplicationException + */ + public static Operation createWebClipUninstallOperation(MobileApp application) throws + DeviceApplicationException { + ProfileOperation operation = new ProfileOperation(); + operation.setCode(MDMAppConstants.IOSConstants.OPCODE_REMOVE_APPLICATION); + operation.setType(Operation.Type.PROFILE); + RemoveApplication removeApplication = new RemoveApplication(); + removeApplication.setUrl(application.getIdentifier()); + operation.setPayLoad(removeApplication.toJSON()); + return operation; + } + }