diff --git a/Exareme-Docker/src/exareme/exareme-master/src/main/java/madgik/exareme/master/gateway/async/handler/HBP/Exceptions/RequestException.java b/Exareme-Docker/src/exareme/exareme-master/src/main/java/madgik/exareme/master/gateway/async/handler/HBP/Exceptions/BadRequestException.java similarity index 50% rename from Exareme-Docker/src/exareme/exareme-master/src/main/java/madgik/exareme/master/gateway/async/handler/HBP/Exceptions/RequestException.java rename to Exareme-Docker/src/exareme/exareme-master/src/main/java/madgik/exareme/master/gateway/async/handler/HBP/Exceptions/BadRequestException.java index cecd101d1..fc6feec31 100644 --- a/Exareme-Docker/src/exareme/exareme-master/src/main/java/madgik/exareme/master/gateway/async/handler/HBP/Exceptions/RequestException.java +++ b/Exareme-Docker/src/exareme/exareme-master/src/main/java/madgik/exareme/master/gateway/async/handler/HBP/Exceptions/BadRequestException.java @@ -1,7 +1,7 @@ package madgik.exareme.master.gateway.async.handler.HBP.Exceptions; -public class RequestException extends Exception { - public RequestException(String algorithmName, String message) { +public class BadRequestException extends Exception { + public BadRequestException(String algorithmName, String message) { super(message + " Algorithm: " + algorithmName); } } \ No newline at end of file diff --git a/Exareme-Docker/src/exareme/exareme-master/src/main/java/madgik/exareme/master/gateway/async/handler/HBP/HBPQueryHandler.java b/Exareme-Docker/src/exareme/exareme-master/src/main/java/madgik/exareme/master/gateway/async/handler/HBP/HBPQueryHandler.java index 8778a1368..1929d6d18 100644 --- a/Exareme-Docker/src/exareme/exareme-master/src/main/java/madgik/exareme/master/gateway/async/handler/HBP/HBPQueryHandler.java +++ b/Exareme-Docker/src/exareme/exareme-master/src/main/java/madgik/exareme/master/gateway/async/handler/HBP/HBPQueryHandler.java @@ -13,8 +13,8 @@ import madgik.exareme.master.engine.iterations.handler.NIterativeAlgorithmResultEntity; import madgik.exareme.master.engine.iterations.state.IterativeAlgorithmState; import madgik.exareme.master.gateway.ExaremeGatewayUtils; +import madgik.exareme.master.gateway.async.handler.HBP.Exceptions.BadRequestException; import madgik.exareme.master.gateway.async.handler.HBP.Exceptions.BadUserInputException; -import madgik.exareme.master.gateway.async.handler.HBP.Exceptions.RequestException; import madgik.exareme.master.gateway.async.handler.entity.NQueryResultEntity; import madgik.exareme.master.queryProcessor.HBP.AlgorithmProperties; import madgik.exareme.master.queryProcessor.HBP.Algorithms; @@ -101,7 +101,7 @@ private void handleHBPAlgorithmExecution(HttpRequest request, HttpResponse respo String algorithmName = getAlgorithmName(request); AlgorithmProperties algorithmProperties = Algorithms.getInstance().getAlgorithmProperties(algorithmName); if (algorithmProperties == null) - throw new RequestException(algorithmName, "The algorithm '" + algorithmName + "' does not exist."); + throw new BadRequestException(algorithmName, "The algorithm '" + algorithmName + "' does not exist."); String algorithmKey = algorithmName + "_" + System.currentTimeMillis(); @@ -168,13 +168,7 @@ private void handleHBPAlgorithmExecution(HttpRequest request, HttpResponse respo response.setStatusCode(HttpStatus.SC_OK); response.setEntity(entity); } - } catch (BadUserInputException e) { - log.error(e.getMessage()); - String errorType = HBPQueryHelper.ErrorResponse.ErrorResponseTypes.user_error; - response.setStatusCode(HttpStatus.SC_OK); - response.setEntity(createErrorResponseEntity(e.getMessage(), errorType)); - - } catch (RequestException e) { + } catch (BadUserInputException | BadRequestException e) { log.error(e.getMessage()); String errorType = HBPQueryHelper.ErrorResponse.ErrorResponseTypes.user_error; response.setStatusCode(HttpStatus.SC_BAD_REQUEST); diff --git a/Exareme-Docker/src/exareme/exareme-master/src/main/java/madgik/exareme/master/gateway/control/handler/HttpAsyncCheckWorker.java b/Exareme-Docker/src/exareme/exareme-master/src/main/java/madgik/exareme/master/gateway/control/handler/HttpAsyncCheckWorker.java index b8a0e9bae..70951201d 100644 --- a/Exareme-Docker/src/exareme/exareme-master/src/main/java/madgik/exareme/master/gateway/control/handler/HttpAsyncCheckWorker.java +++ b/Exareme-Docker/src/exareme/exareme-master/src/main/java/madgik/exareme/master/gateway/control/handler/HttpAsyncCheckWorker.java @@ -9,7 +9,7 @@ import madgik.exareme.master.engine.AdpDBManager; import madgik.exareme.master.engine.AdpDBManagerLocator; import madgik.exareme.master.gateway.ExaremeGatewayUtils; -import madgik.exareme.master.gateway.async.handler.HBP.Exceptions.RequestException; +import madgik.exareme.master.gateway.async.handler.HBP.Exceptions.BadRequestException; import madgik.exareme.master.gateway.async.handler.HBP.Exceptions.BadUserInputException; import madgik.exareme.master.gateway.async.handler.entity.NQueryResultEntity; import madgik.exareme.master.queryProcessor.HBP.AlgorithmProperties; @@ -55,7 +55,7 @@ public void handle( HttpResponse response = httpexchange.getResponse(); try { handleInternal(request, response, context); - } catch (AlgorithmException | CDEsMetadataException | ComposerException | BadUserInputException | RequestException e) { + } catch (AlgorithmException | CDEsMetadataException | ComposerException | BadUserInputException | BadRequestException e) { e.printStackTrace(); } httpexchange.submitResponse(new BasicAsyncResponseProducer(response)); @@ -65,7 +65,7 @@ private void handleInternal( final HttpRequest request, final HttpResponse response, final HttpContext context - ) throws HttpException, IOException, AlgorithmException, CDEsMetadataException, ComposerException, BadUserInputException, RequestException { + ) throws HttpException, IOException, AlgorithmException, CDEsMetadataException, ComposerException, BadUserInputException, BadRequestException { String method = request.getRequestLine().getMethod().toUpperCase(Locale.ENGLISH); if (!method.equals("GET") && !method.equals("HEAD") && !method.equals("POST")) { @@ -97,7 +97,7 @@ private void handleInternal( AlgorithmProperties algorithmProperties = Algorithms.getInstance().getAlgorithmProperties(algorithmName); if (algorithmProperties == null) - throw new RequestException(algorithmName, "The algorithm does not exist."); + throw new BadRequestException(algorithmName, "The algorithm does not exist."); algorithmProperties.mergeWithAlgorithmParameters(inputContent);