Search in sources :

Example 51 with NoarkEntityNotFoundException

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

the class CasePartyRoleService method getCasePartyRoleOrThrow.

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

Example 52 with NoarkEntityNotFoundException

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

the class CaseStatusService method getCaseStatusOrThrow.

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

Example 53 with NoarkEntityNotFoundException

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

the class ClassificationTypeService method getClassificationTypeOrThrow.

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

Example 54 with NoarkEntityNotFoundException

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

the class CommentTypeService method getCommentTypeOrThrow.

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

Example 55 with NoarkEntityNotFoundException

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

the class FileHateoasController method findAllRecordsAssociatedWithFile.

// API - All GET Requests (CRUD - READ)
// Retrieve all Records associated with File identified by systemId
// GET [contextPath][api]/arkivstruktur/mappe/{systemId}/registrering
// REL http://rel.kxml.no/noark5/v4/api/arkivstruktur/registrering/
@ApiOperation(value = "Retrieve all Record associated with a File identified by systemId", response = RecordHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Record returned", response = RecordHateoas.class), @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER), @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@RequestMapping(value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + REGISTRATION, method = RequestMethod.GET)
public ResponseEntity<RecordHateoas> findAllRecordsAssociatedWithFile(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the file to retrieve associated Record", required = true) @PathVariable("systemID") final String systemID) {
    File file = fileService.findBySystemId(systemID);
    if (file == null) {
        throw new NoarkEntityNotFoundException("Could not find File object with systemID " + systemID);
    }
    RecordHateoas recordHateoas = new RecordHateoas((List<INikitaEntity>) (List) file.getReferenceRecord());
    recordHateoasHandler.addLinks(recordHateoas, new Authorisation());
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(recordHateoas);
}
Also used : INikitaEntity(nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity) Authorisation(nikita.webapp.security.Authorisation) NoarkEntityNotFoundException(nikita.common.util.exceptions.NoarkEntityNotFoundException) List(java.util.List) Counted(com.codahale.metrics.annotation.Counted) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

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