/** * Returns a status that represents the exceptions collected. If the collector is empty <code> * IStatus.OK</code> is returned. Otherwise a MultiStatus containing all collected exceptions is * returned. * * @return a multistatus containing the exceptions collected or IStatus.OK if the collector is * empty. */ public IStatus getStatus() { if (statuses.isEmpty()) { return Status.OK_STATUS; } else { MultiStatus multiStatus = new MultiStatus(pluginId, severity, message, null); Iterator it = statuses.iterator(); while (it.hasNext()) { IStatus status = (IStatus) it.next(); multiStatus.merge(status); } return multiStatus; } }
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; }
/** Merges a given IStatus into a MultiStatus */ protected static void mergeStatus(MultiStatus multi, IStatus status) { if (status != null && !status.isOK()) multi.merge(status); }