DNA SVN: r721 - trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-01-29 11:58:14 -0500 (Thu, 29 Jan 2009)
New Revision: 721
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/BasicProperty.java
Log:
DNA-279 Various improvements to the Graph API
Corrected BasicProperty to have a proper "compareTo(Property)" method.
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/BasicProperty.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/BasicProperty.java 2009-01-29 02:33:07 UTC (rev 720)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/BasicProperty.java 2009-01-29 16:58:14 UTC (rev 721)
@@ -81,7 +81,20 @@
/**
* {@inheritDoc}
*/
- public int compareTo( Property o ) {
+ public int compareTo( Property that ) {
+ if (this == that) return 0;
+ int diff = this.getName().compareTo(that.getName());
+ if (diff != 0) return diff;
+ diff = this.size() - that.size();
+ if (diff != 0) return diff;
+ Iterator<?> thisIter = iterator();
+ Iterator<?> thatIter = that.iterator();
+ while (thisIter.hasNext()) { // && thatIter.hasNext()
+ Object thisValue = thisIter.next();
+ Object thatValue = thatIter.next();
+ diff = ValueComparators.OBJECT_COMPARATOR.compare(thisValue, thatValue);
+ if (diff != 0) return diff;
+ }
return 0;
}
15 years, 3 months
DNA SVN: r720 - in trunk: dna-graph/src/main/java/org/jboss/dna/graph/connector/inmemory and 15 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-01-28 21:33:07 -0500 (Wed, 28 Jan 2009)
New Revision: 720
Added:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/VerifyNodeExistsRequest.java
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/DnaLexicon.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/Graph.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/GraphI18n.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/inmemory/InMemoryRepository.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/NamespaceRegistry.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/AbstractPath.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/BasicNamespace.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/BasicNamespaceRegistry.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/BasicPath.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/BasicPathSegment.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/ChildPath.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/RootPath.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CopyBranchRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java
trunk/dna-graph/src/main/resources/org/jboss/dna/graph/GraphI18n.properties
trunk/dna-graph/src/test/java/org/jboss/dna/graph/GraphImporterTest.java
trunk/dna-graph/src/test/java/org/jboss/dna/graph/GraphTest.java
trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/inmemory/InMemoryRepositoryTest.java
trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/BasicNameTest.java
trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/BasicPathOldTest.java
trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/BasicPathTest.java
trunk/dna-graph/src/test/resources/repositoryImporterTestData1.xml
trunk/docs/examples/gettingstarted/repositories/src/main/resources/configRepository.xml
trunk/extensions/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/SingleProjectionCommandExecutor.java
trunk/extensions/dna-connector-filesystem/src/test/java/org/jboss/dna/connector/filesystem/FileSystemSourceTest.java
trunk/extensions/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheConnection.java
trunk/extensions/dna-connector-jbosscache/src/test/java/org/jboss/dna/connector/jbosscache/JBossCacheConnectionTest.java
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/basic/BasicRequestProcessor.java
Log:
DNA-279 Various improvements to the Graph API
Made the following improvements to the Graph API:
1) added a request to verify the existance of a node (basically, this checks for existence and fetches the actual location)
2) added a way to copy a node by specifying the path of the desired location (in addition to the current mechanism of specifying the parent and inferring the name of the new node from the original). This could be accomplished by adding the desired name to the CopyBranchRequest, and then updating all of the RequestProcessor implementations to use this optional information. This may affect a number of classes.
3) made NamespaceRegistry.Namespace extend Comparable<Namespace> so that namespaces can be sorted naturally
4) improved the efficiency of the AbstractPath.equals(...) implementation, which is not efficiently iterating up the Path.Segment instances.
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/DnaLexicon.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/DnaLexicon.java 2009-01-29 02:32:27 UTC (rev 719)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/DnaLexicon.java 2009-01-29 02:33:07 UTC (rev 720)
@@ -32,7 +32,7 @@
public class DnaLexicon {
public static class Namespace {
- public static final String URI = "http://www.jboss.org/dna";
+ public static final String URI = "http://www.jboss.org/dna/1.0";
public static final String PREFIX = "dna";
}
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/Graph.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/Graph.java 2009-01-29 02:32:27 UTC (rev 719)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/Graph.java 2009-01-29 02:33:07 UTC (rev 720)
@@ -158,12 +158,12 @@
this.sourceName = sourceName;
this.connectionFactory = connectionFactory;
this.context = context;
- this.requestQueue = new GraphRequestQueue();
this.nextGraph = new Conjunction<Graph>() {
public Graph and() {
return Graph.this;
}
};
+ this.requestQueue = new GraphRequestQueue();
}
/**
@@ -1527,11 +1527,11 @@
return importXmlFrom(file.toURI());
}
- /*package*/Path createPath( String path ) {
+ protected Path createPath( String path ) {
return getContext().getValueFactories().getPathFactory().create(path);
}
- /*package*/void execute( Request request ) {
+ protected void execute( Request request ) {
RepositoryConnection connection = Graph.this.getConnectionFactory().createConnection(getSourceName());
if (connection == null) {
throw new RepositorySourceException(GraphI18n.unableToFindRepositorySourceWithName.text(getSourceName()));
@@ -1548,7 +1548,7 @@
}
}
- /*package*/List<Segment> getSegments( List<Location> locations ) {
+ protected List<Segment> getSegments( List<Location> locations ) {
List<Segment> segments = new ArrayList<Segment>(locations.size());
for (Location location : locations) {
segments.add(location.getPath().getLastSegment());
@@ -2922,59 +2922,118 @@
*/
public interface Into<Next> {
/**
- * Finish the request by specifying the new location into which the node should be copied/moved.
+ * Finish the request by specifying the location of the parent into which the node should be copied/moved. This operation
+ * will result in the copied/moved node having the same name as the original (but with the appropriately-determined
+ * same-name-sibling index). If you want to control the name of the node for the newly copied/moved node, use
+ * {@link To#to(Location)} instead.
*
- * @param to the location of the new parent
+ * @param parentLocation the location of the new parent
* @return the interface for additional requests or actions
+ * @see To#to(Location)
*/
- Next into( Location to );
+ Next into( Location parentLocation );
/**
- * Finish the request by specifying the new location into which the node should be copied/moved.
+ * Finish the request by specifying the location of the parent into which the node should be copied/moved. This operation
+ * will result in the copied/moved node having the same name as the original (but with the appropriately-determined
+ * same-name-sibling index). If you want to control the name of the node for the newly copied/moved node, use
+ * {@link To#to(String)} instead.
*
- * @param toPath the path of the new parent
+ * @param parentPath the path of the new parent
* @return the interface for additional requests or actions
+ * @see To#to(String)
*/
- Next into( String toPath );
+ Next into( String parentPath );
/**
- * Finish the request by specifying the new location into which the node should be copied/moved.
+ * Finish the request by specifying the location of the parent into which the node should be copied/moved. This operation
+ * will result in the copied/moved node having the same name as the original (but with the appropriately-determined
+ * same-name-sibling index). If you want to control the name of the node for the newly copied/moved node, use
+ * {@link To#to(Path)} instead.
*
- * @param to the path of the new parent
+ * @param parentPath the path of the new parent
* @return the interface for additional requests or actions
+ * @see To#to(Path)
*/
- Next into( Path to );
+ Next into( Path parentPath );
/**
- * Finish the request by specifying the new location into which the node should be copied/moved.
+ * Finish the request by specifying the location of the parent into which the node should be copied/moved. This operation
+ * will result in the copied/moved node having the same name as the original (but with the appropriately-determined
+ * same-name-sibling index).
*
- * @param to the UUID of the new parent
+ * @param parentUuid the UUID of the new parent
* @return the interface for additional requests or actions
*/
- Next into( UUID to );
+ Next into( UUID parentUuid );
/**
- * Finish the request by specifying the new location into which the node should be copied/moved.
+ * Finish the request by specifying the location of the parent into which the node should be copied/moved. This operation
+ * will result in the copied/moved node having the same name as the original (but with the appropriately-determined
+ * same-name-sibling index).
*
- * @param idProperty the property that uniquely identifies the new parent
+ * @param parentIdProperty the property that uniquely identifies the new parent
* @return the interface for additional requests or actions
*/
- Next into( Property idProperty );
+ Next into( Property parentIdProperty );
/**
- * Finish the request by specifying the new location into which the node should be copied/moved.
+ * Finish the request by specifying the location of the parent into which the node should be copied/moved. This operation
+ * will result in the copied/moved node having the same name as the original (but with the appropriately-determined
+ * same-name-sibling index).
*
- * @param firstIdProperty the first property that, with the <code>additionalIdProperties</code>, uniquely identifies the
- * new parent
- * @param additionalIdProperties the additional properties that, with the <code>additionalIdProperties</code>, uniquely
- * identifies the new parent
+ * @param firstParentIdProperty the first property that, with the <code>additionalIdProperties</code>, uniquely identifies
+ * the new parent
+ * @param additionalParentIdProperties the additional properties that, with the <code>additionalIdProperties</code>,
+ * uniquely identifies the new parent
* @return the interface for additional requests or actions
*/
- Next into( Property firstIdProperty,
- Property... additionalIdProperties );
+ Next into( Property firstParentIdProperty,
+ Property... additionalParentIdProperties );
}
/**
+ * A component that defines the location to which a node should be copied or moved.
+ *
+ * @param <Next> The interface that is to be returned when this request is completed
+ * @author Randall Hauch
+ */
+ public interface To<Next> {
+ /**
+ * Finish the request by specifying the new location where the node should be copied/moved. Unlike
+ * {@link Into#into(Location)}, which specifies the location of the parent and which assumes the new node should have the
+ * same name as the original, this method allows the caller to specify a new name for the new node.
+ *
+ * @param desiredLocation the desired location for the new node, which must have a {@link Location#getPath() path}
+ * @return the interface for additional requests or actions
+ * @see Into#into(Location)
+ */
+ Next to( Location desiredLocation );
+
+ /**
+ * Finish the request by specifying the new location where the node should be copied/moved. Unlike
+ * {@link Into#into(String)}, which specifies the location of the parent and which assumes the new node should have the
+ * same name as the original, this method allows the caller to specify a new name for the new node.
+ *
+ * @param desiredPath the path for the new node
+ * @return the interface for additional requests or actions
+ * @see Into#into(String)
+ */
+ Next to( String desiredPath );
+
+ /**
+ * Finish the request by specifying the new location where the node should be copied/moved. Unlike {@link Into#into(Path)}
+ * , which specifies the location of the parent and which assumes the new node should have the same name as the original,
+ * this method allows the caller to specify a new name for the new node.
+ *
+ * @param desiredPath the path for the new node
+ * @return the interface for additional requests or actions
+ * @see Into#into(Path)
+ */
+ Next to( Path desiredPath );
+ }
+
+ /**
* A interface that is used to add more locations that are to be copied/moved.
*
* @param <Next> The interface that is to be returned when this request is completed
@@ -3044,13 +3103,15 @@
}
/**
- * The interface for defining additional nodes to be copied and the parent into which the node(s) are to be copied. where the
- * node(s) are to be moved.
+ * The interface for defining additional nodes to be copied and the locations where the copy is to be placed. The
+ * <code>to(...)</code> methods allow you to specify the location of the copy, including the name for the node that results
+ * from the copy. Alternatively, you can use the <code>into(...)</code> methods to specify the parent location where the copy
+ * is to be placed, which will assume the new copy will have the same name as the original.
*
* @param <Next> The interface that is to be returned when this request is completed
* @author Randall Hauch
*/
- public interface Copy<Next> extends Into<Next>, And<Copy<Next>> {
+ public interface Copy<Next> extends To<Next>, Into<Next>, And<Copy<Next>> {
}
/**
@@ -3885,7 +3946,7 @@
*
* @author Randall Hauch
*/
- /*package*/interface RequestQueue extends Executable {
+ protected interface RequestQueue extends Executable {
Graph getGraph();
void submit( Request request );
@@ -3899,7 +3960,7 @@
* @author Randall Hauch
*/
@NotThreadSafe
- /*package*/class GraphRequestQueue implements RequestQueue {
+ protected class GraphRequestQueue implements RequestQueue {
public Graph getGraph() {
return Graph.this;
}
@@ -4598,49 +4659,75 @@
* Submit any requests to move the targets into the supplied parent location
*
* @param into the parent location
+ * @param nameForCopy the name that should be used for the copy, or null if the name should be the same as the original
* @return this object, for method chaining
*/
- private T submit( Location into ) {
+ private T submit( Location into,
+ Name nameForCopy ) {
if (this.from.hasNext()) {
List<Request> requests = new LinkedList<Request>();
Locations locations = this.from;
while (locations.hasNext()) {
Location location = locations.getLocation();
- requests.add(new CopyBranchRequest(location, into));
+ requests.add(new CopyBranchRequest(location, into, nameForCopy));
locations = locations.next();
}
queue().submit(requests);
} else {
- queue().submit(new CopyBranchRequest(this.from.getLocation(), into));
+ queue().submit(new CopyBranchRequest(this.from.getLocation(), into, nameForCopy));
}
return and();
}
public T into( Location into ) {
- return submit(into);
+ return submit(into, null);
}
public T into( Path into ) {
- return submit(new Location(into));
+ return submit(new Location(into), null);
}
public T into( UUID into ) {
- return submit(new Location(into));
+ return submit(new Location(into), null);
}
public T into( Property firstIdProperty,
Property... additionalIdProperties ) {
- return submit(new Location(firstIdProperty, additionalIdProperties));
+ return submit(new Location(firstIdProperty, additionalIdProperties), null);
}
public T into( Property into ) {
- return submit(new Location(into));
+ return submit(new Location(into), null);
}
public T into( String into ) {
- return submit(new Location(createPath(into)));
+ return submit(new Location(createPath(into)), null);
}
+ public T to( Location desiredLocation ) {
+ if (!desiredLocation.hasPath()) {
+ throw new IllegalArgumentException(GraphI18n.unableToCopyToLocationWithoutAPath.text(this.from, desiredLocation));
+ }
+ Path desiredPath = desiredLocation.getPath();
+ if (desiredPath.isRoot()) {
+ throw new IllegalArgumentException(GraphI18n.unableToCopyToTheRoot.text(this.from, desiredLocation));
+ }
+ Path parent = desiredPath.getParent();
+ return submit(new Location(parent), desiredPath.getLastSegment().getName());
+ }
+
+ public T to( Path desiredPath ) {
+ if (desiredPath.isRoot()) {
+ throw new IllegalArgumentException(GraphI18n.unableToCopyToTheRoot.text(this.from, desiredPath));
+ }
+ Path parent = desiredPath.getParent();
+ return submit(new Location(parent), desiredPath.getLastSegment().getName());
+ }
+
+ public T to( String desiredPath ) {
+ return to(createPath(desiredPath));
+ }
+
@Override
public Results execute() {
return queue().execute();
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/GraphI18n.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/GraphI18n.java 2009-01-29 02:32:27 UTC (rev 719)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/GraphI18n.java 2009-01-29 02:33:07 UTC (rev 720)
@@ -68,8 +68,11 @@
public static I18n closingRequestProcessor;
public static I18n closedRequestProcessor;
public static I18n multipleErrorsWhileExecutingRequests;
+ public static I18n unknownTypeOfRequest;
public static I18n unableToAddMoreRequestsToAlreadyExecutedBatch;
public static I18n unableToCreateReferenceToNodeWithoutUuid;
+ public static I18n unableToCopyToLocationWithoutAPath;
+ public static I18n unableToCopyToTheRoot;
public static I18n actualLocationIsNotSameAsInputLocation;
public static I18n actualLocationIsNotChildOfInputLocation;
public static I18n actualLocationMustHavePath;
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/inmemory/InMemoryRepository.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/inmemory/InMemoryRepository.java 2009-01-29 02:32:27 UTC (rev 719)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/inmemory/InMemoryRepository.java 2009-01-29 02:33:07 UTC (rev 720)
@@ -309,6 +309,7 @@
* @param context
* @param original
* @param newParent
+ * @param desiredName
* @param recursive
* @param oldToNewUuids the map of UUIDs of nodes in the new subgraph keyed by the UUIDs of nodes in the original; may not be
* null
@@ -317,6 +318,7 @@
public InMemoryNode copyNode( ExecutionContext context,
InMemoryNode original,
InMemoryNode newParent,
+ Name desiredName,
boolean recursive,
Map<UUID, UUID> oldToNewUuids ) {
assert context != null;
@@ -325,7 +327,8 @@
assert oldToNewUuids != null;
// Get or create the new node ...
- InMemoryNode copy = createNode(context, newParent, original.getName().getName(), null);
+ Name childName = desiredName != null ? desiredName : original.getName().getName();
+ InMemoryNode copy = createNode(context, newParent, childName, null);
oldToNewUuids.put(original.getUuid(), copy.getUuid());
// Copy the properties ...
@@ -334,7 +337,7 @@
if (recursive) {
// Loop over each child and call this method ...
for (InMemoryNode child : original.getChildren()) {
- copyNode(context, child, copy, true, oldToNewUuids);
+ copyNode(context, child, copy, null, true, oldToNewUuids);
}
}
@@ -439,8 +442,9 @@
if (node == null) return;
// Look up the new parent, which must exist ...
Path newParentPath = request.into().getPath();
+ Name desiredName = request.desiredName();
InMemoryNode newParent = getNode(newParentPath);
- InMemoryNode newNode = copyNode(getExecutionContext(), node, newParent, true, new HashMap<UUID, UUID>());
+ InMemoryNode newNode = copyNode(getExecutionContext(), node, newParent, desiredName, true, new HashMap<UUID, UUID>());
Path newPath = getExecutionContext().getValueFactories().getPathFactory().create(newParentPath, newNode.getName());
Location oldLocation = getActualLocation(request.from().getPath(), node);
Location newLocation = new Location(newPath, newNode.getUuid());
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/NamespaceRegistry.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/NamespaceRegistry.java 2009-01-29 02:32:27 UTC (rev 719)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/NamespaceRegistry.java 2009-01-29 02:33:07 UTC (rev 720)
@@ -119,7 +119,7 @@
* @author Randall Hauch
*/
@Immutable
- interface Namespace {
+ interface Namespace extends Comparable<Namespace> {
/**
* Get the prefix for the namespace
*
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/AbstractPath.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/AbstractPath.java 2009-01-29 02:32:27 UTC (rev 719)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/AbstractPath.java 2009-01-29 02:33:07 UTC (rev 720)
@@ -28,6 +28,7 @@
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
+import java.util.NoSuchElementException;
import org.jboss.dna.common.CommonI18n;
import org.jboss.dna.common.text.TextEncoder;
import org.jboss.dna.common.util.CheckArg;
@@ -53,6 +54,35 @@
public static final Path SELF_PATH = new BasicPath(Collections.singletonList(Path.SELF_SEGMENT), false);
+ protected static Iterator<Path.Segment> EMPTY_PATH_ITERATOR = new Iterator<Segment>() {
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.util.Iterator#hasNext()
+ */
+ public boolean hasNext() {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.util.Iterator#next()
+ */
+ public Segment next() {
+ throw new NoSuchElementException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.util.Iterator#remove()
+ */
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ };
+
private transient int hc = 0;
protected boolean isNormalized( List<Segment> segments ) {
@@ -471,6 +501,14 @@
}
/**
+ * Method used by {@link AbstractPath#equals(Object)} implementation to quickly get an Iterator over the segments in the
+ * parent.
+ *
+ * @return the iterator over the segments; never null, but may not have any elements
+ */
+ protected abstract Iterator<Segment> getSegmentsOfParent();
+
+ /**
* {@inheritDoc}
*/
@Override
@@ -478,10 +516,18 @@
if (obj == this) return true;
if (obj instanceof Path) {
Path that = (Path)obj;
+ // First check whether the paths are roots ...
+ if (this.isRoot()) return that.isRoot();
+ else if (that.isRoot()) return false;
+ // Now check the hash code and size ...
+ if (this.hashCode() != that.hashCode()) return false;
if (this.size() != that.size()) return false;
- if (this.hashCode() != that.hashCode()) return false;
- Iterator<Segment> thisIter = this.iterator();
- Iterator<Segment> thatIter = that.iterator();
+ // Check the last segments, since these will often differ anyway ...
+ if (!this.getLastSegment().equals(that.getLastSegment())) return false;
+ if (this.size() == 1) return true;
+ // Check the rest of the names ...
+ Iterator<Segment> thisIter = that instanceof AbstractPath ? this.getSegmentsOfParent() : this.iterator();
+ Iterator<Segment> thatIter = that instanceof AbstractPath ? ((AbstractPath)that).getSegmentsOfParent() : that.iterator();
while (thisIter.hasNext()) {
Segment thisSegment = thisIter.next();
Segment thatSegment = thatIter.next();
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/BasicNamespace.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/BasicNamespace.java 2009-01-29 02:32:27 UTC (rev 719)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/BasicNamespace.java 2009-01-29 02:33:07 UTC (rev 720)
@@ -80,6 +80,17 @@
/**
* {@inheritDoc}
*
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo( Namespace that ) {
+ if (that == null) return 1;
+ if (this == that) return 0;
+ return this.getNamespaceUri().compareTo(that.getNamespaceUri());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
@@ -101,6 +112,6 @@
*/
@Override
public String toString() {
- return prefix + ":" + namespaceUri;
+ return prefix + "=" + namespaceUri;
}
}
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/BasicNamespaceRegistry.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/BasicNamespaceRegistry.java 2009-01-29 02:32:27 UTC (rev 719)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/BasicNamespaceRegistry.java 2009-01-29 02:33:07 UTC (rev 720)
@@ -24,9 +24,11 @@
package org.jboss.dna.graph.property.basic;
import java.text.DecimalFormat;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.locks.Lock;
@@ -252,6 +254,18 @@
return Collections.unmodifiableSet(result);
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ List<Namespace> namespaces = new ArrayList<Namespace>(getNamespaces());
+ Collections.sort(namespaces);
+ return namespaces.toString();
+ }
+
@GuardedBy( "registryLock" )
protected String generatePrefix() {
DecimalFormat formatter = new DecimalFormat(this.generatedPrefixTemplate);
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/BasicPath.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/BasicPath.java 2009-01-29 02:32:27 UTC (rev 719)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/BasicPath.java 2009-01-29 02:33:07 UTC (rev 720)
@@ -24,6 +24,7 @@
package org.jboss.dna.graph.property.basic;
import java.util.Collections;
+import java.util.Iterator;
import java.util.List;
import net.jcip.annotations.Immutable;
import org.jboss.dna.common.text.Inflector;
@@ -87,7 +88,19 @@
/**
* {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.property.basic.AbstractPath#getSegmentsOfParent()
*/
+ @Override
+ protected Iterator<Segment> getSegmentsOfParent() {
+ int size = this.segments.size();
+ if (size == 1) return EMPTY_PATH_ITERATOR;
+ return this.segments.subList(0, size - 1).iterator();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public List<Segment> getSegmentsList() {
return this.segments;
}
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/BasicPathSegment.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/BasicPathSegment.java 2009-01-29 02:32:27 UTC (rev 719)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/BasicPathSegment.java 2009-01-29 02:33:07 UTC (rev 720)
@@ -89,14 +89,14 @@
* {@inheritDoc}
*/
public boolean isParentReference() {
- return this.name.getNamespaceUri().length() == 0 && this.name.getLocalName().equals(Path.PARENT);
+ return this.name.getLocalName().equals(Path.PARENT) && this.name.getNamespaceUri().length() == 0;
}
/**
* {@inheritDoc}
*/
public boolean isSelfReference() {
- return this.name.getNamespaceUri().length() == 0 && this.name.getLocalName().equals(Path.SELF);
+ return this.name.getLocalName().equals(Path.SELF) && this.name.getNamespaceUri().length() == 0;
}
/**
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/ChildPath.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/ChildPath.java 2009-01-29 02:32:27 UTC (rev 719)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/ChildPath.java 2009-01-29 02:33:07 UTC (rev 720)
@@ -74,6 +74,16 @@
/**
* {@inheritDoc}
*
+ * @see org.jboss.dna.graph.property.basic.AbstractPath#getSegmentsOfParent()
+ */
+ @Override
+ protected Iterator<Segment> getSegmentsOfParent() {
+ return parent.iterator();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see org.jboss.dna.graph.property.Path#getLastSegment()
*/
@Override
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/RootPath.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/RootPath.java 2009-01-29 02:32:27 UTC (rev 719)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/RootPath.java 2009-01-29 02:33:07 UTC (rev 720)
@@ -73,6 +73,16 @@
/**
* {@inheritDoc}
*
+ * @see org.jboss.dna.graph.property.basic.AbstractPath#getSegmentsOfParent()
+ */
+ @Override
+ protected Iterator<Segment> getSegmentsOfParent() {
+ return EMPTY_PATH_ITERATOR;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see org.jboss.dna.graph.property.Path#getCanonicalPath()
*/
@Override
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CopyBranchRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CopyBranchRequest.java 2009-01-29 02:32:27 UTC (rev 719)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CopyBranchRequest.java 2009-01-29 02:33:07 UTC (rev 720)
@@ -27,6 +27,7 @@
import org.jboss.dna.graph.GraphI18n;
import org.jboss.dna.graph.Location;
import org.jboss.dna.graph.NodeConflictBehavior;
+import org.jboss.dna.graph.property.Name;
/**
* Instruction that a branch be copied from one location into another.
@@ -41,6 +42,7 @@
private final Location from;
private final Location into;
+ private final Name desiredNameForCopy;
private final NodeConflictBehavior conflictBehavior;
private Location actualOldLocation;
private Location actualNewLocation;
@@ -54,7 +56,7 @@
*/
public CopyBranchRequest( Location from,
Location into ) {
- this(from, into, DEFAULT_CONFLICT_BEHAVIOR);
+ this(from, into, null, DEFAULT_CONFLICT_BEHAVIOR);
}
/**
@@ -62,18 +64,37 @@
*
* @param from the location of the top node in the existing branch that is to be copied
* @param into the location of the existing node into which the copy should be placed
+ * @param nameForCopy the desired name for the node that results from the copy, or null if the name of the original should be
+ * used
+ * @throws IllegalArgumentException if <code>from</code> or <code>into</code> are null
+ */
+ public CopyBranchRequest( Location from,
+ Location into,
+ Name nameForCopy ) {
+ this(from, into, nameForCopy, DEFAULT_CONFLICT_BEHAVIOR);
+ }
+
+ /**
+ * Create a request to copy a branch to another.
+ *
+ * @param from the location of the top node in the existing branch that is to be copied
+ * @param into the location of the existing node into which the copy should be placed
+ * @param nameForCopy the desired name for the node that results from the copy, or null if the name of the original should be
+ * used
* @param conflictBehavior the expected behavior if an equivalently-named child already exists at the <code>into</code>
* location
* @throws IllegalArgumentException if any of the parameters are null
*/
public CopyBranchRequest( Location from,
Location into,
+ Name nameForCopy,
NodeConflictBehavior conflictBehavior ) {
CheckArg.isNotNull(from, "from");
CheckArg.isNotNull(into, "into");
CheckArg.isNotNull(conflictBehavior, "conflictBehavior");
this.from = from;
this.into = into;
+ this.desiredNameForCopy = nameForCopy;
this.conflictBehavior = conflictBehavior;
}
@@ -96,6 +117,15 @@
}
/**
+ * Get the name of the copy if it is to be different than that of the original.
+ *
+ * @return the desired name of the copy, or null if the name of the original is to be used
+ */
+ public Name desiredName() {
+ return desiredNameForCopy;
+ }
+
+ /**
* {@inheritDoc}
*
* @see org.jboss.dna.graph.request.Request#isReadOnly()
@@ -189,6 +219,9 @@
*/
@Override
public String toString() {
+ if (desiredNameForCopy != null) {
+ return "copy branch " + from() + " into " + into() + " with name " + desiredNameForCopy;
+ }
return "copy branch " + from() + " into " + into();
}
}
Added: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/VerifyNodeExistsRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/VerifyNodeExistsRequest.java (rev 0)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/VerifyNodeExistsRequest.java 2009-01-29 02:33:07 UTC (rev 720)
@@ -0,0 +1,137 @@
+/*
+ * 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.
+ */
+package org.jboss.dna.graph.request;
+
+import org.jboss.dna.common.util.CheckArg;
+import org.jboss.dna.graph.GraphI18n;
+import org.jboss.dna.graph.Location;
+
+/**
+ * Instruction to verify the existance of a node at the specified location. This request also returns the actual location.
+ *
+ * @author Randall Hauch
+ */
+public class VerifyNodeExistsRequest extends CacheableRequest {
+
+ private static final long serialVersionUID = 1L;
+
+ private final Location at;
+ private Location actualLocation;
+
+ /**
+ * Create a request to verify the existance and location of a node at the supplied location.
+ *
+ * @param at the location of the node to be verified
+ * @throws IllegalArgumentException if the location is null
+ */
+ public VerifyNodeExistsRequest( Location at ) {
+ CheckArg.isNotNull(at, "at");
+ this.at = at;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.request.Request#isReadOnly()
+ */
+ @Override
+ public boolean isReadOnly() {
+ return true;
+ }
+
+ /**
+ * Get the location defining the node that is to be read.
+ *
+ * @return the location of the node; never null
+ */
+ public Location at() {
+ return at;
+ }
+
+ /**
+ * Sets the actual and complete location of the node whose properties have been read. This method must be called when
+ * processing the request, and the actual location must have a {@link Location#getPath() path}.
+ *
+ * @param actual the actual location of the node being read, or null if the {@link #at() current location} should be used
+ * @throws IllegalArgumentException if the actual location does not represent the {@link Location#isSame(Location) same
+ * location} as the {@link #at() current location}, or if the actual location does not have a path.
+ */
+ public void setActualLocationOfNode( Location actual ) {
+ if (!at.isSame(actual)) { // not same if actual is null
+ throw new IllegalArgumentException(GraphI18n.actualLocationIsNotSameAsInputLocation.text(actual, at));
+ }
+ assert actual != null;
+ if (!actual.hasPath()) {
+ throw new IllegalArgumentException(GraphI18n.actualLocationMustHavePath.text(actual));
+ }
+ this.actualLocation = actual;
+ }
+
+ /**
+ * Get the actual location of the node whose properties were read.
+ *
+ * @return the actual location, or null if the actual location was not set
+ */
+ public Location getActualLocationOfNode() {
+ return actualLocation;
+ }
+
+ /**
+ * Return whether this node is known to exist. If the request has been processed, it will have an
+ * {@link #getActualLocationOfNode() actual location} or an {@link #getError() error}.
+ *
+ * @return true if this node is known to exist
+ * @see #getActualLocationOfNode()
+ * @see #getError()
+ */
+ public boolean exists() {
+ return actualLocation != null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals( Object obj ) {
+ if (this.getClass().isInstance(obj)) {
+ VerifyNodeExistsRequest that = (VerifyNodeExistsRequest)obj;
+ if (!this.at().equals(that.at())) return false;
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "verify node exists at " + at();
+ }
+
+}
Property changes on: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/VerifyNodeExistsRequest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java 2009-01-29 02:32:27 UTC (rev 719)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java 2009-01-29 02:33:07 UTC (rev 720)
@@ -46,6 +46,7 @@
import org.jboss.dna.graph.request.CopyBranchRequest;
import org.jboss.dna.graph.request.CreateNodeRequest;
import org.jboss.dna.graph.request.DeleteBranchRequest;
+import org.jboss.dna.graph.request.InvalidRequestException;
import org.jboss.dna.graph.request.MoveBranchRequest;
import org.jboss.dna.graph.request.ReadAllChildrenRequest;
import org.jboss.dna.graph.request.ReadAllPropertiesRequest;
@@ -58,6 +59,7 @@
import org.jboss.dna.graph.request.RenameNodeRequest;
import org.jboss.dna.graph.request.Request;
import org.jboss.dna.graph.request.UpdatePropertiesRequest;
+import org.jboss.dna.graph.request.VerifyNodeExistsRequest;
/**
* A component that is used to process and execute {@link Request}s. This class is intended to be subclassed and methods
@@ -188,6 +190,10 @@
process((RenameNodeRequest)request);
} else if (request instanceof UpdatePropertiesRequest) {
process((UpdatePropertiesRequest)request);
+ } else if (request instanceof VerifyNodeExistsRequest) {
+ process((VerifyNodeExistsRequest)request);
+ } else {
+ processUnknownRequest(request);
}
}
@@ -223,6 +229,16 @@
}
/**
+ * Method that is called by {@link #process(Request)} when the request was found to be of a request type that is not known by
+ * this processor. By default this method sets an {@link InvalidRequestException invalid request error} on the request.
+ *
+ * @param request the unknown request
+ */
+ protected void processUnknownRequest( Request request ) {
+ request.setError(new InvalidRequestException(GraphI18n.unknownTypeOfRequest.text(request.getClass().getName(), request)));
+ }
+
+ /**
* Process a request to copy a branch into another location.
* <p>
* This method does nothing if the request is null.
@@ -469,7 +485,7 @@
* Process a request to read a single property of a node at the supplied location.
* <p>
* This method does nothing if the request is null. Unless overridden, this method converts the request that
- * {@link ReadNodeRequest reads the node} and simply returns the one property.
+ * {@link ReadAllPropertiesRequest reads the node} and simply returns the one property.
* </p>
*
* @param request the read request
@@ -490,6 +506,28 @@
}
/**
+ * Process a request to verify that a node exists at the supplied location.
+ * <p>
+ * This method does nothing if the request is null. Unless overridden, this method converts the request that
+ * {@link ReadAllPropertiesRequest reads the node} and uses the result to determine if the node exists.
+ * </p>
+ *
+ * @param request the read request
+ */
+ public void process( VerifyNodeExistsRequest request ) {
+ if (request == null) return;
+ ReadAllPropertiesRequest readNode = new ReadAllPropertiesRequest(request.at());
+ process(readNode);
+ if (readNode.hasError()) {
+ request.setError(readNode.getError());
+ return;
+ }
+ // Set the actual location ...
+ request.setActualLocationOfNode(readNode.getActualLocationOfNode());
+ setCacheableInfo(request);
+ }
+
+ /**
* Process a request to remove the specified properties from a node.
* <p>
* This method does nothing if the request is null. Unless overridden, this method converts this request into a
Modified: trunk/dna-graph/src/main/resources/org/jboss/dna/graph/GraphI18n.properties
===================================================================
--- trunk/dna-graph/src/main/resources/org/jboss/dna/graph/GraphI18n.properties 2009-01-29 02:32:27 UTC (rev 719)
+++ trunk/dna-graph/src/main/resources/org/jboss/dna/graph/GraphI18n.properties 2009-01-29 02:33:07 UTC (rev 720)
@@ -55,8 +55,11 @@
closingRequestProcessor = Closing request processor
closedRequestProcessor = Closed request processor
multipleErrorsWhileExecutingRequests = {0} of the {1} requests resulted in errors
+unknownTypeOfRequest = Unable to process requests of type "{0}" ({1})
unableToAddMoreRequestsToAlreadyExecutedBatch = Unable to add more requests to a batch of graph requests that has already been executed
unableToCreateReferenceToNodeWithoutUuid = Unable to set a reference to node {0} since it has no UUID
+unableToCopyToLocationWithoutAPath = Unable to copy node "{0}" to "{1}" since the desired location has no path
+unableToCopyToTheRoot = Unable to copy node "{0}" to "{1}" since the desired location is the root node
actualLocationIsNotSameAsInputLocation = The actual location of {0} is not the same as the current location of {1}
actualLocationIsNotChildOfInputLocation = The actual location of {0} is not a child of the specified location {1}
actualLocationMustHavePath = The actual location of {0} must have a path
Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/GraphImporterTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/GraphImporterTest.java 2009-01-29 02:32:27 UTC (rev 719)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/GraphImporterTest.java 2009-01-29 02:33:07 UTC (rev 720)
@@ -99,7 +99,7 @@
"/a/b/dna:system[1]/dna:sources[1]/sourceA[1]",
"repositoryName=repositoryA",
"retryLimit=3",
- "jcr:primaryType={http://www.jboss.org/dna}xyz",
+ "jcr:primaryType={http://www.jboss.org/dna/1.0}xyz",
"dna:classname=org.jboss.dna.connector.inmemory.InMemoryRepositorySource");
assertCreateNode(iter,
"/a/b/dna:system[1]/dna:sources[1]/sourceB[1]",
Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/GraphTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/GraphTest.java 2009-01-29 02:32:27 UTC (rev 719)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/GraphTest.java 2009-01-29 02:33:07 UTC (rev 720)
@@ -845,7 +845,9 @@
public void process( CopyBranchRequest request ) {
// Create a child under the new parent ...
if (request.into().hasPath()) {
- Path childPath = context.getValueFactories().getPathFactory().create(request.into().getPath(), "child");
+ Name childName = request.desiredName();
+ if (childName == null) childName = createName("child");
+ Path childPath = context.getValueFactories().getPathFactory().create(request.into().getPath(), childName);
Location newChild = actualLocationOf(new Location(childPath));
// Just update the actual location
request.setActualLocations(actualLocationOf(request.from()), newChild);
Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/inmemory/InMemoryRepositoryTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/inmemory/InMemoryRepositoryTest.java 2009-01-29 02:32:27 UTC (rev 719)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/inmemory/InMemoryRepositoryTest.java 2009-01-29 02:33:07 UTC (rev 720)
@@ -329,7 +329,7 @@
assertThat(repository.getNode(pathFactory.create("/a/b")).getProperties().get(propertyName), is(property));
- repository.copyNode(context, node_b, node_d, true, new HashMap<UUID, UUID>());
+ repository.copyNode(context, node_b, node_d, null, true, new HashMap<UUID, UUID>());
assertThat(repository.getNodesByUuid().size(), is(9));
assertThat(repository.getNode(pathFactory.create("/")), is(sameInstance(repository.getRoot())));
@@ -347,6 +347,49 @@
}
@Test
+ public void shouldCopyNodesWhenDesiredNameIsSpecified() {
+ InMemoryNode root = repository.getRoot();
+ InMemoryNode node_a = repository.createNode(context, root, nameFactory.create("a"), null);
+ InMemoryNode node_b = repository.createNode(context, node_a, nameFactory.create("b"), null);
+ InMemoryNode node_c = repository.createNode(context, node_b, nameFactory.create("c"), null);
+ InMemoryNode node_d = repository.createNode(context, root, nameFactory.create("d"), null);
+ InMemoryNode node_e = repository.createNode(context, node_d, nameFactory.create("e"), null);
+ InMemoryNode node_b2 = repository.createNode(context, node_d, nameFactory.create("b"), null);
+
+ ValueFactory<String> stringFactory = valueFactories.getStringFactory();
+ Name propertyName = nameFactory.create("something");
+ Property property = propertyFactory.create(propertyName, stringFactory.create("Worth the wait"));
+ node_b.getProperties().put(propertyName, property);
+
+ assertThat(repository.getNodesByUuid().size(), is(7));
+ assertThat(repository.getNode(pathFactory.create("/")), is(sameInstance(repository.getRoot())));
+ assertThat(repository.getNode(pathFactory.create("/a")), is(sameInstance(node_a)));
+ assertThat(repository.getNode(pathFactory.create("/a/b")), is(sameInstance(node_b)));
+ assertThat(repository.getNode(pathFactory.create("/a/b/c")), is(sameInstance(node_c)));
+ assertThat(repository.getNode(pathFactory.create("/d")), is(sameInstance(node_d)));
+ assertThat(repository.getNode(pathFactory.create("/d/e")), is(sameInstance(node_e)));
+ assertThat(repository.getNode(pathFactory.create("/d/b")), is(sameInstance(node_b2)));
+
+ assertThat(repository.getNode(pathFactory.create("/a/b")).getProperties().get(propertyName), is(property));
+
+ repository.copyNode(context, node_b, node_d, nameFactory.create("x"), true, new HashMap<UUID, UUID>());
+
+ assertThat(repository.getNodesByUuid().size(), is(9));
+ assertThat(repository.getNode(pathFactory.create("/")), is(sameInstance(repository.getRoot())));
+ assertThat(repository.getNode(pathFactory.create("/a")), is(sameInstance(node_a)));
+ assertThat(repository.getNode(pathFactory.create("/a/b")), is(sameInstance(node_b)));
+ assertThat(repository.getNode(pathFactory.create("/a/b/c")), is(sameInstance(node_c)));
+ assertThat(repository.getNode(pathFactory.create("/d")), is(sameInstance(node_d)));
+ assertThat(repository.getNode(pathFactory.create("/d/e")), is(sameInstance(node_e)));
+ assertThat(repository.getNode(pathFactory.create("/d/b")), is(sameInstance(node_b2)));
+ assertThat(repository.getNode(pathFactory.create("/d/x")), is(notNullValue()));
+ assertThat(repository.getNode(pathFactory.create("/d/x/c")), is(notNullValue()));
+
+ assertThat(repository.getNode(pathFactory.create("/a/b")).getProperties().get(propertyName), is(property));
+ assertThat(repository.getNode(pathFactory.create("/d/x")).getProperties().get(propertyName), is(property));
+ }
+
+ @Test
public void shouldCreateRepositoryStructure() {
repository.createNode(context, "/a").setProperty(context, "name", "value").setProperty(context,
"desc",
Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/BasicNameTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/BasicNameTest.java 2009-01-29 02:32:27 UTC (rev 719)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/BasicNameTest.java 2009-01-29 02:33:07 UTC (rev 720)
@@ -31,8 +31,6 @@
import org.jboss.dna.graph.DnaLexicon;
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.property.Path;
-import org.jboss.dna.graph.property.basic.BasicName;
-import org.jboss.dna.graph.property.basic.BasicNamespaceRegistry;
import org.junit.Before;
import org.junit.Test;
@@ -154,7 +152,7 @@
String encodedLocalName = encoder.encode(validLocalName);
String result = name.getString(encoder);
assertThat(result, is("{" + encodedNamespaceUri + "}" + encodedLocalName));
- assertThat(encodedNamespaceUri, is("http%3a%2f%2fwww.jboss.org%2fdna"));
+ assertThat(encodedNamespaceUri, is("http%3a%2f%2fwww.jboss.org%2fdna%2f1.0"));
assertThat(encodedLocalName, is("some%3aname%3awith%3acolons"));
}
Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/BasicPathOldTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/BasicPathOldTest.java 2009-01-29 02:32:27 UTC (rev 719)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/BasicPathOldTest.java 2009-01-29 02:33:07 UTC (rev 720)
@@ -23,11 +23,11 @@
*/
package org.jboss.dna.graph.property.basic;
-import static org.jboss.dna.graph.property.basic.IsPathContaining.hasSegments;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNot.not;
import static org.hamcrest.core.IsNull.nullValue;
import static org.hamcrest.core.IsSame.sameInstance;
+import static org.jboss.dna.graph.property.basic.IsPathContaining.hasSegments;
import static org.junit.Assert.assertThat;
import java.util.ArrayList;
import java.util.Collections;
@@ -40,14 +40,6 @@
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.property.Path;
import org.jboss.dna.graph.property.ValueFormatException;
-import org.jboss.dna.graph.property.basic.BasicName;
-import org.jboss.dna.graph.property.basic.BasicNamespaceRegistry;
-import org.jboss.dna.graph.property.basic.BasicPath;
-import org.jboss.dna.graph.property.basic.BasicPathSegment;
-import org.jboss.dna.graph.property.basic.NameValueFactory;
-import org.jboss.dna.graph.property.basic.PathValueFactory;
-import org.jboss.dna.graph.property.basic.RootPath;
-import org.jboss.dna.graph.property.basic.StringValueFactory;
import org.junit.Before;
import org.junit.Test;
@@ -708,7 +700,7 @@
public void shouldGetStringWithNamespaceUrisIfNoNamespaceRegistryIsProvided() {
path = pathFactory.create("/dna:a/b/dna:c/../d/./dna:e/../..");
assertThat(path.getString(NO_OP_ENCODER),
- is("/{http://www.jboss.org/dna}a/{}b/{http://www.jboss.org/dna}c/../{}d/./{http://www.jboss.org/dna}e/../.."));
+ is("/{http://www.jboss.org/dna/1.0}a/{}b/{http://www.jboss.org/dna/1.0}c/../{}d/./{http://www.jboss.org/dna/1.0}e/../.."));
}
@Test
Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/BasicPathTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/BasicPathTest.java 2009-01-29 02:32:27 UTC (rev 719)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/BasicPathTest.java 2009-01-29 02:33:07 UTC (rev 720)
@@ -23,10 +23,10 @@
*/
package org.jboss.dna.graph.property.basic;
-import static org.jboss.dna.graph.property.basic.IsPathContaining.hasSegments;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNot.not;
import static org.hamcrest.core.IsSame.sameInstance;
+import static org.jboss.dna.graph.property.basic.IsPathContaining.hasSegments;
import static org.junit.Assert.assertThat;
import java.util.ArrayList;
import java.util.Collections;
@@ -39,14 +39,6 @@
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.property.Path;
import org.jboss.dna.graph.property.ValueFormatException;
-import org.jboss.dna.graph.property.basic.BasicName;
-import org.jboss.dna.graph.property.basic.BasicNamespaceRegistry;
-import org.jboss.dna.graph.property.basic.BasicPath;
-import org.jboss.dna.graph.property.basic.BasicPathSegment;
-import org.jboss.dna.graph.property.basic.NameValueFactory;
-import org.jboss.dna.graph.property.basic.PathValueFactory;
-import org.jboss.dna.graph.property.basic.RootPath;
-import org.jboss.dna.graph.property.basic.StringValueFactory;
import org.junit.Before;
import org.junit.Test;
@@ -630,7 +622,7 @@
public void shouldGetStringWithNamespaceUrisIfNoNamespaceRegistryIsProvided() {
path = pathFactory.create("/dna:a/b/dna:c/../d/./dna:e/../..");
assertThat(path.getString(NO_OP_ENCODER),
- is("/{http://www.jboss.org/dna}a/{}b/{http://www.jboss.org/dna}c/../{}d/./{http://www.jboss.org/dna}e/../.."));
+ is("/{http://www.jboss.org/dna/1.0}a/{}b/{http://www.jboss.org/dna/1.0}c/../{}d/./{http://www.jboss.org/dna/1.0}e/../.."));
}
@Test
@@ -846,12 +838,36 @@
assertThat(path.resolve(pathFactory.create("../x")), hasSegments(pathFactory, "a", "b", "c", "d", "e", "x"));
}
+ @Test
public void shouldResolveNonAbsolutePaths() {
path = pathFactory.create("a/b/c");
assertThat(path, hasSegments(pathFactory, "a", "b", "c"));
}
@Test
+ public void shouldConsiderTwoEquivalentPathsEqual() {
+ Path path1 = pathFactory.create("/a/b/c");
+ Path path2 = pathFactory.create("/a/b/c");
+ assertThat(path1.equals(path2), is(true));
+ }
+
+ @Test
+ public void shouldConsiderTwoDifferentPathsNotEqual() {
+ Path path1 = pathFactory.create("/a/b/c");
+ Path path2 = pathFactory.create("/a/b/d");
+ assertThat(path1.equals(path2), is(false));
+
+ path2 = pathFactory.create("/a/b");
+ assertThat(path1.equals(path2), is(false));
+
+ path2 = pathFactory.create("/a/b/c[2]");
+ assertThat(path1.equals(path2), is(false));
+
+ path2 = pathFactory.create("/a/b/c/c");
+ assertThat(path1.equals(path2), is(false));
+ }
+
+ @Test
public void shouldConvertPathToString() {
TextEncoder encoder = new Jsr283Encoder();
TextEncoder delimEncoder = new TextEncoder() {
Modified: trunk/dna-graph/src/test/resources/repositoryImporterTestData1.xml
===================================================================
--- trunk/dna-graph/src/test/resources/repositoryImporterTestData1.xml 2009-01-29 02:32:27 UTC (rev 719)
+++ trunk/dna-graph/src/test/resources/repositoryImporterTestData1.xml 2009-01-29 02:33:07 UTC (rev 720)
@@ -24,7 +24,7 @@
~ 51 Franklin Street, Fifth Floor
~ Boston, MA 02110-1301 USA
-->
-<dna:system xmlns:dna="http://www.jboss.org/dna" xmlns:jcr="http://www.jcp.org/jcr/1.0">
+<dna:system xmlns:dna="http://www.jboss.org/dna/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0">
<!-- Define the RepositorySource instances that will be added if not already defined -->
<dna:sources>
<sourceA jcr:primaryType="dna:xyz" repositoryName="repositoryA" dna:classname="org.jboss.dna.connector.inmemory.InMemoryRepositorySource" retryLimit="3" />
Modified: trunk/docs/examples/gettingstarted/repositories/src/main/resources/configRepository.xml
===================================================================
--- trunk/docs/examples/gettingstarted/repositories/src/main/resources/configRepository.xml 2009-01-29 02:32:27 UTC (rev 719)
+++ trunk/docs/examples/gettingstarted/repositories/src/main/resources/configRepository.xml 2009-01-29 02:33:07 UTC (rev 720)
@@ -24,7 +24,7 @@
~ 51 Franklin Street, Fifth Floor
~ Boston, MA 02110-1301 USA
-->
-<dna:system xmlns:dna="http://www.jboss.org/dna" xmlns:jcr="http://www.jcp.org/jcr/1.0">
+<dna:system xmlns:dna="http://www.jboss.org/dna/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0">
<!-- Define the sources from which content is made available -->
<dna:sources>
<dna:source jcr:name="SourceA" dna:name="Cars" dna:classname="org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource" dna:retryLimit="3" />
Modified: trunk/extensions/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/SingleProjectionCommandExecutor.java
===================================================================
--- trunk/extensions/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/SingleProjectionCommandExecutor.java 2009-01-29 02:32:27 UTC (rev 719)
+++ trunk/extensions/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/SingleProjectionCommandExecutor.java 2009-01-29 02:33:07 UTC (rev 720)
@@ -257,7 +257,7 @@
public void process( CopyBranchRequest request ) {
Location fromLocationInSource = projectIntoSource(request.from());
Location intoLocationInSource = projectIntoSource(request.into());
- CopyBranchRequest projected = new CopyBranchRequest(fromLocationInSource, intoLocationInSource);
+ CopyBranchRequest projected = new CopyBranchRequest(fromLocationInSource, intoLocationInSource, request.desiredName());
getConnection().execute(this.getExecutionContext(), projected);
if (projected.hasError()) {
projectError(projected, null, request);
Modified: trunk/extensions/dna-connector-filesystem/src/test/java/org/jboss/dna/connector/filesystem/FileSystemSourceTest.java
===================================================================
--- trunk/extensions/dna-connector-filesystem/src/test/java/org/jboss/dna/connector/filesystem/FileSystemSourceTest.java 2009-01-29 02:32:27 UTC (rev 719)
+++ trunk/extensions/dna-connector-filesystem/src/test/java/org/jboss/dna/connector/filesystem/FileSystemSourceTest.java 2009-01-29 02:33:07 UTC (rev 720)
@@ -68,8 +68,8 @@
}
@Test
- public void shouldSupportUpdates() {
- assertThat(source.getCapabilities().supportsUpdates(), is(true));
+ public void shouldNotSupportUpdates() {
+ assertThat(source.getCapabilities().supportsUpdates(), is(false));
}
@Test
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 2009-01-29 02:32:27 UTC (rev 719)
+++ trunk/extensions/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheConnection.java 2009-01-29 02:33:07 UTC (rev 720)
@@ -51,7 +51,6 @@
import org.jboss.dna.graph.property.Property;
import org.jboss.dna.graph.property.PropertyFactory;
import org.jboss.dna.graph.property.ValueFactory;
-import org.jboss.dna.graph.property.Path.Segment;
import org.jboss.dna.graph.request.CopyBranchRequest;
import org.jboss.dna.graph.request.CreateNodeRequest;
import org.jboss.dna.graph.request.DeleteBranchRequest;
@@ -259,7 +258,8 @@
// Look up the new parent, which must exist ...
Path newParentPath = request.into().getPath();
Node<Name, Object> newParent = getNode(context, newParentPath);
- Path.Segment newSegment = copyNode(node, newParent, true, null, null, getExecutionContext());
+ Name desiredName = request.desiredName();
+ Path.Segment newSegment = copyNode(node, newParent, desiredName, true, null, null, getExecutionContext());
UUID uuid = uuidFactory.create(node.get(DnaLexicon.UUID));
Path newPath = pathFactory.create(newParentPath, newSegment);
@@ -283,7 +283,7 @@
// Look up the new parent, which must exist ...
Path newParentPath = request.into().getPath();
Node<Name, Object> newParent = getNode(context, newParentPath);
- Path.Segment newSegment = copyNode(node, newParent, recursive, DnaLexicon.UUID, null, getExecutionContext());
+ Path.Segment newSegment = copyNode(node, newParent, null, recursive, DnaLexicon.UUID, null, getExecutionContext());
// Now delete the old node ...
Node<Name, Object> oldParent = node.getParent();
@@ -357,6 +357,7 @@
protected Path.Segment copyNode( Node<Name, Object> original,
Node<Name, Object> newParent,
+ Name desiredName,
boolean recursive,
Name uuidProperty,
AtomicInteger count,
@@ -364,7 +365,7 @@
assert original != null;
assert newParent != null;
// Get or create the new node ...
- Segment name = (Segment)original.getFqn().getLastElement();
+ Path.Segment name = desiredName != null ? context.getValueFactories().getPathFactory().createSegment(desiredName) : (Path.Segment)original.getFqn().getLastElement();
// Update the children to account for same-name siblings.
// This not only updates the FQN of the child nodes, but it also sets the property that stores the
@@ -383,7 +384,7 @@
if (recursive) {
// Loop over each child and call this method ...
for (Node<Name, Object> child : original.getChildren()) {
- copyNode(child, copy, true, uuidProperty, count, context);
+ copyNode(child, copy, null, true, uuidProperty, count, context);
}
}
return newSegment;
Modified: trunk/extensions/dna-connector-jbosscache/src/test/java/org/jboss/dna/connector/jbosscache/JBossCacheConnectionTest.java
===================================================================
--- trunk/extensions/dna-connector-jbosscache/src/test/java/org/jboss/dna/connector/jbosscache/JBossCacheConnectionTest.java 2009-01-29 02:32:27 UTC (rev 719)
+++ trunk/extensions/dna-connector-jbosscache/src/test/java/org/jboss/dna/connector/jbosscache/JBossCacheConnectionTest.java 2009-01-29 02:33:07 UTC (rev 720)
@@ -299,7 +299,7 @@
assertThat(newNodeC, is(nullValue()));
// Copy node B and place under node D
AtomicInteger count = new AtomicInteger();
- connection.copyNode(nodeB, nodeD, true, uuidProperty, count, context);
+ connection.copyNode(nodeB, nodeD, null, true, uuidProperty, count, context);
assertThat(count.get(), is(2));
newNodeB = cache.getNode(Fqn.fromList(newPathB.getSegmentsList()));
newNodeC = cache.getNode(Fqn.fromList(newPathC.getSegmentsList()));
Modified: trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/basic/BasicRequestProcessor.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/basic/BasicRequestProcessor.java 2009-01-29 02:32:27 UTC (rev 719)
+++ trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/basic/BasicRequestProcessor.java 2009-01-29 02:33:07 UTC (rev 720)
@@ -956,7 +956,8 @@
originalToNewUuid.put(original.getId().getChildUuidString(), copyUuid);
// Now add the new copy of the original ...
- Name childName = fromPath.getLastSegment().getName();
+ Name childName = request.desiredName();
+ if (childName == null) childName = fromPath.getLastSegment().getName();
actualToLocation = addNewChild(actualNewParent, copyUuid, childName);
}
15 years, 3 months
DNA SVN: r719 - in trunk/dna-common/src: test/java/org/jboss/dna/common and 1 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-01-28 21:32:27 -0500 (Wed, 28 Jan 2009)
New Revision: 719
Added:
trunk/dna-common/src/main/java/org/jboss/dna/common/xml/XmlCharacters.java
trunk/dna-common/src/test/java/org/jboss/dna/common/xml/
trunk/dna-common/src/test/java/org/jboss/dna/common/xml/XmlCharactersTest.java
Log:
DNA-278 Create new utility class for determining validity of XML NCNames
Created the implementation class by using a single structure to hold for each character a bitmask that describes the set of classifications that character belongs to. For example, 'a' belongs to multiple character classes, so the bitmask ORs together the bitmask of each of those character classes. A simple array is used to store all the bitmasks, indexed by the integer value of the character. Then, each method (e.g., to check whether a character is a valid NCName starting character) simply has to look up the mask and perform a single bit operation. (Some methods also have some shortcuts, as several of the classes have a very large range of characters (at the upper end) that are or are not in the character class, and these can be checked by simply comparing the integer value of the character with the lower end of the range.)
Added: trunk/dna-common/src/main/java/org/jboss/dna/common/xml/XmlCharacters.java
===================================================================
--- trunk/dna-common/src/main/java/org/jboss/dna/common/xml/XmlCharacters.java (rev 0)
+++ trunk/dna-common/src/main/java/org/jboss/dna/common/xml/XmlCharacters.java 2009-01-29 02:32:27 UTC (rev 719)
@@ -0,0 +1,292 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+package org.jboss.dna.common.xml;
+
+import java.text.CharacterIterator;
+import java.text.StringCharacterIterator;
+
+/**
+ * A utility class for determining the validity of various XML names, per the
+ * <a href="http://www.w3.org/TR/REC-xml/">XML 1.0 Specification</a>.
+ */
+public class XmlCharacters {
+
+ private static final int NUMBER_OF_CHARACTERS = 1 << 16; // 65536 or 0x10000
+
+ /**
+ * This implementation uses an array that captures for each character the XML classifications.
+ * An array is used because it is a fast way of looking up each character.
+ */
+ private static final char[] MASKS = new char[NUMBER_OF_CHARACTERS];
+
+ private static final int VALID_CHARACTER = 1;
+ private static final int CONTENT_CHARACTER = 1 <<1;
+ private static final int SPACE_CHARACTER = 1 <<2;
+ private static final int NAME_START_CHARACTER = 1<<3;
+ private static final int NAME_CHARACTER = 1<<4;
+ private static final int NCNAME_START_CHARACTER = 1<<5;
+ private static final int NCNAME_CHARACTER = 1<<6;
+ private static final int PUBID_CHARACTER = 1<<7;
+
+ static {
+
+ // ----------------
+ // Valid Characters
+ // ----------------
+ // [2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
+ // See http://www.w3.org/TR/REC-xml/#charsets
+ MASKS[0x9] |= VALID_CHARACTER | CONTENT_CHARACTER;
+ MASKS[0xA] |= VALID_CHARACTER | CONTENT_CHARACTER;
+ MASKS[0xD] |= VALID_CHARACTER | CONTENT_CHARACTER;
+ for (int i = 0x20; i <= 0xD7FF; ++i) MASKS[i] |= VALID_CHARACTER | CONTENT_CHARACTER;
+ for (int i = 0xE000; i <= 0xFFFD; ++i) MASKS[i] |= VALID_CHARACTER | CONTENT_CHARACTER;
+ // Last range is bigger than our character array, so we'll handle in the 'isValid' method ...
+ // for ( int i=0x10000; i<=0x10FFFF; ++i ) MASKS[i] = VALID_CHARACTER_MASK | CONTENT_CHARACTER;
+
+ // Remove the other characters that are not allowed in XML content:
+ // '<', '&', '\n', '\r', ']'
+ MASKS['<'] &= ~(CONTENT_CHARACTER);
+ MASKS['&'] &= ~(CONTENT_CHARACTER);
+ MASKS['\n'] &= ~(CONTENT_CHARACTER);
+ MASKS['\r'] &= ~(CONTENT_CHARACTER);
+ MASKS[']'] &= ~(CONTENT_CHARACTER);
+
+ // ---------------------
+ // Whitespace Characters
+ // ---------------------
+ // [3] S ::= (#x20 | #x9 | #xD | #xA)+
+ // See http://www.w3.org/TR/REC-xml/#sec-common-syn
+ MASKS[0x20] |= SPACE_CHARACTER;
+ MASKS[0x9] |= SPACE_CHARACTER;
+ MASKS[0xA] |= SPACE_CHARACTER;
+ MASKS[0xD] |= SPACE_CHARACTER;
+
+ // ---------------------
+ // Name Start Characters
+ // ---------------------
+ // [4] NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] |
+ // [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] |
+ // [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] |
+ // [#x10000-#xEFFFF]
+ // See http://www.w3.org/TR/REC-xml/#sec-common-syn
+ //
+ // Note that all these start characters AND characters are valid for NAME and NCNAME
+ int nameStartMask = NAME_START_CHARACTER | NCNAME_START_CHARACTER | NAME_CHARACTER | NCNAME_CHARACTER;
+ MASKS[':'] |= nameStartMask;
+ MASKS['_'] |= nameStartMask;
+ for (int i = 'A'; i <= 'Z'; ++i) MASKS[i] |= nameStartMask;
+ for (int i = 'a'; i <= 'z'; ++i) MASKS[i] |= nameStartMask;
+ for (int i = 0xC0; i <= 0xD6; ++i) MASKS[i] |= nameStartMask;
+ for (int i = 0xD8; i <= 0xF6; ++i) MASKS[i] |= nameStartMask;
+ for (int i = 0xF8; i <= 0x2FF; ++i) MASKS[i] |= nameStartMask;
+ for (int i = 0x370; i <= 0x37D; ++i) MASKS[i] |= nameStartMask;
+ for (int i = 0x37F; i <= 0x1FFF; ++i) MASKS[i] |= nameStartMask;
+ for (int i = 0x200C; i <= 0x200D; ++i) MASKS[i] |= nameStartMask;
+ for (int i = 0x2070; i <= 0x218F; ++i) MASKS[i] |= nameStartMask;
+ for (int i = 0x2C00; i <= 0x2FEF; ++i) MASKS[i] |= nameStartMask;
+ for (int i = 0x3001; i <= 0xD7FF; ++i) MASKS[i] |= nameStartMask;
+ for (int i = 0xF900; i <= 0xFDCF; ++i) MASKS[i] |= nameStartMask;
+ for (int i = 0xFDF0; i <= 0xFFFD; ++i) MASKS[i] |= nameStartMask;
+ // Last range is bigger than our character array ...
+ //for (int i = 0x10000; i <= 0xEFFFF; ++i) MASKS[i] |= nameStartMask;
+
+ // ---------------
+ // Name Characters
+ // ---------------
+ // [4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
+ // See http://www.w3.org/TR/REC-xml/#sec-common-syn
+ //
+ // Note that all these characters are valid for NAME and NCNAME
+ int nameMask = NAME_CHARACTER | NCNAME_CHARACTER;
+ MASKS['-'] |= nameMask;
+ MASKS['.'] |= nameMask;
+ MASKS[0xB7] |= nameMask;
+ for (int i = '0'; i <= '9'; ++i) MASKS[i] |= nameMask;
+ for (int i = 0x0300; i <= 0x036F; ++i) MASKS[i] |= nameStartMask;
+ for (int i = 0x203F; i <= 0x2040; ++i) MASKS[i] |= nameStartMask;
+
+ // --------
+ // NC Names
+ // --------
+ // [4] NCName ::= NCNameStartChar NCNameChar*
+ // which is just an XML Name, minus the ":"
+ // See http://www.w3.org/TR/REC-xml-names/#ns-decl
+ // So, remove the NCNAME_CHARACTER and NCNAME_START_CHARACTER masks from ':' ...
+ MASKS[':'] &= ~(NCNAME_START_CHARACTER | NCNAME_CHARACTER);
+
+ // --------------------
+ // Public ID characters
+ // --------------------
+ // [13] PubidChar ::= #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%]
+ MASKS[0x20] |= PUBID_CHARACTER;
+ MASKS[0xA] |= PUBID_CHARACTER;
+ MASKS[0xD] |= PUBID_CHARACTER;
+ for (int i = 'A'; i <= 'Z'; ++i) MASKS[i] |= PUBID_CHARACTER;
+ for (int i = 'a'; i <= 'z'; ++i) MASKS[i] |= PUBID_CHARACTER;
+ for (int i = '0'; i <= '9'; ++i) MASKS[i] |= PUBID_CHARACTER;
+ MASKS['-'] |= PUBID_CHARACTER;
+ MASKS['\''] |= PUBID_CHARACTER;
+ MASKS['('] |= PUBID_CHARACTER;
+ MASKS[')'] |= PUBID_CHARACTER;
+ MASKS['+'] |= PUBID_CHARACTER;
+ MASKS[','] |= PUBID_CHARACTER;
+ MASKS['.'] |= PUBID_CHARACTER;
+ MASKS['/'] |= PUBID_CHARACTER;
+ MASKS[':'] |= PUBID_CHARACTER;
+ MASKS['='] |= PUBID_CHARACTER;
+ MASKS['?'] |= PUBID_CHARACTER;
+ MASKS[';'] |= PUBID_CHARACTER;
+ MASKS['!'] |= PUBID_CHARACTER;
+ MASKS['*'] |= PUBID_CHARACTER;
+ MASKS['#'] |= PUBID_CHARACTER;
+ MASKS['@'] |= PUBID_CHARACTER;
+ MASKS['$'] |= PUBID_CHARACTER;
+ MASKS['_'] |= PUBID_CHARACTER;
+ MASKS['%'] |= PUBID_CHARACTER;
+
+ }
+
+ private XmlCharacters() {
+ }
+
+ /**
+ * Determine whether the supplied character is a valid first character in an XML Name.
+ * The first character in an XML name is more restrictive than the {@link #isValidName(int) remaining characters}.
+ *
+ * @param c the character
+ * @return true if the character is valid for an XML Name's first character
+ */
+ public static boolean isValidNameStart( int c ) {
+ return c < NUMBER_OF_CHARACTERS && ( MASKS[c] & NAME_START_CHARACTER ) != 0;
+ }
+
+ /**
+ * Determine whether the supplied character is a valid first character in an XML NCName.
+ * The first character in an XML NCName is more restrictive than the {@link #isValidName(int) remaining characters}.
+ *
+ * @param c the character
+ * @return true if the character is valid for an XML NCName's first character
+ */
+ public static boolean isValidNcNameStart( int c ) {
+ return c < NUMBER_OF_CHARACTERS && ( MASKS[c] & NCNAME_START_CHARACTER ) != 0;
+ }
+
+ /**
+ * Determine whether the supplied character is a valid non-first character in an XML Name.
+ * The {@link #isValidNameStart(int) first character} in an XML name is more restrictive than the remaining characters.
+ *
+ * @param c the character
+ * @return true if the character is valid character in an XML Name
+ */
+ public static boolean isValidName( int c ) {
+ return c < NUMBER_OF_CHARACTERS && ( MASKS[c] & NAME_CHARACTER ) != 0;
+ }
+
+ /**
+ * Determine whether the supplied character is a valid non-first character in an XML NCName.
+ * The {@link #isValidNcNameStart(int) first character} in an XML NCName is more restrictive than the remaining characters.
+ *
+ * @param c the character
+ * @return true if the character is valid character in an XML NCName
+ */
+ public static boolean isValidNcName( int c ) {
+ return c < NUMBER_OF_CHARACTERS && ( MASKS[c] & NCNAME_CHARACTER ) != 0;
+ }
+
+ /**
+ * Determine whether the supplied character is a valid character in an XML Pubid.
+ *
+ * @param c the character
+ * @return true if the character is valid character in an XML Pubid
+ */
+ public static boolean isValidPubid( int c ) {
+ return c < NUMBER_OF_CHARACTERS && ( MASKS[c] & PUBID_CHARACTER ) != 0;
+ }
+
+ /**
+ * Determine whether the supplied character is a valid character in XML.
+ *
+ * @param c the character
+ * @return true if the character is valid character in XML
+ */
+ public static boolean isValid( int c ) {
+ return (c < NUMBER_OF_CHARACTERS && ( MASKS[c] & VALID_CHARACTER ) != 0) || ( 0x10000 <= c && c <= 0x10FFFF);
+ }
+
+ /**
+ * Determine whether the supplied character is a valid character in XML content
+ *
+ * @param c the character
+ * @return true if the character is valid character in XML content
+ */
+ public static boolean isValidContent( int c ) {
+ return (c < NUMBER_OF_CHARACTERS && ( MASKS[c] & CONTENT_CHARACTER ) != 0) || ( 0x10000 <= c && c <= 0x10FFFF);
+ }
+
+ /**
+ * Determine whether the supplied character is a valid whitespace character in XML
+ *
+ * @param c the character
+ * @return true if the character is valid whitespace character in XML
+ */
+ public static boolean isValidSpace( int c ) {
+ return c <= 0x20 && ( MASKS[c] & SPACE_CHARACTER ) != 0;
+ }
+
+ /**
+ * Determine if the supplied name is a valid XML Name.
+ *
+ * @param name the string being checked
+ * @return true if the supplied name is indeed a valid XML Name, or false otherwise
+ */
+ public static boolean isValidName( String name ) {
+ if ( name == null || name.length() == 0 ) return false;
+ CharacterIterator iter = new StringCharacterIterator(name);
+ char c = iter.first();
+ if ( !isValidNameStart(c) ) return false;
+ while ( c != CharacterIterator.DONE ) {
+ if ( !isValidName(c) ) return false;
+ c = iter.next();
+ }
+ return true;
+ }
+
+ /**
+ * Determine if the supplied name is a valid XML NCName.
+ *
+ * @param name the string being checked
+ * @return true if the supplied name is indeed a valid XML NCName, or false otherwise
+ */
+ public static boolean isValidNcName( String name ) {
+ if ( name == null || name.length() == 0 ) return false;
+ CharacterIterator iter = new StringCharacterIterator(name);
+ char c = iter.first();
+ if ( !isValidNcNameStart(c) ) return false;
+ while ( c != CharacterIterator.DONE ) {
+ if ( !isValidNcName(c) ) return false;
+ c = iter.next();
+ }
+ return true;
+ }
+}
Property changes on: trunk/dna-common/src/main/java/org/jboss/dna/common/xml/XmlCharacters.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/dna-common/src/test/java/org/jboss/dna/common/xml/XmlCharactersTest.java
===================================================================
--- trunk/dna-common/src/test/java/org/jboss/dna/common/xml/XmlCharactersTest.java (rev 0)
+++ trunk/dna-common/src/test/java/org/jboss/dna/common/xml/XmlCharactersTest.java 2009-01-29 02:32:27 UTC (rev 719)
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+package org.jboss.dna.common.xml;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class XmlCharactersTest {
+
+ @Test
+ public void shouldNotAllowColonInNcName() {
+ assertThat(XmlCharacters.isValidNcNameStart(':'), is(false));
+ }
+
+ @Test
+ public void shouldNotAllowDigitAsFirstCharacterInName() {
+ assertThat(XmlCharacters.isValidNameStart('0'), is(false));
+ assertThat(XmlCharacters.isValidNameStart('1'), is(false));
+ assertThat(XmlCharacters.isValidNameStart('2'), is(false));
+ assertThat(XmlCharacters.isValidNameStart('3'), is(false));
+ assertThat(XmlCharacters.isValidNameStart('4'), is(false));
+ assertThat(XmlCharacters.isValidNameStart('5'), is(false));
+ assertThat(XmlCharacters.isValidNameStart('6'), is(false));
+ assertThat(XmlCharacters.isValidNameStart('7'), is(false));
+ assertThat(XmlCharacters.isValidNameStart('8'), is(false));
+ assertThat(XmlCharacters.isValidNameStart('9'), is(false));
+ }
+
+ @Test
+ public void shouldAllowLettersAsFirstCharacterInName() {
+ for (char c = 'a'; c <= 'z'; ++c) {
+ assertThat(XmlCharacters.isValidNameStart(c), is(true));
+ }
+ for (char c = 'A'; c <= 'Z'; ++c) {
+ assertThat(XmlCharacters.isValidNameStart(c), is(true));
+ }
+ }
+
+ @Test
+ public void shouldNotAllowDigitAsFirstCharacterInNcName() {
+ assertThat(XmlCharacters.isValidNcNameStart('0'), is(false));
+ assertThat(XmlCharacters.isValidNcNameStart('1'), is(false));
+ assertThat(XmlCharacters.isValidNcNameStart('2'), is(false));
+ assertThat(XmlCharacters.isValidNcNameStart('3'), is(false));
+ assertThat(XmlCharacters.isValidNcNameStart('4'), is(false));
+ assertThat(XmlCharacters.isValidNcNameStart('5'), is(false));
+ assertThat(XmlCharacters.isValidNcNameStart('6'), is(false));
+ assertThat(XmlCharacters.isValidNcNameStart('7'), is(false));
+ assertThat(XmlCharacters.isValidNcNameStart('8'), is(false));
+ assertThat(XmlCharacters.isValidNcNameStart('9'), is(false));
+ }
+}
Property changes on: trunk/dna-common/src/test/java/org/jboss/dna/common/xml/XmlCharactersTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 3 months
DNA SVN: r718 - trunk.
by dna-commits@lists.jboss.org
Author: jverhaeg(a)redhat.com
Date: 2009-01-23 15:54:50 -0500 (Fri, 23 Jan 2009)
New Revision: 718
Modified:
trunk/eclipse-preferences.epf
Log:
DNA-277: Changed preferences to set encoding to UTF-8 and create files using UNIX-style line delimiters.
Modified: trunk/eclipse-preferences.epf
===================================================================
--- trunk/eclipse-preferences.epf 2009-01-22 11:06:28 UTC (rev 717)
+++ trunk/eclipse-preferences.epf 2009-01-23 20:54:50 UTC (rev 718)
@@ -1,4 +1,6 @@
file_export_version=3.0
+/instance/org.eclipse.core.resources/encoding=UTF-8
+/instance/org.eclipse.core.runtime/line.separator=\n
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.argumentPrefixes=
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.argumentSuffixes=
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.fieldPrefixes=
15 years, 3 months
DNA SVN: r717 - trunk/extensions/dna-connector-svn/src/main/resources/org/jboss/dna/connector/svn.
by dna-commits@lists.jboss.org
Author: spagop
Date: 2009-01-22 06:06:28 -0500 (Thu, 22 Jan 2009)
New Revision: 717
Modified:
trunk/extensions/dna-connector-svn/src/main/resources/org/jboss/dna/connector/svn/SVNConnectorI18n.properties
Log:
some exception handling enhancements
Modified: trunk/extensions/dna-connector-svn/src/main/resources/org/jboss/dna/connector/svn/SVNConnectorI18n.properties
===================================================================
--- trunk/extensions/dna-connector-svn/src/main/resources/org/jboss/dna/connector/svn/SVNConnectorI18n.properties 2009-01-22 11:06:04 UTC (rev 716)
+++ trunk/extensions/dna-connector-svn/src/main/resources/org/jboss/dna/connector/svn/SVNConnectorI18n.properties 2009-01-22 11:06:28 UTC (rev 717)
@@ -30,4 +30,5 @@
errorSerializingCachePolicyInSource = Error serializing a {0} instance owned by the {1} SVNRepositorySource
objectFoundInJndiWasNotSVNRepository = Object in JNDI at {0} found by SVNRepositorySource {1} was expected to be a typ of org.tmatesoft.svn.core.io.SVNRepository but instead was {2}
objectFoundInJndiWasNotSVNRepositoryFactory =Object in JNDI at {0} found by SVNRepositorySource {1} was expected to be a typ of org.tmatesoft.svn.core.io.SVNRepositoryFactory but instead was {2}
-sourceIsReadOnly = {0} is a read-only source; no updates are allowed
\ No newline at end of file
+sourceIsReadOnly ={0} is a read-only source; no updates are allowed
+connectingFailureOrUserAuthenticationProblem=failure occured while connecting to the repository {0} or the user's authentication failed
\ No newline at end of file
15 years, 3 months
DNA SVN: r716 - trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn.
by dna-commits@lists.jboss.org
Author: spagop
Date: 2009-01-22 06:06:04 -0500 (Thu, 22 Jan 2009)
New Revision: 716
Modified:
trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNActionExecutor.java
trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryConnectorI18n.java
trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryRequestProcessor.java
Log:
some exception handling enhancements
Modified: trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNActionExecutor.java
===================================================================
--- trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNActionExecutor.java 2009-01-20 19:47:01 UTC (rev 715)
+++ trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNActionExecutor.java 2009-01-22 11:06:04 UTC (rev 716)
@@ -25,6 +25,8 @@
import org.jboss.dna.connector.scm.ScmAction;
import org.jboss.dna.connector.scm.ScmActionExecutor;
+import org.tmatesoft.svn.core.SVNErrorCode;
+import org.tmatesoft.svn.core.SVNErrorMessage;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.io.ISVNEditor;
import org.tmatesoft.svn.core.io.SVNRepository;
@@ -53,21 +55,20 @@
/**
* @param action
* @param message
- * @throws Exception
+ * @throws SVNException
*/
public void execute( ScmAction action,
- String message ) throws Exception {
+ String message ) throws SVNException {
+ ISVNEditor editor = this.repository.getCommitEditor(message, null);
+ editor.openRoot(-1);
try {
- ISVNEditor editor = this.repository.getCommitEditor( message,
- null );
- editor.openRoot( -1 );
- action.applyAction( editor );
- editor.closeDir();
- editor.closeEdit();
- } catch ( SVNException e ) {
- e.printStackTrace();
- //logger.error( "svn error: " );
- throw e;
+ action.applyAction(editor);
+ } catch (Exception e) {
+ SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNKNOWN, "This error is appeared: '{0}'", e.getMessage());
+ throw new SVNException(err);
}
+ editor.closeDir();
+ editor.closeEdit();
+
}
}
Modified: trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryConnectorI18n.java
===================================================================
--- trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryConnectorI18n.java 2009-01-20 19:47:01 UTC (rev 715)
+++ trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryConnectorI18n.java 2009-01-22 11:06:04 UTC (rev 716)
@@ -42,6 +42,7 @@
public static I18n objectFoundInJndiWasNotCacheFactory;
public static I18n locationInRequestMustHavePath;
public static I18n sourceIsReadOnly;
+ public static I18n connectingFailureOrUserAuthenticationProblem;
static {
try {
Modified: trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryRequestProcessor.java
===================================================================
--- trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryRequestProcessor.java 2009-01-20 19:47:01 UTC (rev 715)
+++ trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryRequestProcessor.java 2009-01-22 11:06:04 UTC (rev 716)
@@ -58,6 +58,8 @@
import org.jboss.dna.graph.request.UpdatePropertiesRequest;
import org.jboss.dna.graph.request.processor.RequestProcessor;
import org.tmatesoft.svn.core.SVNDirEntry;
+import org.tmatesoft.svn.core.SVNErrorCode;
+import org.tmatesoft.svn.core.SVNErrorMessage;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNNodeKind;
import org.tmatesoft.svn.core.SVNProperties;
@@ -125,49 +127,46 @@
String root = parent.getString(getExecutionContext().getNamespaceRegistry());
SVNNodeKind rootKind = repository.checkPath(root, -1);
if (rootKind == SVNNodeKind.UNKNOWN) {
- // TODO throw an checked exception
+ SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNKNOWN,
+ "path with name '{0}' is unknown in the repository",
+ root);
+ SVNException ex = new SVNException(err);
+ request.setError(ex);
} else if (rootKind == SVNNodeKind.NONE) {
- // TODO throw an checked exception
+ SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNKNOWN,
+ "path with name '{0}' is missing in the repository",
+ root);
+ SVNException ex = new SVNException(err);
+ request.setError(ex);
} else if (rootKind == SVNNodeKind.FILE) {
- // TODO throw an checked exception
+ SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNKNOWN,
+ "pretended root item with name '{0}' is a file",
+ root);
+ SVNException ex = new SVNException(err);
+ request.setError(ex);
} else if (rootKind == SVNNodeKind.DIR) {
+
+ // TODO if node is a file
+
+ // if the node is a directory
String childName = request.named().getString(getExecutionContext().getNamespaceRegistry());
if (root.length() == 1 && root.charAt(0) == '/') {
// test if so a directory does not exist.
- mkdir("",childName, request.toString());
+ mkdir("", childName, request.toString());
} else {
- if(root.length() > 1 && root.charAt(0) == '/') {
+ if (root.length() > 1 && root.charAt(0) == '/') {
// test if so a directory does not exist.
- mkdir(root.substring(1),childName, request.toString());
+ mkdir(root.substring(1), childName, request.toString());
}
}
}
- } catch (Exception e) {
+ } catch (SVNException e) {
+ request.setError(e);
}
- //
}
/**
- * Create a directory .
- * @param root - the root directory where the created directory will reside
- * @param childName - the name of the created directory.
- * @param message - comment for the creation.
- * @throws Exception - if during the creation, there is an error.
- */
- private void mkdir( String root,
- String childName, String message) throws Exception {
- SVNNodeKind childKind = repository.checkPath(childName, -1);
- if (childKind == SVNNodeKind.NONE) {
- ScmAction addNodeAction = addDirectory(root, childName);
- SVNActionExecutor executor = new SVNActionExecutor(repository);
- executor.execute(addNodeAction, message);
- } else {
- // TODO throwns an exception
- }
- }
-
- /**
* {@inheritDoc}
*
* @see org.jboss.dna.graph.request.processor.RequestProcessor#process(org.jboss.dna.graph.request.DeleteBranchRequest)
@@ -240,11 +239,6 @@
}
request.setActualLocationOfNode(myLocation);
} catch (SVNException e) {
- // if a failure occured while connecting to a repository
- // or the user's authentication failed (see
- // path not found in the specified revision
- // or is not a directory
- e.printStackTrace();
request.setError(e);
}
@@ -323,7 +317,6 @@
request.setActualLocationOfNode(myLocation);
} catch (SVNException e) {
- e.printStackTrace();
request.setError(e);
}
}
@@ -483,10 +476,9 @@
SVNRepositoryConnectorI18n.nodeIsActuallyUnknow.text(myPath));
}
} catch (SVNException e) {
- // if a failure occured while connecting to a repository
- // * or the user's authentication failed (see
- // * {@link org.tmatesoft.svn.core.SVNAuthenticationException})
- // TODO RepositorySourceAuthenticationException
+ throw new RepositorySourceException(
+ getSourceName(),
+ SVNRepositoryConnectorI18n.connectingFailureOrUserAuthenticationProblem.text(getSourceName()));
}
return kind;
@@ -504,10 +496,9 @@
try {
entry = getRepository().info(path, -1);
} catch (SVNException e) {
- // if a failure occured while connecting to a repository
- // * or the user's authentication failed (see
- // * {@link org.tmatesoft.svn.core.SVNAuthenticationException})
- // TODO RepositorySourceAuthenticationException
+ throw new RepositorySourceException(
+ getSourceName(),
+ SVNRepositoryConnectorI18n.connectingFailureOrUserAuthenticationProblem.text(getSourceName()));
}
return entry;
}
@@ -517,7 +508,7 @@
*
* @param editor - abstract editor.
* @param rootPath - the pa to open.
- * @throws SVNException
+ * @throws SVNException when a error occur.
*/
protected static void openDirectories( ISVNEditor editor,
String rootPath ) throws SVNException {
@@ -537,7 +528,7 @@
*
* @param editor - the abstract editor.
* @param path - the directories to open.
- * @throws SVNException
+ * @throws SVNException when a error occur.
*/
protected static void closeDirectories( ISVNEditor editor,
String path ) throws SVNException {
@@ -567,11 +558,13 @@
}
/**
- * @param repository
+ * Add directory in a repository
+ *
+ * @param repository - the repository.
* @param root - the root path has to exist.
* @param child - new path to be added.
* @param message - information about the change action.
- * @throws SVNException
+ * @throws SVNException when a error occur.
*/
protected void addDirEntry( SVNRepository repository,
String root,
@@ -580,11 +573,20 @@
assert root.trim().length() != 0;
SVNNodeKind rootKind = repository.checkPath(root, -1);
if (rootKind == SVNNodeKind.UNKNOWN) {
- // TODO throw an checked exception
+ SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNKNOWN,
+ "path with name '{0}' is unknown in the repository",
+ root);
+ throw new SVNException(err);
} else if (rootKind == SVNNodeKind.NONE) {
- // TODO throw an checked exception
+ SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNKNOWN,
+ "path with name '{0}' is missing in the repository",
+ root);
+ throw new SVNException(err);
} else if (rootKind == SVNNodeKind.FILE) {
- // TODO throw an checked exception
+ SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNKNOWN,
+ "path with name '{0}' is a file, you need a directory",
+ root);
+ throw new SVNException(err);
} else if (rootKind == SVNNodeKind.DIR) {
ISVNEditor editor = repository.getCommitEditor(message, null, true, null);
if (root.length() == 1 && root.charAt(0) == '/') {
@@ -613,7 +615,6 @@
}
} else {
- // TODO throws an exception
closeDirectories(editor, childSegmentName);
if (editedRoot != null) {
closeDirectories(editor, editedRoot);
@@ -624,6 +625,28 @@
}
/**
+ * Create a directory .
+ *
+ * @param root - the root directory where the created directory will reside
+ * @param childName - the name of the created directory.
+ * @param message - comment for the creation.
+ * @throws SVNException - if during the creation, there is an error.
+ */
+ private void mkdir( String root,
+ String childName,
+ String message ) throws SVNException {
+ SVNNodeKind childKind = repository.checkPath(childName, -1);
+ if (childKind == SVNNodeKind.NONE) {
+ ScmAction addNodeAction = addDirectory(root, childName);
+ SVNActionExecutor executor = new SVNActionExecutor(repository);
+ executor.execute(addNodeAction, message);
+ } else {
+ SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNKNOWN, "Item with name '{0}' can't be created", childName);
+ throw new SVNException(err);
+ }
+ }
+
+ /**
* {@inheritDoc}
*
* @see org.jboss.dna.connector.scm.ScmActionFactory#addDirectory(java.lang.String, java.lang.String)
@@ -690,7 +713,7 @@
public void applyAction( Object context ) throws SVNException {
ISVNEditor editor = (ISVNEditor)context;
-
+
openDirectories(editor, this.root);
String[] paths = this.path.split("/");
String newPath = this.root;
15 years, 3 months
DNA SVN: r715 - trunk/build.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-01-20 14:47:01 -0500 (Tue, 20 Jan 2009)
New Revision: 715
Removed:
trunk/build/JBossORG-EULA.txt
Log:
Removed unnecessary JBossORG end-users license agreement file.
Deleted: trunk/build/JBossORG-EULA.txt
===================================================================
--- trunk/build/JBossORG-EULA.txt 2009-01-19 12:31:54 UTC (rev 714)
+++ trunk/build/JBossORG-EULA.txt 2009-01-20 19:47:01 UTC (rev 715)
@@ -1,106 +0,0 @@
-LICENSE AGREEMENT
-JBOSS(r)
-
-This License Agreement governs the use of the Software Packages and any updates to the Software
-Packages, regardless of the delivery mechanism. Each Software Package is a collective work
-under U.S. Copyright Law. Subject to the following terms, Red Hat, Inc. ("Red Hat") grants to
-the user ("Client") a license to the applicable collective work(s) pursuant to the
-GNU Lesser General Public License v. 2.1 except for the following Software Packages:
-(a) JBoss Portal Forums and JBoss Transactions JTS, each of which is licensed pursuant to the
-GNU General Public License v.2;
-
-(b) JBoss Rules, which is licensed pursuant to the Apache License v.2.0;
-
-(c) an optional download for JBoss Cache for the Berkeley DB for Java database, which is licensed under the
-(open source) Sleepycat License (if Client does not wish to use the open source version of this database,
-it may purchase a license from Sleepycat Software);
-
-and (d) the BPEL extension for JBoss jBPM, which is licensed under the Common Public License v.1,
-and, pursuant to the OASIS BPEL4WS standard, requires parties wishing to redistribute to enter various
-royalty-free patent licenses.
-
-Each of the foregoing licenses is available at http://www.opensource.org/licenses/index.php.
-
-1. The Software. "Software Packages" refer to the various software modules that are created and made available
-for distribution by the JBoss.org open source community at http://www.jboss.org. Each of the Software Packages
-may be comprised of hundreds of software components. The end user license agreement for each component is located in
-the component's source code. With the exception of certain image files identified in Section 2 below,
-the license terms for the components permit Client to copy, modify, and redistribute the component,
-in both source code and binary code forms. This agreement does not limit Client's rights under,
-or grant Client rights that supersede, the license terms of any particular component.
-
-2. Intellectual Property Rights. The Software Packages are owned by Red Hat and others and are protected under copyright
-and other laws. Title to the Software Packages and any component, or to any copy, modification, or merged portion shall
-remain with the aforementioned, subject to the applicable license. The "JBoss" trademark, "Red Hat" trademark, the
-individual Software Package trademarks, and the "Shadowman" logo are registered trademarks of Red Hat and its affiliates
-in the U.S. and other countries. This agreement permits Client to distribute unmodified copies of the Software Packages
-using the Red Hat trademarks that Red Hat has inserted in the Software Packages on the condition that Client follows Red Hat's
-trademark guidelines for those trademarks located at http://www.redhat.com/about/corporate/trademark/. Client must abide by
-these trademark guidelines when distributing the Software Packages, regardless of whether the Software Packages have been modified.
-If Client modifies the Software Packages, then Client must replace all Red Hat trademarks and logos identified at
-http://www.jboss.com/company/logos, unless a separate agreement with Red Hat is executed or other permission granted.
-Merely deleting the files containing the Red Hat trademarks may corrupt the Software Packages.
-
-3. Limited Warranty. Except as specifically stated in this Paragraph 3 or a license for a particular
-component, to the maximum extent permitted under applicable law, the Software Packages and the
-components are provided and licensed "as is" without warranty of any kind, expressed or implied,
-including the implied warranties of merchantability, non-infringement or fitness for a particular purpose.
-Red Hat warrants that the media on which Software Packages may be furnished will be free from defects in
-materials and manufacture under normal use for a period of 30 days from the date of delivery to Client.
-Red Hat does not warrant that the functions contained in the Software Packages will meet Client's requirements
-or that the operation of the Software Packages will be entirely error free or appear precisely as described
-in the accompanying documentation. This warranty extends only to the party that purchases the Services
-pertaining to the Software Packages from Red Hat or a Red Hat authorized distributor.
-
-4. Limitation of Remedies and Liability. To the maximum extent permitted by applicable law, the remedies
-described below are accepted by Client as its only remedies. Red Hat's entire liability, and Client's
-exclusive remedies, shall be: If the Software media is defective, Client may return it within 30 days of
-delivery along with a copy of Client's payment receipt and Red Hat, at its option, will replace it or
-refund the money paid by Client for the Software. To the maximum extent permitted by applicable law,
-Red Hat or any Red Hat authorized dealer will not be liable to Client for any incidental or consequential
-damages, including lost profits or lost savings arising out of the use or inability to use the Software,
-even if Red Hat or such dealer has been advised of the possibility of such damages. In no event shall
-Red Hat's liability under this agreement exceed the amount that Client paid to Red Hat under this
-Agreement during the twelve months preceding the action.
-
-5. Export Control. As required by U.S. law, Client represents and warrants that it:
-(a) understands that the Software Packages are subject to export controls under the
-U.S. Commerce Department's Export Administration Regulations ("EAR");
-
-(b) is not located in a prohibited destination country under the EAR or U.S. sanctions regulations
-(currently Cuba, Iran, Iraq, Libya, North Korea, Sudan and Syria);
-
-(c) will not export, re-export, or transfer the Software Packages to any prohibited destination, entity,
-or individual without the necessary export license(s) or authorizations(s) from the U.S. Government;
-
-(d) will not use or transfer the Software Packages for use in any sensitive nuclear, chemical or
-biological weapons, or missile technology end-uses unless authorized by the U.S. Government by
-regulation or specific license;
-
-(e) understands and agrees that if it is in the United States and exports or transfers the Software
-Packages to eligible end users, it will, as required by EAR Section 740.17(e), submit semi-annual
-reports to the Commerce Department's Bureau of Industry & Security (BIS), which include the name and
-address (including country) of each transferee;
-
-and (f) understands that countries other than the United States may restrict the import, use, or
-export of encryption products and that it shall be solely responsible for compliance with any such
-import, use, or export restrictions.
-
-6. Third Party Programs. Red Hat may distribute third party software programs with the Software Packages
-that are not part of the Software Packages and which Client must install separately. These third party
-programs are subject to their own license terms. The license terms either accompany the programs or
-can be viewed at http://www.redhat.com/licenses/. If Client does not agree to abide by the applicable
-license terms for such programs, then Client may not install them. If Client wishes to install the programs
-on more than one system or transfer the programs to another party, then Client must contact the licensor
-of the programs.
-
-7. General. If any provision of this agreement is held to be unenforceable, that shall not affect the
-enforceability of the remaining provisions. This License Agreement shall be governed by the laws of the
-State of North Carolina and of the United States, without regard to any conflict of laws provisions,
-except that the United Nations Convention on the International Sale of Goods shall not apply.
-
-Copyright 2006 Red Hat, Inc. All rights reserved.
-"JBoss" and the JBoss logo are registered trademarks of Red Hat, Inc.
-All other trademarks are the property of their respective owners.
-
- Page 1 of 1 18 October 2006
15 years, 3 months
DNA SVN: r714 - in trunk/extensions: dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi and 2 other directories.
by dna-commits@lists.jboss.org
Author: lisbor
Date: 2009-01-19 07:31:54 -0500 (Mon, 19 Jan 2009)
New Revision: 714
Modified:
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/util/DatabaseUtil.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/DatabaseBeanTest.java
trunk/extensions/dna-connector-jdbc-metadata/.classpath
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcConnection.java
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcRequestProcesor.java
Log:
DNA-37 Federate schema information from relational sources
https://jira.jboss.org/jira/browse/DNA-37
Fix warning messages
Modified: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/util/DatabaseUtil.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/util/DatabaseUtil.java 2009-01-16 21:47:49 UTC (rev 713)
+++ trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/util/DatabaseUtil.java 2009-01-19 12:31:54 UTC (rev 714)
@@ -2261,7 +2261,7 @@
// foreign key name
String foreignKeyName = getString(resultSet, "FK_NAME", false);
// primary key name
- String primaryKeyName = getString(resultSet, "PK_NAME", false);
+ //String primaryKeyName = getString(resultSet, "PK_NAME", false);
// can the evaluation of foreign key constraints be deferred until commit
Integer defferability = getInteger(resultSet, "DEFERRABILITY", false);
Modified: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/DatabaseBeanTest.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/DatabaseBeanTest.java 2009-01-16 21:47:49 UTC (rev 713)
+++ trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/DatabaseBeanTest.java 2009-01-19 12:31:54 UTC (rev 714)
@@ -80,6 +80,13 @@
/**
* testDatabaseMetadataExceptions
*/
+ public void testModelFactoryIsNotNull() {
+ assertNotNull("Default model factory shall be set", factory);
+ }
+
+ /**
+ * testDatabaseMetadataExceptions
+ */
public void testGetExceptions() {
// get list of exceptions
List<DatabaseMetaDataMethodException> exceptionList = bean.getExceptionList();
Modified: trunk/extensions/dna-connector-jdbc-metadata/.classpath
===================================================================
--- trunk/extensions/dna-connector-jdbc-metadata/.classpath 2009-01-16 21:47:49 UTC (rev 713)
+++ trunk/extensions/dna-connector-jdbc-metadata/.classpath 2009-01-19 12:31:54 UTC (rev 714)
@@ -4,7 +4,8 @@
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/data"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
Modified: trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcConnection.java
===================================================================
--- trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcConnection.java 2009-01-16 21:47:49 UTC (rev 713)
+++ trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcConnection.java 2009-01-19 12:31:54 UTC (rev 714)
@@ -148,7 +148,7 @@
public void execute( ExecutionContext context,
Request request ) throws RepositorySourceException {
// create processor and delegate handling
- RequestProcessor proc = new JdbcRequestProcesor(getSourceName(),context, connection);
+ RequestProcessor proc = new JdbcRequestProcesor(getSourceName(),context, connection, rootNodeUuid);
try {
proc.process(request);
} finally {
Modified: trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcRequestProcesor.java
===================================================================
--- trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcRequestProcesor.java 2009-01-16 21:47:49 UTC (rev 713)
+++ trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcRequestProcesor.java 2009-01-19 12:31:54 UTC (rev 714)
@@ -24,6 +24,7 @@
package org.jboss.dna.connector.jdbc;
import java.sql.Connection;
+import java.util.UUID;
import org.jboss.dna.common.util.Logger;
import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.property.DateTime;
@@ -44,6 +45,7 @@
*/
public class JdbcRequestProcesor extends RequestProcessor {
protected Connection connection;
+ protected UUID rootNodeUuid;
/**
* Logging for this instance
@@ -54,26 +56,32 @@
* @param sourceName
* @param context
* @param connection
+ * @param rootNodeUuid
*/
public JdbcRequestProcesor( String sourceName,
ExecutionContext context,
- Connection connection) {
+ Connection connection,
+ UUID rootNodeUuid) {
super(sourceName, context);
this.connection = connection;
+ this.rootNodeUuid = rootNodeUuid;
}
/**
* @param sourceName
* @param context
* @param connection
+ * @param rootNodeUuid
* @param now
*/
public JdbcRequestProcesor( String sourceName,
ExecutionContext context,
Connection connection,
+ UUID rootNodeUuid,
DateTime now ) {
super(sourceName, context, now);
this.connection = connection;
+ this.rootNodeUuid = rootNodeUuid;
}
/**
15 years, 3 months
DNA SVN: r713 - trunk.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-01-16 16:47:49 -0500 (Fri, 16 Jan 2009)
New Revision: 713
Added:
trunk/.gitignore
Log:
Added .gitignore file, so that any git-svn users can benefit
Added: trunk/.gitignore
===================================================================
--- trunk/.gitignore (rev 0)
+++ trunk/.gitignore 2009-01-16 21:47:49 UTC (rev 713)
@@ -0,0 +1,99 @@
+
+# /
+/.metadata
+/target
+
+# /dna-common/
+/dna-common/.settings
+/dna-common/target
+
+# /dna-graph/
+/dna-graph/.settings
+/dna-graph/target
+
+# /dna-integration-tests/
+/dna-integration-tests/.settings
+/dna-integration-tests/target
+
+# /dna-jcr/
+/dna-jcr/target
+
+# /dna-repository/
+/dna-repository/.settings
+/dna-repository/target
+
+# /docs/
+/docs/target
+
+# /docs/examples/gettingstarted/repositories/
+/docs/examples/gettingstarted/repositories/target
+
+# /docs/examples/gettingstarted/sequencers/
+/docs/examples/gettingstarted/sequencers/target
+
+# /docs/gettingstarted/
+/docs/gettingstarted/target
+
+# /docs/presentations/
+/docs/presentations/*.key
+
+# /docs/reference/
+/docs/reference/target
+
+# /extensions/dna-classloader-maven/
+/extensions/dna-classloader-maven/target
+
+# /extensions/dna-common-jdbc/
+/extensions/dna-common-jdbc/target
+
+# /extensions/dna-connector-federation/
+/extensions/dna-connector-federation/target
+
+# /extensions/dna-connector-filesystem/
+/extensions/dna-connector-filesystem/target
+
+# /extensions/dna-connector-inmemory/
+/extensions/dna-connector-inmemory/target
+
+# /extensions/dna-connector-jbosscache/
+/extensions/dna-connector-jbosscache/target
+
+# /extensions/dna-connector-jdbc-metadata/
+/extensions/dna-connector-jdbc-metadata/target
+
+# /extensions/dna-connector-store-jpa/
+/extensions/dna-connector-store-jpa/target
+
+# /extensions/dna-connector-svn/
+/extensions/dna-connector-svn/target
+
+# /extensions/dna-mimetype-detector-aperture/
+/extensions/dna-mimetype-detector-aperture/.settings
+/extensions/dna-mimetype-detector-aperture/target
+
+# /extensions/dna-sequencer-cnd/
+/extensions/dna-sequencer-cnd/target
+
+# /extensions/dna-sequencer-esbMessage/
+/extensions/dna-sequencer-esbMessage/target
+
+# /extensions/dna-sequencer-images/
+/extensions/dna-sequencer-images/target
+
+# /extensions/dna-sequencer-java/
+/extensions/dna-sequencer-java/target
+
+# /extensions/dna-sequencer-jbpm-jpdl/
+/extensions/dna-sequencer-jbpm-jpdl/target
+
+# /extensions/dna-sequencer-mp3/
+/extensions/dna-sequencer-mp3/target
+
+# /extensions/dna-sequencer-msoffice/
+/extensions/dna-sequencer-msoffice/target
+
+# /extensions/dna-sequencer-xml/
+/extensions/dna-sequencer-xml/target
+
+# /extensions/dna-sequencer-zip/
+/extensions/dna-sequencer-zip/target
15 years, 3 months
DNA SVN: r712 - in trunk: dna-graph/src/main/java/org/jboss/dna/graph/connector and 11 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-01-16 15:03:39 -0500 (Fri, 16 Jan 2009)
New Revision: 712
Removed:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/ExecutionContextFactory.java
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/ExecutionContext.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/RepositoryContext.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/RepositorySource.java
trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/test/AbstractConnectorTest.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrNamespaceRegistryTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrRepositoryTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrSessionTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrWorkspaceTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/TestUtil.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryLibrary.java
trunk/docs/examples/gettingstarted/repositories/src/main/java/org/jboss/example/dna/repository/RepositoryClient.java
trunk/docs/gettingstarted/src/main/docbook/en-US/content/using_dna_for_sequencing.xml
trunk/docs/gettingstarted/src/main/docbook/en-US/content/using_dna_repositories.xml
trunk/docs/reference/src/main/docbook/en-US/content/environment.xml
trunk/docs/reference/src/main/docbook/en-US/content/repositories.xml
trunk/docs/reference/src/main/docbook/en-US/custom.dtd
trunk/extensions/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/FederatedRepositorySource.java
trunk/extensions/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/FederatedRepositorySourceIntegrationTest.java
trunk/extensions/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/FederatedRepositorySourceTest.java
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/JpaSource.java
Log:
DNA-276 ExecutionContext story should be simplified by eliminating ExecutionContextFactory
Remove the ExecutionContextFactory interface, and renamed the ExecutionContext.create(...) methods to 'with' (to mirror the other methods of creating a new context by changing an aspect).
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/ExecutionContext.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/ExecutionContext.java 2009-01-16 03:26:56 UTC (rev 711)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/ExecutionContext.java 2009-01-16 20:03:39 UTC (rev 712)
@@ -27,6 +27,7 @@
import java.security.AccessController;
import javax.security.auth.Subject;
import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.login.Configuration;
import javax.security.auth.login.LoginContext;
import javax.security.auth.login.LoginException;
import javax.security.auth.spi.LoginModule;
@@ -52,16 +53,16 @@
* it is given a different one).
* <p>
* ExecutionContext instances are {@link Immutable immutable}, so components may hold onto references to them without concern of
- * those contexts changing. However, contexts may be used to create other context with variations in the environment and/or
- * security context. For example, an ExecutionContext could be used to create another context that references the same
- * {@link #getNamespaceRegistry() namespace registry} but which has a different {@link #getSubject() JAAS subject}.
+ * those contexts changing. Contexts may be used to create other contexts that vary the environment and/or security context. For
+ * example, an ExecutionContext could be used to create another context that references the same {@link #getNamespaceRegistry()
+ * namespace registry} but which has a different {@link #getSubject() JAAS subject}.
* </p>
*
* @author Randall Hauch
* @author John Verhaeg
*/
@Immutable
-public class ExecutionContext implements ClassLoaderFactory, Cloneable, ExecutionContextFactory {
+public class ExecutionContext implements ClassLoaderFactory, Cloneable {
private final ClassLoaderFactory classLoaderFactory;
private final LoginContext loginContext;
@@ -73,9 +74,9 @@
private final MimeTypeDetector mimeTypeDetector;
/**
- * Create an instance of an execution context that inherits the {@link AccessControlContext security context} from the
- * {@link AccessController#getContext() current calling context}, with default implementations for all other components
- * (including default namespaces in the {@link #getNamespaceRegistry() namespace registry}.
+ * Create an instance of an execution context that uses the {@link AccessController#getContext() current JAAS calling context}
+ * , with default implementations for all other components (including default namespaces in the
+ * {@link #getNamespaceRegistry() namespace registry}.
*/
public ExecutionContext() {
this(null, null, null, null, null, null, null);
@@ -295,7 +296,8 @@
* the new namespace registry.
*
* @param namespaceRegistry the new namespace registry implementation, or null if the default implementation should be used
- * @return the new execution context
+ * @return the execution context that is identical with this execution context, but which uses the supplied registry; never
+ * null
*/
public ExecutionContext with( NamespaceRegistry namespaceRegistry ) {
// Don't supply the value factories or property factories, since they'll have to be recreated
@@ -305,11 +307,12 @@
}
/**
- * Create a new execution context that mirrors this context but that uses the supplied {@link MimeTypeDetector MIME type
- * detector}.
+ * Create a new execution context that is the same as this context, but which uses the supplied {@link MimeTypeDetector MIME
+ * type detector}.
*
* @param mimeTypeDetector the new MIME type detector implementation, or null if the default implementation should be used
- * @return the new execution context
+ * @return the execution context that is identical with this execution context, but which uses the supplied detector
+ * implementation; never null
*/
public ExecutionContext with( MimeTypeDetector mimeTypeDetector ) {
// Don't supply the value factories or property factories, since they'll have to be recreated
@@ -323,7 +326,8 @@
* factory}.
*
* @param classLoaderFactory the new class loader factory implementation, or null if the default implementation should be used
- * @return the new execution context
+ * @return the execution context that is identical with this execution context, but which uses the supplied class loader
+ * factory implementation; never null
*/
public ExecutionContext with( ClassLoaderFactory classLoaderFactory ) {
// Don't supply the value factories or property factories, since they'll have to be recreated
@@ -333,10 +337,12 @@
}
/**
- * Creates an {@link ExecutionContext} using the supplied {@link AccessControlContext access control context}.
+ * Creates an {@link ExecutionContext} that is the same as this context, but which uses the supplied
+ * {@link AccessControlContext access control context}.
*
- * @param accessControlContext An access control context.
- * @return the execution context; never <code>null</code>.
+ * @param accessControlContext the JAAS access control context that should be used
+ * @return the execution context that is identical with this execution context, but with a different security context; never
+ * null
* @throws IllegalArgumentException if <code>accessControlContext</code> is <code>null</code>.
*/
public ExecutionContext create( AccessControlContext accessControlContext ) {
@@ -344,10 +350,14 @@
}
/**
- * Create an {@link ExecutionContext} for the supplied {@link LoginContext}.
+ * Create an {@link ExecutionContext} that is the same as this context, but which uses the supplied {@link LoginContext}. A
+ * LoginContext has a variety of constructors, including contructors that take combinations of
+ * {@link Configuration#getAppConfigurationEntry(String) application configuration name}, {@link Subject subject},
+ * {@link CallbackHandler callback handlers}, and a {@link Configuration JAAS configuration}.
*
* @param loginContext the JAAS login context
- * @return the execution context
+ * @return the execution context that is identical with this execution context, but with a different security context; never
+ * null
* @throws IllegalArgumentException if the <code>loginContext</code> is null
*/
public ExecutionContext create( LoginContext loginContext ) {
@@ -355,68 +365,79 @@
}
/**
- * @param name the name of the JAAS login context
- * @return the execution context
+ * Create an {@link ExecutionContext} that is the same as this context, but which uses the supplied
+ * {@link Configuration#getAppConfigurationEntry(String) application configuration name}.
+ *
+ * @param name the name of the {@link Configuration#getAppConfigurationEntry(String) JAAS application configuration name}
+ * @return the execution context that is identical with this execution context, but with a different security context; never
+ * null
* @throws IllegalArgumentException if the <code>name</code> is null
* @throws LoginException if there <code>name</code> is invalid (or there is no login context named "other"), or if the
* default callback handler JAAS property was not set or could not be loaded
*/
- public ExecutionContext create( String name ) throws LoginException {
+ public ExecutionContext with( String name ) throws LoginException {
return new ExecutionContext(this, new LoginContext(name));
}
/**
- * @param name the name of the JAAS login context
+ * Create an {@link ExecutionContext} that is the same as this context, but which uses the supplied
+ * {@link Configuration#getAppConfigurationEntry(String) application configuration name} and a {@link Subject JAAS subject}.
+ *
+ * @param name the name of the {@link Configuration#getAppConfigurationEntry(String) JAAS application configuration name}
* @param subject the subject to authenticate
- * @return the execution context
+ * @return the execution context that is identical with this execution context, but with a different security context; never
+ * null
* @throws LoginException if there <code>name</code> is invalid (or there is no login context named "other"), if the default
* callback handler JAAS property was not set or could not be loaded, or if the <code>subject</code> is null or
* unknown
*/
- public ExecutionContext create( String name,
- Subject subject ) throws LoginException {
+ public ExecutionContext with( String name,
+ Subject subject ) throws LoginException {
return new ExecutionContext(this, new LoginContext(name, subject));
}
/**
- * @param name the name of the JAAS login context
- * @param callbackHandler the callback handler that will be used by {@link LoginModule}s to communicate with the user.
- * @return the execution context
+ * Create an {@link ExecutionContext} that is the same as this context, but which uses the supplied
+ * {@link Configuration#getAppConfigurationEntry(String) application configuration name} and a {@link CallbackHandler JAAS
+ * callback handler} (used to handle authentication callbacks).
+ *
+ * @param name the name of the {@link Configuration#getAppConfigurationEntry(String) JAAS application configuration name}
+ * @param callbackHandler the callback handler that will be used by {@link LoginModule}s to communicate with the user to
+ * authenticate
+ * @return the execution context that is identical with this execution context, but with a different security context; never
+ * null
* @throws LoginException if there <code>name</code> is invalid (or there is no login context named "other"), or if the
* <code>callbackHandler</code> is null
*/
- public ExecutionContext create( String name,
- CallbackHandler callbackHandler ) throws LoginException {
+ public ExecutionContext with( String name,
+ CallbackHandler callbackHandler ) throws LoginException {
return new ExecutionContext(this, new LoginContext(name, callbackHandler));
}
/**
- * @param name the name of the JAAS login context
+ * Create an {@link ExecutionContext} that is the same as this context, but which uses the supplied
+ * {@link Configuration#getAppConfigurationEntry(String) application configuration name}, a {@link Subject JAAS subject}, and
+ * a {@link CallbackHandler JAAS callback handler} (used to handle authentication callbacks).
+ *
+ * @param name the name of the {@link Configuration#getAppConfigurationEntry(String) JAAS application configuration name}
* @param subject the subject to authenticate
- * @param callbackHandler the callback handler that will be used by {@link LoginModule}s to communicate with the user.
- * @return the execution context
+ * @param callbackHandler the callback handler that will be used by {@link LoginModule}s to communicate with the user to
+ * authenticate
+ * @return the execution context that is identical with this execution context, but with a different security context; never
+ * null
* @throws LoginException if there <code>name</code> is invalid (or there is no login context named "other"), if the default
* callback handler JAAS property was not set or could not be loaded, if the <code>subject</code> is null or unknown,
* or if the <code>callbackHandler</code> is null
*/
- public ExecutionContext create( String name,
- Subject subject,
- CallbackHandler callbackHandler ) throws LoginException {
+ public ExecutionContext with( String name,
+ Subject subject,
+ CallbackHandler callbackHandler ) throws LoginException {
return new ExecutionContext(this, new LoginContext(name, subject, callbackHandler));
}
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.graph.ExecutionContextFactory#create()
- */
- public ExecutionContext create() {
- return new ExecutionContext(this);
- }
-
- /**
- * {@inheritDoc}
- *
* @see java.lang.Object#clone()
*/
@Override
Deleted: trunk/dna-graph/src/main/java/org/jboss/dna/graph/ExecutionContextFactory.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/ExecutionContextFactory.java 2009-01-16 03:26:56 UTC (rev 711)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/ExecutionContextFactory.java 2009-01-16 20:03:39 UTC (rev 712)
@@ -1,113 +0,0 @@
-/*
- * 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.
- */
-package org.jboss.dna.graph;
-
-import java.security.AccessControlContext;
-import java.security.AccessController;
-import javax.security.auth.Subject;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.login.LoginContext;
-import javax.security.auth.login.LoginException;
-import javax.security.auth.spi.LoginModule;
-
-/**
- * A factory for creating {@link ExecutionContext} instances. Each execution context is affiliated with a JAAS {@link Subject},
- * and thus the factory methods take the same parameters that the JAAS {@link LoginContext} take.
- *
- * @author Randall Hauch
- * @author John Verhaeg
- */
-public interface ExecutionContextFactory {
-
- /**
- * Creates an {@link ExecutionContext} using a snapshot of the {@link AccessControlContext access control context} obtained
- * from the current calling context.
- *
- * @return the execution context; never <code>null</code>.
- * @see AccessController#getContext()
- */
- ExecutionContext create();
-
- /**
- * Creates an {@link ExecutionContext} using the supplied {@link AccessControlContext access control context}.
- *
- * @param accessControlContext An access control context.
- * @return the execution context; never <code>null</code>.
- * @throws IllegalArgumentException if <code>accessControlContext</code> is <code>null</code>.
- */
- ExecutionContext create( AccessControlContext accessControlContext );
-
- /**
- * Create an {@link ExecutionContext} for the supplied {@link LoginContext}.
- *
- * @param loginContext the JAAS login context
- * @return the execution context
- * @throws IllegalArgumentException if the <code>loginContext</code> is null
- */
- ExecutionContext create( LoginContext loginContext );
-
- /**
- * @param name the name of the JAAS login context
- * @return the execution context
- * @throws IllegalArgumentException if the <code>name</code> is null
- * @throws LoginException if there <code>name</code> is invalid (or there is no login context named "other"), or if the
- * default callback handler JAAS property was not set or could not be loaded
- */
- ExecutionContext create( String name ) throws LoginException;
-
- /**
- * @param name the name of the JAAS login context
- * @param subject the subject to authenticate
- * @return the execution context
- * @throws LoginException if there <code>name</code> is invalid (or there is no login context named "other"), if the default
- * callback handler JAAS property was not set or could not be loaded, or if the <code>subject</code> is null or
- * unknown
- */
- ExecutionContext create( String name,
- Subject subject ) throws LoginException;
-
- /**
- * @param name the name of the JAAS login context
- * @param callbackHandler the callback handler that will be used by {@link LoginModule}s to communicate with the user.
- * @return the execution context
- * @throws LoginException if there <code>name</code> is invalid (or there is no login context named "other"), or if the
- * <code>callbackHandler</code> is null
- */
- ExecutionContext create( String name,
- CallbackHandler callbackHandler ) throws LoginException;
-
- /**
- * @param name the name of the JAAS login context
- * @param subject the subject to authenticate
- * @param callbackHandler the callback handler that will be used by {@link LoginModule}s to communicate with the user.
- * @return the execution context
- * @throws LoginException if there <code>name</code> is invalid (or there is no login context named "other"), if the default
- * callback handler JAAS property was not set or could not be loaded, if the <code>subject</code> is null or unknown,
- * or if the <code>callbackHandler</code> is null
- */
- ExecutionContext create( String name,
- Subject subject,
- CallbackHandler callbackHandler ) throws LoginException;
-
-}
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/RepositoryContext.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/RepositoryContext.java 2009-01-16 03:26:56 UTC (rev 711)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/RepositoryContext.java 2009-01-16 20:03:39 UTC (rev 712)
@@ -23,7 +23,7 @@
*/
package org.jboss.dna.graph.connector;
-import org.jboss.dna.graph.ExecutionContextFactory;
+import org.jboss.dna.graph.ExecutionContext;
/**
* The context for a repository. This interface need not be implemented by a {@link RepositorySource}, as it is normally provided
@@ -34,11 +34,11 @@
public interface RepositoryContext {
/**
- * Get the factory that can be used to create execution contexts.
+ * Get the execution context, which can be used to create other contexts with specific JAAS security contexts.
*
- * @return the execution context factory
+ * @return the execution context; never null
*/
- ExecutionContextFactory getExecutionContextFactory();
+ ExecutionContext getExecutionContext();
/**
* Get the factory for {@link RepositoryConnection connections} to other sources.
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/RepositorySource.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/RepositorySource.java 2009-01-16 03:26:56 UTC (rev 711)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/RepositorySource.java 2009-01-16 20:03:39 UTC (rev 712)
@@ -128,7 +128,7 @@
/**
* Initialize this source to use the supplied {@link RepositoryContext}, from which this source can obtain
* {@link RepositoryContext#getRepositoryConnectionFactory() connections} to other {@link RepositorySource sources} as well as
- * {@link RepositoryContext#getExecutionContextFactory() execution contexts}.
+ * {@link RepositoryContext#getExecutionContext() execution contexts}.
*
* @param context
* @throws RepositorySourceException
Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/test/AbstractConnectorTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/test/AbstractConnectorTest.java 2009-01-16 03:26:56 UTC (rev 711)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/test/AbstractConnectorTest.java 2009-01-16 20:03:39 UTC (rev 712)
@@ -37,7 +37,6 @@
import java.util.concurrent.TimeUnit;
import org.jboss.dna.common.statistic.Stopwatch;
import org.jboss.dna.graph.ExecutionContext;
-import org.jboss.dna.graph.ExecutionContextFactory;
import org.jboss.dna.graph.Graph;
import org.jboss.dna.graph.Location;
import org.jboss.dna.graph.Node;
@@ -71,7 +70,6 @@
*/
public abstract class AbstractConnectorTest {
- protected static ExecutionContextFactory contextFactory;
protected static ExecutionContext context;
protected static RepositorySource source;
protected static Graph graph;
@@ -85,8 +83,7 @@
// Set up the connection factory to other sources ...
// Set up the execution context ...
- contextFactory = new ExecutionContext();
- context = setUpExecutionContext(contextFactory);
+ context = setUpExecutionContext(new ExecutionContext());
// Set up the source ...
source = setUpSource();
@@ -108,8 +105,8 @@
// Initialize the source with the rest of the environment ...
source.initialize(new RepositoryContext() {
- public ExecutionContextFactory getExecutionContextFactory() {
- return contextFactory;
+ public ExecutionContext getExecutionContext() {
+ return context;
}
@SuppressWarnings( "synthetic-access" )
@@ -179,11 +176,11 @@
/**
* Set up the {@link ExecutionContext} for each unit test.
*
- * @param contextFactory the context factory that may be used; never null
+ * @param context the context that may be used directly, or used to create another context; never null
* @return the execution context; may not be null
*/
- protected ExecutionContext setUpExecutionContext( ExecutionContextFactory contextFactory ) {
- return contextFactory.create();
+ protected ExecutionContext setUpExecutionContext( ExecutionContext context ) {
+ return context;
}
/**
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java 2009-01-16 03:26:56 UTC (rev 711)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java 2009-01-16 20:03:39 UTC (rev 712)
@@ -40,7 +40,6 @@
import net.jcip.annotations.ThreadSafe;
import org.jboss.dna.common.util.CheckArg;
import org.jboss.dna.graph.ExecutionContext;
-import org.jboss.dna.graph.ExecutionContextFactory;
import org.jboss.dna.graph.Graph;
import org.jboss.dna.graph.connector.RepositoryConnectionFactory;
import com.google.common.base.ReferenceType;
@@ -50,9 +49,9 @@
* Creates JCR {@link Session sessions} to an underlying repository (which may be a federated repository).
* <p>
* This JCR repository must be configured with the ability to connect to a repository via a supplied
- * {@link RepositoryConnectionFactory repository connection factory} and repository source name. An
- * {@link ExecutionContextFactory execution context factory} must also be supplied to enable working with the underlying DNA graph
- * implementation to which this JCR implementation delegates.
+ * {@link RepositoryConnectionFactory repository connection factory} and repository source name. An {@link ExecutionContext
+ * execution context} must also be supplied to enable working with the underlying DNA graph implementation to which this JCR
+ * implementation delegates.
* </p>
* <p>
* If {@link Credentials credentials} are used to login, implementations <em>must</em> also implement one of the following
@@ -74,21 +73,21 @@
public class JcrRepository implements Repository {
private final Map<String, String> descriptors;
- private final ExecutionContextFactory executionContextFactory;
+ private final ExecutionContext executionContext;
private final RepositoryConnectionFactory connectionFactory;
/**
* Creates a JCR repository that uses the supplied {@link RepositoryConnectionFactory repository connection factory} to
* establish {@link Session sessions} to the underlying repository source upon {@link #login() login}.
*
- * @param executionContextFactory An execution context factory.
+ * @param executionContext An execution context.
* @param connectionFactory A repository connection factory.
* @throws IllegalArgumentException If <code>executionContextFactory</code> or <code>connectionFactory</code> is
* <code>null</code>.
*/
- public JcrRepository( ExecutionContextFactory executionContextFactory,
+ public JcrRepository( ExecutionContext executionContext,
RepositoryConnectionFactory connectionFactory ) {
- this(null, executionContextFactory, connectionFactory);
+ this(null, executionContext, connectionFactory);
}
/**
@@ -96,17 +95,17 @@
* establish {@link Session sessions} to the underlying repository source upon {@link #login() login}.
*
* @param descriptors The {@link #getDescriptorKeys() descriptors} for this repository; may be <code>null</code>.
- * @param executionContextFactory An execution context factory.
+ * @param executionContext An execution context.
* @param connectionFactory A repository connection factory.
* @throws IllegalArgumentException If <code>executionContextFactory</code> or <code>connectionFactory</code> is
* <code>null</code>.
*/
public JcrRepository( Map<String, String> descriptors,
- ExecutionContextFactory executionContextFactory,
+ ExecutionContext executionContext,
RepositoryConnectionFactory connectionFactory ) {
- CheckArg.isNotNull(executionContextFactory, "executionContextFactory");
+ CheckArg.isNotNull(executionContext, "executionContext");
CheckArg.isNotNull(connectionFactory, "connectionFactory");
- this.executionContextFactory = executionContextFactory;
+ this.executionContext = executionContext;
this.connectionFactory = connectionFactory;
Map<String, String> modifiableDescriptors;
if (descriptors == null) {
@@ -209,7 +208,7 @@
// Ensure credentials are either null or provide a JAAS method
ExecutionContext execContext;
if (credentials == null) {
- execContext = executionContextFactory.create();
+ execContext = executionContext;
} else {
try {
// Check if credentials provide a login context
@@ -222,7 +221,7 @@
if (loginContext == null) {
throw new IllegalArgumentException(JcrI18n.credentialsMustReturnLoginContext.text(credentials.getClass()));
}
- execContext = executionContextFactory.create(loginContext);
+ execContext = executionContext.create(loginContext);
} catch (NoSuchMethodException error) {
// Check if credentials provide an access control context
try {
@@ -236,7 +235,7 @@
throw new IllegalArgumentException(
JcrI18n.credentialsMustReturnAccessControlContext.text(credentials.getClass()));
}
- execContext = executionContextFactory.create(accessControlContext);
+ execContext = executionContext.create(accessControlContext);
} catch (NoSuchMethodException error2) {
throw new IllegalArgumentException(JcrI18n.credentialsMustProvideJaasMethod.text(credentials.getClass()),
error2);
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrNamespaceRegistryTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrNamespaceRegistryTest.java 2009-01-16 03:26:56 UTC (rev 711)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrNamespaceRegistryTest.java 2009-01-16 20:03:39 UTC (rev 712)
@@ -30,7 +30,6 @@
import javax.jcr.NamespaceException;
import javax.jcr.UnsupportedRepositoryOperationException;
import org.jboss.dna.graph.ExecutionContext;
-import org.jboss.dna.graph.ExecutionContextFactory;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -45,8 +44,7 @@
@BeforeClass
public static void beforeClass() throws Exception {
- ExecutionContextFactory factory = TestUtil.getExecutionContextFactory();
- executionContext = factory.create();
+ executionContext = TestUtil.getExecutionContext();
}
@Before
@@ -105,7 +103,7 @@
assertThat(registry.getPrefix("http://www.jcp.org/jcr/1.0"), is("jcr"));
assertThat(registry.getPrefix("http://www.jcp.org/jcr/mix/1.0"), is("mix"));
assertThat(registry.getPrefix("http://www.jcp.org/jcr/nt/1.0"), is("nt"));
-// assertThat(registry.getPrefix("http://www.w3.org/XML/1998/namespace"), is("xml"));
+ // assertThat(registry.getPrefix("http://www.w3.org/XML/1998/namespace"), is("xml"));
}
@Test
@@ -115,7 +113,7 @@
assertThat(registry.getURI("jcr"), is("http://www.jcp.org/jcr/1.0"));
assertThat(registry.getURI("mix"), is("http://www.jcp.org/jcr/mix/1.0"));
assertThat(registry.getURI("nt"), is("http://www.jcp.org/jcr/nt/1.0"));
-// assertThat(registry.getURI("xml"), is("http://www.w3.org/XML/1998/namespace"));
+ // assertThat(registry.getURI("xml"), is("http://www.w3.org/XML/1998/namespace"));
}
@Test( expected = NamespaceException.class )
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrRepositoryTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrRepositoryTest.java 2009-01-16 03:26:56 UTC (rev 711)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrRepositoryTest.java 2009-01-16 20:03:39 UTC (rev 712)
@@ -38,7 +38,6 @@
import javax.security.auth.login.LoginContext;
import javax.security.auth.login.LoginException;
import org.jboss.dna.graph.ExecutionContext;
-import org.jboss.dna.graph.ExecutionContextFactory;
import org.jboss.dna.graph.connector.RepositoryConnection;
import org.jboss.dna.graph.connector.RepositoryConnectionFactory;
import org.junit.Before;
@@ -56,8 +55,6 @@
@Mock
private Map<String, String> descriptors;
@Mock
- private ExecutionContextFactory executionContextFactory;
- @Mock
private RepositoryConnectionFactory connectionFactory;
@Mock
private ExecutionContext executionContext;
@@ -79,15 +76,14 @@
@Before
public void before() throws Exception {
MockitoAnnotations.initMocks(this);
- stub(executionContextFactory.create()).toReturn(executionContext);
- stub(executionContextFactory.create(accessControlContext)).toReturn(executionContext);
+ stub(executionContext.create(accessControlContext)).toReturn(executionContext);
stub(connectionFactory.createConnection(JcrI18n.defaultWorkspaceName.text())).toReturn(connection);
- repository = new JcrRepository(descriptors, executionContextFactory, connectionFactory);
+ repository = new JcrRepository(descriptors, executionContext, connectionFactory);
}
@Test
public void shouldAllowNoDescriptors() {
- new JcrRepository(descriptors, executionContextFactory, connectionFactory);
+ new JcrRepository(descriptors, executionContext, connectionFactory);
}
@Test( expected = IllegalArgumentException.class )
@@ -97,7 +93,7 @@
@Test( expected = IllegalArgumentException.class )
public void shouldNotAllowNoConnectionFactories() throws Exception {
- new JcrRepository(executionContextFactory, null);
+ new JcrRepository(executionContext, null);
}
@Test( expected = IllegalArgumentException.class )
@@ -122,7 +118,7 @@
@Test
public void shouldProvideBuiltInDescriptorsWhenNotSuppliedDescriptors() {
- Repository repository = new JcrRepository(descriptors, executionContextFactory, connectionFactory);
+ Repository repository = new JcrRepository(descriptors, executionContext, connectionFactory);
testDescriptorKeys(repository);
testDescriptorValues(repository);
}
@@ -131,7 +127,7 @@
public void shouldProvideUserSuppliedDescriptors() {
Map<String, String> descriptors = new HashMap<String, String>();
descriptors.put("property", "value");
- Repository repository = new JcrRepository(descriptors, executionContextFactory, connectionFactory);
+ Repository repository = new JcrRepository(descriptors, executionContext, connectionFactory);
testDescriptorKeys(repository);
testDescriptorValues(repository);
assertThat(repository.getDescriptor("property"), is("value"));
@@ -152,7 +148,7 @@
@Test
public void shouldAllowLoginWithProperCredentials() throws Exception {
repository.login(credentials);
- stub(executionContextFactory.create(loginContext)).toReturn(executionContext);
+ stub(executionContext.create(loginContext)).toReturn(executionContext);
repository.login(new Credentials() {
private static final long serialVersionUID = 1L;
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrSessionTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrSessionTest.java 2009-01-16 03:26:56 UTC (rev 711)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrSessionTest.java 2009-01-16 20:03:39 UTC (rev 712)
@@ -47,7 +47,6 @@
import javax.security.auth.Subject;
import javax.security.auth.login.LoginContext;
import org.jboss.dna.graph.ExecutionContext;
-import org.jboss.dna.graph.ExecutionContextFactory;
import org.jboss.dna.graph.Graph;
import org.jboss.dna.graph.connector.RepositoryConnection;
import org.jboss.dna.graph.connector.RepositoryConnectionFactory;
@@ -77,13 +76,12 @@
@BeforeClass
public static void beforeClass() throws Exception {
- ExecutionContextFactory factory = TestUtil.getExecutionContextFactory();
- executionContext = factory.create();
+ executionContext = TestUtil.getExecutionContext();
simpleRepository = SimpleRepository.get(WORKSPACE_NAME);
simpleRepository.setProperty(executionContext, "/a/b", "booleanProperty", true);
simpleRepository.setProperty(executionContext, "/a/b/c", "stringProperty", "value");
connectionFactory = TestUtil.createJackRabbitConnectionFactory(simpleRepository, executionContext);
- repository = new JcrRepository(factory, connectionFactory);
+ repository = new JcrRepository(executionContext, connectionFactory);
}
@AfterClass
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrWorkspaceTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrWorkspaceTest.java 2009-01-16 03:26:56 UTC (rev 711)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrWorkspaceTest.java 2009-01-16 20:03:39 UTC (rev 712)
@@ -28,7 +28,6 @@
import static org.junit.Assert.assertThat;
import javax.jcr.Session;
import javax.jcr.Workspace;
-import org.jboss.dna.graph.ExecutionContextFactory;
import org.jboss.dna.graph.connector.SimpleRepository;
import org.junit.After;
import org.junit.AfterClass;
@@ -44,12 +43,11 @@
@BeforeClass
public static void beforeClass() throws Exception {
- ExecutionContextFactory factory = TestUtil.getExecutionContextFactory();
- JcrSessionTest.executionContext = factory.create();
+ JcrSessionTest.executionContext = TestUtil.getExecutionContext();
JcrSessionTest.simpleRepository = SimpleRepository.get(JcrSessionTest.WORKSPACE_NAME);
JcrSessionTest.connectionFactory = TestUtil.createJackRabbitConnectionFactory(JcrSessionTest.simpleRepository,
JcrSessionTest.executionContext);
- JcrSessionTest.repository = new JcrRepository(factory, JcrSessionTest.connectionFactory);
+ JcrSessionTest.repository = new JcrRepository(JcrSessionTest.executionContext, JcrSessionTest.connectionFactory);
}
@AfterClass
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/TestUtil.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/TestUtil.java 2009-01-16 03:26:56 UTC (rev 711)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/TestUtil.java 2009-01-16 20:03:39 UTC (rev 712)
@@ -23,13 +23,9 @@
*/
package org.jboss.dna.jcr;
-import java.security.AccessControlContext;
-import javax.security.auth.Subject;
-import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.login.LoginContext;
import net.jcip.annotations.NotThreadSafe;
import org.jboss.dna.graph.ExecutionContext;
-import org.jboss.dna.graph.ExecutionContextFactory;
import org.jboss.dna.graph.connector.RepositoryConnection;
import org.jboss.dna.graph.connector.RepositoryConnectionFactory;
import org.jboss.dna.graph.connector.SimpleRepository;
@@ -503,7 +499,7 @@
};
}
- public static ExecutionContextFactory getExecutionContextFactory() {
+ public static ExecutionContext getExecutionContext() {
final ExecutionContext context = new ExecutionContext().create(Mockito.mock(LoginContext.class));
NamespaceRegistry registry = context.getNamespaceRegistry();
registry.register("dna", "http://www.jboss.org/dna/1.0");
@@ -515,40 +511,7 @@
registry.register("rep", "internal");
registry.register("sv", "http://www.jcp.org/jcr/sv/1.0");
registry.register("xs", "http://www.w3.org/2001/XMLSchema");
- return new ExecutionContextFactory() {
-
- public ExecutionContext create() {
- return context;
- }
-
- public ExecutionContext create( AccessControlContext accessControlContext ) {
- return context;
- }
-
- public ExecutionContext create( LoginContext loginContext ) {
- return context;
- }
-
- public ExecutionContext create( String name ) {
- return context;
- }
-
- public ExecutionContext create( String name,
- CallbackHandler callbackHandler ) {
- return context;
- }
-
- public ExecutionContext create( String name,
- Subject subject ) {
- return context;
- }
-
- public ExecutionContext create( String name,
- Subject subject,
- CallbackHandler callbackHandler ) {
- return context;
- }
- };
+ return context;
}
private static void createChildDefinition( SimpleRepository repository,
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryLibrary.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryLibrary.java 2009-01-16 03:26:56 UTC (rev 711)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryLibrary.java 2009-01-16 20:03:39 UTC (rev 712)
@@ -36,7 +36,6 @@
import net.jcip.annotations.ThreadSafe;
import org.jboss.dna.common.util.CheckArg;
import org.jboss.dna.graph.ExecutionContext;
-import org.jboss.dna.graph.ExecutionContextFactory;
import org.jboss.dna.graph.connector.RepositoryConnection;
import org.jboss.dna.graph.connector.RepositoryConnectionFactory;
import org.jboss.dna.graph.connector.RepositoryConnectionPool;
@@ -107,7 +106,7 @@
private final ReadWriteLock sourcesLock = new ReentrantReadWriteLock();
private final CopyOnWriteArrayList<RepositoryConnectionPool> pools = new CopyOnWriteArrayList<RepositoryConnectionPool>();
private RepositoryConnectionFactory delegate;
- private final ExecutionContextFactory executionContextFactory;
+ protected final ExecutionContext executionContext;
private final RepositoryContext repositoryContext;
/**
@@ -130,34 +129,36 @@
/**
* Create a new manager instance.
*
- * @param executionContextFactory the execution context factory, used by sources to create {@link ExecutionContext} instances
+ * @param executionContext the execution context, which can be used used by sources to create other {@link ExecutionContext}
+ * instances with different JAAS security contexts
* @throws IllegalArgumentException if the <code>executionContextFactory</code> reference is null
*/
- public RepositoryLibrary( ExecutionContextFactory executionContextFactory ) {
- this(executionContextFactory, null);
+ public RepositoryLibrary( ExecutionContext executionContext ) {
+ this(executionContext, null);
}
/**
* Create a new manager instance.
*
- * @param executionContextFactory the execution context factory, used by sources to create {@link ExecutionContext} instances
+ * @param executionContext the execution context, which can be used used by sources to create other {@link ExecutionContext}
+ * instances with different JAAS security contexts
* @param delegate the connection factory to which this instance should delegate in the event that a source is not found in
* this manager; may be null if there is no delegate
* @throws IllegalArgumentException if the <code>executionContextFactory</code> reference is null
*/
- public RepositoryLibrary( ExecutionContextFactory executionContextFactory,
+ public RepositoryLibrary( ExecutionContext executionContext,
RepositoryConnectionFactory delegate ) {
- CheckArg.isNotNull(executionContextFactory, "executionContextFactory");
+ CheckArg.isNotNull(executionContext, "executionContext");
this.delegate = delegate;
- this.executionContextFactory = executionContextFactory;
+ this.executionContext = executionContext;
this.repositoryContext = new RepositoryContext() {
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.graph.connector.RepositoryContext#getExecutionContextFactory()
+ * @see org.jboss.dna.graph.connector.RepositoryContext#getExecutionContext()
*/
- public ExecutionContextFactory getExecutionContextFactory() {
- return RepositoryLibrary.this.getExecutionContextFactory();
+ public ExecutionContext getExecutionContext() {
+ return RepositoryLibrary.this.executionContext;
}
/**
@@ -175,8 +176,8 @@
/**
* @return executionContextFactory
*/
- public ExecutionContextFactory getExecutionContextFactory() {
- return executionContextFactory;
+ public ExecutionContext getExecutionContext() {
+ return executionContext;
}
/**
Modified: trunk/docs/examples/gettingstarted/repositories/src/main/java/org/jboss/example/dna/repository/RepositoryClient.java
===================================================================
--- trunk/docs/examples/gettingstarted/repositories/src/main/java/org/jboss/example/dna/repository/RepositoryClient.java 2009-01-16 03:26:56 UTC (rev 711)
+++ trunk/docs/examples/gettingstarted/repositories/src/main/java/org/jboss/example/dna/repository/RepositoryClient.java 2009-01-16 20:03:39 UTC (rev 712)
@@ -44,7 +44,6 @@
import org.jboss.dna.common.text.NoOpEncoder;
import org.jboss.dna.common.util.CheckArg;
import org.jboss.dna.graph.ExecutionContext;
-import org.jboss.dna.graph.ExecutionContextFactory;
import org.jboss.dna.graph.Graph;
import org.jboss.dna.graph.Location;
import org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource;
@@ -86,7 +85,6 @@
}
private RepositoryLibrary sources;
- private ExecutionContextFactory contextFactory;
private RepositoryService repositoryService;
private Api api = Api.JCR;
private String jaasContextName;
@@ -130,15 +128,12 @@
public void startRepositories() throws IOException, SAXException, NamingException {
if (repositoryService != null) return; // already started
- // Create the factory for execution contexts.
- contextFactory = new ExecutionContext();
-
// Create the execution context that we'll use for the services. If we'd want to use JAAS, we'd create the context
// by supplying LoginContext, AccessControlContext, or even Subject with CallbackHandlers. But no JAAS in this example.
- context = contextFactory.create();
+ context = new ExecutionContext();
// Create the library for the RepositorySource instances ...
- sources = new RepositoryLibrary(contextFactory);
+ sources = new RepositoryLibrary(context);
// Load into the source manager the repository source for the configuration repository ...
InMemoryRepositorySource configSource = new InMemoryRepositorySource();
@@ -243,7 +238,7 @@
LoginContext loginContext = getLoginContext(); // will ask user to authenticate if needed
switch (api) {
case JCR: {
- JcrRepository jcrRepository = new JcrRepository(contextFactory, sources);
+ JcrRepository jcrRepository = new JcrRepository(context, sources);
Session session = null;
if (loginContext != null) {
Credentials credentials = new JaasCredentials(loginContext);
@@ -304,7 +299,7 @@
case DNA: {
try {
// Use the DNA Graph API to read the properties and children of the node ...
- ExecutionContext context = loginContext != null ? contextFactory.create(loginContext) : contextFactory.create();
+ ExecutionContext context = loginContext != null ? this.context.create(loginContext) : this.context;
Graph graph = Graph.create(sourceName, sources, context);
org.jboss.dna.graph.Node node = graph.getNodeAt(pathToNode);
Modified: trunk/docs/gettingstarted/src/main/docbook/en-US/content/using_dna_for_sequencing.xml
===================================================================
--- trunk/docs/gettingstarted/src/main/docbook/en-US/content/using_dna_for_sequencing.xml 2009-01-16 03:26:56 UTC (rev 711)
+++ trunk/docs/gettingstarted/src/main/docbook/en-US/content/using_dna_for_sequencing.xml 2009-01-16 20:03:39 UTC (rev 712)
@@ -63,7 +63,7 @@
</listitem>
</itemizedlist>
</para>
- <para>As mentioned above, the <code>ExecutionContext</code> provides access to a <code>SessionFactory</code> that is used
+ <para>As mentioned above, the <code>JcrExecutionContext</code> provides access to a <code>SessionFactory</code> that is used
by JBoss DNA to establish sessions to your JCR repositories. Two implementations are available:
<itemizedlist>
<listitem>
@@ -440,7 +440,7 @@
Credentials credentials = new SimpleCredentials(this.username, this.password);
sessionFactory.registerCredentials(this.repositoryName + "/" + this.workspaceName, credentials);
}
- this.executionContext = new SimpleExecutionContext(sessionFactory);
+ this.executionContext = new JcrExecutionContext(sessionFactory, repositoryWorkspaceName);
// Create the sequencing service, passing in the execution context ...
this.sequencingService = new SequencingService();
Modified: trunk/docs/gettingstarted/src/main/docbook/en-US/content/using_dna_repositories.xml
===================================================================
--- trunk/docs/gettingstarted/src/main/docbook/en-US/content/using_dna_repositories.xml 2009-01-16 03:26:56 UTC (rev 711)
+++ trunk/docs/gettingstarted/src/main/docbook/en-US/content/using_dna_repositories.xml 2009-01-16 20:03:39 UTC (rev 712)
@@ -81,13 +81,13 @@
<para>To set up the repository service, we need to first set up a few other objects:
<itemizedlist>
<listitem>
- <para>A <emphasis>factory for execution contexts</emphasis>. Execution contexts define the context (or environment)
+ <para>An <emphasis>execution contexts</emphasis>. Execution contexts define the context (or environment)
in which the service runs and in which operations against repositories are performed. <code>ExecutionContext</code>
instances can be created using JAAS application contexts, meaning that they contain the information about the subject
that the software represents. Execution contexts also provide access to the all of the factories and utilities
used throughout the services and components, and it is through this mechanism that you can inject your own behavior.
- For example, if your application already had a notion of namespaces, you could override the execution context's
- <code>NamespaceRegistry</code> to use the namespaces defined in your application.</para>
+ For example, if your application already had a notion of namespaces, you could create an execution context that
+ uses your own <code>NamespaceRegistry</code> implementation (which would use the namespaces defined in your application).</para>
</listitem>
<listitem>
<para>A <emphasis>repository library</emphasis> that manages the list of <code>RepositorySource</code> instances.
@@ -112,7 +112,7 @@
// Create the execution context that we'll use for the services. If we'd want to use JAAS, we'd
// create the context by supplying LoginContext, AccessControlContext, or even Subject with
// CallbackHandlers. But this example doesn't use JAAS in this example.
- ExecutionContext context = contextFactory.create();
+ ExecutionContext context = new ExecutionContext();
// Create the library for the RepositorySource instances ...
RepositoryLibrary sources = new RepositoryLibrary(context);
Modified: trunk/docs/reference/src/main/docbook/en-US/content/environment.xml
===================================================================
--- trunk/docs/reference/src/main/docbook/en-US/content/environment.xml 2009-01-16 03:26:56 UTC (rev 711)
+++ trunk/docs/reference/src/main/docbook/en-US/content/environment.xml 2009-01-16 20:03:39 UTC (rev 712)
@@ -217,19 +217,18 @@
</para>
<programlisting>
&ExecutionContext; context1 = new &ExecutionContext;();
-&ExecutionContext; context2 = factory.create(); // same as 'context1'
// Create a context for a user, authenticating using JAAS ...
&LoginContext; loginContext = new LoginContext("username",callbackHandler);
-&ExecutionContext; context3 = context1.create(new LoginContext("username"));
+&ExecutionContext; context2 = context1.with(new LoginContext("username"));
// Create a context for the same user, authenticating using JAAS, and using a different callback handler ...
&CallbackHandler; callbackHandler = ...
&LoginContext; loginContext = new LoginContext("username",callbackHandler);
-&ExecutionContext; context4 = context1.create(loginContext);
+&ExecutionContext; context3 = context1.with(loginContext);
</programlisting>
<para>
- These contexts (or the context factory) can then be passed to the various components as needed.
+ These contexts can then be passed to the various components as needed.
</para>
</sect1>
<sect1>
Modified: trunk/docs/reference/src/main/docbook/en-US/content/repositories.xml
===================================================================
--- trunk/docs/reference/src/main/docbook/en-US/content/repositories.xml 2009-01-16 03:26:56 UTC (rev 711)
+++ trunk/docs/reference/src/main/docbook/en-US/content/repositories.xml 2009-01-16 20:03:39 UTC (rev 712)
@@ -191,7 +191,7 @@
<itemizedlist>
<listitem>
<para>
- A &ExecutionContextFactory; instance, as discussed <link linkend="execution-context">earlier</link>.
+ A &ExecutionContext; instance, as discussed <link linkend="execution-context">earlier</link>.
</para>
</listitem>
<listitem>
@@ -221,8 +221,8 @@
<code>org.jboss.example.dna.repository.RepositoryClient</code> class.
</para>
<programlisting>
- // Create the top-level execution context (which is also a factory) ...
- &ExecutionContext; context = contextFactory.create();
+ // Create the top-level execution context with all standard components ...
+ &ExecutionContext; context = new ExecutionContext();
// Create the library for the RepositorySource instances ...
&RepositoryLibrary; sources = new &RepositoryLibrary;(context);
Modified: trunk/docs/reference/src/main/docbook/en-US/custom.dtd
===================================================================
--- trunk/docs/reference/src/main/docbook/en-US/custom.dtd 2009-01-16 03:26:56 UTC (rev 711)
+++ trunk/docs/reference/src/main/docbook/en-US/custom.dtd 2009-01-16 20:03:39 UTC (rev 712)
@@ -61,7 +61,6 @@
<!ENTITY Results "<ulink url='&API;graph/Results.html'><interface>Results</interface></ulink>">
<!ENTITY Location "<ulink url='&API;graph/Location.html'><classname>Location</classname></ulink>">
<!ENTITY ExecutionContext "<ulink url='&API;graph/ExecutionContext.html'><classname>ExecutionContext</classname></ulink>">
-<!ENTITY ExecutionContextFactory "<ulink url='&API;graph/ExecutionContextFactory.html'><interface>ExecutionContextFactory</interface></ulink>">
<!ENTITY Name "<ulink url='&API;graph/property/Name.html'><interface>Name</interface></ulink>">
<!ENTITY Path "<ulink url='&API;graph/property/Path.html'><interface>Path</interface></ulink>">
<!ENTITY PathSegment "<ulink url='&API;graph/property/Path.Segment.html'><interface>Path.Segment</interface></ulink>">
Modified: trunk/extensions/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/FederatedRepositorySource.java
===================================================================
--- trunk/extensions/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/FederatedRepositorySource.java 2009-01-16 03:26:56 UTC (rev 711)
+++ trunk/extensions/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/FederatedRepositorySource.java 2009-01-16 20:03:39 UTC (rev 712)
@@ -47,7 +47,6 @@
import org.jboss.dna.common.i18n.I18n;
import org.jboss.dna.common.util.CheckArg;
import org.jboss.dna.graph.ExecutionContext;
-import org.jboss.dna.graph.ExecutionContextFactory;
import org.jboss.dna.graph.Graph;
import org.jboss.dna.graph.Location;
import org.jboss.dna.graph.Node;
@@ -474,14 +473,14 @@
}
protected ExecutionContext getExecutionContext() {
- ExecutionContextFactory factory = getRepositoryContext().getExecutionContextFactory();
+ ExecutionContext factory = getRepositoryContext().getExecutionContext();
CallbackHandler handler = createCallbackHandler();
try {
String securityDomain = getSecurityDomain();
if (securityDomain != null || getUsername() != null) {
- return factory.create(securityDomain, handler);
+ return factory.with(securityDomain, handler);
}
- return factory.create();
+ return factory;
} catch (LoginException e) {
I18n msg = FederationI18n.unableToCreateExecutionContext;
throw new RepositorySourceException(getName(), msg.text(this.sourceName, securityDomain), e);
Modified: trunk/extensions/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/FederatedRepositorySourceIntegrationTest.java
===================================================================
--- trunk/extensions/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/FederatedRepositorySourceIntegrationTest.java 2009-01-16 03:26:56 UTC (rev 711)
+++ trunk/extensions/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/FederatedRepositorySourceIntegrationTest.java 2009-01-16 20:03:39 UTC (rev 712)
@@ -40,7 +40,6 @@
import javax.security.auth.callback.CallbackHandler;
import org.jboss.dna.graph.DnaLexicon;
import org.jboss.dna.graph.ExecutionContext;
-import org.jboss.dna.graph.ExecutionContextFactory;
import org.jboss.dna.graph.Location;
import org.jboss.dna.graph.connector.RepositoryConnection;
import org.jboss.dna.graph.connector.RepositoryConnectionFactory;
@@ -93,7 +92,7 @@
@Mock
private RepositoryConnectionFactory connectionFactory;
@Mock
- private ExecutionContextFactory executionContextFactory;
+ private ExecutionContext executionContextFactory;
@Mock
private RepositoryContext repositoryContext;
@@ -110,8 +109,8 @@
securityDomain = "security domain";
stub(jndiContext.lookup(executionContextFactoryJndiName)).toReturn(executionContextFactory);
stub(jndiContext.lookup(repositoryConnectionFactoryJndiName)).toReturn(connectionFactory);
- stub(executionContextFactory.create(eq(securityDomain), anyCallbackHandler())).toReturn(context);
- stub(repositoryContext.getExecutionContextFactory()).toReturn(executionContextFactory);
+ stub(executionContextFactory.with(eq(securityDomain), anyCallbackHandler())).toReturn(context);
+ stub(repositoryContext.getExecutionContext()).toReturn(executionContextFactory);
stub(repositoryContext.getRepositoryConnectionFactory()).toReturn(connectionFactory);
// Set up the federated repository source ...
Modified: trunk/extensions/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/FederatedRepositorySourceTest.java
===================================================================
--- trunk/extensions/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/FederatedRepositorySourceTest.java 2009-01-16 03:26:56 UTC (rev 711)
+++ trunk/extensions/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/FederatedRepositorySourceTest.java 2009-01-16 20:03:39 UTC (rev 712)
@@ -44,7 +44,6 @@
import javax.security.auth.login.LoginException;
import org.jboss.dna.graph.DnaLexicon;
import org.jboss.dna.graph.ExecutionContext;
-import org.jboss.dna.graph.ExecutionContextFactory;
import org.jboss.dna.graph.connector.RepositoryConnection;
import org.jboss.dna.graph.connector.RepositoryConnectionFactory;
import org.jboss.dna.graph.connector.RepositoryContext;
@@ -79,7 +78,7 @@
@Mock
private RepositoryConnectionFactory connectionFactory;
@Mock
- private ExecutionContextFactory executionContextFactory;
+ private ExecutionContext executionContextFactory;
@Mock
private RepositoryContext repositoryContext;
@@ -124,10 +123,10 @@
configRepositorySource.setRepositoryName(configRepository.getRepositoryName());
configRepositorySource.setName(configurationSourceName);
configRepositoryConnection = configRepositorySource.getConnection();
- stub(repositoryContext.getExecutionContextFactory()).toReturn(executionContextFactory);
+ stub(repositoryContext.getExecutionContext()).toReturn(executionContextFactory);
stub(repositoryContext.getRepositoryConnectionFactory()).toReturn(connectionFactory);
stub(connectionFactory.createConnection(configurationSourceName)).toReturn(configRepositoryConnection);
- stub(executionContextFactory.create(eq(securityDomain), anyCallbackHandler())).toReturn(context);
+ stub(executionContextFactory.with(eq(securityDomain), anyCallbackHandler())).toReturn(context);
}
protected static CallbackHandler anyCallbackHandler() {
@@ -168,14 +167,14 @@
@Test( expected = RepositorySourceException.class )
public void shouldNotCreateConnectionWhenAuthenticationFails() throws Exception {
// Stub the execution context factory to throw a LoginException to simulate failed authentication
- stub(executionContextFactory.create(eq(securityDomain), anyCallbackHandler())).toThrow(new LoginException());
+ stub(executionContextFactory.with(eq(securityDomain), anyCallbackHandler())).toThrow(new LoginException());
source.getConnection();
}
@Test( expected = NullPointerException.class )
public void shouldPropogateAllExceptionsExceptLoginExceptionThrownFromExecutionContextFactory() throws Exception {
// Stub the execution context factory to throw a LoginException to simulate failed authentication
- stub(executionContextFactory.create(eq(securityDomain), anyCallbackHandler())).toThrow(new NullPointerException());
+ stub(executionContextFactory.with(eq(securityDomain), anyCallbackHandler())).toThrow(new NullPointerException());
source.getConnection();
}
Modified: trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/JpaSource.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/JpaSource.java 2009-01-16 03:26:56 UTC (rev 711)
+++ trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/JpaSource.java 2009-01-16 20:03:39 UTC (rev 712)
@@ -771,7 +771,7 @@
// Set the context class loader, so that the driver could be found ...
if (this.repositoryContext != null && this.driverClassloaderName != null) {
try {
- ExecutionContext context = this.repositoryContext.getExecutionContextFactory().create();
+ ExecutionContext context = this.repositoryContext.getExecutionContext();
ClassLoader loader = context.getClassLoader(this.driverClassloaderName);
if (loader != null) {
Thread.currentThread().setContextClassLoader(loader);
15 years, 3 months