Search in sources :

Example 26 with NoarkEntityNotFoundException

use of nikita.common.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.

the class RecordHateoasController method findAllDocumentDescriptionAssociatedWithRecord.

// Retrieve all DocumentDescriptions associated with a Record identified by systemId
// GET [contextPath][api]/arkivstruktur/resgistrering/{systemId}/dokumentbeskrivelse
@ApiOperation(value = "Retrieves a lit of DocumentDescriptions associated with a Record", response = DocumentDescriptionHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "DocumentDescription returned", response = DocumentDescriptionHateoas.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
@RequestMapping(value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + DOCUMENT_DESCRIPTION, method = RequestMethod.GET)
public ResponseEntity<DocumentDescriptionHateoas> findAllDocumentDescriptionAssociatedWithRecord(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the file to retrieve associated Record", required = true) @PathVariable("systemID") final String systemID) {
    Record record = recordService.findBySystemId(systemID);
    if (record == null) {
        throw new NoarkEntityNotFoundException("Could not find File object with systemID " + systemID);
    }
    DocumentDescriptionHateoas documentDescriptionHateoas = new DocumentDescriptionHateoas((List<INikitaEntity>) (List) record.getReferenceDocumentDescription());
    documentDescriptionHateoasHandler.addLinks(documentDescriptionHateoas, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(documentDescriptionHateoas);
}
Also used : INikitaEntity(nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity) Authorisation(nikita.webapp.security.Authorisation) Record(nikita.common.model.noark5.v4.Record) NoarkEntityNotFoundException(nikita.common.util.exceptions.NoarkEntityNotFoundException) List(java.util.List) Counted(com.codahale.metrics.annotation.Counted) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 27 with NoarkEntityNotFoundException

use of nikita.common.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.

the class SeriesHateoasController method findOneSeriesbySystemId.

// API - All GET Requests (CRUD - READ)
// Retrieve a Series given a systemId
// GET [contextPath][api]/arkivstruktur/arkivdel/{systemId}/
@ApiOperation(value = "Retrieves a single Series entity given a systemId", response = Series.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Series returned", response = Series.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
@RequestMapping(value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.GET)
public ResponseEntity<SeriesHateoas> findOneSeriesbySystemId(HttpServletRequest request, @ApiParam(name = "systemID", value = "systemID of the series to retrieve", required = true) @PathVariable("systemID") final String systemID) {
    Series series = seriesService.findBySystemId(systemID);
    if (series == null) {
        throw new NoarkEntityNotFoundException("Could not find series object with systemID " + systemID);
    }
    SeriesHateoas seriesHateoas = new SeriesHateoas(series);
    seriesHateoasHandler.addLinks(seriesHateoas, new Authorisation());
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(series.getVersion().toString()).body(seriesHateoas);
}
Also used : Authorisation(nikita.webapp.security.Authorisation) NoarkEntityNotFoundException(nikita.common.util.exceptions.NoarkEntityNotFoundException) Counted(com.codahale.metrics.annotation.Counted)

Example 28 with NoarkEntityNotFoundException

use of nikita.common.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.

the class SeriesHateoasController method findAllFileAssociatedWithSeries.

// Retrieve all Files associated with a Series (paginated)
// GET [contextPath][api]/arkivstruktur/arkivdel/{systemId}/mappe/
// GET [contextPath][api]/arkivstruktur/arkivdel/{systemId}/mappe/?top=5&skip=1
@ApiOperation(value = "Retrieves a list of Files associated with a Series", notes = "The field skip" + "tells how many File 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 = FileHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "File list found", response = FileHateoas.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
@RequestMapping(value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + FILE, method = RequestMethod.GET)
public ResponseEntity<FileHateoas> findAllFileAssociatedWithSeries(HttpServletRequest request, @RequestParam(name = "top", required = false) Integer top, @RequestParam(name = "skip", required = false) Integer skip, @ApiParam(name = "systemID", value = "systemID of the series to retrieve", required = true) @PathVariable("systemID") final String systemID) {
    Series series = seriesService.findBySystemId(systemID);
    if (series == null) {
        throw new NoarkEntityNotFoundException("Could not find series object with systemID " + systemID);
    }
    FileHateoas fileHateoas = new FileHateoas((List<INikitaEntity>) (List) series.getReferenceFile());
    fileHateoasHandler.addLinks(fileHateoas, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(fileHateoas);
}
Also used : INikitaEntity(nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity) Authorisation(nikita.webapp.security.Authorisation) NoarkEntityNotFoundException(nikita.common.util.exceptions.NoarkEntityNotFoundException) List(java.util.List) CaseFileHateoas(nikita.common.model.noark5.v4.hateoas.casehandling.CaseFileHateoas) Counted(com.codahale.metrics.annotation.Counted)

Example 29 with NoarkEntityNotFoundException

use of nikita.common.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.

the class CaseFileHateoasController method findRegistryEntryAssociatedWithCaseFileBySystemId.

// Retrieve all RegistryEntry associated with a casefile identified by systemId
// GET [contextPath][api]/casehandling/saksmappe/{systemID}/journalpost
@ApiOperation(value = "Retrieves all RegistryEntry associated with a CaseFile identified by systemId", response = RegistryEntry.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "RegistryEntry list returned", response = RegistryEntryHateoas.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
@RequestMapping(value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + REGISTRY_ENTRY, method = RequestMethod.GET)
public ResponseEntity<RegistryEntryHateoas> findRegistryEntryAssociatedWithCaseFileBySystemId(HttpServletRequest request, @ApiParam(name = "systemID", value = "systemID of the caseFile to retrieve", required = true) @PathVariable("systemID") final String caseFileSystemId) {
    CaseFile caseFile = caseFileService.findBySystemId(caseFileSystemId);
    if (caseFile == null) {
        throw new NoarkEntityNotFoundException(caseFileSystemId);
    }
    RegistryEntryHateoas registryEntryHateoas = new RegistryEntryHateoas((List<INikitaEntity>) (List) (caseFile.getReferenceRecord()));
    registryEntryHateoasHandler.addLinks(registryEntryHateoas, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(registryEntryHateoas);
}
Also used : RegistryEntryHateoas(nikita.common.model.noark5.v4.hateoas.casehandling.RegistryEntryHateoas) CaseFile(nikita.common.model.noark5.v4.casehandling.CaseFile) INikitaEntity(nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity) Authorisation(nikita.webapp.security.Authorisation) NoarkEntityNotFoundException(nikita.common.util.exceptions.NoarkEntityNotFoundException) List(java.util.List) Counted(com.codahale.metrics.annotation.Counted) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 30 with NoarkEntityNotFoundException

use of nikita.common.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.

the class CaseFileHateoasController method findOneCaseFilebySystemId.

// Retrieve a single casefile identified by systemId
// GET [contextPath][api]/casehandling/saksmappe/{systemID}
@ApiOperation(value = "Retrieves a single CaseFile entity given a systemId", 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
@RequestMapping(value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.GET)
public ResponseEntity<CaseFileHateoas> findOneCaseFilebySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the caseFile to retrieve", required = true) @PathVariable("systemID") final String caseFileSystemId) {
    CaseFile caseFile = caseFileService.findBySystemId(caseFileSystemId);
    if (caseFile == null) {
        throw new NoarkEntityNotFoundException(caseFileSystemId);
    }
    CaseFileHateoas caseFileHateoas = new CaseFileHateoas(caseFile);
    caseFileHateoasHandler.addLinks(caseFileHateoas, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(caseFile.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) NoarkEntityNotFoundException(nikita.common.util.exceptions.NoarkEntityNotFoundException) Counted(com.codahale.metrics.annotation.Counted) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

NoarkEntityNotFoundException (nikita.common.util.exceptions.NoarkEntityNotFoundException)55 Authorisation (nikita.webapp.security.Authorisation)13 Counted (com.codahale.metrics.annotation.Counted)12 ApiOperation (io.swagger.annotations.ApiOperation)10 ApiResponses (io.swagger.annotations.ApiResponses)10 List (java.util.List)5 DocumentDescription (nikita.common.model.noark5.v4.DocumentDescription)5 DocumentObject (nikita.common.model.noark5.v4.DocumentObject)5 CaseFile (nikita.common.model.noark5.v4.casehandling.CaseFile)5 INikitaEntity (nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity)5 Class (nikita.common.model.noark5.v4.Class)4 File (nikita.common.model.noark5.v4.File)4 Record (nikita.common.model.noark5.v4.Record)4 BasicRecord (nikita.common.model.noark5.v4.BasicRecord)3 ClassificationSystem (nikita.common.model.noark5.v4.ClassificationSystem)3 Series (nikita.common.model.noark5.v4.Series)3 DocumentObjectHateoas (nikita.common.model.noark5.v4.hateoas.DocumentObjectHateoas)3 NoarkEntityEditWhenClosedException (nikita.common.util.exceptions.NoarkEntityEditWhenClosedException)3 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2