use of org.hisp.dhis.patch.Patch in project dhis2-core by dhis2.
the class AbstractCrudController method partialUpdateObject.
// --------------------------------------------------------------------------
// OLD PATCH
// --------------------------------------------------------------------------
@PatchMapping(value = "/{uid}")
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void partialUpdateObject(@PathVariable("uid") String pvUid, @RequestParam Map<String, String> rpParameters, @CurrentUser User currentUser, HttpServletRequest request) throws Exception {
WebOptions options = new WebOptions(rpParameters);
List<T> entities = getEntity(pvUid, options);
if (entities.isEmpty()) {
throw new WebMessageException(notFound(getEntityClass(), pvUid));
}
T persistedObject = entities.get(0);
if (!aclService.canUpdate(currentUser, persistedObject)) {
throw new UpdateAccessDeniedException("You don't have the proper permissions to update this object.");
}
Patch patch = diff(request);
prePatchEntity(persistedObject);
patchService.apply(patch, persistedObject);
validateAndThrowErrors(() -> schemaValidator.validate(persistedObject));
manager.update(persistedObject);
postPatchEntity(persistedObject);
}
Aggregations