[dna-commits] DNA SVN: r1022 - trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer.
dna-commits at lists.jboss.org
dna-commits at lists.jboss.org
Tue Jun 9 18:51:55 EDT 2009
Author: bcarothers
Date: 2009-06-09 18:51:55 -0400 (Tue, 09 Jun 2009)
New Revision: 1022
Modified:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapter.java
Log:
DNA-443 Java sequencer is not saving content correctly
Well, the initial guess was in the ballpark but not correct.
Part of the StreamSequencerAdapter code (the buildPathTo part) was operating directly against the graph for reads and writes. The other part (saveOutput) was operating against a destination that happened to be a batch. The batch doesn't save until all of the processing for the output of a particular sequencer is complete, leading to some race conditions between the two parts of the code. The batch is there to support a all-or-nothing save semantics for the output of a particular sequencer.
The most correct solution is to switch all of the code to use a batch, but this creates some challenges. For one thing, the batch doesn't support the concept of createIfMissing semantics or reads of any sort. I think that we would have to keep some sort of internal graph of nodes added to the batch while processing the sequencer output and check against that as well as the nodes in the graph.
My workaround for now is to make all of the operations in StreamSequencerAdapter work directly against the graph. We can always revisit this in 0.6.
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapter.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapter.java 2009-06-09 21:08:19 UTC (rev 1021)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapter.java 2009-06-09 22:51:55 UTC (rev 1022)
@@ -32,11 +32,14 @@
import java.util.List;
import java.util.Set;
import org.jboss.dna.common.collection.Problems;
+import org.jboss.dna.graph.JcrLexicon;
+import org.jboss.dna.graph.JcrNtLexicon;
import org.jboss.dna.graph.Node;
import org.jboss.dna.graph.observe.NetChangeObserver.NetChange;
import org.jboss.dna.graph.property.Binary;
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.property.Property;
import org.jboss.dna.graph.property.PropertyFactory;
import org.jboss.dna.graph.property.ValueFactories;
@@ -177,19 +180,26 @@
private void buildPathTo( Path targetPath,
SequencerContext context ) {
PathFactory pathFactory = context.getExecutionContext().getValueFactories().getPathFactory();
+ PropertyFactory propFactory = context.getExecutionContext().getPropertyFactory();
if (targetPath.isRoot()) return;
Path workingPath = pathFactory.createRootPath();
Path.Segment[] segments = targetPath.getSegmentsArray();
int i = 0;
if (segments.length > 1) {
+ Property primaryType = propFactory.create(JcrLexicon.PRIMARY_TYPE, JcrNtLexicon.UNSTRUCTURED);
for (int max = segments.length - 1; i < max; i++) {
workingPath = pathFactory.create(workingPath, segments[i]);
- context.graph().createIfMissing(workingPath);
+
+ try {
+ context.graph().getNodeAt(workingPath);
+ }
+ catch (PathNotFoundException pnfe) {
+ context.graph().create(workingPath, primaryType);
+ }
}
}
- workingPath = pathFactory.create(workingPath, segments[i]);
- context.graph().create(workingPath);
+ context.graph().create(targetPath);
}
/**
@@ -228,7 +238,7 @@
if (absolutePath.getParent() != null) {
buildPathTo(absolutePath.getParent(), context);
}
- context.getDestination().create(absolutePath, properties);
+ context.graph().create(absolutePath, properties);
}
}
More information about the dna-commits
mailing list