/** * Update Status of the lock operation. * * @param status Status of the operation. * @param syncmlDocument parsed syncml payload. * @param deviceIdentifier Device Id. * @throws OperationManagementException * @throws DeviceManagementException * @throws NotificationManagementException */ public void lockOperationUpdate( StatusTag status, SyncmlDocument syncmlDocument, DeviceIdentifier deviceIdentifier) throws OperationManagementException, DeviceManagementException, NotificationManagementException { pendingDataOperations = WindowsAPIUtils.getDeviceManagementService() .getOperationsByDeviceAndStatus(deviceIdentifier, Operation.Status.PENDING); if (Constants.SyncMLResponseCodes.ACCEPTED.equals(status.getData())) { for (Operation operation : pendingDataOperations) { if ((OperationCode.Command.DEVICE_LOCK.getCode().equals(operation.getCode())) && operation.getId() == status.getCommandReference()) { operation.setStatus(Operation.Status.COMPLETED); new OperationUtils() .updateOperations( syncmlDocument.getHeader().getSource().getLocURI(), pendingDataOperations); } } } if (Constants.SyncMLResponseCodes.PIN_NOTFOUND.equals(status.getData())) { for (Operation operation : pendingDataOperations) { if ((OperationCode.Command.DEVICE_LOCK.getCode().equals(operation.getCode()) && operation.getId() == status.getCommandReference())) { operation.setStatus(Operation.Status.ERROR); new OperationUtils() .updateOperations( syncmlDocument.getHeader().getSource().getLocURI(), pendingDataOperations); try { NotificationManagementService nmService = WindowsAPIUtils.getNotificationManagementService(); Notification lockResetNotification = new Notification(); lockResetNotification.setOperationId(status.getCommandReference()); lockResetNotification.setStatus(String.valueOf(Notification.Status.NEW)); lockResetNotification.setDeviceIdentifier(deviceIdentifier); lockResetNotification.setDescription( Constants.SyncMLResponseCodes.LOCKRESET_NOTIFICATION); nmService.addNotification(lockResetNotification); } catch (NotificationManagementException e) { String msg = "Failure occurred in getting notification service"; log.error(msg, e); throw new NotificationManagementException(msg, e); } } } } }
/** * * Update the status of the DataWipe operation. * * @param status Status of the data wipe. * @param syncmlDocument Parsed syncml payload from the syncml engine. * @param deviceIdentifier specific device id to be wiped. * @throws OperationManagementException * @throws DeviceManagementException */ public void dataWipe( StatusTag status, SyncmlDocument syncmlDocument, DeviceIdentifier deviceIdentifier) throws OperationManagementException, DeviceManagementException { if ((Constants.SyncMLResponseCodes.ACCEPTED.equals(status.getData()))) { pendingDataOperations = WindowsAPIUtils.getDeviceManagementService() .getOperationsByDeviceAndStatus(deviceIdentifier, Operation.Status.PENDING); for (Operation operation : pendingDataOperations) { if ((OperationCode.Command.WIPE_DATA.equals(operation.getCode())) && (operation.getId() == status.getCommandReference())) { operation.setStatus(Operation.Status.COMPLETED); updateOperations( syncmlDocument.getHeader().getSource().getLocURI(), pendingDataOperations); } } } }
/** * Update the completed/Error status of the operation which have the URI of the operation code in * the syncml payload. * * @param syncmlDocument SyncmlDocument object generated from the the syncml engine. * @throws DeviceManagementException * @throws NotificationManagementException * @throws OperationManagementException */ public void UpdateUriOperations(SyncmlDocument syncmlDocument) throws DeviceManagementException, NotificationManagementException, OperationManagementException, WindowsOperationException { DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject(syncmlDocument.getHeader().getSource().getLocURI()); List<StatusTag> statuses = syncmlDocument.getBody().getStatus(); OperationUtils operationUtils = new OperationUtils(); for (StatusTag status : statuses) { if ((Constants.EXECUTE.equals(status.getCommand()))) { if (status.getTargetReference() == null) { operationUtils.updateDeviceOperations(status, syncmlDocument, deviceIdentifier); } else { if ((OperationCode.Command.DEVICE_LOCK.equals(status.getTargetReference()))) { operationUtils.lockOperationUpdate(status, syncmlDocument, deviceIdentifier); } if ((OperationCode.Command.DEVICE_RING.equals(status.getTargetReference()))) { operationUtils.ring(status, syncmlDocument, deviceIdentifier); } if (equals(OperationCode.Command.WIPE_DATA.equals(status.getTargetReference()))) { operationUtils.dataWipe(status, syncmlDocument, deviceIdentifier); } } } if ((Constants.SEQUENCE.equals(status.getCommand()))) { if ((Constants.SyncMLResponseCodes.ACCEPTED.equals(status.getData()))) { pendingDataOperations = WindowsAPIUtils.getDeviceManagementService() .getOperationsByDeviceAndStatus(deviceIdentifier, Operation.Status.PENDING); for (Operation operation : pendingDataOperations) { if ((PluginConstants.OperationCodes.POLICY_BUNDLE.equals(operation.getCode())) && operation.getId() == status.getCommandReference()) { operation.setStatus(Operation.Status.COMPLETED); } if ((PluginConstants.OperationCodes.MONITOR.equals(operation.getCode())) && operation.getId() == status.getCommandReference()) { operation.setStatus(Operation.Status.COMPLETED); } } operationUtils.updateOperations( syncmlDocument.getHeader().getSource().getLocURI(), pendingDataOperations); } else { pendingDataOperations = WindowsAPIUtils.getDeviceManagementService() .getOperationsByDeviceAndStatus(deviceIdentifier, Operation.Status.PENDING); for (Operation operation : pendingDataOperations) { if ((PluginConstants.OperationCodes.POLICY_BUNDLE.equals(operation.getCode())) && operation.getId() == status.getCommandReference()) { operation.setStatus(Operation.Status.ERROR); } if ((PluginConstants.OperationCodes.MONITOR.equals(operation.getCode())) && operation.getId() == status.getCommandReference()) { operation.setStatus(Operation.Status.ERROR); } } operationUtils.updateOperations( syncmlDocument.getHeader().getSource().getLocURI(), pendingDataOperations); } } } }