Search in sources :

Example 31 with NoarkEntityNotFoundException

use of nikita.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.

the class DocumentDescriptionService method getDocumentDescriptionOrThrow.

// 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 DocumentDescription back. If there is no valid
     * DocumentDescription, an exception is thrown
     *
     * @param documentDescriptionSystemId
     * @return
     */
protected DocumentDescription getDocumentDescriptionOrThrow(@NotNull String documentDescriptionSystemId) {
    DocumentDescription documentDescription = documentDescriptionRepository.findBySystemIdOrderBySystemId(documentDescriptionSystemId);
    if (documentDescription == null) {
        String info = INFO_CANNOT_FIND_OBJECT + " DocumentDescription, using systemId " + documentDescriptionSystemId;
        logger.info(info);
        throw new NoarkEntityNotFoundException(info);
    }
    return documentDescription;
}
Also used : DocumentDescription(nikita.model.noark5.v4.DocumentDescription) NoarkEntityNotFoundException(nikita.util.exceptions.NoarkEntityNotFoundException)

Example 32 with NoarkEntityNotFoundException

use of nikita.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.findBySystemIdOrderBySystemId(documentObjectSystemId);
    if (documentObject == null) {
        String info = INFO_CANNOT_FIND_OBJECT + " DocumentObject, using systemId " + documentObjectSystemId;
        logger.info(info);
        throw new NoarkEntityNotFoundException(info);
    }
    return documentObject;
}
Also used : DocumentObject(nikita.model.noark5.v4.DocumentObject) NoarkEntityNotFoundException(nikita.util.exceptions.NoarkEntityNotFoundException)

Example 33 with NoarkEntityNotFoundException

use of nikita.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
     * @return
     */
protected File getFileOrThrow(@NotNull String fileSystemId) {
    File file = fileRepository.findBySystemIdOrderBySystemId(fileSystemId);
    if (file == null) {
        String info = INFO_CANNOT_FIND_OBJECT + " File, using systemId " + fileSystemId;
        logger.info(info);
        throw new NoarkEntityNotFoundException(info);
    }
    return file;
}
Also used : NoarkEntityNotFoundException(nikita.util.exceptions.NoarkEntityNotFoundException) File(nikita.model.noark5.v4.File)

Example 34 with NoarkEntityNotFoundException

use of nikita.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.findBySystemIdOrderBySystemId(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.util.exceptions.NoarkEntityNotFoundException) FondsCreator(nikita.model.noark5.v4.FondsCreator)

Example 35 with NoarkEntityNotFoundException

use of nikita.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.findBySystemIdOrderBySystemId(systemID);
    if (record == null) {
        String info = INFO_CANNOT_FIND_OBJECT + " Record, using systemID " + systemID;
        logger.info(info);
        throw new NoarkEntityNotFoundException(info);
    } else {
        TreeSet<Record> records = (TreeSet<Record>) documentDescription.getReferenceRecord();
        if (records == null) {
            records = new TreeSet<>();
            documentDescription.setReferenceRecord(records);
        }
        records.add(record);
        Set<DocumentDescription> documentDescriptions = record.getReferenceDocumentDescription();
        documentDescriptions.add(documentDescription);
        persistedDocumentDescription = documentDescriptionService.save(documentDescription);
    }
    return persistedDocumentDescription;
}
Also used : DocumentDescription(nikita.model.noark5.v4.DocumentDescription) Record(nikita.model.noark5.v4.Record) NoarkEntityNotFoundException(nikita.util.exceptions.NoarkEntityNotFoundException)

Aggregations

NoarkEntityNotFoundException (nikita.util.exceptions.NoarkEntityNotFoundException)51 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)15 Counted (com.codahale.metrics.annotation.Counted)14 Timed (com.codahale.metrics.annotation.Timed)14 ApiOperation (io.swagger.annotations.ApiOperation)12 ApiResponses (io.swagger.annotations.ApiResponses)12 Fonds (nikita.model.noark5.v4.Fonds)8 CaseFile (nikita.model.noark5.v4.casehandling.CaseFile)8 DocumentDescription (nikita.model.noark5.v4.DocumentDescription)7 File (nikita.model.noark5.v4.File)7 Record (nikita.model.noark5.v4.Record)7 Series (nikita.model.noark5.v4.Series)7 NoarkEntityEditWhenClosedException (nikita.util.exceptions.NoarkEntityEditWhenClosedException)7 BasicRecord (nikita.model.noark5.v4.BasicRecord)5 DocumentObject (nikita.model.noark5.v4.DocumentObject)5 Class (nikita.model.noark5.v4.Class)4 ClassificationSystem (nikita.model.noark5.v4.ClassificationSystem)3 RegistryEntry (nikita.model.noark5.v4.casehandling.RegistryEntry)3 DocumentObjectHateoas (nikita.model.noark5.v4.hateoas.DocumentObjectHateoas)3 IOException (java.io.IOException)2