You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by th...@apache.org on 2008/09/22 10:46:47 UTC
svn commit: r697709 - in
/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config:
ConfigurationErrorHandler.java ConfigurationParser.java
Author: thomasm
Date: Mon Sep 22 01:46:47 2008
New Revision: 697709
URL: http://svn.apache.org/viewvc?rev=697709&view=rev
Log:
JCR-1462 repository.xml: throw an exception on error
Modified:
jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/ConfigurationErrorHandler.java
jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/ConfigurationParser.java
Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/ConfigurationErrorHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/ConfigurationErrorHandler.java?rev=697709&r1=697708&r2=697709&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/ConfigurationErrorHandler.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/ConfigurationErrorHandler.java Mon Sep 22 01:46:47 2008
@@ -37,6 +37,7 @@
*/
public void error(SAXParseException exception) throws SAXException {
logError("Error", exception);
+ throw exception;
}
private void logError(String type, SAXParseException exception) {
@@ -49,6 +50,7 @@
*/
public void fatalError(SAXParseException exception) throws SAXException {
logError("Fatal error", exception);
+ throw exception;
}
/**
Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/ConfigurationParser.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/ConfigurationParser.java?rev=697709&r1=697708&r2=697709&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/ConfigurationParser.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/ConfigurationParser.java Mon Sep 22 01:46:47 2008
@@ -252,25 +252,31 @@
* @return named child element, or <code>null</code> if not found and
* <code>required</code> is <code>false</code>.
* @throws ConfigurationException if the child element is not found and
- * <code>required</code> is <code>true</code>.
+ * <code>required</code> is <code>true</code>;
+ * or if more than one element with this name exists.
*/
protected Element getElement(Element parent, String name, boolean required)
throws ConfigurationException {
NodeList children = parent.getChildNodes();
+ Element found = null;
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
if (child.getNodeType() == Node.ELEMENT_NODE
&& name.equals(child.getNodeName())) {
- return (Element) child;
+ if (found != null) {
+ throw new ConfigurationException(
+ "Duplicate configuration element " + name + " in "
+ + parent.getNodeName() + ".");
+ }
+ found = (Element) child;
}
}
- if (required) {
+ if (required && found == null) {
throw new ConfigurationException(
"Configuration element " + name + " not found in "
+ parent.getNodeName() + ".");
- } else {
- return null;
}
+ return found;
}
/**