Search in sources :

Example 51 with Counted

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

the class DocumentMediumController method findBySystemIdOrderBySystemId.

// Retrieves a given documentMedium identified by a systemId
// GET [contextPath][api]/metadata/dokumentmedium/{systemId}/
@ApiOperation(value = "Gets documentMedium identified by its systemId", notes = "Returns the requested " + " documentMedium object", response = DocumentMedium.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "DocumentMedium " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = DocumentMedium.class), @ApiResponse(code = 201, message = "DocumentMedium " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = DocumentMedium.class), @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER), @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER), @ApiResponse(code = 404, message = API_MESSAGE_MALFORMED_PAYLOAD), @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(value = DOCUMENT_MEDIUM + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH, method = RequestMethod.GET)
public ResponseEntity<MetadataHateoas> findBySystemIdOrderBySystemId(@PathVariable("systemID") final String systemId, HttpServletRequest request) {
    DocumentMedium documentMedium = documentMediumService.findBySystemIdOrderBySystemId(systemId);
    MetadataHateoas metadataHateoas = new MetadataHateoas(documentMedium);
    metadataHateoasHandler.addLinks(metadataHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(documentMedium.getVersion().toString()).body(metadataHateoas);
}
Also used : Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) MetadataHateoas(nikita.model.noark5.v4.hateoas.metadata.MetadataHateoas) DocumentMedium(nikita.model.noark5.v4.metadata.DocumentMedium) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 52 with Counted

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

the class FondsStatusController method findBySystemIdOrderBySystemId.

// Retrieves a given fondsStatus identified by a systemId
// GET [contextPath][api]/metadata/arkivstatus/{systemId}/
@ApiOperation(value = "Gets fondsStatus identified by its systemId", notes = "Returns the requested " + " fondsStatus object", response = FondsStatus.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "FondsStatus " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = FondsStatus.class), @ApiResponse(code = 201, message = "FondsStatus " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = FondsStatus.class), @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER), @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER), @ApiResponse(code = 404, message = API_MESSAGE_MALFORMED_PAYLOAD), @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(value = FONDS_STATUS + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH, method = RequestMethod.GET)
public ResponseEntity<MetadataHateoas> findBySystemIdOrderBySystemId(@PathVariable("systemID") final String systemId, HttpServletRequest request) {
    FondsStatus fondsStatus = fondsStatusService.findBySystemIdOrderBySystemId(systemId);
    MetadataHateoas metadataHateoas = new MetadataHateoas(fondsStatus);
    metadataHateoasHandler.addLinks(metadataHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(fondsStatus.getVersion().toString()).body(metadataHateoas);
}
Also used : Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) FondsStatus(nikita.model.noark5.v4.metadata.FondsStatus) MetadataHateoas(nikita.model.noark5.v4.hateoas.metadata.MetadataHateoas) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 53 with Counted

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

the class FondsStatusController method getFondsStatusTemplate.

// Create a suggested fondsStatus(like a template) with default values (nothing persisted)
// GET [contextPath][api]/metadata/ny-arkivstatus
@ApiOperation(value = "Creates a suggested FondsStatus", response = FondsStatus.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "FondsStatus codes found", response = FondsStatus.class), @ApiResponse(code = 404, message = "No FondsStatus found"), @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_STATUS)
public ResponseEntity<MetadataHateoas> getFondsStatusTemplate(HttpServletRequest request) {
    FondsStatus fondsStatus = new FondsStatus();
    fondsStatus.setCode(TEMPLATE_FONDS_STATUS_CODE);
    fondsStatus.setDescription(TEMPLATE_FONDS_STATUS_DESCRIPTION);
    MetadataHateoas metadataHateoas = new MetadataHateoas(fondsStatus);
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(metadataHateoas);
}
Also used : FondsStatus(nikita.model.noark5.v4.metadata.FondsStatus) MetadataHateoas(nikita.model.noark5.v4.hateoas.metadata.MetadataHateoas) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 54 with Counted

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

the class FondsStatusController method updateFondsStatus.

// API - All PUT Requests (CRUD - UPDATE)
// Update a arkivstatus
// PUT [contextPath][api]/metatdata/arkivstatus/
@ApiOperation(value = "Updates a FondsStatus object", notes = "Returns the newly" + " updated FondsStatus object after it is persisted to the database", response = FondsStatus.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "FondsStatus " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = FondsStatus.class), @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER), @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER), @ApiResponse(code = 404, message = API_MESSAGE_MALFORMED_PAYLOAD), @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@Timed
@RequestMapping(method = RequestMethod.PUT, value = FONDS_STATUS + SLASH + FONDS_STATUS)
public ResponseEntity<MetadataHateoas> updateFondsStatus(@RequestBody FondsStatus fondsStatus, HttpServletRequest request) throws NikitaException {
    FondsStatus newFondsStatus = fondsStatusService.update(fondsStatus);
    MetadataHateoas metadataHateoas = new MetadataHateoas(fondsStatus);
    metadataHateoasHandler.addLinks(metadataHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(metadataHateoas);
}
Also used : Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) FondsStatus(nikita.model.noark5.v4.metadata.FondsStatus) MetadataHateoas(nikita.model.noark5.v4.hateoas.metadata.MetadataHateoas) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 55 with Counted

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

the class BasicRecordHateoasController method updateBasicRecord.

// API - All PUT Requests (CRUD - UPDATE)
// Update a BasicRecord
// PUT [contextPath][api]/arkivstruktur/basisregistrering/{systemID}
@ApiOperation(value = "Updates a BasicRecord object", notes = "Returns the newly" + " update BasicRecord object after it is persisted to the database", response = BasicRecordHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "BasicRecord " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = BasicRecordHateoas.class), @ApiResponse(code = 201, message = "BasicRecord " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = BasicRecordHateoas.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 BasicRecord"), @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@RequestMapping(method = RequestMethod.PUT, value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<BasicRecordHateoas> updateBasicRecord(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemId of basicRecord to update.", required = true) @PathVariable("systemID") String systemID, @ApiParam(name = "basicRecord", value = "Incoming basicRecord object", required = true) @RequestBody BasicRecord basicRecord) throws NikitaException {
    validateForUpdate(basicRecord);
    BasicRecord updatedBasicRecord = basicRecordService.handleUpdate(systemID, parseETAG(request.getHeader(ETAG)), basicRecord);
    BasicRecordHateoas basicRecordHateoas = new BasicRecordHateoas(updatedBasicRecord);
    basicRecordHateoasHandler.addLinks(basicRecordHateoas, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, updatedBasicRecord));
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(updatedBasicRecord.getVersion().toString()).body(basicRecordHateoas);
}
Also used : Authorisation(nikita.webapp.security.Authorisation) AfterNoarkEntityUpdatedEvent(nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent) Counted(com.codahale.metrics.annotation.Counted) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

Counted (com.codahale.metrics.annotation.Counted)242 ApiOperation (io.swagger.annotations.ApiOperation)210 ApiResponses (io.swagger.annotations.ApiResponses)210 Timed (com.codahale.metrics.annotation.Timed)128 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)105 Authorisation (nikita.webapp.security.Authorisation)98 MetadataHateoas (nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas)24 List (java.util.List)23 INikitaEntity (nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity)21 ArrayList (java.util.ArrayList)19 AfterNoarkEntityCreatedEvent (no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityCreatedEvent)18 AfterNoarkEntityUpdatedEvent (no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent)16 MetadataHateoas (nikita.model.noark5.v4.hateoas.metadata.MetadataHateoas)15 AfterNoarkEntityUpdatedEvent (nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent)15 INikitaEntity (nikita.model.noark5.v4.interfaces.entities.INikitaEntity)14 NoarkEntityNotFoundException (nikita.util.exceptions.NoarkEntityNotFoundException)14 CaseFileHateoas (nikita.common.model.noark5.v4.hateoas.casehandling.CaseFileHateoas)13 CaseFileHateoas (nikita.model.noark5.v4.hateoas.casehandling.CaseFileHateoas)13 AfterNoarkEntityCreatedEvent (nikita.webapp.web.events.AfterNoarkEntityCreatedEvent)11 AfterNoarkEntityDeletedEvent (nikita.webapp.web.events.AfterNoarkEntityDeletedEvent)11