Пример #1
0
  /**
   * * 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);
        }
      }
    }
  }
Пример #2
0
  /**
   * 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);
        }
      }
    }
  }