Search in sources :

Example 36 with CaseFile

use of nikita.common.model.noark5.v4.casehandling.CaseFile in project nikita-noark5-core by HiOA-ABI.

the class CaseFileHateoasController method updateCaseFile.

// Update a CaseFile with given values
// PUT [contextPath][api]/casehandling/saksmappe/{systemId}
@ApiOperation(value = "Updates a CaseFile identified by a given systemId", notes = "Returns the newly updated caseFile", response = CaseFileHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CaseFile " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = CaseFileHateoas.class), @ApiResponse(code = 201, message = "CaseFile " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = CaseFileHateoas.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 CaseFile"), @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<CaseFileHateoas> updateCaseFile(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemId of caseFile to update", required = true) @PathVariable("systemID") final String systemID, @ApiParam(name = "CaseFile", value = "Incoming caseFile object", required = true) @RequestBody CaseFile caseFile) throws NikitaException {
    validateForUpdate(caseFile);
    CaseFile updatedCaseFile = caseFileService.handleUpdate(systemID, parseETAG(request.getHeader(ETAG)), caseFile);
    CaseFileHateoas caseFileHateoas = new CaseFileHateoas(updatedCaseFile);
    caseFileHateoasHandler.addLinks(caseFileHateoas, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, updatedCaseFile));
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(updatedCaseFile.getVersion().toString()).body(caseFileHateoas);
}
Also used : CaseFileHateoas(nikita.common.model.noark5.v4.hateoas.casehandling.CaseFileHateoas) CaseFile(nikita.common.model.noark5.v4.casehandling.CaseFile) Authorisation(nikita.webapp.security.Authorisation) AfterNoarkEntityUpdatedEvent(nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent) Counted(com.codahale.metrics.annotation.Counted) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

Counted (com.codahale.metrics.annotation.Counted)18 CaseFile (nikita.model.noark5.v4.casehandling.CaseFile)17 CaseFile (nikita.common.model.noark5.v4.casehandling.CaseFile)15 ApiOperation (io.swagger.annotations.ApiOperation)10 ApiResponses (io.swagger.annotations.ApiResponses)10 Timed (com.codahale.metrics.annotation.Timed)9 Authorisation (nikita.webapp.security.Authorisation)9 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)9 CaseFileHateoas (nikita.common.model.noark5.v4.hateoas.casehandling.CaseFileHateoas)7 CaseFileHateoas (nikita.model.noark5.v4.hateoas.casehandling.CaseFileHateoas)7 NoarkEntityNotFoundException (nikita.util.exceptions.NoarkEntityNotFoundException)6 NoarkEntityNotFoundException (nikita.common.util.exceptions.NoarkEntityNotFoundException)4 Series (nikita.model.noark5.v4.Series)4 List (java.util.List)3 Series (nikita.common.model.noark5.v4.Series)3 INikitaEntity (nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2