@Override public void undo(String cookieSentByRPC, Action<Result> action, Result result) throws ActionException, ServiceException { if (action.isSecured() && !cookieMatch(cookieSentByRPC)) { String message = xsrfAttackMessage + " While undoing action: " + action.getClass().getName(); logger.severe(message); throw new ServiceException(message); } try { dispatch.undo(action, result); } catch (ActionException e) { logger.warning("Action exception while undoing " + action.getClass().getName() + ": " + e.getMessage()); throw new ActionException(e.getMessage()); } catch (ServiceException e) { logger.warning("Service exception while undoing " + action.getClass().getName() + ": " + e.getMessage()); throw new ServiceException(e.getMessage()); } catch (RuntimeException e) { logger.warning("Unexpected exception while undoing " + action.getClass().getName() + ": " + e.getMessage()); throw new ServiceException(e.getMessage()); } }
private <A extends Action<R>, R extends Result> void doUndo(A action, R result, ExecutionContext ctx) throws ActionException, ServiceException { ActionValidator actionValidator = findActionValidator(action); ActionHandler<A, R> handler = findHandler(action); try { if (actionValidator.isValid(action)) { handler.undo(action, result, ctx); } else { throw new ServiceException(actionValidator.getClass().getName() + actionValidatorMessage + action .getClass().getName()); } } catch (ActionException e) { throw e; } catch (Exception cause) { throw new ServiceException(cause); } }
/** * Every single action will be executed by this function and validated by the {@link ActionValidator}. * * @param <A> Type of associated {@link Action} type. * @param <R> Type of associated {@link Result} type. * @param action The {@link Action} to execute * @param ctx The {@link ExecutionContext} associated with the {@link Action} * @return The {@link Result} to the client * @throws ActionException * @throws ServiceException */ private <A extends Action<R>, R extends Result> R doExecute(A action, ExecutionContext ctx) throws ActionException, ServiceException { ActionHandler<A, R> handler = findHandler(action); ActionValidator actionValidator = findActionValidator(action); try { if (actionValidator.isValid(action)) { return handler.execute(action, ctx); } else { throw new ServiceException(actionValidator.getClass().getName() + actionValidatorMessage + action .getClass().getName()); } } catch (ActionException e) { throw e; } catch (Exception e) { String newMessage = "Service exception executing action \"" + action.getClass().getSimpleName() + "\", " + "" + e.toString(); throw new ServiceException(newMessage, e); } }
throw new ServiceException(message); if (logger.isLoggable(Level.WARNING)) { logger.log(Level.WARNING, "Service exception while executing " + action.getClass().getName() + ": " + e.getMessage(), e); throw new ServiceException(e.getMessage()); } catch (RuntimeException e) { if (logger.isLoggable(Level.WARNING)) { throw new ServiceException(e.getMessage());