/** * @see org.openmrs.module.webservices.rest.web.resource.api.Purgeable#purge(java.lang.String) */ @Override public void purge(String uuid, RequestContext context) throws ResponseException { T delegate = getByUniqueId(uuid); if (delegate == null) { // HTTP DELETE is idempotent, so if we can't find the object, we assume it's already deleted and return success return; } purge(delegate, context); }
/** * @see org.openmrs.module.webservices.rest.web.resource.api.Deletable#delete(java.lang.String) */ @Override public void delete(String uuid, String reason, RequestContext context) throws ResponseException { T delegate = getByUniqueId(uuid); if (delegate == null) throw new ObjectNotFoundException(); delete(delegate, reason, context); }
/** * @see SubResource#getAll(java.lang.String, RequestContext) */ @Override public SimpleObject getAll(String parentUniqueId, RequestContext context) throws ResponseException { P parent = getParentResource().getByUniqueId(parentUniqueId); PageableResult result = doGetAll(parent, context); return result.toSimpleObject(this); }
/** * TODO * * @param delegateUuid * @param subResourceName * @param rep * @return * @throws ResponseException */ public Object listSubResource(String delegateUuid, String subResourceName, Representation rep) throws ResponseException { // TODO SUBCLASSHANDLER List<String> legal = getPropertiesToExposeAsSubResources(); if (legal == null || !legal.contains(subResourceName)) throw new IllegalPropertyException(); T delegate = getByUniqueId(delegateUuid); if (delegate == null) throw new ObjectNotFoundException(); return ConversionUtil.getPropertyWithRepresentation(delegate, subResourceName, rep); }
/** * @see org.openmrs.module.webservices.rest.web.resource.api.Retrievable#retrieve(java.lang.String, * org.openmrs.module.webservices.rest.web.representation.Representation) */ @Override public Object retrieve(String uuid, RequestContext context) throws ResponseException { T delegate = getByUniqueId(uuid); if (delegate == null) throw new ObjectNotFoundException(); SimpleObject ret = asRepresentation(delegate, context.getRepresentation()); if (hasTypesDefined()) ret.add(RestConstants.PROPERTY_FOR_TYPE, getTypeName(delegate)); return ret; }
/** * @see SubResource#create(java.lang.String, SimpleObject, RequestContext) */ @Override public Object create(String parentUniqueId, SimpleObject post, RequestContext context) throws ResponseException { PR parentResource = getParentResource(); P parent = parentResource.getByUniqueId(parentUniqueId); if (parent == null) throw new ObjectNotFoundException(); T delegate = newDelegate(); setParent(delegate, parent); DelegatingResourceDescription description = getBuildCreatableProperties(post); setConvertedProperties(delegate, post, description, true); delegate = save(delegate); return ConversionUtil.convertToRepresentation(delegate, Representation.DEFAULT); }
T delegate = getByUniqueId(uuid); if (delegate == null) throw new ObjectNotFoundException();