use of nikita.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.
the class SeriesImportService method createFileAssociatedWithSeries.
@Override
public File createFileAssociatedWithSeries(String seriesSystemId, File file) {
File persistedFile = null;
Series series = seriesRepository.findBySystemIdOrderBySystemId(seriesSystemId);
if (series == null) {
String info = INFO_CANNOT_FIND_OBJECT + " Series, using seriesSystemId " + seriesSystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
} else if (series.getSeriesStatus() != null && series.getSeriesStatus().equals(STATUS_CLOSED)) {
String info = INFO_CANNOT_ASSOCIATE_WITH_CLOSED_OBJECT + ". Series with seriesSystemId " + seriesSystemId + "has status " + STATUS_CLOSED;
logger.info(info);
throw new NoarkEntityEditWhenClosedException(info);
} else {
file.setReferenceSeries(series);
persistedFile = fileImportService.createFile(file);
}
return persistedFile;
}
use of nikita.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.findBySystemIdOrderBySystemId(correspondencePartSystemId);
if (correspondencePart == null) {
String info = INFO_CANNOT_FIND_OBJECT + " CorrespondencePart, using systemId " + correspondencePartSystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
}
return correspondencePart;
}
use of nikita.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.
the class ClassHateoasController method findOne.
// API - All GET Requests (CRUD - READ)
@RequestMapping(value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.GET)
public ResponseEntity<ClassHateoas> findOne(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemId", value = "systemId of class to retrieve.", required = true) @PathVariable("systemID") final String classSystemId) {
Class klass = classService.findBySystemIdOrderBySystemId(classSystemId);
if (klass == null) {
throw new NoarkEntityNotFoundException(classSystemId);
}
ClassHateoas classHateoas = new ClassHateoas(klass);
classHateoasHandler.addLinks(classHateoas, request, new Authorisation());
return ResponseEntity.status(HttpStatus.OK).eTag(klass.getVersion().toString()).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(classHateoas);
}
use of nikita.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.
the class ClassificationSystemHateoasController method findOne.
// API - All GET Requests (CRUD - READ)
@RequestMapping(value = CLASSIFICATION_SYSTEM + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.GET)
public ResponseEntity<ClassificationSystemHateoas> findOne(HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemId", value = "systemId of classificationSystem to retrieve.", required = true) @PathVariable("systemID") final String classificationSystemId) {
ClassificationSystem classificationSystem = classificationSystemService.findBySystemIdOrderBySystemId(classificationSystemId);
if (classificationSystem == null) {
throw new NoarkEntityNotFoundException(classificationSystemId);
}
ClassificationSystemHateoas classificationSystemHateoas = new ClassificationSystemHateoas(classificationSystem);
classificationSystemHateoasHandler.addLinks(classificationSystemHateoas, request, new Authorisation());
return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(classificationSystem.getVersion().toString()).body(classificationSystemHateoas);
}
use of nikita.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.
the class DocumentDescriptionHateoasController method findOneDocumentDescriptionBySystemId.
// API - All GET Requests (CRUD - READ)
@ApiOperation(value = "Retrieves a single DocumentDescription entity given a systemId", response = DocumentDescription.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "DocumentDescription returned", response = DocumentDescription.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<DocumentDescriptionHateoas> findOneDocumentDescriptionBySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the documentDescription to retrieve", required = true) @PathVariable("systemID") final String systemID) {
DocumentDescription documentDescription = documentDescriptionService.findBySystemIdOrderBySystemId(systemID);
if (documentDescription == null) {
throw new NoarkEntityNotFoundException(systemID);
}
DocumentDescriptionHateoas documentDescriptionHateoas = new DocumentDescriptionHateoas(documentDescription);
documentDescriptionHateoasHandler.addLinks(documentDescriptionHateoas, request, new Authorisation());
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(documentDescription.getVersion().toString()).body(documentDescriptionHateoas);
}
Aggregations