use of nikita.common.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.
the class VariantFormatService method getVariantFormatOrThrow.
/**
* 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 VariantFormat object back. If there
* is no VariantFormat object, a NoarkEntityNotFoundException exception
* is thrown
*
* @param systemId The systemId of the VariantFormat object to retrieve
* @return the VariantFormat object
*/
private VariantFormat getVariantFormatOrThrow(@NotNull String systemId) {
VariantFormat variantFormat = variantFormatRepository.findBySystemId(systemId);
if (variantFormat == null) {
String info = INFO_CANNOT_FIND_OBJECT + " VariantFormat, using " + "systemId " + systemId;
logger.error(info);
throw new NoarkEntityNotFoundException(info);
}
return variantFormat;
}
use of nikita.common.util.exceptions.NoarkEntityNotFoundException in project nikita-noark5-core by HiOA-ABI.
the class PrecedenceService method getPrecedenceOrThrow.
/**
* 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 Precedence back. If there is no valid
* Precedence, an exception is thrown
*
* @param precedenceSystemId
* @return
*/
protected Precedence getPrecedenceOrThrow(@NotNull String precedenceSystemId) {
Precedence precedence = precedenceRepository.findBySystemId(precedenceSystemId);
if (precedence == null) {
String info = INFO_CANNOT_FIND_OBJECT + " Precedence, using systemId " + precedenceSystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
}
return precedence;
}
use of nikita.common.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.findBySystemId(classSystemId);
if (klass == null) {
throw new NoarkEntityNotFoundException(classSystemId);
}
ClassHateoas classHateoas = new ClassHateoas(klass);
classHateoasHandler.addLinks(classHateoas, new Authorisation());
return ResponseEntity.status(HttpStatus.OK).eTag(klass.getVersion().toString()).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(classHateoas);
}
use of nikita.common.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.findBySystemId(classificationSystemId);
if (classificationSystem == null) {
throw new NoarkEntityNotFoundException(classificationSystemId);
}
ClassificationSystemHateoas classificationSystemHateoas = new ClassificationSystemHateoas(classificationSystem);
classificationSystemHateoasHandler.addLinks(classificationSystemHateoas, new Authorisation());
return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(classificationSystem.getVersion().toString()).body(classificationSystemHateoas);
}
use of nikita.common.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
@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.findBySystemId(systemID);
if (documentDescription == null) {
throw new NoarkEntityNotFoundException(systemID);
}
DocumentDescriptionHateoas documentDescriptionHateoas = new DocumentDescriptionHateoas(documentDescription);
documentDescriptionHateoasHandler.addLinks(documentDescriptionHateoas, new Authorisation());
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(documentDescription.getVersion().toString()).body(documentDescriptionHateoas);
}
Aggregations