Search in sources :

Example 16 with AfterNoarkEntityUpdatedEvent

use of no.arkivlab.hioa.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
@Timed
@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, request, 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);
}
Also used : Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) Record(nikita.model.noark5.v4.Record) AfterNoarkEntityUpdatedEvent(no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

Counted (com.codahale.metrics.annotation.Counted)16 Timed (com.codahale.metrics.annotation.Timed)16 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)16 AfterNoarkEntityUpdatedEvent (no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent)16 ApiOperation (io.swagger.annotations.ApiOperation)15 ApiResponses (io.swagger.annotations.ApiResponses)15 FondsHateoas (nikita.model.noark5.v4.hateoas.FondsHateoas)2 CaseFileHateoas (nikita.model.noark5.v4.hateoas.casehandling.CaseFileHateoas)2 Class (nikita.model.noark5.v4.Class)1 ClassificationSystem (nikita.model.noark5.v4.ClassificationSystem)1 DocumentDescription (nikita.model.noark5.v4.DocumentDescription)1 DocumentObject (nikita.model.noark5.v4.DocumentObject)1 Fonds (nikita.model.noark5.v4.Fonds)1 FondsCreator (nikita.model.noark5.v4.FondsCreator)1 Record (nikita.model.noark5.v4.Record)1 CaseFile (nikita.model.noark5.v4.casehandling.CaseFile)1 RegistryEntry (nikita.model.noark5.v4.casehandling.RegistryEntry)1 CorrespondencePartInternal (nikita.model.noark5.v4.casehandling.secondary.CorrespondencePartInternal)1 CorrespondencePartPerson (nikita.model.noark5.v4.casehandling.secondary.CorrespondencePartPerson)1 CorrespondencePartUnit (nikita.model.noark5.v4.casehandling.secondary.CorrespondencePartUnit)1