Revision: 1878
Author: [email protected]
Date: Sun Apr 18 05:24:22 2010
Log: Log post requests to track form submissions (Issue 285)
http://code.google.com/p/simal/source/detail?r=1878
Modified:
/trunk/uk.ac.osswatch.simal.rest/src/main/java/uk/ac/osswatch/simal/rest/RESTServlet.java
=======================================
---
/trunk/uk.ac.osswatch.simal.rest/src/main/java/uk/ac/osswatch/simal/rest/RESTServlet.java
Sun Jun 21 15:03:10 2009
+++
/trunk/uk.ac.osswatch.simal.rest/src/main/java/uk/ac/osswatch/simal/rest/RESTServlet.java
Sun Apr 18 05:24:22 2010
@@ -19,6 +19,7 @@
import java.io.IOException;
import java.io.PrintWriter;
+import java.util.Enumeration;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
@@ -100,6 +101,7 @@
try {
cmd = RESTCommand.createCommand(req.getPathInfo(),
req.getParameterMap());
} catch (SimalAPIException e) {
+ logger.warn("Error craeting Simal REST command: " + e.getMessage());
throw new ServletException("Unable to create Simal REST command", e);
}
@@ -140,9 +142,33 @@
msg.append(req.getRemoteHost());
msg.append(" (");
msg.append(req.getRemoteUser());
- msg.append(')');
+ msg.append(")\n");
+ msg.append("Contents (length ");
+ msg.append(req.getContentLength());
+ msg.append("):\n");
+ msg.append(getRequestParameters(req));
logger.trace(msg.toString());
}
+
+ /**
+ * Get all parameter names and values from the request.
+ * @return String representation of parameters
+ */
+ @SuppressWarnings("unchecked")
+ private String getRequestParameters(HttpServletRequest req) {
+ StringBuilder msg = new StringBuilder();
+ Enumeration<String> allParams = req.getParameterNames();
+
+ while (allParams.hasMoreElements()) {
+ String curParam = allParams.nextElement();
+ msg.append(curParam);
+ msg.append("=");
+ msg.append(req.getParameter(curParam));
+ msg.append('\n');
+ }
+
+ return msg.toString();
+ }
/**
* Generate an Error response to be returned to the client.
--
You received this message because you are subscribed to the Google Groups "Simal
Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/simal-commits?hl=en.