mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merge DEV\WCM_SERVICES2 to HEAD
12513 Implementation of Asset.getProperties 12469 Implement paths relative to web app. And unit tests. Asset Test is now clean of TODOs. 12413 Implementation of WCM Asset. Still work remaining but this is 80% of the implementation. 12404 WCM Services - asset service - fix rename/move folder issue (folders are not locked) - sandbox service - fix delete sandbox test 12374 WCM Services - optimise get/is web project 12347 WCM Services - "asset service" - add/remove/has aspect, get aspects 12341 WCM Services - "asset service" checkpoint (locking fixes, bulk import, more tests added) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@12547 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -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<QName, PropertyValue> 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)
|
||||
|
@@ -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<AVMDifference> diffs = fSyncService.compare(-1, "main:/", -1, "test:/", null);
|
||||
|
||||
|
||||
List<AVMDifference> 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<Object> cb = new RetryingTransactionHelper.RetryingTransactionCallback<Object>()
|
||||
{
|
||||
@@ -286,7 +290,7 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
{
|
||||
BulkLoader loader = new BulkLoader();
|
||||
loader.setAvmService(fService);
|
||||
loader.recursiveLoad("source/java/org/alfresco/repo/avm", "main:/");
|
||||
loader.recursiveLoad("source/java/org/alfresco/repo/avm", "main--admin:/");
|
||||
return null;
|
||||
}
|
||||
};
|
||||
@@ -304,8 +308,7 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
fLockingService.removeStoreLocks("main");
|
||||
fLockingService.removeWebProject("main");
|
||||
authService.authenticate("admin", "admin".toCharArray());
|
||||
|
||||
fService.purgeStore("test");
|
||||
fService.purgeStore("main--admin");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1967,6 +1970,7 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
final String STAGING = "foo-staging"; // note: it is implied that the website/webproject name is the same as staging name
|
||||
try
|
||||
{
|
||||
|
||||
fService.createStore(STAGING);
|
||||
fService.createDirectory(STAGING+":/", JNDIConstants.DIR_DEFAULT_WWW);
|
||||
fService.createDirectory(STAGING+":/" + JNDIConstants.DIR_DEFAULT_WWW, "a");
|
||||
@@ -1975,7 +1979,7 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
fService.createFile(STAGING+":/" + JNDIConstants.DIR_DEFAULT_WWW + "/a/b/c", "foo").close();
|
||||
fService.createFile(STAGING+":/" + JNDIConstants.DIR_DEFAULT_WWW + "/a/b/c", "bar").close();
|
||||
fService.createStore("area");
|
||||
fService.setStoreProperty("area", SandboxConstants.PROP_WEBSITE_NAME, new PropertyValue(null, STAGING)); // note: it is implied that the website name is the same as staging name
|
||||
fService.setStoreProperty("area", SandboxConstants.PROP_WEBSITE_NAME, new PropertyValue(null, STAGING)); // note: it is implied that the website name is the same as staging name
|
||||
fService.createLayeredDirectory(STAGING+":/" + JNDIConstants.DIR_DEFAULT_WWW, "area:/", JNDIConstants.DIR_DEFAULT_WWW);
|
||||
fService.createFile("area:/" + JNDIConstants.DIR_DEFAULT_WWW, "figs").close();
|
||||
fService.getFileOutputStream("area:/" + JNDIConstants.DIR_DEFAULT_WWW + "/a/b/c/foo").close();
|
||||
|
Reference in New Issue
Block a user