Search in sources :

Example 11 with RecordHateoas

use of nikita.common.model.noark5.v4.hateoas.RecordHateoas in project nikita-noark5-core by HiOA-ABI.

the class FileHateoasController method findAllRecordsAssociatedWithFile.

// API - All GET Requests (CRUD - READ)
// Retrieve all Records associated with File identified by systemId
// GET [contextPath][api]/arkivstruktur/mappe/{systemId}/registrering
// REL http://rel.kxml.no/noark5/v4/api/arkivstruktur/registrering/
@ApiOperation(value = "Retrieve all Record associated with a File identified by systemId", response = RecordHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Record returned", response = RecordHateoas.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 + REGISTRATION, method = RequestMethod.GET)
public ResponseEntity<RecordHateoas> findAllRecordsAssociatedWithFile(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) {
    File file = fileService.findBySystemId(systemID);
    if (file == null) {
        throw new NoarkEntityNotFoundException("Could not find File object with systemID " + systemID);
    }
    RecordHateoas recordHateoas = new RecordHateoas((List<INikitaEntity>) (List) file.getReferenceRecord());
    recordHateoasHandler.addLinks(recordHateoas, new Authorisation());
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(recordHateoas);
}
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) Counted(com.codahale.metrics.annotation.Counted) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 12 with RecordHateoas

use of nikita.common.model.noark5.v4.hateoas.RecordHateoas in project nikita-noark5-core by HiOA-ABI.

the class RecordHateoasController method findOneRecordbySystemId.

// API - All GET Requests (CRUD - READ)
// Retrieve a Record identified by a systemId
// GET [contextPath][api]/arkivstruktur/registrering/{systemId}
// http://rel.kxml.no/noark5/v4/api/arkivstruktur/registrering/
@ApiOperation(value = "Retrieves a single Record entity given a systemId", response = Record.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Record returned", response = Record.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<RecordHateoas> findOneRecordbySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the record to retrieve", required = true) @PathVariable("systemID") final String systemID) {
    Record record = recordService.findBySystemId(systemID);
    RecordHateoas recordHateoas = new RecordHateoas(record);
    recordHateoasHandler.addLinks(recordHateoas, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(record.getVersion().toString()).body(recordHateoas);
}
Also used : Authorisation(nikita.webapp.security.Authorisation) Record(nikita.common.model.noark5.v4.Record) Counted(com.codahale.metrics.annotation.Counted) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 13 with RecordHateoas

use of nikita.common.model.noark5.v4.hateoas.RecordHateoas in project nikita-noark5-core by HiOA-ABI.

the class RecordHateoasController method findAllRecord.

// Retrieve all Records
// GET [contextPath][api]/arkivstruktur/registrering
// http://rel.kxml.no/noark5/v4/api/arkivstruktur/registrering/
@ApiOperation(value = "Retrieves multiple Record entities limited by ownership rights", notes = "The field skip tells how many Record 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 = RecordHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "RecordHateoas found", response = RecordHateoas.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(method = RequestMethod.GET)
public ResponseEntity<RecordHateoas> findAllRecord(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @RequestParam(name = "top", required = false) Integer top, @RequestParam(name = "skip", required = false) Integer skip) {
    String ownedBy = SecurityContextHolder.getContext().getAuthentication().getName();
    RecordHateoas recordHateoas = new RecordHateoas((List<INikitaEntity>) (List) recordService.findByOwnedBy(ownedBy));
    recordHateoasHandler.addLinks(recordHateoas, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(recordHateoas);
}
Also used : INikitaEntity(nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity) Authorisation(nikita.webapp.security.Authorisation) List(java.util.List) Counted(com.codahale.metrics.annotation.Counted) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 14 with RecordHateoas

use of nikita.common.model.noark5.v4.hateoas.RecordHateoas in project nikita-noark5-core by HiOA-ABI.

the class SeriesHateoasController method findAllRecordAssociatedWithSeries.

// Retrieve all Records associated with a Series (paginated)
// GET [contextPath][api]/arkivstruktur/arkivdel/{systemId}/registrering/
// GET [contextPath][api]/arkivstruktur/arkivdel/{systemId}/registrering/?top=5&skip=1
@ApiOperation(value = "Retrieves a lit of Records associated with a Series", notes = "The field skip" + "tells how many Record 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 = RecordHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Record list found", response = RecordHateoas.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 + REGISTRATION, method = RequestMethod.GET)
public ResponseEntity<RecordHateoas> findAllRecordAssociatedWithSeries(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);
    RecordHateoas recordHateoas = new RecordHateoas((List<INikitaEntity>) (List) series.getReferenceRecord());
    recordHateoasHandler.addLinks(recordHateoas, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(recordHateoas);
}
Also used : INikitaEntity(nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity) Authorisation(nikita.webapp.security.Authorisation) List(java.util.List) Counted(com.codahale.metrics.annotation.Counted)

Aggregations

Counted (com.codahale.metrics.annotation.Counted)12 ApiOperation (io.swagger.annotations.ApiOperation)11 ApiResponses (io.swagger.annotations.ApiResponses)11 Authorisation (nikita.webapp.security.Authorisation)7 Timed (com.codahale.metrics.annotation.Timed)5 Record (nikita.common.model.noark5.v4.Record)5 Record (nikita.model.noark5.v4.Record)5 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)5 List (java.util.List)4 ArrayList (java.util.ArrayList)3 INikitaEntity (nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity)3 DocumentDescription (nikita.common.model.noark5.v4.DocumentDescription)2 RecordHateoas (nikita.common.model.noark5.v4.hateoas.RecordHateoas)2 DocumentDescription (nikita.model.noark5.v4.DocumentDescription)2 RecordHateoas (nikita.model.noark5.v4.hateoas.RecordHateoas)2 INikitaEntity (nikita.model.noark5.v4.interfaces.entities.INikitaEntity)2 AfterNoarkEntityDeletedEvent (nikita.webapp.web.events.AfterNoarkEntityDeletedEvent)2 AfterNoarkEntityDeletedEvent (no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityDeletedEvent)2 DocumentObject (nikita.common.model.noark5.v4.DocumentObject)1 NoarkEntity (nikita.common.model.noark5.v4.NoarkEntity)1