Search in sources :

Example 11 with MetadataHateoas

use of nikita.model.noark5.v4.hateoas.metadata.MetadataHateoas in project nikita-noark5-core by HiOA-ABI.

the class CorrespondencePartTypeController method getCorrespondencePartTypeTemplate.

// Create a suggested correspondencePartType(like a template) with default values (nothing persisted)
// GET [contextPath][api]/metadata/ny-korrespondanseparttype
@ApiOperation(value = "Creates a suggested CorrespondencePartType", response = CorrespondencePartType.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CorrespondencePartType codes found", response = CorrespondencePartType.class), @ApiResponse(code = 404, message = "No CorrespondencePartType 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_CORRESPONDENCE_PART_TYPE)
public ResponseEntity<MetadataHateoas> getCorrespondencePartTypeTemplate(HttpServletRequest request) {
    CorrespondencePartType correspondencePartType = new CorrespondencePartType();
    correspondencePartType.setCode(TEMPLATE_FONDS_STATUS_CODE);
    correspondencePartType.setDescription(TEMPLATE_FONDS_STATUS_DESCRIPTION);
    MetadataHateoas metadataHateoas = new MetadataHateoas(correspondencePartType);
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(metadataHateoas);
}
Also used : CorrespondencePartType(nikita.model.noark5.v4.metadata.CorrespondencePartType) 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 12 with MetadataHateoas

use of nikita.model.noark5.v4.hateoas.metadata.MetadataHateoas in project nikita-noark5-core by HiOA-ABI.

the class CorrespondencePartTypeController method updateCorrespondencePartType.

// API - All PUT Requests (CRUD - UPDATE)
// Update a korrespondanseparttype
// PUT [contextPath][api]/metatdata/korrespondanseparttype/
@ApiOperation(value = "Updates a CorrespondencePartType object", notes = "Returns the newly" + " updated CorrespondencePartType object after it is persisted to the database", response = CorrespondencePartType.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CorrespondencePartType " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = CorrespondencePartType.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 = CORRESPONDENCE_PART_TYPE + SLASH + FONDS_STATUS)
public ResponseEntity<MetadataHateoas> updateCorrespondencePartType(@RequestBody CorrespondencePartType correspondencePartType, HttpServletRequest request) throws NikitaException {
    CorrespondencePartType newCorrespondencePartType = correspondencePartTypeService.update(correspondencePartType);
    MetadataHateoas metadataHateoas = new MetadataHateoas(correspondencePartType);
    metadataHateoasHandler.addLinks(metadataHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(correspondencePartType.getVersion().toString()).body(metadataHateoas);
}
Also used : Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) CorrespondencePartType(nikita.model.noark5.v4.metadata.CorrespondencePartType) 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 13 with MetadataHateoas

use of nikita.model.noark5.v4.hateoas.metadata.MetadataHateoas in project nikita-noark5-core by HiOA-ABI.

the class DocumentMediumController method getDocumentMediumTemplate.

// Create a suggested documentMedium(like a template) with default values (nothing persisted)
// GET [contextPath][api]/metadata/ny-dokumentmedium
@ApiOperation(value = "Creates a suggested DocumentMedium", response = DocumentMedium.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "DocumentMedium codes found", response = DocumentMedium.class), @ApiResponse(code = 404, message = "No DocumentMedium 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_DOCUMENT_MEDIUM)
public ResponseEntity<MetadataHateoas> getDocumentMediumTemplate(HttpServletRequest request) {
    DocumentMedium documentMedium = new DocumentMedium();
    documentMedium.setCode(TEMPLATE_DOCUMENT_MEDIUM_CODE);
    documentMedium.setDescription(TEMPLATE_DOCUMENT_MEDIUM_DESCRIPTION);
    MetadataHateoas metadataHateoas = new MetadataHateoas(documentMedium);
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(metadataHateoas);
}
Also used : 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 14 with MetadataHateoas

use of nikita.model.noark5.v4.hateoas.metadata.MetadataHateoas in project nikita-noark5-core by HiOA-ABI.

the class DocumentMediumController method findAll.

// API - All GET Requests (CRUD - READ)
// Retrieves all documentMedium
// GET [contextPath][api]/metadata/dokumentmedium/
@ApiOperation(value = "Retrieves all DocumentMedium ", response = DocumentMedium.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "DocumentMedium codes found", response = DocumentMedium.class), @ApiResponse(code = 404, message = "No DocumentMedium 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 = DOCUMENT_MEDIUM)
public ResponseEntity<MetadataHateoas> findAll(HttpServletRequest request) {
    //ArrayList <DocumentMedium> documentMediumList = (ArrayList<DocumentMedium>) documentMediumService.findAll2();
    MetadataHateoas metadataHateoas = new MetadataHateoas(new ArrayList<>(documentMediumService.findAll2()), DOCUMENT_MEDIUM);
    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) 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 15 with MetadataHateoas

use of nikita.model.noark5.v4.hateoas.metadata.MetadataHateoas in project nikita-noark5-core by HiOA-ABI.

the class FondsStatusController method createFondsStatus.

// API - All POST Requests (CRUD - CREATE)
// Creates a new arkivstatus
// POST [contextPath][api]/metadata/arkivstatus/ny-arkivstatus
@ApiOperation(value = "Persists a new FondsStatus object", notes = "Returns the newly" + " created 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 = 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(method = RequestMethod.POST, value = FONDS_STATUS + SLASH + NEW_FONDS_STATUS)
public ResponseEntity<MetadataHateoas> createFondsStatus(HttpServletRequest request, @RequestBody FondsStatus fondsStatus) throws NikitaException {
    fondsStatusService.createNewFondsStatus(fondsStatus);
    MetadataHateoas metadataHateoas = new MetadataHateoas(fondsStatus);
    metadataHateoasHandler.addLinks(metadataHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(fondsStatus.getVersion().toString()).body(metadataHateoas);
}
Also used : Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) 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)

Aggregations

Counted (com.codahale.metrics.annotation.Counted)15 Timed (com.codahale.metrics.annotation.Timed)15 ApiOperation (io.swagger.annotations.ApiOperation)15 ApiResponses (io.swagger.annotations.ApiResponses)15 MetadataHateoas (nikita.model.noark5.v4.hateoas.metadata.MetadataHateoas)15 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)12 DocumentMedium (nikita.model.noark5.v4.metadata.DocumentMedium)4 CorrespondencePartType (nikita.model.noark5.v4.metadata.CorrespondencePartType)3 FondsStatus (nikita.model.noark5.v4.metadata.FondsStatus)3 IMetadataEntity (nikita.model.noark5.v4.interfaces.entities.IMetadataEntity)1 NikitaException (nikita.util.exceptions.NikitaException)1