use of nikita.common.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.findBySystemId(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.common.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.
the class FondsService method getFondsOrThrow.
// 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 Fonds back. If there is no valid
* Fonds, a NoarkEntityNotFoundException exception is thrown
*
* @param fondsSystemId The systemId of the fonds object to retrieve
* @return the fonds object
*/
private Fonds getFondsOrThrow(@NotNull String fondsSystemId) {
Fonds fonds = fondsRepository.findBySystemId(fondsSystemId);
if (fonds == null) {
String info = INFO_CANNOT_FIND_OBJECT + " Fonds, using systemId " + fondsSystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
}
return fonds;
}
use of nikita.common.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.
the class RecordService method getRecordOrThrow.
// 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 Record back. If there is no valid
* Record, an exception is thrown
*
* @param systemID
* @return
*/
protected Record getRecordOrThrow(@NotNull String systemID) {
Record record = recordRepository.findBySystemId(systemID);
if (record == null) {
String info = INFO_CANNOT_FIND_OBJECT + " Record, using systemId " + systemID;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
}
return record;
}
use of nikita.common.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.findBySystemId(systemID);
if (record == null) {
String info = INFO_CANNOT_FIND_OBJECT + " Record, using systemID " + systemID;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
} else {
ArrayList<Record> records = (ArrayList<Record>) documentDescription.getReferenceRecord();
if (records == null) {
records = new ArrayList<>();
documentDescription.setReferenceRecord(records);
}
records.add(record);
List<DocumentDescription> documentDescriptions = record.getReferenceDocumentDescription();
documentDescriptions.add(documentDescription);
persistedDocumentDescription = documentDescriptionService.save(documentDescription);
}
return persistedDocumentDescription;
}
use of nikita.common.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.
the class AdministrativeUnitService method getAdministrativeUnitOrThrow.
// 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 AdministrativeUnit back. If there is no valid
* AdministrativeUnit, an exception is thrown
*
* @param administrativeUnitSystemId
* @return
*/
protected AdministrativeUnit getAdministrativeUnitOrThrow(@NotNull String administrativeUnitSystemId) {
AdministrativeUnit administrativeUnit = administrativeUnitRepository.findBySystemId(administrativeUnitSystemId);
if (administrativeUnit == null) {
String info = INFO_CANNOT_FIND_OBJECT + " AdministrativeUnit, using systemId " + administrativeUnitSystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
}
return administrativeUnit;
}
Aggregations