- From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
- Date: Tue, 13 Oct 2009 16:33:48 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/action
In directory hutz:/tmp/cvs-serv25785/src/org/w3c/unicorn/action
Modified Files:
ObserveAction.java
Log Message:
added doHead method
+ X-W3C-Validator-xxx headers
Index: ObserveAction.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/action/ObserveAction.java,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -d -r1.51 -r1.52
--- ObserveAction.java 9 Oct 2009 14:58:50 -0000 1.51
+++ ObserveAction.java 13 Oct 2009 16:33:46 -0000 1.52
@@ -32,6 +32,7 @@
import org.w3c.unicorn.input.UploadInputParameter;
import org.w3c.unicorn.output.OutputFactory;
import org.w3c.unicorn.output.OutputModule;
+import org.w3c.unicorn.response.Response;
import org.w3c.unicorn.util.Message;
import org.w3c.unicorn.util.MessageList;
import org.w3c.unicorn.util.Property;
@@ -272,6 +273,27 @@
messages.add(new Message(Message.ERROR, "$message_no_observation_done", null));
aOutputModule.produceError(mapOfStringObject, resp.getWriter());
} else {
+ if (req.getMethod().equals("HEAD")) {
+ LinkedHashMap<String, Response> observationList = aUnicornCall.getObservationList();
+ int errors = 0;
+ int warnings = 0;
+ int infos = 0;
+ for (Object ob : observationList.keySet()) {
+ String key = (String) ob;
+ errors += observationList.get(key).getErrorCount();
+ warnings += observationList.get(key).getWarningCount();
+ infos += observationList.get(key).getInfoCount();
+ }
+ resp.setHeader("X-W3C-Validator-Errors", Integer.toString(errors));
+ resp.setHeader("X-W3C-Validator-Info", Integer.toString(errors));
+ resp.setHeader("X-W3C-Validator-Warnings", Integer.toString(errors));
+ if (errors > 0)
+ resp.setHeader("X-W3C-Validator-Status", "Invalid");
+ else
+ resp.setHeader("X-W3C-Validator-Status", "Valid");
+ }
+
+
aOutputModule.produceOutput(mapOfStringObject, resp.getWriter());
}
} catch (final UnicornException e) {
@@ -297,6 +319,12 @@
doGet(req, resp);
}
+ @Override
+ protected void doHead(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ doGet(req, resp);
+ }
+
protected Map<String, Object> getRequestParameters(HttpServletRequest req) throws FileUploadException {
Hashtable<String, Object> params = new Hashtable<String, Object>();
Received on Tuesday, 13 October 2009 16:33:53 UTC