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;
}
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;
}
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;
}
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;
}
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);
}
Aggregations