use of nikita.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.
the class RegistryEntryService method getRegistryEntryOrThrow.
/**
* 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 RegistryEntry back. If there is no valid
* RegistryEntry, an exception is thrown
*
* @param registryEntrySystemId
* @return
*/
protected RegistryEntry getRegistryEntryOrThrow(@NotNull String registryEntrySystemId) {
RegistryEntry registryEntry = registryEntryRepository.findBySystemIdOrderBySystemId(registryEntrySystemId);
if (registryEntry == null) {
String info = INFO_CANNOT_FIND_OBJECT + " RegistryEntry, using systemId " + registryEntrySystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
}
return registryEntry;
}
use of nikita.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.
the class SeriesService method createFileAssociatedWithSeries.
@Override
public File createFileAssociatedWithSeries(String seriesSystemId, File file) {
File persistedFile = null;
Series series = seriesRepository.findBySystemIdOrderBySystemId(seriesSystemId);
if (series == null) {
String info = INFO_CANNOT_FIND_OBJECT + " Series, using seriesSystemId " + seriesSystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
} else if (series.getSeriesStatus() != null && series.getSeriesStatus().equals(STATUS_CLOSED)) {
String info = INFO_CANNOT_ASSOCIATE_WITH_CLOSED_OBJECT + ". Series with seriesSystemId " + seriesSystemId + "has status " + STATUS_CLOSED;
logger.info(info);
throw new NoarkEntityEditWhenClosedException(info);
} else {
file.setReferenceSeries(series);
persistedFile = fileService.createFile(file);
}
return persistedFile;
}
use of nikita.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.
the class SeriesService method getSeriesOrThrow.
// Helper methods
/**
* 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 Series back. If there is no valid
* Series, an exception is thrown
*
* @param seriesSystemId
* @return
*/
protected Series getSeriesOrThrow(@NotNull String seriesSystemId) {
Series series = seriesRepository.findBySystemIdOrderBySystemId(seriesSystemId);
if (series == null) {
String info = INFO_CANNOT_FIND_OBJECT + " Series, using systemId " + seriesSystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
}
return series;
}
use of nikita.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.
the class FileImportService method createRecordAssociatedWithFile.
@Override
public Record createRecordAssociatedWithFile(String fileSystemId, Record record) {
Record persistedRecord = null;
File file = fileRepository.findBySystemIdOrderBySystemId(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 = recordImportService.save(record);
}
return persistedRecord;
}
use of nikita.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.
the class FileImportService method createBasicRecordAssociatedWithFile.
@Override
public BasicRecord createBasicRecordAssociatedWithFile(String fileSystemId, BasicRecord basicRecord) {
BasicRecord persistedBasicRecord = null;
File file = fileRepository.findBySystemIdOrderBySystemId(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) recordImportService.save(basicRecord);
}
return persistedBasicRecord;
}
Aggregations