Search in sources :

Example 6 with NoarkEntityNotFoundException

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

the class PrecedenceStatusService method getPrecedenceStatusOrThrow.

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

Example 7 with NoarkEntityNotFoundException

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

the class RegistryEntryTypeService method getRegistryEntryTypeOrThrow.

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

Example 8 with NoarkEntityNotFoundException

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

the class SignOffMethodService method getSignOffMethodOrThrow.

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

Example 9 with NoarkEntityNotFoundException

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

the class CorrespondencePartService method getCorrespondencePartOrThrow.

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

Example 10 with NoarkEntityNotFoundException

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

the class ClassService method createClassAssociatedWithClass.

public Class createClassAssociatedWithClass(String classSystemId, Class klass) {
    Class persistedClass = null;
    Class parentKlass = classRepository.findBySystemId(classSystemId);
    if (parentKlass == null) {
        String info = INFO_CANNOT_FIND_OBJECT + " Class, using classSystemId " + classSystemId;
        logger.info(info);
        throw new NoarkEntityNotFoundException(info);
    } else if (parentKlass.getFinalisedDate() != null) {
        String info = INFO_CANNOT_ASSOCIATE_WITH_CLOSED_OBJECT + ". Class with classSystemId " + classSystemId + "has been finalised. Cannot associate a new class object with a finalised class object";
        logger.info(info);
        throw new NoarkEntityEditWhenClosedException(info);
    } else {
        klass.setReferenceParentClass(parentKlass);
        persistedClass = this.save(klass);
    }
    return persistedClass;
}
Also used : Class(nikita.common.model.noark5.v4.Class) NoarkEntityNotFoundException(nikita.common.util.exceptions.NoarkEntityNotFoundException) NoarkEntityEditWhenClosedException(nikita.common.util.exceptions.NoarkEntityEditWhenClosedException)

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