Search in sources :

Example 1 with NoarkEntityNotFoundException

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

the class CorrespondencePartTypeService method getCorrespondencePartTypeOrThrow.

/**
 * 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 CorrespondencePartType back. If there is no valid
 * CorrespondencePartType, an exception is thrown
 *
 * @param correspondencePartTypeCode
 * @return
 */
protected CorrespondencePartType getCorrespondencePartTypeOrThrow(@NotNull String correspondencePartTypeCode) {
    CorrespondencePartType correspondencePartType = correspondencePartTypeRepository.findByCode(correspondencePartTypeCode);
    if (correspondencePartType == null) {
        String info = INFO_CANNOT_FIND_OBJECT + " correspondencePartType, using kode " + correspondencePartTypeCode;
        logger.info(info);
        throw new NoarkEntityNotFoundException(info);
    }
    return correspondencePartType;
}
Also used : CorrespondencePartType(nikita.common.model.noark5.v4.metadata.CorrespondencePartType) NoarkEntityNotFoundException(nikita.common.util.exceptions.NoarkEntityNotFoundException)

Example 2 with NoarkEntityNotFoundException

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

the class CountryService method getCountryOrThrow.

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

Example 3 with NoarkEntityNotFoundException

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

the class DocumentTypeService method getDocumentTypeOrThrow.

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

Example 4 with NoarkEntityNotFoundException

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

the class FileTypeService method getFileTypeOrThrow.

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

Example 5 with NoarkEntityNotFoundException

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

the class FlowStatusService method getFlowStatusOrThrow.

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

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