Author: julien(a)jboss.com
Date: 2007-06-03 15:48:21 -0400 (Sun, 03 Jun 2007)
New Revision: 7380
Added:
trunk/common/src/main/org/jboss/portal/common/xml/NoSuchElementException.java
trunk/common/src/main/org/jboss/portal/common/xml/TooManyElementException.java
trunk/common/src/main/org/jboss/portal/common/xml/XMLTools.java
Removed:
trunk/common/src/main/org/jboss/portal/common/util/NoSuchElementException.java
trunk/common/src/main/org/jboss/portal/common/util/TooManyElementException.java
trunk/common/src/main/org/jboss/portal/common/util/XML.java
Modified:
trunk/cms/src/main/org/jboss/portal/cms/CMSMimeMappings.java
trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCMS.java
trunk/cms/src/main/org/jboss/portal/test/cms/commands/AbstractCommandTestCase.java
trunk/common/src/main/org/jboss/portal/common/util/LoaderResource.java
trunk/core/src/main/org/jboss/portal/core/deployment/jboss/ObjectDeployment.java
trunk/core/src/main/org/jboss/portal/core/deployment/jboss/PortletAppDeployment.java
trunk/core/src/main/org/jboss/portal/core/model/instance/metadata/InstanceMetaData.java
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/ContextMetaData.java
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PageMetaData.java
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalMetaData.java
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalObjectMetaData.java
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/WindowMetaData.java
trunk/security/src/main/org/jboss/portal/security/metadata/SecurityConstraintsMetaData.java
trunk/server/src/main/org/jboss/portal/server/deployment/PortalWebApp.java
trunk/server/src/main/org/jboss/portal/server/deployment/WebAppEnhancer.java
trunk/server/src/main/org/jboss/portal/server/impl/xml/EntityResolverService.java
trunk/test/src/main/org/jboss/portal/test/framework/embedded/DSConfig.java
trunk/test/src/main/org/jboss/portal/test/framework/embedded/DataSourceSupport.java
trunk/test/src/main/org/jboss/portal/test/framework/embedded/HibernateSupport.java
trunk/widget/src/main/org/jboss/portal/widget/google/provider/GGWidgetBuilder.java
Log:
move XML related utils to the common.xml package
Modified: trunk/cms/src/main/org/jboss/portal/cms/CMSMimeMappings.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/cms/CMSMimeMappings.java 2007-06-03 19:44:21 UTC
(rev 7379)
+++ trunk/cms/src/main/org/jboss/portal/cms/CMSMimeMappings.java 2007-06-03 19:48:21 UTC
(rev 7380)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.cms;
-import org.jboss.portal.common.util.XML;
+import org.jboss.portal.common.xml.XMLTools;
import org.jboss.portal.common.io.IOTools;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -50,14 +50,14 @@
try
{
is =
Thread.currentThread().getContextClassLoader().getResourceAsStream(MAPPINGS_FILE);
- Document dmt = XML.getDocumentBuilderFactory().newDocumentBuilder().parse(is);
+ Document dmt =
XMLTools.getDocumentBuilderFactory().newDocumentBuilder().parse(is);
Element docElmt = dmt.getDocumentElement();
- List mappingsList = XML.getChildren(docElmt, "mime-mapping");
+ List mappingsList = XMLTools.getChildren(docElmt, "mime-mapping");
for (int i = 0; i < mappingsList.size(); i++)
{
Element mapping = (Element)mappingsList.get(i);
- String extension = XML.asString(XML.getUniqueChild(mapping,
"extension", true));
- String mimeType = XML.asString(XML.getUniqueChild(mapping,
"mime-type", true));
+ String extension = XMLTools.asString(XMLTools.getUniqueChild(mapping,
"extension", true));
+ String mimeType = XMLTools.asString(XMLTools.getUniqueChild(mapping,
"mime-type", true));
mappings.put(extension, mimeType);
}
}
Modified: trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCMS.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCMS.java 2007-06-03 19:44:21 UTC
(rev 7379)
+++ trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCMS.java 2007-06-03 19:48:21 UTC
(rev 7380)
@@ -45,7 +45,7 @@
import org.jboss.portal.common.invocation.InvocationHandler;
import org.jboss.portal.common.net.URLNavigator;
import org.jboss.portal.common.net.URLVisitor;
-import org.jboss.portal.common.util.XML;
+import org.jboss.portal.common.xml.XMLTools;
import org.jboss.portal.common.io.IOTools;
import org.jboss.portal.jems.as.JNDI;
import org.jboss.portal.identity.User;
@@ -345,7 +345,7 @@
Element copy = (Element)doc.importNode(config, true);
doc.removeChild(doc.getDocumentElement());
doc.appendChild(copy);
- String result = XML.toString(doc);
+ String result = XMLTools.toString(doc);
log.debug("Jackrabbit configuration : " + result);
//
Modified:
trunk/cms/src/main/org/jboss/portal/test/cms/commands/AbstractCommandTestCase.java
===================================================================
---
trunk/cms/src/main/org/jboss/portal/test/cms/commands/AbstractCommandTestCase.java 2007-06-03
19:44:21 UTC (rev 7379)
+++
trunk/cms/src/main/org/jboss/portal/test/cms/commands/AbstractCommandTestCase.java 2007-06-03
19:48:21 UTC (rev 7380)
@@ -25,7 +25,7 @@
import org.jboss.portal.cms.impl.jcr.JCRCMS;
import org.jboss.portal.common.util.CLResourceLoader;
import org.jboss.portal.common.util.LoaderResource;
-import org.jboss.portal.common.util.XML;
+import org.jboss.portal.common.xml.XMLTools;
import org.jboss.portal.test.cms.AbstractCMSTestCase;
import org.w3c.dom.Document;
@@ -55,7 +55,7 @@
super.setUp();
LoaderResource res = new
CLResourceLoader().getResource("jcr/repository.xml");
- Document config =
res.asDocument(XML.getDocumentBuilderFactory().newDocumentBuilder());
+ Document config =
res.asDocument(XMLTools.getDocumentBuilderFactory().newDocumentBuilder());
service = new JCRCMS();
service.setDoChecking(true);
Modified: trunk/common/src/main/org/jboss/portal/common/util/LoaderResource.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/util/LoaderResource.java 2007-06-03
19:44:21 UTC (rev 7379)
+++ trunk/common/src/main/org/jboss/portal/common/util/LoaderResource.java 2007-06-03
19:48:21 UTC (rev 7380)
@@ -26,6 +26,7 @@
import org.xml.sax.SAXException;
import org.apache.log4j.Logger;
import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.common.xml.XMLTools;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.ParserConfigurationException;
@@ -116,9 +117,9 @@
Properties props;
if (xml)
{
- DocumentBuilder builder =
XML.getDocumentBuilderFactory().newDocumentBuilder();
+ DocumentBuilder builder =
XMLTools.getDocumentBuilderFactory().newDocumentBuilder();
Document doc = asDocument(builder);
- props = XML.loadXMLProperties(doc);
+ props = XMLTools.loadXMLProperties(doc);
}
else
{
Deleted: trunk/common/src/main/org/jboss/portal/common/util/NoSuchElementException.java
===================================================================
---
trunk/common/src/main/org/jboss/portal/common/util/NoSuchElementException.java 2007-06-03
19:44:21 UTC (rev 7379)
+++
trunk/common/src/main/org/jboss/portal/common/util/NoSuchElementException.java 2007-06-03
19:48:21 UTC (rev 7380)
@@ -1,52 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.common.util;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class NoSuchElementException extends RuntimeException
-{
- /** The serialVersionUID */
- private static final long serialVersionUID = -393378187931491442L;
-
- public NoSuchElementException()
- {
- }
-
- public NoSuchElementException(String message)
- {
- super(message);
- }
-
- public NoSuchElementException(String message, Throwable cause)
- {
- super(message, cause);
- }
-
- public NoSuchElementException(Throwable cause)
- {
- super(cause);
- }
-}
Deleted: trunk/common/src/main/org/jboss/portal/common/util/TooManyElementException.java
===================================================================
---
trunk/common/src/main/org/jboss/portal/common/util/TooManyElementException.java 2007-06-03
19:44:21 UTC (rev 7379)
+++
trunk/common/src/main/org/jboss/portal/common/util/TooManyElementException.java 2007-06-03
19:48:21 UTC (rev 7380)
@@ -1,52 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.common.util;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class TooManyElementException extends RuntimeException
-{
- /** The serialVersionUID */
- private static final long serialVersionUID = -2381186243988987102L;
-
- public TooManyElementException()
- {
- }
-
- public TooManyElementException(String message)
- {
- super(message);
- }
-
- public TooManyElementException(String message, Throwable cause)
- {
- super(message, cause);
- }
-
- public TooManyElementException(Throwable cause)
- {
- super(cause);
- }
-}
Deleted: trunk/common/src/main/org/jboss/portal/common/util/XML.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/util/XML.java 2007-06-03 19:44:21 UTC
(rev 7379)
+++ trunk/common/src/main/org/jboss/portal/common/util/XML.java 2007-06-03 19:48:21 UTC
(rev 7380)
@@ -1,409 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.common.util;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Result;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-
-/**
- * Utilities for dealing with XML.
- *
- * @author <a href="mailto:mholzner@novell.com">Martin Holzner</a>
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class XML
-{
-
- /** Namespace URI for XML lang. */
- public static final String XML_LANG_NAMESPACE_URI =
"http://www.w3.org/XML/1998/namespace";
-
- /** Document builder factory. */
- private static final DocumentBuilderFactory buildFactory =
DocumentBuilderFactory.newInstance();
-
- /** Transformer factory. */
- private static final TransformerFactory transformerFactory =
TransformerFactory.newInstance();
-
- /** Default output format which is : no xml declaration, no document type, indent. */
- private static Properties DEFAULT_FORMAT = createFormat(true, false, true,
"utf-8");
-
- /** . */
- public static final String PARAM_YES = "yes";
-
- /** . */
- public static final String PARAM_NO = "no";
-
- /** . */
- public static final String ATTRIB_OMIT_XML_DECLARATION =
"omit-xml-declaration";
-
- /** . */
- public static final String ATTRIB_CDATA_SECTION_ELEMENTS =
"cdata-section-elements";
-
- /** . */
- public static final String ATTRIB_METHOD = "method";
-
- /** . */
- public static final String ATTRIB_INDENT = "indent";
-
- /** . */
- public static final String ATTRIB_HREF = "href";
-
- /** . */
- public static final String DIRECTIVE_IMPORT = "xsl:import";
-
- /** . */
- public static final String DIRECTIVE_INCLUDE = "xsl:include";
-
- /** . */
- public static final boolean DEFAULT_NAMESPACE_AWARE = true;
-
- /** . */
- public static final boolean DEFAULT_VALIDATION = false;
-
- /** prevent instantiation */
- private XML()
- {
- }
-
- /** Return the builder factory. */
- public static DocumentBuilderFactory getDocumentBuilderFactory()
- {
- return buildFactory;
- }
-
- /**
- *
- */
- private static Properties createFormat(boolean omitXMLDeclaration, boolean standalone,
boolean indented, String encoding)
- {
- Properties format = new Properties();
- format.setProperty(OutputKeys.OMIT_XML_DECLARATION, omitXMLDeclaration ?
"yes" : "no");
- format.setProperty(OutputKeys.STANDALONE, standalone ? "yes" :
"no");
- format.setProperty(OutputKeys.INDENT, indented ? "yes" :
"no");
- format.setProperty(OutputKeys.ENCODING, encoding);
- return format;
- }
-
- /**
- *
- */
- public static String toString(Document doc, boolean omitXMLDeclaration, boolean
standalone, boolean indented, String encoding) throws TransformerException
- {
- Properties format = createFormat(omitXMLDeclaration, standalone, indented,
encoding);
- return toString(doc, format);
- }
-
- /**
- * Serialize the document with the default format : - No XML declaration - Indented -
Encoding is UTF-8
- *
- * @see #toString(Document,Properties)
- */
- public static String toString(Document doc) throws TransformerException
- {
- return toString(doc, DEFAULT_FORMAT);
- }
-
- /** @see #toString(Document) */
- public static String toString(Element element) throws ParserConfigurationException,
TransformerException
- {
- return toString(element, DEFAULT_FORMAT);
- }
-
- /** Converts an element to a String representation. */
- private static String toString(Element element, Properties properties) throws
ParserConfigurationException, TransformerException
- {
- Document doc = buildFactory.newDocumentBuilder().newDocument();
- element = (Element)doc.importNode(element, true);
- doc.appendChild(element);
- return toString(doc, properties);
- }
-
- /** Converts an document to a String representation. */
- private static String toString(Document doc, Properties format) throws
TransformerException
- {
- Transformer transformer = transformerFactory.newTransformer();
- transformer.setOutputProperties(format);
- StringWriter writer = new StringWriter();
- Source source = new DOMSource(doc);
- Result result = new StreamResult(writer);
- transformer.transform(source, result);
- return writer.toString();
- }
-
- /** Parse a string into a document. */
- public static Document toDocument(String text) throws ParserConfigurationException,
SAXException, IOException
- {
- DocumentBuilder builder = buildFactory.newDocumentBuilder();
- StringReader reader = new StringReader(text);
- InputSource source = new InputSource();
- source.setCharacterStream(reader);
- return builder.parse(source);
- }
-
- /** Parse a string into an element. */
- public static Element toElement(String text) throws ParserConfigurationException,
SAXException, IOException
- {
- Document doc = toDocument(text);
- return doc.getDocumentElement();
- }
-
- public static Document toDocument(Element element) throws
ParserConfigurationException, SAXException, IOException
- {
- if (element == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- Document doc = buildFactory.newDocumentBuilder().newDocument();
- element = (Element)doc.importNode(element, true);
- doc.appendChild(element);
- return doc;
- }
-
- /**
- * Perform trimming by default
- *
- * @param element
- * @return
- * @throws IllegalArgumentException
- * @see #asString(org.w3c.dom.Element,boolean)
- */
- public static String asString(Element element) throws IllegalArgumentException
- {
- return asString(element, true);
- }
-
- /**
- * Get the element's content as a string.
- *
- * @param element the container
- * @param trim true if text should be trimmed before returning result
- * @throws IllegalArgumentException if the element content is mixed or null
- */
- public static String asString(Element element, boolean trim) throws
IllegalArgumentException
- {
- if (element == null)
- {
- throw new IllegalArgumentException("No null element allowed");
- }
-
- //
- StringBuffer buffer = new StringBuffer();
- NodeList children = element.getChildNodes();
- for (int i = 0; i < children.getLength(); i++)
- {
- Node child = children.item(i);
- switch (child.getNodeType())
- {
- case Node.CDATA_SECTION_NODE:
- case Node.TEXT_NODE:
- buffer.append(((Text)child).getData());
- break;
- case Node.ELEMENT_NODE:
- throw new IllegalArgumentException("Mixed content not
allowed");
- default:
- break;
- }
- }
- String result = buffer.toString();
- if (trim)
- {
- result = result.trim();
- }
- return result;
- }
-
- /**
- * Return the optional unique child of an element.
- *
- * @param element the parent element
- * @param strict true if the element must be present
- * @return the child element or null if it does not exist and strict is false
- * @throws IllegalArgumentException if an argument is null
- * @throws NoSuchElementException if strict is true and the element is not present
- * @throws TooManyElementException if more than one element is found
- */
- public static Element getUniqueChild(Element element, boolean strict) throws
IllegalArgumentException,
- NoSuchElementException, TooManyElementException
- {
- if (element == null)
- {
- throw new IllegalArgumentException("No element specified");
- }
- Element childElt = null;
- NodeList list = element.getChildNodes();
- for (int i = 0; i < list.getLength(); i++)
- {
- Node childNode = list.item(i);
- if (childNode instanceof Element)
- {
- if (childElt == null)
- {
- childElt = (Element)childNode;
- }
- else
- {
- throw new TooManyElementException("More than one child element for
element " + element.getNodeName());
- }
- }
- }
- if (strict && childElt == null)
- {
- throw new NoSuchElementException("No child element for element " +
element.getNodeName());
- }
- return childElt;
- }
-
- /**
- * Return an optional child of an element with the specified name.
- *
- * @param element the parent element
- * @param name the child name
- * @param strict if the child must be present
- * @return the child element or null if it does not exist and strict is set to false
- * @throws IllegalArgumentException if an argument is null
- * @throws NoSuchElementException if strict is true and the element is not present
- * @throws TooManyElementException if more than one element is found
- */
- public static Element getUniqueChild(Element element, String name, boolean strict)
throws IllegalArgumentException,
- NoSuchElementException, TooManyElementException
- {
- List list = getChildren(element, name);
- switch (list.size())
- {
- case 0:
- if (strict)
- {
- throw new NoSuchElementException("Missing child " + name +
" of element " + element.getNodeName());
- }
- else
- {
- return null;
- }
- case 1:
- return (Element)list.get(0);
- default:
- throw new TooManyElementException("Too many children for element "
+ element.getNodeName());
- }
- }
-
- /**
- * Return an iterator for all the children of the given element having the specified
name.
- *
- * @param element the parent element
- * @param name the child names
- * @return an iterator for the designated elements
- * @throws IllegalArgumentException if the element is null or the name is null
- */
- public static Iterator getChildrenIterator(Element element, String name) throws
IllegalArgumentException
- {
- return getChildren(element, name).iterator();
- }
-
- /**
- * Return all the children of the given element having the specified name. The
collection object can be modified.
- *
- * @param element the parent element
- * @param name the child names
- * @return a list of elements
- * @throws IllegalArgumentException if the element is null or the name is null
- */
- public static List getChildren(Element element, String name) throws
IllegalArgumentException
- {
- if (element == null)
- {
- throw new IllegalArgumentException("No element found");
- }
- if (name == null)
- {
- throw new IllegalArgumentException("No name specified");
- }
- ArrayList result = new ArrayList();
- NodeList list = element.getChildNodes();
- for (int i = 0; i < list.getLength(); i++)
- {
- Node node = list.item(i);
- if (node.getNodeType() == Node.ELEMENT_NODE)
- {
- Element childElt = (Element)node;
- if (childElt.getTagName().equals(name))
- {
- result.add(childElt);
- }
- }
- }
- return result;
- }
-
- public static Properties loadXMLProperties(Element propertiesElt)
- {
- if (propertiesElt == null)
- {
- throw new IllegalArgumentException();
- }
- Properties props = new Properties();
- for (Iterator i = XML.getChildren(propertiesElt, "entry").iterator();
i.hasNext();)
- {
- Element entryElt = (Element)i.next();
- String key = entryElt.getAttribute("key");
- String value = XML.asString(entryElt);
- props.put(key, value);
- }
- return props;
- }
-
- public static Properties loadXMLProperties(Document doc)
- {
- if (doc == null)
- {
- throw new IllegalArgumentException();
- }
- return loadXMLProperties(doc.getDocumentElement());
- }
-
-}
Copied: trunk/common/src/main/org/jboss/portal/common/xml/NoSuchElementException.java
(from rev 7371,
trunk/common/src/main/org/jboss/portal/common/util/NoSuchElementException.java)
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/xml/NoSuchElementException.java
(rev 0)
+++
trunk/common/src/main/org/jboss/portal/common/xml/NoSuchElementException.java 2007-06-03
19:48:21 UTC (rev 7380)
@@ -0,0 +1,52 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.common.xml;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class NoSuchElementException extends RuntimeException
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -393378187931491442L;
+
+ public NoSuchElementException()
+ {
+ }
+
+ public NoSuchElementException(String message)
+ {
+ super(message);
+ }
+
+ public NoSuchElementException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public NoSuchElementException(Throwable cause)
+ {
+ super(cause);
+ }
+}
Property changes on:
trunk/common/src/main/org/jboss/portal/common/xml/NoSuchElementException.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/common/src/main/org/jboss/portal/common/xml/TooManyElementException.java
(from rev 7371,
trunk/common/src/main/org/jboss/portal/common/util/TooManyElementException.java)
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/xml/TooManyElementException.java
(rev 0)
+++
trunk/common/src/main/org/jboss/portal/common/xml/TooManyElementException.java 2007-06-03
19:48:21 UTC (rev 7380)
@@ -0,0 +1,52 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.common.xml;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class TooManyElementException extends RuntimeException
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -2381186243988987102L;
+
+ public TooManyElementException()
+ {
+ }
+
+ public TooManyElementException(String message)
+ {
+ super(message);
+ }
+
+ public TooManyElementException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public TooManyElementException(Throwable cause)
+ {
+ super(cause);
+ }
+}
Property changes on:
trunk/common/src/main/org/jboss/portal/common/xml/TooManyElementException.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/common/src/main/org/jboss/portal/common/xml/XMLTools.java (from rev 7371,
trunk/common/src/main/org/jboss/portal/common/util/XML.java)
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/xml/XMLTools.java
(rev 0)
+++ trunk/common/src/main/org/jboss/portal/common/xml/XMLTools.java 2007-06-03 19:48:21
UTC (rev 7380)
@@ -0,0 +1,409 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.common.xml;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * Utilities for dealing with XML.
+ *
+ * @author <a href="mailto:mholzner@novell.com">Martin Holzner</a>
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class XMLTools
+{
+
+ /** Namespace URI for XML lang. */
+ public static final String XML_LANG_NAMESPACE_URI =
"http://www.w3.org/XML/1998/namespace";
+
+ /** Document builder factory. */
+ private static final DocumentBuilderFactory buildFactory =
DocumentBuilderFactory.newInstance();
+
+ /** Transformer factory. */
+ private static final TransformerFactory transformerFactory =
TransformerFactory.newInstance();
+
+ /** Default output format which is : no xml declaration, no document type, indent. */
+ private static Properties DEFAULT_FORMAT = createFormat(true, false, true,
"utf-8");
+
+ /** . */
+ public static final String PARAM_YES = "yes";
+
+ /** . */
+ public static final String PARAM_NO = "no";
+
+ /** . */
+ public static final String ATTRIB_OMIT_XML_DECLARATION =
"omit-xml-declaration";
+
+ /** . */
+ public static final String ATTRIB_CDATA_SECTION_ELEMENTS =
"cdata-section-elements";
+
+ /** . */
+ public static final String ATTRIB_METHOD = "method";
+
+ /** . */
+ public static final String ATTRIB_INDENT = "indent";
+
+ /** . */
+ public static final String ATTRIB_HREF = "href";
+
+ /** . */
+ public static final String DIRECTIVE_IMPORT = "xsl:import";
+
+ /** . */
+ public static final String DIRECTIVE_INCLUDE = "xsl:include";
+
+ /** . */
+ public static final boolean DEFAULT_NAMESPACE_AWARE = true;
+
+ /** . */
+ public static final boolean DEFAULT_VALIDATION = false;
+
+ /** prevent instantiation */
+ private XMLTools()
+ {
+ }
+
+ /** Return the builder factory. */
+ public static DocumentBuilderFactory getDocumentBuilderFactory()
+ {
+ return buildFactory;
+ }
+
+ /**
+ *
+ */
+ private static Properties createFormat(boolean omitXMLDeclaration, boolean standalone,
boolean indented, String encoding)
+ {
+ Properties format = new Properties();
+ format.setProperty(OutputKeys.OMIT_XML_DECLARATION, omitXMLDeclaration ?
"yes" : "no");
+ format.setProperty(OutputKeys.STANDALONE, standalone ? "yes" :
"no");
+ format.setProperty(OutputKeys.INDENT, indented ? "yes" :
"no");
+ format.setProperty(OutputKeys.ENCODING, encoding);
+ return format;
+ }
+
+ /**
+ *
+ */
+ public static String toString(Document doc, boolean omitXMLDeclaration, boolean
standalone, boolean indented, String encoding) throws TransformerException
+ {
+ Properties format = createFormat(omitXMLDeclaration, standalone, indented,
encoding);
+ return toString(doc, format);
+ }
+
+ /**
+ * Serialize the document with the default format : - No XML declaration - Indented -
Encoding is UTF-8
+ *
+ * @see #toString(Document,Properties)
+ */
+ public static String toString(Document doc) throws TransformerException
+ {
+ return toString(doc, DEFAULT_FORMAT);
+ }
+
+ /** @see #toString(Document) */
+ public static String toString(Element element) throws ParserConfigurationException,
TransformerException
+ {
+ return toString(element, DEFAULT_FORMAT);
+ }
+
+ /** Converts an element to a String representation. */
+ private static String toString(Element element, Properties properties) throws
ParserConfigurationException, TransformerException
+ {
+ Document doc = buildFactory.newDocumentBuilder().newDocument();
+ element = (Element)doc.importNode(element, true);
+ doc.appendChild(element);
+ return toString(doc, properties);
+ }
+
+ /** Converts an document to a String representation. */
+ private static String toString(Document doc, Properties format) throws
TransformerException
+ {
+ Transformer transformer = transformerFactory.newTransformer();
+ transformer.setOutputProperties(format);
+ StringWriter writer = new StringWriter();
+ Source source = new DOMSource(doc);
+ Result result = new StreamResult(writer);
+ transformer.transform(source, result);
+ return writer.toString();
+ }
+
+ /** Parse a string into a document. */
+ public static Document toDocument(String text) throws ParserConfigurationException,
SAXException, IOException
+ {
+ DocumentBuilder builder = buildFactory.newDocumentBuilder();
+ StringReader reader = new StringReader(text);
+ InputSource source = new InputSource();
+ source.setCharacterStream(reader);
+ return builder.parse(source);
+ }
+
+ /** Parse a string into an element. */
+ public static Element toElement(String text) throws ParserConfigurationException,
SAXException, IOException
+ {
+ Document doc = toDocument(text);
+ return doc.getDocumentElement();
+ }
+
+ public static Document toDocument(Element element) throws
ParserConfigurationException, SAXException, IOException
+ {
+ if (element == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ Document doc = buildFactory.newDocumentBuilder().newDocument();
+ element = (Element)doc.importNode(element, true);
+ doc.appendChild(element);
+ return doc;
+ }
+
+ /**
+ * Perform trimming by default
+ *
+ * @param element
+ * @return
+ * @throws IllegalArgumentException
+ * @see #asString(org.w3c.dom.Element,boolean)
+ */
+ public static String asString(Element element) throws IllegalArgumentException
+ {
+ return asString(element, true);
+ }
+
+ /**
+ * Get the element's content as a string.
+ *
+ * @param element the container
+ * @param trim true if text should be trimmed before returning result
+ * @throws IllegalArgumentException if the element content is mixed or null
+ */
+ public static String asString(Element element, boolean trim) throws
IllegalArgumentException
+ {
+ if (element == null)
+ {
+ throw new IllegalArgumentException("No null element allowed");
+ }
+
+ //
+ StringBuffer buffer = new StringBuffer();
+ NodeList children = element.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++)
+ {
+ Node child = children.item(i);
+ switch (child.getNodeType())
+ {
+ case Node.CDATA_SECTION_NODE:
+ case Node.TEXT_NODE:
+ buffer.append(((Text)child).getData());
+ break;
+ case Node.ELEMENT_NODE:
+ throw new IllegalArgumentException("Mixed content not
allowed");
+ default:
+ break;
+ }
+ }
+ String result = buffer.toString();
+ if (trim)
+ {
+ result = result.trim();
+ }
+ return result;
+ }
+
+ /**
+ * Return the optional unique child of an element.
+ *
+ * @param element the parent element
+ * @param strict true if the element must be present
+ * @return the child element or null if it does not exist and strict is false
+ * @throws IllegalArgumentException if an argument is null
+ * @throws NoSuchElementException if strict is true and the element is not present
+ * @throws TooManyElementException if more than one element is found
+ */
+ public static Element getUniqueChild(Element element, boolean strict) throws
IllegalArgumentException,
+ NoSuchElementException, TooManyElementException
+ {
+ if (element == null)
+ {
+ throw new IllegalArgumentException("No element specified");
+ }
+ Element childElt = null;
+ NodeList list = element.getChildNodes();
+ for (int i = 0; i < list.getLength(); i++)
+ {
+ Node childNode = list.item(i);
+ if (childNode instanceof Element)
+ {
+ if (childElt == null)
+ {
+ childElt = (Element)childNode;
+ }
+ else
+ {
+ throw new TooManyElementException("More than one child element for
element " + element.getNodeName());
+ }
+ }
+ }
+ if (strict && childElt == null)
+ {
+ throw new NoSuchElementException("No child element for element " +
element.getNodeName());
+ }
+ return childElt;
+ }
+
+ /**
+ * Return an optional child of an element with the specified name.
+ *
+ * @param element the parent element
+ * @param name the child name
+ * @param strict if the child must be present
+ * @return the child element or null if it does not exist and strict is set to false
+ * @throws IllegalArgumentException if an argument is null
+ * @throws NoSuchElementException if strict is true and the element is not present
+ * @throws TooManyElementException if more than one element is found
+ */
+ public static Element getUniqueChild(Element element, String name, boolean strict)
throws IllegalArgumentException,
+ NoSuchElementException, TooManyElementException
+ {
+ List list = getChildren(element, name);
+ switch (list.size())
+ {
+ case 0:
+ if (strict)
+ {
+ throw new NoSuchElementException("Missing child " + name +
" of element " + element.getNodeName());
+ }
+ else
+ {
+ return null;
+ }
+ case 1:
+ return (Element)list.get(0);
+ default:
+ throw new TooManyElementException("Too many children for element "
+ element.getNodeName());
+ }
+ }
+
+ /**
+ * Return an iterator for all the children of the given element having the specified
name.
+ *
+ * @param element the parent element
+ * @param name the child names
+ * @return an iterator for the designated elements
+ * @throws IllegalArgumentException if the element is null or the name is null
+ */
+ public static Iterator getChildrenIterator(Element element, String name) throws
IllegalArgumentException
+ {
+ return getChildren(element, name).iterator();
+ }
+
+ /**
+ * Return all the children of the given element having the specified name. The
collection object can be modified.
+ *
+ * @param element the parent element
+ * @param name the child names
+ * @return a list of elements
+ * @throws IllegalArgumentException if the element is null or the name is null
+ */
+ public static List getChildren(Element element, String name) throws
IllegalArgumentException
+ {
+ if (element == null)
+ {
+ throw new IllegalArgumentException("No element found");
+ }
+ if (name == null)
+ {
+ throw new IllegalArgumentException("No name specified");
+ }
+ ArrayList result = new ArrayList();
+ NodeList list = element.getChildNodes();
+ for (int i = 0; i < list.getLength(); i++)
+ {
+ Node node = list.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE)
+ {
+ Element childElt = (Element)node;
+ if (childElt.getTagName().equals(name))
+ {
+ result.add(childElt);
+ }
+ }
+ }
+ return result;
+ }
+
+ public static Properties loadXMLProperties(Element propertiesElt)
+ {
+ if (propertiesElt == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ Properties props = new Properties();
+ for (Iterator i = getChildren(propertiesElt, "entry").iterator();
i.hasNext();)
+ {
+ Element entryElt = (Element)i.next();
+ String key = entryElt.getAttribute("key");
+ String value = asString(entryElt);
+ props.put(key, value);
+ }
+ return props;
+ }
+
+ public static Properties loadXMLProperties(Document doc)
+ {
+ if (doc == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ return loadXMLProperties(doc.getDocumentElement());
+ }
+
+}
Property changes on: trunk/common/src/main/org/jboss/portal/common/xml/XMLTools.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified:
trunk/core/src/main/org/jboss/portal/core/deployment/jboss/ObjectDeployment.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/deployment/jboss/ObjectDeployment.java 2007-06-03
19:44:21 UTC (rev 7379)
+++
trunk/core/src/main/org/jboss/portal/core/deployment/jboss/ObjectDeployment.java 2007-06-03
19:48:21 UTC (rev 7380)
@@ -24,7 +24,7 @@
import org.jboss.deployment.DeploymentException;
import org.jboss.logging.Logger;
-import org.jboss.portal.common.util.XML;
+import org.jboss.portal.common.xml.XMLTools;
import org.jboss.portal.common.xml.NullEntityResolver;
import org.jboss.portal.common.io.IOTools;
import org.jboss.portal.core.model.portal.metadata.PortalObjectMetaData;
@@ -110,7 +110,7 @@
// Load xml document
log.debug("Loading portal metadata from " + url);
in = IOTools.safeBufferedWrapper(url.openStream());
- DocumentBuilder builder = XML.getDocumentBuilderFactory().newDocumentBuilder();
+ DocumentBuilder builder =
XMLTools.getDocumentBuilderFactory().newDocumentBuilder();
EntityResolver entityResolver = factory.getPortalObjectEntityResolver();
if (entityResolver == null)
{
@@ -126,7 +126,7 @@
Element deploymentsElt = doc.getDocumentElement();
// Build the list of deployment units
- List deploymentElts = XML.getChildren(deploymentsElt, "deployment");
+ List deploymentElts = XMLTools.getChildren(deploymentsElt,
"deployment");
units = new ArrayList(deploymentElts.size());
for (int i = 0; i < deploymentElts.size(); i++)
{
@@ -134,15 +134,15 @@
Unit unit = new Unit();
//
- Element parentRefElt = XML.getUniqueChild(deploymentElt,
"parent-ref", false);
- unit.parentRef = parentRefElt == null ? null :
PortalObjectId.parse(XML.asString(parentRefElt), PortalObjectPath.LEGACY_FORMAT);
+ Element parentRefElt = XMLTools.getUniqueChild(deploymentElt,
"parent-ref", false);
+ unit.parentRef = parentRefElt == null ? null :
PortalObjectId.parse(XMLTools.asString(parentRefElt), PortalObjectPath.LEGACY_FORMAT);
//
- Element ifExistsElt = XML.getUniqueChild(deploymentElt,
"if-exists", false);
+ Element ifExistsElt = XMLTools.getUniqueChild(deploymentElt,
"if-exists", false);
unit.ifExists = KEEP_IF_EXISTS;
if (ifExistsElt != null)
{
- String ifExists = XML.asString(ifExistsElt);
+ String ifExists = XMLTools.asString(ifExistsElt);
if ("overwrite".equals(ifExists))
{
unit.ifExists = OVERWRITE_IF_EXISTS;
@@ -157,16 +157,16 @@
Object metaData = null;
//
- Element metaDataElt = XML.getUniqueChild(deploymentElt, "portal",
false);
+ Element metaDataElt = XMLTools.getUniqueChild(deploymentElt,
"portal", false);
if (metaDataElt == null)
{
- metaDataElt = XML.getUniqueChild(deploymentElt, "page", false);
+ metaDataElt = XMLTools.getUniqueChild(deploymentElt, "page",
false);
if (metaDataElt == null)
{
- metaDataElt = XML.getUniqueChild(deploymentElt, "window",
false);
+ metaDataElt = XMLTools.getUniqueChild(deploymentElt,
"window", false);
if (metaDataElt == null)
{
- metaDataElt = XML.getUniqueChild(deploymentElt, "context",
false);
+ metaDataElt = XMLTools.getUniqueChild(deploymentElt,
"context", false);
}
}
}
Modified:
trunk/core/src/main/org/jboss/portal/core/deployment/jboss/PortletAppDeployment.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/deployment/jboss/PortletAppDeployment.java 2007-06-03
19:44:21 UTC (rev 7379)
+++
trunk/core/src/main/org/jboss/portal/core/deployment/jboss/PortletAppDeployment.java 2007-06-03
19:48:21 UTC (rev 7380)
@@ -26,7 +26,7 @@
import org.jboss.mx.util.MBeanProxyExt;
import org.jboss.portal.common.net.URLNavigator;
import org.jboss.portal.common.net.URLVisitor;
-import org.jboss.portal.common.util.XML;
+import org.jboss.portal.common.xml.XMLTools;
import org.jboss.portal.common.value.StringValue;
import org.jboss.portal.common.value.Value;
import org.jboss.portal.common.xml.NullEntityResolver;
@@ -174,7 +174,7 @@
try
{
in = IOTools.safeBufferedWrapper(url.openStream());
- DocumentBuilder builder =
XML.getDocumentBuilderFactory().newDocumentBuilder();
+ DocumentBuilder builder =
XMLTools.getDocumentBuilderFactory().newDocumentBuilder();
EntityResolver entityResolver =
factory.getPortalObjectEntityResolver();
if (entityResolver == null)
{
@@ -188,12 +188,12 @@
builder.setEntityResolver(entityResolver);
Document doc = builder.parse(in);
Element deploymentsElt = doc.getDocumentElement();
- for (Iterator i = XML.getChildrenIterator(deploymentsElt,
"deployment"); i.hasNext();)
+ for (Iterator i = XMLTools.getChildrenIterator(deploymentsElt,
"deployment"); i.hasNext();)
{
Element deploymentElt = (Element)i.next();
//
- Element instanceElt = XML.getUniqueChild(deploymentElt,
"instance", false);
+ Element instanceElt = XMLTools.getUniqueChild(deploymentElt,
"instance", false);
//
if (instanceElt != null)
@@ -236,7 +236,7 @@
// Output legacy file on the console
if (metaDataCtxs.size() > 0)
{
- DocumentBuilder builder =
XML.getDocumentBuilderFactory().newDocumentBuilder();
+ DocumentBuilder builder =
XMLTools.getDocumentBuilderFactory().newDocumentBuilder();
Document doc = builder.newDocument();
Element deployments =
(Element)doc.appendChild(doc.createElement("deployments"));
for (int i = 0; i < metaDataCtxs.size(); i++)
@@ -250,7 +250,7 @@
Element portletRefElt =
(Element)instanceElt.appendChild(doc.createElement("portlet-ref"));
portletRefElt.appendChild(doc.createTextNode(instanceMD.getPortletRef()));
}
- String migratedContent = XML.toString(doc, false, true, true,
"utf-8");
+ String migratedContent = XMLTools.toString(doc, false, true, true,
"utf-8");
log.info("These instances have been found in -object.xml, you should put
them in the file " + webInfPath + "/portlet-instances.xml");
log.info(migratedContent);
}
@@ -262,7 +262,7 @@
in =
IOTools.safeBufferedWrapper(pwa.getServletContext().getResourceAsStream("/WEB-INF/portlet-instances.xml"));
if (in != null)
{
- DocumentBuilder builder =
XML.getDocumentBuilderFactory().newDocumentBuilder();
+ DocumentBuilder builder =
XMLTools.getDocumentBuilderFactory().newDocumentBuilder();
EntityResolver entityResolver =
factory.getPortletInstancesEntityResolver();
if (entityResolver == null)
{
@@ -277,22 +277,22 @@
Document doc = builder.parse(in);
//
- for (Iterator i = XML.getChildrenIterator(doc.getDocumentElement(),
"deployment"); i.hasNext();)
+ for (Iterator i = XMLTools.getChildrenIterator(doc.getDocumentElement(),
"deployment"); i.hasNext();)
{
Element deploymentElt = (Element)i.next();
//
- Element instanceElt = XML.getUniqueChild(deploymentElt,
"instance", true);
+ Element instanceElt = XMLTools.getUniqueChild(deploymentElt,
"instance", true);
//
InstanceMetaData metaData =
InstanceMetaData.buildMetaData(instanceElt);
//
- Element ifExistsElt = XML.getUniqueChild(deploymentElt,
"if-exists", false);
+ Element ifExistsElt = XMLTools.getUniqueChild(deploymentElt,
"if-exists", false);
int ifExists = KEEP_IF_EXISTS;
if (ifExistsElt != null)
{
- String tmp = XML.asString(ifExistsElt);
+ String tmp = XMLTools.asString(ifExistsElt);
if ("overwrite".equals(tmp))
{
ifExists = OVERWRITE_IF_EXISTS;
Modified:
trunk/core/src/main/org/jboss/portal/core/model/instance/metadata/InstanceMetaData.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/instance/metadata/InstanceMetaData.java 2007-06-03
19:44:21 UTC (rev 7379)
+++
trunk/core/src/main/org/jboss/portal/core/model/instance/metadata/InstanceMetaData.java 2007-06-03
19:48:21 UTC (rev 7380)
@@ -23,7 +23,7 @@
package org.jboss.portal.core.model.instance.metadata;
import org.apache.log4j.Logger;
-import org.jboss.portal.common.util.XML;
+import org.jboss.portal.common.xml.XMLTools;
import org.jboss.portal.portlet.impl.jsr168.metadata.PreferenceMetaData;
import org.jboss.portal.security.metadata.SecurityConstraintsMetaData;
import org.w3c.dom.Element;
@@ -103,12 +103,12 @@
public static InstanceMetaData buildMetaData(Element instanceElt)
{
- String instanceName = XML.asString(XML.getUniqueChild(instanceElt,
"instance-id", true));
- String componentRef = XML.asString(XML.getUniqueChild(instanceElt,
"portlet-ref", true));
+ String instanceName = XMLTools.asString(XMLTools.getUniqueChild(instanceElt,
"instance-id", true));
+ String componentRef = XMLTools.asString(XMLTools.getUniqueChild(instanceElt,
"portlet-ref", true));
// Configure preferences override
PreferencesMetaData preferencesMD = new PreferencesMetaData();
- Element preferencesElt = XML.getUniqueChild(instanceElt, "preferences",
false);
+ Element preferencesElt = XMLTools.getUniqueChild(instanceElt,
"preferences", false);
if (preferencesElt != null)
{
for (Iterator i = buildPreferencesMetaData(preferencesElt).values().iterator();
i.hasNext();)
@@ -125,7 +125,7 @@
instanceMD.setPreferences(preferencesMD);
// Add the security constraints
- Element securityConstraintElt = XML.getUniqueChild(instanceElt,
"security-constraint", false);
+ Element securityConstraintElt = XMLTools.getUniqueChild(instanceElt,
"security-constraint", false);
if (securityConstraintElt != null)
{
SecurityConstraintsMetaData securityConstraintsMD =
SecurityConstraintsMetaData.buildSecurityConstraintMetaData(securityConstraintElt);
@@ -142,12 +142,12 @@
*/
public static InstanceMetaData buildLegacyMetaData(Element instanceElt, String pwaId)
{
- Element instanceNameElt = XML.getUniqueChild(instanceElt,
"instance-name", true);
- Element componentRefElt = XML.getUniqueChild(instanceElt,
"component-ref", true);
+ Element instanceNameElt = XMLTools.getUniqueChild(instanceElt,
"instance-name", true);
+ Element componentRefElt = XMLTools.getUniqueChild(instanceElt,
"component-ref", true);
//
- String instanceName = XML.asString(instanceNameElt);
- String componentRef = XML.asString(componentRefElt);
+ String instanceName = XMLTools.asString(instanceNameElt);
+ String componentRef = XMLTools.asString(componentRefElt);
//
int dotIndex = componentRef.indexOf('.');
@@ -183,7 +183,7 @@
// Configure preferences
PreferencesMetaData preferencesMD = new PreferencesMetaData();
- Element preferencesElt = XML.getUniqueChild(instanceElt,
"preferences", false);
+ Element preferencesElt = XMLTools.getUniqueChild(instanceElt,
"preferences", false);
if (preferencesElt != null)
{
for (Iterator j =
InstanceMetaData.buildPreferencesMetaData(preferencesElt).values().iterator();
j.hasNext();)
@@ -194,7 +194,7 @@
}
// Add the security constraints
- Element securityConstraintElt = XML.getUniqueChild(instanceElt,
"security-constraint", false);
+ Element securityConstraintElt = XMLTools.getUniqueChild(instanceElt,
"security-constraint", false);
if (securityConstraintElt != null)
{
SecurityConstraintsMetaData securityConstraintsMD =
SecurityConstraintsMetaData.buildSecurityConstraintMetaData(securityConstraintElt);
@@ -214,7 +214,7 @@
public static Map buildPreferencesMetaData(Element portletPreferencesElt)
{
Map preferences = new HashMap();
- for (Iterator i = XML.getChildrenIterator(portletPreferencesElt,
"preference"); i.hasNext();)
+ for (Iterator i = XMLTools.getChildrenIterator(portletPreferencesElt,
"preference"); i.hasNext();)
{
Element preferenceElt = (Element)i.next();
PreferenceMetaData preference = buildPreferenceMetaData(preferenceElt);
@@ -226,17 +226,17 @@
public static PreferenceMetaData buildPreferenceMetaData(Element preferenceElt)
{
PreferenceMetaData preferenceMD = new PreferenceMetaData();
- List valuesElt = XML.getChildren(preferenceElt, "value");
+ List valuesElt = XMLTools.getChildren(preferenceElt, "value");
String[] values = new String[valuesElt.size()];
for (int i = 0; i < valuesElt.size(); i++)
{
- values[i] = XML.asString((Element)valuesElt.get(i));
+ values[i] = XMLTools.asString((Element)valuesElt.get(i));
}
- Element readOnlyElt = XML.getUniqueChild(preferenceElt, "read-only",
false);
+ Element readOnlyElt = XMLTools.getUniqueChild(preferenceElt, "read-only",
false);
boolean readOnly = false;
if (readOnlyElt != null)
{
- String value = XML.asString(readOnlyElt);
+ String value = XMLTools.asString(readOnlyElt);
if ("true".equals(value))
{
readOnly = true;
@@ -255,7 +255,7 @@
{
readOnly = false;
}
- preferenceMD.setName(XML.asString(XML.getUniqueChild(preferenceElt,
"name", true)));
+ preferenceMD.setName(XMLTools.asString(XMLTools.getUniqueChild(preferenceElt,
"name", true)));
preferenceMD.setReadOnly(readOnly);
preferenceMD.setValues(values);
return preferenceMD;
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/ContextMetaData.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/ContextMetaData.java 2007-06-03
19:44:21 UTC (rev 7379)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/ContextMetaData.java 2007-06-03
19:48:21 UTC (rev 7380)
@@ -23,10 +23,9 @@
package org.jboss.portal.core.model.portal.metadata;
import org.jboss.portal.core.model.portal.PortalObject;
-import org.jboss.portal.core.model.portal.PortalContainer;
import org.jboss.portal.core.model.portal.PortalObjectContainer;
import org.jboss.portal.core.model.content.spi.ContentProviderRegistry;
-import org.jboss.portal.common.util.XML;
+import org.jboss.portal.common.xml.XMLTools;
import org.w3c.dom.Element;
import java.util.List;
@@ -64,7 +63,7 @@
ContextMetaData contextMD = new ContextMetaData();
//
- String contextName = XML.asString(XML.getUniqueChild(contextElt,
"context-name", true));
+ String contextName = XMLTools.asString(XMLTools.getUniqueChild(contextElt,
"context-name", true));
if (contextName != null && contextName.indexOf(".") < 0
&& contextName.indexOf(":") < 0)
{
contextMD.setName(contextName);
@@ -76,7 +75,7 @@
}
//
- List pageElts = XML.getChildren(contextElt, "portal");
+ List pageElts = XMLTools.getChildren(contextElt, "portal");
for (int i = 0; i < pageElts.size(); i++)
{
Element portalElt = (Element)pageElts.get(i);
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PageMetaData.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PageMetaData.java 2007-06-03
19:44:21 UTC (rev 7379)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PageMetaData.java 2007-06-03
19:48:21 UTC (rev 7380)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.core.model.portal.metadata;
-import org.jboss.portal.common.util.XML;
+import org.jboss.portal.common.xml.XMLTools;
import org.jboss.portal.core.model.portal.PageContainer;
import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.content.spi.ContentProviderRegistry;
@@ -57,11 +57,11 @@
PageMetaData pageMD = new PageMetaData();
//
- String pageName = XML.asString(XML.getUniqueChild(pageElt, "page-name",
true));
+ String pageName = XMLTools.asString(XMLTools.getUniqueChild(pageElt,
"page-name", true));
pageMD.setName(pageName);
// Add the contained getWindows
- List windowElts = XML.getChildren(pageElt, "window");
+ List windowElts = XMLTools.getChildren(pageElt, "window");
for (int j = 0; j < windowElts.size(); j++)
{
Element windowElt = (Element)windowElts.get(j);
@@ -77,7 +77,7 @@
}
// Add the contained pages
- List pageElts = XML.getChildren(pageElt, "page");
+ List pageElts = XMLTools.getChildren(pageElt, "page");
for (int j = 0; j < pageElts.size(); j++)
{
Element childPageElt = (Element)pageElts.get(j);
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalMetaData.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalMetaData.java 2007-06-03
19:44:21 UTC (rev 7379)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalMetaData.java 2007-06-03
19:48:21 UTC (rev 7380)
@@ -24,7 +24,7 @@
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
-import org.jboss.portal.common.util.XML;
+import org.jboss.portal.common.xml.XMLTools;
import org.jboss.portal.core.model.portal.PortalContainer;
import org.jboss.portal.core.model.portal.Portal;
import org.jboss.portal.core.model.portal.PortalObject;
@@ -115,7 +115,7 @@
PortalMetaData portalMD = new PortalMetaData();
//
- String portalName = XML.asString(XML.getUniqueChild(portalElt,
"portal-name", true));
+ String portalName = XMLTools.asString(XMLTools.getUniqueChild(portalElt,
"portal-name", true));
if (portalName != null && portalName.length() > 0 &&
portalName.indexOf(".") < 0)
{
portalMD.setName(portalName);
@@ -127,21 +127,21 @@
}
//
- Element supportedModesElt = XML.getUniqueChild(portalElt,
"supported-modes", false);
+ Element supportedModesElt = XMLTools.getUniqueChild(portalElt,
"supported-modes", false);
if (supportedModesElt != null)
{
buildSupportedModes(portalMD, supportedModesElt);
}
//
- Element supportedWindowStatesElt = XML.getUniqueChild(portalElt,
"supported-window-states", false);
+ Element supportedWindowStatesElt = XMLTools.getUniqueChild(portalElt,
"supported-window-states", false);
if (supportedWindowStatesElt != null)
{
buildSupportedWindowStates(portalMD, supportedWindowStatesElt);
}
//
- List pageElts = XML.getChildren(portalElt, "page");
+ List pageElts = XMLTools.getChildren(portalElt, "page");
for (int i = 0; i < pageElts.size(); i++)
{
Element pageElt = (Element)pageElts.get(i);
@@ -156,11 +156,11 @@
public static void buildSupportedModes(PortalMetaData portalMD, Element
supportedModesElt)
{
ModesMetaData modesMD = portalMD.getModes();
- List modeElts = XML.getChildren(supportedModesElt, "mode");
+ List modeElts = XMLTools.getChildren(supportedModesElt, "mode");
for (int i = 0; i < modeElts.size(); i++)
{
Element modeElt = (Element)modeElts.get(i);
- String modeAsString = XML.asString(modeElt);
+ String modeAsString = XMLTools.asString(modeElt);
modesMD.add(modeAsString);
}
}
@@ -168,11 +168,11 @@
public static void buildSupportedWindowStates(PortalMetaData portalMD, Element
supportedWindowStatesElt)
{
WindowStatesMetaData windowStateMD = portalMD.getWindowStates();
- List windowState = XML.getChildren(supportedWindowStatesElt,
"window-state");
+ List windowState = XMLTools.getChildren(supportedWindowStatesElt,
"window-state");
for (int i = 0; i < windowState.size(); i++)
{
Element windowStateElt = (Element)windowState.get(i);
- String windowStateAsString = XML.asString(windowStateElt);
+ String windowStateAsString = XMLTools.asString(windowStateElt);
windowStateMD.add(windowStateAsString);
}
}
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalObjectMetaData.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalObjectMetaData.java 2007-06-03
19:44:21 UTC (rev 7379)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalObjectMetaData.java 2007-06-03
19:48:21 UTC (rev 7380)
@@ -24,7 +24,7 @@
import org.jboss.logging.Logger;
import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.common.util.XML;
+import org.jboss.portal.common.xml.XMLTools;
import org.jboss.portal.core.model.content.spi.ContentProviderRegistry;
import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.PortalObjectContainer;
@@ -221,7 +221,7 @@
if (portalObjectMD != null)
{
// Add the security constraints
- Element securityConstraintElt = XML.getUniqueChild(portalObjectElt,
"security-constraint", false);
+ Element securityConstraintElt = XMLTools.getUniqueChild(portalObjectElt,
"security-constraint", false);
if (securityConstraintElt != null)
{
SecurityConstraintsMetaData securityConstraintsMD =
SecurityConstraintsMetaData.buildSecurityConstraintMetaData(securityConstraintElt);
@@ -229,14 +229,14 @@
}
// Configure properties
- Element propertiesElt = XML.getUniqueChild(portalObjectElt,
"properties", false);
+ Element propertiesElt = XMLTools.getUniqueChild(portalObjectElt,
"properties", false);
if (propertiesElt != null)
{
buildPropertiesMetaData(portalObjectMD, propertiesElt);
}
// Configure listener
- Element listenerElt = XML.getUniqueChild(portalObjectElt, "listener",
false);
+ Element listenerElt = XMLTools.getUniqueChild(portalObjectElt,
"listener", false);
if (listenerElt != null)
{
buildListenerMetaData(portalObjectMD, listenerElt);
@@ -247,14 +247,14 @@
public static void buildPropertiesMetaData(PortalObjectMetaData portalObjectMD,
Element propertiesElt)
{
- List propertyElts = XML.getChildren(propertiesElt, "property");
+ List propertyElts = XMLTools.getChildren(propertiesElt, "property");
for (int i = 0; i < propertyElts.size(); i++)
{
Element propertyElt = (Element)propertyElts.get(i);
- Element nameElt = XML.getUniqueChild(propertyElt, "name", true);
- Element valueElt = XML.getUniqueChild(propertyElt, "value", true);
- String name = XML.asString(nameElt);
- String value = XML.asString(valueElt);
+ Element nameElt = XMLTools.getUniqueChild(propertyElt, "name", true);
+ Element valueElt = XMLTools.getUniqueChild(propertyElt, "value",
true);
+ String name = XMLTools.asString(nameElt);
+ String value = XMLTools.asString(valueElt);
// log.debug("Found property " + name + " = " + value);
portalObjectMD.getProperties().put(name, value);
@@ -263,7 +263,7 @@
public static void buildListenerMetaData(PortalObjectMetaData portalObjectMD, Element
listenerElt)
{
- String listener = XML.asString(listenerElt);
+ String listener = XMLTools.asString(listenerElt);
portalObjectMD.setListener(listener);
}
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/WindowMetaData.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/WindowMetaData.java 2007-06-03
19:44:21 UTC (rev 7379)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/WindowMetaData.java 2007-06-03
19:48:21 UTC (rev 7380)
@@ -28,7 +28,7 @@
import org.jboss.portal.core.model.content.ContentType;
import org.jboss.portal.core.model.content.spi.ContentProviderRegistry;
import org.jboss.portal.theme.ThemeConstants;
-import org.jboss.portal.common.util.XML;
+import org.jboss.portal.common.xml.XMLTools;
import org.w3c.dom.Element;
/**
@@ -113,35 +113,35 @@
WindowMetaData windowMD = new WindowMetaData();
//
- String windowName = XML.asString(XML.getUniqueChild(windowElt,
"window-name", true));
+ String windowName = XMLTools.asString(XMLTools.getUniqueChild(windowElt,
"window-name", true));
windowMD.setName(windowName);
// Get coordinates
- String region = XML.asString(XML.getUniqueChild(windowElt, "region",
true));
+ String region = XMLTools.asString(XMLTools.getUniqueChild(windowElt,
"region", true));
windowMD.setRegion(region);
//
- int height = Integer.parseInt(XML.asString(XML.getUniqueChild(windowElt,
"height", true)));
+ int height = Integer.parseInt(XMLTools.asString(XMLTools.getUniqueChild(windowElt,
"height", true)));
windowMD.setOrder(height);
//
ContentType contentType;
String contentURI;
- Element instanceRefElt = XML.getUniqueChild(windowElt, "instance-ref",
false);
+ Element instanceRefElt = XMLTools.getUniqueChild(windowElt,
"instance-ref", false);
if (instanceRefElt != null)
{
contentType = ContentType.PORTLET;
- contentURI = XML.asString(instanceRefElt);
+ contentURI = XMLTools.asString(instanceRefElt);
}
else
{
- Element contentElt = XML.getUniqueChild(windowElt, "content", true);
- Element contentTypeElt = XML.getUniqueChild(contentElt,
"content-type", true);
- Element contentURIElt = XML.getUniqueChild(contentElt, "content-uri",
true);
+ Element contentElt = XMLTools.getUniqueChild(windowElt, "content",
true);
+ Element contentTypeElt = XMLTools.getUniqueChild(contentElt,
"content-type", true);
+ Element contentURIElt = XMLTools.getUniqueChild(contentElt,
"content-uri", true);
//
- contentType = ContentType.create(XML.asString(contentTypeElt));
- contentURI = XML.asString(contentURIElt);
+ contentType = ContentType.create(XMLTools.asString(contentTypeElt));
+ contentURI = XMLTools.asString(contentURIElt);
}
// Build content meta data
Modified:
trunk/security/src/main/org/jboss/portal/security/metadata/SecurityConstraintsMetaData.java
===================================================================
---
trunk/security/src/main/org/jboss/portal/security/metadata/SecurityConstraintsMetaData.java 2007-06-03
19:44:21 UTC (rev 7379)
+++
trunk/security/src/main/org/jboss/portal/security/metadata/SecurityConstraintsMetaData.java 2007-06-03
19:48:21 UTC (rev 7380)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.security.metadata;
-import org.jboss.portal.common.util.XML;
+import org.jboss.portal.common.xml.XMLTools;
import org.jboss.portal.security.RoleSecurityBinding;
import org.jboss.portal.security.SecurityConstants;
import org.w3c.dom.Element;
@@ -54,15 +54,15 @@
public static SecurityConstraintsMetaData buildSecurityConstraintMetaData(Element
securityConstraintElt)
{
SecurityConstraintsMetaData securityConstraint = new
SecurityConstraintsMetaData();
- for (Iterator i = XML.getChildren(securityConstraintElt,
"policy-permission").iterator(); i.hasNext();)
+ for (Iterator i = XMLTools.getChildren(securityConstraintElt,
"policy-permission").iterator(); i.hasNext();)
{
Element policyPermissionElt = (Element)i.next();
- Element uncheckedElt = XML.getUniqueChild(policyPermissionElt,
"unchecked", false);
+ Element uncheckedElt = XMLTools.getUniqueChild(policyPermissionElt,
"unchecked", false);
Set actionNames = new HashSet();
- for (Iterator j = XML.getChildren(policyPermissionElt,
"action-name").iterator(); j.hasNext();)
+ for (Iterator j = XMLTools.getChildren(policyPermissionElt,
"action-name").iterator(); j.hasNext();)
{
Element actionNameElt = (Element)j.next();
- String actionName = XML.asString(actionNameElt);
+ String actionName = XMLTools.asString(actionNameElt);
actionNames.add(actionName);
}
if (uncheckedElt != null)
@@ -72,10 +72,10 @@
}
else
{
- for (Iterator j = XML.getChildren(policyPermissionElt,
"role-name").iterator(); j.hasNext();)
+ for (Iterator j = XMLTools.getChildren(policyPermissionElt,
"role-name").iterator(); j.hasNext();)
{
Element roleNameElt = (Element)j.next();
- String roleName = XML.asString(roleNameElt);
+ String roleName = XMLTools.asString(roleNameElt);
RoleSecurityBinding binding = new RoleSecurityBinding(actionNames,
roleName);
securityConstraint.children.add(binding);
}
Modified: trunk/server/src/main/org/jboss/portal/server/deployment/PortalWebApp.java
===================================================================
--- trunk/server/src/main/org/jboss/portal/server/deployment/PortalWebApp.java 2007-06-03
19:44:21 UTC (rev 7379)
+++ trunk/server/src/main/org/jboss/portal/server/deployment/PortalWebApp.java 2007-06-03
19:48:21 UTC (rev 7380)
@@ -23,7 +23,7 @@
package org.jboss.portal.server.deployment;
import org.apache.log4j.Logger;
-import org.jboss.portal.common.util.XML;
+import org.jboss.portal.common.xml.XMLTools;
import org.jboss.portal.common.xml.NullEntityResolver;
import org.jboss.portal.common.io.IOTools;
import org.w3c.dom.Document;
@@ -193,10 +193,10 @@
if (descriptor != null)
{
Element jbossAppElt = descriptor.getDocumentElement();
- Element appNameElt = XML.getUniqueChild(jbossAppElt, "app-name",
false);
+ Element appNameElt = XMLTools.getUniqueChild(jbossAppElt, "app-name",
false);
if (appNameElt != null)
{
- id = XML.asString(appNameElt);
+ id = XMLTools.asString(appNameElt);
log.debug("Detected explicit app name = " + id + " for
application under path " + getContextPath());
}
}
@@ -216,7 +216,7 @@
in =
IOTools.safeBufferedWrapper(getServletContext().getResourceAsStream("/WEB-INF/jboss-app.xml"));
if (in != null)
{
- DocumentBuilder builder =
XML.getDocumentBuilderFactory().newDocumentBuilder();
+ DocumentBuilder builder =
XMLTools.getDocumentBuilderFactory().newDocumentBuilder();
if (jbossAppEntityResolver == null)
{
log.debug("Coult not obtain entity resolver for
jboss-app.xml");
Modified: trunk/server/src/main/org/jboss/portal/server/deployment/WebAppEnhancer.java
===================================================================
---
trunk/server/src/main/org/jboss/portal/server/deployment/WebAppEnhancer.java 2007-06-03
19:44:21 UTC (rev 7379)
+++
trunk/server/src/main/org/jboss/portal/server/deployment/WebAppEnhancer.java 2007-06-03
19:48:21 UTC (rev 7380)
@@ -23,7 +23,7 @@
package org.jboss.portal.server.deployment;
import org.jboss.mx.util.MBeanProxy;
-import org.jboss.portal.common.util.XML;
+import org.jboss.portal.common.xml.XMLTools;
import org.jboss.portal.server.config.ServerConfig;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -65,7 +65,7 @@
if (desc != null)
{
Element jbossAppElt = desc.getDocumentElement();
- for (Iterator i = XML.getChildren(jbossAppElt,
"service").iterator(); i.hasNext();)
+ for (Iterator i = XMLTools.getChildren(jbossAppElt,
"service").iterator(); i.hasNext();)
{
Element serviceElt = (Element)i.next();
@@ -73,12 +73,12 @@
log.debug("About to inject a service in the servlet context of "
+ pwa.getURL());
//
- Element serviceNameElt = XML.getUniqueChild(serviceElt,
"service-name", true);
- Element serviceClassElt = XML.getUniqueChild(serviceElt,
"service-class", true);
- Element serviceRefElt = XML.getUniqueChild(serviceElt,
"service-ref", true);
- String serviceName = XML.asString(serviceNameElt);
- String serviceClass = XML.asString(serviceClassElt);
- String serviceRef = XML.asString(serviceRefElt);
+ Element serviceNameElt = XMLTools.getUniqueChild(serviceElt,
"service-name", true);
+ Element serviceClassElt = XMLTools.getUniqueChild(serviceElt,
"service-class", true);
+ Element serviceRefElt = XMLTools.getUniqueChild(serviceElt,
"service-ref", true);
+ String serviceName = XMLTools.asString(serviceNameElt);
+ String serviceClass = XMLTools.asString(serviceClassElt);
+ String serviceRef = XMLTools.asString(serviceRefElt);
//
if (serviceRef.startsWith(":"))
Modified:
trunk/server/src/main/org/jboss/portal/server/impl/xml/EntityResolverService.java
===================================================================
---
trunk/server/src/main/org/jboss/portal/server/impl/xml/EntityResolverService.java 2007-06-03
19:44:21 UTC (rev 7379)
+++
trunk/server/src/main/org/jboss/portal/server/impl/xml/EntityResolverService.java 2007-06-03
19:48:21 UTC (rev 7380)
@@ -23,7 +23,7 @@
package org.jboss.portal.server.impl.xml;
import org.jboss.portal.jems.as.system.AbstractJBossService;
-import org.jboss.portal.common.util.XML;
+import org.jboss.portal.common.xml.XMLTools;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@@ -58,7 +58,7 @@
//
if (this.dtdMapping != null)
{
- dtdMappingProps = XML.loadXMLProperties(dtdMapping);
+ dtdMappingProps = XMLTools.loadXMLProperties(dtdMapping);
}
else
{
Modified: trunk/test/src/main/org/jboss/portal/test/framework/embedded/DSConfig.java
===================================================================
--- trunk/test/src/main/org/jboss/portal/test/framework/embedded/DSConfig.java 2007-06-03
19:44:21 UTC (rev 7379)
+++ trunk/test/src/main/org/jboss/portal/test/framework/embedded/DSConfig.java 2007-06-03
19:48:21 UTC (rev 7380)
@@ -23,7 +23,7 @@
package org.jboss.portal.test.framework.embedded;
-import org.jboss.portal.common.util.XML;
+import org.jboss.portal.common.xml.XMLTools;
import org.jboss.portal.common.test.MultiValuedTestParameterValue;
import org.jboss.portal.common.io.IOTools;
import org.w3c.dom.Document;
@@ -126,33 +126,33 @@
try
{
in = IOTools.safeBufferedWrapper(url.openStream());
- Document doc = XML.getDocumentBuilderFactory().newDocumentBuilder().parse(in);
- for (Iterator i = XML.getChildrenIterator(doc.getDocumentElement(),
"directory"); i.hasNext();)
+ Document doc =
XMLTools.getDocumentBuilderFactory().newDocumentBuilder().parse(in);
+ for (Iterator i = XMLTools.getChildrenIterator(doc.getDocumentElement(),
"directory"); i.hasNext();)
{
Element childElt = (Element)i.next();
- Element nm = XML.getUniqueChild(childElt, "directory-name", true);
- Element desc = XML.getUniqueChild(childElt, "description", true);
- Element config = XML.getUniqueChild(childElt, "config-file",
true);
- Element h = XML.getUniqueChild(childElt, "host", true);
- Element p = XML.getUniqueChild(childElt, "port", true);
- Element context = XML.getUniqueChild(childElt, "context-factory",
true);
- Element admin = XML.getUniqueChild(childElt, "admin-dn", true);
- Element password = XML.getUniqueChild(childElt, "admin-password",
true);
+ Element nm = XMLTools.getUniqueChild(childElt, "directory-name",
true);
+ Element desc = XMLTools.getUniqueChild(childElt, "description",
true);
+ Element config = XMLTools.getUniqueChild(childElt, "config-file",
true);
+ Element h = XMLTools.getUniqueChild(childElt, "host", true);
+ Element p = XMLTools.getUniqueChild(childElt, "port", true);
+ Element context = XMLTools.getUniqueChild(childElt,
"context-factory", true);
+ Element admin = XMLTools.getUniqueChild(childElt, "admin-dn",
true);
+ Element password = XMLTools.getUniqueChild(childElt,
"admin-password", true);
//Element embedded = XML.getUniqueChild(childElt, "use-embedded",
true);
- Element populate = XML.getUniqueChild(childElt, "populate-ldif",
true);
- Element cleanup = XML.getUniqueChild(childElt, "cleanup-dn",
true);
+ Element populate = XMLTools.getUniqueChild(childElt,
"populate-ldif", true);
+ Element cleanup = XMLTools.getUniqueChild(childElt, "cleanup-dn",
true);
- String name = XML.asString(nm);
- String description = XML.asString(desc);
- String configFile = XML.asString(config);
- String host = XML.asString(h);
- String port = XML.asString(p);
- String contextFactory = XML.asString(context);
- String adminDN = XML.asString(admin);
- String adminPassword = XML.asString(password);
+ String name = XMLTools.asString(nm);
+ String description = XMLTools.asString(desc);
+ String configFile = XMLTools.asString(config);
+ String host = XMLTools.asString(h);
+ String port = XMLTools.asString(p);
+ String contextFactory = XMLTools.asString(context);
+ String adminDN = XMLTools.asString(admin);
+ String adminPassword = XMLTools.asString(password);
//boolean embedd = XML.asString(embedded).equals("true");
- String populateLdif = XML.asString(populate);
- String cleanUpDN = XML.asString(cleanup);
+ String populateLdif = XMLTools.asString(populate);
+ String cleanUpDN = XMLTools.asString(cleanup);
DSConfig dsCfg = new DSConfig(
name,
Modified:
trunk/test/src/main/org/jboss/portal/test/framework/embedded/DataSourceSupport.java
===================================================================
---
trunk/test/src/main/org/jboss/portal/test/framework/embedded/DataSourceSupport.java 2007-06-03
19:44:21 UTC (rev 7379)
+++
trunk/test/src/main/org/jboss/portal/test/framework/embedded/DataSourceSupport.java 2007-06-03
19:48:21 UTC (rev 7380)
@@ -23,7 +23,7 @@
package org.jboss.portal.test.framework.embedded;
-import org.jboss.portal.common.util.XML;
+import org.jboss.portal.common.xml.XMLTools;
import org.jboss.portal.common.test.MultiValuedTestParameterValue;
import org.jboss.portal.common.io.IOTools;
import org.jboss.resource.adapter.jdbc.local.LocalTxDataSource;
@@ -268,29 +268,29 @@
try
{
in = IOTools.safeBufferedWrapper(url.openStream());
- Document doc =
XML.getDocumentBuilderFactory().newDocumentBuilder().parse(in);
- for (Iterator i = XML.getChildrenIterator(doc.getDocumentElement(),
"datasource"); i.hasNext();)
+ Document doc =
XMLTools.getDocumentBuilderFactory().newDocumentBuilder().parse(in);
+ for (Iterator i = XMLTools.getChildrenIterator(doc.getDocumentElement(),
"datasource"); i.hasNext();)
{
Element childElt = (Element)i.next();
// Parse the datasource name, taking in account the deprecated
display-name element
- Element nameElt = XML.getUniqueChild(childElt,
"datasource-name", false);
+ Element nameElt = XMLTools.getUniqueChild(childElt,
"datasource-name", false);
if (nameElt == null)
{
System.out.println("XML element datasource-name is not present,
trying deprecated display-name element instead, you should fix your
datasources.xml");
- nameElt = XML.getUniqueChild(childElt, "display-name",
true);
+ nameElt = XMLTools.getUniqueChild(childElt, "display-name",
true);
}
// Parse the rest of the configuration
- Element connectionURLElt = XML.getUniqueChild(childElt,
"connection-url", true);
- Element driverClassElt = XML.getUniqueChild(childElt,
"driver-class", true);
- Element userNameElt = XML.getUniqueChild(childElt, "user-name",
true);
- Element passwordElt = XML.getUniqueChild(childElt, "password",
true);
- String name = XML.asString(nameElt);
- String connectionURL = XML.asString(connectionURLElt);
- String driverClass = XML.asString(driverClassElt);
- String userName = XML.asString(userNameElt);
- String password = XML.asString(passwordElt);
+ Element connectionURLElt = XMLTools.getUniqueChild(childElt,
"connection-url", true);
+ Element driverClassElt = XMLTools.getUniqueChild(childElt,
"driver-class", true);
+ Element userNameElt = XMLTools.getUniqueChild(childElt,
"user-name", true);
+ Element passwordElt = XMLTools.getUniqueChild(childElt,
"password", true);
+ String name = XMLTools.asString(nameElt);
+ String connectionURL = XMLTools.asString(connectionURLElt);
+ String driverClass = XMLTools.asString(driverClassElt);
+ String userName = XMLTools.asString(userNameElt);
+ String password = XMLTools.asString(passwordElt);
Config dsCfg = new Config(
name,
connectionURL,
Modified:
trunk/test/src/main/org/jboss/portal/test/framework/embedded/HibernateSupport.java
===================================================================
---
trunk/test/src/main/org/jboss/portal/test/framework/embedded/HibernateSupport.java 2007-06-03
19:44:21 UTC (rev 7379)
+++
trunk/test/src/main/org/jboss/portal/test/framework/embedded/HibernateSupport.java 2007-06-03
19:48:21 UTC (rev 7380)
@@ -31,7 +31,7 @@
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Settings;
import org.hibernate.tool.hbm2ddl.SchemaExport;
-import org.jboss.portal.common.util.XML;
+import org.jboss.portal.common.xml.XMLTools;
import org.jboss.portal.common.io.IOTools;
import org.w3c.dom.Element;
import org.w3c.dom.Document;
@@ -351,27 +351,27 @@
try
{
in = IOTools.safeBufferedWrapper(url.openStream());
- Document doc = XML.getDocumentBuilderFactory().newDocumentBuilder().parse(in);
- for (Iterator i = XML.getChildrenIterator(doc.getDocumentElement(),
"configuration"); i.hasNext();)
+ Document doc =
XMLTools.getDocumentBuilderFactory().newDocumentBuilder().parse(in);
+ for (Iterator i = XMLTools.getChildrenIterator(doc.getDocumentElement(),
"configuration"); i.hasNext();)
{
Element childElt = (Element)i.next();
//
- Element configurationNameElt = XML.getUniqueChild(childElt,
"configuration-name", true);
- String configurationName = XML.asString(configurationNameElt);
+ Element configurationNameElt = XMLTools.getUniqueChild(childElt,
"configuration-name", true);
+ String configurationName = XMLTools.asString(configurationNameElt);
//
Map properties = new HashMap();
- Element propertiesElt = XML.getUniqueChild(childElt, "properties",
false);
+ Element propertiesElt = XMLTools.getUniqueChild(childElt,
"properties", false);
if (propertiesElt != null)
{
- for (Iterator j = XML.getChildrenIterator(propertiesElt,
"property");j.hasNext();)
+ for (Iterator j = XMLTools.getChildrenIterator(propertiesElt,
"property");j.hasNext();)
{
Element propertyElt = (Element)j.next();
- Element nameElt = XML.getUniqueChild(propertyElt, "name",
true);
- Element valueElt = XML.getUniqueChild(propertyElt, "value",
true);
- String name = XML.asString(nameElt);
- String value = XML.asString(valueElt);
+ Element nameElt = XMLTools.getUniqueChild(propertyElt,
"name", true);
+ Element valueElt = XMLTools.getUniqueChild(propertyElt,
"value", true);
+ String name = XMLTools.asString(nameElt);
+ String value = XMLTools.asString(valueElt);
properties.put(name, value);
}
}
Modified:
trunk/widget/src/main/org/jboss/portal/widget/google/provider/GGWidgetBuilder.java
===================================================================
---
trunk/widget/src/main/org/jboss/portal/widget/google/provider/GGWidgetBuilder.java 2007-06-03
19:44:21 UTC (rev 7379)
+++
trunk/widget/src/main/org/jboss/portal/widget/google/provider/GGWidgetBuilder.java 2007-06-03
19:48:21 UTC (rev 7380)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.widget.google.provider;
-import org.jboss.portal.common.util.XML;
+import org.jboss.portal.common.xml.XMLTools;
import org.jboss.portal.common.i18n.LocalizedString;
import org.jboss.portal.common.net.URLTools;
import org.jboss.portal.common.concurrent.loader.ObjectLoader;
@@ -90,7 +90,7 @@
public GGWidget create() throws Exception
{
- DocumentBuilderFactory factory = XML.getDocumentBuilderFactory();
+ DocumentBuilderFactory factory = XMLTools.getDocumentBuilderFactory();
DocumentBuilder builder = factory.newDocumentBuilder();
byte[] bytes = obtainWidget(url);
if (bytes == null)
@@ -102,7 +102,7 @@
//
Collection tmp = null;
- Iterator userPrefsEltIterator = XML.getChildrenIterator(moduleElt,
"UserPref");
+ Iterator userPrefsEltIterator = XMLTools.getChildrenIterator(moduleElt,
"UserPref");
while (userPrefsEltIterator.hasNext())
{
Element userPref = (Element)userPrefsEltIterator.next();
@@ -140,7 +140,7 @@
break;
case DataType.ENUM:
Collection values = new ArrayList();
- for (Iterator i = XML.getChildrenIterator(userPref,
"EnumValue");i.hasNext();)
+ for (Iterator i = XMLTools.getChildrenIterator(userPref,
"EnumValue");i.hasNext();)
{
Element enumValueElt = (Element)i.next();
String valueAttr = enumValueElt.getAttribute("value");
@@ -179,7 +179,7 @@
}
//
- Iterator modulePrefsEltIterator = XML.getChildrenIterator(moduleElt,
"ModulePrefs");
+ Iterator modulePrefsEltIterator = XMLTools.getChildrenIterator(moduleElt,
"ModulePrefs");
if (modulePrefsEltIterator.hasNext())
{
Element modulePrefsElt = (Element)modulePrefsEltIterator.next();