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;
}
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);
}
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);
}
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);
}
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);
}
Aggregations