cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anto...@apache.org
Subject svn commit: r165532 - /cocoon/blocks/supported/session-fw/trunk/java/org/apache/cocoon/webapps/session/context/RequestSessionContext.java
Date Sun, 01 May 2005 18:04:09 GMT
Author: antonio
Date: Sun May  1 11:04:08 2005
New Revision: 165532

URL: http://svn.apache.org/viewcvs?rev=165532&view=rev
Log:
Quick workaround for request attributes whose name is not suitable for an XML element name
(by Sylvain) + use BooleanUtils (merging from 2.1)

Modified:
    cocoon/blocks/supported/session-fw/trunk/java/org/apache/cocoon/webapps/session/context/RequestSessionContext.java

Modified: cocoon/blocks/supported/session-fw/trunk/java/org/apache/cocoon/webapps/session/context/RequestSessionContext.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/supported/session-fw/trunk/java/org/apache/cocoon/webapps/session/context/RequestSessionContext.java?rev=165532&r1=165531&r2=165532&view=diff
==============================================================================
--- cocoon/blocks/supported/session-fw/trunk/java/org/apache/cocoon/webapps/session/context/RequestSessionContext.java
(original)
+++ cocoon/blocks/supported/session-fw/trunk/java/org/apache/cocoon/webapps/session/context/RequestSessionContext.java
Sun May  1 11:04:08 2005
@@ -29,9 +29,11 @@
 import org.apache.cocoon.transformation.CIncludeTransformer;
 import org.apache.cocoon.xml.IncludeXMLConsumer;
 import org.apache.cocoon.xml.dom.DOMUtil;
+import org.apache.commons.lang.BooleanUtils;
 import org.apache.excalibur.source.SourceParameters;
 import org.apache.excalibur.xml.sax.SAXParser;
 import org.apache.excalibur.xml.xpath.XPathProcessor;
+import org.w3c.dom.DOMException;
 import org.w3c.dom.Document;
 import org.w3c.dom.DocumentFragment;
 import org.w3c.dom.Element;
@@ -111,7 +113,7 @@
  *  - getAuthType()
  *
  * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
- * @version CVS $Id: RequestSessionContext.java,v 1.7 2004/03/19 14:16:55 cziegeler Exp $
+ * @version CVS $Id$
 */
 public final class RequestSessionContext
 implements SessionContext {
@@ -257,13 +259,13 @@
         node.appendChild(this.createTextNode(doc, this.request.getServletPath()));
         root.appendChild(node);
         node = doc.createElementNS(null, "isRequestedSessionIdFromCookie");
-        node.appendChild(doc.createTextNode(this.request.isRequestedSessionIdFromCookie()
? "true" : "false"));
+        node.appendChild(doc.createTextNode(BooleanUtils.toStringTrueFalse(this.request.isRequestedSessionIdFromCookie())));
         root.appendChild(node);
         node = doc.createElementNS(null, "isRequestedSessionIdFromURL");
-        node.appendChild(doc.createTextNode(this.request.isRequestedSessionIdFromURL() ?
"true" : "false"));
+        node.appendChild(doc.createTextNode(BooleanUtils.toStringTrueFalse(this.request.isRequestedSessionIdFromURL())));
         root.appendChild(node);
         node = doc.createElementNS(null, "isRequestedSessionIdValid");
-        node.appendChild(doc.createTextNode(this.request.isRequestedSessionIdValid() ? "true"
: "false"));
+        node.appendChild(doc.createTextNode(BooleanUtils.toStringTrueFalse(this.request.isRequestedSessionIdValid())));
         root.appendChild(node);
     }
 
@@ -281,9 +283,15 @@
         Enumeration all = this.request.getAttributeNames();
         while (all.hasMoreElements() == true) {
             attrName = (String) all.nextElement();
-            attr = doc.createElementNS(null, attrName);
-            attrElement.appendChild(attr);
-            DOMUtil.valueOf(attr, this.request.getAttribute(attrName));
+            try {
+                attr = doc.createElementNS(null, attrName);
+                attrElement.appendChild(attr);
+                DOMUtil.valueOf(attr, this.request.getAttribute(attrName));
+            } catch(DOMException de) {
+                // Some request attributes have names that are invalid as element names.
+                // Example : "FOM JavaScript GLOBAL SCOPE/file://my/path/to/flow/script.js"
+                System.err.println("Cannot create XML element with name '" + attrName + "'
: " + de.getMessage());
+            }
         }
     }
 
@@ -313,7 +321,7 @@
                 node.appendChild(this.createTextNode(doc, current.getDomain()));
                 parent.appendChild(node);
                 node = doc.createElementNS(null, "maxAge");
-                node.appendChild(this.createTextNode(doc, ""+current.getMaxAge()));
+                node.appendChild(this.createTextNode(doc, "" + current.getMaxAge()));
                 parent.appendChild(node);
                 node = doc.createElementNS(null, "name");
                 node.appendChild(this.createTextNode(doc, current.getName()));
@@ -322,13 +330,13 @@
                 node.appendChild(this.createTextNode(doc, current.getPath()));
                 parent.appendChild(node);
                 node = doc.createElementNS(null, "secure");
-                node.appendChild(doc.createTextNode(current.getSecure() ? "true" : "false"));
+                node.appendChild(doc.createTextNode(BooleanUtils.toStringTrueFalse(current.getSecure())));
                 parent.appendChild(node);
                 node = doc.createElementNS(null, "value");
                 node.appendChild(this.createTextNode(doc, current.getValue()));
                 parent.appendChild(node);
                 node = doc.createElementNS(null, "version");
-                node.appendChild(this.createTextNode(doc, ""+current.getVersion()));
+                node.appendChild(this.createTextNode(doc, "" + current.getVersion()));
                 parent.appendChild(node);
             }
         }



Mime
View raw message