Search in sources :

Example 11 with Fonds

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

the class FondsCreatorHateoasController method getFondsCreatorTemplate.

// Create a suggested FondsCreator (like a template) object with default values (nothing persisted)
// GET [contextPath][api]/arkivstruktur/arkiv/{systemID}/ny-arkivskaper
// GET [contextPath][api]/arkivstruktur/ny-arkivskaper
@ApiOperation(value = "Suggests the contents of a new FondsCreator", notes = "Returns a pre-filled FondsCreator" + " with values relevant for the logged-in user", response = FondsCreatorHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "FondsCreator " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = FondsCreatorHateoas.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(method = RequestMethod.GET, value = { NEW_FONDS_CREATOR, FONDS + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + NEW_FONDS_CREATOR })
public ResponseEntity<FondsCreatorHateoas> getFondsCreatorTemplate(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response) throws NikitaException {
    FondsCreator suggestedFondsCreator = new FondsCreator();
    // TODO: This should be replaced with configurable data based on whoever is logged in
    //       Currently just returns the test values
    suggestedFondsCreator.setFondsCreatorId("123456789");
    suggestedFondsCreator.setFondsCreatorName("Eksempel kommune");
    suggestedFondsCreator.setDescription("Eksempel kommune ligger i eksempel fylke nord for nord");
    FondsCreatorHateoas fondsCreatorHateoas = new FondsCreatorHateoas(suggestedFondsCreator);
    fondsHateoasHandler.addLinksOnNew(fondsCreatorHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(fondsCreatorHateoas);
}
Also used : Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) FondsCreatorHateoas(nikita.model.noark5.v4.hateoas.FondsCreatorHateoas) FondsCreator(nikita.model.noark5.v4.FondsCreator) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 12 with Fonds

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

the class FondsCreatorHateoasController method createFondsAssociatedWithFondsCreator.

// Create a new fonds
// POST [contextPath][api]/arkivstruktur/arkivskaper/{systemID}/ny-arkiv
@ApiOperation(value = "Persists a new Fonds associated with a FondsCreator", notes = "Returns the newly" + " created Fonds after it is associated with the Fonds and persisted to the database", response = FondsCreatorHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Fonds " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = FondsHateoas.class), @ApiResponse(code = 201, message = "Fonds " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = FondsHateoas.class), @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER), @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER), @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@Timed
@RequestMapping(method = RequestMethod.POST, value = FONDS_CREATOR + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + NEW_FONDS, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<FondsHateoas> createFondsAssociatedWithFondsCreator(HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemId", value = "systemId of FondsCreator to associate the Fonds with.", required = true) @PathVariable("systemID") String systemID, @ApiParam(name = "fonds", value = "Incoming fonds object", required = true) @RequestBody Fonds fonds) throws NikitaException {
    fondsCreatorService.createFondsAssociatedWithFondsCreator(systemID, fonds);
    FondsHateoas fondsHateoas = new FondsHateoas(fonds);
    fondsHateoasHandler.addLinks(fondsHateoas, request, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, fonds));
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(fonds.getVersion().toString()).body(fondsHateoas);
}
Also used : FondsHateoas(nikita.model.noark5.v4.hateoas.FondsHateoas) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) AfterNoarkEntityUpdatedEvent(no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 13 with Fonds

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

the class FondsHateoasController method findSeriesAssociatedWithFonds.

// Get all Series associated with Fonds identified by systemId
// GET [contextPath][api]/arkivstruktur/arkiv/{systemId}/arkivdel/
@ApiOperation(value = "Retrieves the Series associated with a Fonds identified by 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
@Timed
@RequestMapping(value = FONDS + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + SERIES + SLASH, method = RequestMethod.GET)
public ResponseEntity<SeriesHateoas> findSeriesAssociatedWithFonds(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemId of Fonds that has Series associated with it.", required = true) @PathVariable("systemID") final String systemID) {
    Fonds fonds = fondsService.findBySystemIdOrderBySystemId(systemID);
    if (fonds == null) {
        throw new NoarkEntityNotFoundException("Could not find series object with systemID " + systemID);
    }
    SeriesHateoas seriesHateoas = new SeriesHateoas(new ArrayList<>(fonds.getReferenceSeries()));
    seriesHateoasHandler.addLinks(seriesHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(seriesHateoas);
}
Also used : Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) SeriesHateoas(nikita.model.noark5.v4.hateoas.SeriesHateoas) Fonds(nikita.model.noark5.v4.Fonds) NoarkEntityNotFoundException(nikita.util.exceptions.NoarkEntityNotFoundException) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 14 with Fonds

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

the class FondsHateoasController method findAllFonds.

// Get all fonds
// GET [contextPath][api]/arkivstruktur/arkiv/
@ApiOperation(value = "Retrieves multiple Fonds entities limited by ownership rights", notes = "The field skip" + "tells how many Fonds 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 = FondsHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Fonds found", response = FondsHateoas.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(method = RequestMethod.GET, value = FONDS)
public ResponseEntity<FondsHateoas> findAllFonds(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @RequestParam(name = "top", required = false) Integer top, @RequestParam(name = "skip", required = false) Integer skip) {
    FondsHateoas fondsHateoas = new FondsHateoas((ArrayList<INikitaEntity>) (ArrayList) fondsService.findFondsByOwnerPaginated(top, skip));
    fondsHateoasHandler.addLinks(fondsHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(fondsHateoas);
}
Also used : FondsHateoas(nikita.model.noark5.v4.hateoas.FondsHateoas) 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) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 15 with Fonds

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

the class FondsHateoasController method getFondsTemplate.

// Create a suggested Fonds (like a template) object with default values (nothing persisted)
// GET [contextPath][api]/arkivstruktur/ny-arkiv
@ApiOperation(value = "Suggests the contents of a new Fonds object", notes = "Returns a pre-filled Fonds object" + " with values relevant for the logged-in user", response = FondsHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Fonds " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = FondsHateoas.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(method = RequestMethod.GET, value = { NEW_FONDS, FONDS_CREATOR + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + NEW_FONDS })
public ResponseEntity<FondsHateoas> getFondsTemplate(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response) throws NikitaException {
    Fonds suggestedFonds = new Fonds();
    // TODO: This should be replaced with configurable data based on whoever is logged in
    //       Currently just returns the test values
    suggestedFonds.setTitle(TEST_TITLE);
    suggestedFonds.setDescription(TEST_DESCRIPTION);
    suggestedFonds.setDocumentMedium(DOCUMENT_MEDIUM_ELECTRONIC);
    FondsHateoas fondsHateoas = new FondsHateoas(suggestedFonds);
    fondsHateoasHandler.addLinksOnNew(fondsHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(fondsHateoas);
}
Also used : FondsHateoas(nikita.model.noark5.v4.hateoas.FondsHateoas) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) Fonds(nikita.model.noark5.v4.Fonds) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

Fonds (nikita.model.noark5.v4.Fonds)28 Counted (com.codahale.metrics.annotation.Counted)27 ApiOperation (io.swagger.annotations.ApiOperation)27 ApiResponses (io.swagger.annotations.ApiResponses)27 Timed (com.codahale.metrics.annotation.Timed)18 Fonds (nikita.common.model.noark5.v4.Fonds)15 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)14 Authorisation (nikita.webapp.security.Authorisation)13 FondsHateoas (nikita.model.noark5.v4.hateoas.FondsHateoas)10 FondsHateoas (nikita.common.model.noark5.v4.hateoas.FondsHateoas)9 NoarkEntityNotFoundException (nikita.util.exceptions.NoarkEntityNotFoundException)8 ArrayList (java.util.ArrayList)5 Series (nikita.model.noark5.v4.Series)5 JsonNode (com.fasterxml.jackson.databind.JsonNode)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)4 List (java.util.List)4 FondsCreatorHateoas (nikita.common.model.noark5.v4.hateoas.FondsCreatorHateoas)4 SeriesHateoas (nikita.common.model.noark5.v4.hateoas.SeriesHateoas)4 INikitaEntity (nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity)4 FondsCreator (nikita.common.model.noark5.v4.FondsCreator)3