Search in sources :

Example 16 with NoarkEntityNotFoundException

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;
}
Also used : NoarkEntityNotFoundException(nikita.common.util.exceptions.NoarkEntityNotFoundException) FondsCreator(nikita.common.model.noark5.v4.FondsCreator)

Example 17 with NoarkEntityNotFoundException

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;
}
Also used : Fonds(nikita.common.model.noark5.v4.Fonds) NoarkEntityNotFoundException(nikita.common.util.exceptions.NoarkEntityNotFoundException)

Example 18 with NoarkEntityNotFoundException

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;
}
Also used : Record(nikita.common.model.noark5.v4.Record) NoarkEntityNotFoundException(nikita.common.util.exceptions.NoarkEntityNotFoundException)

Example 19 with NoarkEntityNotFoundException

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;
}
Also used : DocumentDescription(nikita.common.model.noark5.v4.DocumentDescription) Record(nikita.common.model.noark5.v4.Record) NoarkEntityNotFoundException(nikita.common.util.exceptions.NoarkEntityNotFoundException)

Example 20 with NoarkEntityNotFoundException

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;
}
Also used : AdministrativeUnit(nikita.common.model.noark5.v4.admin.AdministrativeUnit) NoarkEntityNotFoundException(nikita.common.util.exceptions.NoarkEntityNotFoundException)

Aggregations

NoarkEntityNotFoundException (nikita.common.util.exceptions.NoarkEntityNotFoundException)55 Authorisation (nikita.webapp.security.Authorisation)13 Counted (com.codahale.metrics.annotation.Counted)12 ApiOperation (io.swagger.annotations.ApiOperation)10 ApiResponses (io.swagger.annotations.ApiResponses)10 List (java.util.List)5 DocumentDescription (nikita.common.model.noark5.v4.DocumentDescription)5 DocumentObject (nikita.common.model.noark5.v4.DocumentObject)5 CaseFile (nikita.common.model.noark5.v4.casehandling.CaseFile)5 INikitaEntity (nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity)5 Class (nikita.common.model.noark5.v4.Class)4 File (nikita.common.model.noark5.v4.File)4 Record (nikita.common.model.noark5.v4.Record)4 BasicRecord (nikita.common.model.noark5.v4.BasicRecord)3 ClassificationSystem (nikita.common.model.noark5.v4.ClassificationSystem)3 Series (nikita.common.model.noark5.v4.Series)3 DocumentObjectHateoas (nikita.common.model.noark5.v4.hateoas.DocumentObjectHateoas)3 NoarkEntityEditWhenClosedException (nikita.common.util.exceptions.NoarkEntityEditWhenClosedException)3 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2