Index: dna-graph/src/main/java/org/jboss/dna/graph/connector/map/MapRequestProcessor.java
===================================================================
--- dna-graph/src/main/java/org/jboss/dna/graph/connector/map/MapRequestProcessor.java (revision 1450)
+++ dna-graph/src/main/java/org/jboss/dna/graph/connector/map/MapRequestProcessor.java (working copy)
@@ -225,7 +225,7 @@
if (parentNode == null) {
Path lowestExisting = workspace.getLowestExistingPath(parent);
request.setError(new PathNotFoundException(request.under(), lowestExisting,
- GraphI18n.inMemoryNodeDoesNotExist.text(parent)));
+ GraphI18n.nodeDoesNotExist.text(parent)));
return;
}
@@ -333,7 +333,7 @@
if (newParent == null) {
Path lowestExisting = workspace.getLowestExistingPath(newParentPath);
request.setError(new PathNotFoundException(request.into(), lowestExisting,
- GraphI18n.inMemoryNodeDoesNotExist.text(newParentPath)));
+ GraphI18n.nodeDoesNotExist.text(newParentPath)));
return;
}
workspace.moveNode(getExecutionContext(), node, request.desiredName(), workspace, newParent, beforeNode);
@@ -589,12 +589,12 @@
}
// Missing path, and could not find by UUID ...
request.setError(new PathNotFoundException(location, pathFactory.createRootPath(),
- GraphI18n.inMemoryNodeDoesNotExist.text(path)));
+ GraphI18n.nodeDoesNotExist.text(path)));
return null;
}
// Could not find the node given the supplied path, so find the lowest path that does exist ...
Path lowestExisting = workspace.getLowestExistingPath(path);
- request.setError(new PathNotFoundException(location, lowestExisting, GraphI18n.inMemoryNodeDoesNotExist.text(path)));
+ request.setError(new PathNotFoundException(location, lowestExisting, GraphI18n.nodeDoesNotExist.text(path)));
}
return node;
}
Index: dna-graph/src/main/java/org/jboss/dna/graph/connector/path/DefaultPathNode.java
===================================================================
--- dna-graph/src/main/java/org/jboss/dna/graph/connector/path/DefaultPathNode.java (revision 0)
+++ dna-graph/src/main/java/org/jboss/dna/graph/connector/path/DefaultPathNode.java (revision 0)
@@ -0,0 +1,79 @@
+package org.jboss.dna.graph.connector.path;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import net.jcip.annotations.Immutable;
+import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.property.Name;
+import org.jboss.dna.graph.property.NameFactory;
+import org.jboss.dna.graph.property.Path;
+import org.jboss.dna.graph.property.Property;
+import org.jboss.dna.graph.property.Path.Segment;
+
+/**
+ * Default immutable implementation of {@link PathNode}
+ */
+@Immutable
+public class DefaultPathNode implements PathNode {
+
+ private final Path path;
+ private final Map
+ * The {@link PathRepositorySource repository source implementation} contains properties for the repository configuration and caching policies. A key
+ * method in the {@code PathRepositorySource} implementation if the {@link org.jboss.dna.graph.connector.RepositorySource#getConnection()} method,
+ * which should generally be implemented using the {@link PathRepositoryConnection default connection implementation}.
+ *
+ * if (repository == null) {
+ * repository = new JdbcMetadataRepository(this);
+ * }
+ * return new MapRepositoryConnection(this, repository);
+ *
+ *
+ * The {@link PathRepository repository implementation} is only required to provide an implementation of the {@link PathRepository#intialize()} + * method to initialize the repository with a default {@link PathWorkspace workspace} implementation for the connector and an implementation of {@link PathWorkspace}. All constructors for the repository must + * call {@link PathRepository#initialize()} after the constructor has completed its initialization, as demonstrated below: + *
+ * public JdbcMetadataRepository( JdbcMetadataSource source ) { + * initialize(); + * } + *+ * + * + * @see JdbcMetadataRepository + * @see JdbcMetadataSource + */ + +package org.jboss.dna.graph.connector.path; + Property changes on: dna-graph\src\main\java\org\jboss\dna\graph\connector\path\package-info.java ___________________________________________________________________ Added: svn:keywords + Id Revision Added: svn:eol-style + LF Index: dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathNode.java =================================================================== --- dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathNode.java (revision 0) +++ dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathNode.java (revision 0) @@ -0,0 +1,61 @@ +package org.jboss.dna.graph.connector.path; + +import java.util.List; +import java.util.Map; +import java.util.Set; +import org.jboss.dna.graph.ExecutionContext; +import org.jboss.dna.graph.property.Name; +import org.jboss.dna.graph.property.NameFactory; +import org.jboss.dna.graph.property.Path; +import org.jboss.dna.graph.property.Property; + +/** + * Basic interface for a read-only node in a {@link PathRepository path repository}. + */ +public interface PathNode { + + /** + * Returns the full path to this node + * + * @return the full path to this node + */ + public Path getPath(); + + /** + * Returns the set of child names for this node + * + * @return the set of child names for this node + */ + public Set
+ * Note that the root nodes themselves are distinct objects in each workspace and a change to the root node of one workspace + * does not imply a change to the root nodes of any other workspaces. However, the JCR specification mandates that all + * referenceable root nodes in a repository use a common UUID (in support of node correspondence); therefore this must be + * supported by DNA. + *
+ * + * @return the root node UUID + */ + public final UUID getRootNodeUuid() { + return rootNodeUuid; + } + + /** + * Returns the logical name (as opposed to the class name) of the repository source that defined this instance of the + * repository for use in error, informational, and other contextual messages. + * + * @return sourceName the logical name for the repository source name + */ + public String getSourceName() { + return sourceName; + } + + protected String getDefaultWorkspaceName() { + return defaultWorkspaceName; + } + + /** + * Returns a list of the names of the currently created workspaces + * + * @return a list of the names of the currently created workspaces + */ + public Set
+ * Due to the ordering restrictions on constructor chaining, this method cannot be called until the repository is fully
+ * initialized. This method MUST be called at the end of the constructor by any class that implements {@code MapRepository}
+ * .
+ */
+ protected abstract void initialize();
+
+}
Property changes on: dna-graph\src\main\java\org\jboss\dna\graph\connector\path\PathRepository.java
___________________________________________________________________
Added: svn:keywords
+ Id Revision
Added: svn:eol-style
+ LF
Index: dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRepositoryConnection.java
===================================================================
--- dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRepositoryConnection.java (revision 0)
+++ dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRepositoryConnection.java (revision 0)
@@ -0,0 +1,110 @@
+package org.jboss.dna.graph.connector.path;
+
+import java.util.concurrent.TimeUnit;
+import javax.transaction.xa.XAResource;
+import org.jboss.dna.common.statistic.Stopwatch;
+import org.jboss.dna.common.util.Logger;
+import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.cache.CachePolicy;
+import org.jboss.dna.graph.connector.RepositoryConnection;
+import org.jboss.dna.graph.connector.RepositoryContext;
+import org.jboss.dna.graph.connector.RepositorySourceException;
+import org.jboss.dna.graph.observe.Observer;
+import org.jboss.dna.graph.request.Request;
+import org.jboss.dna.graph.request.processor.RequestProcessor;
+
+public class PathRepositoryConnection implements RepositoryConnection {
+
+ private final PathRepositorySource source;
+ private final PathRepository repository;
+
+ public PathRepositoryConnection( PathRepositorySource source,
+ PathRepository repository ) {
+ assert source != null;
+ assert repository != null;
+ this.source = source;
+ this.repository = repository;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getSourceName() {
+ return source.getName();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public CachePolicy getDefaultCachePolicy() {
+ return source.getDefaultCachePolicy();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public XAResource getXAResource() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean ping( long time,
+ TimeUnit unit ) {
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void close() {
+ // do nothing
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.connector.RepositoryConnection#execute(org.jboss.dna.graph.ExecutionContext,
+ * org.jboss.dna.graph.request.Request)
+ */
+ public void execute( ExecutionContext context,
+ Request request ) throws RepositorySourceException {
+ Logger logger = context.getLogger(getClass());
+ Stopwatch sw = null;
+ if (logger.isTraceEnabled()) {
+ sw = new Stopwatch();
+ sw.start();
+ }
+ // Do any commands update/write?
+ RepositoryContext repositoryContext = this.source.getRepositoryContext();
+ Observer observer = repositoryContext != null ? repositoryContext.getObserver() : null;
+ RequestProcessor processor = new PathRequestProcessor(context, this.repository, observer);
+
+ try {
+ // Obtain the lock and execute the commands ...
+ processor.process(request);
+ } finally {
+ try {
+ processor.close();
+ } finally {
+ processor.notifyObserverOfChanges();
+ }
+ }
+ if (logger.isTraceEnabled()) {
+ assert sw != null;
+ sw.stop();
+ logger.trace(getClass().getSimpleName() + ".execute(...) took " + sw.getTotalDuration());
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "Connection to the \"" + getSourceName() + "\" " + repository.getClass().getSimpleName();
+ }
+}
Property changes on: dna-graph\src\main\java\org\jboss\dna\graph\connector\path\PathRepositoryConnection.java
___________________________________________________________________
Added: svn:keywords
+ Id Revision
Added: svn:eol-style
+ LF
Index: dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRepositorySource.java
===================================================================
--- dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRepositorySource.java (revision 0)
+++ dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRepositorySource.java (revision 0)
@@ -0,0 +1,27 @@
+package org.jboss.dna.graph.connector.path;
+
+import org.jboss.dna.graph.cache.CachePolicy;
+import org.jboss.dna.graph.connector.RepositoryContext;
+import org.jboss.dna.graph.connector.RepositorySource;
+
+/**
+ * An extension of the {@link RepositorySource} class that provides a {@link CachePolicy cache policy} and a
+ * {@link RepositoryContext repository context}.
+ */
+public interface PathRepositorySource extends RepositorySource {
+
+ /**
+ * Returns the {@link CachePolicy cache policy} for the repository source
+ *
+ * @return the {@link CachePolicy cache policy} for the repository source
+ */
+ CachePolicy getDefaultCachePolicy();
+
+ /**
+ * Returns the {@link RepositoryContext repository context} for the repository source
+ *
+ * @return the {@link RepositoryContext repository context} for the repository source
+ */
+ RepositoryContext getRepositoryContext();
+
+}
Property changes on: dna-graph\src\main\java\org\jboss\dna\graph\connector\path\PathRepositorySource.java
___________________________________________________________________
Added: svn:keywords
+ Id Revision
Added: svn:eol-style
+ LF
Index: dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRequestProcessor.java
===================================================================
--- dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRequestProcessor.java (revision 0)
+++ dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRequestProcessor.java (revision 0)
@@ -0,0 +1,202 @@
+package org.jboss.dna.graph.connector.path;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.jboss.dna.common.i18n.I18n;
+import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.GraphI18n;
+import org.jboss.dna.graph.Location;
+import org.jboss.dna.graph.observe.Observer;
+import org.jboss.dna.graph.property.Path;
+import org.jboss.dna.graph.property.PathFactory;
+import org.jboss.dna.graph.property.PathNotFoundException;
+import org.jboss.dna.graph.request.CloneBranchRequest;
+import org.jboss.dna.graph.request.CloneWorkspaceRequest;
+import org.jboss.dna.graph.request.CopyBranchRequest;
+import org.jboss.dna.graph.request.CreateNodeRequest;
+import org.jboss.dna.graph.request.CreateWorkspaceRequest;
+import org.jboss.dna.graph.request.DeleteBranchRequest;
+import org.jboss.dna.graph.request.DestroyWorkspaceRequest;
+import org.jboss.dna.graph.request.GetWorkspacesRequest;
+import org.jboss.dna.graph.request.InvalidRequestException;
+import org.jboss.dna.graph.request.InvalidWorkspaceException;
+import org.jboss.dna.graph.request.MoveBranchRequest;
+import org.jboss.dna.graph.request.ReadAllChildrenRequest;
+import org.jboss.dna.graph.request.ReadAllPropertiesRequest;
+import org.jboss.dna.graph.request.ReadNodeRequest;
+import org.jboss.dna.graph.request.Request;
+import org.jboss.dna.graph.request.UpdatePropertiesRequest;
+import org.jboss.dna.graph.request.VerifyWorkspaceRequest;
+import org.jboss.dna.graph.request.processor.RequestProcessor;
+
+/**
+ * The default implementation of the {@link RequestProcessor} for path repositories.
+ */
+public class PathRequestProcessor extends RequestProcessor {
+
+ private final PathFactory pathFactory;
+ private final PathRepository repository;
+
+ public PathRequestProcessor( ExecutionContext context,
+ PathRepository repository,
+ Observer observer ) {
+ super(repository.getSourceName(), context, observer);
+ this.repository = repository;
+ pathFactory = context.getValueFactories().getPathFactory();
+ }
+
+ private void updatesNotSupported( Request request ) {
+ request.setError(new InvalidRequestException(GraphI18n.unsupportedRequestType.text(request.getClass().getName(), request)));
+ }
+
+ @Override
+ public void process( VerifyWorkspaceRequest request ) {
+ PathWorkspace original = getWorkspace(request, request.workspaceName());
+ if (original != null) {
+ Path path = getExecutionContext().getValueFactories().getPathFactory().createRootPath();
+ request.setActualRootLocation(Location.create(path, repository.getRootNodeUuid()));
+ request.setActualWorkspaceName(original.getName());
+ }
+ }
+
+ @Override
+ public void process( GetWorkspacesRequest request ) {
+ Set