Search in sources :

Example 31 with Counted

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

the class SeriesHateoasController method createFileAssociatedWithSeries.

// API - All POST Requests (CRUD - CREATE)
// Create a new file
// POST [contextPath][api]/arkivstruktur/arkivdel/ny-mappe/
@ApiOperation(value = "Persists a File object associated with the given Series systemId", notes = "Returns the " + "newly created file object after it was associated with a Series object and persisted to the database", response = FileHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "File " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = FileHateoas.class), @ApiResponse(code = 201, message = "File " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = FileHateoas.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 File"), @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_FILE, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<FileHateoas> createFileAssociatedWithSeries(HttpServletRequest request, @ApiParam(name = "systemID", value = "systemId of series to associate the caseFile with", required = true) @PathVariable String systemID, @ApiParam(name = "File", value = "Incoming file object", required = true) @RequestBody File file) throws NikitaException {
    validateForCreate(file);
    File createdFile = seriesService.createFileAssociatedWithSeries(systemID, file);
    FileHateoas fileHateoas = new FileHateoas(createdFile);
    fileHateoasHandler.addLinks(fileHateoas, request, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityCreatedEvent(this, createdFile));
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(createdFile.getVersion().toString()).body(fileHateoas);
}
Also used : AfterNoarkEntityCreatedEvent(no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityCreatedEvent) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) CaseFile(nikita.model.noark5.v4.casehandling.CaseFile) CaseFileHateoas(nikita.model.noark5.v4.hateoas.casehandling.CaseFileHateoas) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed)

Example 32 with Counted

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

the class SeriesHateoasController method findAllRecordAssociatedWithSeries.

// Retrieve all Records associated with a Series (paginated)
// GET [contextPath][api]/arkivstruktur/arkivdel/{systemId}/registrering/
// GET [contextPath][api]/arkivstruktur/arkivdel/{systemId}/registrering/?top=5&skip=1
@ApiOperation(value = "Retrieves a lit of Records associated with a Series", notes = "The field skip" + "tells how many Record 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 = RecordHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Record list found", response = RecordHateoas.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 = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + REGISTRATION, method = RequestMethod.GET)
public ResponseEntity<RecordHateoas> findAllRecordAssociatedWithSeries(HttpServletRequest request, @RequestParam(name = "top", required = false) Integer top, @RequestParam(name = "skip", required = false) Integer skip, @ApiParam(name = "systemID", value = "systemID of the series to retrieve", required = true) @PathVariable("systemID") final String systemID) {
    Series series = seriesService.findBySystemIdOrderBySystemId(systemID);
    RecordHateoas recordHateoas = new RecordHateoas(new ArrayList<>(series.getReferenceRecord()));
    recordHateoasHandler.addLinks(recordHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(recordHateoas);
}
Also used : Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed)

Example 33 with Counted

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

the class AdministrativeUnitController method findBySystemIdOrderBySystemId.

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

Example 34 with Counted

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

the class CaseFileHateoasController method findOneCaseFilebySystemId.

// Retrieve a single casefile identified by systemId
// GET [contextPath][api]/casehandling/saksmappe/{systemID}
@ApiOperation(value = "Retrieves a single CaseFile entity given a systemId", response = CaseFile.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CaseFile returned", response = CaseFile.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 = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.GET)
public ResponseEntity<CaseFileHateoas> findOneCaseFilebySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the caseFile to retrieve", required = true) @PathVariable("systemID") final String caseFileSystemId) {
    CaseFile caseFile = caseFileService.findBySystemIdOrderBySystemId(caseFileSystemId);
    if (caseFile == null) {
        throw new NoarkEntityNotFoundException(caseFileSystemId);
    }
    CaseFileHateoas caseFileHateoas = new CaseFileHateoas(caseFile);
    caseFileHateoasHandler.addLinks(caseFileHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(caseFile.getVersion().toString()).body(caseFileHateoas);
}
Also used : CaseFileHateoas(nikita.model.noark5.v4.hateoas.casehandling.CaseFileHateoas) CaseFile(nikita.model.noark5.v4.casehandling.CaseFile) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) 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 35 with Counted

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

the class CaseFileHateoasController method createRegistryEntryAssociatedWithFile.

// API - All POST Requests (CRUD - CREATE)
// Create a RegistryEntry entity
// POST [contextPath][api]/casehandling/{systemId}/ny-journalpost
@ApiOperation(value = "Persists a RegistryEntry object associated with the given Series systemId", notes = "Returns the newly created record object after it was associated with a File object and " + "persisted to the database", response = RegistryEntryHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "RegistryEntry " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = RegistryEntryHateoas.class), @ApiResponse(code = 201, message = "RegistryEntry " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = RegistryEntryHateoas.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 RegistryEntry"), @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_REGISTRY_ENTRY, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<RegistryEntryHateoas> createRegistryEntryAssociatedWithFile(HttpServletRequest request, @ApiParam(name = "systemID", value = "systemId of file to associate the record with", required = true) @PathVariable("systemID") final String systemID, @ApiParam(name = "RegistryEntry", value = "Incoming registryEntry object", required = true) @RequestBody RegistryEntry registryEntry) throws NikitaException {
    RegistryEntry createdRegistryEntry = caseFileService.createRegistryEntryAssociatedWithCaseFile(systemID, registryEntry);
    RegistryEntryHateoas registryEntryHateoas = new RegistryEntryHateoas(createdRegistryEntry);
    registryEntryHateoasHandler.addLinks(registryEntryHateoas, request, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityCreatedEvent(this, createdRegistryEntry));
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(createdRegistryEntry.getVersion().toString()).body(registryEntryHateoas);
}
Also used : RegistryEntryHateoas(nikita.model.noark5.v4.hateoas.casehandling.RegistryEntryHateoas) AfterNoarkEntityCreatedEvent(no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityCreatedEvent) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) RegistryEntry(nikita.model.noark5.v4.casehandling.RegistryEntry) 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)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