Search in sources :

Example 26 with Counted

use of com.codahale.metrics.annotation.Counted 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 27 with Counted

use of com.codahale.metrics.annotation.Counted 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 28 with Counted

use of com.codahale.metrics.annotation.Counted 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)

Example 29 with Counted

use of com.codahale.metrics.annotation.Counted in project nikita-noark5-core by HiOA-ABI.

the class FondsHateoasController method createFondsCreatorAssociatedWithFonds.

// Create a FondsCreator and associate it with the Fonds identified by systemId
// POST [contextPath][api]/arkivstruktur/arkiv/{systemId}/ny-arkivskaper
@ApiOperation(value = "Persists a FondsCreator associated with the given Fonds systemId", notes = "Returns" + " the newly created FondsCreator after it was associated with a Fonds and persisted to the " + "database", response = FondsCreatorHateoas.class)
@SuppressWarnings("unchecked")
@ApiResponses(value = { @ApiResponse(code = 200, message = "FondsCreator " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = FondsCreatorHateoas.class), @ApiResponse(code = 201, message = "FondsCreator " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = FondsCreatorHateoas.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 FondsCreator"), @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR), @ApiResponse(code = 501, message = API_MESSAGE_NOT_IMPLEMENTED) })
@Counted
@Timed
@RequestMapping(method = { RequestMethod.POST }, value = FONDS + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + NEW_FONDS_CREATOR, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<FondsCreatorHateoas> createFondsCreatorAssociatedWithFonds(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemId of fonds to associate the series with.", required = true) @PathVariable("systemID") String systemID, @ApiParam(name = "fondsCreator", value = "Incoming fondsCreator object", required = true) @RequestBody FondsCreator fondsCreator) throws NikitaException {
    validateForCreate(fondsCreator);
    fondsService.createFondsCreatorAssociatedWithFonds(systemID, fondsCreator);
    FondsCreatorHateoas fondsCreatorHateoas = new FondsCreatorHateoas(fondsCreator);
    fondsCreatorHateoasHandler.addLinks(fondsCreatorHateoas, request, new Authorisation());
    response.setHeader(ETAG, fondsCreator.getVersion().toString());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityCreatedEvent(this, fondsCreator));
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(fondsCreator.getVersion().toString()).body(fondsCreatorHateoas);
}
Also used : AfterNoarkEntityCreatedEvent(no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityCreatedEvent) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) FondsCreatorHateoas(nikita.model.noark5.v4.hateoas.FondsCreatorHateoas) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 30 with Counted

use of com.codahale.metrics.annotation.Counted in project nikita-noark5-core by HiOA-ABI.

the class RecordHateoasController method createDocumentDescriptionAssociatedWithRecord.

// API - All POST Requests (CRUD - CREATE)
// Create a new DocumentDescription and associate it with the given Record
// POST [contextPath][api]/arkivstruktur/registrering/{systemId}/ny-dokumentobjekt
// http://rel.kxml.no/noark5/v4/api/arkivstruktur/ny-dokumentobjekt/
@ApiOperation(value = "Persists a DocumentDescription object associated with the given Record systemId", notes = "Returns the newly created DocumentDescription object after it was associated with a " + "Record object and persisted to the database", response = DocumentDescriptionHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "DocumentDescription " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = DocumentDescriptionHateoas.class), @ApiResponse(code = 201, message = "DocumentDescription " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = DocumentDescriptionHateoas.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 DocumentDescription"), @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_DOCUMENT_DESCRIPTION, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<DocumentDescriptionHateoas> createDocumentDescriptionAssociatedWithRecord(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemId of record to associate the documentDescription with.", required = true) @PathVariable String systemID, @ApiParam(name = "documentDescription", value = "Incoming documentDescription object", required = true) @RequestBody DocumentDescription documentDescription) throws NikitaException {
    DocumentDescription createdDocumentDescription = recordService.createDocumentDescriptionAssociatedWithRecord(systemID, documentDescription);
    DocumentDescriptionHateoas documentDescriptionHateoas = new DocumentDescriptionHateoas(createdDocumentDescription);
    documentDescriptionHateoasHandler.addLinks(documentDescriptionHateoas, request, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityCreatedEvent(this, createdDocumentDescription));
    return ResponseEntity.status(HttpStatus.CREATED).eTag(createdDocumentDescription.getVersion().toString()).body(documentDescriptionHateoas);
}
Also used : DocumentDescription(nikita.model.noark5.v4.DocumentDescription) AfterNoarkEntityCreatedEvent(no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityCreatedEvent) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

Counted (com.codahale.metrics.annotation.Counted)127 Timed (com.codahale.metrics.annotation.Timed)127 ApiOperation (io.swagger.annotations.ApiOperation)107 ApiResponses (io.swagger.annotations.ApiResponses)107 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)105 AfterNoarkEntityCreatedEvent (no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityCreatedEvent)18 AfterNoarkEntityUpdatedEvent (no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent)16 ArrayList (java.util.ArrayList)15 MetadataHateoas (nikita.model.noark5.v4.hateoas.metadata.MetadataHateoas)15 INikitaEntity (nikita.model.noark5.v4.interfaces.entities.INikitaEntity)14 NoarkEntityNotFoundException (nikita.util.exceptions.NoarkEntityNotFoundException)14 CaseFileHateoas (nikita.model.noark5.v4.hateoas.casehandling.CaseFileHateoas)13 AfterNoarkEntityDeletedEvent (no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityDeletedEvent)11 Metered (com.codahale.metrics.annotation.Metered)9 Fonds (nikita.model.noark5.v4.Fonds)9 FondsHateoas (nikita.model.noark5.v4.hateoas.FondsHateoas)9 DocumentObject (nikita.model.noark5.v4.DocumentObject)8 CaseFile (nikita.model.noark5.v4.casehandling.CaseFile)8 DocumentDescription (nikita.model.noark5.v4.DocumentDescription)7 DocumentObjectHateoas (nikita.model.noark5.v4.hateoas.DocumentObjectHateoas)7