Search in sources :

Example 36 with NoarkEntityNotFoundException

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

the class RegistryEntryService method getRegistryEntryOrThrow.

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

Example 37 with NoarkEntityNotFoundException

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

the class SeriesService method createFileAssociatedWithSeries.

@Override
public File createFileAssociatedWithSeries(String seriesSystemId, File file) {
    File persistedFile = null;
    Series series = seriesRepository.findBySystemIdOrderBySystemId(seriesSystemId);
    if (series == null) {
        String info = INFO_CANNOT_FIND_OBJECT + " Series, using seriesSystemId " + seriesSystemId;
        logger.info(info);
        throw new NoarkEntityNotFoundException(info);
    } else if (series.getSeriesStatus() != null && series.getSeriesStatus().equals(STATUS_CLOSED)) {
        String info = INFO_CANNOT_ASSOCIATE_WITH_CLOSED_OBJECT + ". Series with seriesSystemId " + seriesSystemId + "has status " + STATUS_CLOSED;
        logger.info(info);
        throw new NoarkEntityEditWhenClosedException(info);
    } else {
        file.setReferenceSeries(series);
        persistedFile = fileService.createFile(file);
    }
    return persistedFile;
}
Also used : Series(nikita.model.noark5.v4.Series) NoarkEntityNotFoundException(nikita.util.exceptions.NoarkEntityNotFoundException) File(nikita.model.noark5.v4.File) CaseFile(nikita.model.noark5.v4.casehandling.CaseFile) NoarkEntityEditWhenClosedException(nikita.util.exceptions.NoarkEntityEditWhenClosedException)

Example 38 with NoarkEntityNotFoundException

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

the class SeriesService method getSeriesOrThrow.

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

Example 39 with NoarkEntityNotFoundException

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

the class FileImportService method createRecordAssociatedWithFile.

@Override
public Record createRecordAssociatedWithFile(String fileSystemId, Record record) {
    Record persistedRecord = null;
    File file = fileRepository.findBySystemIdOrderBySystemId(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 = recordImportService.save(record);
    }
    return persistedRecord;
}
Also used : Record(nikita.model.noark5.v4.Record) BasicRecord(nikita.model.noark5.v4.BasicRecord) NoarkEntityNotFoundException(nikita.util.exceptions.NoarkEntityNotFoundException) File(nikita.model.noark5.v4.File)

Example 40 with NoarkEntityNotFoundException

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

the class FileImportService method createBasicRecordAssociatedWithFile.

@Override
public BasicRecord createBasicRecordAssociatedWithFile(String fileSystemId, BasicRecord basicRecord) {
    BasicRecord persistedBasicRecord = null;
    File file = fileRepository.findBySystemIdOrderBySystemId(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) recordImportService.save(basicRecord);
    }
    return persistedBasicRecord;
}
Also used : BasicRecord(nikita.model.noark5.v4.BasicRecord) NoarkEntityNotFoundException(nikita.util.exceptions.NoarkEntityNotFoundException) File(nikita.model.noark5.v4.File)

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