Search in sources :

Example 6 with DocumentStatus

use of nikita.common.model.noark5.v4.metadata.DocumentStatus in project nikita-noark5-core by HiOA-ABI.

the class DocumentStatusController method findBySystemId.

// Retrieves a given documentStatus identified by a systemId
// GET [contextPath][api]/metadata/dokumentstatus/{systemId}/
@ApiOperation(value = "Gets documentStatus identified by its systemId", notes = "Returns the requested " + " documentStatus object", response = DocumentStatus.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "DocumentStatus " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = DocumentStatus.class), @ApiResponse(code = 201, message = "DocumentStatus " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = DocumentStatus.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
@RequestMapping(value = DOCUMENT_STATUS + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH, method = RequestMethod.GET)
public ResponseEntity<MetadataHateoas> findBySystemId(@PathVariable("systemID") final String systemId, HttpServletRequest request) {
    DocumentStatus documentStatus = documentStatusService.findBySystemId(systemId);
    MetadataHateoas metadataHateoas = new MetadataHateoas(documentStatus);
    metadataHateoasHandler.addLinks(metadataHateoas, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(documentStatus.getVersion().toString()).body(metadataHateoas);
}
Also used : DocumentStatus(nikita.common.model.noark5.v4.metadata.DocumentStatus) Authorisation(nikita.webapp.security.Authorisation) MetadataHateoas(nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas) Counted(com.codahale.metrics.annotation.Counted) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 7 with DocumentStatus

use of nikita.common.model.noark5.v4.metadata.DocumentStatus in project nikita-noark5-core by HiOA-ABI.

the class DocumentStatusController method createDocumentStatus.

// API - All POST Requests (CRUD - CREATE)
// Creates a new dokumentstatus
// POST [contextPath][api]/metadata/dokumentstatus/ny-dokumentstatus
@ApiOperation(value = "Persists a new DocumentStatus object", notes = "Returns the newly" + " created DocumentStatus object after it is persisted to the database", response = DocumentStatus.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "DocumentStatus " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = DocumentStatus.class), @ApiResponse(code = 201, message = "DocumentStatus " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = DocumentStatus.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
@RequestMapping(method = RequestMethod.POST, value = DOCUMENT_STATUS + SLASH + NEW_DOCUMENT_STATUS)
public ResponseEntity<MetadataHateoas> createDocumentStatus(HttpServletRequest request, @RequestBody DocumentStatus documentStatus) throws NikitaException {
    documentStatusService.createNewDocumentStatus(documentStatus);
    MetadataHateoas metadataHateoas = new MetadataHateoas(documentStatus);
    metadataHateoasHandler.addLinks(metadataHateoas, new Authorisation());
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(documentStatus.getVersion().toString()).body(metadataHateoas);
}
Also used : Authorisation(nikita.webapp.security.Authorisation) MetadataHateoas(nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas) Counted(com.codahale.metrics.annotation.Counted) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

Counted (com.codahale.metrics.annotation.Counted)5 ApiOperation (io.swagger.annotations.ApiOperation)5 ApiResponses (io.swagger.annotations.ApiResponses)5 MetadataHateoas (nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas)5 Authorisation (nikita.webapp.security.Authorisation)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 DocumentStatus (nikita.common.model.noark5.v4.metadata.DocumentStatus)2 ParseException (java.text.ParseException)1 Date (java.util.Date)1 List (java.util.List)1 DocumentDescription (nikita.common.model.noark5.v4.DocumentDescription)1 INikitaEntity (nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity)1 NikitaMalformedInputDataException (nikita.common.util.exceptions.NikitaMalformedInputDataException)1 DocumentDescription (nikita.model.noark5.v4.DocumentDescription)1 NikitaMalformedInputDataException (nikita.util.exceptions.NikitaMalformedInputDataException)1