use of nikita.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.
the class SeriesHateoasController method findAllFileAssociatedWithSeries.
// Retrieve all Files associated with a Series (paginated)
// GET [contextPath][api]/arkivstruktur/arkivdel/{systemId}/mappe/
// GET [contextPath][api]/arkivstruktur/arkivdel/{systemId}/mappe/?top=5&skip=1
@ApiOperation(value = "Retrieves a list of Files associated with a Series", notes = "The field skip" + "tells how many File rows of the result set to ignore (starting at 0), while top tells how many rows" + " after skip to return. Note if the value of top is greater than system value " + " nikita-noark5-core.pagination.maxPageSize, then nikita-noark5-core.pagination.maxPageSize is used. ", response = FileHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "File list found", response = FileHateoas.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
@Timed
@RequestMapping(value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + FILE, method = RequestMethod.GET)
public ResponseEntity<FileHateoas> findAllFileAssociatedWithSeries(HttpServletRequest request, @RequestParam(name = "top", required = false) Integer top, @RequestParam(name = "skip", required = false) Integer skip, @ApiParam(name = "systemID", value = "systemID of the series to retrieve", required = true) @PathVariable("systemID") final String systemID) {
Series series = seriesService.findBySystemIdOrderBySystemId(systemID);
if (series == null) {
throw new NoarkEntityNotFoundException("Could not find series object with systemID " + systemID);
}
FileHateoas fileHateoas = new FileHateoas(new ArrayList<>(series.getReferenceFile()));
fileHateoasHandler.addLinks(fileHateoas, request, new Authorisation());
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(fileHateoas);
}
use of nikita.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.
the class CaseFileHateoasController method findOneCaseFilebySystemId.
// Retrieve a single casefile identified by systemId
// GET [contextPath][api]/casehandling/saksmappe/{systemID}
@ApiOperation(value = "Retrieves a single CaseFile entity given a systemId", response = CaseFile.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CaseFile returned", response = CaseFile.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
@Timed
@RequestMapping(value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.GET)
public ResponseEntity<CaseFileHateoas> findOneCaseFilebySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the caseFile to retrieve", required = true) @PathVariable("systemID") final String caseFileSystemId) {
CaseFile caseFile = caseFileService.findBySystemIdOrderBySystemId(caseFileSystemId);
if (caseFile == null) {
throw new NoarkEntityNotFoundException(caseFileSystemId);
}
CaseFileHateoas caseFileHateoas = new CaseFileHateoas(caseFile);
caseFileHateoasHandler.addLinks(caseFileHateoas, request, new Authorisation());
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(caseFile.getVersion().toString()).body(caseFileHateoas);
}
use of nikita.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.
the class ClassificationSystemService method getClassificationSystemOrThrow.
// All HELPER operations
/**
* 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 ClassificationSystem back. If there is no valid
* ClassificationSystem, an exception is thrown
*
* @param classificationSystemSystemId
* @return
*/
protected ClassificationSystem getClassificationSystemOrThrow(@NotNull String classificationSystemSystemId) {
ClassificationSystem classificationSystem = classificationSystemRepository.findBySystemIdOrderBySystemId(classificationSystemSystemId);
if (classificationSystem == null) {
String info = INFO_CANNOT_FIND_OBJECT + " ClassificationSystem, using systemId " + classificationSystemSystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
}
return classificationSystem;
}
use of nikita.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.
the class ClassificationSystemService method createClassAssociatedWithClassificationSystem.
@Override
public Class createClassAssociatedWithClassificationSystem(String classificationSystemSystemId, Class klass) {
Class persistedClass = null;
ClassificationSystem classificationSystem = classificationSystemRepository.findBySystemIdOrderBySystemId(classificationSystemSystemId);
if (classificationSystem == null) {
String info = INFO_CANNOT_FIND_OBJECT + " ClassificationSystem, using classificationSystemSystemId " + classificationSystemSystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
} else {
klass.setReferenceClassificationSystem(classificationSystem);
persistedClass = classService.save(klass);
}
return persistedClass;
}
use of nikita.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.
the class DocumentDescriptionService method createDocumentObjectAssociatedWithDocumentDescription.
// All CREATE operations
@Override
public DocumentObject createDocumentObjectAssociatedWithDocumentDescription(String documentDescriptionSystemId, DocumentObject documentObject) {
DocumentObject persistedDocumentObject = null;
DocumentDescription documentDescription = documentDescriptionRepository.findBySystemIdOrderBySystemId(documentDescriptionSystemId);
if (documentDescription == null) {
String info = INFO_CANNOT_FIND_OBJECT + " DocumentDescription, using documentDescriptionSystemId " + documentDescriptionSystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
} else {
documentObject.setReferenceDocumentDescription(documentDescription);
Set<DocumentObject> documentObjects = documentDescription.getReferenceDocumentObject();
documentObjects.add(documentObject);
persistedDocumentObject = documentObjectService.save(documentObject);
}
return persistedDocumentObject;
}
Aggregations