Search in sources :

Example 1 with AfterNoarkEntityUpdatedEvent

use of no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent in project nikita-noark5-core by HiOA-ABI.

the class BasicRecordHateoasController method updateBasicRecord.

// API - All PUT Requests (CRUD - UPDATE)
// Update a BasicRecord
// PUT [contextPath][api]/arkivstruktur/basisregistrering/{systemID}
@ApiOperation(value = "Updates a BasicRecord object", notes = "Returns the newly" + " update BasicRecord object after it is persisted to the database", response = BasicRecordHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "BasicRecord " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = BasicRecordHateoas.class), @ApiResponse(code = 201, message = "BasicRecord " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = BasicRecordHateoas.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 BasicRecord"), @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@Timed
@RequestMapping(method = RequestMethod.PUT, value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<BasicRecordHateoas> updateBasicRecord(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemId of basicRecord to update.", required = true) @PathVariable("systemID") String systemID, @ApiParam(name = "basicRecord", value = "Incoming basicRecord object", required = true) @RequestBody BasicRecord basicRecord) throws NikitaException {
    validateForUpdate(basicRecord);
    BasicRecord updatedBasicRecord = basicRecordService.handleUpdate(systemID, parseETAG(request.getHeader(ETAG)), basicRecord);
    BasicRecordHateoas basicRecordHateoas = new BasicRecordHateoas(updatedBasicRecord);
    basicRecordHateoasHandler.addLinks(basicRecordHateoas, request, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, updatedBasicRecord));
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(updatedBasicRecord.getVersion().toString()).body(basicRecordHateoas);
}
Also used : Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) 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)

Example 2 with AfterNoarkEntityUpdatedEvent

use of no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent in project nikita-noark5-core by HiOA-ABI.

the class DocumentDescriptionHateoasController method updateDocumentDescription.

// API - All PUT Requests (CRUD - UPDATE)
// Update a DocumentDescription
// PUT [contextPath][api]/arkivstruktur/dokumentobjekt/{systemID}
@ApiOperation(value = "Updates a DocumentDescription object", notes = "Returns the newly" + " update DocumentDescription object after it is persisted to the database", response = DocumentDescriptionHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "DocumentDescription " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = DocumentDescriptionHateoas.class), @ApiResponse(code = 201, message = "DocumentDescription " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = DocumentDescriptionHateoas.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 DocumentDescription"), @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@Timed
@RequestMapping(method = RequestMethod.PUT, value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<DocumentDescriptionHateoas> updateDocumentDescription(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemId of documentDescription to update.", required = true) @PathVariable("systemID") String systemID, @ApiParam(name = "documentDescription", value = "Incoming documentDescription object", required = true) @RequestBody DocumentDescription documentDescription) throws NikitaException {
    validateForUpdate(documentDescription);
    DocumentDescription updatedDocumentDescription = documentDescriptionService.handleUpdate(systemID, parseETAG(request.getHeader(ETAG)), documentDescription);
    DocumentDescriptionHateoas documentDescriptionHateoas = new DocumentDescriptionHateoas(updatedDocumentDescription);
    documentDescriptionHateoasHandler.addLinks(documentDescriptionHateoas, request, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, updatedDocumentDescription));
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(updatedDocumentDescription.getVersion().toString()).body(documentDescriptionHateoas);
}
Also used : DocumentDescription(nikita.model.noark5.v4.DocumentDescription) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) DocumentDescriptionHateoas(nikita.model.noark5.v4.hateoas.DocumentDescriptionHateoas) 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)

Example 3 with AfterNoarkEntityUpdatedEvent

use of no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent in project nikita-noark5-core by HiOA-ABI.

the class FileHateoasController method updateFile.

// API - All PUT Requests (CRUD - UPDATE)
// Update a File with given values
// PUT [contextPath][api]/arkivstruktur/mappe/{systemId}
@ApiOperation(value = "Updates a File identified by a given systemId", notes = "Returns the newly updated file", response = FileHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "File " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = FileHateoas.class), @ApiResponse(code = 201, message = "File " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = FileHateoas.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 File"), @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<FileHateoas> updateFile(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemId of file to update", required = true) @PathVariable("systemID") final String systemID, @ApiParam(name = "File", value = "Incoming file object", required = true) @RequestBody File file) throws NikitaException {
    validateForUpdate(file);
    File updatedFile = fileService.handleUpdate(systemID, parseETAG(request.getHeader(ETAG)), file);
    FileHateoas fileHateoas = new FileHateoas(updatedFile);
    fileHateoasHandler.addLinks(fileHateoas, request, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, updatedFile));
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(updatedFile.getVersion().toString()).body(fileHateoas);
}
Also used : Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) CaseFileHateoas(nikita.model.noark5.v4.hateoas.casehandling.CaseFileHateoas) 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)

Example 4 with AfterNoarkEntityUpdatedEvent

use of no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent in project nikita-noark5-core by HiOA-ABI.

the class FondsCreatorHateoasController method createFondsAssociatedWithFondsCreator.

// Create a new fonds
// POST [contextPath][api]/arkivstruktur/arkivskaper/{systemID}/ny-arkiv
@ApiOperation(value = "Persists a new Fonds associated with a FondsCreator", notes = "Returns the newly" + " created Fonds after it is associated with the Fonds and persisted to the database", response = FondsCreatorHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Fonds " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = FondsHateoas.class), @ApiResponse(code = 201, message = "Fonds " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = FondsHateoas.class), @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER), @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER), @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@Timed
@RequestMapping(method = RequestMethod.POST, value = FONDS_CREATOR + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + NEW_FONDS, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<FondsHateoas> createFondsAssociatedWithFondsCreator(HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemId", value = "systemId of FondsCreator to associate the Fonds with.", required = true) @PathVariable("systemID") String systemID, @ApiParam(name = "fonds", value = "Incoming fonds object", required = true) @RequestBody Fonds fonds) throws NikitaException {
    fondsCreatorService.createFondsAssociatedWithFondsCreator(systemID, fonds);
    FondsHateoas fondsHateoas = new FondsHateoas(fonds);
    fondsHateoasHandler.addLinks(fondsHateoas, request, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, fonds));
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(fonds.getVersion().toString()).body(fondsHateoas);
}
Also used : FondsHateoas(nikita.model.noark5.v4.hateoas.FondsHateoas) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) 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)

Example 5 with AfterNoarkEntityUpdatedEvent

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

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