@Override @DELETE @Path("/{domainType}/{instanceId}/properties/{propertyId}") @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ERROR }) public Response clearProperty(@PathParam("domainType") String domainType, @PathParam("instanceId") final String instanceId, @PathParam("propertyId") final String propertyId) { init(Where.OBJECT_FORMS); final ObjectAdapter objectAdapter = getObjectAdapterElseThrowNotFound(domainType, instanceId); final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext(), objectAdapter); final OneToOneAssociation property = helper.getPropertyThatIsVisibleForIntent(propertyId, Intent.MUTATE, getResourceContext().getWhere()); final Consent consent = property.isAssociationValid(objectAdapter, null); if (consent.isVetoed()) { throw RestfulObjectsApplicationException.createWithMessage(HttpStatusCode.UNAUTHORIZED, consent.getReason()); } property.set(objectAdapter, null); return helper.propertyDetails(propertyId, MemberMode.MUTATING, Caching.NONE, getResourceContext().getWhere()); }
private void changeObject(final RequestContext context, final ObjectAdapter object, final FormState editState, final List<ObjectAssociation> fields) { for (int i = 0; i < fields.size(); i++) { final FieldEditState field = editState.getField(fields.get(i).getId()); if (field == null) { continue; } final String newEntry = field.getEntry(); final ObjectAdapter originalValue = fields.get(i).get(object); final boolean isVisible = fields.get(i).isVisible(IsisContext.getAuthenticationSession(), object).isAllowed(); final boolean isUsable = fields.get(i).isUsable(IsisContext.getAuthenticationSession(), object).isAllowed(); final boolean bothEmpty = originalValue == null && newEntry.equals(""); final boolean bothSame = newEntry.equals(originalValue == null ? "" : originalValue.titleString()); if ((!isVisible || !isUsable) || bothEmpty || bothSame) { if (fields.get(i).getSpecification().getFacet(ParseableFacet.class) == null) { // REVIEW restores object to loader context.getMappedObject(newEntry); } continue; } if (fields.get(i).getSpecification().containsFacet(ParseableFacet.class)) { final ParseableFacet facet = fields.get(i).getSpecification().getFacet(ParseableFacet.class); final ObjectAdapter newValue = facet.parseTextEntry(originalValue, newEntry); ((OneToOneAssociation) fields.get(i)).set(object, newValue); } else { ((OneToOneAssociation) fields.get(i)).set(object, field.getValue()); } } }
@Override @DELETE @Path("/{domainType}/{instanceId}/properties/{propertyId}") @Consumes({ MediaType.WILDCARD }) @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_OBJECT_PROPERTY, RestfulMediaType.APPLICATION_JSON_ERROR, MediaType.APPLICATION_XML, RestfulMediaType.APPLICATION_XML_OBJECT_PROPERTY, RestfulMediaType.APPLICATION_XML_ERROR }) public Response clearProperty(@PathParam("domainType") String domainType, @PathParam("instanceId") final String instanceId, @PathParam("propertyId") final String propertyId) { init(Where.OBJECT_FORMS, RepresentationService.Intent.NOT_APPLICABLE); setCommandExecutor(Command.Executor.USER); final ObjectAdapter objectAdapter = getObjectAdapterElseThrowNotFound(domainType, instanceId); final DomainResourceHelper helper = newDomainResourceHelper(objectAdapter); final ObjectAdapterAccessHelper accessHelper = new ObjectAdapterAccessHelper(getResourceContext(), objectAdapter); final OneToOneAssociation property = accessHelper.getPropertyThatIsVisibleForIntent( propertyId, ObjectAdapterAccessHelper.Intent.MUTATE); final Consent consent = property.isAssociationValid(objectAdapter, null, InteractionInitiatedBy.USER); if (consent.isVetoed()) { throw RestfulObjectsApplicationException.createWithMessage(HttpStatusCode.UNAUTHORIZED, consent.getReason()); } property.set(objectAdapter, null, InteractionInitiatedBy.USER); return helper.propertyDetails( propertyId, MemberReprMode.WRITE ); }
@Override @DELETE @Path("/{oid}/properties/{propertyId}") @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ERROR }) public Response clearProperty(@PathParam("oid") final String oidStr, @PathParam("propertyId") final String propertyId) { init(Where.OBJECT_FORMS); final ObjectAdapter objectAdapter = getObjectAdapter(oidStr); final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext(), objectAdapter); final OneToOneAssociation property = helper.getPropertyThatIsVisibleAndUsable(propertyId, Intent.MUTATE, getResourceContext().getWhere()); final Consent consent = property.isAssociationValid(objectAdapter, null); if (consent.isVetoed()) { throw RestfulObjectsApplicationException.create(HttpStatusCode.UNAUTHORIZED, consent.getReason()); } property.set(objectAdapter, null); return helper.propertyDetails(objectAdapter, propertyId, MemberMode.MUTATING, Caching.NONE, getResourceContext().getWhere()); }
public void apply() { final ObjectAdapter adapter = getObjectAdapterMemento().getObjectAdapter(); for (final ScalarModel scalarModel : propertyScalarModels.values()) { final OneToOneAssociation property = scalarModel.getPropertyMemento().getProperty(); final ObjectAdapter associate = scalarModel.getObject(); property.set(adapter, associate); } getObjectAdapterMemento().setAdapter(adapter); toViewMode(); }
@Override @PUT @Path("/{oid}/properties/{propertyId}") @Consumes({ MediaType.WILDCARD }) @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ERROR }) public Response modifyProperty(@PathParam("oid") final String oidStr, @PathParam("propertyId") final String propertyId, final InputStream body) { init(Where.OBJECT_FORMS); final ObjectAdapter objectAdapter = getObjectAdapter(oidStr); final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext(), objectAdapter); final OneToOneAssociation property = helper.getPropertyThatIsVisibleAndUsable(propertyId, Intent.MUTATE, getResourceContext().getWhere()); final ObjectSpecification propertySpec = property.getSpecification(); final String bodyAsString = DomainResourceHelper.asStringUtf8(body); final ObjectAdapter argAdapter = helper.parseAsMapWithSingleValue(propertySpec, bodyAsString); final Consent consent = property.isAssociationValid(objectAdapter, argAdapter); if (consent.isVetoed()) { throw RestfulObjectsApplicationException.create(HttpStatusCode.UNAUTHORIZED, consent.getReason()); } property.set(objectAdapter, argAdapter); return helper.propertyDetails(objectAdapter, propertyId, MemberMode.MUTATING, Caching.NONE, getResourceContext().getWhere()); }
@Override @PUT @Path("/{domainType}/{instanceId}/properties/{propertyId}") @Consumes({ MediaType.WILDCARD }) @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ERROR }) public Response modifyProperty(@PathParam("domainType") String domainType, @PathParam("instanceId") final String instanceId, @PathParam("propertyId") final String propertyId, final InputStream body) { init(Where.OBJECT_FORMS); final ObjectAdapter objectAdapter = getObjectAdapterElseThrowNotFound(domainType, instanceId); final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext(), objectAdapter); final OneToOneAssociation property = helper.getPropertyThatIsVisibleForIntent(propertyId, Intent.MUTATE, getResourceContext().getWhere()); final ObjectSpecification propertySpec = property.getSpecification(); final String bodyAsString = DomainResourceHelper.asStringUtf8(body); final ObjectAdapter argAdapter = helper.parseAsMapWithSingleValue(propertySpec, bodyAsString); final Consent consent = property.isAssociationValid(objectAdapter, argAdapter); if (consent.isVetoed()) { throw RestfulObjectsApplicationException.createWithMessage(HttpStatusCode.UNAUTHORIZED, consent.getReason()); } property.set(objectAdapter, argAdapter); return helper.propertyDetails(propertyId, MemberMode.MUTATING, Caching.NONE, getResourceContext().getWhere()); }
!association.isEmpty(object, InteractionInitiatedBy.FRAMEWORK)) { final OneToOneAssociation property = (OneToOneAssociation) association; property.set(object, null, InteractionInitiatedBy.FRAMEWORK);
@Override @PUT @Path("/{domainType}/{instanceId}/properties/{propertyId}") @Consumes({ MediaType.WILDCARD }) @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_OBJECT_PROPERTY, RestfulMediaType.APPLICATION_JSON_ERROR, MediaType.APPLICATION_XML, RestfulMediaType.APPLICATION_XML_OBJECT_PROPERTY, RestfulMediaType.APPLICATION_XML_ERROR }) public Response modifyProperty(@PathParam("domainType") String domainType, @PathParam("instanceId") final String instanceId, @PathParam("propertyId") final String propertyId, final InputStream body) { init(Where.OBJECT_FORMS, RepresentationService.Intent.NOT_APPLICABLE); setCommandExecutor(Command.Executor.USER); final ObjectAdapter objectAdapter = getObjectAdapterElseThrowNotFound(domainType, instanceId); final DomainResourceHelper helper = newDomainResourceHelper(objectAdapter); final ObjectAdapterAccessHelper accessHelper = new ObjectAdapterAccessHelper(getResourceContext(), objectAdapter); final OneToOneAssociation property = accessHelper.getPropertyThatIsVisibleForIntent(propertyId, ObjectAdapterAccessHelper.Intent.MUTATE); final ObjectSpecification propertySpec = property.getSpecification(); final String bodyAsString = Util.asStringUtf8(body); final ObjectAdapter argAdapter = new JsonParserHelper(getResourceContext(), propertySpec).parseAsMapWithSingleValue( bodyAsString); final Consent consent = property.isAssociationValid(objectAdapter, argAdapter, InteractionInitiatedBy.USER); if (consent.isVetoed()) { throw RestfulObjectsApplicationException.createWithMessage(HttpStatusCode.UNAUTHORIZED, consent.getReason()); } property.set(objectAdapter, argAdapter, InteractionInitiatedBy.USER); return helper.propertyDetails( propertyId, MemberReprMode.WRITE ); }
if (consent.isAllowed()) { try { property.set(objectAdapter, valueAdapter); } catch (final IllegalArgumentException ex) { propertyRepr.mapPut("invalidReason", ex.getMessage());
property.set(adapter, associate, InteractionInitiatedBy.USER);
property.set(adapter, associate, InteractionInitiatedBy.USER);
if (validity.isAllowed()) { try { property.set(objectAdapter, valueAdapter); } catch (final IllegalArgumentException ex) { propertyRepr.mapPut("invalidReason", ex.getMessage());
property.set(targetAdapter, newValueAdapter, InteractionInitiatedBy.FRAMEWORK);
if (validity.isAllowed()) { try { property.set( objectAdapter, valueAdapter, resourceContext.getInteractionInitiatedBy());
will(returnValue(facets.stream())); oneOf(mockPasswordMember).set(mockEmployeeAdapter, mockPasswordAdapter, InteractionInitiatedBy.USER);
will(returnValue(facets)); oneOf(mockPasswordMember).set(mockEmployeeAdapter, mockPasswordAdapter, InteractionInitiatedBy.USER);