Search in sources :

Example 36 with DocumentObject

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

the class DocumentObjectHateoasController method findAllDocumentObject.

// Get all documentObject
// GET [contextPath][api]/arkivstruktur/dokumentobjekt/
@ApiOperation(value = "Retrieves multiple DocumentObject entities limited by ownership rights", notes = "The field skip" + "tells how many DocumentObject 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 = DocumentObjectHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "DocumentObject list found", response = DocumentObjectHateoas.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, produces = { NOARK5_V4_CONTENT_TYPE_JSON, NOARK5_V4_CONTENT_TYPE_JSON_XML })
public ResponseEntity<DocumentObjectHateoas> findAllDocumentObject(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @RequestParam(name = "top", required = false) Integer top, @RequestParam(name = "skip", required = false) Integer skip, @RequestParam(name = "filter", required = false) String filter) {
    String reg = " ";
    String[] pieces;
    DocumentObjectHateoas documentObjectHateoas = null;
    if (filter != null) {
        pieces = filter.split(reg);
        if (pieces.length == 3 && pieces[1].equalsIgnoreCase("eq")) {
            pieces[2] = pieces[2].replace("\'", "");
            documentObjectHateoas = new DocumentObjectHateoas((List<INikitaEntity>) (List) documentObjectService.findDocumentObjectByAnyColumn(pieces[0], pieces[2]));
        }
    }
    if (null == documentObjectHateoas) {
        String loggedInUser = SecurityContextHolder.getContext().getAuthentication().getName();
        documentObjectHateoas = new DocumentObjectHateoas((List<INikitaEntity>) (List) documentObjectService.findByOwnedBy(loggedInUser));
    }
    documentObjectHateoasHandler.addLinks(documentObjectHateoas, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(documentObjectHateoas);
}
Also used : DocumentObjectHateoas(nikita.common.model.noark5.v4.hateoas.DocumentObjectHateoas) 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)

Aggregations

Counted (com.codahale.metrics.annotation.Counted)20 ApiOperation (io.swagger.annotations.ApiOperation)20 ApiResponses (io.swagger.annotations.ApiResponses)20 DocumentObject (nikita.model.noark5.v4.DocumentObject)16 DocumentObject (nikita.common.model.noark5.v4.DocumentObject)15 Timed (com.codahale.metrics.annotation.Timed)10 Authorisation (nikita.webapp.security.Authorisation)9 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)9 DocumentObjectHateoas (nikita.common.model.noark5.v4.hateoas.DocumentObjectHateoas)7 DocumentObjectHateoas (nikita.model.noark5.v4.hateoas.DocumentObjectHateoas)7 NoarkEntityNotFoundException (nikita.common.util.exceptions.NoarkEntityNotFoundException)6 NoarkEntityNotFoundException (nikita.util.exceptions.NoarkEntityNotFoundException)6 IOException (java.io.IOException)4 InputStream (java.io.InputStream)4 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)3 DocumentDescription (nikita.common.model.noark5.v4.DocumentDescription)3 DocumentDescription (nikita.model.noark5.v4.DocumentDescription)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 ArrayList (java.util.ArrayList)2