Source:
private List<DeviceIdentifier> installApplication(String applicationUUID, List<DeviceIdentifier> deviceList, String versionName) throws ApplicationManagementException { List<DeviceIdentifier> failedDeviceList = new ArrayList<>(deviceList); log.info("Install application: " + applicationUUID + "[" + versionName + "]" + " to: " + deviceList.size() + " devices."); for (DeviceIdentifier device : deviceList) { org.wso2.carbon.device.mgt.common.DeviceIdentifier deviceIdentifier = new org.wso2.carbon.device.mgt .common.DeviceIdentifier(device.getId(), device.getType()); try { DeviceManagementProviderService dmpService = HelperUtil.getDeviceManagementProviderService(); if (!dmpService.isEnrolled(deviceIdentifier)) { log.error("Device with ID: [" + device.getId() + "] is not enrolled to install the application."); } else { if (log.isDebugEnabled()) { log.debug("Installing application to : " + device.getId()); } ProfileOperation operation = new ProfileOperation(); operation.setCode("INSTALL_APPLICATION"); operation.setType(Operation.Type.PROFILE); operation.setPayLoad("{'type':'enterprise', 'url':'<LINK_0>', 'app':'" + applicationUUID + "'}"); List<org.wso2.carbon.device.mgt.common.DeviceIdentifier> deviceIdentifiers = new ArrayList<>(); deviceIdentifiers.add(deviceIdentifier); dmpService.addOperation(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, operation, deviceIdentifiers); DeviceApplicationMapping deviceApp = new DeviceApplicationMapping(); deviceApp.setDeviceIdentifier(device.getId()); deviceApp.setApplicationUUID(applicationUUID); deviceApp.setVersionName(versionName); deviceApp.setInstalled(false); dmpService.addDeviceApplicationMapping(deviceApp); failedDeviceList.remove(device); } } catch (DeviceManagementException | OperationManagementException | InvalidDeviceException e) { log.error("Error while installing application to device[" + deviceIdentifier.getId() + "]", e); } } return failedDeviceList; }

Target:
private List<DeviceIdentifier> installApplication(String applicationUUID, List<DeviceIdentifier> deviceList, String versionName) throws ApplicationManagementException { List<DeviceIdentifier> failedDeviceList = new ArrayList<>(deviceList); log.info("Install application: " + applicationUUID + "[" + versionName + "]" + " to: " + deviceList.size() + " devices."); for (DeviceIdentifier device : deviceList) { org.wso2.carbon.device.mgt.common.DeviceIdentifier deviceIdentifier = new org.wso2.carbon.device.mgt .common.DeviceIdentifier(device.getId(), device.getType()); try { DeviceManagementProviderService dmpService = HelperUtil.getDeviceManagementProviderService(); if (!dmpService.isEnrolled(deviceIdentifier)) { log.error("Device with ID: [" + device.getId() + "] is not enrolled to install the application."); } else { if (log.isDebugEnabled()) { log.debug("Installing application to : " + device.getId()); } ProfileOperation operation = new ProfileOperation(); operation.setCode(INSTALL_APPLICATION); operation.setType(Operation.Type.PROFILE); operation.setPayLoad("{'type':'enterprise', 'url':'<LINK_0>', 'app':'" + applicationUUID + "'}"); List<org.wso2.carbon.device.mgt.common.DeviceIdentifier> deviceIdentifiers = new ArrayList<>(); deviceIdentifiers.add(deviceIdentifier); dmpService.addOperation(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, operation, deviceIdentifiers); DeviceApplicationMapping deviceApp = new DeviceApplicationMapping(); deviceApp.setDeviceIdentifier(device.getId()); deviceApp.setApplicationUUID(applicationUUID); deviceApp.setVersionName(versionName); deviceApp.setInstalled(false); dmpService.addDeviceApplicationMapping(deviceApp); failedDeviceList.remove(device); } } catch (DeviceManagementException | OperationManagementException | InvalidDeviceException e) { log.error("Error while installing application to device[" + deviceIdentifier.getId() + "]", e); } } return failedDeviceList; }