/** * Update the operations using device status payload. * * @param status Client side status for the specific operations. * @param syncmlDocument syncml payload for operation status which parse through the syncml * engine. * @param deviceIdentifier specific device identifier for each device. * @throws OperationManagementException * @throws DeviceManagementException */ public void updateDeviceOperations( StatusTag status, SyncmlDocument syncmlDocument, DeviceIdentifier deviceIdentifier) throws OperationManagementException, DeviceManagementException, NotificationManagementException, WindowsOperationException { pendingDataOperations = WindowsAPIUtils.getDeviceManagementService() .getOperationsByDeviceAndStatus(deviceIdentifier, Operation.Status.PENDING); if (Constants.SyncMLResponseCodes.ACCEPTED.equals(status.getData()) || (Constants.SyncMLResponseCodes.ACCEPTED_FOR_PROCESSING.equals(status.getData()))) { for (Operation operation : pendingDataOperations) { if (operation.getId() == status.getCommandReference()) { operation.setStatus(Operation.Status.COMPLETED); } } updateOperations(syncmlDocument.getHeader().getSource().getLocURI(), pendingDataOperations); } else if (Constants.SyncMLResponseCodes.PIN_NOTFOUND.equals(status.getData())) { for (Operation operation : pendingDataOperations) { if (operation.getId() == status.getCommandReference() && (OperationCode.Command.DEVICE_LOCK.equals(operation.getCode()))) { operation.setStatus(Operation.Status.ERROR); 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) { throw new WindowsOperationException( "Failure occurred in getting notification service", e); } } } } }
/** * 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); } } } }