- } catch (Exception e) {
- return ErrorResponse.create(e, HttpStatus.NOT_FOUND);
+ } catch (ServiceException e) {
+ return ErrorResponse.create(e, e.getHttpStatus());
+ }
+ }
+
+ private void validateUri(String url) throws ServiceException {
+ if (url != null && !url.isEmpty()) {
+ try {
+ URI uri = new URI(url);
+ if (!uri.isAbsolute()) {
+ throw new ServiceException("URI: " + url + " is not absolute", HttpStatus.BAD_REQUEST);
+ }
+ } catch (URISyntaxException e) {
+ throw new ServiceException(e.getMessage(), HttpStatus.BAD_REQUEST);
+ }
+ } else {
+ throw new ServiceException("Missing required URL", HttpStatus.BAD_REQUEST);