use of nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent in project nikita-noark5-core by HiOA-ABI.
the class CaseStatusService method handleUpdate.
/**
* Update a CaseStatus identified by its systemId
* <p>
* Copy the values you are allowed to change, code and description
*
* @param systemId The systemId of the caseStatus object you wish to
* update
* @param caseStatus The updated caseStatus object. Note the values
* you are allowed to change are copied from this
* object. This object is not persisted.
* @return the updated caseStatus
*/
@Override
public MetadataHateoas handleUpdate(String systemId, Long version, CaseStatus caseStatus) {
CaseStatus existingCaseStatus = getCaseStatusOrThrow(systemId);
// Copy all the values you are allowed to copy ....
if (null != existingCaseStatus.getCode()) {
existingCaseStatus.setCode(existingCaseStatus.getCode());
}
if (null != existingCaseStatus.getDescription()) {
existingCaseStatus.setDescription(existingCaseStatus.getDescription());
}
// Note this can potentially result in a NoarkConcurrencyException
// exception
existingCaseStatus.setVersion(version);
MetadataHateoas caseStatusHateoas = new MetadataHateoas(caseStatusRepository.save(existingCaseStatus));
metadataHateoasHandler.addLinks(caseStatusHateoas, new Authorisation());
applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, existingCaseStatus));
return caseStatusHateoas;
}
use of nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent in project nikita-noark5-core by HiOA-ABI.
the class CommentTypeService method handleUpdate.
/**
* Update a CommentType identified by its systemId
* <p>
* Copy the values you are allowed to change, code and description
*
* @param systemId The systemId of the commentType object you wish to
* update
* @param commentType The updated commentType object. Note the values
* you are allowed to change are copied from this
* object. This object is not persisted.
* @return the updated commentType
*/
@Override
public MetadataHateoas handleUpdate(String systemId, Long version, CommentType commentType) {
CommentType existingCommentType = getCommentTypeOrThrow(systemId);
// Copy all the values you are allowed to copy ....
if (null != existingCommentType.getCode()) {
existingCommentType.setCode(existingCommentType.getCode());
}
if (null != existingCommentType.getDescription()) {
existingCommentType.setDescription(existingCommentType.getDescription());
}
// Note this can potentially result in a NoarkConcurrencyException
// exception
existingCommentType.setVersion(version);
MetadataHateoas commentTypeHateoas = new MetadataHateoas(commentTypeRepository.save(existingCommentType));
metadataHateoasHandler.addLinks(commentTypeHateoas, new Authorisation());
applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, existingCommentType));
return commentTypeHateoas;
}
use of nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent in project nikita-noark5-core by HiOA-ABI.
the class DocumentObjectHateoasController method updateDocumentObject.
// API - All PUT Requests (CRUD - UPDATE)
// Update a DocumentObject
// PUT [contextPath][api]/arkivstruktur/dokumentobjekt/{systemID}
@ApiOperation(value = "Updates a DocumentObject object", notes = "Returns the newly" + " update DocumentObject object after it is persisted to the database", response = DocumentObjectHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "DocumentObject " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = DocumentObjectHateoas.class), @ApiResponse(code = 201, message = "DocumentObject " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = DocumentObjectHateoas.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 DocumentObject"), @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@RequestMapping(method = RequestMethod.PUT, value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<DocumentObjectHateoas> updateDocumentObject(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemId of documentObject to update.", required = true) @PathVariable("systemID") String systemID, @ApiParam(name = "documentObject", value = "Incoming documentObject object", required = true) @RequestBody DocumentObject documentObject) throws NikitaException {
validateForUpdate(documentObject);
DocumentObject updatedDocumentObject = documentObjectService.handleUpdate(systemID, parseETAG(request.getHeader(ETAG)), documentObject);
DocumentObjectHateoas documentObjectHateoas = new DocumentObjectHateoas(updatedDocumentObject);
documentObjectHateoasHandler.addLinks(documentObjectHateoas, new Authorisation());
applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, updatedDocumentObject));
return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(updatedDocumentObject.getVersion().toString()).body(documentObjectHateoas);
}
use of nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent in project nikita-noark5-core by HiOA-ABI.
the class FondsCreatorHateoasController method updateFondsCreator.
// API - All PUT Requests (CRUD - UPDATE)
// Updates a FondsCreator identified by a systemId
// PUT [contextPath][api]/arkivstruktur/arkivskaper/{systemId}
@ApiOperation(value = "Updates a FondsCreator identified by a systemId with new values", response = FondsCreator.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "FondsCreator updated", response = FondsCreator.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 = FONDS_CREATOR + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.PUT, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<FondsCreatorHateoas> updateFondsCreator(HttpServletRequest request, @ApiParam(name = "fondsCreator", value = "Incoming fondsCreator object", required = true) @RequestBody FondsCreator fondsCreator, @ApiParam(name = "systemId", value = "systemId of FondsCreator to retrieve.", required = true) @PathVariable("systemID") final String systemID) {
FondsCreator createdFonds = fondsCreatorService.handleUpdate(systemID, parseETAG(request.getHeader(ETAG)), fondsCreator);
applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, createdFonds));
FondsCreatorHateoas fondsCreatorHateoas = new FondsCreatorHateoas(createdFonds);
fondsCreatorHateoasHandler.addLinks(fondsCreatorHateoas, new Authorisation());
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(createdFonds.getVersion().toString()).body(fondsCreatorHateoas);
}
use of nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent in project nikita-noark5-core by HiOA-ABI.
the class RecordHateoasController method updateRecord.
// API - All PUT Requests (CRUD - UPDATE)
// Update a Record with given values
// PUT [contextPath][api]/arkivstruktur/registrering/{systemId}
@ApiOperation(value = "Updates a Record identified by a given systemId", notes = "Returns the newly updated record", response = RecordHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Record " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = RecordHateoas.class), @ApiResponse(code = 201, message = "Record " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = RecordHateoas.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 Record"), @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<RecordHateoas> updateRecord(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemId of record to update", required = true) @PathVariable("systemID") final String systemID, @ApiParam(name = "Record", value = "Incoming record object", required = true) @RequestBody Record record) throws NikitaException {
validateForUpdate(record);
Record updatedRecord = recordService.handleUpdate(systemID, parseETAG(request.getHeader(ETAG)), record);
RecordHateoas recordHateoas = new RecordHateoas(updatedRecord);
recordHateoasHandler.addLinks(recordHateoas, new Authorisation());
applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, updatedRecord));
return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(updatedRecord.getVersion().toString()).body(recordHateoas);
}
Aggregations