Search in sources :

Example 36 with Timed

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

the class FileHateoasController method createBasicRecordAssociatedWithFile.

// Create a BasicRecord
// POST [contextPath][api]/arkivstruktur/mappe/{systemId}/ny-basisregistrering
// http://rel.kxml.no/noark5/v4/api/arkivstruktur/ny-basisregistrering/
@ApiOperation(value = "Persists a BasicRecord associated with the given Series systemId", notes = "Returns the newly created basicRecord after it was associated with a File and " + "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
@Timed
@RequestMapping(method = RequestMethod.POST, value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + NEW_BASIC_RECORD, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<BasicRecordHateoas> createBasicRecordAssociatedWithFile(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemId of file to associate the basicRecord with", required = true) @PathVariable("systemID") final String systemID, @ApiParam(name = "BasicRecord", value = "Incoming basicRecord", required = true) @RequestBody BasicRecord basicRecord) throws NikitaException {
    BasicRecord createdBasicRecord = fileService.createBasicRecordAssociatedWithFile(systemID, basicRecord);
    BasicRecordHateoas basicRecordHateoas = new BasicRecordHateoas(createdBasicRecord);
    basicRecordHateoasHandler.addLinks(basicRecordHateoas, request, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityCreatedEvent(this, createdBasicRecord));
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(createdBasicRecord.getVersion().toString()).body(basicRecordHateoas);
}
Also used : 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)

Example 37 with Timed

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

the class FileHateoasController method createRecordAssociatedWithFile.

// API - All POST Requests (CRUD - CREATE)
// Create a Record
// POST [contextPath][api]/arkivstruktur/mappe/{systemId}/ny-registrering
// REL http://rel.kxml.no/noark5/v4/api/arkivstruktur/ny-registrering/
@ApiOperation(value = "Persists a Record associated with the given Series systemId", notes = "Returns the newly created record after it was associated with a File and " + "persisted to the database", response = RecordHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Record " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = RecordHateoas.class), @ApiResponse(code = 201, message = "Record " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = RecordHateoas.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 Record"), @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_RECORD, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<RecordHateoas> createRecordAssociatedWithFile(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "fileSystemId", value = "systemId of file to associate the record with", required = true) @PathVariable("systemID") final String systemID, @ApiParam(name = "Record", value = "Incoming record", required = true) @RequestBody Record record) throws NikitaException {
    Record createdRecord = fileService.createRecordAssociatedWithFile(systemID, record);
    RecordHateoas recordHateoas = new RecordHateoas(createdRecord);
    recordHateoasHandler.addLinks(recordHateoas, request, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityCreatedEvent(this, createdRecord));
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(createdRecord.getVersion().toString()).body(recordHateoas);
}
Also used : 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)

Example 38 with Timed

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

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

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

Aggregations

Timed (com.codahale.metrics.annotation.Timed)1042 Path (javax.ws.rs.Path)386 ApiOperation (io.swagger.annotations.ApiOperation)316 ApiResponses (io.swagger.annotations.ApiResponses)218 GET (javax.ws.rs.GET)203 POST (javax.ws.rs.POST)167 URI (java.net.URI)157 Produces (javax.ws.rs.Produces)148 Counted (com.codahale.metrics.annotation.Counted)122 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)105 AuditEvent (org.graylog2.audit.jersey.AuditEvent)96 Consumes (javax.ws.rs.Consumes)91 PUT (javax.ws.rs.PUT)91 DELETE (javax.ws.rs.DELETE)78 Response (javax.ws.rs.core.Response)73 NotFoundException (javax.ws.rs.NotFoundException)68 ExceptionMetered (com.codahale.metrics.annotation.ExceptionMetered)66 ResponseEntity (org.springframework.http.ResponseEntity)66 HttpHeaders (org.springframework.http.HttpHeaders)54 RequiresPermissions (org.apache.shiro.authz.annotation.RequiresPermissions)53