private List<Resource> getResources(String propertyName, List<String> locations, boolean validate) { List<Resource> resources = new ArrayList<Resource>(); for (String location : locations) { for (Resource resource : doGetResources(location)) { if (resource.exists()) { resources.add(resource); } else if (validate) { throw new ResourceNotFoundException(propertyName, resource); } } } return resources; }
@ResponseStatus(HttpStatus.NOT_FOUND) @ExceptionHandler(ResourceNotFoundException.class) public @ResponseBody ErrorInfo handlerResourceNotFoundException(ResourceNotFoundException ex) { return new ErrorInfo(String.valueOf(HttpStatus.NOT_FOUND.value()), ex.getMessage()); }
@ResponseStatus(HttpStatus.NOT_FOUND) @ExceptionHandler(ResourceNotFoundException.class) public String handleResourceNotFoundException() { log.error("Resource not found"); return "error"; }