use of nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent in project nikita-noark5-core by HiOA-ABI.
the class PostalCodeService method handleUpdate.
/**
* Update a PostalCode identified by its systemId
* <p>
* Copy the values you are allowed to change, code and description
*
* @param systemId The systemId of the postalCode object you wish to
* update
* @param postalCode The updated postalCode object. Note the values
* you are allowed to change are copied from this
* object. This object is not persisted.
* @return the updated postalCode
*/
@Override
public MetadataHateoas handleUpdate(String systemId, Long version, PostalCode postalCode) {
PostalCode existingPostalCode = getPostalCodeOrThrow(systemId);
// Copy all the values you are allowed to copy ....
if (null != existingPostalCode.getCode()) {
existingPostalCode.setCode(existingPostalCode.getCode());
}
if (null != existingPostalCode.getDescription()) {
existingPostalCode.setDescription(existingPostalCode.getDescription());
}
// Note this can potentially result in a NoarkConcurrencyException
// exception
existingPostalCode.setVersion(version);
MetadataHateoas postalCodeHateoas = new MetadataHateoas(postalCodeRepository.save(existingPostalCode));
metadataHateoasHandler.addLinks(postalCodeHateoas, new Authorisation());
applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, existingPostalCode));
return postalCodeHateoas;
}
use of nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent in project nikita-noark5-core by HiOA-ABI.
the class RegistryEntryStatusService method handleUpdate.
/**
* Update a RegistryEntryStatus identified by its systemId
* <p>
* Copy the values you are allowed to change, code and description
*
* @param RegistryEntryStatus
* @return the updated RegistryEntryStatus
*/
@Override
public MetadataHateoas handleUpdate(String systemId, Long version, RegistryEntryStatus RegistryEntryStatus) {
RegistryEntryStatus existingRegistryEntryStatus = getRegistryEntryStatusOrThrow(systemId);
// Copy all the values you are allowed to copy ....
if (null != existingRegistryEntryStatus.getCode()) {
existingRegistryEntryStatus.setCode(existingRegistryEntryStatus.getCode());
}
if (null != existingRegistryEntryStatus.getDescription()) {
existingRegistryEntryStatus.setDescription(existingRegistryEntryStatus.getDescription());
}
// Note this can potentially result in a NoarkConcurrencyException
// exception
existingRegistryEntryStatus.setVersion(version);
MetadataHateoas RegistryEntryStatusHateoas = new MetadataHateoas(RegistryEntryStatusRepository.save(existingRegistryEntryStatus));
metadataHateoasHandler.addLinks(RegistryEntryStatusHateoas, new Authorisation());
applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, existingRegistryEntryStatus));
return RegistryEntryStatusHateoas;
}
use of nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent in project nikita-noark5-core by HiOA-ABI.
the class RegistryEntryTypeService method handleUpdate.
/**
* Update a RegistryEntryType identified by its systemId
* <p>
* Copy the values you are allowed to change, code and description
*
* @param systemId The systemId of the format object you wish to update
* @param format The updated format object. Note the values you are
* allowed to change are copied from this object. This
* object is not persisted.
* @return the updated format
*/
@Override
public MetadataHateoas handleUpdate(String systemId, Long version, RegistryEntryType format) {
RegistryEntryType existingRegistryEntryType = getRegistryEntryTypeOrThrow(systemId);
// Copy all the values you are allowed to copy ....
if (null != existingRegistryEntryType.getCode()) {
existingRegistryEntryType.setCode(existingRegistryEntryType.getCode());
}
if (null != existingRegistryEntryType.getDescription()) {
existingRegistryEntryType.setDescription(existingRegistryEntryType.getDescription());
}
// Note this can potentially result in a NoarkConcurrencyException
// exception
existingRegistryEntryType.setVersion(version);
MetadataHateoas formatHateoas = new MetadataHateoas(formatRepository.save(existingRegistryEntryType));
metadataHateoasHandler.addLinks(formatHateoas, new Authorisation());
applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, existingRegistryEntryType));
return formatHateoas;
}
use of nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent in project nikita-noark5-core by HiOA-ABI.
the class ClassHateoasController method updateClass.
// API - All PUT Requests (CRUD - UPDATE)
// Update a Class
// PUT [contextPath][api]/arkivstruktur/basisregistrering/{systemID}
@ApiOperation(value = "Updates a Class object", notes = "Returns the newly" + " update Class object after it is persisted to the database", response = ClassHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Class " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = ClassHateoas.class), @ApiResponse(code = 201, message = "Class " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = ClassHateoas.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 Class"), @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<ClassHateoas> updateClass(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemId of class to update.", required = true) @PathVariable("systemID") String systemID, @ApiParam(name = "class", value = "Incoming class object", required = true) @RequestBody Class klass) throws NikitaException {
validateForUpdate(klass);
Class updatedClass = classService.handleUpdate(systemID, parseETAG(request.getHeader(ETAG)), klass);
ClassHateoas classHateoas = new ClassHateoas(updatedClass);
classHateoasHandler.addLinks(classHateoas, new Authorisation());
applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, updatedClass));
return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(updatedClass.getVersion().toString()).body(classHateoas);
}
use of nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent in project nikita-noark5-core by HiOA-ABI.
the class ClassificationSystemHateoasController method updateClassificationSystem.
// API - All PUT Requests (CRUD - UPDATE)
// Update a ClassificationSystem
// PUT [contextPath][api]/arkivstruktur/klassifikasjonsystem/{systemID}
@ApiOperation(value = "Updates a ClassificationSystem object", notes = "Returns the newly" + " update ClassificationSystem object after it is persisted to the database", response = ClassificationSystemHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "ClassificationSystem " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = ClassificationSystemHateoas.class), @ApiResponse(code = 201, message = "ClassificationSystem " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = ClassificationSystemHateoas.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 ClassificationSystem"), @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@RequestMapping(method = RequestMethod.PUT, value = CLASSIFICATION_SYSTEM + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<ClassificationSystemHateoas> updateClassificationSystem(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemId of classificationSystem to update.", required = true) @PathVariable("systemID") String systemID, @ApiParam(name = "classificationSystem", value = "Incoming classificationSystem object", required = true) @RequestBody ClassificationSystem classificationSystem) throws NikitaException {
validateForUpdate(classificationSystem);
ClassificationSystem updatedClassificationSystem = classificationSystemService.handleUpdate(systemID, parseETAG(request.getHeader(ETAG)), classificationSystem);
ClassificationSystemHateoas classificationSystemHateoas = new ClassificationSystemHateoas(updatedClassificationSystem);
classificationSystemHateoasHandler.addLinks(classificationSystemHateoas, new Authorisation());
applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, updatedClassificationSystem));
return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(updatedClassificationSystem.getVersion().toString()).body(classificationSystemHateoas);
}
Aggregations