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 properties; + private final List childSegments; + private Set uniqueChildNames; + + public DefaultPathNode( Path path, + Map properties, + List childSegments ) { + super(); + this.path = path; + this.properties = properties; + this.childSegments = childSegments; + } + + @Override + public List getChildSegments() { + return this.childSegments; + } + + @Override + public Path getPath() { + return this.path; + } + + @Override + public Map getProperties() { + return Collections.unmodifiableMap(this.properties); + } + + @Override + public Property getProperty( ExecutionContext context, + String name ) { + NameFactory nameFactory = context.getValueFactories().getNameFactory(); + + return getProperty(nameFactory.create(name)); + } + + @Override + public Property getProperty( Name name ) { + return properties.get(name); + } + + @Override + public Set getUniqueChildNames() { + if (this.uniqueChildNames == null) { + Set childNames = new HashSet(childSegments.size()); + + for (Segment childSegment : childSegments) { + childNames.add(childSegment.getName()); + } + + this.uniqueChildNames = childNames; + } + + return null; + } + +} Property changes on: dna-graph\src\main\java\org\jboss\dna\graph\connector\path\DefaultPathNode.java ___________________________________________________________________ Added: svn:keywords + Id Revision Added: svn:eol-style + LF Index: dna-graph/src/main/java/org/jboss/dna/graph/connector/path/package-info.java =================================================================== --- dna-graph/src/main/java/org/jboss/dna/graph/connector/path/package-info.java (revision 0) +++ dna-graph/src/main/java/org/jboss/dna/graph/connector/path/package-info.java (revision 0) @@ -0,0 +1,57 @@ +/* + * JBoss DNA (http://www.jboss.org/dna) + * See the COPYRIGHT.txt file distributed with this work for information + * regarding copyright ownership. Some portions may be licensed + * to Red Hat, Inc. under one or more contributor license agreements. + * See the AUTHORS.txt file in the distribution for a full listing of + * individual contributors. + * + * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA + * is licensed to you 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. + * + * JBoss DNA 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. + */ +/** + * The {@link PathRepository} class and its supporting classes provide a default read-only implementation of the connector + * classes for connectors that only support path-based access to a {@link PathNode standard + * representation of a node}. Connectors to systems that provide a unique identifier for each node would generally be better implemented using the {@link MapRepository map repository implementation instead}. + * To implement a connector based on this framework, one must create an implementation of {@link PathRepositorySource the repository source}, + * an implementation of {@link PathRepository the repository itself}, and an implementation of {@link PathWorkspace the workspace}. + *

+ * 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 getUniqueChildNames(); + + /** + * @return children + */ + public List getChildSegments(); + + /** + * Returns the named property + * + * @param context the current execution context, used to get a {@link NameFactory name factory} + * @param name the name of the property to return + * @return the property for the given name + */ + public Property getProperty( ExecutionContext context, + String name ); + + /** + * Returns the named property + * + * @param name the name of the property to return + * @return the property for the given name + */ + public Property getProperty( Name name ); + + /** + * Returns a map of property names to the property for the given name + * + * @return a map of property names to the property for the given name + */ + public Map getProperties(); + +} Property changes on: dna-graph\src\main\java\org\jboss\dna\graph\connector\path\PathNode.java ___________________________________________________________________ Added: svn:keywords + Id Revision Added: svn:eol-style + LF Index: dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRepository.java =================================================================== --- dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRepository.java (revision 0) +++ dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRepository.java (revision 0) @@ -0,0 +1,106 @@ +package org.jboss.dna.graph.connector.path; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import org.jboss.dna.common.util.CheckArg; + +public abstract class PathRepository { + + protected final UUID rootNodeUuid; + private final String sourceName; + private final String defaultWorkspaceName; + protected final Map workspaces = new HashMap(); + + /** + * Creates a {@code PathRepository} with the given repository source name, root node UUID, and a default workspace named + * {@code ""} (the empty string). + * + * @param sourceName the name of the repository source for use in error and informational messages; may not be null or empty + * @param rootNodeUuid the UUID that will be used as the root node UUID for each workspace in the repository; may not be null + * or empty + */ + protected PathRepository( String sourceName, + UUID rootNodeUuid ) { + this(sourceName, rootNodeUuid, null); + } + + /** + * Creates a {@code PathRepository} with the given repository source name, root node UUID, and a default workspace with the + * given name. + * + * @param sourceName the name of the repository source for use in error and informational messages; may not be null or empty + * @param rootNodeUuid the UUID that will be used as the root node UUID for each workspace in the repository; may not be null + * or empty + * @param defaultWorkspaceName the name of the default, auto-created workspace + */ + protected PathRepository( String sourceName, + UUID rootNodeUuid, + String defaultWorkspaceName ) { + CheckArg.isNotEmpty(sourceName, "sourceName"); + CheckArg.isNotNull(rootNodeUuid, "rootNodeUUID"); + this.rootNodeUuid = rootNodeUuid; + this.sourceName = sourceName; + this.defaultWorkspaceName = defaultWorkspaceName != null ? defaultWorkspaceName : ""; + } + + /** + * Returns the UUID used by the root nodes in each workspace. + *

+ * 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 getWorkspaceNames() { + return workspaces.keySet(); + } + + /** + * Returns the workspace with the given name + * + * @param name the name of the workspace to return + * @return the workspace with the given name; may be null if no workspace with the given name exists + */ + public PathWorkspace getWorkspace( String name ) { + if (name == null) name = defaultWorkspaceName; + return workspaces.get(name); + } + + /** + * Initializes the repository by creating the default workspace. + *

+ * 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 names = repository.getWorkspaceNames(); + request.setAvailableWorkspaceNames(new HashSet(names)); + setCacheableInfo(request); + } + + @Override + public void process( CreateWorkspaceRequest request ) { + updatesNotSupported(request); + } + + @Override + public void process( CloneBranchRequest request ) { + updatesNotSupported(request); + } + + @Override + public void process( CloneWorkspaceRequest request ) { + updatesNotSupported(request); + } + + @Override + public void process( DestroyWorkspaceRequest request ) { + updatesNotSupported(request); + } + + @Override + public void process( CopyBranchRequest request ) { + updatesNotSupported(request); + } + + @Override + public void process( CreateNodeRequest request ) { + updatesNotSupported(request); + } + + @Override + public void process( DeleteBranchRequest request ) { + updatesNotSupported(request); + } + + @Override + public void process( MoveBranchRequest request ) { + updatesNotSupported(request); + } + + @Override + public void process( ReadNodeRequest request ) { + PathWorkspace workspace = getWorkspace(request, request.inWorkspace()); + PathNode node = getTargetNode(workspace, request, request.at()); + if (node == null) return; + + // Get the names of the children ... + for (Path.Segment childSegment : node.getChildSegments()) { + request.addChild(Location.create(pathFactory.create(node.getPath(), childSegment))); + } + + // Get the properties of the node ... + request.addProperties(node.getProperties().values()); + + request.setActualLocationOfNode(Location.create(node.getPath())); + setCacheableInfo(request); + } + + @Override + public void process( ReadAllChildrenRequest request ) { + PathWorkspace workspace = getWorkspace(request, request.inWorkspace()); + PathNode node = getTargetNode(workspace, request, request.of()); + if (node == null) return; + + List childSegments = node.getChildSegments(); + for (Path.Segment childSegment : childSegments) { + request.addChild(Location.create(pathFactory.create(node.getPath(), childSegment))); + } + request.setActualLocationOfNode(Location.create(node.getPath())); + setCacheableInfo(request); + } + + @Override + public void process( ReadAllPropertiesRequest request ) { + PathWorkspace workspace = getWorkspace(request, request.inWorkspace()); + PathNode node = getTargetNode(workspace, request, request.at()); + if (node == null) return; + + // Get the properties of the node ... + request.addProperties(node.getProperties().values()); + request.setActualLocationOfNode(Location.create(node.getPath())); + setCacheableInfo(request); + } + + @Override + public void process( UpdatePropertiesRequest request ) { + updatesNotSupported(request); + } + + protected PathWorkspace getWorkspace( Request request, + String workspaceName ) { + // Get the workspace for this request ... + PathWorkspace workspace = repository.getWorkspace(workspaceName); + if (workspace == null) { + String msg = GraphI18n.workspaceDoesNotExistInRepository.text(workspaceName, repository.getSourceName()); + request.setError(new InvalidWorkspaceException(msg)); + } + return workspace; + } + + protected PathNode getTargetNode( PathWorkspace workspace, + Request request, + Location location ) { + if (workspace == null) return null; + PathNode node = null; + + if (!location.hasPath()) { + I18n msg = GraphI18n.pathConnectorRequestsMustHavePath; + request.setError(new IllegalArgumentException(msg.text())); + return null; + } + + // Look up the node with the supplied path ... + Path path = location.getPath(); + if (path != null) { + node = workspace.getNode(path); + } + + if (node == null && request != null) { + if (path == null) { + // Missing path, and could not find by UUID ... + request.setError(new PathNotFoundException(location, pathFactory.createRootPath(), + 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.nodeDoesNotExist.text(path))); + } + return node; + } + +} Property changes on: dna-graph\src\main\java\org\jboss\dna\graph\connector\path\PathRequestProcessor.java ___________________________________________________________________ Added: svn:keywords + Id Revision Added: svn:eol-style + LF Index: dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathWorkspace.java =================================================================== --- dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathWorkspace.java (revision 0) +++ dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathWorkspace.java (revision 0) @@ -0,0 +1,85 @@ +package org.jboss.dna.graph.connector.path; + +import org.jboss.dna.graph.ExecutionContext; +import org.jboss.dna.graph.connector.LockFailedException; +import org.jboss.dna.graph.property.Path; +import org.jboss.dna.graph.query.QueryResults; +import org.jboss.dna.graph.request.AccessQueryRequest; +import org.jboss.dna.graph.request.LockBranchRequest.LockScope; + +public interface PathWorkspace { + /** + * Returns the name of the workspace. There can only be one workspace with a given name per repository. + * + * @return the name of the workspace + */ + String getName(); + + /** + * Returns the root node in the workspace. This returns a {@link PathNode map node} where {@code node.getParent() == null} and + * {@code node.getPath().isRoot() == true}. + * + * @return the root node in the workspace + */ + PathNode getRoot(); + + /** + * Returns the node at the given path, if one exists of {@code null} if no {@PathNode node} exists at the given + * path. + * + * @param path the path of the node to retrieve; may not be null + * @return the node at the given path, if one exists of {@code null} if no {@PathNode node} exists at the given + * path. + */ + PathNode getNode( Path path ); + + /** + * Attempts to lock the given node with the given timeout. If the lock attempt fails, a {@link LockFailedException} will be + * thrown. + * + * @param node the node to be locked; may not be null + * @param lockScope the scope of the lock (i.e., whether descendants of {@code node} should be included in the lock + * @param lockTimeoutInMillis the maximum lifetime of the lock in milliseconds; zero (0) indicates that the connector default + * should be used + * @throws LockFailedException if the implementing connector supports locking but the lock could not be acquired. + */ + void lockNode( PathNode node, + LockScope lockScope, + long lockTimeoutInMillis ) throws LockFailedException; + + /** + * Attempts to unlock the given node. + * + * @param node the node to be unlocked; may not be null + */ + void unlockNode( PathNode node ); + + /** + * Find the lowest existing node along the path. + * + * @param path the path to the node; may not be null + * @return the lowest existing node along the path, or the root node if no node exists on the path + */ + Path getLowestExistingPath( Path path ); + + /** + * Perform a query of this workspace. + * + * @param context the context in which the query is to be executed; may not be null + * @param accessQuery the access query; may not be null + * @return the query results, or null if the query is not supported + */ + QueryResults query( ExecutionContext context, + AccessQueryRequest accessQuery ); + + /** + * Perform a full-text search of this workspace. + * + * @param context the context in which the query is to be executed; may not be null + * @param fullTextSearchExpression the full-text search expression; may not be null + * @return the query results, or null if the query is not supported + */ + QueryResults search( ExecutionContext context, + String fullTextSearchExpression ); + +} Property changes on: dna-graph\src\main\java\org\jboss\dna\graph\connector\path\PathWorkspace.java ___________________________________________________________________ Added: svn:keywords + Id Revision Added: svn:eol-style + LF Index: dna-graph/src/main/java/org/jboss/dna/graph/GraphI18n.java =================================================================== --- dna-graph/src/main/java/org/jboss/dna/graph/GraphI18n.java (revision 1450) +++ dna-graph/src/main/java/org/jboss/dna/graph/GraphI18n.java (working copy) @@ -94,9 +94,10 @@ public static I18n couldNotAcquireLock; /* In-Memory Connector */ - public static I18n inMemoryNodeDoesNotExist; + public static I18n nodeDoesNotExist; public static I18n errorSerializingInMemoryCachePolicyInSource; public static I18n inMemoryConnectorRequestsMustHavePathOrUuid; + public static I18n pathConnectorRequestsMustHavePath; public static I18n workspaceDoesNotExistInRepository; public static I18n workspaceAlreadyExistsInRepository; Index: dna-graph/src/main/resources/org/jboss/dna/graph/GraphI18n.properties =================================================================== --- dna-graph/src/main/resources/org/jboss/dna/graph/GraphI18n.properties (revision 1450) +++ dna-graph/src/main/resources/org/jboss/dna/graph/GraphI18n.properties (working copy) @@ -82,9 +82,10 @@ couldNotAcquireLock = Could not acquire lock on the node at "{0}" in workspace "{1}" # In-memory connector -inMemoryNodeDoesNotExist = Could not find an existing node at {0} +nodeDoesNotExist = Could not find an existing node at {0} errorSerializingInMemoryCachePolicyInSource = Error serializing a {0} instance owned by the {1} in-memory repository inMemoryConnectorRequestsMustHavePathOrUuid = In-Memory connector can only process requests with a path and/or UUID +pathConnectorRequestsMustHavePath = Path connectors can only process requests with a path workspaceDoesNotExistInRepository = The workspace "{0}" does not exist in the "{1}" in-memory repository workspaceAlreadyExistsInRepository = The workspace "{0}" already exists in the "{1}" in-memory repository