jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r637933 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config: ConfigurationErrorHandler.java ConfigurationParser.java
Date Mon, 17 Mar 2008 15:11:24 GMT
Author: thomasm
Date: Mon Mar 17 08:11:24 2008
New Revision: 637933

URL: http://svn.apache.org/viewvc?rev=637933&view=rev
Log:
JCR-1462 repository.xml: warning for unsupported configuration - enable XML validation

Added:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/ConfigurationErrorHandler.java
  (with props)
Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/ConfigurationParser.java

Added: 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=637933&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/ConfigurationErrorHandler.java
(added)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/ConfigurationErrorHandler.java
Mon Mar 17 08:11:24 2008
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.core.config;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+/**
+ * Error handler for errors in the repository or workspace configuration.
+ *
+ * @author Thomas Mueller
+ */
+public class ConfigurationErrorHandler implements ErrorHandler {
+
+    private static Logger log = LoggerFactory.getLogger(ConfigurationErrorHandler.class);
+
+    /**
+     * This method is called when there is an error parsing the configuration file.
+     * The relevant information is written to the log file.
+     */
+    public void error(SAXParseException exception) throws SAXException {
+        logError("Error", exception);
+    }
+
+    private void logError(String type, SAXParseException exception) {
+        log.warn(type + " parsing the configuration at line " + exception.getLineNumber()
+ " using system id " + exception.getSystemId() + ": " + exception.toString());
+    }
+
+    /**
+     * This method is called when there is a fatal error parsing the configuration file.
+     * The relevant information is written to the log file.
+     */
+    public void fatalError(SAXParseException exception) throws SAXException {
+        logError("Fatal error", exception);
+    }
+
+    /**
+     * This method is called when there is a warning parsing the configuration file.
+     * The relevant information is written to the log file.
+     */
+    public void warning(SAXParseException exception) throws SAXException {
+        logError("Warning", exception);
+    }
+
+}

Propchange: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/ConfigurationErrorHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

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=637933&r1=637932&r2=637933&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 Mar 17 08:11:24 2008
@@ -188,7 +188,9 @@
         try {
             DocumentBuilderFactory factory =
                 DocumentBuilderFactory.newInstance();
+            factory.setValidating(true);
             DocumentBuilder builder = factory.newDocumentBuilder();
+            builder.setErrorHandler(new ConfigurationErrorHandler());
             builder.setEntityResolver(ConfigurationEntityResolver.INSTANCE);
             Document document = builder.parse(xml);
             return document.getDocumentElement();



Mime
View raw message