use of nikita.common.model.noark5.v4.metadata.Format in project nikita-noark5-core by HiOA-ABI.
the class FormatService method createNewFormat.
// All CREATE operations
/**
* Persists a new Format object to the database.
*
* @param format Format object with values set
* @return the newly persisted Format object wrapped as a MetadataHateoas
* object
*/
@Override
public MetadataHateoas createNewFormat(Format format) {
format.setDeleted(false);
format.setOwnedBy(SecurityContextHolder.getContext().getAuthentication().getName());
MetadataHateoas metadataHateoas = new MetadataHateoas(formatRepository.save(format));
metadataHateoasHandler.addLinks(metadataHateoas, new Authorisation());
return metadataHateoas;
}
use of nikita.common.model.noark5.v4.metadata.Format in project nikita-noark5-core by HiOA-ABI.
the class FormatService method find.
// find by systemId
/**
* Retrieve a single Format object identified by systemId
*
* @param systemId systemId of the Format you wish to retrieve
* @return single Format object wrapped as a MetadataHateoas object
*/
@Override
public MetadataHateoas find(String systemId) {
MetadataHateoas metadataHateoas = new MetadataHateoas(formatRepository.save(formatRepository.findBySystemId(systemId)));
metadataHateoasHandler.addLinks(metadataHateoas, new Authorisation());
return metadataHateoas;
}
use of nikita.common.model.noark5.v4.metadata.Format in project nikita-noark5-core by HiOA-ABI.
the class RegistryEntryTypeService method generateDefaultRegistryEntryType.
/**
* Generate a default RegistryEntryType object
*
* @return the RegistryEntryType object
*/
@Override
public RegistryEntryType generateDefaultRegistryEntryType() {
RegistryEntryType format = new RegistryEntryType();
format.setCode(TEMPLATE_REGISTRY_ENTRY_TYPE_CODE);
format.setDescription(TEMPLATE_REGISTRY_ENTRY_TYPE_DESCRIPTION);
return format;
}
use of nikita.common.model.noark5.v4.metadata.Format in project nikita-noark5-core by HiOA-ABI.
the class RegistryEntryTypeService method getRegistryEntryTypeOrThrow.
/**
* Internal helper method. Rather than having a find and try catch in
* multiple methods, we have it here once. If you call this, be aware
* that you will only ever get a valid RegistryEntryType object back. If
* there is no RegistryEntryType object, a NoarkEntityNotFoundException
* exception is thrown
*
* @param systemId The systemId of the RegistryEntryType object to retrieve
* @return the RegistryEntryType object
*/
private RegistryEntryType getRegistryEntryTypeOrThrow(@NotNull String systemId) {
RegistryEntryType format = formatRepository.findBySystemId(systemId);
if (format == null) {
String info = INFO_CANNOT_FIND_OBJECT + " RegistryEntryType, " + "using systemId " + systemId;
logger.error(info);
throw new NoarkEntityNotFoundException(info);
}
return format;
}
use of nikita.common.model.noark5.v4.metadata.Format 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;
}
Aggregations