[dna-commits] DNA SVN: r658 - in trunk/extensions/dna-connector-svn: src/main/java/org/jboss/dna/connector/svn and 2 other directories.

dna-commits at lists.jboss.org dna-commits at lists.jboss.org
Fri Dec 5 10:26:03 EST 2008


Author: spagop
Date: 2008-12-05 10:26:03 -0500 (Fri, 05 Dec 2008)
New Revision: 658

Added:
   trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryRequestProcessor.java
Modified:
   trunk/extensions/dna-connector-svn/.classpath
   trunk/extensions/dna-connector-svn/.project
   trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryConnection.java
   trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryConnectorI18n.java
   trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryLexicon.java
   trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositorySource.java
   trunk/extensions/dna-connector-svn/src/main/resources/org/jboss/dna/connector/svn/SVNConnectorI18n.properties
   trunk/extensions/dna-connector-svn/src/test/java/org/jboss/dna/connector/svn/SVNConnectorTestUtil.java
   trunk/extensions/dna-connector-svn/src/test/java/org/jboss/dna/connector/svn/SVNRepositoryConnectionTest.java
   trunk/extensions/dna-connector-svn/src/test/java/org/jboss/dna/connector/svn/SVNRepositorySourceTest.java
Log:
a small impl. for the read all children and read all properties request processing 

Modified: trunk/extensions/dna-connector-svn/.classpath
===================================================================
--- trunk/extensions/dna-connector-svn/.classpath	2008-12-04 23:03:08 UTC (rev 657)
+++ trunk/extensions/dna-connector-svn/.classpath	2008-12-05 15:26:03 UTC (rev 658)
@@ -1,10 +1,18 @@
-<?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-	<classpathentry kind="src" path="src/main/java"/>
-	<classpathentry kind="src" path="src/main/resources"/>
-	<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
-	<classpathentry kind="src" output="target/test-classes" path="src/test/resources"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
-	<classpathentry kind="output" path="target/classes"/>
-</classpath>
+  <classpathentry kind="src" path="src/main/java"/>
+  <classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
+  <classpathentry kind="src" path="src/test/java" output="target/test-classes"/>
+  <classpathentry kind="src" path="src/test/resources" output="target/test-classes" excluding="**/*.java"/>
+  <classpathentry kind="output" path="target/classes"/>
+  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+  <classpathentry kind="src" path="/dna-common"/>
+  <classpathentry kind="src" path="/dna-graph"/>
+  <classpathentry kind="var" path="M2_REPO/net/jcip/jcip-annotations/1.0/jcip-annotations-1.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/joda-time/joda-time/1.4/joda-time-1.4.jar"/>
+  <classpathentry kind="var" path="M2_REPO/junit/junit/4.4/junit-4.4.jar"/>
+  <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/mockito/mockito-all/1.5/mockito-all-1.5.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.4.3/slf4j-api-1.4.3.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-log4j12/1.4.3/slf4j-log4j12-1.4.3.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/tmatesoft/svnkit/svnkit/1.2.0.4949/svnkit-1.2.0.4949.jar"/>
+</classpath>
\ No newline at end of file

Modified: trunk/extensions/dna-connector-svn/.project
===================================================================
--- trunk/extensions/dna-connector-svn/.project	2008-12-04 23:03:08 UTC (rev 657)
+++ trunk/extensions/dna-connector-svn/.project	2008-12-05 15:26:03 UTC (rev 658)
@@ -1,23 +1,16 @@
-<?xml version="1.0" encoding="UTF-8"?>
 <projectDescription>
-	<name>dna-connector-svn</name>
-	<comment></comment>
-	<projects>
-	</projects>
-	<buildSpec>
-		<buildCommand>
-			<name>org.maven.ide.eclipse.maven2Builder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
-		<buildCommand>
-			<name>org.eclipse.jdt.core.javabuilder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
-	</buildSpec>
-	<natures>
-		<nature>org.eclipse.jdt.core.javanature</nature>
-		<nature>org.maven.ide.eclipse.maven2Nature</nature>
-	</natures>
-</projectDescription>
+  <name>dna-connector-svn</name>
+  <comment>JBoss DNA Connector that accesses an in-process SVN instance.</comment>
+  <projects>
+    <project>dna-common</project>
+    <project>dna-graph</project>
+  </projects>
+  <buildSpec>
+    <buildCommand>
+      <name>org.eclipse.jdt.core.javabuilder</name>
+    </buildCommand>
+  </buildSpec>
+  <natures>
+    <nature>org.eclipse.jdt.core.javanature</nature>
+  </natures>
+</projectDescription>
\ No newline at end of file

Modified: trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryConnection.java
===================================================================
--- trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryConnection.java	2008-12-04 23:03:08 UTC (rev 657)
+++ trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryConnection.java	2008-12-05 15:26:03 UTC (rev 658)
@@ -29,10 +29,15 @@
 import org.jboss.dna.graph.connectors.RepositoryConnection;
 import org.jboss.dna.graph.connectors.RepositorySourceException;
 import org.jboss.dna.graph.connectors.RepositorySourceListener;
-import org.jboss.dna.graph.properties.Name;
-import org.jboss.dna.graph.properties.NameFactory;
+import org.jboss.dna.graph.properties.PathFactory;
+import org.jboss.dna.graph.properties.PropertyFactory;
+import org.jboss.dna.graph.properties.ValueFactory;
 import org.jboss.dna.graph.requests.Request;
+import org.jboss.dna.graph.requests.processor.RequestProcessor;
+import org.tmatesoft.svn.core.SVNErrorCode;
+import org.tmatesoft.svn.core.SVNErrorMessage;
 import org.tmatesoft.svn.core.SVNException;
+import org.tmatesoft.svn.core.SVNNodeKind;
 import org.tmatesoft.svn.core.io.SVNRepository;
 
 /**
@@ -53,24 +58,47 @@
         }
     };
 
-    private Name uuidPropertyName;
     private final String sourceName;
-    private final String uuidPropertyNameString;
     private final CachePolicy cachePolicy;
     private final SVNRepository repository;
+    private final boolean updatesAllowed;
     private RepositorySourceListener listener = NO_OP_LISTENER;
 
     public SVNRepositoryConnection( String sourceName,
                                     CachePolicy cachePolicy,
-                                    String uuidPropertyName,
+                                    boolean updatesAllowed,
                                     SVNRepository repository ) {
         assert (sourceName != null);
         assert (repository != null);
-        assert (uuidPropertyName != null);
+
+        SVNNodeKind nodeKind = null;
+        try {
+            nodeKind = repository.checkPath("", -1);
+            if (nodeKind == SVNNodeKind.NONE) {
+                SVNErrorMessage error = SVNErrorMessage.create(SVNErrorCode.UNKNOWN,
+                                                               "No entry at URL ''{0}''",
+                                                               repository.getLocation().getPath());
+                throw new SVNException(error);
+            } else if (nodeKind == SVNNodeKind.UNKNOWN) {
+                SVNErrorMessage error = SVNErrorMessage.create(SVNErrorCode.UNKNOWN,
+                                                               "Entry at URL ''{0}'' is a file while directory was expected",
+                                                               repository.getLocation().getPath());
+                throw new SVNException(error);
+            } else if (nodeKind == SVNNodeKind.FILE) {
+                SVNErrorMessage error = SVNErrorMessage.create(SVNErrorCode.UNKNOWN,
+                                                               "Entry at URL ''{0}'' is a file while directory was expected",
+                                                               repository.getLocation().getPath());
+                throw new SVNException(error);
+            }
+        } catch (SVNException e) {
+            // deal with the exception
+            throw new RuntimeException(e);
+        }
+
         this.sourceName = sourceName;
         this.cachePolicy = cachePolicy;
-        this.uuidPropertyNameString = uuidPropertyName;
         this.repository = repository;
+        this.updatesAllowed = updatesAllowed;
     }
 
     SVNRepository getRepository() {
@@ -133,9 +161,20 @@
      * @see org.jboss.dna.graph.connectors.RepositoryConnection#execute(org.jboss.dna.graph.ExecutionContext,
      *      org.jboss.dna.graph.requests.Request)
      */
-    public void execute( ExecutionContext context,
-                         Request request ) throws RepositorySourceException {
-        // TODO
+    @SuppressWarnings( "unused" )
+    public void execute( final ExecutionContext context,
+                         final Request request ) throws RepositorySourceException {
+
+        final PathFactory pathFactory = context.getValueFactories().getPathFactory();
+        final PropertyFactory propertyFactory = context.getPropertyFactory();
+        final ValueFactory<UUID> uuidFactory = context.getValueFactories().getUuidFactory();
+
+        RequestProcessor processor = new SVNRepositoryRequestProcessor(getSourceName(), context, repository, updatesAllowed);
+        try {
+            processor.process(request);
+        } finally {
+            processor.close();
+        }
     }
 
     /**
@@ -145,24 +184,4 @@
         return this.listener;
     }
 
-    /**
-     * Utility method to calculate (if required) and obtain the name that should be used to store the UUID values for each node.
-     * This method may be called without regard to synchronization, since it should return the same value if it happens to be
-     * called concurrently while not yet initialized.
-     * 
-     * @param context the execution context
-     * @return the name, or null if the UUID should not be stored
-     */
-    protected Name getUuidPropertyName( ExecutionContext context ) {
-        if (uuidPropertyName == null) {
-            NameFactory nameFactory = context.getValueFactories().getNameFactory();
-            uuidPropertyName = nameFactory.create(this.uuidPropertyNameString);
-        }
-        return this.uuidPropertyName;
-    }
-
-    protected UUID generateUuid() {
-        return UUID.randomUUID();
-    }
-
 }

Modified: trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryConnectorI18n.java
===================================================================
--- trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryConnectorI18n.java	2008-12-04 23:03:08 UTC (rev 657)
+++ trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryConnectorI18n.java	2008-12-05 15:26:03 UTC (rev 658)
@@ -32,10 +32,14 @@
 
     public static I18n connectorName;
     public static I18n nodeDoesNotExist;
+    public static I18n nodeIsActuallyUnknow;
+    public static I18n nodeTypeIsNotSupported;
     public static I18n propertyIsRequired;
     public static I18n errorSerializingCachePolicyInSource;
     public static I18n objectFoundInJndiWasNotCache;
     public static I18n objectFoundInJndiWasNotCacheFactory;
+    public static I18n locationInRequestMustHavePath;
+    public static I18n sourceIsReadOnly;
 
     static {
         try {

Modified: trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryLexicon.java
===================================================================
--- trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryLexicon.java	2008-12-04 23:03:08 UTC (rev 657)
+++ trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryLexicon.java	2008-12-05 15:26:03 UTC (rev 658)
@@ -25,7 +25,11 @@
 import org.jboss.dna.graph.properties.basic.BasicName;
 
 
-
+/**
+ * The namespace and property names used within a {@link SVNRepositorySource} to store internal information.
+ * 
+ * @author Serge Pagop
+ */
 public class SVNRepositoryLexicon {
 
     public static class Namespace {
@@ -34,5 +38,6 @@
     }
 
     public static final Name CHILD_PATH_SEGMENT_LIST = new BasicName(Namespace.URI, "orderedChildNames");
+    public static final Name UUID = new BasicName(Namespace.URI, "uuid");
 
 }

Added: 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	                        (rev 0)
+++ trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryRequestProcessor.java	2008-12-05 15:26:03 UTC (rev 658)
@@ -0,0 +1,395 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors. 
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.connector.svn;
+
+import java.io.ByteArrayOutputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import org.jboss.dna.common.i18n.I18n;
+import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.JcrLexicon;
+import org.jboss.dna.graph.Location;
+import org.jboss.dna.graph.connectors.RepositorySourceException;
+import org.jboss.dna.graph.properties.Name;
+import org.jboss.dna.graph.properties.NameFactory;
+import org.jboss.dna.graph.properties.Path;
+import org.jboss.dna.graph.properties.PathFactory;
+import org.jboss.dna.graph.properties.PathNotFoundException;
+import org.jboss.dna.graph.properties.Property;
+import org.jboss.dna.graph.properties.PropertyFactory;
+import org.jboss.dna.graph.properties.basic.BasicMultiValueProperty;
+import org.jboss.dna.graph.requests.CopyBranchRequest;
+import org.jboss.dna.graph.requests.CreateNodeRequest;
+import org.jboss.dna.graph.requests.DeleteBranchRequest;
+import org.jboss.dna.graph.requests.MoveBranchRequest;
+import org.jboss.dna.graph.requests.ReadAllChildrenRequest;
+import org.jboss.dna.graph.requests.ReadAllPropertiesRequest;
+import org.jboss.dna.graph.requests.RemovePropertiesRequest;
+import org.jboss.dna.graph.requests.RenameNodeRequest;
+import org.jboss.dna.graph.requests.Request;
+import org.jboss.dna.graph.requests.UpdatePropertiesRequest;
+import org.jboss.dna.graph.requests.processor.RequestProcessor;
+import org.tmatesoft.svn.core.SVNDirEntry;
+import org.tmatesoft.svn.core.SVNException;
+import org.tmatesoft.svn.core.SVNNodeKind;
+import org.tmatesoft.svn.core.SVNProperties;
+import org.tmatesoft.svn.core.SVNProperty;
+import org.tmatesoft.svn.core.io.SVNRepository;
+
+/**
+ * The {@link RequestProcessor} implementation for the file subversion repository connector. This is the class that does the bulk
+ * of the work in the subversion repository connector, since it processes all requests.
+ * 
+ * @author Serge Emmanuel Pagop
+ */
+public class SVNRepositoryRequestProcessor extends RequestProcessor {
+
+    protected static final String BACK_SLASH = "/";
+
+    private final String defaultNamespaceUri;
+    private final boolean updatesAllowed;
+    private SVNRepository repository;
+
+    /**
+     * @param sourceName
+     * @param context
+     * @param repository
+     * @param updatesAllowed true if this connector supports updating the subversion repository, or false if the connector is read
+     *        only
+     */
+    protected SVNRepositoryRequestProcessor( String sourceName,
+                                             ExecutionContext context,
+                                             SVNRepository repository,
+                                             boolean updatesAllowed ) {
+        super(sourceName, context);
+        this.defaultNamespaceUri = getExecutionContext().getNamespaceRegistry().getDefaultNamespaceUri();
+        this.updatesAllowed = updatesAllowed;
+        this.repository = repository;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.graph.requests.processor.RequestProcessor#process(org.jboss.dna.graph.requests.CopyBranchRequest)
+     */
+    @Override
+    public void process( CopyBranchRequest request ) {
+        verifyUpdatesAllowed();
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.graph.requests.processor.RequestProcessor#process(org.jboss.dna.graph.requests.CreateNodeRequest)
+     */
+    @Override
+    public void process( CreateNodeRequest request ) {
+        verifyUpdatesAllowed();
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.graph.requests.processor.RequestProcessor#process(org.jboss.dna.graph.requests.DeleteBranchRequest)
+     */
+    @Override
+    public void process( DeleteBranchRequest request ) {
+        verifyUpdatesAllowed();
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.graph.requests.processor.RequestProcessor#process(org.jboss.dna.graph.requests.MoveBranchRequest)
+     */
+    @Override
+    public void process( MoveBranchRequest request ) {
+        verifyUpdatesAllowed();
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.graph.requests.processor.RequestProcessor#process(org.jboss.dna.graph.requests.ReadAllChildrenRequest)
+     */
+    @SuppressWarnings( "unchecked" )
+    @Override
+    public void process( ReadAllChildrenRequest request ) {
+        Location myLocation = request.of();
+        Path nodePath = getPathFor(myLocation, request);
+        try {
+            SVNNodeKind kind = validateNodeKind(nodePath);
+            String requestedNodePath = nodePath.getString(getExecutionContext().getNamespaceRegistry());
+            if (kind == SVNNodeKind.FILE) { // the requested node is a file.
+                SVNDirEntry entry = getEntryInfo(requestedNodePath);
+                if (!nodePath.getLastSegment().getName().equals(JcrLexicon.CONTENT)) {
+                    String localName = entry.getName();
+                    Name childName = nameFactory().create(defaultNamespaceUri, localName);
+                    String url = entry.getURL().toString();
+                    Property idProperty = propertyFactory().create(childName, url);
+                    request.addChild(new Location(pathFactory().create(nodePath, JcrLexicon.CONTENT), idProperty));
+                }
+            } else if (kind == SVNNodeKind.DIR) { // the requested node is a directory.
+                final Collection<SVNDirEntry> dirEntries = getRepository().getDir(requestedNodePath,
+                                                                                  -1,
+                                                                                  null,
+                                                                                  (Collection<SVNDirEntry>)null);
+                for (SVNDirEntry dirEntry : dirEntries) {
+                    if (dirEntry.getKind() == SVNNodeKind.FILE) {
+                        String localName = dirEntry.getName();
+                        Path newPath = pathFactory().create(requestedNodePath + BACK_SLASH + localName);
+                        if (!newPath.getLastSegment().getName().equals(JcrLexicon.CONTENT)) {
+                            Name childName = nameFactory().create(defaultNamespaceUri, localName);
+                            String url = dirEntry.getURL().toString();
+                            Property idProperty = propertyFactory().create(childName, url);
+                            Location location = new Location(pathFactory().create(newPath, JcrLexicon.CONTENT), idProperty);
+                            request.addChild(location);
+                        }
+                    } else if (dirEntry.getKind() == SVNNodeKind.DIR) {
+                        String localName = dirEntry.getName();
+                        Name childName = nameFactory().create(defaultNamespaceUri, localName);
+                        Path childPath = pathFactory().create(nodePath, childName);
+                        String url = dirEntry.getURL().toString();
+                        Property idProperty = propertyFactory().create(childName, url);
+                        request.addChild(childPath, idProperty);
+                    }
+                }
+            }
+            request.setActualLocationOfNode(myLocation);
+        } catch (SVNException e) {
+            // if a failure occured while connecting to a repository
+            // or the user's authentication failed (see
+            // path not found in the specified revision
+            // or is not a directory
+            e.printStackTrace();
+            request.setError(e);
+        }
+
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.graph.requests.processor.RequestProcessor#process(org.jboss.dna.graph.requests.ReadAllPropertiesRequest)
+     */
+    @Override
+    public void process( ReadAllPropertiesRequest request ) {
+        Location myLocation = request.at();
+        Path nodePath = getPathFor(myLocation, request);
+        if (nodePath.isRoot()) {
+            // There are no properties on the root ...
+            request.setActualLocationOfNode(myLocation);
+            return;
+        }
+        try {
+            // See if the path is a "jcr:content" node ...
+            if (nodePath.getLastSegment().getName().equals(JcrLexicon.CONTENT)) {
+                // //"jcr:primaryType" property value of "nt:resource",
+                // "jcr:data" property whose value are the contents of the file
+                // and a few other properties, like "jcr:encoding", "jcr:mimeType" and "jcr:lastModified" and
+                // also "jcr:created" property
+                Path parent = nodePath.getParent();
+                ByteArrayOutputStream os = new ByteArrayOutputStream();
+                SVNProperties fileProperties = new SVNProperties();
+                List<Property> properties = new ArrayList<Property>();
+                getData(parent.getString(getExecutionContext().getNamespaceRegistry()), fileProperties, os);
+
+                Property ntResourceproperty = propertyFactory().create(JcrLexicon.PRIMARY_TYPE, "nt:resource");
+                properties.add(ntResourceproperty);
+                String mimeType = fileProperties.getStringValue(SVNProperty.MIME_TYPE);
+                if (mimeType != null) {
+                    Property jcrMimeTypeProperty = propertyFactory().create(JcrLexicon.MIME, mimeType);
+                    properties.add(jcrMimeTypeProperty);
+                }
+                String created = fileProperties.getStringValue(SVNProperty.COMMITTED_DATE);
+                if (created != null) {
+                    Property jcrCreatedProperty = propertyFactory().create(JcrLexicon.CREATED, created);
+                    properties.add(jcrCreatedProperty);
+                }
+                SVNDirEntry entry = getEntryInfo(parent.getString(getExecutionContext().getNamespaceRegistry()));
+                Date lastModified = entry.getDate();
+                if (lastModified != null) {
+                    Property jcrLastModifiedProperty = propertyFactory().create(JcrLexicon.LAST_MODIFIED, lastModified.toString());
+                    properties.add(jcrLastModifiedProperty);
+                }
+                if (os.toByteArray().length > 0) {
+                    Property jcrDataProperty = propertyFactory().create(JcrLexicon.DATA, os.toByteArray());
+                    properties.add(jcrDataProperty);
+                }
+                request.addProperties(properties.toArray(new BasicMultiValueProperty[0]));
+            } else {
+                SVNNodeKind kind = validateNodeKind(nodePath);
+                if (kind == SVNNodeKind.FILE) {
+                    // "jcr:primaryType" property whose value is "nt:file".
+                    Property ntFileProperty = propertyFactory().create(JcrLexicon.PRIMARY_TYPE, "nt:file");
+                    request.addProperty(ntFileProperty);
+
+                } else if (kind == SVNNodeKind.DIR) {
+                    // A directory maps to a single node with a name that represents the name of the directory and a
+                    // "jcr:primaryType" property whose value is "nt:folder"
+                    Property property = propertyFactory().create(JcrLexicon.PRIMARY_TYPE, "nt:folder");
+                    request.addProperty(property);
+                }
+            }
+            request.setActualLocationOfNode(myLocation);
+
+        } catch (SVNException e) {
+            e.printStackTrace();
+            request.setError(e);
+        }
+    }
+    
+    /**
+     * {@inheritDoc}
+     *
+     * @see org.jboss.dna.graph.requests.processor.RequestProcessor#process(org.jboss.dna.graph.requests.RemovePropertiesRequest)
+     */
+    @Override
+    public void process( RemovePropertiesRequest request ) {
+        verifyUpdatesAllowed();
+        super.process(request);
+    }
+
+    /**
+     * {@inheritDoc}
+     *
+     * @see org.jboss.dna.graph.requests.processor.RequestProcessor#process(org.jboss.dna.graph.requests.RenameNodeRequest)
+     */
+    @Override
+    public void process( RenameNodeRequest request ) {
+        verifyUpdatesAllowed();
+        super.process(request);
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.graph.requests.processor.RequestProcessor#process(org.jboss.dna.graph.requests.UpdatePropertiesRequest)
+     */
+    @Override
+    public void process( UpdatePropertiesRequest request ) {
+    }
+
+    protected void verifyUpdatesAllowed() {
+        if (!updatesAllowed) {
+            throw new RepositorySourceException(getSourceName(),
+                                                SVNRepositoryConnectorI18n.sourceIsReadOnly.text(getSourceName()));
+        }
+    }
+
+    protected NameFactory nameFactory() {
+        return getExecutionContext().getValueFactories().getNameFactory();
+    }
+
+    protected PathFactory pathFactory() {
+        return getExecutionContext().getValueFactories().getPathFactory();
+    }
+
+    protected PropertyFactory propertyFactory() {
+        return getExecutionContext().getPropertyFactory();
+    }
+
+    protected Path getPathFor( Location location,
+                               Request request ) {
+        Path path = location.getPath();
+        if (path == null) {
+            I18n msg = SVNRepositoryConnectorI18n.locationInRequestMustHavePath;
+            throw new RepositorySourceException(getSourceName(), msg.text(getSourceName(), request));
+        }
+        return path;
+    }
+
+    /**
+     * Get the content of a file.
+     * 
+     * @param path - the path to that file.
+     * @param properties - the properties of the file.
+     * @param os - the output stream where to store the content.
+     * @throws SVNException - throws if such path is not at that revision or in case of a connection problem.
+     */
+    protected void getData( String path,
+                            SVNProperties properties,
+                            OutputStream os ) throws SVNException {
+        getRepository().getFile(path, -1, properties, os);
+
+    }
+
+    /**
+     * @return repository
+     */
+    public SVNRepository getRepository() {
+        return repository;
+    }
+
+    /**
+     * Validate the kind of node and throws an exception if necessary.
+     * 
+     * @param requestedPath
+     * @return the kind.
+     */
+    protected SVNNodeKind validateNodeKind( final Path requestedPath ) {
+        String myPath = requestedPath.getString(getExecutionContext().getNamespaceRegistry());
+        SVNNodeKind kind = null;
+        try {
+            kind = getRepository().checkPath(myPath, -1);
+            if (kind == SVNNodeKind.NONE) {
+                // node does not exist or requested node is not correct.
+                throw new PathNotFoundException(new Location(requestedPath), null,
+                                                SVNRepositoryConnectorI18n.nodeDoesNotExist.text(myPath));
+            } else if (kind == SVNNodeKind.UNKNOWN) {
+                // node is unknown
+                throw new PathNotFoundException(new Location(requestedPath), null,
+                                                SVNRepositoryConnectorI18n.nodeIsActuallyUnknow.text(myPath));
+            }
+        } catch (SVNException e) {
+            // if a failure occured while connecting to a repository
+            // * or the user's authentication failed (see
+            // * {@link org.tmatesoft.svn.core.SVNAuthenticationException})
+            // TODO RepositorySourceAuthenticationException
+        }
+
+        return kind;
+    }
+
+    /**
+     * Get some important informations of a path
+     * 
+     * @param path - the path
+     * @return - the {@link SVNDirEntry}.
+     */
+    protected SVNDirEntry getEntryInfo( String path ) {
+        assert path != null;
+        SVNDirEntry entry = null;
+        try {
+            entry = getRepository().info(path, -1);
+        } catch (SVNException e) {
+            // if a failure occured while connecting to a repository
+            // * or the user's authentication failed (see
+            // * {@link org.tmatesoft.svn.core.SVNAuthenticationException})
+            // TODO RepositorySourceAuthenticationException
+        }
+        return entry;
+    }
+}

Modified: trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositorySource.java
===================================================================
--- trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositorySource.java	2008-12-04 23:03:08 UTC (rev 657)
+++ trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositorySource.java	2008-12-05 15:26:03 UTC (rev 658)
@@ -30,7 +30,7 @@
 import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.Map;
-import java.util.UUID;
+import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 import javax.naming.BinaryRefAddr;
 import javax.naming.Context;
@@ -40,16 +40,15 @@
 import javax.naming.Referenceable;
 import javax.naming.StringRefAddr;
 import javax.naming.spi.ObjectFactory;
+import net.jcip.annotations.ThreadSafe;
 import org.jboss.dna.common.i18n.I18n;
 import org.jboss.dna.common.util.CheckArg;
-import org.jboss.dna.graph.DnaLexicon;
 import org.jboss.dna.graph.cache.CachePolicy;
 import org.jboss.dna.graph.connectors.RepositoryConnection;
 import org.jboss.dna.graph.connectors.RepositoryContext;
 import org.jboss.dna.graph.connectors.RepositorySource;
 import org.jboss.dna.graph.connectors.RepositorySourceCapabilities;
 import org.jboss.dna.graph.connectors.RepositorySourceException;
-import org.jboss.dna.graph.properties.Property;
 import org.tmatesoft.svn.core.SVNException;
 import org.tmatesoft.svn.core.SVNURL;
 import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager;
@@ -65,7 +64,8 @@
  * {@link SVNRepository} instance or creating a new instance. This process is controlled entirely by the JavaBean properties of
  * the SVNRepositorySource instance. Like other {@link RepositorySource} classes, instances of SVNRepositorySource can be placed
  * into JNDI and do support the creation of {@link Referenceable JNDI referenceable} objects and resolution of references into
- * SVNRepositorySource. </p>
+ * SVNRepositorySource.
+ * </p>
  * 
  * @author Serge Pagop
  */
@@ -77,14 +77,25 @@
      */
     public static final int DEFAULT_RETRY_LIMIT = 0;
 
-    protected static final RepositorySourceCapabilities CAPABILITIES = new RepositorySourceCapabilities(false, true);
+    /**
+     * This source supports events.
+     */
+    protected static final boolean SUPPORTS_EVENTS = true;
+    /**
+     * This source supports same-name-siblings.
+     */
+    protected static final boolean SUPPORTS_SAME_NAME_SIBLINGS = false;
+    /**
+     * This source supports udpates by default, but each instance may be configured to {@link #setSupportsUpdates(boolean) be
+     * read-only or updateable}.
+     */
+    public static final boolean DEFAULT_SUPPORTS_UPDATES = true;
 
-    public static final String DEFAULT_UUID_PROPERTY_NAME = DnaLexicon.UUID.getString();
+    public static final int DEFAULT_CACHE_TIME_TO_LIVE_IN_SECONDS = 60 * 5; // 5 minutes
 
+
     protected static final String SOURCE_NAME = "sourceName";
-    protected static final String ROOT_NODE_UUID = "rootNodeUuid";
     protected static final String DEFAULT_CACHE_POLICY = "defaultCachePolicy";
-    protected static final String UUID_PROPERTY_NAME = "uuidPropertyName";
     protected static final String SVN_REPOS_JNDI_NAME = "svnReposJndiName";
     protected static final String SVN_REPOS_FACTORY_JNDI_NAME = "svnReposFactoryJndiName";
     protected static final String SVN_URL = "svnURL";
@@ -94,13 +105,13 @@
 
     private final AtomicInteger retryLimit = new AtomicInteger(DEFAULT_RETRY_LIMIT);
     private String name;
-    private UUID rootNodeUuid = UUID.randomUUID();
-    private String uuidPropertyName = DEFAULT_UUID_PROPERTY_NAME;
     private String svnURL;
     private String svnUsername;
     private String svnPassword;
     private CachePolicy defaultCachePolicy;
 
+    private final Capabilities capabilities = new Capabilities();
+
     private transient Context jndiContext;
     private transient RepositoryContext repositoryContext;
     private transient SVNRepository svnRepository;
@@ -110,6 +121,15 @@
      */
     public SVNRepositorySource() {
     }
+    
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.graph.connectors.RepositorySource#getCapabilities()
+     */
+    public RepositorySourceCapabilities getCapabilities() {
+        return capabilities;
+    }
 
     /**
      * {@inheritDoc}
@@ -180,61 +200,6 @@
         this.defaultCachePolicy = defaultCachePolicy;
     }
 
-    /**
-     * Get the UUID of the root node for the cache. If the cache exists, this UUID is not used but is instead set to the UUID of
-     * the existing root node.
-     * 
-     * @return the UUID of the root node for the cache.
-     */
-    public String getRootNodeUuid() {
-        return this.rootNodeUuid.toString();
-    }
-
-    /**
-     * Get the UUID of the root node for the cache. If the cache exists, this UUID is not used but is instead set to the UUID of
-     * the existing root node.
-     * 
-     * @return the UUID of the root node for the cache.
-     */
-    public UUID getRootNodeUuidObject() {
-        return this.rootNodeUuid;
-    }
-
-    /**
-     * Set the UUID of the root node in this repository. If the cache exists, this UUID is not used but is instead set to the UUID
-     * of the existing root node.
-     * 
-     * @param rootNodeUuid the UUID of the root node for the cache, or null if the UUID should be randomly generated
-     */
-    public synchronized void setRootNodeUuid( String rootNodeUuid ) {
-        UUID uuid = null;
-        if (rootNodeUuid == null) uuid = UUID.randomUUID();
-        else uuid = UUID.fromString(rootNodeUuid);
-        if (this.rootNodeUuid.equals(uuid)) return; // unchanged
-        this.rootNodeUuid = uuid;
-    }
-
-    /**
-     * Get the {@link Property#getName() property name} where the UUID is stored for each node.
-     * 
-     * @return the name of the UUID property; never null
-     */
-    public String getUuidPropertyName() {
-        return this.uuidPropertyName;
-    }
-
-    /**
-     * Set the {@link Property#getName() property name} where the UUID is stored for each node.
-     * 
-     * @param uuidPropertyName the name of the UUID property, or null if the {@link #DEFAULT_UUID_PROPERTY_NAME default name}
-     *        should be used
-     */
-    public synchronized void setUuidPropertyName( String uuidPropertyName ) {
-        if (uuidPropertyName == null || uuidPropertyName.trim().length() == 0) uuidPropertyName = DEFAULT_UUID_PROPERTY_NAME;
-        if (this.uuidPropertyName.equals(uuidPropertyName)) return; // unchanged
-        this.uuidPropertyName = uuidPropertyName;
-    }
-
     public String getSVNURL() {
         return this.svnURL;
     }
@@ -273,15 +238,25 @@
     }
 
     /**
-     * {@inheritDoc}
+     * Get whether this source supports updates.
      * 
-     * @see org.jboss.dna.graph.connectors.RepositorySource#getCapabilities()
+     * @return true if this source supports updates, or false if this source only supports reading content.
      */
-    public RepositorySourceCapabilities getCapabilities() {
-        return CAPABILITIES;
+    public boolean getSupportsUpdates() {
+        return capabilities.supportsUpdates();
     }
 
     /**
+     * Set whether this source supports updates.
+     * 
+     * @param supportsUpdates true if this source supports updating content, or false if this source only supports reading
+     *        content.
+     */
+    public synchronized void setSupportsUpdates( boolean supportsUpdates ) {
+        capabilities.setSupportsUpdates(supportsUpdates);
+    }
+
+    /**
      * {@inheritDoc}
      * 
      * @see org.jboss.dna.graph.connectors.RepositorySource#getConnection()
@@ -291,10 +266,6 @@
             I18n msg = SVNRepositoryConnectorI18n.propertyIsRequired;
             throw new RepositorySourceException(getName(), msg.text("name"));
         }
-        if (getUuidPropertyName() == null) {
-            I18n msg = SVNRepositoryConnectorI18n.propertyIsRequired;
-            throw new RepositorySourceException(getUuidPropertyName(), msg.text("uuidPropertyName"));
-        }
         SVNURL svnURL = null;
         if (this.svnRepository == null) {
             try {
@@ -306,20 +277,22 @@
                     ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(this.getSVNUsername(),
                                                                                                          this.getSVNPassword());
                     this.svnRepository.setAuthenticationManager(authManager);
-                }
-                if (usedProtocol.equals(SVNProtocol.HTTP.value()) || usedProtocol.equals(SVNProtocol.HTTPS.value())) {
+                } else if (usedProtocol.equals(SVNProtocol.HTTP.value()) || usedProtocol.equals(SVNProtocol.HTTPS.value())) {
                     DAVRepositoryFactory.setup();
                     this.svnRepository = DAVRepositoryFactory.create(svnURL);
                     ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(this.getSVNUsername(),
                                                                                                          this.getSVNPassword());
                     this.svnRepository.setAuthenticationManager(authManager);
-                }
-                if (usedProtocol.equals(SVNProtocol.FILE.value())) {
+                } else if (usedProtocol.equals(SVNProtocol.FILE.value())) {
                     FSRepositoryFactory.setup();
                     this.svnRepository = FSRepositoryFactory.create(svnURL);
                     ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(this.getSVNUsername(),
                                                                                                          this.getSVNPassword());
                     this.svnRepository.setAuthenticationManager(authManager);
+                } else {
+                    // protocol not supported by this connector
+                    throw new RepositorySourceException(getSVNURL(),
+                                                        "Protocol is not supported by this connector or there is problem in the svn url");
                 }
 
             } catch (SVNException ex) {
@@ -327,8 +300,9 @@
                 throw new RepositorySourceException(getSVNURL(), msg.text(this.getSVNURL()), ex);
             }
         }
-        return new SVNRepositoryConnection(this.getName(), this.getDefaultCachePolicy(), this.getUuidPropertyName(),
-                                           this.svnRepository);
+        boolean supportsUpdates = getSupportsUpdates();
+        return new SVNRepositoryConnection(this.getName(), this.getDefaultCachePolicy(),
+                                           supportsUpdates, this.svnRepository);
     }
 
     protected Context getContext() {
@@ -370,12 +344,6 @@
         if (getName() != null) {
             ref.add(new StringRefAddr(SOURCE_NAME, getName()));
         }
-        if (getRootNodeUuid() != null) {
-            ref.add(new StringRefAddr(ROOT_NODE_UUID, getRootNodeUuid().toString()));
-        }
-        if (getUuidPropertyName() != null) {
-            ref.add(new StringRefAddr(UUID_PROPERTY_NAME, getUuidPropertyName()));
-        }
         if (getSVNURL() != null) {
             ref.add(new StringRefAddr(SVN_URL, getSVNURL()));
         }
@@ -434,8 +402,6 @@
                 }
             }
             String sourceName = (String)values.get(SOURCE_NAME);
-            String rootNodeUuidString = (String)values.get(ROOT_NODE_UUID);
-            String uuidPropertyName = (String)values.get(UUID_PROPERTY_NAME);
             String svnURL = (String)values.get(SVN_URL);
             String svnUsername = (String)values.get(SVN_USERNAME);
             String svnPassword = (String)values.get(SVN_PASSWORD);
@@ -445,8 +411,6 @@
             // Create the source instance ...
             SVNRepositorySource source = new SVNRepositorySource();
             if (sourceName != null) source.setName(sourceName);
-            if (rootNodeUuidString != null) source.setRootNodeUuid(rootNodeUuidString);
-            if (uuidPropertyName != null) source.setUuidPropertyName(uuidPropertyName);
             if (svnURL != null) source.setSVNURL(svnURL);
             if (svnUsername != null) source.setSVNUsername(svnUsername);
             if (svnPassword != null) source.setSVNPassword(svnPassword);
@@ -459,4 +423,22 @@
         return null;
     }
 
+    @ThreadSafe
+    protected class Capabilities extends RepositorySourceCapabilities {
+        private final AtomicBoolean supportsUpdates = new AtomicBoolean(DEFAULT_SUPPORTS_UPDATES);
+
+        /*package*/Capabilities() {
+            super(SUPPORTS_SAME_NAME_SIBLINGS, DEFAULT_SUPPORTS_UPDATES, SUPPORTS_EVENTS);
+        }
+
+        /*package*/void setSupportsUpdates( boolean supportsUpdates ) {
+            this.supportsUpdates.set(supportsUpdates);
+        }
+
+        @Override
+        public boolean supportsUpdates() {
+            return this.supportsUpdates.get();
+        }
+    }
+
 }

Modified: trunk/extensions/dna-connector-svn/src/main/resources/org/jboss/dna/connector/svn/SVNConnectorI18n.properties
===================================================================
--- trunk/extensions/dna-connector-svn/src/main/resources/org/jboss/dna/connector/svn/SVNConnectorI18n.properties	2008-12-04 23:03:08 UTC (rev 657)
+++ trunk/extensions/dna-connector-svn/src/main/resources/org/jboss/dna/connector/svn/SVNConnectorI18n.properties	2008-12-05 15:26:03 UTC (rev 658)
@@ -21,8 +21,11 @@
 #
 
 connectorName = SVN Connector
-nodeDoesNotExist = Could not find an existing node at {0}
+nodeDoesNotExist = This node kind is missing at {0}
+locationInRequestMustHavePath = Location must have a path {0}
+nodeIsActuallyUnknow =  This node kind is actually unknown {0}
 propertyIsRequired = The {0} property is required but has no value
 errorSerializingCachePolicyInSource = Error serializing a {0} instance owned by the {1} SVNRepositorySource
 objectFoundInJndiWasNotSVNRepository = Object in JNDI at {0} found by SVNRepositorySource {1} was expected to be a typ of org.tmatesoft.svn.core.io.SVNRepository but instead was {2}
-objectFoundInJndiWasNotSVNRepositoryFactory =Object in JNDI at {0} found by SVNRepositorySource {1} was expected to be a typ of org.tmatesoft.svn.core.io.SVNRepositoryFactory but instead was {2}
\ No newline at end of file
+objectFoundInJndiWasNotSVNRepositoryFactory =Object in JNDI at {0} found by SVNRepositorySource {1} was expected to be a typ of org.tmatesoft.svn.core.io.SVNRepositoryFactory but instead was {2}
+sourceIsReadOnly = {0} is a read-only source; no updates are allowed
\ No newline at end of file

Modified: trunk/extensions/dna-connector-svn/src/test/java/org/jboss/dna/connector/svn/SVNConnectorTestUtil.java
===================================================================
--- trunk/extensions/dna-connector-svn/src/test/java/org/jboss/dna/connector/svn/SVNConnectorTestUtil.java	2008-12-04 23:03:08 UTC (rev 657)
+++ trunk/extensions/dna-connector-svn/src/test/java/org/jboss/dna/connector/svn/SVNConnectorTestUtil.java	2008-12-05 15:26:03 UTC (rev 658)
@@ -43,10 +43,13 @@
      * @return {@link DAVRepository}.
      * @throws SVNException - when error situation.
      */
-    public static DAVRepository createDAVRepositoryURL( String url,
-                                                        String username,
-                                                        String password ) throws SVNException {
+    public static DAVRepository createRepository( String url,
+                                                  String username,
+                                                  String password ) throws SVNException {
+        // for DAV (over http and https)
         DAVRepositoryFactory.setup();
+
+        
         // The factory knows how to create a DAVRepository
         DAVRepository repository = (DAVRepository)DAVRepositoryFactory.create(SVNURL.parseURIDecoded(url));
         ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(username, password);

Modified: trunk/extensions/dna-connector-svn/src/test/java/org/jboss/dna/connector/svn/SVNRepositoryConnectionTest.java
===================================================================
--- trunk/extensions/dna-connector-svn/src/test/java/org/jboss/dna/connector/svn/SVNRepositoryConnectionTest.java	2008-12-04 23:03:08 UTC (rev 657)
+++ trunk/extensions/dna-connector-svn/src/test/java/org/jboss/dna/connector/svn/SVNRepositoryConnectionTest.java	2008-12-05 15:26:03 UTC (rev 658)
@@ -28,22 +28,46 @@
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.stub;
 import static org.mockito.Mockito.verify;
+import java.io.ByteArrayOutputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
 import java.util.concurrent.TimeUnit;
+import org.jboss.dna.common.text.UrlEncoder;
 import org.jboss.dna.graph.BasicExecutionContext;
 import org.jboss.dna.graph.DnaLexicon;
 import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.Graph;
+import org.jboss.dna.graph.JcrLexicon;
+import org.jboss.dna.graph.JcrNtLexicon;
+import org.jboss.dna.graph.Location;
+import org.jboss.dna.graph.Node;
 import org.jboss.dna.graph.cache.CachePolicy;
 import org.jboss.dna.graph.connectors.RepositorySourceListener;
 import org.jboss.dna.graph.properties.Name;
 import org.jboss.dna.graph.properties.NameFactory;
+import org.jboss.dna.graph.properties.Path;
 import org.jboss.dna.graph.properties.PathFactory;
+import org.jboss.dna.graph.properties.PathNotFoundException;
 import org.jboss.dna.graph.properties.PropertyFactory;
+import org.jboss.dna.graph.properties.Path.Segment;
+import org.jboss.dna.graph.requests.ReadAllChildrenRequest;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.MockitoAnnotations;
 import org.mockito.MockitoAnnotations.Mock;
+import org.tmatesoft.svn.core.SVNDirEntry;
+import org.tmatesoft.svn.core.SVNException;
+import org.tmatesoft.svn.core.SVNNodeKind;
+import org.tmatesoft.svn.core.SVNProperties;
 import org.tmatesoft.svn.core.internal.io.dav.DAVRepository;
+import org.tmatesoft.svn.core.internal.util.SVNEncodingUtil;
+import org.tmatesoft.svn.core.io.SVNRepository;
 
 /**
  * @author Serge Pagop
@@ -58,15 +82,21 @@
     private DAVRepository davRepository;
     private String uuidPropertyName;
     private String sourceName;
+    private Graph graph;
 
     @Mock
     private CachePolicy policy;
 
+    @Mock
+    private ReadAllChildrenRequest request;
+
     @Before
     public void beforeEach() throws Exception {
         MockitoAnnotations.initMocks(this);
         context = new BasicExecutionContext();
         context.getNamespaceRegistry().register(DnaLexicon.Namespace.PREFIX, DnaLexicon.Namespace.URI);
+        context.getNamespaceRegistry().register(JcrLexicon.Namespace.PREFIX, JcrLexicon.Namespace.URI);
+        context.getNamespaceRegistry().register(JcrNtLexicon.Namespace.PREFIX, JcrNtLexicon.Namespace.URI);
         pathFactory = context.getValueFactories().getPathFactory();
         propertyFactory = context.getPropertyFactory();
         nameFactory = context.getValueFactories().getNameFactory();
@@ -76,38 +106,34 @@
         String username = "anonymous";
         String password = "anonymous";
         // Set up the appropriate factory for a particular protocol
-        davRepository = SVNConnectorTestUtil.createDAVRepositoryURL(url, username, password);
+        davRepository = SVNConnectorTestUtil.createRepository(url, username, password);
         sourceName = "the source name";
-        uuidPropertyName = "dna:uuid";
-        connection = new SVNRepositoryConnection(sourceName, policy, uuidPropertyName, davRepository);
+        connection = new SVNRepositoryConnection(sourceName, policy, Boolean.FALSE, davRepository);
+        // And create the graph ...
+        graph = Graph.create(connection, context);
     }
 
     @After
     public void afterEach() {
+        try {
+            if (connection != null) connection.close();
+        } finally {
 
+        }
     }
 
     @Test( expected = AssertionError.class )
     public void shouldFailToInstantiateIfSourceNameIsNull() {
         sourceName = null;
-        connection = new SVNRepositoryConnection(sourceName, policy, uuidPropertyName, davRepository);
+        connection = new SVNRepositoryConnection(sourceName, policy, Boolean.FALSE, davRepository);
     }
-    
+
     @Test( expected = AssertionError.class )
     public void shouldFailToInstantiateIfRepositoryIsNull() {
         davRepository = null;
-        connection = new SVNRepositoryConnection(sourceName, policy, uuidPropertyName, davRepository);
+        connection = new SVNRepositoryConnection(sourceName, policy, Boolean.FALSE, davRepository);
     }
-    
-    
 
-    @Test( expected = AssertionError.class )
-    public void shouldFailToInstantiateIfUuidPropertyNameIsNull() throws Exception {
-        uuidPropertyName = null;
-        connection = new SVNRepositoryConnection(sourceName, policy, uuidPropertyName, davRepository);
-
-    }
-
     @Test
     public void shouldInstantiateWithValidSourceAndDAVRepositoryReferences() throws Exception {
         assertThat(connection, is(notNullValue()));
@@ -123,16 +149,16 @@
         assertThat(connection.getDefaultCachePolicy(), is(sameInstance(policy)));
     }
 
-    @Test
-    public void shouldGetTheSVNRepositoryRootFromTheSVNRepositoryWhenPinged() throws Exception {
-        CachePolicy policy = mock(CachePolicy.class);
-        davRepository = mock(DAVRepository.class);
-        connection = new SVNRepositoryConnection("the source name", policy, SVNRepositorySource.DEFAULT_UUID_PROPERTY_NAME,
-                                                 davRepository);
-        stub(davRepository.getRepositoryRoot(true)).toReturn(null);
-        assertThat(connection.ping(1, TimeUnit.SECONDS), is(true));
-        verify(davRepository).getRepositoryRoot(true);
-    }
+    // @Test
+    // public void shouldGetTheSVNRepositoryRootFromTheSVNRepositoryWhenPinged() throws Exception {
+    // CachePolicy policy = mock(CachePolicy.class);
+    // davRepository = mock(DAVRepository.class);
+    // connection = new SVNRepositoryConnection("the source name", policy, SVNRepositorySource.DEFAULT_UUID_PROPERTY_NAME,
+    // davRepository);
+    // stub(davRepository.getRepositoryRoot(true)).toReturn(null);
+    // assertThat(connection.ping(1, TimeUnit.SECONDS), is(true));
+    // verify(davRepository).getRepositoryRoot(true);
+    // }
 
     @Test
     public void shouldHaveNoOpListenerWhenCreated() {
@@ -154,40 +180,49 @@
         assertThat(connection.getListener(), is(sameInstance(SVNRepositoryConnection.NO_OP_LISTENER)));
     }
 
+    @Test( expected = PathNotFoundException.class )
+    public void shouldFailToGetChildrenFromAWrongRequestedPath() {
+        List<Location> l = graph.getChildren().of(pathFactory.create("wrongRequestedPath"));
+    }
+
     @Test
-    public void shouldGetUuidPropertyNameFromSouceAndShouldNotChangeDuringLifetimeOfConnection() {
-        Name name = connection.getUuidPropertyName(context);
-        assertThat(name.getLocalName(), is("uuid"));
-        assertThat(name.getNamespaceUri(), is(DnaLexicon.Namespace.URI));
-        for (int i = 0; i != 10; ++i) {
-            Name name2 = connection.getUuidPropertyName(context);
-            assertThat(name2, is(sameInstance(name)));
-        }
+    public void shouldReturnTheContentNodePathOfTheFile() {
+        List<Location> locations00 = graph.getChildren().of(pathFactory.create("/trunk/extensions/dna-connector-svn/src/test/resources/nodeA/itemA1.txt"));
+        assertThat(locations00.isEmpty(), is(false));
+        assertThat(containsPaths(locations00).contains("/trunk/extensions/dna-connector-svn/src/test/resources/nodeA/itemA1.txt/jcr:content"),
+                   is(true));
+
     }
 
     @Test
-    public void shouldGenerateUuid() {
-        for (int i = 0; i != 100; ++i) {
-            assertThat(connection.generateUuid(), is(notNullValue()));
+    public void shouldListLocationForChildrenOfAParentPath() {
+
+        // read children from the root node.
+        List<Location> l = graph.getChildren().of(pathFactory.create("/"));
+        assertThat(containsPaths(l).contains("/trunk"), is(true));
+        assertThat(containsPaths(l).contains("/branches"), is(true));
+        assertThat(containsPaths(l).contains("/tags"), is(true));
+
+        List<Location> locations02 = graph.getChildren().of(pathFactory.create("/trunk/extensions/dna-connector-svn/src/test/resources/nodeA"));
+        assertThat(locations02.size() > 0, is(true));
+        assertThat(containsPaths(locations02).contains("/trunk/extensions/dna-connector-svn/src/test/resources/nodeA/itemA1.txt/jcr:content"),
+                   is(true));
+        assertThat(containsPaths(locations02).contains("/trunk/extensions/dna-connector-svn/src/test/resources/nodeA/itemA2.txt/jcr:content"),
+                   is(true));
+
+        List<Location> locations03 = graph.getChildren().of(pathFactory.create("/trunk/extensions/dna-connector-svn/src/test/resources/nodeB"));
+        assertThat(locations03.size() > 0, is(true));
+        assertThat(containsPaths(locations03).contains("/trunk/extensions/dna-connector-svn/src/test/resources/nodeB/JBossORG-EULA.txt/jcr:content"),
+                   is(true));
+        assertThat(containsPaths(locations03).contains("/trunk/extensions/dna-connector-svn/src/test/resources/nodeB/nodeB1"),
+                   is(true));
+    }
+
+    protected Collection<String> containsPaths( Collection<Location> locations ) {
+        List<String> paths = new ArrayList<String>();
+        for (Location location : locations) {
+            paths.add(location.getPath().getString(context.getNamespaceRegistry(), new UrlEncoder()));
         }
+        return paths;
     }
-    
-
-    /**
-     * Create a Repository instance from the file-protocol.
-     * 
-     * @return {@link FSRepository} the repository
-     * @throws Exception - in case of a exceptional error during the access.
-     */
-    // @SuppressWarnings( "unused" )
-    // private FSRepository createFSRepositoryFromFileProtocol() throws Exception {
-    // //TODO to be changed
-    // // String url = "file:///Users/sp/SVNRepos/test";
-    // String url = "";
-    // // Set up the appropriate factory for a particular protocol
-    // FSRepositoryFactory.setup();
-    // // The factory knows how to create a DAVRepository
-    // FSRepository fsRepository = (FSRepository)FSRepositoryFactory.create(SVNURL.parseURIDecoded(url));
-    // return fsRepository;
-    // }
 }

Modified: trunk/extensions/dna-connector-svn/src/test/java/org/jboss/dna/connector/svn/SVNRepositorySourceTest.java
===================================================================
--- trunk/extensions/dna-connector-svn/src/test/java/org/jboss/dna/connector/svn/SVNRepositorySourceTest.java	2008-12-04 23:03:08 UTC (rev 657)
+++ trunk/extensions/dna-connector-svn/src/test/java/org/jboss/dna/connector/svn/SVNRepositorySourceTest.java	2008-12-05 15:26:03 UTC (rev 658)
@@ -203,8 +203,6 @@
         source.setSVNUsername(username);
         source.setSVNPassword(password);
         source.setDefaultCachePolicy(cachePolicy);
-        source.setRootNodeUuid(rootNodeUuid != null ? rootNodeUuid.toString() : null);
-        source.setUuidPropertyName(uuidPropertyName);
 
         Reference ref = source.getReference();
 
@@ -219,8 +217,6 @@
         }
 
         assertThat((String)refAttributes.remove(SVNRepositorySource.SOURCE_NAME), is(source.getName()));
-        assertThat((String)refAttributes.remove(SVNRepositorySource.ROOT_NODE_UUID), is(source.getRootNodeUuid()));
-        assertThat((String)refAttributes.remove(SVNRepositorySource.UUID_PROPERTY_NAME), is(source.getUuidPropertyName()));
         assertThat((String)refAttributes.remove(SVNRepositorySource.SVN_URL), is(source.getSVNURL()));
         assertThat((String)refAttributes.remove(SVNRepositorySource.SVN_USERNAME), is(source.getSVNUsername()));
         assertThat((String)refAttributes.remove(SVNRepositorySource.SVN_PASSWORD), is(source.getSVNPassword()));
@@ -237,8 +233,6 @@
         assertThat(recoveredSource, is(notNullValue()));
 
         assertThat(recoveredSource.getName(), is(source.getName()));
-        assertThat(recoveredSource.getRootNodeUuid(), is(source.getRootNodeUuid()));
-        assertThat(recoveredSource.getUuidPropertyName(), is(source.getUuidPropertyName()));
         assertThat(recoveredSource.getSVNURL(), is(source.getSVNURL()));
         assertThat(recoveredSource.getSVNUsername(), is(source.getSVNUsername()));
         assertThat(recoveredSource.getSVNPassword(), is(source.getSVNPassword()));




More information about the dna-commits mailing list