/** * Invokes the action for the object (checking it is visible) and then delegates to the {@link * org.apache.isis.viewer.restfulobjects.rendering.service.RepresentationService} to render a * representation of the result of that action. */ public Response invokeAction(final String actionId, final JsonRepresentation arguments) { ObjectAdapterAccessHelper accessHelper = new ObjectAdapterAccessHelper(representationServiceContext, objectAdapter); final ObjectAction action = accessHelper.getObjectActionThatIsVisibleForIntent( actionId, ObjectAdapterAccessHelper.Intent.MUTATE); return invokeActionUsingAdapters(action, arguments, ActionResultReprRenderer.SelfLink.EXCLUDED); }
/** * Obtains the action details (arguments etc), checking it is visible, of the object and then * delegates to the {@link * org.apache.isis.viewer.restfulobjects.rendering.service.RepresentationService} to render a * representation of that object's action (arguments). */ public Response actionPrompt(final String actionId) { ObjectAdapterAccessHelper accessHelper = new ObjectAdapterAccessHelper(representationServiceContext, objectAdapter); final ObjectAction action = accessHelper.getObjectActionThatIsVisibleForIntent( actionId, ObjectAdapterAccessHelper.Intent.ACCESS); transactionService.flushTransaction(); return representationService.actionPrompt( representationServiceContext, new ObjectAndAction(objectAdapter, action)); }
/** * Invokes the action for the object (checking it is visible) and then delegates to the {@link * org.apache.isis.viewer.restfulobjects.rendering.service.RepresentationService} to render a * representation of the result of that action. * * <p>The action must have {@link org.apache.isis.applib.annotation.ActionSemantics.Of#IDEMPOTENT * idempotent} semantics otherwise an error response is thrown. */ public Response invokeActionIdempotent( final String actionId, final JsonRepresentation arguments) { final ObjectAdapterAccessHelper accessHelper = new ObjectAdapterAccessHelper(representationServiceContext, objectAdapter); final ObjectAction action = accessHelper.getObjectActionThatIsVisibleForIntent( actionId, ObjectAdapterAccessHelper.Intent.MUTATE); final ActionSemantics.Of actionSemantics = action.getSemantics(); if (!actionSemantics.isIdempotentInNature()) { throw RestfulObjectsApplicationException.createWithMessage( RestfulResponse.HttpStatusCode.METHOD_NOT_ALLOWED, "Method not allowed; action '%s' is not idempotent", action.getId()); } return invokeActionUsingAdapters(action, arguments, ActionResultReprRenderer.SelfLink.EXCLUDED); }