Search in sources :

Example 11 with NoarkEntityNotFoundException

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

the class ClassService method getClassOrThrow.

// 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 Class back. If there is no valid
 * Class, an exception is thrown
 *
 * @param classSystemId systemId of the class object you are looking for
 * @return the newly found class object or null if it does not exist
 */
protected Class getClassOrThrow(@NotNull String classSystemId) {
    Class klass = classRepository.findBySystemId(classSystemId);
    if (null == klass) {
        String info = INFO_CANNOT_FIND_OBJECT + " Class, using systemId " + classSystemId;
        logger.info(info);
        throw new NoarkEntityNotFoundException(info);
    }
    return klass;
}
Also used : Class(nikita.common.model.noark5.v4.Class) NoarkEntityNotFoundException(nikita.common.util.exceptions.NoarkEntityNotFoundException)

Example 12 with NoarkEntityNotFoundException

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

the class ClassificationSystemService method createClassAssociatedWithClassificationSystem.

@Override
public Class createClassAssociatedWithClassificationSystem(String classificationSystemSystemId, Class klass) {
    Class persistedClass = null;
    ClassificationSystem classificationSystem = classificationSystemRepository.findBySystemId(classificationSystemSystemId);
    if (classificationSystem == null) {
        String info = INFO_CANNOT_FIND_OBJECT + " ClassificationSystem, using classificationSystemSystemId " + classificationSystemSystemId;
        logger.info(info);
        throw new NoarkEntityNotFoundException(info);
    } else {
        klass.setReferenceClassificationSystem(classificationSystem);
        persistedClass = classService.save(klass);
    }
    return persistedClass;
}
Also used : ClassificationSystem(nikita.common.model.noark5.v4.ClassificationSystem) Class(nikita.common.model.noark5.v4.Class) NoarkEntityNotFoundException(nikita.common.util.exceptions.NoarkEntityNotFoundException)

Example 13 with NoarkEntityNotFoundException

use of nikita.common.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 systemId of the file object you are looking for
 * @return the newly found file object or null if it does not exist
 */
private File getFileOrThrow(@NotNull String fileSystemId) {
    File file = fileRepository.findBySystemId(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.common.util.exceptions.NoarkEntityNotFoundException) File(nikita.common.model.noark5.v4.File)

Example 14 with NoarkEntityNotFoundException

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

the class FileService method createRecordAssociatedWithFile.

@Override
public Record createRecordAssociatedWithFile(String fileSystemId, Record record) {
    Record persistedRecord;
    File file = fileRepository.findBySystemId(fileSystemId);
    if (file == null) {
        String info = INFO_CANNOT_FIND_OBJECT + " File, using fileSystemId " + fileSystemId;
        logger.info(info);
        throw new NoarkEntityNotFoundException(info);
    } else {
        record.setReferenceFile(file);
        persistedRecord = recordService.save(record);
    }
    return persistedRecord;
}
Also used : BasicRecord(nikita.common.model.noark5.v4.BasicRecord) Record(nikita.common.model.noark5.v4.Record) NoarkEntityNotFoundException(nikita.common.util.exceptions.NoarkEntityNotFoundException) File(nikita.common.model.noark5.v4.File)

Example 15 with NoarkEntityNotFoundException

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

the class FileService method createBasicRecordAssociatedWithFile.

@Override
public BasicRecord createBasicRecordAssociatedWithFile(String fileSystemId, BasicRecord basicRecord) {
    BasicRecord persistedBasicRecord;
    File file = fileRepository.findBySystemId(fileSystemId);
    if (file == null) {
        String info = INFO_CANNOT_FIND_OBJECT + " File, using fileSystemId " + fileSystemId;
        logger.info(info);
        throw new NoarkEntityNotFoundException(info);
    } else {
        basicRecord.setReferenceFile(file);
        persistedBasicRecord = (BasicRecord) recordService.save(basicRecord);
    }
    return persistedBasicRecord;
}
Also used : BasicRecord(nikita.common.model.noark5.v4.BasicRecord) NoarkEntityNotFoundException(nikita.common.util.exceptions.NoarkEntityNotFoundException) File(nikita.common.model.noark5.v4.File)

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