Search in sources :

Example 31 with NoarkEntityNotFoundException

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

the class ElectronicSignatureSecurityLevelService method getElectronicSignatureSecurityLevelOrThrow.

/**
 * 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 ElectronicSignatureSecurityLevel
 * object back. If there is no ElectronicSignatureSecurityLevel object,
 * a NoarkEntityNotFoundException exception is thrown
 *
 * @param systemId The systemId of the ElectronicSignatureSecurityLevel
 *                 object to retrieve
 * @return the ElectronicSignatureSecurityLevel object
 */
private ElectronicSignatureSecurityLevel getElectronicSignatureSecurityLevelOrThrow(@NotNull String systemId) {
    ElectronicSignatureSecurityLevel electronicSignatureSecurityLevel = electronicSignatureSecurityLevelRepository.findBySystemId(systemId);
    if (electronicSignatureSecurityLevel == null) {
        String info = INFO_CANNOT_FIND_OBJECT + " ElectronicSignatureSecurityLevel, using systemId " + systemId;
        logger.error(info);
        throw new NoarkEntityNotFoundException(info);
    }
    return electronicSignatureSecurityLevel;
}
Also used : ElectronicSignatureSecurityLevel(nikita.common.model.noark5.v4.metadata.ElectronicSignatureSecurityLevel) NoarkEntityNotFoundException(nikita.common.util.exceptions.NoarkEntityNotFoundException)

Example 32 with NoarkEntityNotFoundException

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

the class ElectronicSignatureVerifiedService method getElectronicSignatureVerifiedOrThrow.

/**
 * 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 ElectronicSignatureVerified
 * object back. If there is no ElectronicSignatureVerified object,
 * a NoarkEntityNotFoundException exception is thrown
 *
 * @param systemId The systemId of the ElectronicSignatureVerified
 *                 object to retrieve
 * @return the ElectronicSignatureVerified object
 */
private ElectronicSignatureVerified getElectronicSignatureVerifiedOrThrow(@NotNull String systemId) {
    ElectronicSignatureVerified electronicSignatureVerified = electronicSignatureVerifiedRepository.findBySystemId(systemId);
    if (electronicSignatureVerified == null) {
        String info = INFO_CANNOT_FIND_OBJECT + " ElectronicSignatureVerified, using systemId " + systemId;
        logger.error(info);
        throw new NoarkEntityNotFoundException(info);
    }
    return electronicSignatureVerified;
}
Also used : ElectronicSignatureVerified(nikita.common.model.noark5.v4.metadata.ElectronicSignatureVerified) NoarkEntityNotFoundException(nikita.common.util.exceptions.NoarkEntityNotFoundException)

Example 33 with NoarkEntityNotFoundException

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

the class FormatService method getFormatOrThrow.

/**
 * 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 Format object back. If there is no
 * Format object, a NoarkEntityNotFoundException exception is thrown
 *
 * @param systemId The systemId of the Format object to retrieve
 * @return the Format object
 */
private Format getFormatOrThrow(@NotNull String systemId) {
    Format format = formatRepository.findBySystemId(systemId);
    if (format == null) {
        String info = INFO_CANNOT_FIND_OBJECT + " Format, using systemId " + systemId;
        logger.error(info);
        throw new NoarkEntityNotFoundException(info);
    }
    return format;
}
Also used : Format(nikita.common.model.noark5.v4.metadata.Format) NoarkEntityNotFoundException(nikita.common.util.exceptions.NoarkEntityNotFoundException)

Example 34 with NoarkEntityNotFoundException

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

the class PostalCodeService method getPostalCodeOrThrow.

/**
 * 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 PostalCode object back. If there
 * is no PostalCode object, a NoarkEntityNotFoundException exception
 * is thrown
 *
 * @param systemId The systemId of the PostalCode object to retrieve
 * @return the PostalCode object
 */
private PostalCode getPostalCodeOrThrow(@NotNull String systemId) {
    PostalCode postalCode = postalCodeRepository.findBySystemId(systemId);
    if (postalCode == null) {
        String info = INFO_CANNOT_FIND_OBJECT + " PostalCode, using " + "systemId " + systemId;
        logger.error(info);
        throw new NoarkEntityNotFoundException(info);
    }
    return postalCode;
}
Also used : PostalCode(nikita.common.model.noark5.v4.metadata.PostalCode) NoarkEntityNotFoundException(nikita.common.util.exceptions.NoarkEntityNotFoundException)

Example 35 with NoarkEntityNotFoundException

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

the class RegistryEntryStatusService method getRegistryEntryStatusOrThrow.

/**
 * 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 RegistryEntryStatus object back. If there
 * is no RegistryEntryStatus object, a NoarkEntityNotFoundException exception
 * is thrown
 *
 * @param systemId The systemId of the RegistryEntryStatus object to retrieve
 * @return the RegistryEntryStatus object
 */
private RegistryEntryStatus getRegistryEntryStatusOrThrow(@NotNull String systemId) {
    RegistryEntryStatus RegistryEntryStatus = RegistryEntryStatusRepository.findBySystemId(systemId);
    if (RegistryEntryStatus == null) {
        String info = INFO_CANNOT_FIND_OBJECT + " RegistryEntryStatus, using " + "systemId " + systemId;
        logger.error(info);
        throw new NoarkEntityNotFoundException(info);
    }
    return RegistryEntryStatus;
}
Also used : RegistryEntryStatus(nikita.common.model.noark5.v4.metadata.RegistryEntryStatus) 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