Пример #1
0
  void undo(
      MultiStatus status,
      EngineSession session,
      IProfile profile,
      Operand operand,
      ProvisioningAction[] actions,
      ProvisioningContext context) {
    if (operandParameters == null) {
      operandParameters = new HashMap<String, Object>(phaseParameters);
      operandParameters.put(PARM_OPERAND, operand);
      mergeStatus(
          status,
          initializeOperand(profile, operand, operandParameters, new NullProgressMonitor()));
      Touchpoint operandTouchpoint = (Touchpoint) operandParameters.get(PARM_TOUCHPOINT);
      if (operandTouchpoint != null) {
        mergeStatus(
            status,
            initializeTouchpointParameters(
                profile, operand, operandTouchpoint, new NullProgressMonitor()));
        if (status.matches(IStatus.ERROR | IStatus.CANCEL)) return;

        operandParameters = touchpointToTouchpointOperandParameters.get(operandTouchpoint);
      }
      operandParameters = Collections.unmodifiableMap(operandParameters);
    }
    for (int j = 0; j < actions.length; j++) {
      ProvisioningAction action = actions[j];
      Map<String, Object> parameters = operandParameters;
      Touchpoint touchpoint = action.getTouchpoint();
      if (touchpoint != null) {
        mergeStatus(
            status,
            initializeTouchpointParameters(
                profile, operand, touchpoint, new NullProgressMonitor()));
        if (status.matches(IStatus.ERROR)) return;

        parameters = touchpointToTouchpointOperandParameters.get(touchpoint);
      }
      IStatus actionStatus = null;
      try {
        session.recordActionUndo(action, parameters);
        actionStatus = action.undo(parameters);
      } catch (RuntimeException e) {
        // "action.undo" calls user code and might throw an unchecked exception
        // we catch the error here to gather information on where the problem occurred.
        actionStatus =
            new Status(
                IStatus.ERROR,
                EngineActivator.ID,
                NLS.bind(Messages.action_undo_error, action.getClass().getName()),
                e);
      } catch (LinkageError e) {
        // Catch linkage errors as these are generally recoverable but let other Errors propagate
        // (see bug 222001)
        actionStatus =
            new Status(
                IStatus.ERROR,
                EngineActivator.ID,
                NLS.bind(Messages.action_undo_error, action.getClass().getName()),
                e);
      }
      if (actionStatus != null && actionStatus.matches(IStatus.ERROR)) {
        MultiStatus result =
            new MultiStatus(EngineActivator.ID, IStatus.ERROR, getProblemMessage(), null);
        result.add(
            new Status(
                IStatus.ERROR,
                EngineActivator.ID,
                session.getContextString(this, operand, action),
                null));
        result.merge(actionStatus);
      }
    }
    mergeStatus(
        status,
        touchpointCompleteOperand(profile, operand, operandParameters, new NullProgressMonitor()));
    mergeStatus(
        status, completeOperand(profile, operand, operandParameters, new NullProgressMonitor()));
    operandParameters = null;
  }