CCM NG: Reverted some changes from revision r5078
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@5083 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
8209244a33
commit
d5c7c63a8c
|
|
@ -155,7 +155,8 @@ public abstract class BaseDispatcherServlet extends HttpServlet
|
|||
File file = new File(getServletContext().getRealPath(
|
||||
"/WEB-INF/web.xml"));
|
||||
// all we care about is the welcome-file-list element
|
||||
SAXParserFactory spf = SAXParserFactory.class.getDeclaredConstructor().newInstance();
|
||||
SAXParserFactory spf = SAXParserFactory
|
||||
.newInstance();
|
||||
spf.setValidating(false);
|
||||
SAXParser parser = spf.newSAXParser();
|
||||
parser.parse(file, new WebXMLReader());
|
||||
|
|
@ -165,8 +166,6 @@ public abstract class BaseDispatcherServlet extends HttpServlet
|
|||
LOGGER.error("error in init", pce);
|
||||
} catch (IOException ioe) {
|
||||
LOGGER.error("error in init", ioe);
|
||||
} catch (IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException e) {
|
||||
LOGGER.error(e);
|
||||
}
|
||||
// default to index.jsp, index.html
|
||||
if (m_welcomeFiles.isEmpty()) {
|
||||
|
|
|
|||
|
|
@ -98,7 +98,8 @@ public final class XSLTemplate {
|
|||
try {
|
||||
LOGGER.debug("Getting new templates object");
|
||||
|
||||
final TransformerFactory factory = TransformerFactory.class.getDeclaredConstructor().newInstance();
|
||||
final TransformerFactory factory = TransformerFactory
|
||||
.newInstance();
|
||||
factory.setURIResolver(resolver);
|
||||
factory.setErrorListener(listener);
|
||||
|
||||
|
|
@ -110,9 +111,6 @@ public final class XSLTemplate {
|
|||
throw new WrappedTransformerException(ex);
|
||||
} catch (TransformerException ex) {
|
||||
throw new WrappedTransformerException(ex);
|
||||
} catch (IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException e) {
|
||||
LOGGER.error(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
// List contains each include/import URL found in the style sheet
|
||||
|
|
|
|||
|
|
@ -51,14 +51,18 @@ public class SystemInformationTab extends LayoutPanel {
|
|||
|
||||
final SegmentedPanel panel = new SegmentedPanel();
|
||||
|
||||
panel.addSegment(new Label(GlobalizationUtil.globalize("ui.admin.sysinfo.appinfo")),
|
||||
new PropertySheet(new CCMSysInfoPropertySheetModelBuilder()));
|
||||
panel.addSegment(new Label(GlobalizationUtil.globalize(
|
||||
"ui.admin.sysinfo.appinfo")),
|
||||
new PropertySheet(
|
||||
new CCMSysInfoPropertySheetModelBuilder()));
|
||||
|
||||
panel.addSegment(new Label(GlobalizationUtil.globalize(
|
||||
"ui.admin.sysinfo.java_system_properties")),
|
||||
new PropertySheet(new JavaSystemPropertiesSheetModelBuilder()));
|
||||
new PropertySheet(
|
||||
new JavaSystemPropertiesSheetModelBuilder()));
|
||||
|
||||
panel.addSegment(new Label(GlobalizationUtil.globalize("ui.admin.sysinfo.xml_config")),
|
||||
panel.addSegment(new Label(GlobalizationUtil.globalize(
|
||||
"ui.admin.sysinfo.xml_config")),
|
||||
new PropertySheet(new XMLConfigSheetModelBuilder()));
|
||||
|
||||
setRight(panel);
|
||||
|
|
@ -73,7 +77,8 @@ public class SystemInformationTab extends LayoutPanel {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PropertySheetModel makeModel(final PropertySheet sheet, final PageState state) {
|
||||
public PropertySheetModel makeModel(final PropertySheet sheet,
|
||||
final PageState state) {
|
||||
return new CCMSysInfoPropertySheetModel();
|
||||
}
|
||||
|
||||
|
|
@ -130,7 +135,8 @@ public class SystemInformationTab extends LayoutPanel {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PropertySheetModel makeModel(final PropertySheet sheet, final PageState state) {
|
||||
public PropertySheetModel makeModel(final PropertySheet sheet,
|
||||
final PageState state) {
|
||||
return new JavaSystemPropertiesSheetModel();
|
||||
}
|
||||
|
||||
|
|
@ -182,7 +188,8 @@ public class SystemInformationTab extends LayoutPanel {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PropertySheetModel makeModel(final PropertySheet sheet, final PageState state) {
|
||||
public PropertySheetModel makeModel(final PropertySheet sheet,
|
||||
final PageState state) {
|
||||
return new XMLConfigSheetModel();
|
||||
}
|
||||
|
||||
|
|
@ -232,18 +239,23 @@ public class SystemInformationTab extends LayoutPanel {
|
|||
public GlobalizedMessage getGlobalizedLabel() {
|
||||
switch (currentIndex) {
|
||||
case TRANSFORMER_FACTORY_INDEX:
|
||||
return GlobalizationUtil.globalize("ui.admin.sysinfo.xml_transformer_factory");
|
||||
return GlobalizationUtil.globalize(
|
||||
"ui.admin.sysinfo.xml_transformer_factory");
|
||||
case TRANSFORMER_INDEX:
|
||||
return GlobalizationUtil.globalize("ui.admin.sysinfo.xml_transformer");
|
||||
return GlobalizationUtil.globalize(
|
||||
"ui.admin.sysinfo.xml_transformer");
|
||||
case DOCUMENT_BUILDER_FACTORY_INDEX:
|
||||
return GlobalizationUtil.globalize(
|
||||
"ui.admin.sysinfo.xml_document_builder_factory");
|
||||
case DOCUMENT_BUILDER_INDEX:
|
||||
return GlobalizationUtil.globalize("ui.admin.sysinfo.xml_document_builder");
|
||||
return GlobalizationUtil.globalize(
|
||||
"ui.admin.sysinfo.xml_document_builder");
|
||||
case SAX_PARSER_FACTORY_INDEX:
|
||||
return GlobalizationUtil.globalize("ui.admin.sysinfo.sax_parser_factory");
|
||||
return GlobalizationUtil.globalize(
|
||||
"ui.admin.sysinfo.sax_parser_factory");
|
||||
case SAX_PARSER_INDEX:
|
||||
return GlobalizationUtil.globalize("ui.admin.sysinfo.sax_parser");
|
||||
return GlobalizationUtil.globalize(
|
||||
"ui.admin.sysinfo.sax_parser");
|
||||
default:
|
||||
return GlobalizationUtil.globalize("unknown");
|
||||
}
|
||||
|
|
@ -253,41 +265,47 @@ public class SystemInformationTab extends LayoutPanel {
|
|||
public String getValue() {
|
||||
switch (currentIndex) {
|
||||
case TRANSFORMER_FACTORY_INDEX:
|
||||
try {
|
||||
return TransformerFactory.class.getDeclaredConstructor().newInstance().getClass().getName();
|
||||
} catch (IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException e) {
|
||||
}
|
||||
return TransformerFactory
|
||||
.newInstance()
|
||||
.getClass()
|
||||
.getName();
|
||||
case TRANSFORMER_INDEX:
|
||||
try {
|
||||
return TransformerFactory.class.getDeclaredConstructor().newInstance().newTransformer().getClass().getName();
|
||||
return TransformerFactory
|
||||
.newInstance()
|
||||
.newTransformer()
|
||||
.getClass()
|
||||
.getName();
|
||||
} catch (TransformerConfigurationException ex) {
|
||||
return "???";
|
||||
} catch (IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException e) {
|
||||
}
|
||||
case DOCUMENT_BUILDER_FACTORY_INDEX:
|
||||
try {
|
||||
return DocumentBuilderFactory.class.getDeclaredConstructor().newInstance().getClass().getName();
|
||||
} catch (IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException e) {
|
||||
}
|
||||
return DocumentBuilderFactory.newInstance().getClass()
|
||||
.getName();
|
||||
case DOCUMENT_BUILDER_INDEX:
|
||||
try {
|
||||
return DocumentBuilderFactory.class.getDeclaredConstructor().newInstance().newDocumentBuilder().getClass()
|
||||
return DocumentBuilderFactory
|
||||
.newInstance()
|
||||
.newDocumentBuilder()
|
||||
.getClass()
|
||||
.getName();
|
||||
} catch (ParserConfigurationException ex) {
|
||||
return "???";
|
||||
} catch (IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException e) {
|
||||
}
|
||||
case SAX_PARSER_FACTORY_INDEX:
|
||||
try {
|
||||
return SAXParserFactory.class.getDeclaredConstructor().newInstance().getClass().getName();
|
||||
} catch (IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException e) {
|
||||
}
|
||||
return SAXParserFactory
|
||||
.newInstance()
|
||||
.getClass()
|
||||
.getName();
|
||||
case SAX_PARSER_INDEX:
|
||||
try {
|
||||
return SAXParserFactory.class.getDeclaredConstructor().newInstance().newSAXParser().getClass().getName();
|
||||
return SAXParserFactory
|
||||
.newInstance()
|
||||
.newSAXParser()
|
||||
.getClass()
|
||||
.getName();
|
||||
} catch (ParserConfigurationException | SAXException ex) {
|
||||
return "???";
|
||||
} catch (IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException e) {
|
||||
}
|
||||
default:
|
||||
return "";
|
||||
|
|
|
|||
|
|
@ -41,13 +41,12 @@ import java.lang.reflect.InvocationTargetException;
|
|||
* <code>org.jdom.Document</code> using <code>org.w3c.dom.Document</code>.
|
||||
*
|
||||
* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
* pboy (Jan. 09)
|
||||
* Class uses "DocumentBuilderFactory.class.getDeclaredConstructor().newInstance()" to setup the parser
|
||||
* (according to the javax.xml specification). This is a simple and
|
||||
* pboy (Jan. 09) Class uses "DocumentBuilderFactory.newInstance()" to setup the
|
||||
* parser (according to the javax.xml specification). This is a simple and
|
||||
* straightforward, but rather thumb method. It requires a JVM wide acceptable
|
||||
* configuration (using a system.property or a static JRE configuration file) and
|
||||
* contrains all programms in a JVM (e.g. multiple CCM running in a container)
|
||||
* to use the same configuration.
|
||||
* configuration (using a system.property or a static JRE configuration file)
|
||||
* and contrains all programms in a JVM (e.g. multiple CCM running in a
|
||||
* container) to use the same configuration.
|
||||
*
|
||||
* Other methods are available but we have to dig deeper into the CCM code.
|
||||
* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
|
@ -58,14 +57,14 @@ import java.lang.reflect.InvocationTargetException;
|
|||
*/
|
||||
public class Document {
|
||||
|
||||
private static final Logger LOGGER =
|
||||
LogManager.getLogger(Document.class.getName());
|
||||
private static final Logger LOGGER = LogManager.getLogger(Document.class
|
||||
.getName());
|
||||
/**
|
||||
* this is the identity XSL stylesheet. We need to provide the
|
||||
* identity transform as XSL explicitly because the default
|
||||
* transformer (newTransformer()) strips XML namespace attributes.
|
||||
* Also, this XSLT will strip the <bebop:structure> debugging info
|
||||
* from the XML document if present.
|
||||
* this is the identity XSL stylesheet. We need to provide the identity
|
||||
* transform as XSL explicitly because the default transformer
|
||||
* (newTransformer()) strips XML namespace attributes. Also, this XSLT will
|
||||
* strip the <bebop:structure> debugging info from the XML document if
|
||||
* present.
|
||||
*/
|
||||
// XXX For some reason JD.XSLT doesn't copy xmlns: attributes
|
||||
// to the output doc with <xsl:copy>
|
||||
|
|
@ -84,8 +83,7 @@ public class Document {
|
|||
*/
|
||||
// Explicitly create elements & attributes to avoid namespace
|
||||
// problems
|
||||
private final static String identityXSL =
|
||||
"<xsl:stylesheet version=\"2.0\""
|
||||
private final static String identityXSL = "<xsl:stylesheet version=\"2.0\""
|
||||
+ " xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">\n"
|
||||
+ "<xsl:output method=\"xml\"/>\n"
|
||||
+ "<xsl:template match=\"text()|comment()|processing-instruction()\">\n"
|
||||
|
|
@ -102,13 +100,12 @@ public class Document {
|
|||
+ "</xsl:template>\n"
|
||||
+ "</xsl:stylesheet>";
|
||||
/**
|
||||
* A single <code>DocumentBuilderFactory</code> to use for
|
||||
* creating Documents.
|
||||
* A single <code>DocumentBuilderFactory</code> to use for creating
|
||||
* Documents.
|
||||
*/
|
||||
protected static DocumentBuilderFactory s_builder = null;
|
||||
/**
|
||||
* A single <code>DocumentBuilder</code> to use for
|
||||
* creating Documents.
|
||||
* A single <code>DocumentBuilder</code> to use for creating Documents.
|
||||
*/
|
||||
protected static ThreadLocal s_db = null;
|
||||
|
||||
|
|
@ -117,9 +114,9 @@ public class Document {
|
|||
// instead to achieve independence from a JVM wide configuration.
|
||||
// Requires additional modifications in c.ad.util.xml.XML
|
||||
static {
|
||||
try {
|
||||
// try {
|
||||
LOGGER.debug("Static initalizer starting...");
|
||||
s_builder = DocumentBuilderFactory.class.getDeclaredConstructor().newInstance();
|
||||
s_builder = DocumentBuilderFactory.newInstance();
|
||||
s_builder.setNamespaceAware(true);
|
||||
s_db = new ThreadLocal() {
|
||||
|
||||
|
|
@ -131,11 +128,13 @@ public class Document {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
LOGGER.debug("Static initalized finished.");
|
||||
} catch (IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException e) {
|
||||
LOGGER.error(e);
|
||||
}
|
||||
// }
|
||||
// catch ( e) {
|
||||
// LOGGER.error(e);
|
||||
// }
|
||||
}
|
||||
|
||||
/* Used to build the DOM Documents that this class wraps */
|
||||
|
|
@ -173,6 +172,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 {
|
||||
|
|
@ -188,10 +188,11 @@ 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
|
||||
*/
|
||||
|
|
@ -227,6 +228,7 @@ public class Document {
|
|||
* Sets the root element.
|
||||
*
|
||||
* @param rootNode the element to use as the root node
|
||||
*
|
||||
* @return this document.
|
||||
*/
|
||||
public Document setRootElement(Element rootNode) {
|
||||
|
|
@ -237,14 +239,15 @@ public class Document {
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates a new element and sets it as the root.
|
||||
* Equivalent to
|
||||
* Creates a new element and sets it as the root. Equivalent to
|
||||
* <pre>
|
||||
* Element root = new Element("name", NS);
|
||||
* doc.setRootElement(root);
|
||||
* </pre>
|
||||
*
|
||||
* @param elt the element name
|
||||
* @param ns the element's namespace URI
|
||||
*
|
||||
* @return The newly created root element.
|
||||
*/
|
||||
public Element createRootElement(String elt, String ns) {
|
||||
|
|
@ -256,13 +259,14 @@ public class Document {
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates a new element and sets it as the root.
|
||||
* Equivalent to
|
||||
* Creates a new element and sets it as the root. Equivalent to
|
||||
* <pre>
|
||||
* Element root = new Element("name", NS);
|
||||
* doc.setRootElement(root);
|
||||
* </pre>
|
||||
*
|
||||
* @param elt the element name
|
||||
*
|
||||
* @return The newly created root element.
|
||||
*/
|
||||
public Element createRootElement(String elt) {
|
||||
|
|
@ -274,8 +278,9 @@ public class Document {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the root element for the document. This is the top-level
|
||||
* element (the "HTML" element in an HTML document).
|
||||
* Returns the root element for the document. This is the top-level element
|
||||
* (the "HTML" element in an HTML document).
|
||||
*
|
||||
* @return the document's root element.
|
||||
*/
|
||||
public Element getRootElement() {
|
||||
|
|
@ -285,10 +290,10 @@ public class Document {
|
|||
}
|
||||
|
||||
/**
|
||||
* Not a part of <code>org.jdom.Document</code>, this function returns
|
||||
* the internal DOM representation of this document. This method should
|
||||
* only be used when passing the DOM to the translator. It will require
|
||||
* changes once JDOM replaces this class.
|
||||
* Not a part of <code>org.jdom.Document</code>, this function returns the
|
||||
* internal DOM representation of this document. This method should only be
|
||||
* used when passing the DOM to the translator. It will require changes once
|
||||
* JDOM replaces this class.
|
||||
*
|
||||
* @return this document.
|
||||
*/
|
||||
|
|
@ -297,16 +302,16 @@ public class Document {
|
|||
}
|
||||
|
||||
/**
|
||||
* General toString() method for org.w3c.domDocument.
|
||||
* Not really related to xml.Document, but needed here.
|
||||
* Converts an XML in-memory DOM to String representation, using
|
||||
* an XSLT identity transformation.
|
||||
* General toString() method for org.w3c.domDocument. Not really related to
|
||||
* xml.Document, but needed here. Converts an XML in-memory DOM to String
|
||||
* representation, using an XSLT identity transformation.
|
||||
*
|
||||
* @param document the <code>org.w3c.dom.Document</code> object to convert
|
||||
* to a String representation
|
||||
* @param indent if <code>true</code>, try to indent elements according to
|
||||
* normal XML/SGML indentation conventions (may only work
|
||||
* with certain XSLT engines)
|
||||
*
|
||||
* @param document the <code>org.w3c.dom.Document</code> object
|
||||
* to convert to a String representation
|
||||
* @param indent if <code>true</code>, try to indent elements according to normal
|
||||
* XML/SGML indentation conventions (may only work with certain
|
||||
* XSLT engines)
|
||||
* @return a String representation of <code>document</code>.
|
||||
*/
|
||||
public static String toString(org.w3c.dom.Document document,
|
||||
|
|
@ -314,10 +319,11 @@ public class Document {
|
|||
Transformer identity;
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
try {
|
||||
StreamSource identitySource =
|
||||
new StreamSource(new StringReader(identityXSL));
|
||||
identity = TransformerFactory.class.getDeclaredConstructor().newInstance().newTransformer(
|
||||
identitySource);
|
||||
StreamSource identitySource = new StreamSource(new StringReader(
|
||||
identityXSL));
|
||||
identity = TransformerFactory
|
||||
.newInstance()
|
||||
.newTransformer(identitySource);
|
||||
identity.setOutputProperty("method", "xml");
|
||||
identity.setOutputProperty("indent", (indent ? "yes" : "no"));
|
||||
identity.setOutputProperty("encoding", "UTF-8");
|
||||
|
|
@ -325,9 +331,6 @@ public class Document {
|
|||
} catch (javax.xml.transform.TransformerException e) {
|
||||
LOGGER.error("error in toString", e);
|
||||
return document.toString();
|
||||
} catch (IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException e) {
|
||||
LOGGER.error(e);
|
||||
return null; // This shouldn't be possible
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
@ -338,9 +341,12 @@ public class Document {
|
|||
}
|
||||
}
|
||||
|
||||
/** Convenience wrapper for static toString(Document, boolean),
|
||||
* without additional indenting.
|
||||
/**
|
||||
* Convenience wrapper for static toString(Document, boolean), without
|
||||
* additional indenting.
|
||||
*
|
||||
* @param document the <code>org.w3c.dom.Document</code> to output
|
||||
*
|
||||
* @return a String representation of <code>document</code>.
|
||||
*/
|
||||
public static String toString(org.w3c.dom.Document document) {
|
||||
|
|
@ -349,20 +355,25 @@ public class Document {
|
|||
|
||||
/**
|
||||
* Generates an XML text representation of this document.
|
||||
*
|
||||
* @param indent if <code>true</code>, try to indent XML elements according
|
||||
* to XML/SGML convention
|
||||
*
|
||||
* @return a String representation of <code>this</code>.
|
||||
*/
|
||||
public String toString(boolean indent) {
|
||||
return toString(m_document, indent);
|
||||
}
|
||||
|
||||
/** Generates an XML text representation of this document,
|
||||
* without additional indenting.
|
||||
/**
|
||||
* Generates an XML text representation of this document, without additional
|
||||
* indenting.
|
||||
*
|
||||
* @return a String representation of <code>this</code>.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return toString(m_document, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,19 +35,20 @@ import java.util.List;
|
|||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Attr;
|
||||
|
||||
|
||||
/**
|
||||
* A wrapper class that implements some functionality of
|
||||
* <code>org.jdom.Element</code> using <code>org.w3c.dom.Element</code>.
|
||||
*
|
||||
* @author Patrick McNeill
|
||||
* @since ACS 4.5a
|
||||
* @version $Revision$ $Date$
|
||||
* @version $Revision$ $Date: 2017-10-25 15:26:01 +0200 (Mi, 25 Okt 2017)
|
||||
* $
|
||||
* @version $Id$
|
||||
*/
|
||||
public class Element {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger(Element.class.getName());
|
||||
private static final Logger LOGGER = LogManager.getLogger(Element.class
|
||||
.getName());
|
||||
protected org.w3c.dom.Element m_element;
|
||||
/* DOM element that is being wrapped */
|
||||
/**
|
||||
|
|
@ -56,11 +57,12 @@ public class Element {
|
|||
private org.w3c.dom.Document m_doc;
|
||||
|
||||
private static ThreadLocal s_localDocument = new ThreadLocal() {
|
||||
|
||||
@Override
|
||||
public Object initialValue() {
|
||||
try {
|
||||
DocumentBuilderFactory builder =
|
||||
DocumentBuilderFactory.class.getDeclaredConstructor().newInstance();
|
||||
DocumentBuilderFactory builder = DocumentBuilderFactory
|
||||
.newInstance();
|
||||
builder.setNamespaceAware(true);
|
||||
return builder.newDocumentBuilder().newDocument();
|
||||
} catch (ParserConfigurationException e) {
|
||||
|
|
@ -68,9 +70,6 @@ public class Element {
|
|||
throw new UncheckedWrapperException(
|
||||
"INTERNAL: Could not create thread local DOM document.",
|
||||
e);
|
||||
} catch (IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException e) {
|
||||
LOGGER.error(e);
|
||||
return null; // This shouldn't be possible
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -92,7 +91,6 @@ public class Element {
|
|||
// .getOwnerDocument().importNode(element.m_element,
|
||||
// true);
|
||||
// }
|
||||
|
||||
public void syncDocs() {
|
||||
if (m_doc == null) {
|
||||
m_doc = (org.w3c.dom.Document) s_localDocument.get();
|
||||
|
|
@ -104,9 +102,9 @@ public class Element {
|
|||
}
|
||||
|
||||
/**
|
||||
* Protected constructor to set up factories, etc. Does not actually
|
||||
* create a new element. Used if we are programatically setting the
|
||||
* m_element field later.
|
||||
* Protected constructor to set up factories, etc. Does not actually create
|
||||
* a new element. Used if we are programatically setting the m_element field
|
||||
* later.
|
||||
*/
|
||||
protected Element() {
|
||||
}
|
||||
|
|
@ -139,16 +137,17 @@ public class Element {
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates a new element and adds it as a child to this
|
||||
* element. <code>elt.newChildElement("newElt")</code> is
|
||||
* equivalent to
|
||||
* Creates a new element and adds it as a child to this element.
|
||||
* <code>elt.newChildElement("newElt")</code> is equivalent to
|
||||
* <pre>
|
||||
* Element newElt = new Element("newElt");
|
||||
* elt.addChild(newElt);
|
||||
* </pre>
|
||||
*
|
||||
* @param name the name of the element
|
||||
*
|
||||
* @return the created child element.
|
||||
*
|
||||
* @pre m_element != null
|
||||
*/
|
||||
public Element newChildElement(String name) {
|
||||
|
|
@ -165,10 +164,9 @@ public class Element {
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates a new element. Adds it as a child to this element
|
||||
* element and assigns it to the namespace defined at <code>uri</code>.
|
||||
* <code>elt.newChildElement("newElt", namespace)</code> is
|
||||
* equivalent to
|
||||
* Creates a new element. Adds it as a child to this element element and
|
||||
* assigns it to the namespace defined at <code>uri</code>.
|
||||
* <code>elt.newChildElement("newElt", namespace)</code> is equivalent to
|
||||
* <pre>
|
||||
* Element newElt = new Element("newElt", namespace);
|
||||
* elt.addChild(newElt);
|
||||
|
|
@ -176,7 +174,9 @@ public class Element {
|
|||
*
|
||||
* @param name the name of the Element
|
||||
* @param uri the URI for the namespace definition
|
||||
*
|
||||
* @return the created child element.
|
||||
*
|
||||
* @pre m_element != null
|
||||
*/
|
||||
public Element newChildElement(String name, String uri) {
|
||||
|
|
@ -194,10 +194,10 @@ public class Element {
|
|||
}
|
||||
|
||||
/**
|
||||
* Copies the passed in element and all of its children to a new
|
||||
* Element.
|
||||
* Copies the passed in element and all of its children to a new Element.
|
||||
*
|
||||
* @param copyFrom
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Element newChildElement(Element copyFrom) {
|
||||
|
|
@ -208,18 +208,20 @@ public class Element {
|
|||
}
|
||||
|
||||
Element copyTo = new Element();
|
||||
copyTo.m_element = m_doc.createElementNS(copyFrom.m_element.getNamespaceURI(), copyFrom.getName());
|
||||
copyTo.m_element = m_doc.createElementNS(copyFrom.m_element
|
||||
.getNamespaceURI(), copyFrom.getName());
|
||||
this.m_element.appendChild(copyTo.m_element);
|
||||
newChildElementHelper(copyFrom, copyTo);
|
||||
return copyTo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies the passed in element and all of its children to a new
|
||||
* Element using the passed-in name.
|
||||
* Copies the passed in element and all of its children to a new Element
|
||||
* using the passed-in name.
|
||||
*
|
||||
* @param name
|
||||
* @param copyFrom
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Element newChildElement(String name, Element copyFrom) {
|
||||
|
|
@ -235,12 +237,13 @@ public class Element {
|
|||
}
|
||||
|
||||
/**
|
||||
* Copies the passed in element and all of its children to a new
|
||||
* Element using the passed-in name.
|
||||
* Copies the passed in element and all of its children to a new Element
|
||||
* using the passed-in name.
|
||||
*
|
||||
* @param name
|
||||
* @param uri
|
||||
* @param copyFrom
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Element newChildElement(String name, String uri, Element copyFrom) {
|
||||
|
|
@ -258,7 +261,6 @@ public class Element {
|
|||
private void newChildElementHelper(Element copyFrom, Element copyTo) {
|
||||
copyTo.setText(copyFrom.getText());
|
||||
|
||||
|
||||
NamedNodeMap nnm = copyFrom.m_element.getAttributes();
|
||||
|
||||
if (nnm != null) {
|
||||
|
|
@ -282,6 +284,7 @@ public class Element {
|
|||
*
|
||||
* @param name the name of the attribute
|
||||
* @param value the value of the attribute
|
||||
*
|
||||
* @return this element.
|
||||
*/
|
||||
public Element addAttribute(String name, String value) {
|
||||
|
|
@ -307,6 +310,7 @@ public class Element {
|
|||
* Adds a child element to this element.
|
||||
*
|
||||
* @param newContent the new child element
|
||||
*
|
||||
* @return this element.
|
||||
*/
|
||||
public Element addContent(Element newContent) {
|
||||
|
|
@ -319,11 +323,11 @@ public class Element {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets the text value of the current element (the part between the
|
||||
* tags). If the passed in text is null then it is converted to
|
||||
* the empty string.
|
||||
* Sets the text value of the current element (the part between the tags).
|
||||
* If the passed in text is null then it is converted to the empty string.
|
||||
*
|
||||
* @param text the text to include
|
||||
*
|
||||
* @return this element.
|
||||
*/
|
||||
public Element setText(String text) {
|
||||
|
|
@ -334,16 +338,16 @@ public class Element {
|
|||
// is to throw the NPE which causes other problems
|
||||
text = "";
|
||||
}
|
||||
org.w3c.dom.Text textElem =
|
||||
m_element.getOwnerDocument().createTextNode(text);
|
||||
org.w3c.dom.Text textElem = m_element.getOwnerDocument().createTextNode(
|
||||
text);
|
||||
m_element.appendChild(textElem);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the concatenation of all the text in all child nodes
|
||||
* of the current element.
|
||||
* Returns the concatenation of all the text in all child nodes of the
|
||||
* current element.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -370,8 +374,8 @@ public class Element {
|
|||
cdata = "";
|
||||
}
|
||||
|
||||
org.w3c.dom.CDATASection cdataSection =
|
||||
m_element.getOwnerDocument().createCDATASection(cdata);
|
||||
org.w3c.dom.CDATASection cdataSection = m_element.getOwnerDocument()
|
||||
.createCDATASection(cdata);
|
||||
|
||||
m_element.appendChild(cdataSection);
|
||||
|
||||
|
|
@ -399,15 +403,15 @@ public class Element {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a <code>List</code> of all the child elements nested
|
||||
* directly (one level deep) within this element, as <code>Element</code>
|
||||
* objects. If this target element has no nested elements, an empty
|
||||
* <code>List</code> is returned. The returned list is "live", so
|
||||
* changes to it affect the element's actual contents.
|
||||
* Returns a <code>List</code> of all the child elements nested directly
|
||||
* (one level deep) within this element, as <code>Element</code> objects. If
|
||||
* this target element has no nested elements, an empty <code>List</code> is
|
||||
* returned. The returned list is "live", so changes to it affect the
|
||||
* element's actual contents.
|
||||
* <p>
|
||||
*
|
||||
* This performs no recursion, so elements nested two levels deep would
|
||||
* have to be obtained with:
|
||||
* This performs no recursion, so elements nested two levels deep would have
|
||||
* to be obtained with:
|
||||
* <pre>
|
||||
* Iterator itr = currentElement.getChildren().iterator();
|
||||
* while (itr.hasNext()) {
|
||||
|
|
@ -416,6 +420,7 @@ public class Element {
|
|||
* // Do something with these children
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* @return list of child <code>Element</code> objects for this element.
|
||||
*/
|
||||
public java.util.List getChildren() {
|
||||
|
|
@ -434,8 +439,7 @@ public class Element {
|
|||
|
||||
public java.util.Map getAttributes() {
|
||||
// Retrieve the attributes of the DOM Element
|
||||
org.w3c.dom.NamedNodeMap attributeNodeMap =
|
||||
m_element.getAttributes();
|
||||
org.w3c.dom.NamedNodeMap attributeNodeMap = m_element.getAttributes();
|
||||
|
||||
// Create the HashMap that we will return the attributes
|
||||
// in
|
||||
|
|
@ -457,10 +461,11 @@ public class Element {
|
|||
|
||||
/**
|
||||
* Retrieves an attribute value by name.
|
||||
*
|
||||
* @param name The name of the attribute to retrieve
|
||||
* @return The Attr value as a string,
|
||||
* or the empty string if that attribute does not have a specified
|
||||
* or default value.
|
||||
*
|
||||
* @return The Attr value as a string, or the empty string if that attribute
|
||||
* does not have a specified or default value.
|
||||
*/
|
||||
public String getAttribute(String name) {
|
||||
return m_element.getAttribute(name);
|
||||
|
|
@ -475,9 +480,8 @@ public class Element {
|
|||
}
|
||||
|
||||
/**
|
||||
* Functions to allow this class to interact appropriately with the
|
||||
* Document class (for example, allows nodes to be moved around,
|
||||
* and so on).
|
||||
* Functions to allow this class to interact appropriately with the Document
|
||||
* class (for example, allows nodes to be moved around, and so on).
|
||||
*
|
||||
* @return the internal DOM Element.
|
||||
*/
|
||||
|
|
@ -486,9 +490,9 @@ public class Element {
|
|||
}
|
||||
|
||||
/**
|
||||
* Imports the internal node into another document.
|
||||
* This could also be done with a combination of getInternalElement
|
||||
* and a setInternalElement function.
|
||||
* Imports the internal node into another document. This could also be done
|
||||
* with a combination of getInternalElement and a setInternalElement
|
||||
* function.
|
||||
*
|
||||
* @param doc the org.w3c.dom.Document to import into
|
||||
*/
|
||||
|
|
@ -504,14 +508,13 @@ public class Element {
|
|||
}
|
||||
|
||||
/**
|
||||
* Workaround for bug in some versions of Xerces.
|
||||
* For some reason, importNode doesn't also copy attribute
|
||||
* values unless you call getValue() on them first. This may
|
||||
* be fixed in a later version of Xerces. In the meantime,
|
||||
* calling visitAllAttributes(node) before importNode should
|
||||
* help.
|
||||
* Workaround for bug in some versions of Xerces. For some reason,
|
||||
* importNode doesn't also copy attribute values unless you call getValue()
|
||||
* on them first. This may be fixed in a later version of Xerces. In the
|
||||
* meantime, calling visitAllAttributes(node) before importNode should help.
|
||||
*
|
||||
* @param node the org.w3c.dom.Node about to be imported
|
||||
*
|
||||
* @deprecated with no replacement, 1 May 2003
|
||||
*/
|
||||
public static void visitAllAttributes(org.w3c.dom.Node node) {
|
||||
|
|
@ -531,9 +534,10 @@ public class Element {
|
|||
}
|
||||
|
||||
/**
|
||||
* retrieve an unordered list of strings relating to node tree including
|
||||
* and below the current element. Strings include element names, attribute names,
|
||||
* attribute values, text and CData sections
|
||||
* retrieve an unordered list of strings relating to node tree including and
|
||||
* below the current element. Strings include element names, attribute
|
||||
* names, attribute values, text and CData sections
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private List getXMLFragments() {
|
||||
|
|
@ -559,9 +563,10 @@ public class Element {
|
|||
}
|
||||
|
||||
/**
|
||||
* retrieve a string that is an ordered concatenation of all information describing
|
||||
* this node and its subnodes, suitable as the basis of a hashCode or equals
|
||||
* implementation.
|
||||
* retrieve a string that is an ordered concatenation of all information
|
||||
* describing this node and its subnodes, suitable as the basis of a
|
||||
* hashCode or equals implementation.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected String getXMLHashString() {
|
||||
|
|
|
|||
|
|
@ -204,7 +204,8 @@ public class XML {
|
|||
// configuration (affecting all CCM instances which may run in a
|
||||
// container).
|
||||
// Requires additional modifications in c.ad.util.xml.XML
|
||||
SAXParserFactory spf = SAXParserFactory.class.getDeclaredConstructor().newInstance();
|
||||
SAXParserFactory spf = SAXParserFactory
|
||||
.newInstance();
|
||||
spf.setFeature("http://xml.org/sax/features/namespaces", true);
|
||||
SAXParser parser = spf.newSAXParser();
|
||||
parser.parse(source, handler);
|
||||
|
|
@ -219,8 +220,6 @@ public class XML {
|
|||
}
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedWrapperException("error parsing stream", e);
|
||||
} catch (IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException e) {
|
||||
LOGGER.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -80,54 +80,56 @@ public class SysInfoController {
|
|||
|
||||
final ResourceBundle texts = ResourceBundle.getBundle(
|
||||
"com.arsdigita.ui.admin.AdminResources");
|
||||
try {
|
||||
xmlProps.add(new SysInfoProperty(
|
||||
texts.getString("ui.admin.sysinfo.xml_transformer_factory"),
|
||||
TransformerFactory.class.getDeclaredConstructor().newInstance().getClass().getName()));
|
||||
} catch (IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException e) {
|
||||
}
|
||||
TransformerFactory
|
||||
.newInstance()
|
||||
.getClass()
|
||||
.getName()));
|
||||
try {
|
||||
xmlProps.add(new SysInfoProperty(
|
||||
texts.getString("ui.admin.sysinfo.xml_transformer"),
|
||||
TransformerFactory.class.getDeclaredConstructor().newInstance().newTransformer().getClass()
|
||||
TransformerFactory.newInstance()
|
||||
.newTransformer()
|
||||
.getClass()
|
||||
.getName()));
|
||||
} catch (TransformerConfigurationException ex) {
|
||||
xmlProps.add(new SysInfoProperty(
|
||||
texts.getString("ui.admin.sysinfo.xml_transformer"), "???"));
|
||||
} catch (IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException e) {
|
||||
}
|
||||
try {
|
||||
xmlProps.add(new SysInfoProperty(
|
||||
texts.getString("ui.admin.sysinfo.xml_document_builder_factory"),
|
||||
DocumentBuilderFactory.class.getDeclaredConstructor().newInstance().getClass().getName()));
|
||||
} catch (IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException e) {
|
||||
DocumentBuilderFactory.newInstance().getClass().getName()));
|
||||
}
|
||||
try {
|
||||
xmlProps.add(new SysInfoProperty(
|
||||
texts.getString("ui.admin.sysinfo.xml_document_builder"),
|
||||
DocumentBuilderFactory.class.getDeclaredConstructor().newInstance().newDocumentBuilder()
|
||||
.getClass().getName()));
|
||||
DocumentBuilderFactory
|
||||
.newInstance()
|
||||
.newDocumentBuilder()
|
||||
.getClass()
|
||||
.getName()));
|
||||
} catch (ParserConfigurationException ex) {
|
||||
xmlProps.add(new SysInfoProperty(
|
||||
texts.getString("ui.admin.sysinfo.xml_document_builder"),
|
||||
"???"));
|
||||
} catch (IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException e) {
|
||||
}
|
||||
try {
|
||||
xmlProps.add(new SysInfoProperty(
|
||||
texts.getString("ui.admin.sysinfo.sax_parser_factory"),
|
||||
SAXParserFactory.class.getDeclaredConstructor().newInstance().getClass().getName()));
|
||||
} catch (IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException e) {
|
||||
}
|
||||
SAXParserFactory
|
||||
.newInstance()
|
||||
.getClass()
|
||||
.getName()));
|
||||
try {
|
||||
xmlProps.add(new SysInfoProperty(
|
||||
texts.getString("ui.admin.sysinfo.sax_parser"),
|
||||
SAXParserFactory.class.getDeclaredConstructor().newInstance().newSAXParser().getClass()
|
||||
SAXParserFactory
|
||||
.newInstance()
|
||||
.newSAXParser()
|
||||
.getClass()
|
||||
.getName()));
|
||||
} catch (ParserConfigurationException | SAXException ex) {
|
||||
xmlProps.add(new SysInfoProperty(
|
||||
texts.getString("ui.admin.sysinfo.sax_parser"), "???"));
|
||||
} catch (IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException e) {
|
||||
}
|
||||
|
||||
return xmlProps;
|
||||
|
|
|
|||
Loading…
Reference in New Issue