asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mb...@apache.org
Subject asterixdb git commit: Add sendError() to AbstractServlet
Date Sat, 10 Jun 2017 16:32:57 GMT
Repository: asterixdb
Updated Branches:
  refs/heads/master 3c07fe545 -> 456cb9fd0


Add sendError() to AbstractServlet

Change-Id: I24a1d5a6d06f37a9a02056b829541ce96a38b197
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1827
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
BAD: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <tillw@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/456cb9fd
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/456cb9fd
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/456cb9fd

Branch: refs/heads/master
Commit: 456cb9fd06dd7659ec1f1fb68fdeb02d564051bf
Parents: 3c07fe5
Author: Michael Blow <mblow@apache.org>
Authored: Sat Jun 10 00:23:37 2017 -0400
Committer: Michael Blow <mblow@apache.org>
Committed: Sat Jun 10 09:32:42 2017 -0700

----------------------------------------------------------------------
 .../hyracks/http/server/AbstractServlet.java    | 22 +++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/456cb9fd/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/AbstractServlet.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/AbstractServlet.java
b/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/AbstractServlet.java
index 1030686..3c41165 100644
--- a/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/AbstractServlet.java
+++ b/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/AbstractServlet.java
@@ -91,10 +91,25 @@ public abstract class AbstractServlet implements IServlet {
         }
     }
 
-    protected void notAllowed(HttpMethod method, IServletResponse response) throws IOException
{
-        response.setStatus(HttpResponseStatus.METHOD_NOT_ALLOWED);
+    protected void sendError(IServletResponse response, HttpResponseStatus status, String
message)
+            throws IOException {
+        response.setStatus(status);
         HttpUtil.setContentType(response, HttpUtil.ContentType.TEXT_PLAIN, HttpUtil.Encoding.UTF8);
-        response.writer().write("Method " + method + " not allowed for the requested resource.\n");
+        if (message != null) {
+            response.writer().println(message);
+        }
+        if (LOGGER.isLoggable(Level.INFO)) {
+            LOGGER.info("sendError: status=" + status + ", message=" + message);
+        }
+    }
+
+    protected void sendError(IServletResponse response, HttpResponseStatus status) throws
IOException {
+        sendError(response, status, null);
+    }
+
+    protected void notAllowed(HttpMethod method, IServletResponse response) throws IOException
{
+        sendError(response, HttpResponseStatus.METHOD_NOT_ALLOWED,
+                "Method " + method + " not allowed for the requested resource.");
     }
 
     @SuppressWarnings("squid:S1172")
@@ -168,4 +183,5 @@ public abstract class AbstractServlet implements IServlet {
     public String toString() {
         return this.getClass().getSimpleName() + Arrays.toString(paths);
     }
+
 }


Mime
View raw message