diff --git a/ccm-core/lib/jdxslt.jar b/ccm-core/etc/libsNolongerInUse/jdxslt.jar similarity index 100% rename from ccm-core/lib/jdxslt.jar rename to ccm-core/etc/libsNolongerInUse/jdxslt.jar diff --git a/ccm-core/src/com/arsdigita/templating/XSLTemplate.java b/ccm-core/src/com/arsdigita/templating/XSLTemplate.java index cf97aeaea..5913163dc 100755 --- a/ccm-core/src/com/arsdigita/templating/XSLTemplate.java +++ b/ccm-core/src/com/arsdigita/templating/XSLTemplate.java @@ -50,8 +50,8 @@ import org.apache.log4j.Logger; import org.w3c.dom.Document; /** - * A class for loading, caching and generally managing XSL templates - * and transformers. + * A class for loading, caching and generally managing XSL templates and + * transformers. * * @author Dan Berrange * @version $Id: XSLTemplate.java 1942 2009-05-29 07:53:23Z terry $ @@ -317,8 +317,10 @@ public final class XSLTemplate { * critical, because XSL files should always use * relative imports, which implies all imported files * will be in the same URL space. + * * @param os the output stream to write the ZIP to * @param base the base directory in which the files will extract + * @throws java.io.IOException */ public void toZIP(OutputStream os, String base) @@ -358,14 +360,17 @@ public final class XSLTemplate { private static class Log4JErrorListener implements ErrorListener { + @Override public void warning(TransformerException e) throws TransformerException { log(Level.WARN, e); } + @Override public void error(TransformerException e) throws TransformerException { log(Level.ERROR, e); } + @Override public void fatalError(TransformerException e) throws TransformerException { log(Level.FATAL, e); diff --git a/ccm-core/src/com/arsdigita/util/config/JavaPropertyLoader.java.nolongerInUse b/ccm-core/src/com/arsdigita/util/config/JavaPropertyLoader.java.nolongerInUse deleted file mode 100755 index f5267d02a..000000000 --- a/ccm-core/src/com/arsdigita/util/config/JavaPropertyLoader.java.nolongerInUse +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2003-2004 Red Hat Inc. All Rights Reserved. - * - * This library 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 library 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 library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -package com.arsdigita.util.config; - -import com.arsdigita.util.Assert; -import com.arsdigita.util.JavaPropertyReader; -import com.arsdigita.util.parameter.Parameter; -import com.arsdigita.util.parameter.ParameterLoader; -import com.arsdigita.util.parameter.ParameterValue; -import java.util.Properties; -import org.apache.log4j.Logger; - -/** - * @deprecated Use {@link com.arsdigita.util.JavaPropertyReader} - * instead - */ -public class JavaPropertyLoader extends JavaPropertyReader - implements ParameterLoader { - public final static String versionId = - "$Id: JavaPropertyLoader.java 287 2005-02-22 00:29:02Z sskracic $" + - "$Author: sskracic $" + - "$DateTime: 2004/08/16 18:10:38 $"; - - private static final Logger s_log = Logger.getLogger - (JavaPropertyLoader.class); - - private final Properties m_props; - - /** - * Constructs a parameter loader that uses props. - * - * @param props The Properties object that stores - * property values; it cannot be null - */ - public JavaPropertyLoader(final Properties props) { - super(props); - - m_props = props; - } - - public final ParameterValue load(final Parameter param) { - if (s_log.isDebugEnabled()) { - s_log.debug("Loading " + param + " from " + this); - } - - Assert.exists(param, Parameter.class); - - final String key = param.getName(); - - if (m_props.containsKey(key)) { - final ParameterValue value = new ParameterValue(); - - value.setObject(param.read(this, value.getErrors())); - - return value; - } else { - return null; - } - } - - /** - * Returns a String representation of this object. - * - * @return super.toString() + ":" + properties.size() - */ - public String toString() { - return super.toString() + ":" + m_props.size(); - } -} diff --git a/ccm-core/src/com/arsdigita/xml/Document.java b/ccm-core/src/com/arsdigita/xml/Document.java index bca552e3f..5c24efdcd 100755 --- a/ccm-core/src/com/arsdigita/xml/Document.java +++ b/ccm-core/src/com/arsdigita/xml/Document.java @@ -48,15 +48,11 @@ import java.io.UnsupportedEncodingException; * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * @author Patrick McNeill - * @version ACS 4.5a * @since ACS 4.5a + * @version $Id: Document.java 287 2005-02-22 00:29:02Z sskracic $ */ public class Document { - public static final String versionId = - "$Id: Document.java 287 2005-02-22 00:29:02Z sskracic $" - + " by $Author: sskracic $, " - + "$DateTime: 2004/08/16 18:10:38 $"; private static final Logger s_log = Logger.getLogger(Document.class.getName()); /** @@ -121,6 +117,7 @@ public class Document { s_builder.setNamespaceAware(true); s_db = new ThreadLocal() { + @Override public Object initialValue() { try { return s_builder.newDocumentBuilder(); @@ -140,6 +137,8 @@ public class Document { /** * Creates a new Document class with no root element. + * + * @throws javax.xml.parsers.ParserConfigurationException */ public Document() throws ParserConfigurationException { DocumentBuilder db = (DocumentBuilder) s_db.get(); @@ -165,6 +164,7 @@ public class Document { * Creates a new Document class with the given root element. * * @param rootNode the element to use as the root node + * @throws javax.xml.parsers.ParserConfigurationException */ public Document(Element rootNode) throws ParserConfigurationException { DocumentBuilder db = (DocumentBuilder) s_db.get(); @@ -179,8 +179,12 @@ public class Document { } /** - * Creates a document from the passed in string that should - * be properly formatted XML + * Creates a document from the passed in string that should + * be properly formatted XML + * + * @param xmlString + * @throws javax.xml.parsers.ParserConfigurationException + * @throws org.xml.sax.SAXException */ public Document(String xmlString) throws ParserConfigurationException, org.xml.sax.SAXException { @@ -345,6 +349,7 @@ public class Document { * without additional indenting. * @return a String representation of this. */ + @Override public String toString() { return toString(m_document, false); } diff --git a/ccm-core/src/com/arsdigita/xml/Element.java b/ccm-core/src/com/arsdigita/xml/Element.java index 64bd8f21d..bf9819683 100755 --- a/ccm-core/src/com/arsdigita/xml/Element.java +++ b/ccm-core/src/com/arsdigita/xml/Element.java @@ -188,6 +188,9 @@ public class Element { /** * Copies the passed in element and all of its children to a new * Element. + * + * @param copyFrom + * @return */ public Element newChildElement(Element copyFrom) { Assert.exists(copyFrom, Element.class); @@ -205,7 +208,11 @@ public class Element { /** * Copies the passed in element and all of its children to a new - * Element using the passed-in name + * Element using the passed-in name. + * + * @param name + * @param copyFrom + * @return */ public Element newChildElement(String name, Element copyFrom) { if (m_doc == null) { @@ -221,7 +228,12 @@ public class Element { /** * Copies the passed in element and all of its children to a new - * Element using the passed-in name + * Element using the passed-in name. + * + * @param name + * @param uri + * @param copyFrom + * @return */ public Element newChildElement(String name, String uri, Element copyFrom) { if (m_doc == null) { @@ -324,6 +336,8 @@ public class Element { /** * Returns the concatenation of all the text in all child nodes * of the current element. + * + * @return */ public String getText() { StringBuilder result = new StringBuilder(); diff --git a/ccm-core/src/com/arsdigita/xml/FactoriesSetup.java b/ccm-core/src/com/arsdigita/xml/FactoriesSetup.java index a935c37ab..de6c552f6 100755 --- a/ccm-core/src/com/arsdigita/xml/FactoriesSetup.java +++ b/ccm-core/src/com/arsdigita/xml/FactoriesSetup.java @@ -59,6 +59,30 @@ import org.apache.log4j.Logger; * modified by * @author pboy */ + + +// ///////////////////////////////////////////////////////////////////////////// +// +// NOTE: The ServiceProviderInterface as implementet by the JaxP factory +// class newInstance() follow a specific search order as explained above. +// The META-INF directory MUST be found via ContextClasspathLoader, i.e. must +// be located in WEB-INF/classes/META-INF or in a jar-file at WEB-INF/lib (or +// in one of the locations searched by common class loader which is not useful) +// Therefore is is not possible to switch a factory implementation after +// deployment at runtime or webapp startup, because both locations are not meant +// to be changed after deployment of an application. +// The alternative instantiation using newInstance(ImplementationClass, +// LoaderClass) is no replacement, because developers may use newInstance() +// anyway and probably get an unintended implementation. +// +// Therefore we must engage a quick'nd dirty way to achieve the goal and mess +// around with the WEB-INF/classes directory, until a better solution will be +// available. +// +// ///////////////////////////////////////////////////////////////////////////// + + + public class FactoriesSetup { private static final Logger s_log = Logger.getLogger @@ -71,12 +95,12 @@ public class FactoriesSetup { * method which modifies the system.property. */ public static void setupFactories() { - setupFactory("javax.xml.parsers.DocumentBuilderFactory", - XMLConfig.getConfig().getDOMBuilderFactoryClassname()); - setupFactory("javax.xml.parsers.SAXParserFactory", - XMLConfig.getConfig().getSAXParserFactoryClassname()); - setupFactory("javax.xml.transform.TransformerFactory", - XMLConfig.getConfig().getXSLTransformerFactoryClassname()); + // setupFactory("javax.xml.parsers.DocumentBuilderFactory", + // XMLConfig.getConfig().getDOMBuilderFactoryClassname()); + // setupFactory("javax.xml.parsers.SAXParserFactory", + // XMLConfig.getConfig().getSAXParserFactoryClassname()); + // setupFactory("javax.xml.transform.TransformerFactory", + // XMLConfig.getConfig().getXSLTransformerFactoryClassname()); } /* ************ internal worker methods section ************ */ @@ -97,8 +121,8 @@ public class FactoriesSetup { if (s_log.isInfoEnabled()) { s_log.info("Setting " + name + " to " + impl); } - System.setProperty(name, - impl); + // System.setProperty(name, + // impl); } else { if (s_log.isInfoEnabled()) { s_log.info("Leaving " + name + " as " + @@ -106,28 +130,5 @@ public class FactoriesSetup { } } } - /** - * Actually unfinished work. - * - * ToDo: Use an alternative Factory constructor of javax.xml. ... (e.g. - * DocumentBuilderFactory) which directly accepts a classname and a - * class loader, so we do not depend on a system wide configuration. - * - * @param impl the value of the class name of the factory to use - */ -// static void setupDomBuilderFactory( String implClass) { -// if (implClass != null) { - // if (s_log.isInfoEnabled()) { - // s_log.info("Setting " + name + " to " + impl); - // } - // System.setProperty(name, - // impl); -// } else { - // if (s_log.isInfoEnabled()) { - // s_log.info("Leaving " + name + " as " + - // System.getProperty(name)); - // } -// } -// } } diff --git a/ccm-core/src/com/arsdigita/xml/XML.java b/ccm-core/src/com/arsdigita/xml/XML.java index 5e9cb9d99..8d049781c 100755 --- a/ccm-core/src/com/arsdigita/xml/XML.java +++ b/ccm-core/src/com/arsdigita/xml/XML.java @@ -42,7 +42,7 @@ import org.xml.sax.helpers.DefaultHandler; import org.apache.log4j.Logger; /** - * Provides a set of helper methods for dealing with XML, + * Provides a set of static helper methods for dealing with XML, * including file parsing & object -> string serialization */ public class XML { @@ -51,13 +51,16 @@ public class XML { // private static XMLConfig s_config; - private static Map s_formatters = new HashMap(); + private static final Map s_formatters = new HashMap(); static { s_log.debug("Static initalizer starting..."); s_formatters.put(Date.class, new DateTimeFormatter()); s_log.debug("Static initalizer finished."); } + /** + * Constructor. All methods are static, no initialization required. + */ private XML() {} /** @@ -74,6 +77,8 @@ public class XML { /** * Registers a formatter for serializing objects of a * class to a String suitable for XML output. + * @param klass + * @param formatter */ public static void registerFormatter(Class klass, Formatter formatter) { @@ -82,6 +87,7 @@ public class XML { /** * Unregisters a formatter against a class. + * @param klass */ public static void unregisterFormatter(Class klass) { s_formatters.remove(klass); @@ -98,6 +104,7 @@ public class XML { /** * Looks for the best matching formatter. + * * @param klass the class to find a formatter for * @return the formatter, or null if non is registered */ @@ -115,7 +122,10 @@ public class XML { * matching registered Formatter implementation. Looks * for a formatter registered against the object's * class first, then its superclass, etc. If no formatter - * is found, uses the toString() method + * is found, uses the toString() method. + * + * @param value + * @return */ public static String format(Object value) { if (value == null) { @@ -219,11 +229,14 @@ public class XML { /** * Prints the skeleton structure of the element to the supplied print * writer. + * @param element + * @param writer **/ public static void toSkeleton(final Element element, final PrintWriter writer) { XML.traverse(element, 0, new Action() { + @Override public void apply(Element elem, int level) { final String padding = " "; for (int ii=0; ii + + --> @@ -92,7 +94,7 @@ - +