You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2010/04/16 10:50:51 UTC
svn commit: r934712 - in /sling/trunk/bundles/jcr/base: ./
src/main/java/org/apache/sling/jcr/base/ src/test/ src/test/java/
src/test/java/org/ src/test/java/org/apache/
src/test/java/org/apache/sling/ src/test/java/org/apache/sling/jcr/
src/test/java/...
Author: bdelacretaz
Date: Fri Apr 16 08:50:50 2010
New Revision: 934712
URL: http://svn.apache.org/viewvc?rev=934712&view=rev
Log:
SLING-1490 - use DEBUG log level for RepositoryException that indicates builtin nodetype being re-registered
Added:
sling/trunk/bundles/jcr/base/src/test/
sling/trunk/bundles/jcr/base/src/test/java/
sling/trunk/bundles/jcr/base/src/test/java/org/
sling/trunk/bundles/jcr/base/src/test/java/org/apache/
sling/trunk/bundles/jcr/base/src/test/java/org/apache/sling/
sling/trunk/bundles/jcr/base/src/test/java/org/apache/sling/jcr/
sling/trunk/bundles/jcr/base/src/test/java/org/apache/sling/jcr/base/
sling/trunk/bundles/jcr/base/src/test/java/org/apache/sling/jcr/base/NodeTypeLoaderTest.java (with props)
Modified:
sling/trunk/bundles/jcr/base/pom.xml
sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/NodeTypeLoader.java
Modified: sling/trunk/bundles/jcr/base/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/base/pom.xml?rev=934712&r1=934711&r2=934712&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/base/pom.xml (original)
+++ sling/trunk/bundles/jcr/base/pom.xml Fri Apr 16 08:50:50 2010
@@ -127,6 +127,16 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
Modified: sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/NodeTypeLoader.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/NodeTypeLoader.java?rev=934712&r1=934711&r2=934712&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/NodeTypeLoader.java (original)
+++ sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/NodeTypeLoader.java Fri Apr 16 08:50:50 2010
@@ -76,7 +76,11 @@ public class NodeTypeLoader {
} catch (IOException ioe) {
log.error("Cannot register node types from " + source, ioe);
} catch (RepositoryException re) {
- log.error("Cannot register node types from " + source, re);
+ if(isReRegisterBuiltinNodeType(re)) {
+ log.debug("Attempt to re-register built-in node type from " + source, re);
+ } else {
+ log.error("Cannot register node types from " + source, re);
+ }
} finally {
if (ins != null) {
try {
@@ -118,9 +122,22 @@ public class NodeTypeLoader {
try {
Workspace wsp = session.getWorkspace();
CndImporter.registerNodeTypes(reader, systemId, wsp.getNodeTypeManager(), wsp.getNamespaceRegistry(), session.getValueFactory(), reregisterExisting);
+ } catch(RepositoryException re) {
+ if(isReRegisterBuiltinNodeType(re)) {
+ log.debug("Attempt to re-register built-in node type, RepositoryException ignored", re);
+ } else {
+ throw re;
+ }
} catch (ParseException e) {
throw new IOException("Unable to parse CND Input: " + e.getMessage());
}
return true;
}
+
+ /** True if we think e was caused by an attempt to reregister a built-in node type */
+ static boolean isReRegisterBuiltinNodeType(Exception e) {
+ return
+ (e instanceof RepositoryException)
+ & (e.getMessage() != null && e.getMessage().contains("reregister built-in node type"));
+ }
}
Added: sling/trunk/bundles/jcr/base/src/test/java/org/apache/sling/jcr/base/NodeTypeLoaderTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/base/src/test/java/org/apache/sling/jcr/base/NodeTypeLoaderTest.java?rev=934712&view=auto
==============================================================================
--- sling/trunk/bundles/jcr/base/src/test/java/org/apache/sling/jcr/base/NodeTypeLoaderTest.java (added)
+++ sling/trunk/bundles/jcr/base/src/test/java/org/apache/sling/jcr/base/NodeTypeLoaderTest.java Fri Apr 16 08:50:50 2010
@@ -0,0 +1,41 @@
+/*
+ * 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.sling.jcr.base;
+
+import javax.jcr.RepositoryException;
+
+import org.junit.Test;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class NodeTypeLoaderTest {
+
+ @Test
+ public void testisReRegisterBuiltinNodeType() {
+ assertFalse("Exception does not match",
+ NodeTypeLoader.isReRegisterBuiltinNodeType(new Exception()));
+ assertFalse("Plain RepositoryException does not match",
+ NodeTypeLoader.isReRegisterBuiltinNodeType(new RepositoryException()));
+ assertFalse("Non-reregister RepositoryException does not match",
+ NodeTypeLoader.isReRegisterBuiltinNodeType(new RepositoryException("builtin that's it")));
+ assertTrue("Reregister RepositoryException matches",
+ NodeTypeLoader.isReRegisterBuiltinNodeType(
+ new RepositoryException("{http://www.jcp.org/jcr/mix/1.0}language: can't reregister built-in node type")));
+ }
+}
Propchange: sling/trunk/bundles/jcr/base/src/test/java/org/apache/sling/jcr/base/NodeTypeLoaderTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/trunk/bundles/jcr/base/src/test/java/org/apache/sling/jcr/base/NodeTypeLoaderTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision Rev URL