use of nikita.common.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.
the class ClassService method getClassOrThrow.
// 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 Class back. If there is no valid
* Class, an exception is thrown
*
* @param classSystemId systemId of the class object you are looking for
* @return the newly found class object or null if it does not exist
*/
protected Class getClassOrThrow(@NotNull String classSystemId) {
Class klass = classRepository.findBySystemId(classSystemId);
if (null == klass) {
String info = INFO_CANNOT_FIND_OBJECT + " Class, using systemId " + classSystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
}
return klass;
}
use of nikita.common.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.
the class ClassificationSystemService method createClassAssociatedWithClassificationSystem.
@Override
public Class createClassAssociatedWithClassificationSystem(String classificationSystemSystemId, Class klass) {
Class persistedClass = null;
ClassificationSystem classificationSystem = classificationSystemRepository.findBySystemId(classificationSystemSystemId);
if (classificationSystem == null) {
String info = INFO_CANNOT_FIND_OBJECT + " ClassificationSystem, using classificationSystemSystemId " + classificationSystemSystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
} else {
klass.setReferenceClassificationSystem(classificationSystem);
persistedClass = classService.save(klass);
}
return persistedClass;
}
use of nikita.common.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 systemId of the file object you are looking for
* @return the newly found file object or null if it does not exist
*/
private File getFileOrThrow(@NotNull String fileSystemId) {
File file = fileRepository.findBySystemId(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.common.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.
the class FileService method createRecordAssociatedWithFile.
@Override
public Record createRecordAssociatedWithFile(String fileSystemId, Record record) {
Record persistedRecord;
File file = fileRepository.findBySystemId(fileSystemId);
if (file == null) {
String info = INFO_CANNOT_FIND_OBJECT + " File, using fileSystemId " + fileSystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
} else {
record.setReferenceFile(file);
persistedRecord = recordService.save(record);
}
return persistedRecord;
}
use of nikita.common.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.
the class FileService method createBasicRecordAssociatedWithFile.
@Override
public BasicRecord createBasicRecordAssociatedWithFile(String fileSystemId, BasicRecord basicRecord) {
BasicRecord persistedBasicRecord;
File file = fileRepository.findBySystemId(fileSystemId);
if (file == null) {
String info = INFO_CANNOT_FIND_OBJECT + " File, using fileSystemId " + fileSystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
} else {
basicRecord.setReferenceFile(file);
persistedBasicRecord = (BasicRecord) recordService.save(basicRecord);
}
return persistedBasicRecord;
}
Aggregations