Search in sources :

Example 11 with Counted

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

the class ClassificationSystemHateoasController method deleteClassificationSystemBySystemId.

// Delete a ClassificationSystem identified by systemID
// DELETE [contextPath][api]/arkivstruktur/klassifikasjonsystem/{systemId}/
@ApiOperation(value = "Deletes a single ClassificationSystem entity identified by systemID", response = FondsStructureDetails.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Parent ApplicationDetails returned", response = FondsStructureDetails.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 + CLASSIFICATION_SYSTEM + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.DELETE)
public ResponseEntity<FondsStructureDetails> deleteClassificationSystemBySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the ClassificationSystem to delete", required = true) @PathVariable("systemID") final String systemID) {
    ClassificationSystem classificationSystem = classificationSystemService.findBySystemIdOrderBySystemId(systemID);
    classificationSystemService.deleteEntity(systemID);
    applicationEventPublisher.publishEvent(new AfterNoarkEntityDeletedEvent(this, classificationSystem));
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(applicationService.getFondsStructureDetails());
}
Also used : ClassificationSystem(nikita.model.noark5.v4.ClassificationSystem) AfterNoarkEntityDeletedEvent(no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityDeletedEvent) 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 Counted

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

the class DocumentDescriptionHateoasController method deleteDocumentDescriptionBySystemId.

// Delete a DocumentDescription identified by systemID
// DELETE [contextPath][api]/arkivstruktur/dokumentobjekt/{systemId}/
@ApiOperation(value = "Deletes a single DocumentDescription entity identified by systemID", response = RecordHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Parent Fonds returned", 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, method = RequestMethod.DELETE)
public ResponseEntity<RecordHateoas> deleteDocumentDescriptionBySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the documentDescription to delete", required = true) @PathVariable("systemID") final String systemID) {
    DocumentDescription documentDescription = documentDescriptionService.findBySystemIdOrderBySystemId(systemID);
    List<Record> record = new ArrayList<>();
    record.addAll(documentDescription.getReferenceRecord());
    documentDescriptionService.deleteEntity(systemID);
    RecordHateoas recordHateoas = new RecordHateoas((List<INikitaEntity>) (List) record);
    recordHateoasHandler.addLinks(recordHateoas, request, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityDeletedEvent(this, documentDescription));
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(recordHateoas);
}
Also used : DocumentDescription(nikita.model.noark5.v4.DocumentDescription) INikitaEntity(nikita.model.noark5.v4.interfaces.entities.INikitaEntity) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) ArrayList(java.util.ArrayList) RecordHateoas(nikita.model.noark5.v4.hateoas.RecordHateoas) Record(nikita.model.noark5.v4.Record) ArrayList(java.util.ArrayList) List(java.util.List) AfterNoarkEntityDeletedEvent(no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityDeletedEvent) 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 Counted

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

the class DocumentDescriptionHateoasController method updateDocumentDescription.

// API - All PUT Requests (CRUD - UPDATE)
// Update a DocumentDescription
// PUT [contextPath][api]/arkivstruktur/dokumentobjekt/{systemID}
@ApiOperation(value = "Updates a DocumentDescription object", notes = "Returns the newly" + " update DocumentDescription object after it is 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.PUT, value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<DocumentDescriptionHateoas> updateDocumentDescription(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemId of documentDescription to update.", required = true) @PathVariable("systemID") String systemID, @ApiParam(name = "documentDescription", value = "Incoming documentDescription object", required = true) @RequestBody DocumentDescription documentDescription) throws NikitaException {
    validateForUpdate(documentDescription);
    DocumentDescription updatedDocumentDescription = documentDescriptionService.handleUpdate(systemID, parseETAG(request.getHeader(ETAG)), documentDescription);
    DocumentDescriptionHateoas documentDescriptionHateoas = new DocumentDescriptionHateoas(updatedDocumentDescription);
    documentDescriptionHateoasHandler.addLinks(documentDescriptionHateoas, request, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, updatedDocumentDescription));
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(updatedDocumentDescription.getVersion().toString()).body(documentDescriptionHateoas);
}
Also used : DocumentDescription(nikita.model.noark5.v4.DocumentDescription) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) DocumentDescriptionHateoas(nikita.model.noark5.v4.hateoas.DocumentDescriptionHateoas) 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 14 with Counted

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

the class DocumentDescriptionHateoasController method findOneDocumentDescriptionBySystemId.

// API - All GET Requests (CRUD - READ)
@ApiOperation(value = "Retrieves a single DocumentDescription entity given a systemId", response = DocumentDescription.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "DocumentDescription returned", response = DocumentDescription.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<DocumentDescriptionHateoas> findOneDocumentDescriptionBySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the documentDescription to retrieve", required = true) @PathVariable("systemID") final String systemID) {
    DocumentDescription documentDescription = documentDescriptionService.findBySystemIdOrderBySystemId(systemID);
    if (documentDescription == null) {
        throw new NoarkEntityNotFoundException(systemID);
    }
    DocumentDescriptionHateoas documentDescriptionHateoas = new DocumentDescriptionHateoas(documentDescription);
    documentDescriptionHateoasHandler.addLinks(documentDescriptionHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(documentDescription.getVersion().toString()).body(documentDescriptionHateoas);
}
Also used : DocumentDescription(nikita.model.noark5.v4.DocumentDescription) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) DocumentDescriptionHateoas(nikita.model.noark5.v4.hateoas.DocumentDescriptionHateoas) 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 15 with Counted

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

the class DocumentDescriptionHateoasController method createDocumentObjectAssociatedWithDocumentDescription.

// API - All POST Requests (CRUD - CREATE)
@ApiOperation(value = "Persists a DocumentObject object associated with the given DocumentDescription systemId", notes = "Returns the newly created documentObject after it was associated with a DocumentDescription" + " object and persisted to the database", response = DocumentDescriptionHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "DocumentObject " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = DocumentDescriptionHateoas.class), @ApiResponse(code = 201, message = "DocumentObject " + 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 DocumentObject"), @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_OBJECT, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<DocumentObjectHateoas> createDocumentObjectAssociatedWithDocumentDescription(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemId of documentDescription to associate the documentObject with.", required = true) @PathVariable String systemID, @ApiParam(name = "documentObject", value = "Incoming documentObject object", required = true) @RequestBody DocumentObject documentObject) throws NikitaException {
    DocumentObject createdDocumentObject = documentDescriptionService.createDocumentObjectAssociatedWithDocumentDescription(systemID, documentObject);
    DocumentObjectHateoas documentObjectHateoas = new DocumentObjectHateoas(documentObject);
    documentObjectHateoasHandler.addLinks(documentObjectHateoas, request, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityCreatedEvent(this, createdDocumentObject));
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(createdDocumentObject.getVersion().toString()).body(documentObjectHateoas);
}
Also used : AfterNoarkEntityCreatedEvent(no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityCreatedEvent) DocumentObjectHateoas(nikita.model.noark5.v4.hateoas.DocumentObjectHateoas) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) DocumentObject(nikita.model.noark5.v4.DocumentObject) 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