Author: rhauch
Date: 2009-06-17 13:19:39 -0400 (Wed, 17 Jun 2009)
New Revision: 1053
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/FederatedRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/JoinRequestProcessor.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/ProjectedNode.java
Log:
DNA-463 Federation connector incorrectly expects identification properties on all source
nodes
Corrected the for loop that is aggregating the identifier properties on source node
locations. If the location does not even have identifier properties, then this
aggregation process is not even performed.
Also added toString() implementations for ProjectedNode and FederatedRequest.
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/FederatedRequest.java
===================================================================
---
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/FederatedRequest.java 2009-06-17
17:19:33 UTC (rev 1052)
+++
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/FederatedRequest.java 2009-06-17
17:19:39 UTC (rev 1053)
@@ -93,6 +93,24 @@
if (forkLatch != null) forkLatch.await();
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("Federated request:
").append(original).append("\n");
+ sb.append(" projected to: ").append("\n");
+ ProjectedRequest projected = first;
+ while (projected != null) {
+ sb.append(" - ").append(projected).append("\n");
+ projected = projected.next();
+ }
+ return sb.toString();
+ }
+
class ProjectedRequest {
private final Projection projection;
private final Projection projection2;
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/JoinRequestProcessor.java
===================================================================
---
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/JoinRequestProcessor.java 2009-06-17
17:19:33 UTC (rev 1052)
+++
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/JoinRequestProcessor.java 2009-06-17
17:19:39 UTC (rev 1053)
@@ -203,19 +203,20 @@
}
// Make sure we have an actual location ...
- actualLocation = determineActualLocation(actualLocation,
-
readFromSource.getActualLocationOfNode(),
- projectedRequest.getProjection());
+ Location sourceLocation = readFromSource.getActualLocationOfNode();
+ actualLocation = determineActualLocation(actualLocation, sourceLocation,
projectedRequest.getProjection());
- // Accumulate the identification properties ...
- for (Property propertyInSource :
readFromSource.getActualLocationOfNode().getIdProperties()) {
- Name name = propertyInSource.getName();
- Property existing = actualLocation.getIdProperty(name);
- if (existing != null) {
- // Merge the property values ...
- propertyInSource = merge(existing, propertyInSource, propertyFactory,
true);
+ if (sourceLocation.hasIdProperties()) {
+ // Accumulate the identification properties ...
+ for (Property propertyInSource : sourceLocation.getIdProperties()) {
+ Name name = propertyInSource.getName();
+ Property existing = actualLocation.getIdProperty(name);
+ if (existing != null) {
+ // Merge the property values ...
+ propertyInSource = merge(existing, propertyInSource,
propertyFactory, true);
+ }
+ actualLocation = actualLocation.with(propertyInSource);
}
- actualLocation = actualLocation.with(propertyInSource);
}
setCacheableInfo(request, readFromSource.getCachePolicy());
projectedRequest = projectedRequest.next();
@@ -268,19 +269,22 @@
if (federatedPath == null) federatedPath =
childInRepos.getPath().getParent();
} else {
ReadNodeRequest readFromSource = (ReadNodeRequest)sourceRequest;
- // Accumulate the identification properties ...
- for (Property propertyInSource :
readFromSource.getActualLocationOfNode().getIdProperties()) {
- Name name = propertyInSource.getName();
- Property existing = actualLocation.getIdProperty(name);
- if (existing != null) {
- // Merge the property values ...
- propertyInSource = merge(existing, propertyInSource,
propertyFactory, true);
+ Location sourceLocation = readFromSource.getActualLocationOfNode();
+ if (sourceLocation.hasIdProperties()) {
+ // Accumulate the identification properties ...
+ for (Property propertyInSource : sourceLocation.getIdProperties()) {
+ Name name = propertyInSource.getName();
+ Property existing = actualLocation.getIdProperty(name);
+ if (existing != null) {
+ // Merge the property values ...
+ propertyInSource = merge(existing, propertyInSource,
propertyFactory, true);
+ }
+ actualLocation = actualLocation.with(propertyInSource);
}
- actualLocation = actualLocation.with(propertyInSource);
}
// Make sure we have an actual location ...
- actualLocation = determineActualLocation(actualLocation,
readFromSource.getActualLocationOfNode(), projection);
+ actualLocation = determineActualLocation(actualLocation, sourceLocation,
projection);
if (federatedPath == null) federatedPath = actualLocation.getPath();
// Add all the children from the source ...
@@ -416,15 +420,18 @@
if (federatedPath == null) federatedPath =
childInRepos.getPath().getParent();
} else {
ReadAllChildrenRequest readFromSource =
(ReadAllChildrenRequest)sourceRequest;
- // Accumulate the identification properties ...
- for (Property propertyInSource :
readFromSource.getActualLocationOfNode().getIdProperties()) {
- Name name = propertyInSource.getName();
- Property existing = actualLocation.getIdProperty(name);
- if (existing != null) {
- // Merge the property values ...
- propertyInSource = merge(existing, propertyInSource,
propertyFactory, true);
+ Location sourceLocation = readFromSource.getActualLocationOfNode();
+ if (sourceLocation.hasIdProperties()) {
+ // Accumulate the identification properties ...
+ for (Property propertyInSource : sourceLocation.getIdProperties()) {
+ Name name = propertyInSource.getName();
+ Property existing = actualLocation.getIdProperty(name);
+ if (existing != null) {
+ // Merge the property values ...
+ propertyInSource = merge(existing, propertyInSource,
propertyFactory, true);
+ }
+ actualLocation = actualLocation.with(propertyInSource);
}
- actualLocation = actualLocation.with(propertyInSource);
}
// Make sure we have an actual location ...
@@ -498,19 +505,20 @@
}
// Make sure we have an actual location ...
- actualLocation = determineActualLocation(actualLocation,
-
readFromSource.getActualLocationOfNode(),
- projectedRequest.getProjection());
+ Location sourceLocation = readFromSource.getActualLocationOfNode();
+ actualLocation = determineActualLocation(actualLocation, sourceLocation,
projectedRequest.getProjection());
- // Accumulate the identification properties ...
- for (Property propertyInSource :
readFromSource.getActualLocationOfNode().getIdProperties()) {
- Name name = propertyInSource.getName();
- Property existing = actualLocation.getIdProperty(name);
- if (existing != null) {
- // Merge the property values ...
- propertyInSource = merge(existing, propertyInSource, propertyFactory,
true);
+ if (sourceLocation.hasIdProperties()) {
+ // Accumulate the identification properties ...
+ for (Property propertyInSource : sourceLocation.getIdProperties()) {
+ Name name = propertyInSource.getName();
+ Property existing = actualLocation.getIdProperty(name);
+ if (existing != null) {
+ // Merge the property values ...
+ propertyInSource = merge(existing, propertyInSource,
propertyFactory, true);
+ }
+ actualLocation = actualLocation.with(propertyInSource);
}
- actualLocation = actualLocation.with(propertyInSource);
}
// Add all the properties ...
@@ -559,19 +567,20 @@
}
// Make sure we have an actual location ...
- actualLocation = determineActualLocation(actualLocation,
-
readFromSource.getActualLocationOfNode(),
- projectedRequest.getProjection());
+ Location sourceLocation = readFromSource.getActualLocationOfNode();
+ actualLocation = determineActualLocation(actualLocation, sourceLocation,
projectedRequest.getProjection());
- // Accumulate the identification properties ...
- for (Property propertyInSource :
readFromSource.getActualLocationOfNode().getIdProperties()) {
- Name name = propertyInSource.getName();
- Property existing = actualLocation.getIdProperty(name);
- if (existing != null) {
- // Merge the property values ...
- propertyInSource = merge(existing, propertyInSource, propertyFactory,
true);
+ if (sourceLocation.hasIdProperties()) {
+ // Accumulate the identification properties ...
+ for (Property propertyInSource : sourceLocation.getIdProperties()) {
+ Name name = propertyInSource.getName();
+ Property existing = actualLocation.getIdProperty(name);
+ if (existing != null) {
+ // Merge the property values ...
+ propertyInSource = merge(existing, propertyInSource,
propertyFactory, true);
+ }
+ actualLocation = actualLocation.with(propertyInSource);
}
- actualLocation = actualLocation.with(propertyInSource);
}
// Add all the properties ...
@@ -930,15 +939,18 @@
return;
}
- // Accumulate the identification properties ...
- for (Property propertyInSource :
readFromSource.getActualLocationOfNode().getIdProperties()) {
- Name name = propertyInSource.getName();
- Property existing = actualLocation.getIdProperty(name);
- if (existing != null) {
- // Merge the property values ...
- propertyInSource = merge(existing, propertyInSource, propertyFactory,
true);
+ Location sourceLocation = readFromSource.getActualLocationOfNode();
+ if (sourceLocation.hasIdProperties()) {
+ // Accumulate the identification properties ...
+ for (Property propertyInSource : sourceLocation.getIdProperties()) {
+ Name name = propertyInSource.getName();
+ Property existing = actualLocation.getIdProperty(name);
+ if (existing != null) {
+ // Merge the property values ...
+ propertyInSource = merge(existing, propertyInSource,
propertyFactory, true);
+ }
+ actualLocation = actualLocation.with(propertyInSource);
}
- actualLocation = actualLocation.with(propertyInSource);
}
projectedRequest = projectedRequest.next();
}
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/ProjectedNode.java
===================================================================
---
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/ProjectedNode.java 2009-06-17
17:19:33 UTC (rev 1052)
+++
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/ProjectedNode.java 2009-06-17
17:19:39 UTC (rev 1053)
@@ -121,6 +121,11 @@
public ProxyNode asProxy() {
return null;
}
+
+ @Override
+ public String toString() {
+ return "Placeholder " + location();
+ }
}
@NotThreadSafe
@@ -196,4 +201,10 @@
public boolean isSameLocationAsOriginal() {
return this.sameLocationAsOriginal;
}
+
+ @Override
+ public String toString() {
+ return "Proxy for " + federatedLocation() + " projected from
" + location() + " in workspace \"" + workspaceName()
+ + "\" in \"" + source() + "\"";
+ }
}