mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Bulk import into sandboxes has reached the stage of just sucking.
Thought I'd check in this stage. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6188 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -873,7 +873,6 @@ public class AVMLockingAwareService implements AVMService, ApplicationContextAwa
|
||||
{
|
||||
throw new AVMLockingException("avmlockservice.locked", new Object[]{path});
|
||||
}
|
||||
fLockingService.addWebProject(webProject);
|
||||
if (fLockingService.getLock(webProject, storePath[1]) == null)
|
||||
{
|
||||
List<String> owners = new ArrayList<String>(1);
|
||||
|
@@ -77,6 +77,11 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
||||
{
|
||||
private static Logger fgLogger = Logger.getLogger(AVMNodeService.class);
|
||||
|
||||
/**
|
||||
* Flag for whether policy callbacks are made.
|
||||
*/
|
||||
private boolean fInvokePolicies = false;
|
||||
|
||||
/**
|
||||
* Reference to AVMService.
|
||||
*/
|
||||
@@ -98,6 +103,11 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
||||
{
|
||||
}
|
||||
|
||||
public void setInvokePolicies(boolean invoke)
|
||||
{
|
||||
fInvokePolicies = invoke;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of all available node store references
|
||||
*
|
||||
@@ -1265,13 +1275,14 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
||||
{
|
||||
try
|
||||
{
|
||||
Map<QName, Serializable> propsBefore = new HashMap<QName, Serializable>();
|
||||
// ContentData oldContentData = fAVMService.getContentDataForRead(-1, avmVersionPath.getSecond());
|
||||
// propsBefore.put(ContentModel.PROP_CONTENT, oldContentData);
|
||||
fAVMService.setContentData(avmVersionPath.getSecond(), (ContentData)value);
|
||||
Map<QName, Serializable> propsAfter = new HashMap<QName, Serializable>();
|
||||
propsAfter.put(ContentModel.PROP_CONTENT, value);
|
||||
invokeOnUpdateProperties(nodeRef, propsBefore, propsAfter);
|
||||
if (fInvokePolicies)
|
||||
{
|
||||
Map<QName, Serializable> propsBefore = new HashMap<QName, Serializable>();
|
||||
Map<QName, Serializable> propsAfter = new HashMap<QName, Serializable>();
|
||||
propsAfter.put(ContentModel.PROP_CONTENT, value);
|
||||
invokeOnUpdateProperties(nodeRef, propsBefore, propsAfter);
|
||||
}
|
||||
}
|
||||
catch (ClassCastException e)
|
||||
{
|
||||
|
@@ -101,6 +101,54 @@ import org.alfresco.util.Pair;
|
||||
*/
|
||||
public class AVMServiceTest extends AVMServiceTestBase
|
||||
{
|
||||
/**
|
||||
* Minimal testing of Locking Aware service.
|
||||
*/
|
||||
public void testLockingAwareService()
|
||||
{
|
||||
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(QName.createQName(null, "silly"), "Nothing."));
|
||||
fService.createStore("test");
|
||||
fService.setStoreProperty("test", QName.createQName(null, ".dns.test.main"),
|
||||
new PropertyValue(QName.createQName(null, "silly"), "Nothing."));
|
||||
setupBasicTree0();
|
||||
authService.authenticateAsGuest();
|
||||
// assertEquals(0, fLockingService.getUsersLocks("admin").size());
|
||||
List<AVMDifference> diffs = fSyncService.compare(-1, "main:/", -1, "test:/", null);
|
||||
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||
RetryingTransactionHelper.RetryingTransactionCallback<Object> cb =
|
||||
new RetryingTransactionHelper.RetryingTransactionCallback<Object>()
|
||||
{
|
||||
public Object execute()
|
||||
throws Exception
|
||||
{
|
||||
BulkLoader loader = new BulkLoader();
|
||||
loader.setAvmService(fService);
|
||||
loader.recursiveLoad("source/java/org/alfresco/repo/avm", "main:/");
|
||||
return null;
|
||||
}
|
||||
};
|
||||
RetryingTransactionHelper helper = (RetryingTransactionHelper)fContext.getBean("retryingTransactionHelper");
|
||||
helper.doInTransaction(cb);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
finally
|
||||
{
|
||||
fService = oldService;
|
||||
fLockingService.removeWebProject("main");
|
||||
authService.authenticate("admin", "admin".toCharArray());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test version by date lookup.
|
||||
*/
|
||||
@@ -270,39 +318,6 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Minimal testing of Locking Aware service.
|
||||
*/
|
||||
public void testLockingAwareService()
|
||||
{
|
||||
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(QName.createQName(null, "silly"), "Nothing."));
|
||||
fService.createStore("test");
|
||||
fService.setStoreProperty("test", QName.createQName(null, ".dns.test.main"),
|
||||
new PropertyValue(QName.createQName(null, "silly"), "Nothing."));
|
||||
setupBasicTree0();
|
||||
authService.authenticateAsGuest();
|
||||
assertEquals(0, fLockingService.getUsersLocks("admin").size());
|
||||
List<AVMDifference> diffs = fSyncService.compare(-1, "main:/", -1, "test:/", null);
|
||||
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
finally
|
||||
{
|
||||
fService = oldService;
|
||||
fLockingService.removeWebProject("main");
|
||||
authService.authenticate("admin", "admin".toCharArray());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test async indexing.
|
||||
|
@@ -26,15 +26,13 @@
|
||||
package org.alfresco.repo.avm.locking;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.model.WCMAppModel;
|
||||
import org.alfresco.repo.attributes.Attribute;
|
||||
import org.alfresco.repo.attributes.ListAttributeValue;
|
||||
import org.alfresco.repo.attributes.MapAttributeValue;
|
||||
import org.alfresco.repo.attributes.StringAttributeValue;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||
import org.alfresco.service.cmr.attributes.AttrQueryEquals;
|
||||
import org.alfresco.service.cmr.attributes.AttributeService;
|
||||
@@ -169,6 +167,7 @@ public class AVMLockingServiceImpl implements AVMLockingService
|
||||
Attribute table = fAttributeService.getAttribute(LOCK_TABLE);
|
||||
if (table != null)
|
||||
{
|
||||
/*
|
||||
Attribute stores = fAttributeService.getAttribute(LOCK_TABLE + '/' + STORES);
|
||||
if (stores == null)
|
||||
{
|
||||
@@ -178,7 +177,8 @@ public class AVMLockingServiceImpl implements AVMLockingService
|
||||
if (users == null)
|
||||
{
|
||||
fAttributeService.setAttribute(LOCK_TABLE, USERS, new MapAttributeValue());
|
||||
; }
|
||||
}
|
||||
*/
|
||||
Attribute webProjects = fAttributeService.getAttribute(LOCK_TABLE + '/' + WEB_PROJECTS);
|
||||
if (webProjects == null)
|
||||
{
|
||||
@@ -188,8 +188,10 @@ public class AVMLockingServiceImpl implements AVMLockingService
|
||||
}
|
||||
fAttributeService.setAttribute("", LOCK_TABLE, new MapAttributeValue());
|
||||
fAttributeService.setAttribute(LOCK_TABLE, WEB_PROJECTS, new MapAttributeValue());
|
||||
/*
|
||||
fAttributeService.setAttribute(LOCK_TABLE, USERS, new MapAttributeValue());
|
||||
fAttributeService.setAttribute(LOCK_TABLE, STORES, new MapAttributeValue());
|
||||
*/
|
||||
return null;
|
||||
}
|
||||
};
|
||||
@@ -238,23 +240,24 @@ public class AVMLockingServiceImpl implements AVMLockingService
|
||||
*/
|
||||
public List<AVMLock> getUsersLocks(String user)
|
||||
{
|
||||
List<String> keys = new ArrayList<String>(3);
|
||||
keys.add(LOCK_TABLE);
|
||||
keys.add(USERS);
|
||||
keys.add(user);
|
||||
Attribute userLocks = fAttributeService.getAttribute(keys);
|
||||
List<AVMLock> locks = new ArrayList<AVMLock>();
|
||||
if (userLocks == null)
|
||||
{
|
||||
return locks;
|
||||
}
|
||||
for (Attribute entry : userLocks)
|
||||
{
|
||||
String webProject = entry.get("web_project").getStringValue();
|
||||
String path = entry.get("path").getStringValue();
|
||||
locks.add(getLock(webProject, path));
|
||||
}
|
||||
return locks;
|
||||
// List<String> keys = new ArrayList<String>(3);
|
||||
// keys.add(LOCK_TABLE);
|
||||
// keys.add(USERS);
|
||||
// keys.add(user);
|
||||
// Attribute userLocks = fAttributeService.getAttribute(keys);
|
||||
// List<AVMLock> locks = new ArrayList<AVMLock>();
|
||||
// if (userLocks == null)
|
||||
// {
|
||||
// return locks;
|
||||
// }
|
||||
// for (Attribute entry : userLocks)
|
||||
// {
|
||||
// String webProject = entry.get("web_project").getStringValue();
|
||||
// String path = entry.get("path").getStringValue();
|
||||
// locks.add(getLock(webProject, path));
|
||||
// }
|
||||
// return locks;
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -275,43 +278,46 @@ public class AVMLockingServiceImpl implements AVMLockingService
|
||||
keys.add(LOCK_TABLE);
|
||||
keys.add(WEB_PROJECTS);
|
||||
keys.add(lock.getWebProject());
|
||||
if (fAttributeService.getAttribute(keys) == null)
|
||||
String digest = MD5.Digest(lock.getPath().getBytes());
|
||||
keys.add(digest);
|
||||
if (fAttributeService.getAttribute(keys) != null)
|
||||
{
|
||||
throw new AVMExistsException("Lock Exists: " + keys);
|
||||
}
|
||||
fAttributeService.setAttribute(keys, MD5.Digest(lock.getPath().getBytes()), lockData);
|
||||
Attribute reverseEntry = new MapAttributeValue();
|
||||
reverseEntry.put("web_project", new StringAttributeValue(lock.getWebProject()));
|
||||
reverseEntry.put("path", new StringAttributeValue(lock.getPath()));
|
||||
keys.clear();
|
||||
keys.add(LOCK_TABLE);
|
||||
keys.add(USERS);
|
||||
for (String user : lock.getOwners())
|
||||
{
|
||||
keys.add(user);
|
||||
Attribute userEntry = fAttributeService.getAttribute(keys);
|
||||
keys.remove(2);
|
||||
if (userEntry == null)
|
||||
{
|
||||
fAttributeService.setAttribute(keys, user, new ListAttributeValue());
|
||||
}
|
||||
keys.add(user);
|
||||
fAttributeService.addAttribute(keys, reverseEntry);
|
||||
keys.remove(2);
|
||||
}
|
||||
String store = lock.getStore();
|
||||
keys.clear();
|
||||
keys.add(LOCK_TABLE);
|
||||
keys.add(STORES);
|
||||
keys.add(store);
|
||||
Attribute storeEntry = fAttributeService.getAttribute(keys);
|
||||
keys.remove(2);
|
||||
if (storeEntry == null)
|
||||
{
|
||||
fAttributeService.setAttribute(keys, store, new ListAttributeValue());
|
||||
}
|
||||
keys.add(store);
|
||||
fAttributeService.addAttribute(keys, reverseEntry);
|
||||
keys.remove(3);
|
||||
fAttributeService.setAttribute(keys, digest, lockData);
|
||||
// Attribute reverseEntry = new MapAttributeValue();
|
||||
// reverseEntry.put("web_project", new StringAttributeValue(lock.getWebProject()));
|
||||
// reverseEntry.put("path", new StringAttributeValue(lock.getPath()));
|
||||
// keys.clear();
|
||||
// keys.add(LOCK_TABLE);
|
||||
// keys.add(USERS);
|
||||
// for (String user : lock.getOwners())
|
||||
// {
|
||||
// keys.add(user);
|
||||
// Attribute userEntry = fAttributeService.getAttribute(keys);
|
||||
// keys.remove(2);
|
||||
// if (userEntry == null)
|
||||
// {
|
||||
// fAttributeService.setAttribute(keys, user, new ListAttributeValue());
|
||||
// }
|
||||
// keys.add(user);
|
||||
// fAttributeService.addAttribute(keys, reverseEntry);
|
||||
// keys.remove(2);
|
||||
// }
|
||||
// String store = lock.getStore();
|
||||
// keys.clear();
|
||||
// keys.add(LOCK_TABLE);
|
||||
// keys.add(STORES);
|
||||
// keys.add(store);
|
||||
// Attribute storeEntry = fAttributeService.getAttribute(keys);
|
||||
// keys.remove(2);
|
||||
// if (storeEntry == null)
|
||||
// {
|
||||
// fAttributeService.setAttribute(keys, store, new ListAttributeValue());
|
||||
// }
|
||||
// keys.add(store);
|
||||
// fAttributeService.addAttribute(keys, reverseEntry);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -333,42 +339,42 @@ public class AVMLockingServiceImpl implements AVMLockingService
|
||||
}
|
||||
keys.remove(3);
|
||||
fAttributeService.removeAttribute(keys, pathKey);
|
||||
AVMLock lock = new AVMLock(lockData);
|
||||
List<String> userKeys = new ArrayList<String>();
|
||||
userKeys.add(LOCK_TABLE);
|
||||
userKeys.add(USERS);
|
||||
for (String user : lock.getOwners())
|
||||
{
|
||||
userKeys.add(user);
|
||||
Attribute userLocks = fAttributeService.getAttribute(userKeys);
|
||||
for (int i = userLocks.size() - 1; i >= 0; i--)
|
||||
{
|
||||
Attribute lockInfo = userLocks.get(i);
|
||||
if (lockInfo.get("web_project").getStringValue().equals(lock.getWebProject())
|
||||
&& lockInfo.get("path").getStringValue().equals(lock.getPath()))
|
||||
{
|
||||
fAttributeService.removeAttribute(userKeys, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
userKeys.remove(2);
|
||||
}
|
||||
List<String> storeKeys = new ArrayList<String>(3);
|
||||
storeKeys.add(LOCK_TABLE);
|
||||
storeKeys.add(STORES);
|
||||
String store = lock.getStore();
|
||||
storeKeys.add(store);
|
||||
Attribute storeLocks = fAttributeService.getAttribute(storeKeys);
|
||||
for (int i = storeLocks.size() - 1; i >= 0; i--)
|
||||
{
|
||||
Attribute lockInfo = storeLocks.get(i);
|
||||
if (lockInfo.get("web_project").getStringValue().equals(lock.getWebProject()) &&
|
||||
lockInfo.get("path").getStringValue().equals(lock.getPath()))
|
||||
{
|
||||
fAttributeService.removeAttribute(storeKeys, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// AVMLock lock = new AVMLock(lockData);
|
||||
// List<String> userKeys = new ArrayList<String>();
|
||||
// userKeys.add(LOCK_TABLE);
|
||||
// userKeys.add(USERS);
|
||||
// for (String user : lock.getOwners())
|
||||
// {
|
||||
// userKeys.add(user);
|
||||
// Attribute userLocks = fAttributeService.getAttribute(userKeys);
|
||||
// for (int i = userLocks.size() - 1; i >= 0; i--)
|
||||
// {
|
||||
// Attribute lockInfo = userLocks.get(i);
|
||||
// if (lockInfo.get("web_project").getStringValue().equals(lock.getWebProject())
|
||||
// && lockInfo.get("path").getStringValue().equals(lock.getPath()))
|
||||
// {
|
||||
// fAttributeService.removeAttribute(userKeys, i);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// userKeys.remove(2);
|
||||
// }
|
||||
// List<String> storeKeys = new ArrayList<String>(3);
|
||||
// storeKeys.add(LOCK_TABLE);
|
||||
// storeKeys.add(STORES);
|
||||
// String store = lock.getStore();
|
||||
// storeKeys.add(store);
|
||||
// Attribute storeLocks = fAttributeService.getAttribute(storeKeys);
|
||||
// for (int i = storeLocks.size() - 1; i >= 0; i--)
|
||||
// {
|
||||
// Attribute lockInfo = storeLocks.get(i);
|
||||
// if (lockInfo.get("web_project").getStringValue().equals(lock.getWebProject()) &&
|
||||
// lockInfo.get("path").getStringValue().equals(lock.getPath()))
|
||||
// {
|
||||
// fAttributeService.removeAttribute(storeKeys, i);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -380,7 +386,7 @@ public class AVMLockingServiceImpl implements AVMLockingService
|
||||
keys.add(LOCK_TABLE);
|
||||
keys.add(WEB_PROJECTS);
|
||||
keys.add(webProject);
|
||||
if (fAttributeService.getAttribute(keys) != null)
|
||||
if (fAttributeService.exists(keys))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -414,49 +420,49 @@ public class AVMLockingServiceImpl implements AVMLockingService
|
||||
*/
|
||||
public void removeWebProject(String webProject)
|
||||
{
|
||||
List<String> userKeys = new ArrayList<String>(2);
|
||||
userKeys.add(LOCK_TABLE);
|
||||
userKeys.add(USERS);
|
||||
List<String> users = fAttributeService.getKeys(userKeys);
|
||||
// TODO This works incredibly slowly. AttributeService has to support
|
||||
// extended querying on values.
|
||||
for (String user : users)
|
||||
{
|
||||
userKeys.add(user);
|
||||
Attribute userLocks = fAttributeService.getAttribute(userKeys);
|
||||
Iterator<Attribute> iter = userLocks.iterator();
|
||||
while (iter.hasNext())
|
||||
{
|
||||
Attribute lockInfo = iter.next();
|
||||
if (lockInfo.get("web_project").getStringValue().equals(webProject))
|
||||
{
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
userKeys.remove(2);
|
||||
fAttributeService.setAttribute(userKeys, user, userLocks);
|
||||
}
|
||||
List<String> storeKeys = new ArrayList<String>();
|
||||
storeKeys.add(LOCK_TABLE);
|
||||
storeKeys.add(STORES);
|
||||
List<String> stores = fAttributeService.getKeys(storeKeys);
|
||||
// TODO Ditto.
|
||||
for (String store : stores)
|
||||
{
|
||||
storeKeys.add(store);
|
||||
Attribute storeLocks = fAttributeService.getAttribute(storeKeys);
|
||||
Iterator<Attribute> iter = storeLocks.iterator();
|
||||
while (iter.hasNext())
|
||||
{
|
||||
Attribute lockInfo = iter.next();
|
||||
if (lockInfo.get("web_project").getStringValue().equals(webProject))
|
||||
{
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
storeKeys.remove(2);
|
||||
fAttributeService.setAttribute(storeKeys, store, storeLocks);
|
||||
}
|
||||
// List<String> userKeys = new ArrayList<String>(2);
|
||||
// userKeys.add(LOCK_TABLE);
|
||||
// userKeys.add(USERS);
|
||||
// List<String> users = fAttributeService.getKeys(userKeys);
|
||||
// // TODO This works incredibly slowly. AttributeService has to support
|
||||
// // extended querying on values.
|
||||
// for (String user : users)
|
||||
// {
|
||||
// userKeys.add(user);
|
||||
// Attribute userLocks = fAttributeService.getAttribute(userKeys);
|
||||
// Iterator<Attribute> iter = userLocks.iterator();
|
||||
// while (iter.hasNext())
|
||||
// {
|
||||
// Attribute lockInfo = iter.next();
|
||||
// if (lockInfo.get("web_project").getStringValue().equals(webProject))
|
||||
// {
|
||||
// iter.remove();
|
||||
// }
|
||||
// }
|
||||
// userKeys.remove(2);
|
||||
// fAttributeService.setAttribute(userKeys, user, userLocks);
|
||||
// }
|
||||
// List<String> storeKeys = new ArrayList<String>();
|
||||
// storeKeys.add(LOCK_TABLE);
|
||||
// storeKeys.add(STORES);
|
||||
// List<String> stores = fAttributeService.getKeys(storeKeys);
|
||||
// // TODO Ditto.
|
||||
// for (String store : stores)
|
||||
// {
|
||||
// storeKeys.add(store);
|
||||
// Attribute storeLocks = fAttributeService.getAttribute(storeKeys);
|
||||
// Iterator<Attribute> iter = storeLocks.iterator();
|
||||
// while (iter.hasNext())
|
||||
// {
|
||||
// Attribute lockInfo = iter.next();
|
||||
// if (lockInfo.get("web_project").getStringValue().equals(webProject))
|
||||
// {
|
||||
// iter.remove();
|
||||
// }
|
||||
// }
|
||||
// storeKeys.remove(2);
|
||||
// fAttributeService.setAttribute(storeKeys, store, storeLocks);
|
||||
// }
|
||||
List<String> keys = new ArrayList<String>(2);
|
||||
keys.add(LOCK_TABLE);
|
||||
keys.add(WEB_PROJECTS);
|
||||
@@ -468,27 +474,28 @@ public class AVMLockingServiceImpl implements AVMLockingService
|
||||
*/
|
||||
public List<AVMLock> getStoreLocks(String store)
|
||||
{
|
||||
List<AVMLock> locks = new ArrayList<AVMLock>(3);
|
||||
List<String> keys = new ArrayList<String>();
|
||||
keys.add(LOCK_TABLE);
|
||||
keys.add(STORES);
|
||||
keys.add(store);
|
||||
List<String> lockKeys = new ArrayList<String>();
|
||||
lockKeys.add(LOCK_TABLE);
|
||||
lockKeys.add(WEB_PROJECTS);
|
||||
Attribute storeLocks = fAttributeService.getAttribute(keys);
|
||||
for (Attribute lockInfo : storeLocks)
|
||||
{
|
||||
String webProject = lockInfo.get("web_project").getStringValue();
|
||||
String path = lockInfo.get("path").getStringValue();
|
||||
lockKeys.add(webProject);
|
||||
lockKeys.add(MD5.Digest(path.getBytes()));
|
||||
Attribute lockData = fAttributeService.getAttribute(lockKeys);
|
||||
locks.add(new AVMLock(lockData));
|
||||
lockKeys.remove(3);
|
||||
lockKeys.remove(2);
|
||||
}
|
||||
return locks;
|
||||
return null;
|
||||
// List<AVMLock> locks = new ArrayList<AVMLock>(3);
|
||||
// List<String> keys = new ArrayList<String>();
|
||||
// keys.add(LOCK_TABLE);
|
||||
// keys.add(STORES);
|
||||
// keys.add(store);
|
||||
// List<String> lockKeys = new ArrayList<String>();
|
||||
// lockKeys.add(LOCK_TABLE);
|
||||
// lockKeys.add(WEB_PROJECTS);
|
||||
// Attribute storeLocks = fAttributeService.getAttribute(keys);
|
||||
// for (Attribute lockInfo : storeLocks)
|
||||
// {
|
||||
// String webProject = lockInfo.get("web_project").getStringValue();
|
||||
// String path = lockInfo.get("path").getStringValue();
|
||||
// lockKeys.add(webProject);
|
||||
// lockKeys.add(MD5.Digest(path.getBytes()));
|
||||
// Attribute lockData = fAttributeService.getAttribute(lockKeys);
|
||||
// locks.add(new AVMLock(lockData));
|
||||
// lockKeys.remove(3);
|
||||
// lockKeys.remove(2);
|
||||
// }
|
||||
// return locks;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -541,20 +548,31 @@ public class AVMLockingServiceImpl implements AVMLockingService
|
||||
*/
|
||||
public void removeStoreLocks(String store)
|
||||
{
|
||||
List<String> storeKeys = new ArrayList<String>(3);
|
||||
storeKeys.add(LOCK_TABLE);
|
||||
storeKeys.add(STORES);
|
||||
storeKeys.add(store);
|
||||
Attribute storeLocks = fAttributeService.getAttribute(storeKeys);
|
||||
if (storeLocks == null)
|
||||
String webProject = store;
|
||||
int index = store.indexOf("--");
|
||||
if (index >= 0)
|
||||
{
|
||||
webProject = store.substring(0, index);
|
||||
}
|
||||
List<String> keys = new ArrayList<String>(3);
|
||||
keys.add(LOCK_TABLE);
|
||||
keys.add(WEB_PROJECTS);
|
||||
keys.add(webProject);
|
||||
Attribute project = fAttributeService.getAttribute(keys);
|
||||
if (project == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (Attribute lockInfo : storeLocks)
|
||||
for (Map.Entry<String, Attribute> entry: project.entrySet())
|
||||
{
|
||||
removeLock(lockInfo.get("web_project").getStringValue(),
|
||||
lockInfo.get("path").getStringValue());
|
||||
AVMLock lock = new AVMLock(entry.getValue());
|
||||
if (lock.getStore().equals(store))
|
||||
{
|
||||
project.remove(entry.getKey());
|
||||
}
|
||||
}
|
||||
keys.remove(2);
|
||||
fAttributeService.setAttribute(keys, webProject, project);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@@ -168,7 +168,7 @@ public class AVMLockingServiceTest extends TestCase
|
||||
fService.lockPath(lock);
|
||||
System.out.println(fAttributeService.getAttribute(".avm_lock_table"));
|
||||
assertNotNull(fService.getLock("alfresco", "Revello Drive/1630"));
|
||||
assertEquals(1, fService.getUsersLocks("Buffy").size());
|
||||
// assertEquals(1, fService.getUsersLocks("Buffy").size());
|
||||
assertEquals(1, fService.getWebProjectLocks("alfresco").size());
|
||||
List<String> owners2 = new ArrayList<String>();
|
||||
owners2.add("Buffy");
|
||||
@@ -180,18 +180,18 @@ public class AVMLockingServiceTest extends TestCase
|
||||
owners2);
|
||||
fService.lockPath(lock2);
|
||||
System.out.println(fAttributeService.getAttribute(".avm_lock_table"));
|
||||
assertEquals(2, fService.getUsersLocks("Buffy").size());
|
||||
// assertEquals(2, fService.getUsersLocks("Buffy").size());
|
||||
assertEquals(2, fService.getWebProjectLocks("alfresco").size());
|
||||
fService.removeLock("alfresco", "Revello Drive/1630");
|
||||
System.out.println(fAttributeService.getAttribute(".avm_lock_table"));
|
||||
assertEquals(1, fService.getUsersLocks("Buffy").size());
|
||||
// assertEquals(1, fService.getUsersLocks("Buffy").size());
|
||||
assertEquals(1, fService.getWebProjectLocks("alfresco").size());
|
||||
fService.removeWebProject("alfresco");
|
||||
System.out.println(fAttributeService.getAttribute(".avm_lock_table"));
|
||||
assertEquals(0, fService.getUsersLocks("Spike").size());
|
||||
assertEquals(0, fService.getUsersLocks("Buffy").size());
|
||||
assertEquals(0, fService.getUsersLocks("Willow").size());
|
||||
assertEquals(0, fService.getUsersLocks("Tara").size());
|
||||
// assertEquals(0, fService.getUsersLocks("Spike").size());
|
||||
// assertEquals(0, fService.getUsersLocks("Buffy").size());
|
||||
// assertEquals(0, fService.getUsersLocks("Willow").size());
|
||||
// assertEquals(0, fService.getUsersLocks("Tara").size());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
Reference in New Issue
Block a user