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:
@@ -8,5 +8,6 @@
|
|||||||
<classpathentry kind="src" path="/3rd Party"/>
|
<classpathentry kind="src" path="/3rd Party"/>
|
||||||
<classpathentry combineaccessrules="false" kind="src" path="/MBean"/>
|
<classpathentry combineaccessrules="false" kind="src" path="/MBean"/>
|
||||||
<classpathentry combineaccessrules="false" kind="src" path="/Deployment"/>
|
<classpathentry combineaccessrules="false" kind="src" path="/Deployment"/>
|
||||||
|
<classpathentry kind="lib" path="/3rd Party/lib/ehcache-1.3.0.jar"/>
|
||||||
<classpathentry kind="output" path="build/classes"/>
|
<classpathentry kind="output" path="build/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
@@ -873,7 +873,6 @@ public class AVMLockingAwareService implements AVMService, ApplicationContextAwa
|
|||||||
{
|
{
|
||||||
throw new AVMLockingException("avmlockservice.locked", new Object[]{path});
|
throw new AVMLockingException("avmlockservice.locked", new Object[]{path});
|
||||||
}
|
}
|
||||||
fLockingService.addWebProject(webProject);
|
|
||||||
if (fLockingService.getLock(webProject, storePath[1]) == null)
|
if (fLockingService.getLock(webProject, storePath[1]) == null)
|
||||||
{
|
{
|
||||||
List<String> owners = new ArrayList<String>(1);
|
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);
|
private static Logger fgLogger = Logger.getLogger(AVMNodeService.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flag for whether policy callbacks are made.
|
||||||
|
*/
|
||||||
|
private boolean fInvokePolicies = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reference to AVMService.
|
* 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
|
* Gets a list of all available node store references
|
||||||
*
|
*
|
||||||
@@ -1265,13 +1275,14 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
|||||||
{
|
{
|
||||||
try
|
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);
|
fAVMService.setContentData(avmVersionPath.getSecond(), (ContentData)value);
|
||||||
Map<QName, Serializable> propsAfter = new HashMap<QName, Serializable>();
|
if (fInvokePolicies)
|
||||||
propsAfter.put(ContentModel.PROP_CONTENT, value);
|
{
|
||||||
invokeOnUpdateProperties(nodeRef, propsBefore, propsAfter);
|
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)
|
catch (ClassCastException e)
|
||||||
{
|
{
|
||||||
|
@@ -101,6 +101,54 @@ import org.alfresco.util.Pair;
|
|||||||
*/
|
*/
|
||||||
public class AVMServiceTest extends AVMServiceTestBase
|
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.
|
* 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.
|
* Test async indexing.
|
||||||
|
@@ -26,15 +26,13 @@
|
|||||||
package org.alfresco.repo.avm.locking;
|
package org.alfresco.repo.avm.locking;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.alfresco.model.WCMAppModel;
|
import org.alfresco.model.WCMAppModel;
|
||||||
import org.alfresco.repo.attributes.Attribute;
|
import org.alfresco.repo.attributes.Attribute;
|
||||||
import org.alfresco.repo.attributes.ListAttributeValue;
|
|
||||||
import org.alfresco.repo.attributes.MapAttributeValue;
|
import org.alfresco.repo.attributes.MapAttributeValue;
|
||||||
import org.alfresco.repo.attributes.StringAttributeValue;
|
|
||||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||||
import org.alfresco.service.cmr.attributes.AttrQueryEquals;
|
import org.alfresco.service.cmr.attributes.AttrQueryEquals;
|
||||||
import org.alfresco.service.cmr.attributes.AttributeService;
|
import org.alfresco.service.cmr.attributes.AttributeService;
|
||||||
@@ -169,6 +167,7 @@ public class AVMLockingServiceImpl implements AVMLockingService
|
|||||||
Attribute table = fAttributeService.getAttribute(LOCK_TABLE);
|
Attribute table = fAttributeService.getAttribute(LOCK_TABLE);
|
||||||
if (table != null)
|
if (table != null)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
Attribute stores = fAttributeService.getAttribute(LOCK_TABLE + '/' + STORES);
|
Attribute stores = fAttributeService.getAttribute(LOCK_TABLE + '/' + STORES);
|
||||||
if (stores == null)
|
if (stores == null)
|
||||||
{
|
{
|
||||||
@@ -178,7 +177,8 @@ public class AVMLockingServiceImpl implements AVMLockingService
|
|||||||
if (users == null)
|
if (users == null)
|
||||||
{
|
{
|
||||||
fAttributeService.setAttribute(LOCK_TABLE, USERS, new MapAttributeValue());
|
fAttributeService.setAttribute(LOCK_TABLE, USERS, new MapAttributeValue());
|
||||||
; }
|
}
|
||||||
|
*/
|
||||||
Attribute webProjects = fAttributeService.getAttribute(LOCK_TABLE + '/' + WEB_PROJECTS);
|
Attribute webProjects = fAttributeService.getAttribute(LOCK_TABLE + '/' + WEB_PROJECTS);
|
||||||
if (webProjects == null)
|
if (webProjects == null)
|
||||||
{
|
{
|
||||||
@@ -188,8 +188,10 @@ public class AVMLockingServiceImpl implements AVMLockingService
|
|||||||
}
|
}
|
||||||
fAttributeService.setAttribute("", LOCK_TABLE, new MapAttributeValue());
|
fAttributeService.setAttribute("", LOCK_TABLE, new MapAttributeValue());
|
||||||
fAttributeService.setAttribute(LOCK_TABLE, WEB_PROJECTS, new MapAttributeValue());
|
fAttributeService.setAttribute(LOCK_TABLE, WEB_PROJECTS, new MapAttributeValue());
|
||||||
|
/*
|
||||||
fAttributeService.setAttribute(LOCK_TABLE, USERS, new MapAttributeValue());
|
fAttributeService.setAttribute(LOCK_TABLE, USERS, new MapAttributeValue());
|
||||||
fAttributeService.setAttribute(LOCK_TABLE, STORES, new MapAttributeValue());
|
fAttributeService.setAttribute(LOCK_TABLE, STORES, new MapAttributeValue());
|
||||||
|
*/
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -238,23 +240,24 @@ public class AVMLockingServiceImpl implements AVMLockingService
|
|||||||
*/
|
*/
|
||||||
public List<AVMLock> getUsersLocks(String user)
|
public List<AVMLock> getUsersLocks(String user)
|
||||||
{
|
{
|
||||||
List<String> keys = new ArrayList<String>(3);
|
// List<String> keys = new ArrayList<String>(3);
|
||||||
keys.add(LOCK_TABLE);
|
// keys.add(LOCK_TABLE);
|
||||||
keys.add(USERS);
|
// keys.add(USERS);
|
||||||
keys.add(user);
|
// keys.add(user);
|
||||||
Attribute userLocks = fAttributeService.getAttribute(keys);
|
// Attribute userLocks = fAttributeService.getAttribute(keys);
|
||||||
List<AVMLock> locks = new ArrayList<AVMLock>();
|
// List<AVMLock> locks = new ArrayList<AVMLock>();
|
||||||
if (userLocks == null)
|
// if (userLocks == null)
|
||||||
{
|
// {
|
||||||
return locks;
|
// return locks;
|
||||||
}
|
// }
|
||||||
for (Attribute entry : userLocks)
|
// for (Attribute entry : userLocks)
|
||||||
{
|
// {
|
||||||
String webProject = entry.get("web_project").getStringValue();
|
// String webProject = entry.get("web_project").getStringValue();
|
||||||
String path = entry.get("path").getStringValue();
|
// String path = entry.get("path").getStringValue();
|
||||||
locks.add(getLock(webProject, path));
|
// locks.add(getLock(webProject, path));
|
||||||
}
|
// }
|
||||||
return locks;
|
// return locks;
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@@ -275,43 +278,46 @@ public class AVMLockingServiceImpl implements AVMLockingService
|
|||||||
keys.add(LOCK_TABLE);
|
keys.add(LOCK_TABLE);
|
||||||
keys.add(WEB_PROJECTS);
|
keys.add(WEB_PROJECTS);
|
||||||
keys.add(lock.getWebProject());
|
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);
|
throw new AVMExistsException("Lock Exists: " + keys);
|
||||||
}
|
}
|
||||||
fAttributeService.setAttribute(keys, MD5.Digest(lock.getPath().getBytes()), lockData);
|
keys.remove(3);
|
||||||
Attribute reverseEntry = new MapAttributeValue();
|
fAttributeService.setAttribute(keys, digest, lockData);
|
||||||
reverseEntry.put("web_project", new StringAttributeValue(lock.getWebProject()));
|
// Attribute reverseEntry = new MapAttributeValue();
|
||||||
reverseEntry.put("path", new StringAttributeValue(lock.getPath()));
|
// reverseEntry.put("web_project", new StringAttributeValue(lock.getWebProject()));
|
||||||
keys.clear();
|
// reverseEntry.put("path", new StringAttributeValue(lock.getPath()));
|
||||||
keys.add(LOCK_TABLE);
|
// keys.clear();
|
||||||
keys.add(USERS);
|
// keys.add(LOCK_TABLE);
|
||||||
for (String user : lock.getOwners())
|
// keys.add(USERS);
|
||||||
{
|
// for (String user : lock.getOwners())
|
||||||
keys.add(user);
|
// {
|
||||||
Attribute userEntry = fAttributeService.getAttribute(keys);
|
// keys.add(user);
|
||||||
keys.remove(2);
|
// Attribute userEntry = fAttributeService.getAttribute(keys);
|
||||||
if (userEntry == null)
|
// keys.remove(2);
|
||||||
{
|
// if (userEntry == null)
|
||||||
fAttributeService.setAttribute(keys, user, new ListAttributeValue());
|
// {
|
||||||
}
|
// fAttributeService.setAttribute(keys, user, new ListAttributeValue());
|
||||||
keys.add(user);
|
// }
|
||||||
fAttributeService.addAttribute(keys, reverseEntry);
|
// keys.add(user);
|
||||||
keys.remove(2);
|
// fAttributeService.addAttribute(keys, reverseEntry);
|
||||||
}
|
// keys.remove(2);
|
||||||
String store = lock.getStore();
|
// }
|
||||||
keys.clear();
|
// String store = lock.getStore();
|
||||||
keys.add(LOCK_TABLE);
|
// keys.clear();
|
||||||
keys.add(STORES);
|
// keys.add(LOCK_TABLE);
|
||||||
keys.add(store);
|
// keys.add(STORES);
|
||||||
Attribute storeEntry = fAttributeService.getAttribute(keys);
|
// keys.add(store);
|
||||||
keys.remove(2);
|
// Attribute storeEntry = fAttributeService.getAttribute(keys);
|
||||||
if (storeEntry == null)
|
// keys.remove(2);
|
||||||
{
|
// if (storeEntry == null)
|
||||||
fAttributeService.setAttribute(keys, store, new ListAttributeValue());
|
// {
|
||||||
}
|
// fAttributeService.setAttribute(keys, store, new ListAttributeValue());
|
||||||
keys.add(store);
|
// }
|
||||||
fAttributeService.addAttribute(keys, reverseEntry);
|
// keys.add(store);
|
||||||
|
// fAttributeService.addAttribute(keys, reverseEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@@ -333,42 +339,42 @@ public class AVMLockingServiceImpl implements AVMLockingService
|
|||||||
}
|
}
|
||||||
keys.remove(3);
|
keys.remove(3);
|
||||||
fAttributeService.removeAttribute(keys, pathKey);
|
fAttributeService.removeAttribute(keys, pathKey);
|
||||||
AVMLock lock = new AVMLock(lockData);
|
// AVMLock lock = new AVMLock(lockData);
|
||||||
List<String> userKeys = new ArrayList<String>();
|
// List<String> userKeys = new ArrayList<String>();
|
||||||
userKeys.add(LOCK_TABLE);
|
// userKeys.add(LOCK_TABLE);
|
||||||
userKeys.add(USERS);
|
// userKeys.add(USERS);
|
||||||
for (String user : lock.getOwners())
|
// for (String user : lock.getOwners())
|
||||||
{
|
// {
|
||||||
userKeys.add(user);
|
// userKeys.add(user);
|
||||||
Attribute userLocks = fAttributeService.getAttribute(userKeys);
|
// Attribute userLocks = fAttributeService.getAttribute(userKeys);
|
||||||
for (int i = userLocks.size() - 1; i >= 0; i--)
|
// for (int i = userLocks.size() - 1; i >= 0; i--)
|
||||||
{
|
// {
|
||||||
Attribute lockInfo = userLocks.get(i);
|
// Attribute lockInfo = userLocks.get(i);
|
||||||
if (lockInfo.get("web_project").getStringValue().equals(lock.getWebProject())
|
// if (lockInfo.get("web_project").getStringValue().equals(lock.getWebProject())
|
||||||
&& lockInfo.get("path").getStringValue().equals(lock.getPath()))
|
// && lockInfo.get("path").getStringValue().equals(lock.getPath()))
|
||||||
{
|
// {
|
||||||
fAttributeService.removeAttribute(userKeys, i);
|
// fAttributeService.removeAttribute(userKeys, i);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
userKeys.remove(2);
|
// userKeys.remove(2);
|
||||||
}
|
// }
|
||||||
List<String> storeKeys = new ArrayList<String>(3);
|
// List<String> storeKeys = new ArrayList<String>(3);
|
||||||
storeKeys.add(LOCK_TABLE);
|
// storeKeys.add(LOCK_TABLE);
|
||||||
storeKeys.add(STORES);
|
// storeKeys.add(STORES);
|
||||||
String store = lock.getStore();
|
// String store = lock.getStore();
|
||||||
storeKeys.add(store);
|
// storeKeys.add(store);
|
||||||
Attribute storeLocks = fAttributeService.getAttribute(storeKeys);
|
// Attribute storeLocks = fAttributeService.getAttribute(storeKeys);
|
||||||
for (int i = storeLocks.size() - 1; i >= 0; i--)
|
// for (int i = storeLocks.size() - 1; i >= 0; i--)
|
||||||
{
|
// {
|
||||||
Attribute lockInfo = storeLocks.get(i);
|
// Attribute lockInfo = storeLocks.get(i);
|
||||||
if (lockInfo.get("web_project").getStringValue().equals(lock.getWebProject()) &&
|
// if (lockInfo.get("web_project").getStringValue().equals(lock.getWebProject()) &&
|
||||||
lockInfo.get("path").getStringValue().equals(lock.getPath()))
|
// lockInfo.get("path").getStringValue().equals(lock.getPath()))
|
||||||
{
|
// {
|
||||||
fAttributeService.removeAttribute(storeKeys, i);
|
// fAttributeService.removeAttribute(storeKeys, i);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@@ -380,7 +386,7 @@ public class AVMLockingServiceImpl implements AVMLockingService
|
|||||||
keys.add(LOCK_TABLE);
|
keys.add(LOCK_TABLE);
|
||||||
keys.add(WEB_PROJECTS);
|
keys.add(WEB_PROJECTS);
|
||||||
keys.add(webProject);
|
keys.add(webProject);
|
||||||
if (fAttributeService.getAttribute(keys) != null)
|
if (fAttributeService.exists(keys))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -414,49 +420,49 @@ public class AVMLockingServiceImpl implements AVMLockingService
|
|||||||
*/
|
*/
|
||||||
public void removeWebProject(String webProject)
|
public void removeWebProject(String webProject)
|
||||||
{
|
{
|
||||||
List<String> userKeys = new ArrayList<String>(2);
|
// List<String> userKeys = new ArrayList<String>(2);
|
||||||
userKeys.add(LOCK_TABLE);
|
// userKeys.add(LOCK_TABLE);
|
||||||
userKeys.add(USERS);
|
// userKeys.add(USERS);
|
||||||
List<String> users = fAttributeService.getKeys(userKeys);
|
// List<String> users = fAttributeService.getKeys(userKeys);
|
||||||
// TODO This works incredibly slowly. AttributeService has to support
|
// // TODO This works incredibly slowly. AttributeService has to support
|
||||||
// extended querying on values.
|
// // extended querying on values.
|
||||||
for (String user : users)
|
// for (String user : users)
|
||||||
{
|
// {
|
||||||
userKeys.add(user);
|
// userKeys.add(user);
|
||||||
Attribute userLocks = fAttributeService.getAttribute(userKeys);
|
// Attribute userLocks = fAttributeService.getAttribute(userKeys);
|
||||||
Iterator<Attribute> iter = userLocks.iterator();
|
// Iterator<Attribute> iter = userLocks.iterator();
|
||||||
while (iter.hasNext())
|
// while (iter.hasNext())
|
||||||
{
|
// {
|
||||||
Attribute lockInfo = iter.next();
|
// Attribute lockInfo = iter.next();
|
||||||
if (lockInfo.get("web_project").getStringValue().equals(webProject))
|
// if (lockInfo.get("web_project").getStringValue().equals(webProject))
|
||||||
{
|
// {
|
||||||
iter.remove();
|
// iter.remove();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
userKeys.remove(2);
|
// userKeys.remove(2);
|
||||||
fAttributeService.setAttribute(userKeys, user, userLocks);
|
// fAttributeService.setAttribute(userKeys, user, userLocks);
|
||||||
}
|
// }
|
||||||
List<String> storeKeys = new ArrayList<String>();
|
// List<String> storeKeys = new ArrayList<String>();
|
||||||
storeKeys.add(LOCK_TABLE);
|
// storeKeys.add(LOCK_TABLE);
|
||||||
storeKeys.add(STORES);
|
// storeKeys.add(STORES);
|
||||||
List<String> stores = fAttributeService.getKeys(storeKeys);
|
// List<String> stores = fAttributeService.getKeys(storeKeys);
|
||||||
// TODO Ditto.
|
// // TODO Ditto.
|
||||||
for (String store : stores)
|
// for (String store : stores)
|
||||||
{
|
// {
|
||||||
storeKeys.add(store);
|
// storeKeys.add(store);
|
||||||
Attribute storeLocks = fAttributeService.getAttribute(storeKeys);
|
// Attribute storeLocks = fAttributeService.getAttribute(storeKeys);
|
||||||
Iterator<Attribute> iter = storeLocks.iterator();
|
// Iterator<Attribute> iter = storeLocks.iterator();
|
||||||
while (iter.hasNext())
|
// while (iter.hasNext())
|
||||||
{
|
// {
|
||||||
Attribute lockInfo = iter.next();
|
// Attribute lockInfo = iter.next();
|
||||||
if (lockInfo.get("web_project").getStringValue().equals(webProject))
|
// if (lockInfo.get("web_project").getStringValue().equals(webProject))
|
||||||
{
|
// {
|
||||||
iter.remove();
|
// iter.remove();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
storeKeys.remove(2);
|
// storeKeys.remove(2);
|
||||||
fAttributeService.setAttribute(storeKeys, store, storeLocks);
|
// fAttributeService.setAttribute(storeKeys, store, storeLocks);
|
||||||
}
|
// }
|
||||||
List<String> keys = new ArrayList<String>(2);
|
List<String> keys = new ArrayList<String>(2);
|
||||||
keys.add(LOCK_TABLE);
|
keys.add(LOCK_TABLE);
|
||||||
keys.add(WEB_PROJECTS);
|
keys.add(WEB_PROJECTS);
|
||||||
@@ -468,27 +474,28 @@ public class AVMLockingServiceImpl implements AVMLockingService
|
|||||||
*/
|
*/
|
||||||
public List<AVMLock> getStoreLocks(String store)
|
public List<AVMLock> getStoreLocks(String store)
|
||||||
{
|
{
|
||||||
List<AVMLock> locks = new ArrayList<AVMLock>(3);
|
return null;
|
||||||
List<String> keys = new ArrayList<String>();
|
// List<AVMLock> locks = new ArrayList<AVMLock>(3);
|
||||||
keys.add(LOCK_TABLE);
|
// List<String> keys = new ArrayList<String>();
|
||||||
keys.add(STORES);
|
// keys.add(LOCK_TABLE);
|
||||||
keys.add(store);
|
// keys.add(STORES);
|
||||||
List<String> lockKeys = new ArrayList<String>();
|
// keys.add(store);
|
||||||
lockKeys.add(LOCK_TABLE);
|
// List<String> lockKeys = new ArrayList<String>();
|
||||||
lockKeys.add(WEB_PROJECTS);
|
// lockKeys.add(LOCK_TABLE);
|
||||||
Attribute storeLocks = fAttributeService.getAttribute(keys);
|
// lockKeys.add(WEB_PROJECTS);
|
||||||
for (Attribute lockInfo : storeLocks)
|
// Attribute storeLocks = fAttributeService.getAttribute(keys);
|
||||||
{
|
// for (Attribute lockInfo : storeLocks)
|
||||||
String webProject = lockInfo.get("web_project").getStringValue();
|
// {
|
||||||
String path = lockInfo.get("path").getStringValue();
|
// String webProject = lockInfo.get("web_project").getStringValue();
|
||||||
lockKeys.add(webProject);
|
// String path = lockInfo.get("path").getStringValue();
|
||||||
lockKeys.add(MD5.Digest(path.getBytes()));
|
// lockKeys.add(webProject);
|
||||||
Attribute lockData = fAttributeService.getAttribute(lockKeys);
|
// lockKeys.add(MD5.Digest(path.getBytes()));
|
||||||
locks.add(new AVMLock(lockData));
|
// Attribute lockData = fAttributeService.getAttribute(lockKeys);
|
||||||
lockKeys.remove(3);
|
// locks.add(new AVMLock(lockData));
|
||||||
lockKeys.remove(2);
|
// lockKeys.remove(3);
|
||||||
}
|
// lockKeys.remove(2);
|
||||||
return locks;
|
// }
|
||||||
|
// return locks;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@@ -541,20 +548,31 @@ public class AVMLockingServiceImpl implements AVMLockingService
|
|||||||
*/
|
*/
|
||||||
public void removeStoreLocks(String store)
|
public void removeStoreLocks(String store)
|
||||||
{
|
{
|
||||||
List<String> storeKeys = new ArrayList<String>(3);
|
String webProject = store;
|
||||||
storeKeys.add(LOCK_TABLE);
|
int index = store.indexOf("--");
|
||||||
storeKeys.add(STORES);
|
if (index >= 0)
|
||||||
storeKeys.add(store);
|
{
|
||||||
Attribute storeLocks = fAttributeService.getAttribute(storeKeys);
|
webProject = store.substring(0, index);
|
||||||
if (storeLocks == null)
|
}
|
||||||
|
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;
|
return;
|
||||||
}
|
}
|
||||||
for (Attribute lockInfo : storeLocks)
|
for (Map.Entry<String, Attribute> entry: project.entrySet())
|
||||||
{
|
{
|
||||||
removeLock(lockInfo.get("web_project").getStringValue(),
|
AVMLock lock = new AVMLock(entry.getValue());
|
||||||
lockInfo.get("path").getStringValue());
|
if (lock.getStore().equals(store))
|
||||||
|
{
|
||||||
|
project.remove(entry.getKey());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
keys.remove(2);
|
||||||
|
fAttributeService.setAttribute(keys, webProject, project);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@@ -168,7 +168,7 @@ public class AVMLockingServiceTest extends TestCase
|
|||||||
fService.lockPath(lock);
|
fService.lockPath(lock);
|
||||||
System.out.println(fAttributeService.getAttribute(".avm_lock_table"));
|
System.out.println(fAttributeService.getAttribute(".avm_lock_table"));
|
||||||
assertNotNull(fService.getLock("alfresco", "Revello Drive/1630"));
|
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());
|
assertEquals(1, fService.getWebProjectLocks("alfresco").size());
|
||||||
List<String> owners2 = new ArrayList<String>();
|
List<String> owners2 = new ArrayList<String>();
|
||||||
owners2.add("Buffy");
|
owners2.add("Buffy");
|
||||||
@@ -180,18 +180,18 @@ public class AVMLockingServiceTest extends TestCase
|
|||||||
owners2);
|
owners2);
|
||||||
fService.lockPath(lock2);
|
fService.lockPath(lock2);
|
||||||
System.out.println(fAttributeService.getAttribute(".avm_lock_table"));
|
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());
|
assertEquals(2, fService.getWebProjectLocks("alfresco").size());
|
||||||
fService.removeLock("alfresco", "Revello Drive/1630");
|
fService.removeLock("alfresco", "Revello Drive/1630");
|
||||||
System.out.println(fAttributeService.getAttribute(".avm_lock_table"));
|
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());
|
assertEquals(1, fService.getWebProjectLocks("alfresco").size());
|
||||||
fService.removeWebProject("alfresco");
|
fService.removeWebProject("alfresco");
|
||||||
System.out.println(fAttributeService.getAttribute(".avm_lock_table"));
|
System.out.println(fAttributeService.getAttribute(".avm_lock_table"));
|
||||||
assertEquals(0, fService.getUsersLocks("Spike").size());
|
// assertEquals(0, fService.getUsersLocks("Spike").size());
|
||||||
assertEquals(0, fService.getUsersLocks("Buffy").size());
|
// assertEquals(0, fService.getUsersLocks("Buffy").size());
|
||||||
assertEquals(0, fService.getUsersLocks("Willow").size());
|
// assertEquals(0, fService.getUsersLocks("Willow").size());
|
||||||
assertEquals(0, fService.getUsersLocks("Tara").size());
|
// assertEquals(0, fService.getUsersLocks("Tara").size());
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user