use of nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent in project nikita-noark5-core by HiOA-ABI.
the class SeriesHateoasController method updateSeries.
// Update an identified Series
// PUT [contextPath][api]/arkivstruktur/arkivdel/{systemId}
@ApiOperation(value = "Updates a Series object", notes = "Returns the newly" + " update Series object after it is persisted to the database", response = SeriesHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Series " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = SeriesHateoas.class), @ApiResponse(code = 201, message = "Series " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = SeriesHateoas.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 = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<SeriesHateoas> updateSeries(HttpServletRequest request, @ApiParam(name = "systemID", value = "systemId of fonds to update.", required = true) @PathVariable("systemID") String systemID, @ApiParam(name = "series", value = "Incoming series object", required = true) @RequestBody Series series) throws NikitaException {
validateForUpdate(series);
Series updatedSeries = seriesService.handleUpdate(systemID, parseETAG(request.getHeader(ETAG)), series);
SeriesHateoas seriesHateoas = new SeriesHateoas(updatedSeries);
seriesHateoasHandler.addLinks(seriesHateoas, new Authorisation());
applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, updatedSeries));
return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(updatedSeries.getVersion().toString()).body(seriesHateoas);
}
use of nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent in project nikita-noark5-core by HiOA-ABI.
the class CountryService method handleUpdate.
/**
* Update a Country identified by its systemId
* <p>
* Copy the values you are allowed to change, code and description
*
* @param systemId The systemId of the country object you wish to
* update
* @param country The updated country object. Note the values
* you are allowed to change are copied from this
* object. This object is not persisted.
* @return the updated country
*/
@Override
public MetadataHateoas handleUpdate(String systemId, Long version, Country country) {
Country existingCountry = getCountryOrThrow(systemId);
// Copy all the values you are allowed to copy ....
if (null != existingCountry.getCode()) {
existingCountry.setCode(existingCountry.getCode());
}
if (null != existingCountry.getDescription()) {
existingCountry.setDescription(existingCountry.getDescription());
}
// Note this can potentially result in a NoarkConcurrencyException
// exception
existingCountry.setVersion(version);
MetadataHateoas countryHateoas = new MetadataHateoas(countryRepository.save(existingCountry));
metadataHateoasHandler.addLinks(countryHateoas, new Authorisation());
applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, existingCountry));
return countryHateoas;
}
use of nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent in project nikita-noark5-core by HiOA-ABI.
the class DocumentTypeService method handleUpdate.
/**
* Update a documentType identified by its systemId
* <p>
* Copy the values you are allowed to change, code and description
*
* @param documentType
* @return the updated documentType
*/
@Override
public MetadataHateoas handleUpdate(String systemId, Long version, DocumentType documentType) {
DocumentType existingDocumentType = getDocumentTypeOrThrow(systemId);
// Copy all the values you are allowed to copy ....
if (null != existingDocumentType.getCode()) {
existingDocumentType.setCode(existingDocumentType.getCode());
}
if (null != existingDocumentType.getDescription()) {
existingDocumentType.setDescription(existingDocumentType.getDescription());
}
// Note this can potentially result in a NoarkConcurrencyException
// exception
existingDocumentType.setVersion(version);
MetadataHateoas documentTypeHateoas = new MetadataHateoas(documentTypeRepository.save(existingDocumentType));
metadataHateoasHandler.addLinks(documentTypeHateoas, new Authorisation());
applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, existingDocumentType));
return documentTypeHateoas;
}
use of nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent in project nikita-noark5-core by HiOA-ABI.
the class ElectronicSignatureSecurityLevelService method handleUpdate.
/**
* Update a ElectronicSignatureSecurityLevel identified by its systemId
* <p>
* Copy the values you are allowed to change, code and description
*
* @param systemId The systemId of the electronicSignatureSecurityLevel
* object you wish to update
* @param electronicSignatureSecurityLevel The updated
* electronicSignatureSecurityLevel
* object. Note the values you
* are allowed to change are
* copied from this object. This
* object is not persisted.
* @return the updated electronicSignatureSecurityLevel
*/
@Override
public MetadataHateoas handleUpdate(String systemId, Long version, ElectronicSignatureSecurityLevel electronicSignatureSecurityLevel) {
ElectronicSignatureSecurityLevel existingElectronicSignatureSecurityLevel = getElectronicSignatureSecurityLevelOrThrow(systemId);
// Copy all the values you are allowed to copy ....
if (null != existingElectronicSignatureSecurityLevel.getCode()) {
existingElectronicSignatureSecurityLevel.setCode(existingElectronicSignatureSecurityLevel.getCode());
}
if (null != existingElectronicSignatureSecurityLevel.getDescription()) {
existingElectronicSignatureSecurityLevel.setDescription(existingElectronicSignatureSecurityLevel.getDescription());
}
// Note this can potentially result in a NoarkConcurrencyException
// exception
existingElectronicSignatureSecurityLevel.setVersion(version);
MetadataHateoas electronicSignatureSecurityLevelHateoas = new MetadataHateoas(electronicSignatureSecurityLevelRepository.save(existingElectronicSignatureSecurityLevel));
metadataHateoasHandler.addLinks(electronicSignatureSecurityLevelHateoas, new Authorisation());
applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, existingElectronicSignatureSecurityLevel));
return electronicSignatureSecurityLevelHateoas;
}
use of nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent in project nikita-noark5-core by HiOA-ABI.
the class FileTypeService method handleUpdate.
/**
* Update a FileType identified by its systemId
* <p>
* Copy the values you are allowed to change, code and description
*
* @param systemId The systemId of the fileType object you wish to
* update
* @param fileType The updated fileType object. Note the values
* you are allowed to change are copied from this
* object. This object is not persisted.
* @return the updated fileType
*/
@Override
public MetadataHateoas handleUpdate(String systemId, Long version, FileType fileType) {
FileType existingFileType = getFileTypeOrThrow(systemId);
// Copy all the values you are allowed to copy ....
if (null != existingFileType.getCode()) {
existingFileType.setCode(existingFileType.getCode());
}
if (null != existingFileType.getDescription()) {
existingFileType.setDescription(existingFileType.getDescription());
}
// Note this can potentially result in a NoarkConcurrencyException
// exception
existingFileType.setVersion(version);
MetadataHateoas fileTypeHateoas = new MetadataHateoas(fileTypeRepository.save(existingFileType));
metadataHateoasHandler.addLinks(fileTypeHateoas, new Authorisation());
applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, existingFileType));
return fileTypeHateoas;
}
Aggregations