Author: jverhaeg(a)redhat.com
Date: 2008-08-20 11:44:54 -0400 (Wed, 20 Aug 2008)
New Revision: 454
Modified:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/xml/XmlSequencer.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/Path.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/PathNotFoundException.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicPath.java
trunk/dna-spi/src/test/java/org/jboss/dna/spi/connector/SimpleRepository.java
trunk/dna-spi/src/test/java/org/jboss/dna/spi/connector/SimpleRepositorySource.java
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicPathTest.java
trunk/extensions/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/FederatingCommandExecutor.java
trunk/extensions/dna-connector-inmemory/src/main/java/org/jboss/dna/connector/inmemory/InMemoryRepository.java
trunk/extensions/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheConnection.java
Log:
DNA-208: Renamed Path.getAncestor() to getParent() and updated all referencing classes.
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java 2008-08-20 15:34:04 UTC
(rev 453)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java 2008-08-20 15:44:54 UTC
(rev 454)
@@ -206,7 +206,7 @@
return getRootNode();
}
// Since we don't know whether path refers to a node or property, get the
parent contents, which must refer to a node
- Path parentPath = path.getAncestor();
+ Path parentPath = path.getParent();
BasicGetNodeCommand getNodeCommand = new BasicGetNodeCommand(parentPath);
execute(getNodeCommand);
// First search for a child with the last name in the path
Modified:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/xml/XmlSequencer.java
===================================================================
---
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/xml/XmlSequencer.java 2008-08-20
15:34:04 UTC (rev 453)
+++
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/xml/XmlSequencer.java 2008-08-20
15:44:54 UTC (rev 454)
@@ -313,7 +313,7 @@
private void endElement() {
// Recover parent's path, namespace, and indexedName map, clearing the
ended element's map to free memory
- path = path.getAncestor();
+ path = path.getParent();
nameToIndexedNamesMap.clear();
nameToIndexedNamesMap = nameToIndexedNamesMapStack.removeFirst();
nsStack.removeFirst();
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/Path.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/Path.java 2008-08-20 15:34:04 UTC
(rev 453)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/Path.java 2008-08-20 15:44:54 UTC
(rev 454)
@@ -63,7 +63,7 @@
* This class simplifies working with paths and using a <code>Path</code> is
often more efficient that processing and
* manipulating the equivalent <code>String</code>. This class can easily
{@link #iterator() iterate} over the segments, return
* the {@link #size() number of segments}, {@link #compareTo(Path) compare} with other
paths, {@link #resolve(Path) resolve}
- * relative paths, return the {@link #getAncestor() ancestor (or parent)}, determine
whether one path is an
+ * relative paths, return the {@link #getParent() ancestor (or parent)}, determine
whether one path is an
* {@link #isAncestorOf(Path) ancestor} or {@link #isDecendantOf(Path) decendent} of
another path, and
* {@link #getCommonAncestor(Path) finding a common ancestor}.
* </p>
@@ -389,7 +389,7 @@
*
* @return the parent path, or this path if it is already the root
*/
- public Path getAncestor();
+ public Path getParent();
/**
* Return the path to the ancestor of the supplied degree. An ancestor of degree
<code>x</code> is the path that is <code>x
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/PathNotFoundException.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/PathNotFoundException.java 2008-08-20
15:34:04 UTC (rev 453)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/PathNotFoundException.java 2008-08-20
15:44:54 UTC (rev 454)
@@ -98,7 +98,7 @@
}
/**
- * Get the lowest (closest) existing {@link Path#getAncestor() ancestor} of the
{@link #getPath() non-existant path}.
+ * Get the lowest (closest) existing {@link Path#getParent() ancestor} of the {@link
#getPath() non-existant path}.
* @return the lowest ancestor that does exist
*/
public Path getLowestAncestorThatDoesExist() {
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicPath.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicPath.java 2008-08-20
15:34:04 UTC (rev 453)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicPath.java 2008-08-20
15:44:54 UTC (rev 454)
@@ -82,7 +82,7 @@
/**
* {@inheritDoc}
*/
- public Path getAncestor() {
+ public Path getParent() {
if (this.isRoot()) return null;
if (this.segments.size() == 1) return ROOT;
return subpath(0, this.segments.size() - 1);
@@ -435,7 +435,7 @@
if (relativePath.size() == 1) {
Segment onlySegment = relativePath.getSegment(0);
if (onlySegment.isSelfReference()) return this;
- if (onlySegment.isParentReference()) return this.getAncestor();
+ if (onlySegment.isParentReference()) return this.getParent();
}
List<Segment> segments = new ArrayList<Segment>(this.size() +
relativePath.size());
segments.addAll(this.segments);
Modified: trunk/dna-spi/src/test/java/org/jboss/dna/spi/connector/SimpleRepository.java
===================================================================
---
trunk/dna-spi/src/test/java/org/jboss/dna/spi/connector/SimpleRepository.java 2008-08-20
15:34:04 UTC (rev 453)
+++
trunk/dna-spi/src/test/java/org/jboss/dna/spi/connector/SimpleRepository.java 2008-08-20
15:44:54 UTC (rev 454)
@@ -133,7 +133,7 @@
PropertyFactory propertyFactory = context.getPropertyFactory();
Path pathObj = pathFactory.create(path);
if (!pathObj.isRoot()) {
- create(context,
pathObj.getAncestor().getString(context.getNamespaceRegistry()));
+ create(context,
pathObj.getParent().getString(context.getNamespaceRegistry()));
}
Property property = propertyFactory.create(nameFactory.create(propertyName),
values);
Map<Name, Property> properties = new HashMap<Name, Property>();
@@ -157,7 +157,7 @@
Path ancestorPath = pathObj;
while (!ancestorPath.isRoot()) {
data.putIfAbsent(ancestorPath, new HashMap<Name, Property>());
- ancestorPath = ancestorPath.getAncestor();
+ ancestorPath = ancestorPath.getParent();
}
Name uuidName =
context.getValueFactories().getNameFactory().create(this.getUuidPropertyName());
UUID uuid = context.getValueFactories().getUuidFactory().create();
Modified:
trunk/dna-spi/src/test/java/org/jboss/dna/spi/connector/SimpleRepositorySource.java
===================================================================
---
trunk/dna-spi/src/test/java/org/jboss/dna/spi/connector/SimpleRepositorySource.java 2008-08-20
15:34:04 UTC (rev 453)
+++
trunk/dna-spi/src/test/java/org/jboss/dna/spi/connector/SimpleRepositorySource.java 2008-08-20
15:44:54 UTC (rev 454)
@@ -323,7 +323,7 @@
// Iterate through all of the properties, looking for any paths that are
children of the path ...
List<Path.Segment> childSegments = new
LinkedList<Path.Segment>();
for (Path path : data.keySet()) {
- if (!path.isRoot() && path.getAncestor().equals(targetPath)) {
+ if (!path.isRoot() && path.getParent().equals(targetPath)) {
childSegments.add(path.getLastSegment());
}
}
Modified: trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicPathTest.java
===================================================================
--- trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicPathTest.java 2008-08-20
15:34:04 UTC (rev 453)
+++ trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicPathTest.java 2008-08-20
15:44:54 UTC (rev 454)
@@ -225,14 +225,14 @@
@Test
public void shouldReturnNoAncestorForRoot() {
- assertThat(BasicPath.ROOT.getAncestor(), nullValue());
+ assertThat(BasicPath.ROOT.getParent(), nullValue());
}
@Test
public void shouldReturnAncestorForNodeOtherThanRoot() {
- assertThat(path.getAncestor(),
is(pathFactory.create("/dna:a/dna:b")));
- assertThat(path.getAncestor().getAncestor(),
is(pathFactory.create("/dna:a")));
- assertThat(path.getAncestor().getAncestor().getAncestor(), is(ROOT));
+ assertThat(path.getParent(), is(pathFactory.create("/dna:a/dna:b")));
+ assertThat(path.getParent().getParent(),
is(pathFactory.create("/dna:a")));
+ assertThat(path.getParent().getParent().getParent(), is(ROOT));
}
@Test
@@ -306,7 +306,7 @@
assertThat(common.isAncestorOf(path2), is(true));
assertThat(common.isAncestorOf(path3), is(false));
- assertThat(path1.getAncestor().isAncestorOf(path1), is(true));
+ assertThat(path1.getParent().isAncestorOf(path1), is(true));
for (int i = 1; i < path1.size(); ++i) {
assertThat(path1.getAncestor(i).isAncestorOf(path1), is(true));
}
@@ -332,7 +332,7 @@
assertThat(path2.isDecendantOf(common), is(true));
assertThat(path3.isDecendantOf(common), is(false));
- assertThat(path1.getAncestor().isAncestorOf(path1), is(true));
+ assertThat(path1.getParent().isAncestorOf(path1), is(true));
for (int i = 1; i < path1.size(); ++i) {
assertThat(path1.isDecendantOf(path1.getAncestor(i)), is(true));
}
@@ -844,7 +844,7 @@
@Test
public void shouldResolveRelativePathToParent() {
path = pathFactory.create("/a/b/c/d/e/f");
- assertThat(path.resolve(pathFactory.create("..")),
is(path.getAncestor()));
+ assertThat(path.resolve(pathFactory.create("..")),
is(path.getParent()));
assertThat(path.resolve(pathFactory.create("..")),
hasSegments(pathFactory, "a", "b", "c", "d",
"e"));
}
@@ -852,9 +852,9 @@
public void shouldResolveRelativePaths() {
path = pathFactory.create("/a/b/c/d/e/f");
assertThat(path.resolve(pathFactory.create("../../../../../..")),
is(sameInstance(ROOT)));
- assertThat(path.resolve(pathFactory.create("../..")),
is(path.getAncestor().getAncestor()));
+ assertThat(path.resolve(pathFactory.create("../..")),
is(path.getParent().getParent()));
assertThat(path.resolve(pathFactory.create("../..")),
hasSegments(pathFactory, "a", "b", "c", "d"));
- assertThat(path.resolve(pathFactory.create("../x/../y/../z/..")),
is(path.getAncestor()));
+ assertThat(path.resolve(pathFactory.create("../x/../y/../z/..")),
is(path.getParent()));
assertThat(path.resolve(pathFactory.create("../x/../y/../z/..")),
hasSegments(pathFactory, "a", "b", "c", "d",
"e"));
assertThat(path.resolve(pathFactory.create("../x")),
hasSegments(pathFactory, "a", "b", "c", "d",
"e", "x"));
}
Modified:
trunk/extensions/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/FederatingCommandExecutor.java
===================================================================
---
trunk/extensions/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/FederatingCommandExecutor.java 2008-08-20
15:34:04 UTC (rev 453)
+++
trunk/extensions/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/FederatingCommandExecutor.java 2008-08-20
15:44:54 UTC (rev 454)
@@ -310,11 +310,11 @@
// that already exists in the cache.
PathNotFoundException notFound =
(PathNotFoundException)fromCache.getError();
Path lowestExistingAncestor = notFound.getLowestAncestorThatDoesExist();
- Path ancestor = path.getAncestor();
+ Path ancestor = path.getParent();
if (!ancestor.equals(lowestExistingAncestor)) {
// Load the nodes along the path below the existing ancestor, down to
(but excluding) the desired path
- Path pathToLoad = path.getAncestor();
+ Path pathToLoad = path.getParent();
while (!pathToLoad.equals(lowestExistingAncestor)) {
loadContributionsFromSources(pathToLoad, null, contributions); //
sourceNames may be null or empty
FederatedNode mergedNode = createFederatedNode(pathToLoad,
contributions, true);
@@ -326,7 +326,7 @@
}
contributions.clear();
// Move to the next child along the path ...
- pathToLoad = pathToLoad.getAncestor();
+ pathToLoad = pathToLoad.getParent();
}
}
// At this point, all ancestors exist ...
@@ -366,7 +366,7 @@
FederatedNode mergedNode = createFederatedNode(path, contributions, true);
if (mergedNode == null) {
// No source had a contribution ...
- Path ancestor = path.getAncestor();
+ Path ancestor = path.getParent();
I18n msg = FederationI18n.nodeDoesNotExistAtPath;
fromCache.setError(new PathNotFoundException(path, ancestor, msg.text(path,
ancestor)));
return fromCache;
Modified:
trunk/extensions/dna-connector-inmemory/src/main/java/org/jboss/dna/connector/inmemory/InMemoryRepository.java
===================================================================
---
trunk/extensions/dna-connector-inmemory/src/main/java/org/jboss/dna/connector/inmemory/InMemoryRepository.java 2008-08-20
15:34:04 UTC (rev 453)
+++
trunk/extensions/dna-connector-inmemory/src/main/java/org/jboss/dna/connector/inmemory/InMemoryRepository.java 2008-08-20
15:44:54 UTC (rev 454)
@@ -203,7 +203,7 @@
assert pathToNewNode != null;
Path path = context.getValueFactories().getPathFactory().create(pathToNewNode);
if (path.isRoot()) return getRoot();
- Path parentPath = path.getAncestor();
+ Path parentPath = path.getParent();
Node parentNode = getNode(parentPath);
Name name = path.getLastSegment().getName();
return createNode(context, parentNode, name, null);
@@ -344,7 +344,7 @@
@Override
public void execute( CreateNodeCommand command ) {
Path path = command.getPath();
- Path parent = path.getAncestor();
+ Path parent = path.getParent();
// Look up the parent node, which must exist ...
Node parentNode = getNode(parent);
if (parentNode == null) {
@@ -420,7 +420,7 @@
Node node = getTargetNode(command);
// Look up the new parent, which must exist ...
Path newPath = command.getNewPath();
- Node newParent = getNode(newPath.getAncestor());
+ Node newParent = getNode(newPath.getParent());
copyNode(getExecutionContext(), node, newParent, false);
}
@@ -429,7 +429,7 @@
Node node = getTargetNode(command);
// Look up the new parent, which must exist ...
Path newPath = command.getNewPath();
- Node newParent = getNode(newPath.getAncestor());
+ Node newParent = getNode(newPath.getParent());
copyNode(getExecutionContext(), node, newParent, true);
}
@@ -438,7 +438,7 @@
Node node = getTargetNode(command);
// Look up the new parent, which must exist ...
Path newPath = command.getNewPath();
- Node newParent = getNode(newPath.getAncestor());
+ Node newParent = getNode(newPath.getParent());
node.setParent(newParent);
}
Modified:
trunk/extensions/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheConnection.java
===================================================================
---
trunk/extensions/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheConnection.java 2008-08-20
15:34:04 UTC (rev 453)
+++
trunk/extensions/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheConnection.java 2008-08-20
15:44:54 UTC (rev 454)
@@ -461,7 +461,7 @@
@Override
public void execute( CreateNodeCommand command ) {
Path path = command.getPath();
- Path parent = path.getAncestor();
+ Path parent = path.getParent();
// Look up the parent node, which must exist ...
Node<Name, Object> parentNode = getNode(parent);
@@ -559,7 +559,7 @@
Node<Name, Object> node = getNode(command.getPath());
// Look up the new parent, which must exist ...
Path newPath = command.getNewPath();
- Node<Name, Object> newParent = getNode(newPath.getAncestor());
+ Node<Name, Object> newParent = getNode(newPath.getParent());
copyNode(node, newParent, false, null, getExecutionContext());
}
@@ -568,7 +568,7 @@
Node<Name, Object> node = getNode(command.getPath());
// Look up the new parent, which must exist ...
Path newPath = command.getNewPath();
- Node<Name, Object> newParent = getNode(newPath.getAncestor());
+ Node<Name, Object> newParent = getNode(newPath.getParent());
copyNode(node, newParent, true, null, getExecutionContext());
}
@@ -579,7 +579,7 @@
Name uuidProperty = getUuidPropertyName(getExecutionContext());
// Look up the new parent, which must exist ...
Path newPath = command.getNewPath();
- Node<Name, Object> newParent = getNode(newPath.getAncestor());
+ Node<Name, Object> newParent = getNode(newPath.getParent());
copyNode(node, newParent, recursive, uuidProperty, getExecutionContext());
// Now delete the old node ...