author | Eugene Ostroukhov <eugeneo@symbian.org> |
Mon, 17 May 2010 15:31:00 -0700 | |
changeset 336 | 131c321bf080 |
parent 191 | 61c04b3eb3e7 |
permissions | -rw-r--r-- |
191
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1 |
// |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
2 |
// $Id: CssValidator.java,v 1.42 2009-02-26 10:41:25 ylafon Exp $ |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
3 |
// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
4 |
// |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
5 |
// (c) COPYRIGHT MIT and INRIA, 1997. |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
6 |
// Please first read the full copyright statement in file COPYRIGHT.html |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
7 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
8 |
package org.w3c.css.servlet; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
9 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
10 |
import java.io.ByteArrayInputStream; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
11 |
import java.io.IOException; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
12 |
import java.io.InputStream; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
13 |
import java.io.OutputStream; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
14 |
import java.io.OutputStreamWriter; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
15 |
import java.io.PrintWriter; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
16 |
import java.net.ProtocolException; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
17 |
import java.net.URL; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
18 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
19 |
import javax.servlet.ServletConfig; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
20 |
import javax.servlet.ServletException; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
21 |
import javax.servlet.ServletInputStream; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
22 |
import javax.servlet.http.HttpServlet; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
23 |
import javax.servlet.http.HttpServletRequest; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
24 |
import javax.servlet.http.HttpServletResponse; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
25 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
26 |
import org.w3c.css.css.CssParser; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
27 |
import org.w3c.css.css.DocumentParser; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
28 |
import org.w3c.css.css.StyleReport; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
29 |
import org.w3c.css.css.StyleReportFactory; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
30 |
import org.w3c.css.css.StyleSheet; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
31 |
import org.w3c.css.css.StyleSheetParser; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
32 |
import org.w3c.css.css.TagSoupStyleSheetHandler; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
33 |
import org.w3c.css.error.ErrorReport; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
34 |
import org.w3c.css.error.ErrorReportFactory; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
35 |
import org.w3c.css.index.IndexGenerator; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
36 |
import org.w3c.css.properties.PropertiesLoader; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
37 |
import org.w3c.css.util.ApplContext; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
38 |
import org.w3c.css.util.Codecs; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
39 |
import org.w3c.css.util.FakeFile; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
40 |
import org.w3c.css.util.HTTPURL; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
41 |
import org.w3c.css.util.NVPair; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
42 |
import org.w3c.css.util.Utf8Properties; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
43 |
import org.w3c.css.util.Util; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
44 |
import org.w3c.www.mime.MimeType; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
45 |
import org.w3c.www.mime.MimeTypeFormatException; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
46 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
47 |
/** |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
48 |
* This class is a servlet to use the validator. |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
49 |
* |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
50 |
* @version $Revision: 1.42 $ |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
51 |
*/ |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
52 |
public final class CssValidator extends HttpServlet { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
53 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
54 |
final static String texthtml = "text/html"; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
55 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
56 |
final static String applxhtml = "application/xhtml+xml"; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
57 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
58 |
final static String textplain = "text/plain"; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
59 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
60 |
final static String textcss = "text/css"; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
61 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
62 |
final static String textunknwon = "text/unknown"; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
63 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
64 |
final static String soap12 = "application/soap+xml"; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
65 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
66 |
final static String json = "application/json"; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
67 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
68 |
final static String server_name = "Jigsaw/2.2.5 " |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
69 |
+ "W3C_CSS_Validator_JFouffa/2.0"; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
70 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
71 |
final static String headers_name = "X-W3C-Validator-"; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
72 |
/** |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
73 |
* Create a new CssValidator. |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
74 |
*/ |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
75 |
public CssValidator() { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
76 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
77 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
78 |
/** |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
79 |
* Initializes the servlet and logs the initialization. The init method is |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
80 |
* called once, automatically, by the network service each time it loads |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
81 |
* the servlet. It is guaranteed to finish before any service requests are |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
82 |
* accepted. On fatal initialization errors, an UnavailableException should |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
83 |
* be thrown. Do not call the method System.exit. |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
84 |
* |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
85 |
* <p> |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
86 |
* The init method stores the ServletConfig object. Servlet writers who |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
87 |
* specialize this method should call either super.init, or store the |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
88 |
* ServletConfig object themselves. If an implementor decides to store the |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
89 |
* ServletConfig object in a different location, then the getServletConfig |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
90 |
* method must also be overridden. |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
91 |
* |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
92 |
* <P> |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
93 |
* <DL> |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
94 |
* <STRONG>Init parameters:</STRONG> |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
95 |
* <DT>debug |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
96 |
* <DD><code>true</code> if you want to be in debug mode. |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
97 |
* <DT>aural |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
98 |
* <DD><code>true</code> if you want to be in aural mode. |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
99 |
* <DT>import |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
100 |
* <DD><code>false</code> if you don't want to activate the import |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
101 |
* statement. For security reasons, you shoud be careful when you lunch the |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
102 |
* servlet on a HTTP server with special access authorization. |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
103 |
* <DT>input |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
104 |
* <DD><code>html</code> if the user have an HTML input or |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
105 |
* <code>xml</code> otherwise. <strong>deprecated</strong> |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
106 |
* </DL> |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
107 |
* |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
108 |
* @param config |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
109 |
* servlet configuration information. |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
110 |
* @exception ServletException |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
111 |
* if a servlet exception has occurred. |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
112 |
*/ |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
113 |
public void init(ServletConfig config) throws ServletException { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
114 |
super.init(config); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
115 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
116 |
// [SECURITY] don't forget this ! |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
117 |
Util.servlet = true; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
118 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
119 |
if (config.getInitParameter("debug") != null) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
120 |
// servlet debug mode |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
121 |
// define a boolean property CSS.StyleSheet.debug if you want more |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
122 |
// debug. |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
123 |
Util.onDebug = config.getInitParameter("debug").equals("true"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
124 |
System.err.println("RUN IN DEBUG MODE: " |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
125 |
+ config.getInitParameter("debug").equals("true")); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
126 |
} else if (Util.onDebug) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
127 |
System.err.println("RUN IN DEBUG MODE"+ |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
128 |
" but activated outside the servlet"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
129 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
130 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
131 |
if ((config.getInitParameter("import") != null) |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
132 |
&& (config.getInitParameter("import").equals("false"))) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
133 |
Util.importSecurity = true; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
134 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
135 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
136 |
// The following code will check if the index files are missing or outdated |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
137 |
// If so, the files will be regenerated |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
138 |
// This is done in a Thread so that the validation can carry on. |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
139 |
new Thread () { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
140 |
public void run () { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
141 |
IndexGenerator.generatesIndex(true); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
142 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
143 |
}.start(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
144 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
145 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
146 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
147 |
private PrintWriter getLocalPrintWriter(OutputStream os, String encoding) |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
148 |
throws IOException { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
149 |
if (encoding != null) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
150 |
return new PrintWriter(new OutputStreamWriter(os, encoding)); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
151 |
} else { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
152 |
return new PrintWriter(new OutputStreamWriter(os, |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
153 |
Utf8Properties.ENCODING)); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
154 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
155 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
156 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
157 |
/** |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
158 |
* Performs the HTTP GET operation. |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
159 |
* An HTTP BAD_REQUEST error is reported if |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
160 |
* an error occurs. This servlet writers shouldn't set the headers for the |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
161 |
* requested entity (content type and encoding). |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
162 |
* |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
163 |
* <P> |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
164 |
* Note that the GET operation is expected to be <em>safe</em>, without |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
165 |
* any side effects for which users might be held responsible. For example, |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
166 |
* most form queries have no side effects. Requests intended to change |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
167 |
* stored data should use some other HTTP method. (There have been cases of |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
168 |
* significant security breaches reported because web-based applications |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
169 |
* used GET inappropriately.) |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
170 |
* |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
171 |
* <P> |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
172 |
* The GET operation is also expected to be <em>idempotent</em>, meaning |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
173 |
* that it can safely be repeated. This is not quite the same as being |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
174 |
* safe, but in some common examples the requirements have the same result. |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
175 |
* For example, repeating queries is both safe and idempotent |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
176 |
* (unless payment is required!), but buying something or modifying data |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
177 |
* is neither safe nor idempotent. |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
178 |
* |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
179 |
* <P> |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
180 |
* <DL> |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
181 |
* <STRONG>Forms parameters:</STRONG> |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
182 |
* <DT>URL |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
183 |
* <DD>the URL to be parsed. |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
184 |
* <DT>submitURL |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
185 |
* <DD>if the user want to parse an URL. |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
186 |
* <DT>text |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
187 |
* <DD>The text to be parsed. |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
188 |
* <DT>submitTEXT |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
189 |
* <DD>if the user want to parse the text. |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
190 |
* <DT>output |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
191 |
* <DD>HTML if the user want an HTML output or XML otherwise. |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
192 |
* <DT>input |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
193 |
* <DD>HTML if the user have an HTML input or XML otherwise. |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
194 |
* </DL> |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
195 |
* |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
196 |
* @param req |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
197 |
* encapsulates the request to the servlet. |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
198 |
* @param resp |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
199 |
* encapsulates the response from the servlet. |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
200 |
* @exception ServletException |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
201 |
* if the request could not be handled. |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
202 |
* @exception IOException |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
203 |
* if detected when handling the request. |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
204 |
* @see org.w3c.css.css.StyleSheetGenerator |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
205 |
*/ |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
206 |
public void doGet(HttpServletRequest req, HttpServletResponse res) |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
207 |
throws ServletException, IOException { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
208 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
209 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
210 |
boolean errorReport = true; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
211 |
int warningLevel = 2; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
212 |
CssParser parser = null; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
213 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
214 |
String lang = null; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
215 |
try { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
216 |
lang = req.getParameter("lang"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
217 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
218 |
catch(Exception e) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
219 |
lang = null; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
220 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
221 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
222 |
if(lang == null || lang.equals("")) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
223 |
lang = req.getHeader("Accept-Language"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
224 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
225 |
else { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
226 |
lang += ',' + req.getHeader("Accept-Language"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
227 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
228 |
ApplContext ac = new ApplContext(lang); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
229 |
ac.setLink(req.getQueryString()); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
230 |
ac.setContentEncoding(req.getHeader("Accept-Charset")); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
231 |
String output = req.getParameter("output"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
232 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
233 |
String uri = null; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
234 |
try { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
235 |
uri = req.getParameter("uri"); // null if the parameter does not |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
236 |
// exist |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
237 |
} catch (Exception ex) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
238 |
// pb in URI decoding (bad escaping, most probably) |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
239 |
handleError(res, ac, output, "No file", new IOException( |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
240 |
"Invalid escape sequence in URI"), false); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
241 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
242 |
String text = null; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
243 |
try { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
244 |
text = req.getParameter("text"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
245 |
} catch (Exception ex) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
246 |
// pb in URI decoding (bad escaping, most probably) |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
247 |
// not sure it will work here, as it may be catched by the first |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
248 |
// getParameter call |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
249 |
handleError(res, ac, output, "Invalid text", new IOException( |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
250 |
"Invalid escape sequence in URI"), false); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
251 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
252 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
253 |
String warning = req.getParameter("warning"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
254 |
String error = req.getParameter("error"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
255 |
String profile = req.getParameter("profile"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
256 |
String usermedium = req.getParameter("usermedium"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
257 |
String type = req.getParameter("type"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
258 |
if (type == null) |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
259 |
type = "none"; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
260 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
261 |
String credential = req.getHeader("Authorization"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
262 |
if ((credential != null) && (credential.length() > 1)) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
263 |
ac.setCredential(credential); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
264 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
265 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
266 |
if (usermedium == null || "".equals(usermedium)) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
267 |
usermedium = "all"; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
268 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
269 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
270 |
InputStream in = req.getInputStream(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
271 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
272 |
ac.setMedium(usermedium); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
273 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
274 |
if (req.getParameter("debug") != null) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
275 |
Util.onDebug = req.getParameter("debug").equals("true"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
276 |
if (Util.onDebug) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
277 |
System.err.println("SWITCH DEBUG MODE REQUEST"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
278 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
279 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
280 |
else { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
281 |
Util.onDebug = false; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
282 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
283 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
284 |
//text = Util.suppressWhiteSpace(text); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
285 |
uri = Util.suppressWhiteSpace(uri); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
286 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
287 |
if (output == null) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
288 |
output = texthtml; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
289 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
290 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
291 |
// CSS version |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
292 |
if (profile != null && (!"none".equals(profile) || "".equals(profile))) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
293 |
if ("css1".equals(profile) || "css2".equals(profile) |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
294 |
|| "css21".equals(profile) |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
295 |
|| "css3".equals(profile) || "svg".equals(profile) |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
296 |
|| "svgbasic".equals(profile) || "svgtiny".equals(profile)) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
297 |
ac.setCssVersion(profile); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
298 |
} else { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
299 |
ac.setProfile(profile); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
300 |
ac.setCssVersion(PropertiesLoader.config.getProperty("defaultProfile")); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
301 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
302 |
} else { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
303 |
ac.setProfile("none"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
304 |
ac.setCssVersion(PropertiesLoader.config.getProperty("defaultProfile")); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
305 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
306 |
if (Util.onDebug) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
307 |
System.err.println("[DEBUG] profile is : " + ac.getCssVersion() |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
308 |
+ " medium is " + usermedium); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
309 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
310 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
311 |
// verify the request |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
312 |
if ((uri == null) && (text == null)) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
313 |
// res.sendError(res.SC_BAD_REQUEST, |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
314 |
// "You have send an invalid request."); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
315 |
handleError(res, ac, output, "No file", |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
316 |
new IOException(ac.getMsg().getServletString("invalid-request")), |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
317 |
false); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
318 |
return; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
319 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
320 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
321 |
in.close(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
322 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
323 |
// set the warning output |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
324 |
if (warning != null) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
325 |
if (warning.equals("no")) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
326 |
warningLevel = -1; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
327 |
} else { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
328 |
try { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
329 |
warningLevel = Integer.parseInt(warning); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
330 |
} catch (Exception e) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
331 |
System.err.println(e); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
332 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
333 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
334 |
ac.setWarningLevel(warningLevel); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
335 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
336 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
337 |
// set the error report |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
338 |
if (error != null && error.equals("no")) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
339 |
errorReport = false; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
340 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
341 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
342 |
// debug mode |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
343 |
Util.verbose("\nServlet request "); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
344 |
if (uri != null) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
345 |
Util.verbose("Source file : " + uri); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
346 |
} else { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
347 |
Util.verbose("TEXTAREA Input"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
348 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
349 |
// verbose("From " + req.getRemoteHost() + |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
350 |
// " (" + req.getRemoteAddr() + ") at " + (new Date()) ); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
351 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
352 |
if (uri != null) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
353 |
// HTML document |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
354 |
try { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
355 |
uri = HTTPURL.getURL(uri).toString(); // needed to be sure |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
356 |
// that it is a valid |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
357 |
// url |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
358 |
uri = uri.replaceAll(" ", "%20"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
359 |
DocumentParser URLparser = new DocumentParser(ac, uri); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
360 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
361 |
handleRequest(ac, res, uri, URLparser.getStyleSheet(), output, |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
362 |
warningLevel, errorReport); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
363 |
} catch (ProtocolException pex) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
364 |
if (Util.onDebug) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
365 |
pex.printStackTrace(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
366 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
367 |
res.setHeader("WWW-Authenticate", pex.getMessage()); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
368 |
res.sendError(HttpServletResponse.SC_UNAUTHORIZED); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
369 |
} catch (Exception e) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
370 |
handleError(res, ac, output, uri, e, true); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
371 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
372 |
} else if (text != null) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
373 |
String fileName = "TextArea"; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
374 |
Util.verbose("- " + fileName + " Data -"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
375 |
Util.verbose(text); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
376 |
Util.verbose("- End of " + fileName + " Data"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
377 |
InputStream is = new ByteArrayInputStream(text.getBytes()); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
378 |
fileName = "file://localhost/" + fileName; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
379 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
380 |
try { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
381 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
382 |
if ("css".equals(type) || ( "none".equals(type) && isCSS(text))) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
383 |
// if CSS: |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
384 |
parser = new StyleSheetParser(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
385 |
parser.parseStyleElement(ac, is, null, usermedium, |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
386 |
new URL(fileName), 0); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
387 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
388 |
handleRequest(ac, res, fileName, parser |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
389 |
.getStyleSheet(), output, warningLevel, errorReport); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
390 |
} else { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
391 |
// else, trying HTML |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
392 |
TagSoupStyleSheetHandler handler = new TagSoupStyleSheetHandler(null, ac); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
393 |
handler.parse(is, fileName); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
394 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
395 |
handleRequest(ac, res, fileName, handler.getStyleSheet(), output, |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
396 |
warningLevel, errorReport); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
397 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
398 |
} catch (ProtocolException pex) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
399 |
if (Util.onDebug) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
400 |
pex.printStackTrace(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
401 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
402 |
res.setHeader("WWW-Authenticate", pex.getMessage()); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
403 |
res.sendError(HttpServletResponse.SC_UNAUTHORIZED); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
404 |
} catch (Exception e) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
405 |
handleError(res, ac, output, fileName, e, false); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
406 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
407 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
408 |
Util.verbose("CssValidator: Request terminated.\n"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
409 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
410 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
411 |
/** |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
412 |
* This method is used for the direct input |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
413 |
* If the <style> tag is found, it may be an HTML entry |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
414 |
* The exception is when this tag is inside comment |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
415 |
* It might also be an HTML document with no CSS => why ? |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
416 |
* Or with only imports (we can't chack thoses imports...) |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
417 |
* @param text, the textarea to test |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
418 |
* @return <tt>false</tt> if it contains the style tag well formed |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
419 |
*/ |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
420 |
private boolean isCSS(String text) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
421 |
try { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
422 |
text = text.toLowerCase(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
423 |
int p = text.indexOf("<style"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
424 |
return p == -1 || p > text.indexOf("</style>"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
425 |
} catch (Exception e) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
426 |
System.err.println("error: " + e.getMessage()); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
427 |
return true; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
428 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
429 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
430 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
431 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
432 |
/** |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
433 |
* Performs the HTTP POST operation. An HTTP BAD_REQUEST error is reported |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
434 |
* if an error occurs. The headers that are set should include content type, |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
435 |
* length, and encoding. Setting content length allows the servlet to take |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
436 |
* advantage of HTTP "connection keep alive". If content length can not be |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
437 |
* set in advance, the performance penalties associated with not using keep |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
438 |
* alives will sometimes be avoided if the response entity fits in an |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
439 |
* internal buffer. The servlet implementor must write the headers before |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
440 |
* the response data because the headers can be flushed at any time after |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
441 |
* the data starts to be written. |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
442 |
* |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
443 |
* <P> |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
444 |
* This method does not need to be either "safe" or "idempotent". Operations |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
445 |
* requested through POST could be ones for which users need to be held |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
446 |
* accountable. Specific examples including updating stored data or buying |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
447 |
* things online. |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
448 |
* |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
449 |
* <P> |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
450 |
* <DL> |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
451 |
* <STRONG>Forms parameters:</STRONG> |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
452 |
* <DT>file |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
453 |
* <DD>The input file to be parsed. |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
454 |
* <DT>output |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
455 |
* <DD>The format output. |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
456 |
* <DT>input |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
457 |
* <DD>HTML if the user have an HTML input or XML otherwise. |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
458 |
* </DL> |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
459 |
* |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
460 |
* @param req |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
461 |
* encapsulates the request to the servlet |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
462 |
* @param resp |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
463 |
* encapsulates the response from the servlet |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
464 |
* @exception ServletException |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
465 |
* if the request could not be handled |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
466 |
* @exception IOException |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
467 |
* if detected when handling the request |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
468 |
* @see org.w3c.css.css.StyleSheetGenerator |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
469 |
*/ |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
470 |
public void doPost(HttpServletRequest req, HttpServletResponse res) |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
471 |
throws ServletException, IOException { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
472 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
473 |
String lang = null; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
474 |
try { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
475 |
lang = req.getParameter("lang"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
476 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
477 |
catch(Exception e) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
478 |
lang = null; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
479 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
480 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
481 |
boolean errorReport = true; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
482 |
int warningLevel = 2; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
483 |
CssParser parser = null; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
484 |
FakeFile file = null; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
485 |
String text = null; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
486 |
String output = null; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
487 |
//boolean XMLinput = false; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
488 |
String warning = null; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
489 |
String error = null; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
490 |
String profile = "none"; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
491 |
String usermedium = "all"; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
492 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
493 |
ServletInputStream in = req.getInputStream(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
494 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
495 |
byte[] buf = new byte[2048]; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
496 |
byte[] general = new byte[65536]; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
497 |
int count = 0; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
498 |
int len; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
499 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
500 |
if (req.getParameter("debug") != null) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
501 |
Util.onDebug = req.getParameter("debug").equals("true"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
502 |
if (Util.onDebug) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
503 |
System.err.println("SWITCH DEBUG MODE REQUEST"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
504 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
505 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
506 |
else { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
507 |
Util.onDebug = false; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
508 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
509 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
510 |
Util.verbose("\nCssValidator: Servlet request "); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
511 |
// verbose("From " + req.getRemoteHost() + |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
512 |
// " (" + req.getRemoteAddr() + ") at " + (new Date()) ); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
513 |
Util.verbose("Content-length : " + req.getContentLength()); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
514 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
515 |
if (req.getContentType().trim().startsWith("multipart/form-data")) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
516 |
Util.verbose("Content-type : multipart/form-data"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
517 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
518 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
519 |
try { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
520 |
while ((len = in.readLine(buf, 0, buf.length)) != -1) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
521 |
if (len >= 2 && buf[len - 1] == '\n' && buf[len - 2] == '\r') { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
522 |
len -= 1; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
523 |
buf[len - 1] = (byte) '\n'; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
524 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
525 |
if (len != 0 && buf[len - 1] == '\r') { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
526 |
buf[len - 1] = (byte) '\n'; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
527 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
528 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
529 |
if (general.length < (count + len)) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
530 |
byte[] old = general; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
531 |
general = new byte[old.length * 2]; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
532 |
System.arraycopy(old, 0, general, 0, old.length); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
533 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
534 |
System.arraycopy(buf, 0, general, count, len); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
535 |
count += len; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
536 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
537 |
} finally { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
538 |
in.close(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
539 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
540 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
541 |
try { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
542 |
buf = new byte[count]; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
543 |
System.arraycopy(general, 0, buf, 0, count); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
544 |
NVPair[] tmp = Codecs.mpFormDataDecode(buf, req.getContentType()); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
545 |
for (int i = 0; i < tmp.length; i++) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
546 |
if (tmp[i].getName().equals("file")) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
547 |
file = (FakeFile) tmp[i].getValue(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
548 |
} else if (tmp[i].getName().equals("text")) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
549 |
text = (String) tmp[i].getValue(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
550 |
} else if (tmp[i].getName().equals("lang")) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
551 |
lang = (String) tmp[i].getValue(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
552 |
} else if (tmp[i].getName().equals("output")) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
553 |
output = (String) tmp[i].getValue(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
554 |
} else if (tmp[i].getName().equals("warning")) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
555 |
warning = (String) tmp[i].getValue(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
556 |
} else if (tmp[i].getName().equals("error")) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
557 |
warning = (String) tmp[i].getValue(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
558 |
//} else if (tmp[i].getName().equals("input")) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
559 |
// XMLinput = ((String) tmp[i].getValue()).equals("XML"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
560 |
} else if (tmp[i].getName().equals("profile")) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
561 |
profile = (String) tmp[i].getValue(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
562 |
} else if (tmp[i].getName().equals("usermedium")) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
563 |
usermedium = (String) tmp[i].getValue(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
564 |
if (usermedium == null || "".equals(usermedium)) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
565 |
usermedium = "all"; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
566 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
567 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
568 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
569 |
} catch (Exception e) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
570 |
System.out.println("Oups! Error in Util/Codecs.java?!?"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
571 |
e.printStackTrace(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
572 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
573 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
574 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
575 |
if(lang == null || lang.equals("")) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
576 |
lang = req.getHeader("Accept-Language"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
577 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
578 |
else { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
579 |
lang += ',' + req.getHeader("Accept-Language"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
580 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
581 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
582 |
ApplContext ac = new ApplContext(lang); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
583 |
ac.setLink(req.getQueryString()); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
584 |
ac.setMedium(usermedium); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
585 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
586 |
if (output == null) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
587 |
output = texthtml; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
588 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
589 |
if ((file == null || file.getSize() == 0) && |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
590 |
(text == null || text.length() == 0)) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
591 |
// res.sendError(res.SC_BAD_REQUEST, |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
592 |
// "You have send an invalid request"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
593 |
handleError(res, ac, output, "No file", |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
594 |
new IOException(ac.getMsg().getServletString( |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
595 |
"invalid-request")), |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
596 |
false); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
597 |
return; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
598 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
599 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
600 |
// set the warning output |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
601 |
if (warning != null) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
602 |
if (warning.equals("no")) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
603 |
warningLevel = -1; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
604 |
} else { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
605 |
try { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
606 |
warningLevel = Integer.parseInt(warning); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
607 |
} catch (Exception e) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
608 |
System.err.println(e); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
609 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
610 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
611 |
ac.setWarningLevel(warningLevel); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
612 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
613 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
614 |
// set the error report |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
615 |
if (error != null && error.equals("no")) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
616 |
errorReport = false; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
617 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
618 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
619 |
// CSS version |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
620 |
if (profile != null && (!"none".equals(profile) ||"".equals(profile))) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
621 |
if ("css1".equals(profile) || "css2".equals(profile) |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
622 |
|| "css21".equals(profile) |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
623 |
|| "css3".equals(profile) || "svg".equals(profile) |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
624 |
|| "svgbasic".equals(profile) || "svgtiny".equals(profile)) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
625 |
ac.setCssVersion(profile); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
626 |
} else { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
627 |
ac.setProfile(profile); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
628 |
ac.setCssVersion(PropertiesLoader.config.getProperty( |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
629 |
"defaultProfile")); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
630 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
631 |
} else { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
632 |
ac.setProfile("none"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
633 |
ac.setCssVersion(PropertiesLoader.config.getProperty( |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
634 |
"defaultProfile")); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
635 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
636 |
String fileName = ""; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
637 |
InputStream is = null; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
638 |
boolean isCSS = false; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
639 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
640 |
if (file != null && file.getSize() != 0) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
641 |
ac.setFakeFile(file); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
642 |
fileName = file.getName(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
643 |
Util.verbose("File : " + fileName); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
644 |
// another way to get file type... |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
645 |
isCSS = file.getContentType().equals(textcss); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
646 |
} else if (text != null ) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
647 |
ac.setFakeText(text); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
648 |
fileName = "TextArea"; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
649 |
Util.verbose("- " + fileName + " Data -"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
650 |
Util.verbose(text); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
651 |
Util.verbose("- End of " + fileName + " Data"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
652 |
//quick test that works in most cases to determine wether it's |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
653 |
//HTML or CSS |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
654 |
isCSS = isCSS(text); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
655 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
656 |
fileName = "file://localhost/" + fileName; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
657 |
try { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
658 |
URL u = new URL(fileName); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
659 |
is = ac.getFakeInputStream(u); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
660 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
661 |
ac.setFakeURL(fileName); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
662 |
if (isCSS) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
663 |
//if CSS: |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
664 |
parser = new StyleSheetParser(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
665 |
parser.parseStyleElement(ac, is, null, usermedium, |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
666 |
new URL(fileName), 0); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
667 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
668 |
handleRequest(ac, res, fileName, parser.getStyleSheet(), |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
669 |
output, warningLevel, errorReport); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
670 |
} else { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
671 |
// else, trying HTML |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
672 |
TagSoupStyleSheetHandler handler; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
673 |
handler = new TagSoupStyleSheetHandler(null, ac); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
674 |
handler.parse(is, fileName); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
675 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
676 |
handleRequest(ac, res, fileName, handler.getStyleSheet(), |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
677 |
output, warningLevel, errorReport); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
678 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
679 |
} catch (ProtocolException pex) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
680 |
if (Util.onDebug) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
681 |
//pex.printStackTrace(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
682 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
683 |
res.setHeader("WWW-Authenticate", pex.getMessage()); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
684 |
res.sendError(HttpServletResponse.SC_UNAUTHORIZED); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
685 |
} catch (Exception e) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
686 |
handleError(res, ac, output, fileName, e, false); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
687 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
688 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
689 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
690 |
Util.verbose("CssValidator: Request terminated.\n"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
691 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
692 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
693 |
private void handleRequest(ApplContext ac, HttpServletResponse res, |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
694 |
String title, StyleSheet styleSheet, |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
695 |
String output, int warningLevel, |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
696 |
boolean errorReport) throws Exception { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
697 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
698 |
buildHeader(ac, res, output); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
699 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
700 |
if (styleSheet == null) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
701 |
throw new IOException(ac.getMsg().getServletString("process") + " " |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
702 |
+ title); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
703 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
704 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
705 |
// if the output parameter was a mime type, we convert it |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
706 |
// to an understandable value for the StyleReportFactory |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
707 |
if ("text/xml".equals(ac.getInput()) && texthtml.equals(output)) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
708 |
output = "xhtml"; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
709 |
} else if (texthtml.equals(output)) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
710 |
output = "html"; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
711 |
} else if (soap12.equals(output)) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
712 |
output = "soap12"; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
713 |
} else if (json.equals(output)) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
714 |
output = "json"; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
715 |
} else if(textplain.equals(output)) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
716 |
output = "text"; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
717 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
718 |
styleSheet.findConflicts(ac); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
719 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
720 |
StyleReport style = StyleReportFactory.getStyleReport(ac, title, |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
721 |
styleSheet, output, warningLevel); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
722 |
if (!errorReport) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
723 |
style.desactivateError(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
724 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
725 |
PrintWriter out = getLocalPrintWriter(res.getOutputStream(), ac |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
726 |
.getContentEncoding()); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
727 |
int nb_errors = styleSheet.getErrors().getErrorCount(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
728 |
res.setHeader(headers_name + "Errors", String.valueOf(nb_errors)); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
729 |
res.setHeader(headers_name + "Status", nb_errors == 0 ? "Valid" : "Invalid"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
730 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
731 |
try { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
732 |
style.print(out); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
733 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
734 |
} finally { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
735 |
out.close(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
736 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
737 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
738 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
739 |
/** |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
740 |
* Generates the response header |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
741 |
* @param ac |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
742 |
* @param res |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
743 |
* @param output |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
744 |
* @throws MimeTypeFormatException |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
745 |
*/ |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
746 |
private void buildHeader(ApplContext ac, HttpServletResponse res, |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
747 |
String output) |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
748 |
{ |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
749 |
// I don't want cache for the response (inhibits proxy) |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
750 |
res.setHeader("Pragma", "no-cache"); // @@deprecated |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
751 |
res.setHeader("Cache-Control", "no-cache"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
752 |
// Here is a little joke :-) |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
753 |
// res.setHeader("Server", server_name); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
754 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
755 |
if(output == null) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
756 |
output = new String(texthtml); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
757 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
758 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
759 |
// set the content-type for the response |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
760 |
MimeType outputMt = null; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
761 |
if (output.equals(texthtml) || output.equals("html")) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
762 |
outputMt = MimeType.TEXT_HTML.getClone(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
763 |
} else if (output.equals(applxhtml) || output.equals("xhtml")) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
764 |
outputMt = MimeType.APPLICATION_XHTML_XML.getClone(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
765 |
} else if (output.equals(soap12) || output.equals("soap12")) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
766 |
// invert the comments on the following lines to (de)activate |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
767 |
// the soap Mime Type |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
768 |
try { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
769 |
outputMt = new MimeType(soap12); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
770 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
771 |
catch (MimeTypeFormatException e) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
772 |
outputMt = MimeType.TEXT_PLAIN.getClone(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
773 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
774 |
//outputMt = MimeType.TEXT_PLAIN.getClone(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
775 |
} else if(output.equals("ucn")) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
776 |
outputMt = MimeType.APPLICATION_XML.getClone(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
777 |
} else if(output.equals("json")) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
778 |
try { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
779 |
outputMt = new MimeType(json); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
780 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
781 |
catch (MimeTypeFormatException e) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
782 |
outputMt = MimeType.TEXT_PLAIN.getClone(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
783 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
784 |
} else { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
785 |
// Change this line if you want text/html output when incorrect |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
786 |
// output is passed |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
787 |
outputMt = MimeType.TEXT_PLAIN.getClone(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
788 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
789 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
790 |
if(ac != null) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
791 |
// ignore content encoding if output is SOAP |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
792 |
if(output.equals("soap12")) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
793 |
ac.setContentEncoding(null); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
794 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
795 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
796 |
if (ac.getContentEncoding() != null) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
797 |
outputMt.setParameter("charset", ac.getContentEncoding()); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
798 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
799 |
res.setContentType(outputMt.toString()); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
800 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
801 |
if (ac.getContentLanguage() != null) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
802 |
res.setHeader("Content-Language", ac.getContentLanguage()); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
803 |
} else { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
804 |
res.setHeader("Content-Language", "en"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
805 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
806 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
807 |
else { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
808 |
res.setHeader("Content-Language", "en"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
809 |
res.setHeader("charset", Utf8Properties.ENCODING); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
810 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
811 |
res.setHeader("Vary", "Accept-Language"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
812 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
813 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
814 |
private void handleError(HttpServletResponse res, ApplContext ac, |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
815 |
String output, String title, Exception e, |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
816 |
boolean validURI) |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
817 |
throws IOException { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
818 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
819 |
System.err.println("[ERROR VALIDATOR] " + title); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
820 |
System.err.println(e.toString()); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
821 |
e.printStackTrace(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
822 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
823 |
buildHeader(ac, res, output); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
824 |
res.setStatus(500); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
825 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
826 |
if((e instanceof java.net.UnknownHostException) || |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
827 |
((e instanceof java.io.FileNotFoundException) && |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
828 |
((e.getMessage().indexOf("Not Found") != -1) || |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
829 |
(e.getMessage().indexOf("Service Unavailable") != -1)))) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
830 |
validURI = true; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
831 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
832 |
else { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
833 |
validURI = false; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
834 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
835 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
836 |
PrintWriter out = getLocalPrintWriter(res.getOutputStream(), ac |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
837 |
.getContentEncoding()); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
838 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
839 |
ErrorReport error = ErrorReportFactory.getErrorReport(ac, title, output, |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
840 |
e, validURI); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
841 |
res.setHeader(headers_name + "Status", "Abort"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
842 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
843 |
try { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
844 |
error.print(out); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
845 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
846 |
finally { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
847 |
out.close(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
848 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
849 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
850 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
851 |
} |