Fix WCM-857

Added AVMLockingService.removeLocksInDirectory() which, given the state of AttributeService, is a bit
of a sledgehammer.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6932 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2007-10-08 15:14:11 +00:00
parent e5bef04dbf
commit 2a47726733
3 changed files with 113 additions and 103 deletions

View File

@@ -678,6 +678,8 @@ 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);
}
/* (non-Javadoc)
@@ -689,6 +691,7 @@ 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]);
}
/* (non-Javadoc)

View File

@@ -322,42 +322,41 @@ 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;
// }
// }
}
/* (non-Javadoc)
* @see org.alfresco.service.cmr.avm.locking.AVMLockingService#removeLocksInDirectory(java.lang.String, java.lang.String, java.lang.String)
*/
public void removeLocksInDirectory(String webProject, String store,
String path)
{
path = normalizePath(path);
if (logger.isDebugEnabled())
{
logger.debug("removing locks in directory: " + path + "(" + webProject + ", " + store + ")");
}
List<String> keys = new ArrayList<String>();
keys.add(LOCK_TABLE);
keys.add(WEB_PROJECTS);
keys.add(webProject);
Attribute map = fAttributeService.getAttribute(keys);
if (map == null)
{
return;
}
for (Map.Entry<String, Attribute> entry : map.entrySet())
{
if (logger.isDebugEnabled())
{
logger.debug(entry);
}
Attribute child = entry.getValue();
if (child.get("store").getStringValue().equals(store) &&
child.get("path").getStringValue().startsWith(path + '/'))
{
fAttributeService.removeAttribute(keys, entry.getKey());
}
}
}
/* (non-Javadoc)

View File

@@ -77,6 +77,14 @@ public interface AVMLockingService
*/
public void removeLock(String webProject, String path);
/**
* Remove all locks on files contained within a directory.
* @param webProject
* @param store
* @param path
*/
public void removeLocksInDirectory(String webProject, String store, String path);
/**
* Removes all locks residing in a store.
* @param store The store name.