use of nikita.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.
the class DocumentDescriptionService method getDocumentDescriptionOrThrow.
// All HELPER operations
/**
* 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 DocumentDescription back. If there is no valid
* DocumentDescription, an exception is thrown
*
* @param documentDescriptionSystemId
* @return
*/
protected DocumentDescription getDocumentDescriptionOrThrow(@NotNull String documentDescriptionSystemId) {
DocumentDescription documentDescription = documentDescriptionRepository.findBySystemIdOrderBySystemId(documentDescriptionSystemId);
if (documentDescription == null) {
String info = INFO_CANNOT_FIND_OBJECT + " DocumentDescription, using systemId " + documentDescriptionSystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
}
return documentDescription;
}
use of nikita.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.
the class DocumentObjectService method getDocumentObjectOrThrow.
// All HELPER operations
/**
* 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 DocumentObject back. If there is no valid
* DocumentObject, an exception is thrown
*
* @param documentObjectSystemId
* @return
*/
protected DocumentObject getDocumentObjectOrThrow(@NotNull String documentObjectSystemId) {
DocumentObject documentObject = documentObjectRepository.findBySystemIdOrderBySystemId(documentObjectSystemId);
if (documentObject == null) {
String info = INFO_CANNOT_FIND_OBJECT + " DocumentObject, using systemId " + documentObjectSystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
}
return documentObject;
}
use of nikita.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.
the class FileService method getFileOrThrow.
// All HELPER operations
/**
* 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 File back. If there is no valid
* File, an exception is thrown
*
* @param fileSystemId
* @return
*/
protected File getFileOrThrow(@NotNull String fileSystemId) {
File file = fileRepository.findBySystemIdOrderBySystemId(fileSystemId);
if (file == null) {
String info = INFO_CANNOT_FIND_OBJECT + " File, using systemId " + fileSystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
}
return file;
}
use of nikita.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.
the class FondsCreatorService method getFondsCreatorOrThrow.
// All HELPER operations
/**
* 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 FondsCreator back. If there is no valid
* FondsCreator, an exception is thrown
*
* @param fondsCreatorSystemId
* @return
*/
protected FondsCreator getFondsCreatorOrThrow(@NotNull String fondsCreatorSystemId) {
FondsCreator fondsCreator = fondsCreatorRepository.findBySystemIdOrderBySystemId(fondsCreatorSystemId);
if (fondsCreator == null) {
String info = INFO_CANNOT_FIND_OBJECT + " FondsCreator, using systemId " + fondsCreatorSystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
}
return fondsCreator;
}
use of nikita.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.
the class RecordService method createDocumentDescriptionAssociatedWithRecord.
@Override
public DocumentDescription createDocumentDescriptionAssociatedWithRecord(String systemID, DocumentDescription documentDescription) {
DocumentDescription persistedDocumentDescription = null;
Record record = recordRepository.findBySystemIdOrderBySystemId(systemID);
if (record == null) {
String info = INFO_CANNOT_FIND_OBJECT + " Record, using systemID " + systemID;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
} else {
TreeSet<Record> records = (TreeSet<Record>) documentDescription.getReferenceRecord();
if (records == null) {
records = new TreeSet<>();
documentDescription.setReferenceRecord(records);
}
records.add(record);
Set<DocumentDescription> documentDescriptions = record.getReferenceDocumentDescription();
documentDescriptions.add(documentDescription);
persistedDocumentDescription = documentDescriptionService.save(documentDescription);
}
return persistedDocumentDescription;
}
Aggregations