You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by dp...@apache.org on 2008/03/28 16:48:10 UTC
svn commit: r642270 - in /jackrabbit/trunk/jackrabbit-core/src:
main/java/org/apache/jackrabbit/core/ItemImpl.java
main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
test/java/org/apache/jackrabbit/core/ShareableNodeTest.java
Author: dpfister
Date: Fri Mar 28 08:48:02 2008
New Revision: 642270
URL: http://svn.apache.org/viewvc?rev=642270&view=rev
Log:
JCR-1104 - JSR 283 support
- shareble nodes (work in progress)
- clone to same workspace only allowed when removeExisting==false
- remove trailing whitespace
Modified:
jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ShareableNodeTest.java
Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java?rev=642270&r1=642269&r2=642270&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java Fri Mar 28 08:48:02 2008
@@ -758,7 +758,7 @@
}
}
}
-
+
/**
* Process all items given in iterator and check whether <code>mix:shareable</code>
* or (some derived node type) has been added or removed:
@@ -789,7 +789,7 @@
if (!wasShareable && isShareable) {
// mix:shareable has been added
ns.addShare(ns.getParentId());
-
+
} else if (wasShareable && !isShareable) {
// mix:shareable has been removed: not supported
String msg = "Removing mix:shareable is not supported.";
@@ -1279,7 +1279,7 @@
// process transient items marked as 'removed'
removeTransientItems(removed.iterator());
-
+
// process transient items that have change in mixins
processShareableNodes(dirty.iterator());
Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java?rev=642270&r1=642269&r2=642270&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java Fri Mar 28 08:48:02 2008
@@ -404,13 +404,13 @@
}
}
}
-
+
/**
* Handles a clone inside the same workspace, which is supported with
* shareable nodes.
- *
+ *
* @see {@link #clone()}
- *
+ *
* @param srcAbsPath source path
* @param destAbsPath destination path
* @return the path of the node at its new position
@@ -426,7 +426,7 @@
throws ConstraintViolationException, AccessDeniedException,
VersionException, PathNotFoundException, ItemExistsException,
LockException, RepositoryException {
-
+
Path srcPath;
try {
srcPath = session.getQPath(srcAbsPath).getNormalizedPath();
@@ -1089,8 +1089,15 @@
// check workspace name
if (getName().equals(srcWorkspace)) {
- // same as current workspace: is allowed for mix:shareable nodes
- return internalClone(srcAbsPath, destAbsPath);
+ // clone to same workspace is allowed for mix:shareable nodes,
+ // but only if removeExisting is false
+ if (!removeExisting) {
+ return internalClone(srcAbsPath, destAbsPath);
+ }
+ // same as current workspace
+ String msg = srcWorkspace + ": illegal workspace (same as current)";
+ log.debug(msg);
+ throw new RepositoryException(msg);
}
// check authorization for specified workspace
Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ShareableNodeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ShareableNodeTest.java?rev=642270&r1=642269&r2=642270&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ShareableNodeTest.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ShareableNodeTest.java Fri Mar 28 08:48:02 2008
@@ -60,7 +60,7 @@
// clone
Workspace workspace = b1.getSession().getWorkspace();
workspace.clone(workspace.getName(), b1.getPath(),
- a2.getPath() + "/b", true);
+ a2.getPath() + "/b", false);
Node[] shared = getSharedSet(b1);
assertEquals(2, shared.length);
@@ -90,7 +90,7 @@
// clone
Workspace workspace = b1.getSession().getWorkspace();
workspace.clone(workspace.getName(), b1.getPath(),
- a2.getPath() + "/b2", true);
+ a2.getPath() + "/b2", false);
Node[] shared = getSharedSet(b1);
assertEquals(2, shared.length);
@@ -120,7 +120,7 @@
// clone
Workspace workspace = b1.getSession().getWorkspace();
workspace.clone(workspace.getName(), b1.getPath(),
- a2.getPath() + "/b2", true);
+ a2.getPath() + "/b2", false);
Node[] shared = getSharedSet(b1);
assertEquals(2, shared.length);
@@ -149,7 +149,7 @@
// clone
Workspace workspace = b1.getSession().getWorkspace();
workspace.clone(workspace.getName(), b1.getPath(),
- a2.getPath() + "/b2", true);
+ a2.getPath() + "/b2", false);
// verify shared set contains 2 items
Node[] shared = getSharedSet(b1);
@@ -186,7 +186,7 @@
// clone
Workspace workspace = b1.getSession().getWorkspace();
workspace.clone(workspace.getName(), b1.getPath(),
- a2.getPath() + "/b2", true);
+ a2.getPath() + "/b2", false);
Node[] shared = getSharedSet(b1);
assertEquals(2, shared.length);
@@ -220,7 +220,7 @@
// clone
Workspace workspace = b1.getSession().getWorkspace();
workspace.clone(workspace.getName(), b1.getPath(),
- a2.getPath() + "/b2", true);
+ a2.getPath() + "/b2", false);
// remove shared set
((NodeImpl) b1).removeSharedSet();
@@ -250,7 +250,7 @@
// clone
Workspace workspace = b1.getSession().getWorkspace();
workspace.clone(workspace.getName(), b1.getPath(),
- a2.getPath() + "/b2", true);
+ a2.getPath() + "/b2", false);
// remove shared set
((NodeImpl) b1).removeSharedSet();
@@ -282,7 +282,7 @@
// clone
Workspace workspace = b1.getSession().getWorkspace();
workspace.clone(workspace.getName(), b1.getPath(),
- a2.getPath() + "/b2", true);
+ a2.getPath() + "/b2", false);
Node[] shared = getSharedSet(b1);
assertEquals(2, shared.length);
@@ -312,7 +312,7 @@
// clone
Workspace workspace = b1.getSession().getWorkspace();
workspace.clone(workspace.getName(), b1.getPath(),
- a2.getPath() + "/b2", true);
+ a2.getPath() + "/b2", false);
Node[] shared = getSharedSet(b1);
assertEquals(2, shared.length);
@@ -348,7 +348,7 @@
// clone
Workspace workspace = b1.getSession().getWorkspace();
workspace.clone(workspace.getName(), b1.getPath(),
- a2.getPath() + "/b2", true);
+ a2.getPath() + "/b2", false);
// copy source tree to destination
workspace.copy(s.getPath(), testRootNode.getPath() + "/d");
@@ -380,7 +380,7 @@
try {
// clone underneath b1: this must fail
workspace.clone(workspace.getName(), b1.getPath(),
- b1.getPath() + "/c", true);
+ b1.getPath() + "/c", false);
fail("Cloning should create a share cycle.");
} catch (RepositoryException e) {
// expected
@@ -404,7 +404,7 @@
// clone
Workspace workspace = b1.getSession().getWorkspace();
workspace.clone(workspace.getName(), b1.getPath(),
- a2.getPath() + "/b2", true);
+ a2.getPath() + "/b2", false);
// event listener that counts events received
class EventCounter implements SynchronousEventListener {
@@ -425,7 +425,7 @@
public void resetCount() {
count = 0;
}
- };
+ }
EventCounter el = new EventCounter();
ObservationManager om = superuser.getWorkspace().getObservationManager();
@@ -498,7 +498,7 @@
// clone
Workspace workspace = b1.getSession().getWorkspace();
workspace.clone(workspace.getName(), b1.getPath(),
- a2.getPath() + "/b2", true);
+ a2.getPath() + "/b2", false);
Node[] shared = getSharedSet(b1);
assertEquals(2, shared.length);
@@ -538,7 +538,7 @@
try {
// clone (1st attempt, without mix:shareable, should fail)
workspace.clone(workspace.getName(), b1.getPath(),
- a2.getPath() + "/b2", true);
+ a2.getPath() + "/b2", false);
fail("Cloning a node into the same workspace should fail.");
} catch (RepositoryException e) {
// expected
@@ -550,7 +550,7 @@
// clone (2nd attempt, with mix:shareable)
workspace.clone(workspace.getName(), b1.getPath(),
- a2.getPath() + "/b2", true);
+ a2.getPath() + "/b2", false);
}
/**
@@ -571,7 +571,7 @@
// clone
Workspace workspace = b1.getSession().getWorkspace();
workspace.clone(workspace.getName(), b1.getPath(),
- a2.getPath() + "/b2", true);
+ a2.getPath() + "/b2", false);
Node[] shared = getSharedSet(b1);
assertEquals(2, shared.length);
@@ -625,7 +625,7 @@
// clone
Workspace workspace = b1.getSession().getWorkspace();
workspace.clone(workspace.getName(), b1.getPath(),
- a2.getPath() + "/b2", true);
+ a2.getPath() + "/b2", false);
// add new referenceable child
Node c = b1.addNode("c");
@@ -666,7 +666,7 @@
try {
// clone to same parent
workspace.clone(workspace.getName(), b1.getPath(),
- a.getPath() + "/b2", true);
+ a.getPath() + "/b2", false);
fail("Cloning inside same parent should fail.");
} catch (UnsupportedRepositoryOperationException e) {
// expected