use of nikita.common.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.findBySystemId(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.common.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.findBySystemId(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.common.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.findBySystemId(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.common.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.findBySystemId(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.common.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.
the class SeriesService method createCaseFileAssociatedWithSeries.
// All CREATE operations
@Override
public CaseFile createCaseFileAssociatedWithSeries(String seriesSystemId, CaseFile caseFile) {
CaseFile persistedFile = null;
Series series = seriesRepository.findBySystemId(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 {
caseFile.setReferenceSeries(series);
persistedFile = caseFileService.save(caseFile);
}
return persistedFile;
}
Aggregations