@Override public Activity installApplicationForUsers(Operation operation, List<String> userNameList) throws ApplicationManagementException { String userName = null; try { List<Device> deviceList; List<DeviceIdentifier> deviceIdentifierList = new ArrayList<>(); DeviceIdentifier deviceIdentifier; for (String user : userNameList) { userName = user; deviceList = DeviceManagementDataHolder.getInstance() .getDeviceManagementProvider() .getDevicesOfUser(user); for (Device device : deviceList) { deviceIdentifier = new DeviceIdentifier(); deviceIdentifier.setId(Integer.toString(device.getId())); deviceIdentifier.setType(device.getType()); deviceIdentifierList.add(deviceIdentifier); } } // TODO: Fix this properly later adding device type to be passed in when the task manage // executes "addOperations()" String type = null; if (deviceIdentifierList.size() > 0) { type = deviceIdentifierList.get(0).getType(); } return DeviceManagementDataHolder.getInstance() .getDeviceManagementProvider() .addOperation(type, operation, deviceIdentifierList); } catch (InvalidDeviceException e) { throw new ApplicationManagementException("Invalid DeviceIdentifiers found.", e); } catch (DeviceManagementException e) { throw new ApplicationManagementException( "Error in get devices for user: "******" in app installation", e); } catch (OperationManagementException e) { throw new ApplicationManagementException("Error in add operation at app installation", e); } }