Search in sources :

Example 41 with NoarkEntityNotFoundException

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

the class BasicRecordService method getBasicRecordOrThrow.

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

Example 42 with NoarkEntityNotFoundException

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

the class CaseFileService method getCaseFileOrThrow.

// 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 CaseFile back. If there is no valid
 * CaseFile, an exception is thrown
 *
 * @param caseFileSystemId
 * @return
 */
protected CaseFile getCaseFileOrThrow(@NotNull String caseFileSystemId) {
    CaseFile caseFile = caseFileRepository.findBySystemId(caseFileSystemId);
    if (caseFile == null) {
        String info = INFO_CANNOT_FIND_OBJECT + " CaseFile, using systemId " + caseFileSystemId;
        logger.info(info);
        throw new NoarkEntityNotFoundException(info);
    }
    return caseFile;
}
Also used : CaseFile(nikita.common.model.noark5.v4.casehandling.CaseFile) NoarkEntityNotFoundException(nikita.common.util.exceptions.NoarkEntityNotFoundException)

Example 43 with NoarkEntityNotFoundException

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

the class ClassificationSystemService method getClassificationSystemOrThrow.

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

Example 44 with NoarkEntityNotFoundException

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

Example 45 with NoarkEntityNotFoundException

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

the class DocumentDescriptionService method createDocumentObjectAssociatedWithDocumentDescription.

// All CREATE operations
@Override
public DocumentObject createDocumentObjectAssociatedWithDocumentDescription(String documentDescriptionSystemId, DocumentObject documentObject) {
    DocumentObject persistedDocumentObject = null;
    DocumentDescription documentDescription = documentDescriptionRepository.findBySystemId(documentDescriptionSystemId);
    if (documentDescription == null) {
        String info = INFO_CANNOT_FIND_OBJECT + " DocumentDescription, using documentDescriptionSystemId " + documentDescriptionSystemId;
        logger.info(info);
        throw new NoarkEntityNotFoundException(info);
    } else {
        documentObject.setReferenceDocumentDescription(documentDescription);
        List<DocumentObject> documentObjects = documentDescription.getReferenceDocumentObject();
        documentObjects.add(documentObject);
        persistedDocumentObject = documentObjectService.save(documentObject);
    }
    return persistedDocumentObject;
}
Also used : DocumentDescription(nikita.common.model.noark5.v4.DocumentDescription) DocumentObject(nikita.common.model.noark5.v4.DocumentObject) 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