Search in sources :

Example 26 with Authorisation

use of no.arkivlab.hioa.nikita.webapp.security.Authorisation 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)

Example 27 with Authorisation

use of no.arkivlab.hioa.nikita.webapp.security.Authorisation in project nikita-noark5-core by HiOA-ABI.

the class RecordHateoasController method createDefaultDocumentDescription.

// Create a DocumentDescription with default values
// GET [contextPath][api]/arkivstruktur/resgistrering/{systemId}/ny-dokumentbeskrivelse
@ApiOperation(value = "Create a DocumentDescription with default values", response = DocumentDescriptionHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "DocumentDescription returned", response = DocumentDescriptionHateoas.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 + NEW_DOCUMENT_DESCRIPTION, method = RequestMethod.GET)
public ResponseEntity<DocumentDescriptionHateoas> createDefaultDocumentDescription(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response) {
    DocumentDescription defaultDocumentDescription = new DocumentDescription();
    defaultDocumentDescription.setAssociatedWithRecordAs(MAIN_DOCUMENT);
    defaultDocumentDescription.setTitle(TEST_TITLE);
    defaultDocumentDescription.setDocumentType(LETTER);
    defaultDocumentDescription.setDocumentStatus(DOCUMENT_STATUS_FINALISED);
    defaultDocumentDescription.setDescription(TEST_DESCRIPTION);
    DocumentDescriptionHateoas documentDescriptionHateoas = new DocumentDescriptionHateoas(defaultDocumentDescription);
    documentDescriptionHateoasHandler.addLinksOnNew(documentDescriptionHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(documentDescriptionHateoas);
}
Also used : DocumentDescription(nikita.model.noark5.v4.DocumentDescription) 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 28 with Authorisation

use of no.arkivlab.hioa.nikita.webapp.security.Authorisation in project nikita-noark5-core by HiOA-ABI.

the class RecordHateoasController method findAllDocumentDescriptionAssociatedWithRecord.

// Retrieve all DocumentDescriptions associated with a Record identified by systemId
// GET [contextPath][api]/arkivstruktur/resgistrering/{systemId}/dokumentbeskrivelse
@ApiOperation(value = "Retrieves a lit of DocumentDescriptions associated with a Record", response = DocumentDescriptionHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "DocumentDescription returned", response = DocumentDescriptionHateoas.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 + DOCUMENT_DESCRIPTION, method = RequestMethod.GET)
public ResponseEntity<DocumentDescriptionHateoas> findAllDocumentDescriptionAssociatedWithRecord(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the file to retrieve associated Record", required = true) @PathVariable("systemID") final String systemID) {
    Record record = recordService.findBySystemIdOrderBySystemId(systemID);
    if (record == null) {
        throw new NoarkEntityNotFoundException("Could not find File object with systemID " + systemID);
    }
    DocumentDescriptionHateoas documentDescriptionHateoas = new DocumentDescriptionHateoas(new ArrayList<>(record.getReferenceDocumentDescription()));
    documentDescriptionHateoasHandler.addLinks(documentDescriptionHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(documentDescriptionHateoas);
}
Also used : Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) Record(nikita.model.noark5.v4.Record) 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 29 with Authorisation

use of no.arkivlab.hioa.nikita.webapp.security.Authorisation in project nikita-noark5-core by HiOA-ABI.

the class RecordHateoasController method createDefaultDocumentObject.

// Create a DocumentObject with default values
// GET [contextPath][api]/arkivstruktur/resgistrering/{systemId}/ny-dokumentobjekt
@ApiOperation(value = "Create a DocumentObject with default values", response = DocumentObjectHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "DocumentObject returned", response = DocumentObjectHateoas.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 + NEW_DOCUMENT_OBJECT, method = RequestMethod.GET)
public ResponseEntity<DocumentObjectHateoas> createDefaultDocumentObject(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response) {
    DocumentObject defaultDocumentObject = new DocumentObject();
    // This is just temporary code as this will have to be replaced if this ever goes into production
    defaultDocumentObject.setMimeType(MediaType.APPLICATION_XML.toString());
    defaultDocumentObject.setVariantFormat(PRODUCTION_VERSION);
    defaultDocumentObject.setFormat("XML");
    DocumentObjectHateoas documentObjectHateoas = new DocumentObjectHateoas(defaultDocumentObject);
    documentObjectHateoasHandler.addLinksOnNew(documentObjectHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(documentObjectHateoas);
}
Also used : 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)

Example 30 with Authorisation

use of no.arkivlab.hioa.nikita.webapp.security.Authorisation in project nikita-noark5-core by HiOA-ABI.

the class SeriesHateoasController method updateSeries.

// Update an identified Series
// PUT [contextPath][api]/arkivstruktur/arkivdel/{systemId}
@ApiOperation(value = "Updates a Series object", notes = "Returns the newly" + " update Series object after it is persisted to the database", response = SeriesHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Series " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = SeriesHateoas.class), @ApiResponse(code = 201, message = "Series " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = SeriesHateoas.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 ClassificationSystem"), @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<SeriesHateoas> updateSeries(HttpServletRequest request, @ApiParam(name = "systemID", value = "systemId of fonds to update.", required = true) @PathVariable("systemID") String systemID, @ApiParam(name = "series", value = "Incoming series object", required = true) @RequestBody Series series) throws NikitaException {
    validateForUpdate(series);
    Series updatedSeries = seriesService.handleUpdate(systemID, parseETAG(request.getHeader(ETAG)), series);
    SeriesHateoas seriesHateoas = new SeriesHateoas(updatedSeries);
    seriesHateoasHandler.addLinks(seriesHateoas, request, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, updatedSeries));
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(updatedSeries.getVersion().toString()).body(seriesHateoas);
}
Also used : 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)

Aggregations

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