public ObjectAction getObjectActionThatIsVisibleForIntent( final String actionId, final Intent intent) { final Where where = rendererContext.getWhere(); final ObjectAction action; try { final ObjectSpecification specification = objectAdapter.getSpecification(); action = specification.getObjectAction(actionId); } catch(Exception ex) { throwNotFoundException(actionId, MemberType.ACTION); return null; // to keep compiler happy. } if (action == null) { throwNotFoundException(actionId, MemberType.ACTION); } return memberThatIsVisibleForIntent(action, MemberType.ACTION, intent); }
public OneToOneAssociation getPropertyThatIsVisibleForIntent( final String propertyId, final Intent intent) { final Where where = rendererContext.getWhere(); final ObjectAssociation association; try { final ObjectSpecification specification = objectAdapter.getSpecification(); association = specification.getAssociation(propertyId); } catch(Exception ex) { // fall through throwNotFoundException(propertyId, MemberType.PROPERTY); return null; // to keep compiler happy. } if (association == null || !association.isOneToOneAssociation()) { throwNotFoundException(propertyId, MemberType.PROPERTY); } final OneToOneAssociation property = (OneToOneAssociation) association; return memberThatIsVisibleForIntent(property, MemberType.PROPERTY, intent); }
public OneToManyAssociation getCollectionThatIsVisibleForIntent( final String collectionId, final Intent intent) { final Where where = rendererContext.getWhere(); final ObjectAssociation association; try { final ObjectSpecification specification = objectAdapter.getSpecification(); association = specification.getAssociation(collectionId); } catch(Exception ex) { // fall through throwNotFoundException(collectionId, MemberType.COLLECTION); return null; // to keep compiler happy. } if (association == null || !association.isOneToManyAssociation()) { throwNotFoundException(collectionId, MemberType.COLLECTION); } final OneToManyAssociation collection = (OneToManyAssociation) association; return memberThatIsVisibleForIntent(collection, MemberType.COLLECTION, intent); }
public <T extends ObjectMember> T memberThatIsVisibleForIntent( final T objectMember, final MemberType memberType, final Intent intent) { final Where where = rendererContext.getWhere(); final String memberId = objectMember.getId(); final Consent visibilityConsent = objectMember.isVisible( objectAdapter, InteractionInitiatedBy.USER, where); if (visibilityConsent.isVetoed()) { throwNotFoundException(memberId, memberType); } if (intent.isMutate()) { final Consent usabilityConsent = objectMember.isUsable( objectAdapter, InteractionInitiatedBy.USER, where ); if (usabilityConsent.isVetoed()) { throw RestfulObjectsApplicationException.createWithMessage(RestfulResponse.HttpStatusCode.FORBIDDEN, usabilityConsent.getReason()); } } return objectMember; }
private void addActions(final ObjectAdapter objectAdapter, final List<ObjectAction> actions, final JsonRepresentation members) { for (final ObjectAction action : actions) { final Consent visibility = action.isVisible(objectAdapter, getInteractionInitiatedBy(), rendererContext.getWhere()); if (!visibility.isAllowed()) { continue; } final LinkFollowSpecs linkFollowSpecs = getLinkFollowSpecs().follow("members["+action.getId()+"]"); final ObjectActionReprRenderer renderer = new ObjectActionReprRenderer(getRendererContext(), linkFollowSpecs, action.getId(), JsonRepresentation.newMap()); renderer.with(new ObjectAndAction(objectAdapter, action)).usingLinkTo(linkToBuilder); members.mapPut(action.getId(), renderer.render()); } }
private void addActions(final ObjectAdapter objectAdapter, final List<ObjectAction> actions, final JsonRepresentation members) { for (final ObjectAction action : actions) { final Consent visibility = action.isVisible(getRendererContext().getAuthenticationSession(), objectAdapter, rendererContext.getWhere()); if (!visibility.isAllowed()) { continue; } final LinkFollowSpecs linkFollowSpecs = getLinkFollowSpecs().follow("members["+action.getId()+"]"); final ObjectActionReprRenderer renderer = new ObjectActionReprRenderer(getRendererContext(), linkFollowSpecs, action.getId(), JsonRepresentation.newMap()); renderer.with(new ObjectAndAction(objectAdapter, action)).usingLinkTo(linkToBuilder); members.mapPut(action.getId(), renderer.render()); } }
final String id = property.getId(); final JsonRepresentation propertyRepr = propertiesList.getRepresentation(id); final Consent visibility = property.isVisible(resourceContext.getAuthenticationSession() , objectAdapter, resourceContext.getWhere()); final Consent usability = property.isUsable(resourceContext.getAuthenticationSession() , objectAdapter, resourceContext.getWhere());
private void addCollections(final ObjectAdapter objectAdapter, final JsonRepresentation members, final List<ObjectAssociation> associations) { for (final ObjectAssociation assoc : associations) { if (mode.checkVisibility()) { final Consent visibility = assoc.isVisible(objectAdapter, getInteractionInitiatedBy(), rendererContext.getWhere()); if (!visibility.isAllowed()) { continue; } } if (!(assoc instanceof OneToManyAssociation)) { continue; } final OneToManyAssociation collection = (OneToManyAssociation) assoc; final LinkFollowSpecs linkFollowerForColl = getLinkFollowSpecs().follow( "members[" + collection.getId() + "]"); final JsonRepresentation collectionRepresentation = JsonRepresentation.newMap(); final ObjectCollectionReprRenderer renderer = new ObjectCollectionReprRenderer(getRendererContext(), linkFollowerForColl, collection.getId(), collectionRepresentation); renderer.with(new ObjectAndCollection(objectAdapter, collection)).usingLinkTo(linkToBuilder); if(mode.isEventSerialization()) { renderer.asEventSerialization(); } members.mapPut(assoc.getId(), renderer.render()); } }
private void addProperties(final ObjectAdapter objectAdapter, final JsonRepresentation members, final List<ObjectAssociation> associations) { for (final ObjectAssociation assoc : associations) { if (mode.checkVisibility()) { final Consent visibility = assoc.isVisible(objectAdapter, getInteractionInitiatedBy(), rendererContext.getWhere()); if (!visibility.isAllowed()) { continue; } } if (!(assoc instanceof OneToOneAssociation)) { continue; } final OneToOneAssociation property = (OneToOneAssociation) assoc; final LinkFollowSpecs linkFollowerForProp = getLinkFollowSpecs().follow("members[" + property.getId() + "]"); final JsonRepresentation propertyRepresentation = JsonRepresentation.newMap(); final ObjectPropertyReprRenderer renderer = new ObjectPropertyReprRenderer(getRendererContext(), linkFollowerForProp, property.getId(), propertyRepresentation); renderer.with(new ObjectAndProperty(objectAdapter, property)).usingLinkTo(linkToBuilder); if (mode.isArgs()) { renderer.asArguments(); } if(mode.isEventSerialization()) { renderer.asEventSerialization(); } final JsonRepresentation propertyValueRepresentation = renderer.render(); final JsonRepresentation propertyRepr = rendererContext.objectPropertyValuesOnly() ? propertyValueRepresentation.getRepresentation("value") : propertyValueRepresentation; members.mapPut(assoc.getId(), propertyRepr); } }
final Consent visibility = assoc.isVisible(getRendererContext().getAuthenticationSession(), objectAdapter, rendererContext.getWhere()); if (!visibility.isAllowed()) { continue;