private ActionMemento( final ObjectSpecId owningSpecId, final ActionType actionType, final String nameParmsId, final ObjectAction action) { this.owningType = owningSpecId; this.actionType = actionType; this.nameParmsId = nameParmsId; this.action = action; this.actionSemantics = action.getSemantics(); }
private ActionMemento( final ObjectSpecId owningSpecId, final ActionType actionType, final String nameParmsId, final ObjectAction action) { this.owningType = owningSpecId; this.actionType = actionType; this.nameParmsId = nameParmsId; this.action = action; this.actionSemantics = action.getSemantics(); }
@Override protected void addMutatorsIfEnabled() { if (usability().isVetoed()) { return; } final Map<String, MutatorSpec> mutators = memberType.getMutators(); final ActionSemantics.Of actionSemantics = objectMember.getSemantics(); final String mutator = InvokeKeys.getKeyFor(actionSemantics); final MutatorSpec mutatorSpec = mutators.get(mutator); addLinkFor(mutatorSpec); }
@Override protected void addMutatorLinksIfEnabled() { if (usability().isVetoed()) { return; } final Map<String, MutatorSpec> mutators = objectMemberType.getMutators(); final ActionSemantics.Of actionSemantics = objectMember.getSemantics(); final String mutator = InvokeKeys.getKeyFor(actionSemantics); final MutatorSpec mutatorSpec = mutators.get(mutator); addLinkFor(mutatorSpec); }
@Override protected void addMutatorsIfEnabled() { if (usability().isVetoed()) { return; } final Map<String, MutatorSpec> mutators = objectMemberType.getMutators(); final ActionSemantics.Of actionSemantics = objectMember.getSemantics(); final String mutator = InvokeKeys.getKeyFor(actionSemantics); final MutatorSpec mutatorSpec = mutators.get(mutator); addLinkFor(mutatorSpec); }
Response invokeActionQueryOnly(final String actionId, final JsonRepresentation arguments, Where where) { final ObjectAction action = getObjectActionThatIsVisibleForIntent(actionId, Intent.MUTATE, where); final ActionSemantics.Of actionSemantics = action.getSemantics(); if (actionSemantics != ActionSemantics.Of.SAFE) { throw RestfulObjectsApplicationException.createWithMessage(HttpStatusCode.METHOD_NOT_ALLOWED, "Method not allowed; action '%s' is not query only", action.getId()); } return invokeActionUsingAdapters(action, arguments, SelfLink.INCLUDED); }
Response invokeActionQueryOnly(final String actionId, final JsonRepresentation arguments, Where where) { final ObjectAction action = getObjectActionThatIsVisibleAndUsable(actionId, Intent.ACCESS, where); final ActionSemantics.Of actionSemantics = action.getSemantics(); if (actionSemantics != ActionSemantics.Of.SAFE) { throw RestfulObjectsApplicationException.create(HttpStatusCode.METHOD_NOT_ALLOWED, "Method not allowed; action '%s' is not query only", action.getId()); } return invokeActionUsingAdapters(action, arguments); }
/** * Bookmarkable if the {@link ObjectAction action} has a {@link BookmarkPolicyFacet bookmark} policy * of {@link BookmarkPolicy#AS_ROOT root}, and has safe {@link ObjectAction#getSemantics() semantics}. */ public boolean isBookmarkable() { final ObjectAction action = getAction(); final BookmarkPolicyFacet bookmarkPolicy = action.getFacet(BookmarkPolicyFacet.class); final boolean safeSemantics = action.getSemantics().isSafeInNature(); return bookmarkPolicy.value() == BookmarkPolicy.AS_ROOT && safeSemantics; }
Response invokeActionIdempotent(final String actionId, final JsonRepresentation arguments, Where where) { final ObjectAction action = getObjectActionThatIsVisibleForIntent(actionId, Intent.MUTATE, where); final ActionSemantics.Of actionSemantics = action.getSemantics(); if (!actionSemantics.isIdempotentInNature()) { throw RestfulObjectsApplicationException.createWithMessage(HttpStatusCode.METHOD_NOT_ALLOWED, "Method not allowed; action '%s' is not idempotent", action.getId()); } return invokeActionUsingAdapters(action, arguments, SelfLink.EXCLUDED); }
@Override protected void putExtensionsIsisProprietary() { getExtensions().mapPut("actionType", objectMember.getType().name().toLowerCase()); final ActionSemantics.Of semantics = objectMember.getSemantics(); getExtensions().mapPut("actionSemantics", semantics.getCamelCaseName()); }
@Override protected void putExtensionsIsisProprietary() { getExtensions().mapPut("actionType", objectMember.getType().name().toLowerCase()); final ActionSemantics.Of semantics = objectMember.getSemantics(); getExtensions().mapPut("actionSemantics", semantics.getCamelCaseName()); }
@Override protected void putExtensionsIsisProprietary() { getExtensions().mapPut("actionType", objectMember.getType().name().toLowerCase()); final ActionSemantics.Of semantics = objectMember.getSemantics(); getExtensions().mapPut("actionSemantics", semantics.getCamelCaseName()); }
/** * Bookmarkable if the {@link ObjectAction action} has a {@link BookmarkPolicyFacet bookmark} policy * of {@link BookmarkPolicy#AS_ROOT root}, and has safe {@link ObjectAction#getSemantics() semantics}. */ public boolean isBookmarkable() { final ObjectAction action = getActionMemento().getAction(getSpecificationLoader()); final BookmarkPolicyFacet bookmarkPolicy = action.getFacet(BookmarkPolicyFacet.class); final boolean safeSemantics = action.getSemantics().isSafeInNature(); return bookmarkPolicy.value() == BookmarkPolicy.AS_ROOT && safeSemantics; }
/** * 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 ActionSemantics.Of#isSafeInNature()} safe/request-cacheable} semantics * otherwise an error response is thrown. * </p> */ public Response invokeActionQueryOnly(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.isSafeInNature()) { throw RestfulObjectsApplicationException.createWithMessage(RestfulResponse.HttpStatusCode.METHOD_NOT_ALLOWED, "Method not allowed; action '%s' does not have safe semantics", action.getId()); } return invokeActionUsingAdapters(action, arguments, ActionResultReprRenderer.SelfLink.INCLUDED); }
Response invokeActionIdempotent(final String actionId, final InputStream body, Where where) { final ObjectAction action = getObjectActionThatIsVisibleAndUsable(actionId, Intent.MUTATE, where); final ActionSemantics.Of actionSemantics = action.getSemantics(); if (!actionSemantics.isIdempotentInNature()) { throw RestfulObjectsApplicationException.create(HttpStatusCode.METHOD_NOT_ALLOWED, "Method not allowed; action '%s' is not idempotent", action.getId()); } final String bodyAsString = asStringUtf8(body); final JsonRepresentation arguments = readAsMap(bodyAsString); return invokeActionUsingAdapters(action, arguments); }
private JsonRepresentation representationWithSelfFor(final ObjectAction action, final JsonRepresentation bodyArgs) { final JsonRepresentation links = JsonRepresentation.newArray(); representation.mapPut("links", links); final LinkBuilder selfLinkBuilder = adapterLinkTo.memberBuilder(Rel.SELF, MemberType.ACTION, action, RepresentationType.ACTION_RESULT, "invoke"); // TODO: remove duplication with AbstractObjectMember#addLinkTo final MemberType memberType = MemberType.of(action); final Map<String, MutatorSpec> mutators = memberType.getMutators(); final String mutator = InvokeKeys.getKeyFor(action.getSemantics()); final MutatorSpec mutatorSpec = mutators.get(mutator); selfLinkBuilder.withHttpMethod(mutatorSpec.httpMethod); final JsonRepresentation selfLink = selfLinkBuilder.build(); links.arrayAdd(selfLink); selfLink.mapPut("args", bodyArgs); return representation; }
/** * 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. * </p> */ 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); }
private void representationWithSelfFor(final ObjectAction action, final JsonRepresentation bodyArgs) { final JsonRepresentation links = JsonRepresentation.newArray(); representation.mapPut("links", links); if(selfLink == SelfLink.EXCLUDED) { return; } final LinkBuilder selfLinkBuilder = adapterLinkTo.memberBuilder(Rel.SELF, MemberType.ACTION, action, RepresentationType.ACTION_RESULT, "invoke"); // TODO: remove duplication with AbstractObjectMember#addLinkTo final MemberType memberType = MemberType.of(action); final Map<String, MutatorSpec> mutators = memberType.getMutators(); final String mutator = InvokeKeys.getKeyFor(action.getSemantics()); final MutatorSpec mutatorSpec = mutators.get(mutator); selfLinkBuilder.withHttpMethod(mutatorSpec.httpMethod); final JsonRepresentation selfLink = selfLinkBuilder.build(); links.arrayAdd(selfLink); selfLink.mapPut("args", bodyArgs); }
private void representationWithSelfFor(final ObjectAction action, final JsonRepresentation bodyArgs) { final JsonRepresentation links = JsonRepresentation.newArray(); representation.mapPut("links", links); if(selfLink == SelfLink.EXCLUDED) { return; } final LinkBuilder selfLinkBuilder = adapterLinkTo.memberBuilder(Rel.SELF, MemberType.ACTION, action, RepresentationType.ACTION_RESULT, "invoke"); // TODO: remove duplication with AbstractObjectMember#addLinkTo final MemberType memberType = MemberType.of(action); final Map<String, MutatorSpec> mutators = memberType.getMutators(); final String mutator = InvokeKeys.getKeyFor(action.getSemantics()); final MutatorSpec mutatorSpec = mutators.get(mutator); selfLinkBuilder.withHttpMethod(mutatorSpec.httpMethod); final JsonRepresentation selfLink = selfLinkBuilder.build(); links.arrayAdd(selfLink); selfLink.mapPut("args", bodyArgs); final LinkBuilder upLinkBuilder = adapterLinkTo.memberBuilder(Rel.UP, MemberType.ACTION, action, RepresentationType.OBJECT_ACTION); upLinkBuilder.withHttpMethod(RestfulHttpMethod.GET); links.arrayAdd(upLinkBuilder.build()); }
public static LinkAndLabel newLinkAndLabel( final ObjectAdapter objectAdapter, final ObjectAction objectAction, final AbstractLink link, final String disabledReasonIfAny, final boolean blobOrClob) { final String name = ObjectAction.Utils.nameFor(objectAction); final boolean explorationOrPrototype = objectAction.isPrototype(); final String actionIdentifier = ObjectAction.Utils.actionIdentifierFor(objectAction); final String description = ObjectAction.Utils.descriptionOf(objectAction); final String cssClass = ObjectAction.Utils.cssClassFor(objectAction, objectAdapter); final String cssClassFa = ObjectAction.Utils.cssClassFaFor(objectAction); final CssClassFaPosition cssClassFaPosition = ObjectAction.Utils.cssClassFaPositionFor(objectAction); final ActionLayout.Position actionLayoutPosition = ObjectAction.Utils.actionLayoutPositionOf(objectAction); final ActionSemantics.Of semantics = objectAction.getSemantics(); return new LinkAndLabel( link, name, disabledReasonIfAny, description, blobOrClob, explorationOrPrototype, actionIdentifier, cssClass, cssClassFa, cssClassFaPosition, actionLayoutPosition, SemanticsOf.from(semantics), Parameters.fromParameterCount(objectAction.getParameterCount())); }