[Mulgara-svn] r1936 - trunk/src/jar/querylang/java/org/mulgara/protocol/http
pag at mulgara.org
pag at mulgara.org
Fri Apr 16 16:28:59 UTC 2010
Author: pag
Date: 2010-04-16 09:28:57 -0700 (Fri, 16 Apr 2010)
New Revision: 1936
Modified:
trunk/src/jar/querylang/java/org/mulgara/protocol/http/ProtocolServlet.java
Log:
Added a hook for HTTP PATCH requests
Modified: trunk/src/jar/querylang/java/org/mulgara/protocol/http/ProtocolServlet.java
===================================================================
--- trunk/src/jar/querylang/java/org/mulgara/protocol/http/ProtocolServlet.java 2010-04-12 15:13:12 UTC (rev 1935)
+++ trunk/src/jar/querylang/java/org/mulgara/protocol/http/ProtocolServlet.java 2010-04-16 16:28:57 UTC (rev 1936)
@@ -95,6 +95,11 @@
*/
protected interface ObjectStreamConstructor extends StreamConstructor<Object> { }
+ /**
+ * Identifies the HTTP PATCH method. Need to explicitly handle this as it is not yet in the API.
+ */
+ private static final String METHOD_PATCH = "PATCH";
+
/** The parameter identifying the query. */
private static final String QUERY_ARG = "query";
@@ -182,6 +187,11 @@
*/
abstract protected void initializeBuilders();
+ protected void service(HttpServletRequest req, HttpServletResponse resp) throws javax.servlet.ServletException, IOException {
+ if (METHOD_PATCH.equals(req.getMethod())) doPatch(req, resp);
+ else super.service(req, resp);
+ }
+
/**
* Respond to a request for the servlet.
* @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
@@ -246,6 +256,23 @@
}
}
+ /**
+ * Responds to an HTTP PATCH request.
+ * This is a default implementation for the moment and will be overridden or replaced.
+ * @param req an {@link javax.servlet.http.HttpServletRequest} object that contains the request the client has made of the servlet
+ * @param resp an {@link javax.servlet.http.HttpServletResponse} object that contains the response the servlet sends to the client
+ * @throws ServletException if the request for a PATCH could not be handled.
+ * @throws IOException If an I/O error occurs while handling the request.
+ */
+ protected void doPatch(HttpServletRequest req, HttpServletResponse resp) throws javax.servlet.ServletException, IOException {
+ String protocol = req.getProtocol();
+ String msg = "PATCH Method not supported";
+ if (protocol.endsWith("1.1")) {
+ resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, msg);
+ } else {
+ resp.sendError(HttpServletResponse.SC_BAD_REQUEST, msg);
+ }
+ }
/**
* Provide a description for the servlet.
More information about the Mulgara-svn
mailing list