DNA SVN: r1372 - in trunk/dna-graph/src/main/java/org/jboss/dna/graph: request and 1 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-11-30 16:53:47 -0500 (Mon, 30 Nov 2009)
New Revision: 1372
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/query/optimize/RewriteAsRangeCriteria.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CloneBranchRequest.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/CreateNodeRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/DeleteBranchRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/DeleteChildrenRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/LockBranchRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/MoveBranchRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/ReadAllChildrenRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/ReadAllPropertiesRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/ReadBlockOfChildrenRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/ReadBranchRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/ReadNextBlockOfChildrenRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/ReadNodeRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/ReadPropertyRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/RemovePropertyRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/RenameNodeRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/SetPropertyRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UnlockBranchRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UpdatePropertiesRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/VerifyNodeExistsRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/session/GraphSession.java
Log:
DNA-551 Fixed a couple of calls to 'Location.isSame()' that should have been fixed earlier.
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/query/optimize/RewriteAsRangeCriteria.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/query/optimize/RewriteAsRangeCriteria.java 2009-11-30 20:08:48 UTC (rev 1371)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/query/optimize/RewriteAsRangeCriteria.java 2009-11-30 21:53:47 UTC (rev 1372)
@@ -48,7 +48,6 @@
import org.jboss.dna.graph.query.plan.PlanNode.Type;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
-import com.google.common.collect.Multimaps;
/**
* An {@link OptimizerRule optimizer rule} that rewrites two {@link And AND-ed} {@link Constraint}s that constraint a dynamic
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CloneBranchRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CloneBranchRequest.java 2009-11-30 20:08:48 UTC (rev 1371)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CloneBranchRequest.java 2009-11-30 21:53:47 UTC (rev 1372)
@@ -167,10 +167,9 @@
*
* @param fromLocation the actual location of the node being cloned
* @param intoLocation the actual location of the new clone of the node
- * @throws IllegalArgumentException if the either location is null; if the old location does not represent the
- * {@link Location#isSame(Location) same location} as the {@link #from() from location}; if the new location does not
- * represent the {@link Location#isSame(Location) same location} as the {@link #into() into location}; if the either
- * location does not have a path
+ * @throws IllegalArgumentException if the either location is null; if the old location is not {@link Location#equals(Object)
+ * equal to} the {@link #from() from location}; if the new location is not {@link Location#equals(Object) equal to}
+ * the {@link #into() into location}; if the either location does not have a path
* @throws IllegalStateException if the request is frozen
*/
public void setActualLocations( Location fromLocation,
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-11-30 20:08:48 UTC (rev 1371)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CopyBranchRequest.java 2009-11-30 21:53:47 UTC (rev 1372)
@@ -203,10 +203,9 @@
*
* @param fromLocation the actual location of the node being copied
* @param intoLocation the actual location of the new copy of the node
- * @throws IllegalArgumentException if the either location is null; if the old location does not represent the
- * {@link Location#isSame(Location) same location} as the {@link #from() from location}; if the new location does not
- * represent the {@link Location#isSame(Location) same location} as the {@link #into() into location}; if the either
- * location does not have a path
+ * @throws IllegalArgumentException if the either location is null; if the old location is not {@link Location#equals(Object)
+ * equal to} the {@link #from() from location}; if the new location is not {@link Location#equals(Object) equal to}
+ * the {@link #into() into location}; if the either location does not have a path
* @throws IllegalStateException if the request is frozen
*/
public void setActualLocations( Location fromLocation,
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CreateNodeRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CreateNodeRequest.java 2009-11-30 20:08:48 UTC (rev 1371)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CreateNodeRequest.java 2009-11-30 21:53:47 UTC (rev 1372)
@@ -275,8 +275,8 @@
*
* @param actual the actual location of the node being created, or null if the {@link #under() current location} should be
* used
- * @throws IllegalArgumentException if the actual location does not represent the {@link Location#isSame(Location) same
- * location} as the {@link #under() current location}, or if the actual location does not have a path.
+ * @throws IllegalArgumentException if the actual location is not {@link Location#equals(Object) equal to} the
+ * {@link #under() current location}, or if the actual location does not have a path.
* @throws IllegalStateException if the request is frozen
*/
public void setActualLocationOfNode( Location actual ) {
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/DeleteBranchRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/DeleteBranchRequest.java 2009-11-30 20:08:48 UTC (rev 1371)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/DeleteBranchRequest.java 2009-11-30 21:53:47 UTC (rev 1372)
@@ -88,8 +88,8 @@
* and the actual location must have a {@link Location#getPath() path}.
*
* @param actual the actual location of the node being deleted, 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.
+ * @throws IllegalArgumentException if the actual location is not {@link Location#equals(Object) equal to} the {@link #at()
+ * current location}, or if the actual location does not have a path.
* @throws IllegalStateException if the request is frozen
*/
public void setActualLocationOfNode( Location actual ) {
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/DeleteChildrenRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/DeleteChildrenRequest.java 2009-11-30 20:08:48 UTC (rev 1371)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/DeleteChildrenRequest.java 2009-11-30 21:53:47 UTC (rev 1372)
@@ -92,8 +92,8 @@
* and the actual location must have a {@link Location#getPath() path}.
*
* @param actual the actual location of the node being deleted, 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.
+ * @throws IllegalArgumentException if the actual location is not {@link Location#equals(Object) equal to} the {@link #at()
+ * current location}, or if the actual location does not have a path.
* @throws IllegalStateException if the request is frozen
*/
public void setActualLocationOfNode( Location actual ) {
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/LockBranchRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/LockBranchRequest.java 2009-11-30 20:08:48 UTC (rev 1371)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/LockBranchRequest.java 2009-11-30 21:53:47 UTC (rev 1372)
@@ -122,8 +122,8 @@
* the actual location must have a {@link Location#getPath() path}.
*
* @param actualLocation the actual location of the node before being locked
- * @throws IllegalArgumentException if the either location is null or is missing its path, if the old location does not
- * represent the {@link Location#isSame(Location) same location} as the {@link #at() current location}
+ * @throws IllegalArgumentException if the either location is null or is missing its path, if the old location is not
+ * {@link Location#equals(Object) equal to} the {@link #at() current location}
* @throws IllegalStateException if the request is frozen
*/
public void setActualLocation( Location actualLocation ) {
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/MoveBranchRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/MoveBranchRequest.java 2009-11-30 20:08:48 UTC (rev 1371)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/MoveBranchRequest.java 2009-11-30 21:53:47 UTC (rev 1372)
@@ -225,10 +225,9 @@
*
* @param oldLocation the actual location of the node before being moved
* @param newLocation the actual new location of the node
- * @throws IllegalArgumentException if the either location is null, if the old location does not represent the
- * {@link Location#isSame(Location) same location} as the {@link #from() from location}, if the new location does not
- * represent the {@link Location#isSame(Location) same location} as the {@link #into() into location}, or if the
- * either location does not have a path
+ * @throws IllegalArgumentException if the either location is null, if the old location is not {@link Location#equals(Object)
+ * equal to} the {@link #from() from location}, if the new location is not {@link Location#equals(Object) equal to}
+ * the {@link #into() into location}, or if the either location does not have a path
* @throws IllegalStateException if the request is frozen
*/
public void setActualLocations( Location oldLocation,
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/ReadAllChildrenRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/ReadAllChildrenRequest.java 2009-11-30 20:08:48 UTC (rev 1371)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/ReadAllChildrenRequest.java 2009-11-30 21:53:47 UTC (rev 1372)
@@ -187,9 +187,8 @@
*
* @param actualLocation the actual location of the node being read, or null if the {@link #of() current location} should be
* used
- * @throws IllegalArgumentException if the actual location does not represent the {@link Location#isSame(Location) same
- * location} as the {@link #of() current location}; if the actual location does not have a path; or if the actual
- * workspace name is null
+ * @throws IllegalArgumentException if the actual location is not {@link Location#equals(Object) equal to} the {@link #of()
+ * current location}; if the actual location does not have a path; or if the actual workspace name is null
* @throws IllegalStateException if the request is frozen
*/
public void setActualLocationOfNode( Location actualLocation ) {
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/ReadAllPropertiesRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/ReadAllPropertiesRequest.java 2009-11-30 20:08:48 UTC (rev 1371)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/ReadAllPropertiesRequest.java 2009-11-30 21:53:47 UTC (rev 1372)
@@ -189,8 +189,8 @@
* 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.
+ * @throws IllegalArgumentException if the actual location is not {@link Location#equals(Object) equal to} the {@link #at()
+ * current location}, or if the actual location does not have a path.
* @throws IllegalStateException if the request is frozen
*/
public void setActualLocationOfNode( Location actual ) {
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/ReadBlockOfChildrenRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/ReadBlockOfChildrenRequest.java 2009-11-30 20:08:48 UTC (rev 1371)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/ReadBlockOfChildrenRequest.java 2009-11-30 21:53:47 UTC (rev 1372)
@@ -234,8 +234,8 @@
* 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 #of() current location} should be used
- * @throws IllegalArgumentException if the actual location does not represent the {@link Location#isSame(Location) same
- * location} as the {@link #of() current location}, or if the actual location does not have a path.
+ * @throws IllegalArgumentException if the actual location is not {@link Location#equals(Object) equal to} the {@link #of()
+ * current location}, or if the actual location does not have a path.
* @throws IllegalStateException if the request is frozen
*/
public void setActualLocationOfNode( Location actual ) {
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/ReadBranchRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/ReadBranchRequest.java 2009-11-30 20:08:48 UTC (rev 1371)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/ReadBranchRequest.java 2009-11-30 21:53:47 UTC (rev 1372)
@@ -363,8 +363,8 @@
* 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.
+ * @throws IllegalArgumentException if the actual location is not {@link Location#equals(Object) equal to} the {@link #at()
+ * current location}, or if the actual location does not have a path.
*/
public void setActualLocationOfNode( Location actual ) {
if (!at.equals(actual)) { // not same if actual is null
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/ReadNextBlockOfChildrenRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/ReadNextBlockOfChildrenRequest.java 2009-11-30 20:08:48 UTC (rev 1371)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/ReadNextBlockOfChildrenRequest.java 2009-11-30 21:53:47 UTC (rev 1372)
@@ -203,13 +203,13 @@
*
* @param actual the actual location of the node being read, or null if the {@link #startingAfter() starting after location}
* should be used
- * @throws IllegalArgumentException if the actual location does not represent the {@link Location#isSame(Location) same
- * location} as the {@link #startingAfter() starting after location}, or if the actual location does not have a path.
+ * @throws IllegalArgumentException if the actual location is not {@link Location#equals(Object) equal to} the
+ * {@link #startingAfter() starting after location}, or if the actual location does not have a path.
* @throws IllegalStateException if the request is frozen
*/
public void setActualLocationOfStartingAfterNode( Location actual ) {
checkNotFrozen();
- if (!startingAfter.isSame(actual)) { // not same if actual is null
+ if (!startingAfter.equals(actual)) { // not same if actual is null
throw new IllegalArgumentException(GraphI18n.actualLocationNotEqualToInputLocation.text(actual, startingAfter));
}
assert actual != null;
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/ReadNodeRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/ReadNodeRequest.java 2009-11-30 20:08:48 UTC (rev 1371)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/ReadNodeRequest.java 2009-11-30 21:53:47 UTC (rev 1372)
@@ -253,8 +253,8 @@
* 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.
+ * @throws IllegalArgumentException if the actual location is not {@link Location#equals(Object) equal to} the {@link #at()
+ * current location}, or if the actual location does not have a path.
* @throws IllegalStateException if the request is frozen
*/
public void setActualLocationOfNode( Location actual ) {
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/ReadPropertyRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/ReadPropertyRequest.java 2009-11-30 20:08:48 UTC (rev 1371)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/ReadPropertyRequest.java 2009-11-30 21:53:47 UTC (rev 1372)
@@ -128,8 +128,8 @@
* 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 #on() current location} should be used
- * @throws IllegalArgumentException if the actual location does not represent the {@link Location#isSame(Location) same
- * location} as the {@link #on() current location}, or if the actual location does not have a path.
+ * @throws IllegalArgumentException if the actual location is not {@link Location#equals(Object) equal to} the {@link #on()
+ * current location}, or if the actual location does not have a path.
* @throws IllegalStateException if the request is frozen
*/
public void setActualLocationOfNode( Location actual ) {
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/RemovePropertyRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/RemovePropertyRequest.java 2009-11-30 20:08:48 UTC (rev 1371)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/RemovePropertyRequest.java 2009-11-30 21:53:47 UTC (rev 1372)
@@ -104,13 +104,13 @@
* and the actual location must have a {@link Location#getPath() path}.
*
* @param actual the actual location of the node being updated, or null if the {@link #from() current location} should be used
- * @throws IllegalArgumentException if the actual location does represent the {@link Location#isSame(Location) same location}
- * as the {@link #from() current location}, or if the actual location does not have a path.
+ * @throws IllegalArgumentException if the actual location is not {@link Location#equals(Object) equal to} the {@link #from()
+ * current location}, or if the actual location does not have a path.
* @throws IllegalStateException if the request is frozen
*/
public void setActualLocationOfNode( Location actual ) {
checkNotFrozen();
- if (!from.isSame(actual)) { // not same if actual is null
+ if (!from.equals(actual)) { // not same if actual is null
throw new IllegalArgumentException(GraphI18n.actualLocationNotEqualToInputLocation.text(actual, from));
}
assert actual != null;
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/RenameNodeRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/RenameNodeRequest.java 2009-11-30 20:08:48 UTC (rev 1371)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/RenameNodeRequest.java 2009-11-30 21:53:47 UTC (rev 1372)
@@ -106,17 +106,16 @@
*
* @param oldLocation the actual location of the node before being renamed
* @param newLocation the actual location of the node after being renamed
- * @throws IllegalArgumentException if the either location is null or is missing its path, if the old location does not
- * represent the {@link Location#isSame(Location) same location} as the {@link #at() current location}, if the new
- * location does not have the same parent as the old location, or if the new location does not have the same
- * {@link Path.Segment#getName() name} on {@link Path#getLastSegment() last segment} as that {@link #toName()
- * specified on the request}
+ * @throws IllegalArgumentException if the either location is null or is missing its path, if the old location is not
+ * {@link Location#equals(Object) equal to} the {@link #at() current location}, if the new location does not have the
+ * same parent as the old location, or if the new location does not have the same {@link Path.Segment#getName() name}
+ * on {@link Path#getLastSegment() last segment} as that {@link #toName() specified on the request}
* @throws IllegalStateException if the request is frozen
*/
public void setActualLocations( Location oldLocation,
Location newLocation ) {
checkNotFrozen();
- if (!at.isSame(oldLocation)) { // not same if actual is null
+ if (!at.equals(oldLocation)) { // not same if actual is null
throw new IllegalArgumentException(GraphI18n.actualLocationNotEqualToInputLocation.text(oldLocation, at));
}
assert oldLocation != null;
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/SetPropertyRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/SetPropertyRequest.java 2009-11-30 20:08:48 UTC (rev 1371)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/SetPropertyRequest.java 2009-11-30 21:53:47 UTC (rev 1372)
@@ -106,8 +106,8 @@
* and the actual location must have a {@link Location#getPath() path}.
*
* @param actual the actual location of the node being updated, or null if the {@link #on() current location} should be used
- * @throws IllegalArgumentException if the actual location does represent the {@link Location#isSame(Location) same location}
- * as the {@link #on() current location}, or if the actual location does not have a path.
+ * @throws IllegalArgumentException if the actual location is not {@link Location#equals(Object) equal to} the {@link #on()
+ * current location}, or if the actual location does not have a path.
* @throws IllegalStateException if the request is frozen
*/
public void setActualLocationOfNode( Location actual ) {
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UnlockBranchRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UnlockBranchRequest.java 2009-11-30 20:08:48 UTC (rev 1371)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UnlockBranchRequest.java 2009-11-30 21:53:47 UTC (rev 1372)
@@ -88,13 +88,13 @@
* and the actual location must have a {@link Location#getPath() path}.
*
* @param actualLocation the actual location of the node before being unlocked
- * @throws IllegalArgumentException if the either location is null or is missing its path, if the old location does not
- * represent the {@link Location#isSame(Location) same location} as the {@link #at() current location}
+ * @throws IllegalArgumentException if the either location is null or is missing its path, if the old location is not
+ * {@link Location#equals(Object) equal to} the {@link #at() current location}
* @throws IllegalStateException if the request is frozen
*/
public void setActualLocation( Location actualLocation ) {
checkNotFrozen();
- if (!at.isSame(actualLocation)) { // not same if actual is null
+ if (!at.equals(actualLocation)) { // not same if actual is null
throw new IllegalArgumentException(GraphI18n.actualLocationNotEqualToInputLocation.text(actualLocation, at));
}
assert actualLocation != null;
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UpdatePropertiesRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UpdatePropertiesRequest.java 2009-11-30 20:08:48 UTC (rev 1371)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UpdatePropertiesRequest.java 2009-11-30 21:53:47 UTC (rev 1372)
@@ -125,8 +125,8 @@
* and the actual location must have a {@link Location#getPath() path}.
*
* @param actual the actual location of the node being updated, or null if the {@link #on() current location} should be used
- * @throws IllegalArgumentException if the actual location does represent the {@link Location#isSame(Location) same location}
- * as the {@link #on() current location}, or if the actual location does not have a path.
+ * @throws IllegalArgumentException if the actual location is not {@link Location#equals(Object) equal to} the {@link #on()
+ * current location}, or if the actual location does not have a path.
* @throws IllegalStateException if the request is frozen
* @see #setNewProperties(Iterable)
* @see #setNewProperties(Name...)
Modified: 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 2009-11-30 20:08:48 UTC (rev 1371)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/VerifyNodeExistsRequest.java 2009-11-30 21:53:47 UTC (rev 1372)
@@ -87,8 +87,8 @@
* 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.
+ * @throws IllegalArgumentException if the actual location is not {@link Location#equals(Object) equal to} the {@link #at()
+ * current location}, or if the actual location does not have a path.
* @throws IllegalStateException if the request is frozen
*/
public void setActualLocationOfNode( Location actual ) {
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/session/GraphSession.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/session/GraphSession.java 2009-11-30 20:08:48 UTC (rev 1371)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/session/GraphSession.java 2009-11-30 21:53:47 UTC (rev 1372)
@@ -65,9 +65,8 @@
import org.jboss.dna.graph.request.MoveBranchRequest;
import org.jboss.dna.graph.request.Request;
import org.jboss.dna.graph.session.GraphSession.Authorizer.Action;
-import com.google.common.collect.ListMultimap;
import com.google.common.collect.LinkedListMultimap;
-import com.google.common.collect.Multimaps;
+import com.google.common.collect.ListMultimap;
/**
* This class represents an interactive session for working with the content within a graph. This session maintains a cache of
14 years, 5 months
DNA SVN: r1371 - in trunk/dna-jcr/src: test/java/org/jboss/dna/jcr and 1 other directory.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-11-30 15:08:48 -0500 (Mon, 30 Nov 2009)
New Revision: 1371
Modified:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrWorkspace.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/WorkspaceLockManager.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractSessionTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/WorkspaceLockManagerTest.java
Log:
Merge branch 'dna-548'
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-11-30 19:40:58 UTC (rev 1370)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java 2009-11-30 20:08:48 UTC (rev 1371)
@@ -424,8 +424,9 @@
// Right now, the other nodes will be created as needed
}
- Graph createWorkspaceGraph( String workspaceName ) {
- Graph graph = Graph.create(this.federatedSource, this.executionContext);
+ Graph createWorkspaceGraph( String workspaceName,
+ ExecutionContext workspaceContext ) {
+ Graph graph = Graph.create(this.federatedSource, workspaceContext);
graph.useWorkspace(workspaceName);
return graph;
}
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrWorkspace.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrWorkspace.java 2009-11-30 19:40:58 UTC (rev 1370)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrWorkspace.java 2009-11-30 20:08:48 UTC (rev 1371)
@@ -102,7 +102,7 @@
/**
* The reference to the {@link JcrRepository} instance that owns this {@link Workspace} instance. Very few methods on this
- * repository object are used; mainly {@link JcrRepository#createWorkspaceGraph(String)},
+ * repository object are used; mainly {@link JcrRepository#createWorkspaceGraph(String,ExecutionContext)},
* {@link JcrRepository#getPersistentRegistry()} and {@link JcrRepository#getRepositorySourceName()}.
*/
private final JcrRepository repository;
@@ -158,7 +158,7 @@
this.context = context.with(local);
// Now create a graph for the session ...
- this.graph = this.repository.createWorkspaceGraph(workspaceName);
+ this.graph = this.repository.createWorkspaceGraph(this.name, this.context);
// Set up the session for this workspace ...
this.session = new JcrSession(this.repository, this, this.context, globalRegistry, sessionAttributes);
@@ -312,7 +312,7 @@
/*
* Find the UUID for the source node. Have to go directly against the graph.
*/
- org.jboss.dna.graph.Node sourceNode = repository.createWorkspaceGraph(srcWorkspace).getNodeAt(srcPath);
+ org.jboss.dna.graph.Node sourceNode = repository.createWorkspaceGraph(srcWorkspace, context).getNodeAt(srcPath);
Property uuidProp = sourceNode.getProperty(DnaLexicon.UUID);
if (uuidProp != null) {
@@ -467,7 +467,7 @@
/*
* Find the UUID for the source node. Have to go directly against the graph.
*/
- org.jboss.dna.graph.Node sourceNode = repository.createWorkspaceGraph(srcWorkspace).getNodeAt(srcPath);
+ org.jboss.dna.graph.Node sourceNode = repository.createWorkspaceGraph(srcWorkspace, context).getNodeAt(srcPath);
Property uuidProp = sourceNode.getProperty(DnaLexicon.UUID);
if (uuidProp != null) {
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/WorkspaceLockManager.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/WorkspaceLockManager.java 2009-11-30 19:40:58 UTC (rev 1370)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/WorkspaceLockManager.java 2009-11-30 20:08:48 UTC (rev 1371)
@@ -160,7 +160,7 @@
DnaLock lock,
boolean isDeep ) throws RepositoryException {
// Write them directly to the underlying graph
- Graph.Batch workspaceBatch = repository.createWorkspaceGraph(workspaceName).batch();
+ Graph.Batch workspaceBatch = repository.createWorkspaceGraph(workspaceName, session.getExecutionContext()).batch();
workspaceBatch.set(lockOwnerProp, lockIsDeepProp).on(nodeUuid);
if (isDeep) {
workspaceBatch.lock(nodeUuid).andItsDescendants().withDefaultTimeout();
@@ -195,7 +195,7 @@
batch.remove(JcrLexicon.LOCK_OWNER, JcrLexicon.LOCK_IS_DEEP).on(lock.nodeUuid);
batch.execute();
- unlockNodeInRepository(lock);
+ unlockNodeInRepository(session, lock);
workspaceLocksByNodeUuid.remove(lock.nodeUuid);
} catch (PathNotFoundException pnfe) {
@@ -221,10 +221,12 @@
* /jcr:system/dna:locks} subgraph.
* </p>
*
+ * @param session the session in which the node is being unlocked
* @param lock
*/
- void unlockNodeInRepository( DnaLock lock ) {
- Graph.Batch workspaceBatch = repository.createWorkspaceGraph(this.workspaceName).batch();
+ void unlockNodeInRepository( JcrSession session,
+ DnaLock lock ) {
+ Graph.Batch workspaceBatch = repository.createWorkspaceGraph(this.workspaceName, session.getExecutionContext()).batch();
workspaceBatch.remove(JcrLexicon.LOCK_OWNER, JcrLexicon.LOCK_IS_DEEP).on(lock.nodeUuid);
workspaceBatch.unlock(lock.nodeUuid);
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractSessionTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractSessionTest.java 2009-11-30 19:40:58 UTC (rev 1370)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractSessionTest.java 2009-11-30 20:08:48 UTC (rev 1371)
@@ -23,6 +23,7 @@
*/
package org.jboss.dna.jcr;
+import static org.mockito.Matchers.anyObject;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.stub;
import java.io.IOException;
@@ -137,7 +138,7 @@
stub(repository.getRepositoryTypeManager()).toReturn(repoTypeManager);
stub(repository.getRepositorySourceName()).toReturn(repositorySourceName);
stub(repository.getPersistentRegistry()).toReturn(context.getNamespaceRegistry());
- stub(repository.createWorkspaceGraph(anyString())).toAnswer(new Answer<Graph>() {
+ stub(repository.createWorkspaceGraph(anyString(), (ExecutionContext)anyObject())).toAnswer(new Answer<Graph>() {
public Graph answer( InvocationOnMock invocation ) throws Throwable {
return graph;
}
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/WorkspaceLockManagerTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/WorkspaceLockManagerTest.java 2009-11-30 19:40:58 UTC (rev 1370)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/WorkspaceLockManagerTest.java 2009-11-30 20:08:48 UTC (rev 1371)
@@ -3,6 +3,7 @@
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsInstanceOf.instanceOf;
import static org.junit.Assert.assertThat;
+import static org.mockito.Matchers.anyObject;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.stub;
@@ -71,7 +72,7 @@
stub(repository.getRepositoryTypeManager()).toReturn(repoTypeManager);
stub(repository.getRepositorySourceName()).toReturn(sourceName);
stub(repository.getPersistentRegistry()).toReturn(context.getNamespaceRegistry());
- stub(repository.createWorkspaceGraph(anyString())).toAnswer(new Answer<Graph>() {
+ stub(repository.createWorkspaceGraph(anyString(), (ExecutionContext)anyObject())).toAnswer(new Answer<Graph>() {
public Graph answer( InvocationOnMock invocation ) throws Throwable {
return graph;
}
@@ -150,7 +151,9 @@
@Test
public void shouldCreateLockRequestWhenUnlockingNode() {
DnaLock lock = workspaceLockManager.createLock("testOwner", UUID.randomUUID(), validUuid, false, false);
- workspaceLockManager.unlockNodeInRepository(lock);
+ JcrSession session = mock(JcrSession.class);
+ stub(session.getExecutionContext()).toReturn(context);
+ workspaceLockManager.unlockNodeInRepository(session, lock);
assertNextRequestIsUnlock(validLocation);
}
14 years, 5 months
DNA SVN: r1370 - in trunk: dna-jcr/src/main/java/org/jboss/dna/jcr and 1 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-11-30 14:40:58 -0500 (Mon, 30 Nov 2009)
New Revision: 1370
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/Changes.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrWorkspace.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/WorkspaceLockManager.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractSessionTest.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/WorkspaceLockManagerTest.java
Log:
DNA-548 Changed JcrWorkspace, JcrSession, and WorkspaceLockManager so that they use ExecutionContext more consistently. JcrWorkspace and JcrSession both share the exact same ExecutionContext instance, while WorkspaceLockManager was changed to expect the JcrSession in most of its methods so the lock manager can use the JcrSession's ExecutionContext in its operations. (The latter also has the advantage of recording which sessions were performing the lock operations, since now the session's context is used for all lock operations.)
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/Changes.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/Changes.java 2009-11-30 17:06:05 UTC (rev 1369)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/Changes.java 2009-11-30 19:40:58 UTC (rev 1370)
@@ -127,7 +127,7 @@
* @return the context identifier; never null
*/
public String getContextId() {
- return processId;
+ return contextId;
}
/**
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java 2009-11-30 17:06:05 UTC (rev 1369)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java 2009-11-30 19:40:58 UTC (rev 1370)
@@ -1336,7 +1336,7 @@
* @see javax.jcr.Node#holdsLock()
*/
public final boolean holdsLock() /*throws RepositoryException*/{
- WorkspaceLockManager.DnaLock lock = session().workspace().lockManager().lockFor(this.location);
+ WorkspaceLockManager.DnaLock lock = session().workspace().lockManager().lockFor(session(), this.location);
return lock != null && cache.session().lockTokens().contains(lock.getLockToken());
}
@@ -1368,9 +1368,9 @@
while (!nodesToVisit.isEmpty()) {
Node<JcrNodePayload, JcrPropertyPayload> node = nodesToVisit.remove(nodesToVisit.size() - 1);
- if (session().workspace().lockManager().lockFor(node.getLocation()) != null) throw new LockException(
- JcrI18n.parentAlreadyLocked.text(this.location,
- node.getLocation()));
+ if (session().workspace().lockManager().lockFor(session(), node.getLocation()) != null) throw new LockException(
+ JcrI18n.parentAlreadyLocked.text(this.location,
+ node.getLocation()));
for (Node<JcrNodePayload, JcrPropertyPayload> child : node.getChildren()) {
nodesToVisit.add(child);
@@ -1378,9 +1378,8 @@
}
}
- WorkspaceLockManager.DnaLock lock = session().workspace().lockManager().lock(cache,
+ WorkspaceLockManager.DnaLock lock = session().workspace().lockManager().lock(session(),
this.location,
- session().getUserID(),
isDeep,
isSessionScoped);
@@ -1394,7 +1393,7 @@
* @see javax.jcr.Node#unlock()
*/
public final void unlock() throws LockException, RepositoryException {
- WorkspaceLockManager.DnaLock lock = session().workspace().lockManager().lockFor(this.location);
+ WorkspaceLockManager.DnaLock lock = session().workspace().lockManager().lockFor(session(), this.location);
if (lock == null) {
throw new LockException(JcrI18n.notLocked.text(this.location));
@@ -1404,7 +1403,7 @@
throw new LockException(JcrI18n.lockTokenNotHeld.text(this.location));
}
- session().workspace().lockManager().unlock(lock);
+ session().workspace().lockManager().unlock(session(), lock);
session().removeLockToken(lock.getLockToken());
}
@@ -1413,14 +1412,14 @@
if (session() == null || session().workspace() == null) return null;
WorkspaceLockManager lockManager = session().workspace().lockManager();
- WorkspaceLockManager.DnaLock lock = lockManager.lockFor(this.location);
+ WorkspaceLockManager.DnaLock lock = lockManager.lockFor(session(), this.location);
if (lock != null) return lock;
AbstractJcrNode parent = this;
while (!parent.isRoot()) {
parent = parent.getParent();
- WorkspaceLockManager.DnaLock parentLock = lockManager.lockFor(parent.location);
+ WorkspaceLockManager.DnaLock parentLock = lockManager.lockFor(session(), parent.location);
if (parentLock != null && parentLock.isLive()) {
return parentLock.isDeep() ? parentLock : null;
}
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-11-30 17:06:05 UTC (rev 1369)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java 2009-11-30 19:40:58 UTC (rev 1370)
@@ -410,7 +410,7 @@
this.federatedSource.initialize(new FederatedRepositoryContext(this.connectionFactory));
this.lockManagers = new ConcurrentHashMap<String, WorkspaceLockManager>();
- this.locksPath = pathFactory.create(pathFactory.createRootPath(), JcrLexicon.SYSTEM, DnaLexicon.LOCKS);
+ this.locksPath = pathFactory.create(pathFactory.createRootPath(), JcrLexicon.SYSTEM, DnaLexicon.LOCKS);
}
protected void initializeSystemContent( Graph systemGraph ) {
@@ -430,12 +430,12 @@
return graph;
}
- Graph createSystemGraph() {
+ Graph createSystemGraph( ExecutionContext sessionContext ) {
assert this.systemSourceName != null;
assert this.connectionFactory != null;
- assert this.executionContext != null;
+ assert sessionContext != null;
// The default workspace should be the system workspace ...
- Graph result = Graph.create(this.systemSourceName, this.connectionFactory, this.executionContext);
+ Graph result = Graph.create(this.systemSourceName, this.connectionFactory, sessionContext);
if (this.systemWorkspaceName != null) {
result.useWorkspace(systemWorkspaceName);
}
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java 2009-11-30 17:06:05 UTC (rev 1369)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java 2009-11-30 19:40:58 UTC (rev 1370)
@@ -65,7 +65,6 @@
import org.jboss.dna.graph.property.Path;
import org.jboss.dna.graph.property.PathFactory;
import org.jboss.dna.graph.property.ValueFactories;
-import org.jboss.dna.graph.property.basic.LocalNamespaceRegistry;
import org.jboss.dna.graph.session.GraphSession;
import org.jboss.dna.jcr.JcrContentHandler.EnclosingSAXException;
import org.jboss.dna.jcr.JcrContentHandler.SaveMode;
@@ -143,21 +142,21 @@
JcrSession( JcrRepository repository,
JcrWorkspace workspace,
- ExecutionContext workspaceContext,
+ ExecutionContext sessionContext,
+ NamespaceRegistry globalNamespaceRegistry,
Map<String, Object> sessionAttributes ) {
assert repository != null;
assert workspace != null;
assert sessionAttributes != null;
- assert workspaceContext != null;
+ assert sessionContext != null;
this.repository = repository;
this.sessionAttributes = sessionAttributes;
this.workspace = workspace;
// Create an execution context for this session, which should use the local namespace registry ...
- NamespaceRegistry workspaceRegistry = workspaceContext.getNamespaceRegistry();
- NamespaceRegistry local = new LocalNamespaceRegistry(workspaceRegistry);
- this.executionContext = workspaceContext.with(local);
- this.sessionRegistry = new JcrNamespaceRegistry(Behavior.JSR170_SESSION, local, workspaceRegistry, this);
+ this.executionContext = sessionContext;
+ NamespaceRegistry local = sessionContext.getNamespaceRegistry();
+ this.sessionRegistry = new JcrNamespaceRegistry(Behavior.JSR170_SESSION, local, globalNamespaceRegistry, this);
this.rootPath = this.executionContext.getValueFactories().getPathFactory().createRootPath();
// Set up the graph to use for this session (which uses the session's namespace registry and context) ...
@@ -311,11 +310,11 @@
return;
}
- if (workspace().lockManager().isHeldBySession(lt)) {
+ if (workspace().lockManager().isHeldBySession(this, lt)) {
throw new LockException(JcrI18n.lockTokenAlreadyHeld.text(lt));
}
- workspace().lockManager().setHeldBySession(lt, true);
+ workspace().lockManager().setHeldBySession(this, lt, true);
lockTokens.add(lt);
}
@@ -776,7 +775,7 @@
return;
}
- this.workspace().lockManager().cleanLocks(lockTokens);
+ this.workspace().lockManager().cleanLocks(this);
this.executionContext.getSecurityContext().logout();
isLive = false;
}
@@ -858,7 +857,7 @@
throw new IllegalStateException(JcrI18n.cannotRemoveLockToken.text(lt));
}
- workspace().lockManager().setHeldBySession(lt, false);
+ workspace().lockManager().setHeldBySession(this, lt, false);
lockTokens.remove(lt);
}
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrWorkspace.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrWorkspace.java 2009-11-30 17:06:05 UTC (rev 1369)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrWorkspace.java 2009-11-30 19:40:58 UTC (rev 1370)
@@ -34,7 +34,6 @@
import javax.jcr.InvalidSerializedDataException;
import javax.jcr.ItemExistsException;
import javax.jcr.ItemNotFoundException;
-import javax.jcr.NamespaceRegistry;
import javax.jcr.NoSuchWorkspaceException;
import javax.jcr.PathNotFoundException;
import javax.jcr.RepositoryException;
@@ -61,10 +60,12 @@
import org.jboss.dna.graph.connector.RepositorySourceException;
import org.jboss.dna.graph.connector.UuidAlreadyExistsException;
import org.jboss.dna.graph.property.Name;
+import org.jboss.dna.graph.property.NamespaceRegistry;
import org.jboss.dna.graph.property.Path;
import org.jboss.dna.graph.property.PathFactory;
import org.jboss.dna.graph.property.Property;
import org.jboss.dna.graph.property.ValueFormatException;
+import org.jboss.dna.graph.property.basic.LocalNamespaceRegistry;
import org.jboss.dna.graph.request.InvalidWorkspaceException;
import org.jboss.dna.graph.request.ReadBranchRequest;
import org.jboss.dna.graph.session.GraphSession;
@@ -132,7 +133,7 @@
private final JcrQueryManager queryManager;
private final WorkspaceLockManager lockManager;
-
+
/**
* The {@link Session} instance that this corresponds with this workspace.
*/
@@ -151,34 +152,16 @@
this.repository = repository;
this.lockManager = repository.getLockManager(workspaceName);
- // // Set up the execution context for this workspace, which should use the namespace registry that persists
- // // the namespaces in the graph ...
- // Graph namespaceGraph = Graph.create(this.repository.getRepositorySourceName(),
- // this.repository.getConnectionFactory(),
- // context);
- // namespaceGraph.useWorkspace(workspaceName);
- //
- // // Make sure the "/jcr:system" node exists ...
- // PathFactory pathFactory = context.getValueFactories().getPathFactory();
- // Path root = pathFactory.createRootPath();
- // Path systemPath = pathFactory.create(root, JcrLexicon.SYSTEM);
- // Property systemPrimaryType = context.getPropertyFactory().create(JcrLexicon.PRIMARY_TYPE, DnaLexicon.SYSTEM);
- // namespaceGraph.create(systemPath, systemPrimaryType).ifAbsent().and();
- //
- // Name uriProperty = DnaLexicon.NAMESPACE_URI;
- // Path namespacesPath = pathFactory.create(systemPath, DnaLexicon.NAMESPACES);
- // PropertyFactory propertyFactory = context.getPropertyFactory();
- // Property namespaceType = propertyFactory.create(JcrLexicon.PRIMARY_TYPE, DnaLexicon.NAMESPACE);
- // org.jboss.dna.graph.property.NamespaceRegistry persistentRegistry = new GraphNamespaceRegistry(namespaceGraph,
- // namespacesPath,
- // uriProperty, namespaceType);
- this.context = context;
+ // Create an execution context for this session, which should use the local namespace registry ...
+ NamespaceRegistry globalRegistry = context.getNamespaceRegistry();
+ NamespaceRegistry local = new LocalNamespaceRegistry(globalRegistry);
+ this.context = context.with(local);
// Now create a graph for the session ...
this.graph = this.repository.createWorkspaceGraph(workspaceName);
// Set up the session for this workspace ...
- this.session = new JcrSession(this.repository, this, this.context, sessionAttributes);
+ this.session = new JcrSession(this.repository, this, this.context, globalRegistry, sessionAttributes);
// This must be initialized after the session
this.nodeTypeManager = new JcrNodeTypeManager(session, this.repository.getRepositoryTypeManager());
@@ -213,7 +196,7 @@
final WorkspaceLockManager lockManager() {
return this.lockManager;
}
-
+
/**
* {@inheritDoc}
*/
@@ -233,7 +216,7 @@
*
* @see javax.jcr.Workspace#getNamespaceRegistry()
*/
- public final NamespaceRegistry getNamespaceRegistry() {
+ public final javax.jcr.NamespaceRegistry getNamespaceRegistry() {
return workspaceRegistry;
}
@@ -325,7 +308,6 @@
// This also performs the check permission for reading the parent ...
Name newNodeName = destPath.getLastSegment().getName();
SessionCache cache = this.session.cache();
-
/*
* Find the UUID for the source node. Have to go directly against the graph.
@@ -336,7 +318,7 @@
if (uuidProp != null) {
UUID sourceUuid = this.context.getValueFactories().getUuidFactory().create(uuidProp.getFirstValue());
- DnaLock sourceLock = lockManager().lockFor(Location.create(sourceUuid));
+ DnaLock sourceLock = lockManager().lockFor(session, Location.create(sourceUuid));
if (sourceLock != null && sourceLock.getLockToken() == null) {
throw new LockException(JcrI18n.lockTokenNotHeld.text(srcAbsPath));
}
@@ -350,7 +332,7 @@
throw new LockException(destAbsPath);
}
}
-
+
Node<JcrNodePayload, JcrPropertyPayload> parent = cache.findNode(null, destPath.getParent());
cache.findBestNodeDefinition(parent, newNodeName, parent.getPayload().getPrimaryTypeName());
@@ -481,7 +463,6 @@
// This also performs the check permission for reading the parent ...
Name newNodeName = destPath.getLastSegment().getName();
SessionCache cache = this.session.cache();
-
/*
* Find the UUID for the source node. Have to go directly against the graph.
@@ -492,7 +473,7 @@
if (uuidProp != null) {
UUID sourceUuid = this.context.getValueFactories().getUuidFactory().create(uuidProp.getFirstValue());
- DnaLock sourceLock = lockManager().lockFor(Location.create(sourceUuid));
+ DnaLock sourceLock = lockManager().lockFor(session, Location.create(sourceUuid));
if (sourceLock != null && sourceLock.getLockToken() == null) {
throw new LockException(srcAbsPath);
}
@@ -506,7 +487,7 @@
throw new LockException(destAbsPath);
}
}
-
+
Node<JcrNodePayload, JcrPropertyPayload> parent = cache.findNode(null, destPath.getParent());
cache.findBestNodeDefinition(parent, newNodeName, parent.getPayload().getPrimaryTypeName());
@@ -633,7 +614,7 @@
if (newParentLock != null && newParentLock.getLockToken() == null) {
throw new LockException(destAbsPath);
}
- }
+ }
// Now perform the clone, using the direct (non-session) method ...
cache.graphSession().immediateMove(srcPath, destPath);
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/WorkspaceLockManager.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/WorkspaceLockManager.java 2009-11-30 17:06:05 UTC (rev 1369)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/WorkspaceLockManager.java 2009-11-30 19:40:58 UTC (rev 1370)
@@ -31,7 +31,6 @@
@ThreadSafe
class WorkspaceLockManager {
- private final ExecutionContext context;
private final Path locksPath;
private final JcrRepository repository;
private final String workspaceName;
@@ -41,7 +40,6 @@
JcrRepository repository,
String workspaceName,
Path locksPath ) {
- this.context = context;
this.repository = repository;
this.workspaceName = workspaceName;
this.locksPath = locksPath;
@@ -49,7 +47,7 @@
this.workspaceLocksByNodeUuid = new ConcurrentHashMap<UUID, DnaLock>();
Property locksPrimaryType = context.getPropertyFactory().create(JcrLexicon.PRIMARY_TYPE, DnaLexicon.LOCKS);
- repository.createSystemGraph().create(locksPath, locksPrimaryType).ifAbsent().and();
+ repository.createSystemGraph(context).create(locksPath, locksPrimaryType).ifAbsent().and();
}
/**
@@ -60,34 +58,34 @@
* The location given in {@code nodeLocation} must have a UUID.
* </p>
*
- * @param cache the session cache from which the node was loaded
+ * @param session the session in which the node is being locked and that loaded the node
* @param nodeLocation the location for the node; may not be null and must have a UUID
- * @param lockOwner the owner of the new lock
* @param isDeep whether the node's descendants in the content graph should also be locked
* @param isSessionScoped whether the lock should outlive the session in which it was created
* @return an object representing the newly created lock
* @throws RepositoryException if an error occurs updating the graph state
*/
- DnaLock lock( SessionCache cache,
+ DnaLock lock( JcrSession session,
Location nodeLocation,
- String lockOwner,
boolean isDeep,
boolean isSessionScoped ) throws RepositoryException {
assert nodeLocation != null;
UUID lockUuid = UUID.randomUUID();
- UUID nodeUuid = uuidFor(nodeLocation);
+ UUID nodeUuid = uuidFor(session, nodeLocation);
if (nodeUuid == null) {
throw new RepositoryException(JcrI18n.uuidRequiredForLock.text(nodeLocation));
}
+ ExecutionContext sessionContext = session.getExecutionContext();
+ String lockOwner = sessionContext.getSecurityContext().getUserName();
DnaLock lock = createLock(lockOwner, lockUuid, nodeUuid, isDeep, isSessionScoped);
- Graph.Batch batch = repository.createSystemGraph().batch();
+ Graph.Batch batch = repository.createSystemGraph(sessionContext).batch();
- PropertyFactory propFactory = context.getPropertyFactory();
- PathFactory pathFactory = context.getValueFactories().getPathFactory();
+ PropertyFactory propFactory = sessionContext.getPropertyFactory();
+ PathFactory pathFactory = sessionContext.getValueFactories().getPathFactory();
Property lockOwnerProp = propFactory.create(JcrLexicon.LOCK_OWNER, lockOwner);
Property lockIsDeepProp = propFactory.create(JcrLexicon.LOCK_IS_DEEP, isDeep);
@@ -102,6 +100,7 @@
lockIsDeepProp).ifAbsent().and();
batch.execute();
+ SessionCache cache = session.cache();
AbstractJcrNode lockedNode = cache.findJcrNode(Location.create(nodeUuid));
NodeEditor editor = cache.getEditorFor(lockedNode.nodeInfo());
@@ -111,7 +110,7 @@
false);
editor.setProperty(JcrLexicon.LOCK_IS_DEEP, (JcrValue)cache.session().getValueFactory().createValue(isDeep), false);
- lockNodeInRepository(nodeUuid, lockOwnerProp, lockIsDeepProp, lock, isDeep);
+ lockNodeInRepository(session, nodeUuid, lockOwnerProp, lockIsDeepProp, lock, isDeep);
workspaceLocksByNodeUuid.put(nodeUuid, lock);
return lock;
@@ -133,13 +132,14 @@
* <p>
* This method will also attempt to {@link Graph#lock(Location) lock the node in the underlying repository}. If the underlying
* repository supports locks and {@link LockFailedException the lock attempt fails}, this method will cancel the lock attempt
- * by calling {@link #unlock(DnaLock)} and will throw a {@code RepositoryException}.
+ * by calling {@link #unlock(JcrSession,DnaLock)} and will throw a {@code RepositoryException}.
* </p>
* <p>
* This method does not modify the system graph. In other words, it will not create the record for the lock in the {@code
* /jcr:system/dna:locks} subgraph.
* </p>
*
+ * @param session the session in which the node is being locked and that loaded the node
* @param nodeUuid the UUID of the node to lock
* @param lockOwnerProp an existing property with name {@link JcrLexicon#LOCK_OWNER} and the value being the name of the lock
* owner
@@ -153,7 +153,8 @@
* @throws RepositoryException if the repository in which the node represented by {@code nodeUuid} supports locking but
* signals that the lock for the node cannot be acquired
*/
- void lockNodeInRepository( UUID nodeUuid,
+ void lockNodeInRepository( JcrSession session,
+ UUID nodeUuid,
Property lockOwnerProp,
Property lockIsDeepProp,
DnaLock lock,
@@ -170,7 +171,7 @@
workspaceBatch.execute();
} catch (LockFailedException lfe) {
// Attempt to lock node at the repo level failed - cancel lock
- unlock(lock);
+ unlock(session, lock);
throw new RepositoryException(lfe);
}
@@ -179,13 +180,16 @@
/**
* Removes the provided lock, effectively unlocking the node to which the lock is associated.
*
+ * @param session the session in which the node is being unlocked
* @param lock the lock to be removed
*/
- void unlock( DnaLock lock ) {
+ void unlock( JcrSession session,
+ DnaLock lock ) {
try {
+ ExecutionContext context = session.getExecutionContext();
PathFactory pathFactory = context.getValueFactories().getPathFactory();
- Graph.Batch batch = repository.createSystemGraph().batch();
+ Graph.Batch batch = repository.createSystemGraph(context).batch();
batch.delete(pathFactory.create(locksPath, pathFactory.createSegment(lock.getUuid().toString())));
batch.remove(JcrLexicon.LOCK_OWNER, JcrLexicon.LOCK_IS_DEEP).on(lock.nodeUuid);
@@ -232,17 +236,21 @@
* Checks whether the given lock token is currently held by any session by querying the lock record in the underlying
* repository.
*
+ * @param session the session on behalf of which the lock query is being performed
* @param lockToken the lock token to check; may not be null
* @return true if a session currently holds the lock token, false otherwise
*/
- boolean isHeldBySession( String lockToken ) {
+ boolean isHeldBySession( JcrSession session,
+ String lockToken ) {
assert lockToken != null;
+ ExecutionContext context = session.getExecutionContext();
ValueFactory<Boolean> booleanFactory = context.getValueFactories().getBooleanFactory();
PathFactory pathFactory = context.getValueFactories().getPathFactory();
- org.jboss.dna.graph.Node lockNode = repository.createSystemGraph().getNodeAt(pathFactory.create(locksPath,
- pathFactory.createSegment(lockToken)));
+ org.jboss.dna.graph.Node lockNode = repository.createSystemGraph(context)
+ .getNodeAt(pathFactory.create(locksPath,
+ pathFactory.createSegment(lockToken)));
return booleanFactory.create(lockNode.getProperty(DnaLexicon.IS_HELD_BY_SESSION).getFirstValue());
@@ -253,18 +261,22 @@
* lock as being held (or not held) by some {@link Session}. Note that this method does not identify <i>which</i> (if any)
* session holds the token for the lock, just that <i>some</i> session holds the token for the lock.
*
+ * @param session the session on behalf of which the lock operation is being performed
* @param lockToken the lock token for which the "held" status should be modified; may not be null
* @param value the new value
*/
- void setHeldBySession( String lockToken,
+ void setHeldBySession( JcrSession session,
+ String lockToken,
boolean value ) {
assert lockToken != null;
+ ExecutionContext context = session.getExecutionContext();
PropertyFactory propFactory = context.getPropertyFactory();
PathFactory pathFactory = context.getValueFactories().getPathFactory();
- repository.createSystemGraph().set(propFactory.create(DnaLexicon.IS_HELD_BY_SESSION, value)).on(pathFactory.create(locksPath,
- pathFactory.createSegment(lockToken)));
+ repository.createSystemGraph(context)
+ .set(propFactory.create(DnaLexicon.IS_HELD_BY_SESSION, value))
+ .on(pathFactory.create(locksPath, pathFactory.createSegment(lockToken)));
}
/**
@@ -288,11 +300,13 @@
/**
* Returns the lock that corresponds to the given UUID
*
+ * @param session the session on behalf of which the lock operation is being performed
* @param nodeLocation the node UUID
* @return the corresponding lock, possibly null if there is no such lock
*/
- DnaLock lockFor( Location nodeLocation ) {
- UUID nodeUuid = uuidFor(nodeLocation);
+ DnaLock lockFor( JcrSession session,
+ Location nodeLocation ) {
+ UUID nodeUuid = uuidFor(session, nodeLocation);
if (nodeUuid == null) return null;
return workspaceLocksByNodeUuid.get(nodeUuid);
}
@@ -302,10 +316,12 @@
* returns the {@link Location#getUuid() default UUID} if it exists. If it does not, the method returns the value of the
* {@link JcrLexicon#UUID} property as a UUID. If the location does not contain that property, the method returns null.
*
+ * @param session the session on behalf of which the lock operation is being performed
* @param location the location for which the UUID should be returned
* @return the UUID that identifies the given location or {@code null} if the location does not have a UUID.
*/
- UUID uuidFor( Location location ) {
+ UUID uuidFor( JcrSession session,
+ Location location ) {
assert location != null;
if (location.getUuid() != null) return location.getUuid();
@@ -313,26 +329,28 @@
org.jboss.dna.graph.property.Property uuidProp = location.getIdProperty(JcrLexicon.UUID);
if (uuidProp == null) return null;
+ ExecutionContext context = session.getExecutionContext();
return context.getValueFactories().getUuidFactory().create(uuidProp.getFirstValue());
}
/**
* Unlocks all locks corresponding to the tokens in the {@code lockTokens} collection that are session scoped.
*
- * @param lockTokens the collection of lock tokens
+ * @param session the session on behalf of which the lock operation is being performed
*/
- void cleanLocks( Collection<String> lockTokens ) {
+ void cleanLocks( JcrSession session ) {
+ Collection<String> lockTokens = session.lockTokens();
for (String lockToken : lockTokens) {
DnaLock lock = lockFor(lockToken);
if (lock != null && lock.isSessionScoped()) {
- unlock(lock);
+ unlock(session, lock);
}
}
}
/**
* Internal representation of a locked node. This class should only be created through calls to
- * {@link WorkspaceLockManager#lock(SessionCache, Location, String, boolean, boolean)}.
+ * {@link WorkspaceLockManager#lock(JcrSession, Location, boolean, boolean)}.
*/
@ThreadSafe
public class DnaLock {
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractSessionTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractSessionTest.java 2009-11-30 17:06:05 UTC (rev 1369)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractSessionTest.java 2009-11-30 19:40:58 UTC (rev 1370)
@@ -142,7 +142,7 @@
return graph;
}
});
- stub(repository.createSystemGraph()).toAnswer(new Answer<Graph>() {
+ stub(repository.createSystemGraph(context)).toAnswer(new Answer<Graph>() {
public Graph answer( InvocationOnMock invocation ) throws Throwable {
return graph;
}
@@ -164,7 +164,7 @@
// Set up the session attributes ...
sessionAttributes = new HashMap<String, Object>();
sessionAttributes.put("attribute1", "value1");
-
+
// Now create the workspace ...
SecurityContext mockSecurityContext = new MockSecurityContext(null,
Collections.singleton(JcrSession.DNA_WRITE_PERMISSION));
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-11-30 17:06:05 UTC (rev 1369)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrRepositoryTest.java 2009-11-30 19:40:58 UTC (rev 1370)
@@ -119,7 +119,7 @@
sourceGraph = Graph.create(source, context);
// Set up the graph that goes directly to the system source ...
- systemGraph = repository.createSystemGraph();
+ systemGraph = repository.createSystemGraph(context);
}
@After
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-11-30 17:06:05 UTC (rev 1369)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrSessionTest.java 2009-11-30 19:40:58 UTC (rev 1370)
@@ -56,7 +56,9 @@
import javax.jcr.nodetype.NodeType;
import javax.security.auth.Subject;
import javax.security.auth.login.LoginContext;
+import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.JaasSecurityContext;
+import org.jboss.dna.graph.property.NamespaceRegistry;
import org.jboss.dna.graph.property.Path;
import org.junit.After;
import org.junit.Before;
@@ -203,8 +205,9 @@
Subject subject = new Subject(false, Collections.singleton(principal), Collections.EMPTY_SET, Collections.EMPTY_SET);
LoginContext loginContext = mock(LoginContext.class);
stub(loginContext.getSubject()).toReturn(subject);
- Session session = new JcrSession(repository, workspace, context.with(new JaasSecurityContext(loginContext)),
- sessionAttributes);
+ NamespaceRegistry globalRegistry = context.getNamespaceRegistry();
+ ExecutionContext sessionContext = context.with(new JaasSecurityContext(loginContext));
+ Session session = new JcrSession(repository, workspace, sessionContext, globalRegistry, sessionAttributes);
try {
assertThat(session.getUserID(), is("name"));
} finally {
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-11-30 17:06:05 UTC (rev 1369)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrWorkspaceTest.java 2009-11-30 19:40:58 UTC (rev 1370)
@@ -117,6 +117,11 @@
}
@Test
+ public void shouldHaveSameContextIdAsSession() {
+ assertThat(workspace.context().getId(), is(session.getExecutionContext().getId()));
+ }
+
+ @Test
public void shouldProvideNamespaceRegistry() throws Exception {
NamespaceRegistry registry = workspace.getNamespaceRegistry();
assertThat(registry, is(notNullValue()));
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/WorkspaceLockManagerTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/WorkspaceLockManagerTest.java 2009-11-30 17:06:05 UTC (rev 1369)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/WorkspaceLockManagerTest.java 2009-11-30 19:40:58 UTC (rev 1370)
@@ -4,6 +4,7 @@
import static org.hamcrest.core.IsInstanceOf.instanceOf;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.stub;
import java.util.LinkedList;
import java.util.UUID;
@@ -75,7 +76,7 @@
return graph;
}
});
- stub(repository.createSystemGraph()).toAnswer(new Answer<Graph>() {
+ stub(repository.createSystemGraph(context)).toAnswer(new Answer<Graph>() {
public Graph answer( InvocationOnMock invocation ) throws Throwable {
return graph;
}
@@ -139,7 +140,9 @@
Property lockOwnerProp = propFactory.create(JcrLexicon.LOCK_OWNER, lockOwner);
Property lockIsDeepProp = propFactory.create(JcrLexicon.LOCK_IS_DEEP, isDeep);
- workspaceLockManager.lockNodeInRepository(validUuid, lockOwnerProp, lockIsDeepProp, lock, isDeep);
+ JcrSession session = mock(JcrSession.class);
+ stub(session.getExecutionContext()).toReturn(context);
+ workspaceLockManager.lockNodeInRepository(session, validUuid, lockOwnerProp, lockIsDeepProp, lock, isDeep);
assertNextRequestIsLock(validLocation, LockScope.SELF_ONLY, 0);
}
14 years, 5 months
DNA SVN: r1369 - in trunk: dna-graph and 5 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-11-30 12:06:05 -0500 (Mon, 30 Nov 2009)
New Revision: 1369
Modified:
trunk/.gitignore
trunk/dna-graph/pom.xml
trunk/dna-graph/src/main/java/org/jboss/dna/graph/query/optimize/RewriteAsRangeCriteria.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/session/GraphSession.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/xml/XmlHandler.java
trunk/dna-jcr/pom.xml
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DefinitionCache.java
Log:
DNA-561 Google Collections API compatibility issues w/ Weld/AS 6
Applied the patch and successfully ran all of the tests. Nicely done, John!
Also uploaded the Google Collections 1.0RC3 (jar,sources,javadoc) to the JBoss Maven Repository.
Modified: trunk/.gitignore
===================================================================
--- trunk/.gitignore 2009-11-29 12:25:56 UTC (rev 1368)
+++ trunk/.gitignore 2009-11-30 17:06:05 UTC (rev 1369)
@@ -41,6 +41,8 @@
/web/dna-web-jcr-rest-war/target/
/web/dna-web-jcr-rest-client/target/
+/utils/dna-jpa-ddl-gen/target/
+
/extensions/dna-classloader-maven/target
/extensions/dna-common-jdbc/target
/extensions/dna-connector-federation/target
Modified: trunk/dna-graph/pom.xml
===================================================================
--- trunk/dna-graph/pom.xml 2009-11-29 12:25:56 UTC (rev 1368)
+++ trunk/dna-graph/pom.xml 2009-11-30 17:06:05 UTC (rev 1369)
@@ -32,11 +32,11 @@
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
</dependency>
- <dependency>
- <groupId>com.google.code.google-collections</groupId>
- <artifactId>google-collect</artifactId>
- <version>snapshot-20080530</version>
- </dependency>
+ <dependency>
+ <groupId>com.google.collections</groupId>
+ <artifactId>google-collections</artifactId>
+ <version>1.0-rc3</version>
+ </dependency>
<!--
Testing (note the scope)
-->
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/query/optimize/RewriteAsRangeCriteria.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/query/optimize/RewriteAsRangeCriteria.java 2009-11-29 12:25:56 UTC (rev 1368)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/query/optimize/RewriteAsRangeCriteria.java 2009-11-30 17:06:05 UTC (rev 1369)
@@ -46,6 +46,7 @@
import org.jboss.dna.graph.query.plan.PlanNode;
import org.jboss.dna.graph.query.plan.PlanNode.Property;
import org.jboss.dna.graph.query.plan.PlanNode.Type;
+import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps;
@@ -80,7 +81,7 @@
for (PlanNode access : plan.findAllAtOrBelow(Type.ACCESS)) {
// Look for select nodes below an ACCESS node that have a single Comparison constraint,
// and accumulate them keyed by the dynamic operand ...
- Multimap<DynamicOperand, PlanNode> selectNodeByOperand = Multimaps.newArrayListMultimap();
+ Multimap<DynamicOperand, PlanNode> selectNodeByOperand = ArrayListMultimap.create();
for (PlanNode select : access.findAllAtOrBelow(Type.SELECT)) {
Constraint constraint = select.getProperty(Property.SELECT_CRITERIA, Constraint.class);
// Look for Comparison constraints that use a range operator
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/session/GraphSession.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/session/GraphSession.java 2009-11-29 12:25:56 UTC (rev 1368)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/session/GraphSession.java 2009-11-30 17:06:05 UTC (rev 1369)
@@ -66,6 +66,7 @@
import org.jboss.dna.graph.request.Request;
import org.jboss.dna.graph.session.GraphSession.Authorizer.Action;
import com.google.common.collect.ListMultimap;
+import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.Multimaps;
/**
@@ -86,7 +87,7 @@
@NotThreadSafe
public class GraphSession<Payload, PropertyPayload> {
- protected final ListMultimap<Name, Node<Payload, PropertyPayload>> NO_CHILDREN = Multimaps.immutableMultimap();
+ protected final ListMultimap<Name, Node<Payload, PropertyPayload>> NO_CHILDREN = LinkedListMultimap.create();
protected final Map<Name, PropertyInfo<PropertyPayload>> NO_PROPERTIES = Collections.emptyMap();
protected final Authorizer authorizer;
@@ -1621,7 +1622,7 @@
if (children.isEmpty()) {
childrenByName = cache.NO_CHILDREN;
} else {
- childrenByName = Multimaps.newLinkedListMultimap();
+ childrenByName = LinkedListMultimap.create();
for (Location location : children) {
NodeId id = cache.idFactory.create();
Name childName = location.getPath().getLastSegment().getName();
@@ -1699,7 +1700,7 @@
Name childName = childPath.getLastSegment().getName();
if (this.childrenByName.isEmpty()) {
// Just have to add the child ...
- this.childrenByName = Multimaps.newLinkedListMultimap();
+ this.childrenByName = LinkedListMultimap.create();
if (childPath.getLastSegment().hasIndex()) {
// The child has a SNS index, but this is an only child ...
newChild = newChild.with(cache.pathFactory.create(childPath.getParent(), childName));
@@ -1710,7 +1711,7 @@
}
// Unfortunately, there is no efficient way to insert into the multi-map, so we need to recreate it ...
- ListMultimap<Name, Node<Payload, PropertyPayload>> children = Multimaps.newLinkedListMultimap();
+ ListMultimap<Name, Node<Payload, PropertyPayload>> children = LinkedListMultimap.create();
boolean added = false;
for (Node<Payload, PropertyPayload> child : this.childrenByName.values()) {
if (!added && child.isNew()) {
@@ -1988,7 +1989,7 @@
child.remove();
// Now add the child ...
if (parent.childrenByName == cache.NO_CHILDREN) {
- parent.childrenByName = Multimaps.newLinkedListMultimap();
+ parent.childrenByName = LinkedListMultimap.create();
}
parent.childrenByName.put(newNodeName, child);
child.parent = parent;
@@ -2035,7 +2036,7 @@
parent.load();
if (parent.childrenByName == cache.NO_CHILDREN) {
- parent.childrenByName = Multimaps.newLinkedListMultimap();
+ parent.childrenByName = LinkedListMultimap.create();
}
cache.nodeOperations.preCopy(this, parent);
@@ -2101,7 +2102,7 @@
}
// Unfortunately, there is no efficient way to insert into the multi-map, so we need to recreate it ...
- ListMultimap<Name, Node<Payload, PropertyPayload>> children = Multimaps.newLinkedListMultimap();
+ ListMultimap<Name, Node<Payload, PropertyPayload>> children = LinkedListMultimap.create();
for (Node<Payload, PropertyPayload> child : childrenByName.values()) {
if (child == nodeToBeMoved) continue;
if (before != null && child.getSegment().equals(before)) {
@@ -2388,7 +2389,7 @@
Node<Payload, PropertyPayload> child = cache.createNode(this, cache.idFactory.create(), newChild);
child.markAsNew(); // marks parent as changed
if (childrenByName == cache.NO_CHILDREN) {
- childrenByName = Multimaps.newLinkedListMultimap();
+ childrenByName = LinkedListMultimap.create();
}
childrenByName.put(name, child);
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/xml/XmlHandler.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/xml/XmlHandler.java 2009-11-29 12:25:56 UTC (rev 1368)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/xml/XmlHandler.java 2009-11-30 17:06:05 UTC (rev 1369)
@@ -513,7 +513,7 @@
this.pathToParent = pathToParent;
this.name = name;
this.state = ElementEntryState.TBD;
- properties = new LinkedHashMultimap<Name, Object>();
+ properties = LinkedHashMultimap.create();
}
protected void setName( Name name ) {
Modified: trunk/dna-jcr/pom.xml
===================================================================
--- trunk/dna-jcr/pom.xml 2009-11-29 12:25:56 UTC (rev 1368)
+++ trunk/dna-jcr/pom.xml 2009-11-30 17:06:05 UTC (rev 1369)
@@ -102,11 +102,11 @@
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-jcr-tests</artifactId>
</dependency>
- <dependency>
- <groupId>com.google.code.google-collections</groupId>
- <artifactId>google-collect</artifactId>
- <version>snapshot-20080530</version>
- </dependency>
+ <dependency>
+ <groupId>com.google.collections</groupId>
+ <artifactId>google-collections</artifactId>
+ <version>1.0-rc3</version>
+ </dependency>
<dependency>
<groupId>org.jboss.security</groupId>
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DefinitionCache.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DefinitionCache.java 2009-11-29 12:25:56 UTC (rev 1368)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DefinitionCache.java 2009-11-30 17:06:05 UTC (rev 1369)
@@ -53,7 +53,7 @@
* first, followed by those of the immediate supertypes, followed by those from those supertypes' supertypes, etc.
* </p>
*/
- private final Multimap<Name, JcrNodeDefinition> childNodeDefinitionsThatAllowSns = new LinkedListMultimap<Name, JcrNodeDefinition>();
+ private final Multimap<Name, JcrNodeDefinition> childNodeDefinitionsThatAllowSns = LinkedListMultimap.create();
/**
* A local cache of all defined and inherited child node definitions, keyed by their name, that do <i>not</i> allow
* same-name-sibilings. This includes residual child node definitions, which are keyed by the
@@ -67,7 +67,7 @@
* first, followed by those of the immediate supertypes, followed by those from those supertypes' supertypes, etc.
* </p>
*/
- private final Multimap<Name, JcrNodeDefinition> childNodeDefinitionsThatAllowNoSns = new LinkedListMultimap<Name, JcrNodeDefinition>();
+ private final Multimap<Name, JcrNodeDefinition> childNodeDefinitionsThatAllowNoSns = LinkedListMultimap.create();
/**
* A local cache of all defined and inherited property definitions, keyed by their name, that allow multiple values. This
@@ -80,7 +80,7 @@
* or the multiple attribute" (Section 4.7.15 of the JSR-283 draft specification).
* </p>
*/
- private final Multimap<Name, JcrPropertyDefinition> multiValuedPropertyDefinitions = new LinkedListMultimap<Name, JcrPropertyDefinition>();
+ private final Multimap<Name, JcrPropertyDefinition> multiValuedPropertyDefinitions = LinkedListMultimap.create();
/**
* A local cache of all defined and inherited property definitions, keyed by their name, that allow single values. This
* includes residual property definitions, which are keyed by the {@link JcrNodeType#RESIDUAL_NAME}. The content of this map
@@ -92,10 +92,10 @@
* or the multiple attribute" (Section 4.7.15 of the JSR-283 draft specification).
* </p>
*/
- private final Multimap<Name, JcrPropertyDefinition> singleValuedPropertyDefinitions = new LinkedListMultimap<Name, JcrPropertyDefinition>();
+ private final Multimap<Name, JcrPropertyDefinition> singleValuedPropertyDefinitions = LinkedListMultimap.create();
- private final Multimap<Name, JcrNodeDefinition> allChildNodeDefinitions = new LinkedListMultimap<Name, JcrNodeDefinition>();
- private final Multimap<Name, JcrPropertyDefinition> allPropertyDefinitions = new LinkedListMultimap<Name, JcrPropertyDefinition>();
+ private final Multimap<Name, JcrNodeDefinition> allChildNodeDefinitions = LinkedListMultimap.create();
+ private final Multimap<Name, JcrPropertyDefinition> allPropertyDefinitions = LinkedListMultimap.create();
DefinitionCache( JcrNodeType nodeType ) {
addDefinitionsForTypeAndAllSupertypes(nodeType);
14 years, 5 months
DNA SVN: r1368 - trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa.
by dna-commits@lists.jboss.org
Author: bcarothers
Date: 2009-11-29 07:25:56 -0500 (Sun, 29 Nov 2009)
New Revision: 1368
Modified:
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaSourceTest.java
Log:
DNA-546 JCR Workspace and Session Imports Can Fail on JPA Connector
Committed test with dependency on some previous changes. This should fix the nightly integration build.
Modified: trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaSourceTest.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaSourceTest.java 2009-11-28 23:26:28 UTC (rev 1367)
+++ trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaSourceTest.java 2009-11-29 12:25:56 UTC (rev 1368)
@@ -41,7 +41,7 @@
public class JpaSourceTest {
private JpaSource source;
- private JpaConnection connection;
+ private RepositoryConnection connection;
@Before
public void beforeEach() throws Exception {
@@ -73,7 +73,7 @@
@Test
public void shouldCreateConnection() throws Exception {
- connection = (JpaConnection)source.getConnection();
+ connection = source.getConnection();
assertThat(connection, is(notNullValue()));
}
14 years, 5 months
DNA SVN: r1367 - trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa.
by dna-commits@lists.jboss.org
Author: bcarothers
Date: 2009-11-28 18:26:28 -0500 (Sat, 28 Nov 2009)
New Revision: 1367
Removed:
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/JpaConnection.java
Log:
DNA-546 JCR Workspace and Session Imports Can Fail on JPA Connector
Deleted file that had been moved.
Deleted: trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/JpaConnection.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/JpaConnection.java 2009-11-27 17:22:54 UTC (rev 1366)
+++ trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/JpaConnection.java 2009-11-28 23:26:28 UTC (rev 1367)
@@ -1,172 +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.connector.store.jpa;
-
-import java.util.UUID;
-import java.util.concurrent.TimeUnit;
-import javax.persistence.EntityManager;
-import javax.transaction.xa.XAResource;
-import org.jboss.dna.graph.ExecutionContext;
-import org.jboss.dna.graph.cache.CachePolicy;
-import org.jboss.dna.graph.connector.RepositoryConnection;
-import org.jboss.dna.graph.connector.RepositorySourceException;
-import org.jboss.dna.graph.observe.Observer;
-import org.jboss.dna.graph.request.Request;
-import org.jboss.dna.graph.request.processor.RequestProcessor;
-
-/**
- * The repository connection to JPA repository sources.
- */
-public class JpaConnection implements RepositoryConnection {
-
- private final String name;
- private final CachePolicy cachePolicy;
- private final EntityManagers entityManagers;
- private EntityManager entityManager;
- private final Model model;
- private final UUID rootNodeUuid;
- private final String nameOfDefaultWorkspace;
- private final String[] predefinedWorkspaceNames;
- private final boolean creatingWorkspacesAllowed;
- private final long largeValueMinimumSizeInBytes;
- private final boolean compressData;
- private final boolean enforceReferentialIntegrity;
- private final Observer observer;
-
- /*package*/JpaConnection( String sourceName,
- Observer observer,
- CachePolicy cachePolicy,
- EntityManagers entityManagers,
- Model model,
- UUID rootNodeUuid,
- String nameOfDefaultWorkspace,
- String[] predefinedWorkspaceNames,
- long largeValueMinimumSizeInBytes,
- boolean creatingWorkspacesAllowed,
- boolean compressData,
- boolean enforceReferentialIntegrity ) {
- assert sourceName != null;
- assert entityManagers != null;
- assert model != null;
- assert rootNodeUuid != null;
- this.observer = observer;
- this.name = sourceName;
- this.cachePolicy = cachePolicy; // may be null
- this.entityManagers = entityManagers;
- this.entityManager = entityManagers.checkout();
- assert this.entityManagers != null;
- this.model = model;
- this.rootNodeUuid = rootNodeUuid;
- this.largeValueMinimumSizeInBytes = largeValueMinimumSizeInBytes;
- this.compressData = compressData;
- this.enforceReferentialIntegrity = enforceReferentialIntegrity;
- this.nameOfDefaultWorkspace = nameOfDefaultWorkspace;
- this.predefinedWorkspaceNames = predefinedWorkspaceNames != null ? predefinedWorkspaceNames : new String[] {};
- this.creatingWorkspacesAllowed = creatingWorkspacesAllowed;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.graph.connector.RepositoryConnection#getSourceName()
- */
- public String getSourceName() {
- return name;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.graph.connector.RepositoryConnection#getDefaultCachePolicy()
- */
- public CachePolicy getDefaultCachePolicy() {
- return cachePolicy;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.graph.connector.RepositoryConnection#getXAResource()
- */
- public XAResource getXAResource() {
- return null;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.graph.connector.RepositoryConnection#ping(long, java.util.concurrent.TimeUnit)
- */
- public boolean ping( long time,
- TimeUnit unit ) {
- return entityManager != null ? entityManager.isOpen() : false;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.graph.connector.RepositoryConnection#execute(org.jboss.dna.graph.ExecutionContext,
- * org.jboss.dna.graph.request.Request)
- */
- public void execute( ExecutionContext context,
- Request request ) throws RepositorySourceException {
- long size = largeValueMinimumSizeInBytes;
- if (entityManager == null) {
- throw new RepositorySourceException(JpaConnectorI18n.connectionIsNoLongerOpen.text(name));
- }
- RequestProcessor proc = model.createRequestProcessor(name,
- context,
- observer,
- entityManager,
- rootNodeUuid,
- nameOfDefaultWorkspace,
- predefinedWorkspaceNames,
- size,
- creatingWorkspacesAllowed,
- compressData,
- enforceReferentialIntegrity);
- try {
- proc.process(request);
- } finally {
- proc.close();
- }
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.graph.connector.RepositoryConnection#close()
- */
- public void close() {
- if (entityManager != null) {
- // Do this only once ...
- try {
- entityManagers.checkin(entityManager);
- } finally {
- entityManager = null;
- }
- }
- }
-
-}
14 years, 5 months
DNA SVN: r1366 - in trunk/extensions/dna-connector-store-jpa/src: main/java/org/jboss/dna/connector/store/jpa/model/basic and 2 other directories.
by dna-commits@lists.jboss.org
Author: bcarothers
Date: 2009-11-27 12:22:54 -0500 (Fri, 27 Nov 2009)
New Revision: 1366
Added:
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/basic/BasicJpaConnection.java
Modified:
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/EntityManagers.java
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/Model.java
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/basic/BasicModel.java
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/ModelTest.java
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/basic/BasicModelTest.java
Log:
DNA-546
Committed patch (DNA-546_jpa_connector_refactor.patch) that refactors the existing JPA connector framework to more readily support the new model that I'm working on.
The patch removes the relationship between the model and the request processor and adds a relationship between the model and its connection. To work within the MapRepository framework, I had to be able to pass a reference to the MapRepository into the MapRequestProcessor. This ruled out using the existing JpaConnection. The cleanest way to isolate the reusable pieces of the code seemed to be to rename JpaConnection to BasicJpaConnection, move it into model.basic, and then replace Model.createRequestProcessor(...) with Model.createConnection(JpaSource). This required a few changes to class visibility (but not constructor visibility) and the addition of some accessors to JpaSource.
Modified: trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/EntityManagers.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/EntityManagers.java 2009-11-27 16:52:16 UTC (rev 1365)
+++ trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/EntityManagers.java 2009-11-27 17:22:54 UTC (rev 1366)
@@ -30,16 +30,17 @@
import javax.persistence.EntityManagerFactory;
import net.jcip.annotations.ThreadSafe;
import org.hibernate.ejb.Ejb3Configuration;
+import org.jboss.dna.graph.connector.RepositoryConnection;
/**
* Utility class that owns an {@link EntityManagerFactory} instance and that provides references to {@link EntityManager}
* instances while providing the ability to properly clean up all resources by closing the EntityManager and EntityManagerFactory
* objects when no longer needed.
* <p>
- * This class is instantiated by the {@link JpaSource} and passed to the {@link JpaConnection} objects, which use this class to
- * obtain an EntityManager. When the JpaConnection object is {@link JpaConnection#close() closed}, it returns the EntityManager to
- * this object. Because this class maintains a count of the EntityManager references handed out, the last EntityManager to be
- * returned will cause the EntityManagerFactory to be closed.
+ * This class is instantiated by the {@link JpaSource} and passed to the {@link RepositoryConnection} objects, which use this
+ * class to obtain an EntityManager. When the JPA connection object is {@link RepositoryConnection#close() closed}, it returns the
+ * EntityManager to this object. Because this class maintains a count of the EntityManager references handed out, the last
+ * EntityManager to be returned will cause the EntityManagerFactory to be closed.
* </p>
* <p>
* This class does put the EntityManager implementations inside a HashMap, and therefore does expect that the EntityManager uses
@@ -47,7 +48,7 @@
* </p>
*/
@ThreadSafe
-class EntityManagers {
+public class EntityManagers {
private final Ejb3Configuration configuration;
private final Map<EntityManager, AtomicInteger> referenceCounts = new HashMap<EntityManager, AtomicInteger>();
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-11-27 16:52:16 UTC (rev 1365)
+++ trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/JpaSource.java 2009-11-27 17:22:54 UTC (rev 1366)
@@ -59,7 +59,6 @@
import org.jboss.dna.graph.connector.RepositorySource;
import org.jboss.dna.graph.connector.RepositorySourceCapabilities;
import org.jboss.dna.graph.connector.RepositorySourceException;
-import org.jboss.dna.graph.observe.Observer;
/**
* The {@link RepositorySource} for the connector that stores content in a (custom) relational database. This connector uses Java
@@ -75,7 +74,8 @@
*/
public static class Models {
public static final Model BASIC = new BasicModel();
- private static final Model[] ALL_ARRAY = new Model[] {BASIC};
+ // public static final Model SIMPLE = new SimpleModel();
+ private static final Model[] ALL_ARRAY = new Model[] {BASIC /*, SIMPLE */};
private static final List<Model> MODIFIABLE_MODELS = new ArrayList<Model>(Arrays.asList(ALL_ARRAY));
public static final Collection<Model> ALL = Collections.unmodifiableCollection(MODIFIABLE_MODELS);
public static final Model DEFAULT = BASIC;
@@ -367,6 +367,24 @@
}
/**
+ * Returns the current cache policy
+ *
+ * @return the current cache policy
+ */
+ public CachePolicy getCachePolicy() {
+ return cachePolicy;
+ }
+
+ /**
+ * Returns the current {@code EntityManagers} reference.
+ *
+ * @return the current {@code EntityManagers} reference.
+ */
+ public EntityManagers getEntityManagers() {
+ return entityManagers;
+ }
+
+ /**
* @return rootNodeUuid
*/
public String getRootNodeUuid() {
@@ -374,6 +392,13 @@
}
/**
+ * @return rootUuid
+ */
+ public UUID getRootUuid() {
+ return rootUuid;
+ }
+
+ /**
* @param rootNodeUuid Sets rootNodeUuid to the specified value.
* @throws IllegalArgumentException if the string value cannot be converted to UUID
*/
@@ -812,6 +837,15 @@
}
/**
+ * Returns the current repository context for the source, as set with a call to {@link #initialize(RepositoryContext)}.
+ *
+ * @return the current repository context for the source
+ */
+ public RepositoryContext getRepositoryContext() {
+ return repositoryContext;
+ }
+
+ /**
* {@inheritDoc}
*/
public Object getObjectInstance( Object obj,
@@ -1000,10 +1034,8 @@
// Now, create another entity manager with the classes from the correct model and without changing the schema...
entityManagers = new EntityManagers(configurator);
}
- Observer observer = repositoryContext != null ? repositoryContext.getObserver() : null;
- return new JpaConnection(getName(), observer, cachePolicy, entityManagers, model, rootUuid, defaultWorkspace,
- getPredefinedWorkspaceNames(), largeValueSizeInBytes, isCreatingWorkspacesAllowed(),
- compressData, referentialIntegrityEnforced);
+
+ return model.createConnection(this);
}
/**
Modified: trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/Model.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/Model.java 2009-11-27 16:52:16 UTC (rev 1365)
+++ trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/Model.java 2009-11-27 17:22:54 UTC (rev 1366)
@@ -24,14 +24,10 @@
package org.jboss.dna.connector.store.jpa;
import java.util.Locale;
-import java.util.UUID;
-import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
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.observe.Observer;
-import org.jboss.dna.graph.request.processor.RequestProcessor;
+import org.jboss.dna.graph.connector.RepositoryConnection;
/**
* A descriptor of a schema used by this connector.
@@ -76,17 +72,7 @@
return description.text(locale);
}
- public abstract RequestProcessor createRequestProcessor( String sourceName,
- ExecutionContext context,
- Observer observer,
- EntityManager entityManager,
- UUID rootNodeUuid,
- String nameOfDefaultWorkspace,
- String[] predefinedWorkspaceNames,
- long largeValueMinimumSizeInBytes,
- boolean creatingWorkspacesAllowed,
- boolean comparessData,
- boolean enforceReferentialIntegrity );
+ public abstract RepositoryConnection createConnection( JpaSource source );
/**
* Configure the entity class that will be used by JPA to store information in the database.
Added: trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/basic/BasicJpaConnection.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/basic/BasicJpaConnection.java (rev 0)
+++ trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/basic/BasicJpaConnection.java 2009-11-27 17:22:54 UTC (rev 1366)
@@ -0,0 +1,163 @@
+/*
+ * 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.connector.store.jpa.model.basic;
+
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
+import javax.persistence.EntityManager;
+import javax.transaction.xa.XAResource;
+import org.jboss.dna.connector.store.jpa.EntityManagers;
+import org.jboss.dna.connector.store.jpa.JpaConnectorI18n;
+import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.cache.CachePolicy;
+import org.jboss.dna.graph.connector.RepositoryConnection;
+import org.jboss.dna.graph.connector.RepositorySourceException;
+import org.jboss.dna.graph.observe.Observer;
+import org.jboss.dna.graph.request.Request;
+import org.jboss.dna.graph.request.processor.RequestProcessor;
+
+/**
+ * The repository connection to JPA repository sources.
+ */
+class BasicJpaConnection implements RepositoryConnection {
+
+ private final String name;
+ private final CachePolicy cachePolicy;
+ private final EntityManagers entityManagers;
+ private EntityManager entityManager;
+ private final UUID rootNodeUuid;
+ private final String nameOfDefaultWorkspace;
+ private final String[] predefinedWorkspaceNames;
+ private final boolean creatingWorkspacesAllowed;
+ private final long largeValueMinimumSizeInBytes;
+ private final boolean compressData;
+ private final boolean enforceReferentialIntegrity;
+ private final Observer observer;
+
+ public BasicJpaConnection( String sourceName,
+ Observer observer,
+ CachePolicy cachePolicy,
+ EntityManagers entityManagers,
+ UUID rootNodeUuid,
+ String nameOfDefaultWorkspace,
+ String[] predefinedWorkspaceNames,
+ long largeValueMinimumSizeInBytes,
+ boolean creatingWorkspacesAllowed,
+ boolean compressData,
+ boolean enforceReferentialIntegrity ) {
+ assert sourceName != null;
+ assert entityManagers != null;
+ assert rootNodeUuid != null;
+ this.observer = observer;
+ this.name = sourceName;
+ this.cachePolicy = cachePolicy; // may be null
+ this.entityManagers = entityManagers;
+ this.entityManager = entityManagers.checkout();
+ assert this.entityManagers != null;
+ this.rootNodeUuid = rootNodeUuid;
+ this.largeValueMinimumSizeInBytes = largeValueMinimumSizeInBytes;
+ this.compressData = compressData;
+ this.enforceReferentialIntegrity = enforceReferentialIntegrity;
+ this.nameOfDefaultWorkspace = nameOfDefaultWorkspace;
+ this.predefinedWorkspaceNames = predefinedWorkspaceNames != null ? predefinedWorkspaceNames : new String[] {};
+ this.creatingWorkspacesAllowed = creatingWorkspacesAllowed;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.connector.RepositoryConnection#getSourceName()
+ */
+ public String getSourceName() {
+ return name;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.connector.RepositoryConnection#getDefaultCachePolicy()
+ */
+ public CachePolicy getDefaultCachePolicy() {
+ return cachePolicy;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.connector.RepositoryConnection#getXAResource()
+ */
+ public XAResource getXAResource() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.connector.RepositoryConnection#ping(long, java.util.concurrent.TimeUnit)
+ */
+ public boolean ping( long time,
+ TimeUnit unit ) {
+ return entityManager != null ? entityManager.isOpen() : false;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.connector.RepositoryConnection#execute(org.jboss.dna.graph.ExecutionContext,
+ * org.jboss.dna.graph.request.Request)
+ */
+ public void execute( ExecutionContext context,
+ Request request ) throws RepositorySourceException {
+ if (entityManager == null) {
+ throw new RepositorySourceException(JpaConnectorI18n.connectionIsNoLongerOpen.text(name));
+ }
+
+ RequestProcessor proc = new BasicRequestProcessor(name, context, observer, entityManager, rootNodeUuid,
+ nameOfDefaultWorkspace, predefinedWorkspaceNames,
+ largeValueMinimumSizeInBytes, creatingWorkspacesAllowed, compressData,
+ enforceReferentialIntegrity);
+ try {
+ proc.process(request);
+ } finally {
+ proc.close();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.connector.RepositoryConnection#close()
+ */
+ public void close() {
+ if (entityManager != null) {
+ // Do this only once ...
+ try {
+ entityManagers.checkin(entityManager);
+ } finally {
+ entityManager = null;
+ }
+ }
+ }
+
+}
Property changes on: trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/basic/BasicJpaConnection.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/basic/BasicModel.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/basic/BasicModel.java 2009-11-27 16:52:16 UTC (rev 1365)
+++ trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/basic/BasicModel.java 2009-11-27 17:22:54 UTC (rev 1366)
@@ -23,21 +23,20 @@
*/
package org.jboss.dna.connector.store.jpa.model.basic;
-import java.util.UUID;
-import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.jboss.dna.connector.store.jpa.JpaConnectorI18n;
+import org.jboss.dna.connector.store.jpa.JpaSource;
import org.jboss.dna.connector.store.jpa.Model;
import org.jboss.dna.connector.store.jpa.model.common.ChangeLogEntity;
import org.jboss.dna.connector.store.jpa.model.common.NamespaceEntity;
import org.jboss.dna.connector.store.jpa.model.common.WorkspaceEntity;
-import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.connector.RepositoryConnection;
+import org.jboss.dna.graph.connector.RepositoryContext;
import org.jboss.dna.graph.observe.Observer;
import org.jboss.dna.graph.request.CopyBranchRequest;
import org.jboss.dna.graph.request.DeleteBranchRequest;
import org.jboss.dna.graph.request.MoveBranchRequest;
import org.jboss.dna.graph.request.ReadBranchRequest;
-import org.jboss.dna.graph.request.processor.RequestProcessor;
/**
* Database model that stores node properties as opaque records and children as transparent records. Large property values are
@@ -98,29 +97,6 @@
}
/**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.connector.store.jpa.Model#createRequestProcessor(String, ExecutionContext, Observer, EntityManager,
- * UUID, String, String[], long, boolean, boolean, boolean)
- */
- @Override
- public RequestProcessor createRequestProcessor( String sourceName,
- ExecutionContext context,
- Observer observer,
- EntityManager entityManager,
- UUID rootNodeUuid,
- String nameOfDefaultWorkspace,
- String[] predefinedWorkspaceNames,
- long largeValueMinimumSizeInBytes,
- boolean creatingWorkspacesAllowed,
- boolean compressData,
- boolean enforceReferentialIntegrity ) {
- return new BasicRequestProcessor(sourceName, context, observer, entityManager, rootNodeUuid, nameOfDefaultWorkspace,
- predefinedWorkspaceNames, largeValueMinimumSizeInBytes, creatingWorkspacesAllowed,
- compressData, enforceReferentialIntegrity);
- }
-
- /**
* Configure the entity class that will be used by JPA to store information in the database.
*
* @param configurator the Hibernate {@link Ejb3Configuration} component; never null
@@ -148,4 +124,15 @@
// "read-write, RegionName");
}
+ @Override
+ public RepositoryConnection createConnection( JpaSource source ) {
+ RepositoryContext repositoryContext = source.getRepositoryContext();
+ Observer observer = repositoryContext != null ? repositoryContext.getObserver() : null;
+ return new BasicJpaConnection(getName(), observer, source.getCachePolicy(), source.getEntityManagers(),
+ source.getRootUuid(),
+ source.getDefaultWorkspaceName(), source.getPredefinedWorkspaceNames(),
+ source.getLargeValueSizeInBytes(), source.isCreatingWorkspacesAllowed(),
+ source.isCompressData(), source.isReferentialIntegrityEnforced());
+ }
+
}
Modified: trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/ModelTest.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/ModelTest.java 2009-11-27 16:52:16 UTC (rev 1365)
+++ trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/ModelTest.java 2009-11-27 17:22:54 UTC (rev 1366)
@@ -26,13 +26,9 @@
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNot.not;
import static org.junit.Assert.assertThat;
-import java.util.UUID;
-import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.jboss.dna.common.i18n.I18n;
-import org.jboss.dna.graph.ExecutionContext;
-import org.jboss.dna.graph.observe.Observer;
-import org.jboss.dna.graph.request.processor.RequestProcessor;
+import org.jboss.dna.graph.connector.RepositoryConnection;
import org.junit.Before;
import org.junit.Test;
import org.mockito.MockitoAnnotations;
@@ -50,7 +46,7 @@
private Model model2;
private Model model3;
@Mock
- private RequestProcessor requestProcessor;
+ private RepositoryConnection connection;
@Before
public void beforeEach() throws Exception {
@@ -104,20 +100,10 @@
public void configure( Ejb3Configuration configurator ) {
}
- @SuppressWarnings( "synthetic-access" )
@Override
- public RequestProcessor createRequestProcessor( String sourceName,
- ExecutionContext context,
- Observer observer,
- EntityManager entityManager,
- UUID rootNodeUuid,
- String nameOfDefaultWorkspace,
- String[] predefinedWorkspaceNames,
- long largeValueMinimumSizeInBytes,
- boolean createWorkspacesAllowed,
- boolean compressData,
- boolean enforceReferentialIntegrity ) {
- return requestProcessor;
+ public RepositoryConnection createConnection( JpaSource source ) {
+ return connection;
}
+
}
}
Modified: trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/basic/BasicModelTest.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/basic/BasicModelTest.java 2009-11-27 16:52:16 UTC (rev 1365)
+++ trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/basic/BasicModelTest.java 2009-11-27 17:22:54 UTC (rev 1366)
@@ -39,11 +39,12 @@
import org.hibernate.ejb.Ejb3Configuration;
import org.jboss.dna.common.util.SecureHash;
import org.jboss.dna.common.util.StringUtil;
+import org.jboss.dna.connector.store.jpa.EntityManagers;
import org.jboss.dna.connector.store.jpa.JpaConnectorI18n;
+import org.jboss.dna.connector.store.jpa.JpaSource;
import org.jboss.dna.connector.store.jpa.model.common.NamespaceEntity;
-import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.connector.RepositoryConnection;
import org.jboss.dna.graph.property.PropertyType;
-import org.jboss.dna.graph.request.processor.RequestProcessor;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -62,7 +63,6 @@
private EntityManagerFactory factory;
private EntityManager manager;
private BasicModel model;
- private ExecutionContext context;
@BeforeClass
public static void beforeAll() throws Exception {
@@ -71,7 +71,6 @@
@Before
public void beforeEach() throws Exception {
model = new BasicModel();
- context = new ExecutionContext();
}
@After
@@ -122,22 +121,22 @@
}
@Test
- public void shouldCreateRequestProcessor() {
+ public void shouldCreateConnection() {
EntityManager manager = mock(EntityManager.class);
EntityTransaction txn = mock(EntityTransaction.class);
+ EntityManagers managers = mock(EntityManagers.class);
+ JpaSource source = mock(JpaSource.class);
+
stub(manager.getTransaction()).toReturn(txn);
- RequestProcessor proc = model.createRequestProcessor("test source",
- context,
- null,
- manager,
- UUID.randomUUID(),
- "default workspace",
- new String[] {"default workspace", "workspace1"},
- 100,
- true,
- false,
- false);
- assertThat(proc, is(notNullValue()));
+
+ stub(managers.checkout()).toReturn(manager);
+
+ stub(source.getRootUuid()).toReturn(UUID.randomUUID());
+ stub(source.getEntityManagers()).toReturn(managers);
+
+ RepositoryConnection conn = model.createConnection(source);
+
+ assertThat(conn, is(notNullValue()));
}
@Test
14 years, 5 months
DNA SVN: r1365 - in trunk: docs/reference/src/main/docbook/en-US/content/connectors and 16 other directories.
by dna-commits@lists.jboss.org
Author: bcarothers
Date: 2009-11-27 11:52:16 -0500 (Fri, 27 Nov 2009)
New Revision: 1365
Added:
trunk/utils/dna-jpa-ddl-gen/
trunk/utils/dna-jpa-ddl-gen/.classpath
trunk/utils/dna-jpa-ddl-gen/.project
trunk/utils/dna-jpa-ddl-gen/pom.xml
trunk/utils/dna-jpa-ddl-gen/src/
trunk/utils/dna-jpa-ddl-gen/src/main/
trunk/utils/dna-jpa-ddl-gen/src/main/java/
trunk/utils/dna-jpa-ddl-gen/src/main/java/org/
trunk/utils/dna-jpa-ddl-gen/src/main/java/org/jboss/
trunk/utils/dna-jpa-ddl-gen/src/main/java/org/jboss/dna/
trunk/utils/dna-jpa-ddl-gen/src/main/java/org/jboss/dna/util/
trunk/utils/dna-jpa-ddl-gen/src/main/java/org/jboss/dna/util/SchemaGen.java
trunk/utils/dna-jpa-ddl-gen/src/main/resources/
trunk/utils/dna-jpa-ddl-gen/src/main/resources/log4j.properties
trunk/utils/dna-jpa-ddl-gen/src/test/
trunk/utils/dna-jpa-ddl-gen/src/test/java/
trunk/utils/dna-jpa-ddl-gen/src/test/java/org/
trunk/utils/dna-jpa-ddl-gen/src/test/java/org/jboss/
trunk/utils/dna-jpa-ddl-gen/src/test/java/org/jboss/dna/
trunk/utils/dna-jpa-ddl-gen/src/test/java/org/jboss/dna/util/
trunk/utils/dna-jpa-ddl-gen/src/test/java/org/jboss/dna/util/SchemaGenTest.java
Modified:
trunk/docs/reference/src/main/docbook/en-US/content/connectors/jdbc_storage.xml
trunk/pom.xml
Log:
DNA-511 The JPA Source should provide a way of producing the DDL for the database dialect
Committed new version of previous patch that adds comments, documentation, and more tolerance for variations on the dialect parameter.
Modified: trunk/docs/reference/src/main/docbook/en-US/content/connectors/jdbc_storage.xml
===================================================================
--- trunk/docs/reference/src/main/docbook/en-US/content/connectors/jdbc_storage.xml 2009-11-27 03:08:49 UTC (rev 1364)
+++ trunk/docs/reference/src/main/docbook/en-US/content/connectors/jdbc_storage.xml 2009-11-27 16:52:16 UTC (rev 1365)
@@ -263,6 +263,25 @@
Of course, setting other more advanced properties would entail calling <code>setProperty(...)</code> for each. Since almost all
of the properties have acceptable default values, however, we don't need to set very many of them.
</para>
+ <para>
+ DNA users who prefer not to give DDL privileges to the DNA database user for this connector can use the DNA JPA DDL generation
+ tool to create the proper DDL files for their database dialect. This tool is packaged as an executable jar in the
+ utils/dna-jpa-ddl-gen subproject and can be executed with the following syntax:
+ </para>
+<programlisting>
+java -jar <jar_name> -dialect <dialect name> -model <model_name> [-out <path to output directory>]
+</programlisting>
+ <para>
+ The dialect and model parameters should match the value of the <code>dialect</code> and <code>model</code> properties specified for the
+ JPA connector.
+ </para>
+ <para>
+ Running this executable will create two files in the output directory (or the current directory if no output directory
+ was specified): create.dna-jpa-connector.ddl and drop.dna-jpa-connector.ddl. The former contains the DDL to create or replace the tables,
+ foreign keys, indices, and sequences needed by the JPA connector and the latter containts the DDL to drop any tables, foreign keys, indices, and
+ sequences needed by the JPA connector.
+ </para>
+
<sect2>
<title>Basic Model</title>
<para>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-11-27 03:08:49 UTC (rev 1364)
+++ trunk/pom.xml 2009-11-27 16:52:16 UTC (rev 1365)
@@ -145,6 +145,7 @@
<module>web/dna-web-jcr-rest</module>
<module>web/dna-web-jcr-rest-client</module>
<module>web/dna-web-jcr-rest-war</module>
+ <module>utils/dna-jpa-ddl-gen</module>
</modules>
<properties>
<!-- These are properties used in the database profiles. Must initialize them to be empty so that Maven applies
Added: trunk/utils/dna-jpa-ddl-gen/.classpath
===================================================================
--- trunk/utils/dna-jpa-ddl-gen/.classpath (rev 0)
+++ trunk/utils/dna-jpa-ddl-gen/.classpath 2009-11-27 16:52:16 UTC (rev 1365)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="target/classes" path="src/main/java"/>
+ <classpathentry kind="src" path="src/test/java"/>
+ <classpathentry kind="src" path="src/main/resources"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
Added: trunk/utils/dna-jpa-ddl-gen/.project
===================================================================
--- trunk/utils/dna-jpa-ddl-gen/.project (rev 0)
+++ trunk/utils/dna-jpa-ddl-gen/.project 2009-11-27 16:52:16 UTC (rev 1365)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>dna-jpa-ddl-gen</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
+ </natures>
+</projectDescription>
Added: trunk/utils/dna-jpa-ddl-gen/pom.xml
===================================================================
--- trunk/utils/dna-jpa-ddl-gen/pom.xml (rev 0)
+++ trunk/utils/dna-jpa-ddl-gen/pom.xml 2009-11-27 16:52:16 UTC (rev 1365)
@@ -0,0 +1,111 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.jboss.dna</groupId>
+ <artifactId>dna</artifactId>
+ <version>0.7-SNAPSHOT</version>
+ <relativePath>../..</relativePath>
+ </parent>
+ <!-- The groupId and version values are inherited from parent -->
+ <artifactId>dna-jpa-ddl-gen</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss JPA Connector DDL Generator</name>
+ <description>
+ Utility application to generate ddl for JBoss DNA JPA connector
+ </description>
+ <url>http://labs.jboss.org/dna</url>
+ <!--
+ Define the dependencies. Note that all version and scopes default to
+ those defined in the dependencyManagement section of the parent pom.
+ -->
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <descriptorRefs>
+ <descriptorRef>jar-with-dependencies</descriptorRef>
+ </descriptorRefs>
+ <archive>
+ <manifest>
+ <addClasspath>true</addClasspath>
+ <mainClass>org.jboss.dna.util.SchemaGen</mainClass>
+ </manifest>
+ </archive>
+ </configuration>
+ <executions>
+ <execution>
+ <id>make-my-jar-with-dependencies</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <!--
+ Common
+ -->
+ <dependency>
+ <groupId>org.jboss.dna</groupId>
+ <artifactId>dna-connector-store-jpa</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-tools</artifactId>
+ <version>3.2.4.GA</version>
+ </dependency>
+ <!--
+ Testing (note the scope)
+ -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-library</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ Logging (require SLF4J API for compiling, but use Log4J and its SLF4J
+ binding for testing)
+ -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <!-- This defaults to test scope; needs to be compile scope to be in executable JAR -->
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <!-- This defaults to test scope; needs to be compile scope to be in executable JAR -->
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-report-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </reporting>
+</project>
\ No newline at end of file
Property changes on: trunk/utils/dna-jpa-ddl-gen/pom.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/utils/dna-jpa-ddl-gen/src/main/java/org/jboss/dna/util/SchemaGen.java
===================================================================
--- trunk/utils/dna-jpa-ddl-gen/src/main/java/org/jboss/dna/util/SchemaGen.java (rev 0)
+++ trunk/utils/dna-jpa-ddl-gen/src/main/java/org/jboss/dna/util/SchemaGen.java 2009-11-27 16:52:16 UTC (rev 1365)
@@ -0,0 +1,128 @@
+package org.jboss.dna.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Properties;
+import org.hibernate.cfg.Environment;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.ejb.Ejb3Configuration;
+import org.hibernate.tool.hbm2ddl.SchemaExport;
+import org.jboss.dna.connector.store.jpa.JpaSource;
+import org.jboss.dna.connector.store.jpa.Model;
+
+/**
+ * Main class to generate DDL that can be used to build the schema for the {@link JpaSource JPA connector}. The class is intended
+ * to be bundled into an executable jar file and invoked with the following syntax:
+ *
+ * <pre>
+ * java -jar <jar_name> -dialect <dialect name> -model <model_name> [-out <path to output directory>]
+ * Example: java -jar dna-jpa-ddl-gen-0.7-jar-with-dependencies.jar -dialect HSQL -model Basic -out /tmp
+ * </pre>
+ */
+public class SchemaGen {
+
+ public static final String CREATE_FILE_NAME = "create.dna-jpa-connector.ddl";
+ public static final String DROP_FILE_NAME = "drop.dna-jpa-connector.ddl";
+
+ private final Dialect dialect;
+ private final Model model;
+ private final File outputPath;
+
+ public SchemaGen( String dialect,
+ String model,
+ File outputPath ) {
+
+ this.dialect = dialectFor(dialect);
+ this.model = JpaSource.Models.getModel(model);
+ this.outputPath = outputPath;
+ }
+
+ /**
+ * Returns the {@link Dialect Hibernate dialect} that corresponds to the provided name.
+ * <p>
+ * This method will tolerate certain kinds of abbreviations for the dialect. Since all Hibernate dialects have a name equal to
+ * their fully-qualified name, all valid dialect names start with "org.hibernate.dialect.". If the given {@code
+ * dialectName} does not begin with this string, this string will be prepended.
+ * </p>
+ * <p>
+ * Additionally, all Hibernate dialect names end in "Dialect". If the given dialect name does not end with
+ * "Dialect", this will be appended to the dialect name before the Hibernate dialect is looked up.
+ * </p>
+ * <p>
+ * The net effect of these rules is that callers wishing to retrieve a dialect (e.g., org.hibernate.dialect.HSQLDialect) can
+ * specify the dialect as "org.hibernate.dialect.HSQLDialect", "HSQLDialect", "org.hibernate.dialect.HSQL", or just "HSQL".
+ * </p>
+ *
+ * @param dialectName the name of the {@code Dialect} to return
+ * @return the {@link Dialect Hibernate dialect} that corresponds to the provided name.
+ */
+ private Dialect dialectFor( String dialectName ) {
+ Properties props = new Properties();
+
+ if (!dialectName.endsWith("Dialect")) dialectName += "Dialect";
+ if (!dialectName.startsWith("org.hibernate.dialect.")) dialectName = "org.hibernate.dialect." + dialectName;
+
+ props.put(Environment.DIALECT, dialectName);
+
+ return Dialect.getDialect(props);
+ }
+
+ /**
+ * Writes {@link SchemaExport#create(boolean, boolean) create} and {@link SchemaExport#drop(boolean, boolean) drop} DDL files
+ * to the given {@link #outputPath output directory} or the current directory if no output directory was provided.
+ *
+ * @throws IOException
+ */
+ void generate() throws IOException {
+ Ejb3Configuration configurator = new Ejb3Configuration();
+ configurator.setProperty(Environment.DIALECT, dialect.toString());
+ model.configure(configurator);
+ // cfg.setProperties(properties);
+ SchemaExport export = new SchemaExport(configurator.getHibernateConfiguration());
+ export.setOutputFile(new File(outputPath, CREATE_FILE_NAME).getCanonicalPath());
+ export.create(false, false);
+
+ export.setOutputFile(new File(outputPath, DROP_FILE_NAME).getCanonicalPath());
+ export.drop(false, false);
+ }
+
+ public static final String USAGE = "java -jar <jar_name> -dialect <dialect name> -model <model_name> [-out <path to output directory>]\n"
+ + "\tExample: java -jar dna-jpa-ddl-gen-0.7-jar-with-dependencies.jar -dialect HSQL -model Basic -out /tmp";
+
+ public static void main( String[] args ) throws IOException {
+ String modelName = null;
+ String dialectName = null;
+ File outputFile = new File(".");
+
+ int i = 0;
+ while (i < args.length) {
+ if ("-dialect".equals(args[i])) {
+ if (i == args.length - 1) printUsage();
+ dialectName = args[++i];
+ } else if ("-model".equals(args[i])) {
+ if (i == args.length - 1) printUsage();
+ modelName = args[++i];
+ } else if ("-out".equals(args[i])) {
+ if (i == args.length - 1) printUsage();
+ outputFile = new File(args[++i]);
+ } else if ("-help".equals(args[i]) || "-?".equals(args[i])) {
+ printUsage();
+ }
+ i++;
+ }
+
+ if (modelName == null || dialectName == null) printUsage();
+
+ SchemaGen main = new SchemaGen(dialectName, modelName, outputFile);
+ main.generate();
+ }
+
+ /**
+ * Print the usage message and exit with a non-zero return code.
+ */
+ private static void printUsage() {
+ System.err.println(USAGE);
+ System.exit(1);
+ }
+
+}
Property changes on: trunk/utils/dna-jpa-ddl-gen/src/main/java/org/jboss/dna/util/SchemaGen.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/utils/dna-jpa-ddl-gen/src/main/resources/log4j.properties
===================================================================
--- trunk/utils/dna-jpa-ddl-gen/src/main/resources/log4j.properties (rev 0)
+++ trunk/utils/dna-jpa-ddl-gen/src/main/resources/log4j.properties 2009-11-27 16:52:16 UTC (rev 1365)
@@ -0,0 +1,20 @@
+# Direct log messages to stdout
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %m%n
+
+# Root logger option
+log4j.rootLogger=INFO, stdout
+
+# Set up the default logging to be INFO level, then override specific units
+log4j.logger.org.jboss.dna=INFO
+log4j.logger.org.junit=DEBUG
+# log4j.logger.org.jboss.dna.tests.integration.jackrabbit.JackrabbitMySqlStressTest=DEBUG
+log4j.logger.org.hibernate=WARN, stdout
+
+
+# Jackrabbit logging
+log4j.logger.org.apache.jackrabbit=WARN, stdout
+log4j.logger.org.apache.derby=INFO, stdout
+
Added: trunk/utils/dna-jpa-ddl-gen/src/test/java/org/jboss/dna/util/SchemaGenTest.java
===================================================================
--- trunk/utils/dna-jpa-ddl-gen/src/test/java/org/jboss/dna/util/SchemaGenTest.java (rev 0)
+++ trunk/utils/dna-jpa-ddl-gen/src/test/java/org/jboss/dna/util/SchemaGenTest.java 2009-11-27 16:52:16 UTC (rev 1365)
@@ -0,0 +1,66 @@
+package org.jboss.dna.util;
+
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+import java.io.File;
+import java.io.IOException;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.Test;
+
+public class SchemaGenTest {
+
+ private static final File outputPath = new File("target");
+
+ @Before
+ public void beforeEach() {
+ cleanFiles();
+ }
+
+ @AfterClass
+ // Run this after the last test to keep the target directory clean
+ public static void cleanFiles() {
+ new File(outputPath, SchemaGen.CREATE_FILE_NAME).delete();
+ new File(outputPath, SchemaGen.DROP_FILE_NAME).delete();
+ }
+
+ private void checkFiles() {
+ File createFile = new File(outputPath, SchemaGen.CREATE_FILE_NAME);
+ assertThat(createFile.exists(), is(true));
+ assertThat(createFile.length(), greaterThan(0L));
+
+ File dropFile = new File(outputPath, SchemaGen.DROP_FILE_NAME);
+ assertThat(dropFile.exists(), is(true));
+ assertThat(dropFile.length(), greaterThan(0L));
+ }
+
+ @Test
+ public void shouldCreateSchemaForHSqlDialect() throws IOException {
+ SchemaGen main = new SchemaGen("org.hibernate.dialect.HSQLDialect", "Basic", outputPath);
+ main.generate();
+ checkFiles();
+ }
+
+ @Test
+ public void shouldCreateSchemaForOracleDialect() throws IOException {
+ SchemaGen main = new SchemaGen("org.hibernate.dialect.Oracle10gDialect", "Basic", outputPath);
+ main.generate();
+ checkFiles();
+ }
+
+ @Test
+ public void shouldCreateSchemaForDialectThatIsNotFullyQualified() throws IOException {
+ SchemaGen main = new SchemaGen("HSQLDialect", "Basic", outputPath);
+ main.generate();
+ checkFiles();
+ }
+
+ @Test
+ public void shouldCreateSchemaForShortFormDialect() throws IOException {
+ SchemaGen main = new SchemaGen("HSQL", "Basic", outputPath);
+ main.generate();
+ checkFiles();
+ }
+
+}
Property changes on: trunk/utils/dna-jpa-ddl-gen/src/test/java/org/jboss/dna/util/SchemaGenTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
14 years, 5 months
DNA SVN: r1364 - in trunk/utils/dna-jcr-gen: src/main/java/org/jboss/dna/jcr/gen and 2 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-11-26 22:08:49 -0500 (Thu, 26 Nov 2009)
New Revision: 1364
Removed:
trunk/utils/dna-jcr-gen/benerator-0.5.9-SR1.xsd
trunk/utils/dna-jcr-gen/pom.xml
trunk/utils/dna-jcr-gen/readme.txt
trunk/utils/dna-jcr-gen/src/main/java/org/jboss/dna/jcr/gen/JCRDataMassGen.java
trunk/utils/dna-jcr-gen/src/main/resources/benerator-0.5.9-SR1.xsd
trunk/utils/dna-jcr-gen/src/main/resources/log4j.properties
trunk/utils/dna-jcr-gen/src/test/resources/benerator/bank.properties
trunk/utils/dna-jcr-gen/src/test/resources/benerator/benerator.xml
Log:
DNA-560 Removed the 'dna-jcr-gen' project because of licensing concerns.
Deleted: trunk/utils/dna-jcr-gen/benerator-0.5.9-SR1.xsd
===================================================================
--- trunk/utils/dna-jcr-gen/benerator-0.5.9-SR1.xsd 2009-11-27 02:26:23 UTC (rev 1363)
+++ trunk/utils/dna-jcr-gen/benerator-0.5.9-SR1.xsd 2009-11-27 03:08:49 UTC (rev 1364)
@@ -1,372 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
- targetNamespace="http://databene.org/benerator/0.5.9-SR1"
- xmlns="http://databene.org/benerator/0.5.9-SR1"
- elementFormDefault="qualified">
-
- <xs:annotation>
- <xs:documentation>The benerator schema describes the generation setup for benerator.</xs:documentation>
- <xs:appinfo/>
- </xs:annotation>
-
- <xs:simpleType name="script-expression-type">
- <xs:restriction base="xs:string">
- <xs:pattern value="\{.*\}"/>
- </xs:restriction>
- </xs:simpleType>
-
- <xs:simpleType name="errorhandler-type">
- <xs:union>
- <xs:simpleType>
- <xs:restriction base="xs:string">
- <xs:enumeration value="fatal"/>
- <xs:enumeration value="error"/>
- <xs:enumeration value="warn"/>
- <xs:enumeration value="info"/>
- <xs:enumeration value="debug"/>
- <xs:enumeration value="trace"/>
- <xs:enumeration value="ignore"/>
- </xs:restriction>
- </xs:simpleType>
- <xs:simpleType>
- <xs:restriction base="script-expression-type"/>
- </xs:simpleType>
- </xs:union>
- </xs:simpleType>
-
-
- <!-- The document root, it can list beans, create-entities and run-tasks in arbitrary order. -->
- <xs:element name="setup">
- <xs:complexType>
- <xs:sequence minOccurs="0" maxOccurs="unbounded">
- <xs:element ref="comment" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="import" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="include" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="property" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="database" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="bean" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="defaultAttributes" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="create-entities" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="update-entities" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="run-task" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="execute" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="evaluate" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="echo" minOccurs="0" maxOccurs="unbounded"/>
- </xs:sequence>
- <xs:attribute name="default-script" type="xs:string"/> <!-- deprecated -->
- <xs:attribute name="default-null" type="xs:string"/> <!-- deprecated -->
- <xs:attribute name="defaultScript" type="xs:string"/>
- <xs:attribute name="defaultNull" type="xs:string"/>
- <xs:attribute name="defaultEncoding" type="xs:string"/>
- <xs:attribute name="defaultLineSeparator" type="xs:string"/>
- <xs:attribute name="defaultLocale" type="xs:string"/>
- <xs:attribute name="defaultDataset" type="xs:string"/>
- <xs:attribute name="defaultPagesize" type="xs:string"/>
- <xs:attribute name="defaultSeparator" type="xs:string"/>
- <xs:attribute name="defaultErrorHandler" type="errorhandler-type"/>
- <xs:attribute name="maxCount" type="xs:string"/>
- </xs:complexType>
- </xs:element>
-
- <xs:element name="comment" type="xs:string" />
-
- <!-- Imports classes. -->
- <xs:element name="import">
- <xs:complexType>
- <xs:attribute name="class" type="xs:string"/>
- <xs:attribute name="domain" type="xs:string"/>
- <xs:attribute name="defaults" type="xs:string"/>
- </xs:complexType>
- </xs:element>
-
- <!-- Includes a properties file. -->
- <xs:element name="include">
- <xs:complexType>
- <xs:attribute name="uri" type="xs:string" use="required"/>
- </xs:complexType>
- </xs:element>
-
- <!-- Outputs a message to the console. -->
- <xs:element name="echo">
- <xs:complexType>
- <xs:attribute name="message" type="xs:string" use="required"/>
- </xs:complexType>
- </xs:element>
-
- <!-- Instantiates a JavaBean of the given class.
- If the 'id' is set, the bean is put into the context with that name.
- If the JavaBean itself has a property named 'id', this one is set to the value specified here. -->
- <xs:element name="bean">
- <xs:complexType>
- <xs:sequence minOccurs="0" maxOccurs="unbounded">
- <xs:element ref="comment" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="property" minOccurs="0" maxOccurs="unbounded"/>
- </xs:sequence>
- <xs:attribute name="id" type="xs:string" use="required"/>
- <xs:attribute name="class" type="xs:string"/>
- <xs:attribute name="spec" type="xs:string"/>
- </xs:complexType>
- </xs:element>
-
- <!-- connects to a database -->
- <xs:element name="database">
- <xs:complexType>
- <xs:attribute name="id" type="xs:string" use="required"/>
- <xs:attribute name="url" type="xs:string"/>
- <xs:attribute name="driver" type="xs:string"/>
- <xs:attribute name="user" type="xs:string"/>
- <xs:attribute name="schema" type="xs:string"/>
- <xs:attribute name="password" type="xs:string"/>
- <xs:attribute name="batch" type="xs:string"/>
- <xs:attribute name="fetchSize" type="xs:string"/>
- <xs:attribute name="readOnly" type="xs:string"/>
- </xs:complexType>
- </xs:element>
-
- <xs:complexType name="execute-type">
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute name="uri" type="xs:string"/>
- <xs:attribute name="encoding" type="xs:string"/>
- <xs:attribute name="target" type="xs:string"/>
- <xs:attribute name="type" type="xs:string"/>
- <xs:attribute name="onError" type="errorhandler-type"/>
- <xs:attribute name="optimize" type="xs:string"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
-
- <!-- executes a script, e.g. SQL -->
- <xs:element name="execute" />
-
- <!-- evaluates a script, e.g. SQL -->
- <xs:element name="evaluate">
- <xs:complexType>
- <xs:simpleContent>
- <xs:extension base="execute-type">
- <xs:attribute name="assert" type="xs:string"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- </xs:element>
-
- <!-- Declares a JavaBean to be used as consumer, either by referencing an object from the context (ref)
- or by instantiating a JavaBean like with the <bean> tag. -->
- <xs:element name="consumer">
- <xs:complexType>
- <xs:sequence minOccurs="1" maxOccurs="unbounded">
- <xs:element ref="comment" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="property" minOccurs="0" maxOccurs="unbounded"/>
- </xs:sequence>
- <xs:attribute name="id" type="xs:string"/>
- <xs:attribute name="class" type="xs:string"/>
- <xs:attribute name="ref" type="xs:string"/>
- </xs:complexType>
- </xs:element>
-
- <!-- Sets a JavaBean's property to the simple property specified as 'value' attribute
- or to the object stored in the context with the 'ref'. -->
- <xs:element name="property">
- <xs:complexType>
- <xs:sequence minOccurs="0" maxOccurs="unbounded">
- <xs:element ref="comment" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="bean" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="idref" minOccurs="0" maxOccurs="unbounded"/>
- </xs:sequence>
- <xs:attribute name="name" type="xs:string"/>
- <xs:attribute name="value" type="xs:string"/>
- <xs:attribute name="ref" type="xs:string"/>
- </xs:complexType>
- </xs:element>
-
- <!-- Represents a reference to a JavaBean (of the name specified by the 'bean' attribute) from the context. -->
- <xs:element name="idref">
- <xs:complexType>
- <xs:attribute name="bean" type="xs:string"/>
- </xs:complexType>
- </xs:element>
-
- <!-- Instantiates and executes a JavaBean that implements the Task interface.
- Properties are handled like in the <bean> tag.
- The task is executed 'count' times in a number of 'threads' parallel threads.
- Invocations are executed in groups of size 'pagesize'. -->
- <xs:element name="run-task">
- <xs:complexType>
- <xs:sequence minOccurs="0" maxOccurs="unbounded">
- <xs:element ref="comment" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="property" minOccurs="0" maxOccurs="unbounded"/>
- </xs:sequence>
- <xs:attribute name="class" type="xs:string"/>
- <xs:attribute name="count" type="xs:string"/>
- <xs:attribute name="pagesize" type="xs:string"/>
- <xs:attribute name="threads" type="xs:string"/>
- <xs:attribute name="pager" type="xs:string"/>
- </xs:complexType>
- </xs:element>
-
- <xs:element name="defaultAttributes">
- <xs:complexType>
- <xs:sequence minOccurs="0" maxOccurs="unbounded">
- <xs:element ref="comment" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="id" minOccurs="0" maxOccurs="1"/>
- <xs:element ref="attribute" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="reference" minOccurs="0" maxOccurs="unbounded"/>
- </xs:sequence>
- <xs:attribute name="name" type="xs:string"/>
- <xs:attribute name="count" type="xs:string"/>
- <xs:attribute name="pagesize" type="xs:string"/>
- <xs:attribute name="threads" type="xs:string"/>
- <xs:attribute name="source" type="xs:string"/>
- <xs:attribute name="encoding" type="xs:string"/>
- </xs:complexType>
- </xs:element>
-
- <!-- Creates entities. If a 'count' is provided the corresponding number of entities is created.
- If no count is provided, entities are created as long as each involved generator is available. -->
- <xs:element name="create-entities">
- <xs:complexType>
- <xs:sequence minOccurs="0" maxOccurs="unbounded">
- <xs:element ref="comment" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="id" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="attribute" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="reference" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="variable" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="consumer" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="create-entities" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="update-entities" minOccurs="0" maxOccurs="unbounded"/>
- </xs:sequence>
- <xs:attribute name="name" type="xs:string"/>
- <xs:attribute name="count" type="xs:string"/>
- <xs:attribute name="minCount" type="xs:string"/>
- <xs:attribute name="maxCount" type="xs:string"/>
- <xs:attribute name="pagesize" type="xs:string"/>
- <xs:attribute name="threads" type="xs:string"/>
- <xs:attribute name="source" type="xs:string"/>
- <xs:attribute name="selector" type="xs:string"/>
- <xs:attribute name="encoding" type="xs:string"/>
- <xs:attribute name="consumer" type="xs:string"/>
- </xs:complexType>
- </xs:element>
-
- <!-- Updates entities. -->
- <xs:element name="update-entities">
- <xs:complexType>
- <xs:sequence minOccurs="0" maxOccurs="unbounded">
- <xs:element ref="comment" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="id" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="attribute" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="reference" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="variable" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="consumer" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="create-entities" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="update-entities" minOccurs="0" maxOccurs="unbounded"/>
- </xs:sequence>
- <xs:attribute name="name" type="xs:string"/>
- <xs:attribute name="count" type="xs:string"/>
- <xs:attribute name="pagesize" type="xs:string"/>
- <xs:attribute name="threads" type="xs:string"/>
- <xs:attribute name="source" type="xs:string"/>
- <xs:attribute name="selector" type="xs:string"/>
- <xs:attribute name="encoding" type="xs:string"/>
- <xs:attribute name="consumer" type="xs:string"/>
- </xs:complexType>
- </xs:element>
-
- <!-- Defines an ID generator that can be reused in different scopes. -->
- <xs:element name="id">
- <xs:complexType>
- <xs:attribute name="name" type="xs:string"/>
- <xs:attribute name="type" type="xs:string"/>
- <xs:attribute name="source" type="xs:string"/>
- <xs:attribute name="strategy" type="xs:string"/>
- <xs:attribute name="scope" type="xs:string"/>
- <xs:attribute name="param" type="xs:string"/>
- </xs:complexType>
- </xs:element>
-
- <!-- Defines a reference generator. -->
- <xs:element name="reference">
- <xs:complexType>
- <xs:attribute name="name" type="xs:string"/>
- <xs:attribute name="type" type="xs:string"/>
- <xs:attribute name="nullable" type="xs:string"/>
- <xs:attribute name="nullQuota" type="xs:string"/>
- <xs:attribute name="source" type="xs:string"/>
- <xs:attribute name="targetType" type="xs:string"/>
- <xs:attribute name="selector" type="xs:string"/>
- <xs:attribute name="distribution" type="xs:string"/>
- <xs:attribute name="mode" type="xs:string"/>
- </xs:complexType>
- </xs:element>
-
- <!-- Defines a variable that is recreated by a generator on each entity creation -->
- <xs:element name="variable" type="generator-setup"/>
-
- <xs:complexType name="generator-setup">
- <xs:attribute name="name" type="xs:string" use="required"/>
- <xs:attribute name="type" type="xs:string"/>
- <xs:attribute name="generator" type="xs:string"/>
- <xs:attribute name="validator" type="xs:string"/>
- <xs:attribute name="values" type="xs:string"/>
- <xs:attribute name="source" type="xs:string"/>
- <xs:attribute name="encoding" type="xs:string"/>
- <xs:attribute name="selector" type="xs:string"/>
- <xs:attribute name="pattern" type="xs:string"/>
- <xs:attribute name="nullQuota" type="xs:string"/>
- <xs:attribute name="converter" type="xs:string"/>
- <xs:attribute name="dataset" type="xs:string"/>
- <xs:attribute name="nesting" type="xs:string"/>
- <xs:attribute name="locale" type="xs:string"/>
- <xs:attribute name="unique" type="xs:string"/>
- <xs:attribute name="distribution" type="xs:string"/>
- <xs:attribute name="variation1" type="xs:string"/>
- <xs:attribute name="variation2" type="xs:string"/>
- <xs:attribute name="cyclic" type="xs:string"/>
- <xs:attribute name="proxy">
- <xs:simpleType>
- <xs:union>
- <xs:simpleType> <!-- (skip | repeat) -->
- <xs:restriction base="xs:string">
- <xs:enumeration value="skip"/>
- <xs:enumeration value="repeat"/>
- </xs:restriction>
- </xs:simpleType>
- <xs:simpleType>
- <xs:restriction base="script-expression-type"/>
- </xs:simpleType>
- </xs:union>
- </xs:simpleType>
- </xs:attribute>
- <xs:attribute name="proxy-param1" type="xs:string"/>
- <xs:attribute name="proxy-param2" type="xs:string"/>
- </xs:complexType>
-
- <xs:element name="attribute" type="attribute-generator-setup"/>
-
- <xs:complexType name="attribute-generator-setup">
- <xs:complexContent>
- <xs:extension base="generator-setup">
-
- <xs:attribute name="nullable" type="xs:string"/>
- <xs:attribute name="mode" type="xs:string"/>
-
- <!-- boolean generator setup -->
- <xs:attribute name="trueQuota" type="xs:string"/>
-
- <!-- number generator setup -->
- <xs:attribute name="min" type="xs:string"/>
- <xs:attribute name="minExclusive" type="xs:string"/>
- <xs:attribute name="max" type="xs:string"/>
- <xs:attribute name="maxExclusive" type="xs:string"/>
- <xs:attribute name="precision" type="xs:string"/>
-
- <!-- String generator setup -->
- <xs:attribute name="script" type="xs:string"/>
- <xs:attribute name="minLength" type="xs:string"/>
- <xs:attribute name="maxLength" type="xs:string"/>
-
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
-
-</xs:schema>
Deleted: trunk/utils/dna-jcr-gen/pom.xml
===================================================================
--- trunk/utils/dna-jcr-gen/pom.xml 2009-11-27 02:26:23 UTC (rev 1363)
+++ trunk/utils/dna-jcr-gen/pom.xml 2009-11-27 03:08:49 UTC (rev 1364)
@@ -1,133 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.jboss.dna</groupId>
- <artifactId>dna</artifactId>
- <version>0.6-SNAPSHOT</version>
- <relativePath>../..</relativePath>
- </parent>
- <!-- The groupId and version values are inherited from parent -->
- <artifactId>dna-jcr-gen</artifactId>
- <packaging>jar</packaging>
- <name>JBoss DNA JCR data mass generator</name>
- <description>
- A Utilty to generate mass of data for a jcr repository
- and then write them into the source. For Performance testing,
- for dummy daten for a start up project.
- </description>
- <url>http://labs.jboss.org/dna</url>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.databene</groupId>
- <artifactId>maven-benerator-plugin</artifactId>
- <version>0.5.9-SR1</version>
- <configuration>
- <descriptor>
- src/test/resources/benerator/benerator.xml
- </descriptor>
- <!-- If you use benerator offline -->
- <validate>false</validate>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <!--
- Define the dependencies. Note that all version and scopes default to those
- defined in the dependencyManagement section of the parent pom.
- -->
- <dependencies>
- <dependency>
- <groupId>org.databene</groupId>
- <artifactId>databene-benerator</artifactId>
- <version>0.5.9-SR1</version>
- </dependency>
- <!--
- Java Content Repository API
- -->
- <dependency>
- <groupId>javax.jcr</groupId>
- <artifactId>jcr</artifactId>
- <version>1.0.1</version>
- <scope>compile</scope>
- </dependency>
- <!--
- JBoss DNA JCR (JCR Implementation) for repository implementation
- -->
- <dependency>
- <groupId>org.jboss.dna</groupId>
- <artifactId>dna-jcr</artifactId>
- <version>${project.version}</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.dna</groupId>
- <artifactId>dna-repository</artifactId>
- <version>${project.version}</version>
- <scope>compile</scope>
- </dependency>
-
- <!--
- Logging (require SLF4J API for compiling, but use Log4J and its SLF4J binding for testing)
- -->
- <!-- Logging (require SLF4J API for compiling, but use Log4J and its SLF4J binding for testing) -->
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>1.4.3</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <version>1.4.3</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>1.2.14</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>com.google.code.google-collections</groupId>
- <artifactId>google-collect</artifactId>
- <version>snapshot-20080530</version>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.security</groupId>
- <artifactId>jboss-idtrust</artifactId>
- <version>2.0.2.CR1</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.security</groupId>
- <artifactId>jboss-security-spi-bare</artifactId>
- <version>2.0.2.SP6</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.security</groupId>
- <artifactId>jbosssx-bare</artifactId>
- <version>2.0.2.SP6</version>
- <exclusions>
- <exclusion>
- <groupId>apache-xalan</groupId>
- <artifactId>xalan</artifactId>
- </exclusion>
- <exclusion>
- <groupId>apache-xalan</groupId>
- <artifactId>serializer</artifactId>
- </exclusion>
- </exclusions>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
\ No newline at end of file
Deleted: trunk/utils/dna-jcr-gen/readme.txt
===================================================================
--- trunk/utils/dna-jcr-gen/readme.txt 2009-11-27 02:26:23 UTC (rev 1363)
+++ trunk/utils/dna-jcr-gen/readme.txt 2009-11-27 03:08:49 UTC (rev 1364)
@@ -1,23 +0,0 @@
-
-- Prerequire
-
-you need to have JDK6 installed on your OS
-
-check
-
- sp$ java -version
-java version "1.6.0_13"
-Java(TM) SE Runtime Environment (build 1.6.0_13-b03-211)
-Java HotSpot(TM) 64-Bit Server VM (build 11.3-b02-83, mixed mode)
-
-
-- How to generate mass of data
-
- -- This two files bank.properties and benerator.xml describe how many entities and the model
-
- * /dna-jcr-gen/src/test/resources/benerator/bank.properties
- * /dna-jcr-gen/src/test/resources/benerator/benerator.xml
- -- Use "mvn benerator:generate" command to generate data into you Source (For now only test on
- InMemoryRepositorySource source)
-
-
\ No newline at end of file
Deleted: trunk/utils/dna-jcr-gen/src/main/java/org/jboss/dna/jcr/gen/JCRDataMassGen.java
===================================================================
--- trunk/utils/dna-jcr-gen/src/main/java/org/jboss/dna/jcr/gen/JCRDataMassGen.java 2009-11-27 02:26:23 UTC (rev 1363)
+++ trunk/utils/dna-jcr-gen/src/main/java/org/jboss/dna/jcr/gen/JCRDataMassGen.java 2009-11-27 03:08:49 UTC (rev 1364)
@@ -1,234 +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.jcr.gen;
-
-import java.io.InputStream;
-import java.util.Calendar;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
-import javax.jcr.PropertyIterator;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.Value;
-import javax.jcr.ValueFormatException;
-import javax.jcr.lock.LockException;
-import javax.jcr.nodetype.ConstraintViolationException;
-import javax.jcr.version.VersionException;
-import org.databene.model.consumer.AbstractConsumer;
-import org.databene.model.data.Entity;
-import org.jboss.dna.graph.SecurityContext;
-import org.jboss.dna.graph.connector.RepositorySource;
-import org.jboss.dna.jcr.JcrConfiguration;
-import org.jboss.dna.jcr.JcrEngine;
-import org.jboss.dna.jcr.SecurityContextCredentials;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * A Utility that writes the generated content as nodes to a DNA JCR repository.<br/>
- *
- * @author Serge Pagop
- */
-
-public class JCRDataMassGen extends AbstractConsumer<Entity> {
-
- private static final Logger log = LoggerFactory.getLogger(JCRDataMassGen.class);
- // attributes ------------------------------------------------------------------------------------------------------
-
- private Session session;
- private Node currentNode;
- private boolean printContent;
-
- private JcrConfiguration configuration;
- private JcrEngine engine;
- private Repository repository;
-
- // Constructor -----------------------------------------------------------------------------------------------------
-
- /**
- * Construct a Data Mass Generator, that may be used to generate test data.
- * @param sourceName - the name of the source.
- * @param description - the configuration description.
- * @param beanPropertyName - the name of the bean property.
- * @param workspaceName - the workspace name.
- * @param repositoryName - the repository name.
- * @param repositorySource -
- * @param username
- * @param printContent
- * @throws Exception
- */
- @SuppressWarnings( "unchecked" )
- public JCRDataMassGen( String sourceName,
- String description,
- String beanPropertyName,
- String workspaceName,
- String repositoryName,
- String repositorySource,
- String username,
- boolean printContent ) throws Exception {
- this.printContent = printContent;
-
- // setting up the JcrConfiguration
- configuration = new JcrConfiguration();
- Class<? extends RepositorySource> clazz = (Class<? extends RepositorySource>)Class.forName(repositorySource);
- configuration.repositorySource(sourceName).usingClass(clazz).setDescription(description).setProperty(beanPropertyName,
- workspaceName);
- // repository
- configuration.repository(repositoryName).setSource(sourceName);
- // Start the engine
- engine = configuration.build();
- engine.start();
- // Obtain a JCR Repository instance by name
- repository = engine.getRepository(repositoryName);
- SecurityContext securityContext = new MyCustomSecurityContext(username);
- SecurityContextCredentials credentials = new SecurityContextCredentials(securityContext);
- this.session = repository.login(credentials, workspaceName);
- this.currentNode = session.getRootNode();
- }
-
- // consumer interface implementation -------------------------------------------------------------------------------
-
- public void startConsuming( Entity entity ) {
- Node newNode;
- try {
- String n = entity.get("nodeName").toString();
- newNode = currentNode.addNode(n, "nt:unstructured");
- for (Map.Entry<String, Object> component : entity.getComponents().entrySet()) {
- String key = component.getKey();
- Object value = component.getValue();
- if (!"nodeName".equals(key)) setNodeProperty(newNode, key, value);
- }
- currentNode = newNode;
- } catch (Exception e) {
- throw new RuntimeException("Exception whe trying to store " + entity, e);
- }
- }
-
- @Override
- public void finishConsuming( Entity object ) {
- try {
- session.save();
- currentNode = currentNode.getParent();
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- @Override
- public void close() {
- try {
- if (printContent) printNode(session.getRootNode(), "");
- } catch (RepositoryException e) {
- throw new RuntimeException(e);
-
- } finally {
- session.logout();
-
- // Shutdown the engine
- if (engine != null) {
- engine.shutdown();
- try {
- engine.awaitTermination(3, TimeUnit.SECONDS);
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
- }
-
- }
- }
-
- public void setPrintContent( boolean printContent ) {
- this.printContent = printContent;
- }
-
- // private helpers -------------------------------------------------------------------------------------------------
-
- private void setNodeProperty( Node node,
- String propertyName,
- Object propertyValue )
- throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
- if (propertyValue instanceof Long) node.setProperty(propertyName, (Long)propertyValue);
- else if (propertyValue instanceof Double) node.setProperty(propertyName, (Double)propertyValue);
- else if (propertyValue instanceof Boolean) node.setProperty(propertyName, (Boolean)propertyValue);
- else if (propertyValue instanceof Calendar) node.setProperty(propertyName, (Calendar)propertyValue);
- else if (propertyValue instanceof String[]) node.setProperty(propertyName, (String[])propertyValue);
- else if (propertyValue instanceof InputStream) node.setProperty(propertyName, (InputStream)propertyValue);
- else if (propertyValue instanceof Node) node.setProperty(propertyName, (Node)propertyValue);
- else if (propertyValue instanceof Value) node.setProperty(propertyName, (Value)propertyValue);
- else if (propertyValue instanceof Value[]) node.setProperty(propertyName, (Value[])propertyValue);
- else node.setProperty(propertyName, propertyValue.toString());
- }
-
- private void printNode( Node node,
- String indent ) throws RepositoryException {
- log.info(indent + "Node: " + node.getName() + " " + node.getPrimaryNodeType().getName());
- PropertyIterator propIt = node.getProperties();
- while (propIt.hasNext()) {
- Property property = (Property)propIt.next();
- log.info(indent + '\t' + '\t' + property.getName());
- Value value = property.getValue();
- log.info(indent + '\t' + '\t' + '\t' + value.getString());
-
- }
- NodeIterator iterator = node.getNodes();
- while (iterator.hasNext())
- printNode(iterator.nextNode(), indent + '\t');
- }
-
- protected class MyCustomSecurityContext implements SecurityContext {
- private String username;
-
- public MyCustomSecurityContext( String username ) {
- this.username = username;
- }
-
- /**
- * @see org.jboss.dna.graph.SecurityContext#getUserName()
- */
- public String getUserName() {
- return this.username;
- }
-
- /**
- * @see org.jboss.dna.graph.SecurityContext#hasRole(java.lang.String)
- */
-
- public boolean hasRole( String roleName ) {
- return true;
- }
-
- /**
- * @see org.jboss.dna.graph.SecurityContext#logout()
- */
- public void logout() {
- // do something
- }
- }
-
-}
Deleted: trunk/utils/dna-jcr-gen/src/main/resources/benerator-0.5.9-SR1.xsd
===================================================================
--- trunk/utils/dna-jcr-gen/src/main/resources/benerator-0.5.9-SR1.xsd 2009-11-27 02:26:23 UTC (rev 1363)
+++ trunk/utils/dna-jcr-gen/src/main/resources/benerator-0.5.9-SR1.xsd 2009-11-27 03:08:49 UTC (rev 1364)
@@ -1,372 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
- targetNamespace="http://databene.org/benerator/0.5.9-SR1"
- xmlns="http://databene.org/benerator/0.5.9-SR1"
- elementFormDefault="qualified">
-
- <xs:annotation>
- <xs:documentation>The benerator schema describes the generation setup for benerator.</xs:documentation>
- <xs:appinfo/>
- </xs:annotation>
-
- <xs:simpleType name="script-expression-type">
- <xs:restriction base="xs:string">
- <xs:pattern value="\{.*\}"/>
- </xs:restriction>
- </xs:simpleType>
-
- <xs:simpleType name="errorhandler-type">
- <xs:union>
- <xs:simpleType>
- <xs:restriction base="xs:string">
- <xs:enumeration value="fatal"/>
- <xs:enumeration value="error"/>
- <xs:enumeration value="warn"/>
- <xs:enumeration value="info"/>
- <xs:enumeration value="debug"/>
- <xs:enumeration value="trace"/>
- <xs:enumeration value="ignore"/>
- </xs:restriction>
- </xs:simpleType>
- <xs:simpleType>
- <xs:restriction base="script-expression-type"/>
- </xs:simpleType>
- </xs:union>
- </xs:simpleType>
-
-
- <!-- The document root, it can list beans, create-entities and run-tasks in arbitrary order. -->
- <xs:element name="setup">
- <xs:complexType>
- <xs:sequence minOccurs="0" maxOccurs="unbounded">
- <xs:element ref="comment" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="import" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="include" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="property" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="database" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="bean" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="defaultAttributes" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="create-entities" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="update-entities" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="run-task" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="execute" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="evaluate" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="echo" minOccurs="0" maxOccurs="unbounded"/>
- </xs:sequence>
- <xs:attribute name="default-script" type="xs:string"/> <!-- deprecated -->
- <xs:attribute name="default-null" type="xs:string"/> <!-- deprecated -->
- <xs:attribute name="defaultScript" type="xs:string"/>
- <xs:attribute name="defaultNull" type="xs:string"/>
- <xs:attribute name="defaultEncoding" type="xs:string"/>
- <xs:attribute name="defaultLineSeparator" type="xs:string"/>
- <xs:attribute name="defaultLocale" type="xs:string"/>
- <xs:attribute name="defaultDataset" type="xs:string"/>
- <xs:attribute name="defaultPagesize" type="xs:string"/>
- <xs:attribute name="defaultSeparator" type="xs:string"/>
- <xs:attribute name="defaultErrorHandler" type="errorhandler-type"/>
- <xs:attribute name="maxCount" type="xs:string"/>
- </xs:complexType>
- </xs:element>
-
- <xs:element name="comment" type="xs:string" />
-
- <!-- Imports classes. -->
- <xs:element name="import">
- <xs:complexType>
- <xs:attribute name="class" type="xs:string"/>
- <xs:attribute name="domain" type="xs:string"/>
- <xs:attribute name="defaults" type="xs:string"/>
- </xs:complexType>
- </xs:element>
-
- <!-- Includes a properties file. -->
- <xs:element name="include">
- <xs:complexType>
- <xs:attribute name="uri" type="xs:string" use="required"/>
- </xs:complexType>
- </xs:element>
-
- <!-- Outputs a message to the console. -->
- <xs:element name="echo">
- <xs:complexType>
- <xs:attribute name="message" type="xs:string" use="required"/>
- </xs:complexType>
- </xs:element>
-
- <!-- Instantiates a JavaBean of the given class.
- If the 'id' is set, the bean is put into the context with that name.
- If the JavaBean itself has a property named 'id', this one is set to the value specified here. -->
- <xs:element name="bean">
- <xs:complexType>
- <xs:sequence minOccurs="0" maxOccurs="unbounded">
- <xs:element ref="comment" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="property" minOccurs="0" maxOccurs="unbounded"/>
- </xs:sequence>
- <xs:attribute name="id" type="xs:string" use="required"/>
- <xs:attribute name="class" type="xs:string"/>
- <xs:attribute name="spec" type="xs:string"/>
- </xs:complexType>
- </xs:element>
-
- <!-- connects to a database -->
- <xs:element name="database">
- <xs:complexType>
- <xs:attribute name="id" type="xs:string" use="required"/>
- <xs:attribute name="url" type="xs:string"/>
- <xs:attribute name="driver" type="xs:string"/>
- <xs:attribute name="user" type="xs:string"/>
- <xs:attribute name="schema" type="xs:string"/>
- <xs:attribute name="password" type="xs:string"/>
- <xs:attribute name="batch" type="xs:string"/>
- <xs:attribute name="fetchSize" type="xs:string"/>
- <xs:attribute name="readOnly" type="xs:string"/>
- </xs:complexType>
- </xs:element>
-
- <xs:complexType name="execute-type">
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute name="uri" type="xs:string"/>
- <xs:attribute name="encoding" type="xs:string"/>
- <xs:attribute name="target" type="xs:string"/>
- <xs:attribute name="type" type="xs:string"/>
- <xs:attribute name="onError" type="errorhandler-type"/>
- <xs:attribute name="optimize" type="xs:string"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
-
- <!-- executes a script, e.g. SQL -->
- <xs:element name="execute" />
-
- <!-- evaluates a script, e.g. SQL -->
- <xs:element name="evaluate">
- <xs:complexType>
- <xs:simpleContent>
- <xs:extension base="execute-type">
- <xs:attribute name="assert" type="xs:string"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- </xs:element>
-
- <!-- Declares a JavaBean to be used as consumer, either by referencing an object from the context (ref)
- or by instantiating a JavaBean like with the <bean> tag. -->
- <xs:element name="consumer">
- <xs:complexType>
- <xs:sequence minOccurs="1" maxOccurs="unbounded">
- <xs:element ref="comment" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="property" minOccurs="0" maxOccurs="unbounded"/>
- </xs:sequence>
- <xs:attribute name="id" type="xs:string"/>
- <xs:attribute name="class" type="xs:string"/>
- <xs:attribute name="ref" type="xs:string"/>
- </xs:complexType>
- </xs:element>
-
- <!-- Sets a JavaBean's property to the simple property specified as 'value' attribute
- or to the object stored in the context with the 'ref'. -->
- <xs:element name="property">
- <xs:complexType>
- <xs:sequence minOccurs="0" maxOccurs="unbounded">
- <xs:element ref="comment" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="bean" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="idref" minOccurs="0" maxOccurs="unbounded"/>
- </xs:sequence>
- <xs:attribute name="name" type="xs:string"/>
- <xs:attribute name="value" type="xs:string"/>
- <xs:attribute name="ref" type="xs:string"/>
- </xs:complexType>
- </xs:element>
-
- <!-- Represents a reference to a JavaBean (of the name specified by the 'bean' attribute) from the context. -->
- <xs:element name="idref">
- <xs:complexType>
- <xs:attribute name="bean" type="xs:string"/>
- </xs:complexType>
- </xs:element>
-
- <!-- Instantiates and executes a JavaBean that implements the Task interface.
- Properties are handled like in the <bean> tag.
- The task is executed 'count' times in a number of 'threads' parallel threads.
- Invocations are executed in groups of size 'pagesize'. -->
- <xs:element name="run-task">
- <xs:complexType>
- <xs:sequence minOccurs="0" maxOccurs="unbounded">
- <xs:element ref="comment" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="property" minOccurs="0" maxOccurs="unbounded"/>
- </xs:sequence>
- <xs:attribute name="class" type="xs:string"/>
- <xs:attribute name="count" type="xs:string"/>
- <xs:attribute name="pagesize" type="xs:string"/>
- <xs:attribute name="threads" type="xs:string"/>
- <xs:attribute name="pager" type="xs:string"/>
- </xs:complexType>
- </xs:element>
-
- <xs:element name="defaultAttributes">
- <xs:complexType>
- <xs:sequence minOccurs="0" maxOccurs="unbounded">
- <xs:element ref="comment" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="id" minOccurs="0" maxOccurs="1"/>
- <xs:element ref="attribute" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="reference" minOccurs="0" maxOccurs="unbounded"/>
- </xs:sequence>
- <xs:attribute name="name" type="xs:string"/>
- <xs:attribute name="count" type="xs:string"/>
- <xs:attribute name="pagesize" type="xs:string"/>
- <xs:attribute name="threads" type="xs:string"/>
- <xs:attribute name="source" type="xs:string"/>
- <xs:attribute name="encoding" type="xs:string"/>
- </xs:complexType>
- </xs:element>
-
- <!-- Creates entities. If a 'count' is provided the corresponding number of entities is created.
- If no count is provided, entities are created as long as each involved generator is available. -->
- <xs:element name="create-entities">
- <xs:complexType>
- <xs:sequence minOccurs="0" maxOccurs="unbounded">
- <xs:element ref="comment" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="id" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="attribute" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="reference" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="variable" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="consumer" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="create-entities" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="update-entities" minOccurs="0" maxOccurs="unbounded"/>
- </xs:sequence>
- <xs:attribute name="name" type="xs:string"/>
- <xs:attribute name="count" type="xs:string"/>
- <xs:attribute name="minCount" type="xs:string"/>
- <xs:attribute name="maxCount" type="xs:string"/>
- <xs:attribute name="pagesize" type="xs:string"/>
- <xs:attribute name="threads" type="xs:string"/>
- <xs:attribute name="source" type="xs:string"/>
- <xs:attribute name="selector" type="xs:string"/>
- <xs:attribute name="encoding" type="xs:string"/>
- <xs:attribute name="consumer" type="xs:string"/>
- </xs:complexType>
- </xs:element>
-
- <!-- Updates entities. -->
- <xs:element name="update-entities">
- <xs:complexType>
- <xs:sequence minOccurs="0" maxOccurs="unbounded">
- <xs:element ref="comment" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="id" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="attribute" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="reference" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="variable" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="consumer" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="create-entities" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element ref="update-entities" minOccurs="0" maxOccurs="unbounded"/>
- </xs:sequence>
- <xs:attribute name="name" type="xs:string"/>
- <xs:attribute name="count" type="xs:string"/>
- <xs:attribute name="pagesize" type="xs:string"/>
- <xs:attribute name="threads" type="xs:string"/>
- <xs:attribute name="source" type="xs:string"/>
- <xs:attribute name="selector" type="xs:string"/>
- <xs:attribute name="encoding" type="xs:string"/>
- <xs:attribute name="consumer" type="xs:string"/>
- </xs:complexType>
- </xs:element>
-
- <!-- Defines an ID generator that can be reused in different scopes. -->
- <xs:element name="id">
- <xs:complexType>
- <xs:attribute name="name" type="xs:string"/>
- <xs:attribute name="type" type="xs:string"/>
- <xs:attribute name="source" type="xs:string"/>
- <xs:attribute name="strategy" type="xs:string"/>
- <xs:attribute name="scope" type="xs:string"/>
- <xs:attribute name="param" type="xs:string"/>
- </xs:complexType>
- </xs:element>
-
- <!-- Defines a reference generator. -->
- <xs:element name="reference">
- <xs:complexType>
- <xs:attribute name="name" type="xs:string"/>
- <xs:attribute name="type" type="xs:string"/>
- <xs:attribute name="nullable" type="xs:string"/>
- <xs:attribute name="nullQuota" type="xs:string"/>
- <xs:attribute name="source" type="xs:string"/>
- <xs:attribute name="targetType" type="xs:string"/>
- <xs:attribute name="selector" type="xs:string"/>
- <xs:attribute name="distribution" type="xs:string"/>
- <xs:attribute name="mode" type="xs:string"/>
- </xs:complexType>
- </xs:element>
-
- <!-- Defines a variable that is recreated by a generator on each entity creation -->
- <xs:element name="variable" type="generator-setup"/>
-
- <xs:complexType name="generator-setup">
- <xs:attribute name="name" type="xs:string" use="required"/>
- <xs:attribute name="type" type="xs:string"/>
- <xs:attribute name="generator" type="xs:string"/>
- <xs:attribute name="validator" type="xs:string"/>
- <xs:attribute name="values" type="xs:string"/>
- <xs:attribute name="source" type="xs:string"/>
- <xs:attribute name="encoding" type="xs:string"/>
- <xs:attribute name="selector" type="xs:string"/>
- <xs:attribute name="pattern" type="xs:string"/>
- <xs:attribute name="nullQuota" type="xs:string"/>
- <xs:attribute name="converter" type="xs:string"/>
- <xs:attribute name="dataset" type="xs:string"/>
- <xs:attribute name="nesting" type="xs:string"/>
- <xs:attribute name="locale" type="xs:string"/>
- <xs:attribute name="unique" type="xs:string"/>
- <xs:attribute name="distribution" type="xs:string"/>
- <xs:attribute name="variation1" type="xs:string"/>
- <xs:attribute name="variation2" type="xs:string"/>
- <xs:attribute name="cyclic" type="xs:string"/>
- <xs:attribute name="proxy">
- <xs:simpleType>
- <xs:union>
- <xs:simpleType> <!-- (skip | repeat) -->
- <xs:restriction base="xs:string">
- <xs:enumeration value="skip"/>
- <xs:enumeration value="repeat"/>
- </xs:restriction>
- </xs:simpleType>
- <xs:simpleType>
- <xs:restriction base="script-expression-type"/>
- </xs:simpleType>
- </xs:union>
- </xs:simpleType>
- </xs:attribute>
- <xs:attribute name="proxy-param1" type="xs:string"/>
- <xs:attribute name="proxy-param2" type="xs:string"/>
- </xs:complexType>
-
- <xs:element name="attribute" type="attribute-generator-setup"/>
-
- <xs:complexType name="attribute-generator-setup">
- <xs:complexContent>
- <xs:extension base="generator-setup">
-
- <xs:attribute name="nullable" type="xs:string"/>
- <xs:attribute name="mode" type="xs:string"/>
-
- <!-- boolean generator setup -->
- <xs:attribute name="trueQuota" type="xs:string"/>
-
- <!-- number generator setup -->
- <xs:attribute name="min" type="xs:string"/>
- <xs:attribute name="minExclusive" type="xs:string"/>
- <xs:attribute name="max" type="xs:string"/>
- <xs:attribute name="maxExclusive" type="xs:string"/>
- <xs:attribute name="precision" type="xs:string"/>
-
- <!-- String generator setup -->
- <xs:attribute name="script" type="xs:string"/>
- <xs:attribute name="minLength" type="xs:string"/>
- <xs:attribute name="maxLength" type="xs:string"/>
-
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
-
-</xs:schema>
Deleted: trunk/utils/dna-jcr-gen/src/main/resources/log4j.properties
===================================================================
--- trunk/utils/dna-jcr-gen/src/main/resources/log4j.properties 2009-11-27 02:26:23 UTC (rev 1363)
+++ trunk/utils/dna-jcr-gen/src/main/resources/log4j.properties 2009-11-27 03:08:49 UTC (rev 1364)
@@ -1,13 +0,0 @@
-# Direct log messages to stdout
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.Target=System.out
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %m%n
-
-# Root logger option
-log4j.rootLogger=INFO, stdout
-
-# Set up the default logging to be INFO level, then override specific units
-log4j.logger.org.jboss.dna=INFO
-log4j.logger.org.jboss.example.dna=INFO
-
Deleted: trunk/utils/dna-jcr-gen/src/test/resources/benerator/bank.properties
===================================================================
--- trunk/utils/dna-jcr-gen/src/test/resources/benerator/bank.properties 2009-11-27 02:26:23 UTC (rev 1363)
+++ trunk/utils/dna-jcr-gen/src/test/resources/benerator/bank.properties 2009-11-27 03:08:49 UTC (rev 1364)
@@ -1,5 +0,0 @@
-bankCount=20
-minProd=3
-maxProd=20
-minCont=4
-maxCont=20
Deleted: trunk/utils/dna-jcr-gen/src/test/resources/benerator/benerator.xml
===================================================================
--- trunk/utils/dna-jcr-gen/src/test/resources/benerator/benerator.xml 2009-11-27 02:26:23 UTC (rev 1363)
+++ trunk/utils/dna-jcr-gen/src/test/resources/benerator/benerator.xml 2009-11-27 03:08:49 UTC (rev 1364)
@@ -1,57 +0,0 @@
-<?xml version="1.0" encoding="iso-8859-1"?>
-<setup xmlns="http://databene.org/benerator/0.5.9-SR1"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://databene.org/benerator/0.5.9-SR1 benerator-0.5.9-SR1.xsd">
-
- <!-- Already existed generator -->
- <import domain="person" />
- <import domain="address" />
-
- <!-- My consumer for my InMmemery repos. source -->
- <bean id="dnaJcrConsumer" spec="org.jboss.dna.jcr.gen.JCRDataMassGen('firstSource',
- 'this is only my first jcr repos source with some test data',
- 'defaultWorkspaceName',
- 'WS1',
- 'test repository',
- 'org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource',
- 'username',true)"/>
-
- <!-- Some extras data -->
- <include uri="bank.properties"/>
-
- <!-- My Model -->
- <create-entities name="Bank" consumer="dnaJcrConsumer" count="{${bankCount}}">
- <attribute name="nodeName" type="string" pattern="[A-Z]{3} Bank" unique="true"/>
-
- <create-entities name="Product" consumer="dnaJcrConsumer" minCount="{${minProd}}" maxCount="{${maxProd}}">
- <attribute name="nodeName" type="string" pattern="[A-Z]{3} Credit" unique="true"/>
-
- <create-entities name="Contract" consumer="dnaJcrConsumer" minCount="{${minCont}}" maxCount="{${maxCont}}">
- <id name="id" strategy="increment(100000)"/>
- <attribute name="nodeName" script="{Contract #${Contract.id}}"/>
- <attribute name="amount" type="float" min="1000" max="20000" distribution="cumulated"/>
- <attribute name="interest" type="big_decimal" min="7" max="12" precision="0.05"/>
-
- <create-entities name="Person" consumer="dnaJcrConsumer" count="1">
- <variable name="person" generator="PersonGenerator" dataset="US" locale="en"/>
- <attribute name="nodeName" script="{${person.givenName} ${person.familyName}}"/>
- <attribute name="salutation" script="{${person.salutation}}"/>
- <attribute name="firstName" script="{${person.givenName}}"/>
- <attribute name="surname" script="{${person.familyName}}"/>
- <attribute name="birthDate" type="date" source="person.birthDate"/>
- </create-entities>
-
- <create-entities name="Address" consumer="dnaJcrConsumer" count="1">
- <variable name="address" generator="AddressGenerator" dataset="US"/>
- <id name="id" strategy="increment(100000)"/>
- <attribute name="nodeName" script="{Address #${Address.id}}"/>
- <attribute name="street" script="{${address.street} ${address.houseNumber}}"/>
- <attribute name="zipCode" script="{${address.zipCode}}"/>
- <attribute name="city" script="{${address.city}}"/>
- <attribute name="country" script="{${address.country}}"/>
- </create-entities>
- </create-entities>
- </create-entities>
- </create-entities>
-
-</setup>
\ No newline at end of file
14 years, 5 months
DNA SVN: r1363 - trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map.
by dna-commits@lists.jboss.org
Author: bcarothers
Date: 2009-11-26 21:26:23 -0500 (Thu, 26 Nov 2009)
New Revision: 1363
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/MapRequestProcessor.java
Log:
DNA-546 JCR Workspace and Session Imports Can Fail on JPA Connector
Fixed bug in behavior of MapRequestProcessor.process(CreateNodeRequest) when given valueless properties.
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/MapRequestProcessor.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/MapRequestProcessor.java 2009-11-27 01:57:01 UTC (rev 1362)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/MapRequestProcessor.java 2009-11-27 02:26:23 UTC (rev 1363)
@@ -233,7 +233,7 @@
if (property.getName().equals(DnaLexicon.UUID) || property.getName().equals(JcrLexicon.UUID)) {
uuid = getExecutionContext().getValueFactories().getUuidFactory().create(property.getValues().next());
} else {
- propsToStore.add(property);
+ if (property.size() > 0) propsToStore.add(property);
}
}
14 years, 5 months