Search in sources :

Example 11 with CaseFileHateoas

use of nikita.model.noark5.v4.hateoas.casehandling.CaseFileHateoas 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)

Example 12 with CaseFileHateoas

use of nikita.model.noark5.v4.hateoas.casehandling.CaseFileHateoas in project nikita-noark5-core by HiOA-ABI.

the class SeriesHateoasController method createDefaultCaseFile.

// Create a CaseFile object with default values
// GET [contextPath][api]/arkivstruktur/arkivdel/{systemId}/ny-saksmappe/
@ApiOperation(value = "Create a CaseFile with default values", response = CaseFile.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CaseFile returned", response = CaseFile.class), @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER), @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@Timed
@RequestMapping(value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + NEW_CASE_FILE, method = RequestMethod.GET)
public ResponseEntity<CaseFileHateoas> createDefaultCaseFile(HttpServletRequest request, final HttpServletResponse response) {
    CaseFile defaultCaseFile = new CaseFile();
    defaultCaseFile.setTitle(TEST_TITLE);
    defaultCaseFile.setOfficialTitle(TEST_TITLE);
    defaultCaseFile.setFileId("2017/01");
    defaultCaseFile.setDescription(TEST_DESCRIPTION);
    defaultCaseFile.setDocumentMedium(DOCUMENT_MEDIUM_ELECTRONIC);
    defaultCaseFile.setTitle(TEST_TITLE);
    defaultCaseFile.setDescription(TEST_DESCRIPTION);
    defaultCaseFile.setDocumentMedium(DOCUMENT_MEDIUM_ELECTRONIC);
    defaultCaseFile.setCaseResponsible(TEST_USER_CASE_HANDLER_1);
    defaultCaseFile.setAdministrativeUnit(TEST_ADMINISTRATIVE_UNIT);
    defaultCaseFile.setCaseDate(new Date());
    defaultCaseFile.setCaseStatus(STATUS_OPEN);
    CaseFileHateoas caseFileHateoas = new CaseFileHateoas(defaultCaseFile);
    caseFileHateoasHandler.addLinksOnNew(caseFileHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(caseFileHateoas);
}
Also used : CaseFileHateoas(nikita.model.noark5.v4.hateoas.casehandling.CaseFileHateoas) CaseFile(nikita.model.noark5.v4.casehandling.CaseFile) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) Date(java.util.Date) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed)

Example 13 with CaseFileHateoas

use of nikita.model.noark5.v4.hateoas.casehandling.CaseFileHateoas in project nikita-noark5-core by HiOA-ABI.

the class SeriesHateoasController method findAllCaseFileAssociatedWithCaseFile.

// Retrieve all CaseFiles associated with a Series (paginated)
// GET [contextPath][api]/arkivstruktur/arkivdel/{systemId}/saksmappe/
// GET [contextPath][api]/arkivstruktur/arkivdel/{systemId}/saksmappe/?top=5&skip=1
@ApiOperation(value = "Retrieves a list of CaseFiles associated with a Series", notes = "The field skip" + "tells how many CaseFile rows of the result set to ignore (starting at 0), while  top tells how many rows" + " after skip to return. Note if the value of top is greater than system value " + " nikita-noark5-core.pagination.maxPageSize, then nikita-noark5-core.pagination.maxPageSize is used. ", response = CaseFileHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CaseFile list found", response = CaseFileHateoas.class), @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER), @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@Timed
@RequestMapping(value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + CASE_FILE, method = RequestMethod.GET)
public ResponseEntity<CaseFileHateoas> findAllCaseFileAssociatedWithCaseFile(HttpServletRequest request, @ApiParam(name = "systemID", value = "systemID of the series to retrieve", required = true) @PathVariable("systemID") final String systemID) {
    seriesService.findAllCaseFileBySeries(systemID);
    CaseFileHateoas caseFileHateoas = new CaseFileHateoas((ArrayList<INikitaEntity>) (ArrayList) seriesService.findAllCaseFileBySeries(systemID));
    caseFileHateoasHandler.addLinksOnRead(caseFileHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(caseFileHateoas);
}
Also used : CaseFileHateoas(nikita.model.noark5.v4.hateoas.casehandling.CaseFileHateoas) INikitaEntity(nikita.model.noark5.v4.interfaces.entities.INikitaEntity) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) ArrayList(java.util.ArrayList) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed)

Example 14 with CaseFileHateoas

use of nikita.model.noark5.v4.hateoas.casehandling.CaseFileHateoas in project nikita-noark5-core by HiOA-ABI.

the class SeriesHateoasController method createCaseFileAssociatedWithSeries.

// Create a new casefile
// POST [contextPath][api]/arkivstruktur/arkivdel/{systemId}/ny-saksmappe/
// This currently is not supported in the standard, but probably will be later
@ApiOperation(value = "Persists a CaseFile object associated with the given Series systemId", notes = "Returns " + "the newly created caseFile object after it was associated with a Series object and persisted to " + "the database", response = CaseFileHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "File " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = CaseFileHateoas.class), @ApiResponse(code = 201, message = "File " + 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
@Timed
@RequestMapping(method = RequestMethod.POST, value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + NEW_CASE_FILE, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<CaseFileHateoas> createCaseFileAssociatedWithSeries(HttpServletRequest request, @ApiParam(name = "systemID", value = "systemId of series to associate the caseFile with", required = true) @PathVariable String systemID, @ApiParam(name = "caseFile", value = "Incoming caseFile object", required = true) @RequestBody CaseFile caseFile) throws NikitaException {
    validateForCreate(caseFile);
    CaseFile createdCaseFile = seriesService.createCaseFileAssociatedWithSeries(systemID, caseFile);
    CaseFileHateoas caseFileHateoas = new CaseFileHateoas(createdCaseFile);
    caseFileHateoasHandler.addLinks(caseFileHateoas, request, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityCreatedEvent(this, createdCaseFile));
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(createdCaseFile.getVersion().toString()).body(caseFileHateoas);
}
Also used : CaseFileHateoas(nikita.model.noark5.v4.hateoas.casehandling.CaseFileHateoas) AfterNoarkEntityCreatedEvent(no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityCreatedEvent) CaseFile(nikita.model.noark5.v4.casehandling.CaseFile) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed)

Aggregations

Counted (com.codahale.metrics.annotation.Counted)12 Timed (com.codahale.metrics.annotation.Timed)6 ApiOperation (io.swagger.annotations.ApiOperation)6 ApiResponses (io.swagger.annotations.ApiResponses)6 CaseFileHateoas (nikita.common.model.noark5.v4.hateoas.casehandling.CaseFileHateoas)6 CaseFileHateoas (nikita.model.noark5.v4.hateoas.casehandling.CaseFileHateoas)6 Authorisation (nikita.webapp.security.Authorisation)6 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)6 CaseFile (nikita.common.model.noark5.v4.casehandling.CaseFile)5 CaseFile (nikita.model.noark5.v4.casehandling.CaseFile)5 ArrayList (java.util.ArrayList)2 List (java.util.List)2 INikitaEntity (nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity)2 INikitaEntity (nikita.model.noark5.v4.interfaces.entities.INikitaEntity)2 Date (java.util.Date)1 NoarkEntityNotFoundException (nikita.common.util.exceptions.NoarkEntityNotFoundException)1 NoarkEntityNotFoundException (nikita.util.exceptions.NoarkEntityNotFoundException)1 AfterNoarkEntityCreatedEvent (nikita.webapp.web.events.AfterNoarkEntityCreatedEvent)1 AfterNoarkEntityUpdatedEvent (nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent)1 AfterNoarkEntityCreatedEvent (no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityCreatedEvent)1