use of nikita.common.model.noark5.v4.casehandling.RegistryEntry in project nikita-noark5-core by HiOA-ABI.
the class RegistryEntryHateoasController method updateRegistryEntry.
// Update a RegistryEntry with given values
// PUT [contextPath][api]/casehandling/journalpost/{systemId}
@ApiOperation(value = "Updates a RegistryEntry identified by a given systemId", notes = "Returns the newly updated registryEntry", response = RegistryEntryHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "RegistryEntry " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = RegistryEntryHateoas.class), @ApiResponse(code = 201, message = "RegistryEntry " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = RegistryEntryHateoas.class), @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER), @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER), @ApiResponse(code = 404, message = API_MESSAGE_PARENT_DOES_NOT_EXIST + " of type RegistryEntry"), @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@RequestMapping(value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.PUT, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<RegistryEntryHateoas> updateRegistryEntry(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemId of registryEntry to update", required = true) @PathVariable("systemID") final String systemID, @ApiParam(name = "RegistryEntry", value = "Incoming registryEntry object", required = true) @RequestBody RegistryEntry registryEntry) throws NikitaException {
validateForUpdate(registryEntry);
RegistryEntry updatedRegistryEntry = registryEntryService.handleUpdate(systemID, parseETAG(request.getHeader(ETAG)), registryEntry);
RegistryEntryHateoas registryEntryHateoas = new RegistryEntryHateoas(updatedRegistryEntry);
registryEntryHateoasHandler.addLinks(registryEntryHateoas, new Authorisation());
applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, updatedRegistryEntry));
return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(updatedRegistryEntry.getVersion().toString()).body(registryEntryHateoas);
}
use of nikita.common.model.noark5.v4.casehandling.RegistryEntry in project nikita-noark5-core by HiOA-ABI.
the class RegistryEntryHateoasController method deleteRecordBySystemId.
// Delete a Record identified by systemID
// DELETE [contextPath][api]/casehandling/journalpost/{systemId}/
@ApiOperation(value = "Deletes a single RegistryEntry entity identified by systemID", response = String.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Parent entity (DocumentDescription or Record) returned", response = String.class), @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER), @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@RequestMapping(value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.DELETE)
public ResponseEntity<String> deleteRecordBySystemId(HttpServletRequest request, @ApiParam(name = "systemID", value = "systemID of the record to delete", required = true) @PathVariable("systemID") final String systemID) {
RegistryEntry registryEntry = registryEntryService.findBySystemId(systemID);
registryEntryService.deleteEntity(systemID);
applicationEventPublisher.publishEvent(new AfterNoarkEntityDeletedEvent(this, registryEntry));
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(CommonUtils.WebUtils.getSuccessStatusStringForDelete());
}
Aggregations