Search in sources :

Example 6 with SeriesStatus

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

the class FondsDeserializer method deserialize.

@Override
public Fonds deserialize(JsonParser jsonParser, DeserializationContext dc) throws IOException {
    StringBuilder errors = new StringBuilder();
    Fonds fonds = new Fonds();
    ObjectNode objectNode = mapper.readTree(jsonParser);
    // TODO : Are we deserialising parent? No, it's not done here or is it????
    // Deserialise general properties
    CommonUtils.Hateoas.Deserialize.deserialiseNoarkEntity(fonds, objectNode, errors);
    CommonUtils.Hateoas.Deserialize.deserialiseDocumentMedium(fonds, objectNode, errors);
    CommonUtils.Hateoas.Deserialize.deserialiseStorageLocation(fonds, objectNode, errors);
    // Deserialize seriesStatus
    JsonNode currentNode = objectNode.get(N5ResourceMappings.FONDS_STATUS);
    if (currentNode != null) {
        fonds.setFondsStatus(currentNode.textValue());
        objectNode.remove(N5ResourceMappings.FONDS_STATUS);
    }
    // If there are additional throw a malformed input exception
    if (objectNode.size() != 0) {
        errors.append("The arkiv you tried to create is malformed. The " + "following fields are not recognised as arkiv fields [" + CommonUtils.Hateoas.Deserialize.checkNodeObjectEmpty(objectNode) + "]. ");
    }
    if (0 < errors.length())
        throw new NikitaMalformedInputDataException(errors.toString());
    return fonds;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Fonds(nikita.common.model.noark5.v4.Fonds) JsonNode(com.fasterxml.jackson.databind.JsonNode) NikitaMalformedInputDataException(nikita.common.util.exceptions.NikitaMalformedInputDataException)

Example 7 with SeriesStatus

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

the class SeriesStatusController method findBySystemId.

// Retrieves a given seriesStatus identified by a systemId
// GET [contextPath][api]/metadata/arkivdelstatus/{systemId}/
@ApiOperation(value = "Gets seriesStatus identified by its systemId", notes = "Returns the requested " + " seriesStatus object", response = SeriesStatus.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "SeriesStatus " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = SeriesStatus.class), @ApiResponse(code = 201, message = "SeriesStatus " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = SeriesStatus.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 = FONDS_STATUS + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH, method = RequestMethod.GET)
public ResponseEntity<MetadataHateoas> findBySystemId(@PathVariable("systemID") final String systemId, HttpServletRequest request) {
    SeriesStatus seriesStatus = seriesStatusService.findBySystemId(systemId);
    MetadataHateoas metadataHateoas = new MetadataHateoas(seriesStatus);
    metadataHateoasHandler.addLinks(metadataHateoas, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(seriesStatus.getVersion().toString()).body(metadataHateoas);
}
Also used : SeriesStatus(nikita.common.model.noark5.v4.metadata.SeriesStatus) 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 8 with SeriesStatus

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

the class SeriesStatusController method createSeriesStatus.

// API - All POST Requests (CRUD - CREATE)
// Creates a new arkivdelstatus
// POST [contextPath][api]/metadata/arkivdelstatus/ny-arkivdelstatus
@ApiOperation(value = "Persists a new SeriesStatus object", notes = "Returns the newly" + " created SeriesStatus object after it is persisted to the database", response = SeriesStatus.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "SeriesStatus " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = SeriesStatus.class), @ApiResponse(code = 201, message = "SeriesStatus " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = SeriesStatus.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 = FONDS_STATUS + SLASH + NEW_FONDS_STATUS)
public ResponseEntity<MetadataHateoas> createSeriesStatus(HttpServletRequest request, @RequestBody SeriesStatus seriesStatus) throws NikitaException {
    seriesStatusService.createNewSeriesStatus(seriesStatus);
    MetadataHateoas metadataHateoas = new MetadataHateoas(seriesStatus);
    metadataHateoasHandler.addLinks(metadataHateoas, new Authorisation());
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(seriesStatus.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)

Example 9 with SeriesStatus

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

the class SeriesStatusController method getSeriesStatusTemplate.

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

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

the class SeriesStatusController method updateSeriesStatus.

// API - All PUT Requests (CRUD - UPDATE)
// Update a arkivdelstatus
// PUT [contextPath][api]/metatdata/arkivdelstatus/
@ApiOperation(value = "Updates a SeriesStatus object", notes = "Returns the newly" + " updated SeriesStatus object after it is persisted to the database", response = SeriesStatus.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "SeriesStatus " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = SeriesStatus.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
@RequestMapping(method = RequestMethod.PUT, value = FONDS_STATUS + SLASH + FONDS_STATUS)
public ResponseEntity<MetadataHateoas> updateSeriesStatus(@RequestBody SeriesStatus seriesStatus, HttpServletRequest request) throws NikitaException {
    seriesStatusService.update(seriesStatus);
    MetadataHateoas metadataHateoas = new MetadataHateoas(seriesStatus);
    metadataHateoasHandler.addLinks(metadataHateoas, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).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

JsonNode (com.fasterxml.jackson.databind.JsonNode)6 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)6 Counted (com.codahale.metrics.annotation.Counted)4 ApiOperation (io.swagger.annotations.ApiOperation)4 ApiResponses (io.swagger.annotations.ApiResponses)4 MetadataHateoas (nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas)4 NikitaMalformedInputDataException (nikita.common.util.exceptions.NikitaMalformedInputDataException)3 NikitaMalformedInputDataException (nikita.util.exceptions.NikitaMalformedInputDataException)3 Authorisation (nikita.webapp.security.Authorisation)3 Fonds (nikita.common.model.noark5.v4.Fonds)2 SeriesStatus (nikita.common.model.noark5.v4.metadata.SeriesStatus)2 Fonds (nikita.model.noark5.v4.Fonds)2 ParseException (java.text.ParseException)1 Date (java.util.Date)1 Series (nikita.common.model.noark5.v4.Series)1 Series (nikita.model.noark5.v4.Series)1