use of nikita.common.util.exceptions.NikitaMalformedInputDataException in project nikita-noark5-core by HiOA-ABI.
the class ClassifiactionSystemDeserializer method deserialize.
@Override
public ClassificationSystem deserialize(JsonParser jsonParser, DeserializationContext dc) throws IOException {
StringBuilder errors = new StringBuilder();
ClassificationSystem classificationSystem = new ClassificationSystem();
ObjectNode objectNode = mapper.readTree(jsonParser);
// Deserialise general properties
CommonUtils.Hateoas.Deserialize.deserialiseNoarkEntity(classificationSystem, objectNode, errors);
// If there are additional throw a malformed input exception
if (objectNode.size() != 0) {
errors.append("The klassifikasjonssystem you tried to create is " + "malformed. The following fields are not recognised as klassifikasjonssystem fields [" + CommonUtils.Hateoas.Deserialize.checkNodeObjectEmpty(objectNode) + "]. ");
}
if (0 < errors.length())
throw new NikitaMalformedInputDataException(errors.toString());
return classificationSystem;
}
use of nikita.common.util.exceptions.NikitaMalformedInputDataException in project nikita-noark5-core by HiOA-ABI.
the class DocumentObjectDeserializer method deserialize.
@Override
public DocumentObject deserialize(JsonParser jsonParser, DeserializationContext dc) throws IOException {
StringBuilder errors = new StringBuilder();
DocumentObject documentObject = new DocumentObject();
ObjectNode objectNode = mapper.readTree(jsonParser);
// Deserialise general DocumentObject properties
CommonUtils.Hateoas.Deserialize.deserialiseNoarkSystemIdEntity(documentObject, objectNode, errors);
// Deserialize versionNumber
JsonNode currentNode = objectNode.get(N5ResourceMappings.DOCUMENT_OBJECT_VERSION_NUMBER);
if (null != currentNode) {
documentObject.setVersionNumber(new Integer(currentNode.intValue()));
objectNode.remove(N5ResourceMappings.DOCUMENT_OBJECT_VERSION_NUMBER);
}
// Deserialize variantFormat
currentNode = objectNode.get(N5ResourceMappings.DOCUMENT_OBJECT_VARIANT_FORMAT);
if (null != currentNode) {
documentObject.setVariantFormat(currentNode.textValue());
objectNode.remove(N5ResourceMappings.DOCUMENT_OBJECT_VARIANT_FORMAT);
}
// Deserialize format
currentNode = objectNode.get(N5ResourceMappings.DOCUMENT_OBJECT_FORMAT);
if (null != currentNode) {
documentObject.setFormat(currentNode.textValue());
objectNode.remove(N5ResourceMappings.DOCUMENT_OBJECT_FORMAT);
}
// Deserialize formatDetails
currentNode = objectNode.get(N5ResourceMappings.DOCUMENT_OBJECT_FORMAT_DETAILS);
if (null != currentNode) {
documentObject.setFormatDetails(currentNode.textValue());
objectNode.remove(N5ResourceMappings.DOCUMENT_OBJECT_FORMAT_DETAILS);
}
CommonUtils.Hateoas.Deserialize.deserialiseNoarkCreateEntity(documentObject, objectNode, errors);
// Deserialize referenceDocumentFile
currentNode = objectNode.get(N5ResourceMappings.DOCUMENT_OBJECT_REFERENCE_DOCUMENT_FILE);
if (null != currentNode) {
documentObject.setReferenceDocumentFile(currentNode.textValue());
objectNode.remove(N5ResourceMappings.DOCUMENT_OBJECT_REFERENCE_DOCUMENT_FILE);
}
// Deserialize checksum
currentNode = objectNode.get(N5ResourceMappings.DOCUMENT_OBJECT_CHECKSUM);
if (null != currentNode) {
documentObject.setChecksum(currentNode.textValue());
objectNode.remove(N5ResourceMappings.DOCUMENT_OBJECT_CHECKSUM);
}
// Deserialize checksumAlgorithm
currentNode = objectNode.get(N5ResourceMappings.DOCUMENT_OBJECT_CHECKSUM_ALGORITHM);
if (null != currentNode) {
documentObject.setChecksumAlgorithm(currentNode.textValue());
objectNode.remove(N5ResourceMappings.DOCUMENT_OBJECT_CHECKSUM_ALGORITHM);
}
// Deserialize fileSize
currentNode = objectNode.get(N5ResourceMappings.DOCUMENT_OBJECT_FILE_SIZE);
if (null != currentNode) {
documentObject.setFileSize(currentNode.asLong());
objectNode.remove(N5ResourceMappings.DOCUMENT_OBJECT_FILE_SIZE);
}
// Deserialize filename
currentNode = objectNode.get(N5ResourceMappings.DOCUMENT_OBJECT_FILE_NAME);
if (null != currentNode) {
documentObject.setOriginalFilename(currentNode.textValue());
objectNode.remove(N5ResourceMappings.DOCUMENT_OBJECT_FILE_NAME);
}
// Deserialize mimeType
currentNode = objectNode.get(N5ResourceMappings.DOCUMENT_OBJECT_MIME_TYPE);
if (null != currentNode) {
documentObject.setMimeType(currentNode.textValue());
objectNode.remove(N5ResourceMappings.DOCUMENT_OBJECT_MIME_TYPE);
}
// If there are additional throw a malformed input exception
if (objectNode.size() != 0) {
errors.append("The dokumentobjekt you tried to create is malformed. The " + "following fields are not recognised as dokumentobjekt fields [" + CommonUtils.Hateoas.Deserialize.checkNodeObjectEmpty(objectNode) + "]. ");
}
if (0 < errors.length())
throw new NikitaMalformedInputDataException(errors.toString());
return documentObject;
}
use of nikita.common.util.exceptions.NikitaMalformedInputDataException in project nikita-noark5-core by HiOA-ABI.
the class FileDeserializer method deserialize.
@Override
public File deserialize(JsonParser jsonParser, DeserializationContext dc) throws IOException {
StringBuilder errors = new StringBuilder();
File file = new File();
ObjectNode objectNode = mapper.readTree(jsonParser);
// Deserialise general properties
CommonUtils.Hateoas.Deserialize.deserialiseNoarkEntity(file, objectNode, errors);
CommonUtils.Hateoas.Deserialize.deserialiseDocumentMedium(file, objectNode, errors);
CommonUtils.Hateoas.Deserialize.deserialiseStorageLocation(file, objectNode, errors);
CommonUtils.Hateoas.Deserialize.deserialiseKeyword(file, objectNode, errors);
// Deserialize fileId
JsonNode currentNode = objectNode.get(N5ResourceMappings.FILE_ID);
if (null != currentNode) {
file.setFileId(currentNode.textValue());
objectNode.remove(N5ResourceMappings.FILE_ID);
}
// Deserialize officialTitle
currentNode = objectNode.get(N5ResourceMappings.FILE_PUBLIC_TITLE);
if (null != currentNode) {
file.setOfficialTitle(currentNode.textValue());
objectNode.remove(N5ResourceMappings.FILE_PUBLIC_TITLE);
}
// TODO: FIX THIS CommonCommonUtils.Hateoas.Deserialize.deserialiseCrossReference(file, objectNode);
CommonUtils.Hateoas.Deserialize.deserialiseComments(file, objectNode, errors);
file.setReferenceDisposal(CommonUtils.Hateoas.Deserialize.deserialiseDisposal(objectNode, errors));
file.setReferenceScreening(CommonUtils.Hateoas.Deserialize.deserialiseScreening(objectNode, errors));
file.setReferenceClassified(CommonUtils.Hateoas.Deserialize.deserialiseClassified(objectNode, errors));
// Deserialize referenceSeries
currentNode = objectNode.get(N5ResourceMappings.REFERENCE_SERIES);
if (null != currentNode) {
Series series = new Series();
String systemID = currentNode.textValue();
if (systemID != null) {
series.setSystemId(systemID);
}
file.setReferenceSeries(series);
objectNode.remove(N5ResourceMappings.REFERENCE_SERIES);
}
// If there are additional throw a malformed input exception
if (objectNode.size() != 0) {
errors.append("The mappe you tried to create is malformed. The " + "following fields are not recognised as mappe fields [" + CommonUtils.Hateoas.Deserialize.checkNodeObjectEmpty(objectNode) + "]. ");
}
if (0 < errors.length())
throw new NikitaMalformedInputDataException(errors.toString());
return file;
}
use of nikita.common.util.exceptions.NikitaMalformedInputDataException in project nikita-noark5-core by HiOA-ABI.
the class FondsCreatorDeserializer method deserialize.
@Override
public FondsCreator deserialize(JsonParser jsonParser, DeserializationContext dc) throws IOException {
StringBuilder errors = new StringBuilder();
FondsCreator fondsCreator = new FondsCreator();
ObjectNode objectNode = mapper.readTree(jsonParser);
// Deserialise general properties
CommonUtils.Hateoas.Deserialize.deserialiseFondsCreator(fondsCreator, objectNode, errors);
// If there are additional throw a malformed input exception
if (objectNode.size() != 0) {
errors.append("The arkivskaper you tried to create is malformed. The " + "following fields are not recognised as arkivskaper fields [" + CommonUtils.Hateoas.Deserialize.checkNodeObjectEmpty(objectNode) + "]. ");
}
if (0 < errors.length())
throw new NikitaMalformedInputDataException(errors.toString());
return fondsCreator;
}
use of nikita.common.util.exceptions.NikitaMalformedInputDataException in project nikita-noark5-core by HiOA-ABI.
the class SeriesDeserializer method deserialize.
@Override
public Series deserialize(JsonParser jsonParser, DeserializationContext dc) throws IOException {
StringBuilder errors = new StringBuilder();
Series series = new Series();
ObjectNode objectNode = mapper.readTree(jsonParser);
// Deserialise general properties
CommonUtils.Hateoas.Deserialize.deserialiseNoarkEntity(series, objectNode, errors);
CommonUtils.Hateoas.Deserialize.deserialiseDocumentMedium(series, objectNode, errors);
CommonUtils.Hateoas.Deserialize.deserialiseStorageLocation(series, objectNode, errors);
// Deserialize seriesStatus
JsonNode currentNode = objectNode.get(N5ResourceMappings.SERIES_STATUS);
if (null != currentNode) {
series.setSeriesStatus(currentNode.textValue());
objectNode.remove(N5ResourceMappings.SERIES_STATUS);
}
// Deserialize seriesStartDate
series.setSeriesStartDate(CommonUtils.Hateoas.Deserialize.deserializeDate(N5ResourceMappings.SERIES_START_DATE, objectNode, errors));
// Deserialize seriesEndDate
series.setSeriesEndDate(CommonUtils.Hateoas.Deserialize.deserializeDate(N5ResourceMappings.SERIES_END_DATE, objectNode, errors));
// Deserialize referencePrecursor
currentNode = objectNode.get(N5ResourceMappings.SERIES_PRECURSOR);
if (null != currentNode) {
Series seriesPrecursor = new Series();
seriesPrecursor.setSystemId(currentNode.textValue());
series.setReferencePrecursor(seriesPrecursor);
// TODO: Does this imply that the current arkivdel is the successor?
// I would not set it here, as the service class has to check that
// the seriesPrecursor object actually exists
objectNode.remove(N5ResourceMappings.SERIES_PRECURSOR);
}
// Deserialize referenceSuccessor
currentNode = objectNode.get(N5ResourceMappings.SERIES_SUCCESSOR);
if (null != currentNode) {
Series seriesSuccessor = new Series();
seriesSuccessor.setSystemId(currentNode.textValue());
series.setReferenceSuccessor(seriesSuccessor);
// TODO: Does this imply that the current arkivdel is the precursor?
// I would not set it here, as the service class should do this
objectNode.remove(N5ResourceMappings.SERIES_SUCCESSOR);
}
series.setReferenceDisposal(CommonUtils.Hateoas.Deserialize.deserialiseDisposal(objectNode, errors));
series.setReferenceDisposalUndertaken(CommonUtils.Hateoas.Deserialize.deserialiseDisposalUndertaken(objectNode, errors));
series.setReferenceDeletion(CommonUtils.Hateoas.Deserialize.deserialiseDeletion(objectNode, errors));
series.setReferenceScreening(CommonUtils.Hateoas.Deserialize.deserialiseScreening(objectNode, errors));
series.setReferenceClassified(CommonUtils.Hateoas.Deserialize.deserialiseClassified(objectNode, errors));
// If there are additional throw a malformed input exception
if (objectNode.size() != 0) {
errors.append("The arkivdel you tried to create is malformed. The " + "following fields are not recognised as arkivdel fields [" + CommonUtils.Hateoas.Deserialize.checkNodeObjectEmpty(objectNode) + "]. ");
}
if (0 < errors.length())
throw new NikitaMalformedInputDataException(errors.toString());
return series;
}
Aggregations