Author: rhauch
Date: 2009-09-03 16:55:13 -0400 (Thu, 03 Sep 2009)
New Revision: 1193
Modified:
trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/svn/SvnAndJcrIntegrationTest.java
trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryRequestProcessor.java
Log:
DNA-505 Svn Repository Source with NPE and other issues while opening connection through
Jcr
There really isn't a durable UUID available for each file in SVN (there is a single
UUID for each repository, though). And so the SVN connector does not return a
'jcr:uuid' property for the 'jcr:content' node, and this fouls up the
SessionCache implementation. However, while 'nt:file' and 'nt:folder' are
not referenceable, 'nt:resource' is. But lucky for us that the JCR spec does not
require that the 'jcr:content' node has a type of 'nt:resource'; it merely
says:
A common approach is to make the jcr:content a node of type nt:resource. (Section
6.7.22.6 of the 1.0.1 version of the JCR specification, page 160.)
So, a solution is to do the same thing we did in the file system connector: use a
'dna:resource' node type that is identical to 'nt:resource' except that it
does not extend 'mix:referenceable'.
Modified:
trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/svn/SvnAndJcrIntegrationTest.java
===================================================================
---
trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/svn/SvnAndJcrIntegrationTest.java 2009-09-03
20:01:08 UTC (rev 1192)
+++
trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/svn/SvnAndJcrIntegrationTest.java 2009-09-03
20:55:13 UTC (rev 1193)
@@ -26,7 +26,10 @@
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNull.notNullValue;
import static org.junit.Assert.assertThat;
+import javax.jcr.Node;
import javax.jcr.NodeIterator;
+import javax.jcr.Property;
+import javax.jcr.PropertyIterator;
import javax.jcr.Session;
import org.jboss.dna.connector.svn.SVNRepositorySource;
import org.jboss.dna.graph.SecurityContext;
@@ -92,6 +95,18 @@
assertThat(this.session.getRootNode().getNode("dna-graph"),
is(notNullValue()));
}
+ @Test
+ public void shouldProvideAccessToJcrDataNodeUnderFileNode() throws Exception {
+ System.out.println("Getting /pom.xml/jcr:content and then walking its
properties ...");
+ Node resourceNodeOfPomFile =
this.session.getRootNode().getNode("pom.xml/jcr:content");
+ assertThat(resourceNodeOfPomFile, is(notNullValue()));
+
+ for (PropertyIterator iter = resourceNodeOfPomFile.getProperties();
iter.hasNext();) {
+ Property property = iter.nextProperty();
+ assertThat(property.getName(), is(notNullValue()));
+ }
+ }
+
protected class MyCustomSecurityContext implements SecurityContext {
/**
* {@inheritDoc}
Modified:
trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryRequestProcessor.java
===================================================================
---
trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryRequestProcessor.java 2009-09-03
20:01:08 UTC (rev 1192)
+++
trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryRequestProcessor.java 2009-09-03
20:55:13 UTC (rev 1193)
@@ -36,6 +36,7 @@
import org.jboss.dna.common.util.Logger;
import org.jboss.dna.connector.scm.ScmAction;
import org.jboss.dna.connector.scm.ScmActionFactory;
+import org.jboss.dna.graph.DnaLexicon;
import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.JcrLexicon;
import org.jboss.dna.graph.JcrNtLexicon;
@@ -214,7 +215,11 @@
SVNDirEntry entry = getEntryInfo(workspaceRoot,
contentPath);
if (entry != null) {
// The request is to get properties of the
"jcr:content" child node ...
- addProperty(properties, factory, JcrLexicon.PRIMARY_TYPE,
JcrNtLexicon.RESOURCE);
+ // Do NOT use "nt:resource", since it extends
"mix:referenceable". The JCR spec
+ // does not require that "jcr:content" is of
type "nt:resource", but rather just
+ // suggests it. Therefore, we can use
"dna:resource", which is identical to
+ // "nt:resource" except it does not extend
"mix:referenceable"
+ addProperty(properties, factory, JcrLexicon.PRIMARY_TYPE,
DnaLexicon.RESOURCE);
addProperty(properties, factory,
JcrLexicon.LAST_MODIFIED, dateFactory.create(entry.getDate()));
}
Show replies by date