diff --git a/config/alfresco/wcm-services-context.xml b/config/alfresco/wcm-services-context.xml
index 678c65f99a..20a5d85e0b 100644
--- a/config/alfresco/wcm-services-context.xml
+++ b/config/alfresco/wcm-services-context.xml
@@ -229,6 +229,7 @@
+
diff --git a/source/java/org/alfresco/repo/avm/AVMLockingAwareService.java b/source/java/org/alfresco/repo/avm/AVMLockingAwareService.java
index 4d1ea5d57e..9bc2d7fe99 100644
--- a/source/java/org/alfresco/repo/avm/AVMLockingAwareService.java
+++ b/source/java/org/alfresco/repo/avm/AVMLockingAwareService.java
@@ -50,6 +50,7 @@ import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.Pair;
+import org.alfresco.wcm.util.WCMUtil;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
@@ -680,8 +681,11 @@ public class AVMLockingAwareService implements AVMService, ApplicationContextAwa
fService.removeNode(parent, name);
String[] storePath = parent.split(":");
fService.createSnapshot(storePath[0], null, null);
- fLockingService.removeLocksInDirectory(getWebProject(storePath[0]), storePath[0],
- storePath[1] + '/' + name);
+ String webProject = getWebProject(storePath[0]);
+ if (webProject != null)
+ {
+ fLockingService.removeLocksInDirectory(webProject, storePath[0], storePath[1] + '/' + name);
+ }
}
/* (non-Javadoc)
@@ -693,7 +697,11 @@ public class AVMLockingAwareService implements AVMService, ApplicationContextAwa
fService.removeNode(path);
String[] storePath = path.split(":");
fService.createSnapshot(storePath[0], null, null);
- fLockingService.removeLocksInDirectory(getWebProject(storePath[0]), storePath[0], storePath[1]);
+ String webProject = getWebProject(storePath[0]);
+ if (webProject != null)
+ {
+ fLockingService.removeLocksInDirectory(webProject, storePath[0], storePath[1]);
+ }
}
/* (non-Javadoc)
@@ -704,14 +712,26 @@ public class AVMLockingAwareService implements AVMService, ApplicationContextAwa
{
// TODO Unresolved: how to deal with directory level locking.
// TODO This assumes that the rename occurs within the same web project.
- grabLock(srcParent + '/' + srcName);
- fService.rename(srcParent, srcName, dstParent, dstName);
- String[] srcStorePath = splitPath(srcParent + '/' + srcName);
- String[] dstStorePath = splitPath(dstParent + '/' + dstName);
- String webProject = getWebProject(dstStorePath[0]);
- if (webProject != null)
+
+ String srcPath = srcParent + '/' + srcName;
+
+ AVMNodeDescriptor desc = fService.lookup(-1, srcPath, false);
+ if (! (desc != null && desc.isDirectory()))
{
- fLockingService.modifyLock(webProject, srcStorePath[1], dstStorePath[1], dstStorePath[0], null, null);
+ grabLock(srcParent + '/' + srcName);
+ }
+
+ fService.rename(srcParent, srcName, dstParent, dstName);
+
+ if (! (desc != null && desc.isDirectory()))
+ {
+ String[] srcStorePath = splitPath(srcParent + '/' + srcName);
+ String[] dstStorePath = splitPath(dstParent + '/' + dstName);
+ String webProject = getWebProject(dstStorePath[0]);
+ if (webProject != null)
+ {
+ fLockingService.modifyLock(webProject, srcStorePath[1], dstStorePath[1], dstStorePath[0], null, null);
+ }
}
}
@@ -851,18 +871,13 @@ public class AVMLockingAwareService implements AVMService, ApplicationContextAwa
}
private String getWebProject(String name)
- {
- Map results = fService.queryStorePropertyKey(name, QName.createQName(null, ".dns%"));
- if (results.size() != 1)
+ {
+ String wpStoreId = WCMUtil.getWebProjectStoreId(name);
+ if (WCMUtil.getWebProjectNodeFromWebProjectStore(fService, wpStoreId) != null)
{
- return null;
+ return wpStoreId;
}
- String dnsString = results.keySet().iterator().next().getLocalName();
- String storeName = dnsString.substring(dnsString.lastIndexOf('.') + 1, dnsString.length());
- final int index = storeName.indexOf(STORE_SEPARATOR);
- return (index == -1
- ? storeName
- : storeName.substring(0, index));
+ return null;
}
private void grabLock(String path)
diff --git a/source/java/org/alfresco/repo/avm/AVMServiceTest.java b/source/java/org/alfresco/repo/avm/AVMServiceTest.java
index 0167ff58e4..89a56e8854 100644
--- a/source/java/org/alfresco/repo/avm/AVMServiceTest.java
+++ b/source/java/org/alfresco/repo/avm/AVMServiceTest.java
@@ -268,17 +268,21 @@ public class AVMServiceTest extends AVMServiceTestBase
AVMService oldService = fService;
fService = (AVMService) fContext.getBean("AVMLockingAwareService");
AuthenticationService authService = (AuthenticationService) fContext.getBean("AuthenticationService");
+
try
{
- fService.setStoreProperty("main", QName.createQName(null, ".dns.main"), new PropertyValue(DataTypeDefinition.TEXT, "Nothing."));
- fService.createStore("test");
- fService.setStoreProperty("test", QName.createQName(null, ".dns.test.main"), new PropertyValue(DataTypeDefinition.TEXT, "Nothing."));
+ // note: locking applies to WCM web projects, hence relies on WCM sandbox conventions (naming and properties)
+ fService.setStoreProperty("main", SandboxConstants.PROP_WEB_PROJECT_NODE_REF, new PropertyValue(DataTypeDefinition.NODE_REF, new NodeRef("workspace://SpacesStore/dummy")));
+
+ fService.createStore("main--admin");
+
setupBasicTree0();
- authService.authenticateAsGuest();
- // assertEquals(0, fLockingService.getUsersLocks("admin").size());
- List diffs = fSyncService.compare(-1, "main:/", -1, "test:/", null);
+
+
+ List diffs = fSyncService.compare(-1, "main:/", -1, "main--admin:/", null);
assertEquals(2, diffs.size());
- assertEquals("[main:/a[-1] > test:/a[-1], main:/d[-1] > test:/d[-1]]", diffs.toString());
+ assertEquals("[main:/a[-1] > main--admin:/a[-1], main:/d[-1] > main--admin:/d[-1]]", diffs.toString());
+
fSyncService.update(diffs, null, false, false, false, false, null, null);
RetryingTransactionHelper.RetryingTransactionCallback