mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
RM-732: CLONE - "caveat" functionality of the (dod5015) Records Management Module is not cluster-aware
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.0@52115 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -892,9 +892,44 @@
|
|||||||
|
|
||||||
<property name="caveatAspects" ref="caveatAspects"/>
|
<property name="caveatAspects" ref="caveatAspects"/>
|
||||||
<property name="caveatModels" ref="caveatModels"/>
|
<property name="caveatModels" ref="caveatModels"/>
|
||||||
|
|
||||||
|
<property name="caveatConfig" ref="caveatConfigCache"/>
|
||||||
|
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
<!-- ===================================== -->
|
||||||
|
<!-- Record Management Caveat Config Cache -->
|
||||||
|
<!-- ===================================== -->
|
||||||
|
|
||||||
|
<!-- The cross-transaction shared cache for in-memory CaveatConfig -->
|
||||||
|
|
||||||
|
<bean name="caveatConfigSharedCache" class="org.alfresco.repo.cache.EhCacheAdapter">
|
||||||
|
<property name="cache">
|
||||||
|
<bean class="org.springframework.cache.ehcache.EhCacheFactoryBean" >
|
||||||
|
<property name="cacheManager">
|
||||||
|
<ref bean="internalEHCacheManager" />
|
||||||
|
</property>
|
||||||
|
<property name="cacheName">
|
||||||
|
<value>org.alfresco.cache.caveatConfigCache</value>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<!-- The transactional cache for in-memory CaveatConfig -->
|
||||||
|
|
||||||
|
<bean name="caveatConfigCache" class="org.alfresco.repo.cache.TransactionalCache">
|
||||||
|
<property name="sharedCache">
|
||||||
|
<ref bean="caveatConfigSharedCache" />
|
||||||
|
</property>
|
||||||
|
<property name="name">
|
||||||
|
<value>org.alfresco.caveatConfigTransactionalCache</value>
|
||||||
|
</property>
|
||||||
|
<property name="maxCacheSize" value="500" />
|
||||||
|
<property name="mutable" value="true" />
|
||||||
|
<property name="disableSharedCache" value="${system.cache.disableMutableSharedCaches}" />
|
||||||
|
</bean>
|
||||||
|
|
||||||
<bean id="caveatAspects" class="java.util.ArrayList" >
|
<bean id="caveatAspects" class="java.util.ArrayList" >
|
||||||
<constructor-arg>
|
<constructor-arg>
|
||||||
<list>
|
<list>
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
* Copyright (C) 2005-2013 Alfresco Software Limited.
|
||||||
*
|
*
|
||||||
* This file is part of Alfresco
|
* This file is part of Alfresco
|
||||||
*
|
*
|
||||||
@@ -22,18 +22,22 @@ import java.io.File;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.locks.Lock;
|
||||||
|
import java.util.concurrent.locks.ReadWriteLock;
|
||||||
|
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.caveat.RMListOfValuesConstraint.MatchLogic;
|
import org.alfresco.module.org_alfresco_module_rm.caveat.RMListOfValuesConstraint.MatchLogic;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||||
|
import org.alfresco.repo.cache.SimpleCache;
|
||||||
import org.alfresco.repo.content.ContentServicePolicies;
|
import org.alfresco.repo.content.ContentServicePolicies;
|
||||||
import org.alfresco.repo.content.MimetypeMap;
|
import org.alfresco.repo.content.MimetypeMap;
|
||||||
import org.alfresco.repo.node.NodeServicePolicies;
|
import org.alfresco.repo.node.NodeServicePolicies;
|
||||||
@@ -97,16 +101,25 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon
|
|||||||
|
|
||||||
private static final QName DATATYPE_TEXT = DataTypeDefinition.TEXT;
|
private static final QName DATATYPE_TEXT = DataTypeDefinition.TEXT;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lock objects
|
||||||
|
*/
|
||||||
|
private ReadWriteLock lock = new ReentrantReadWriteLock();
|
||||||
|
private Lock readLock = lock.readLock();
|
||||||
|
private Lock writeLock = lock.writeLock();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Caveat Config
|
* Caveat Config (Shared) config
|
||||||
* first string is property name
|
* first string is property name
|
||||||
* second string is authority name (user or group full name)
|
* second string is authority name (user or group full name)
|
||||||
* third string is list of values of property
|
* third string is list of values of property
|
||||||
*/
|
*/
|
||||||
|
private SimpleCache<String, Map<String, List<String>>> caveatConfig;
|
||||||
|
|
||||||
// TODO - convert to SimpleCache to be cluster-aware (for dynamic changes to caveat config across a cluster)
|
public void setCaveatConfig(SimpleCache<String, Map<String, List<String>>> caveatConfig)
|
||||||
private Map<String, Map<String, List<String>>> caveatConfig = new ConcurrentHashMap<String, Map<String, List<String>>>(2);
|
{
|
||||||
|
this.caveatConfig = caveatConfig;
|
||||||
|
}
|
||||||
|
|
||||||
public void setPolicyComponent(PolicyComponent policyComponent)
|
public void setPolicyComponent(PolicyComponent policyComponent)
|
||||||
{
|
{
|
||||||
@@ -252,6 +265,12 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon
|
|||||||
validateAndReset(childAssocRef.getChildRef());
|
validateAndReset(childAssocRef.getChildRef());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate the caveat config and optionally update the cache.
|
||||||
|
*
|
||||||
|
* @param nodeRef The nodeRef of the config
|
||||||
|
* @param updateCache Set to <code>true</code> to update the cache
|
||||||
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
protected void validateAndReset(NodeRef nodeRef)
|
protected void validateAndReset(NodeRef nodeRef)
|
||||||
{
|
{
|
||||||
@@ -409,15 +428,29 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Valid, so update
|
try
|
||||||
caveatConfig.clear();
|
|
||||||
|
|
||||||
for (Map.Entry<String, Object> conEntry : caveatConfigMap.entrySet())
|
|
||||||
{
|
{
|
||||||
String conStr = conEntry.getKey();
|
writeLock.lock();
|
||||||
Map<String, List<String>> caveatMap = (Map<String, List<String>>)conEntry.getValue();
|
// we can't just clear the cache, as all puts to the cache afterwards in this transaction will be ignored
|
||||||
|
// first delete all keys that are now not in the config
|
||||||
|
caveatConfig.getKeys().retainAll(caveatConfigMap.keySet());
|
||||||
|
|
||||||
caveatConfig.put(conStr, caveatMap);
|
for (Map.Entry<String, Object> conEntry : caveatConfigMap.entrySet())
|
||||||
|
{
|
||||||
|
String conStr = conEntry.getKey();
|
||||||
|
Map<String, List<String>> caveatMap = (Map<String, List<String>>)conEntry.getValue();
|
||||||
|
|
||||||
|
Map<String, List<String>> cacheValue = caveatConfig.get(conStr);
|
||||||
|
if (cacheValue == null || !cacheValue.equals(caveatMap))
|
||||||
|
{
|
||||||
|
// update the cache
|
||||||
|
caveatConfig.put(conStr, caveatMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
writeLock.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (JSONException e)
|
catch (JSONException e)
|
||||||
@@ -495,9 +528,19 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get list of all caveat qualified names
|
// Get list of all caveat qualified names
|
||||||
public Set<String> getRMConstraintNames()
|
public Collection<String> getRMConstraintNames()
|
||||||
{
|
{
|
||||||
return caveatConfig.keySet();
|
Collection<String> rmConstraintNames = Collections.emptySet();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
readLock.lock();
|
||||||
|
rmConstraintNames = caveatConfig.getKeys();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
readLock.unlock();
|
||||||
|
}
|
||||||
|
return Collections.unmodifiableCollection(rmConstraintNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get allowed values for given caveat (for current user)
|
// Get allowed values for given caveat (for current user)
|
||||||
@@ -510,8 +553,7 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon
|
|||||||
{
|
{
|
||||||
if (! (AuthenticationUtil.isMtEnabled() && AuthenticationUtil.isRunAsUserTheSystemUser()))
|
if (! (AuthenticationUtil.isMtEnabled() && AuthenticationUtil.isRunAsUserTheSystemUser()))
|
||||||
{
|
{
|
||||||
// note: userName and userGroupNames must not be null
|
// note: userName and userGroupNames must not be null
|
||||||
Map<String, List<String>> caveatConstraintDef = caveatConfig.get(constraintName);
|
|
||||||
Set<String> userGroupFullNames = authorityService.getAuthoritiesForUser(userName);
|
Set<String> userGroupFullNames = authorityService.getAuthoritiesForUser(userName);
|
||||||
allowedValues = getRMAllowedValues(userName, userGroupFullNames, constraintName);
|
allowedValues = getRMAllowedValues(userName, userGroupFullNames, constraintName);
|
||||||
}
|
}
|
||||||
@@ -525,7 +567,16 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon
|
|||||||
Set<String>allowedValues = new HashSet<String>();
|
Set<String>allowedValues = new HashSet<String>();
|
||||||
|
|
||||||
// note: userName and userGroupNames must not be null
|
// note: userName and userGroupNames must not be null
|
||||||
Map<String, List<String>> caveatConstraintDef = caveatConfig.get(constraintName);
|
Map<String, List<String>> caveatConstraintDef = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
readLock.lock();
|
||||||
|
caveatConstraintDef = caveatConfig.get(constraintName);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
readLock.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
if (caveatConstraintDef != null)
|
if (caveatConstraintDef != null)
|
||||||
{
|
{
|
||||||
@@ -547,7 +598,7 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon
|
|||||||
|
|
||||||
List<String>ret = new ArrayList<String>();
|
List<String>ret = new ArrayList<String>();
|
||||||
ret.addAll(allowedValues);
|
ret.addAll(allowedValues);
|
||||||
return ret;
|
return Collections.unmodifiableList(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -692,23 +743,53 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon
|
|||||||
*
|
*
|
||||||
* @param listName the name of the RMConstraintList
|
* @param listName the name of the RMConstraintList
|
||||||
* @param authorityName
|
* @param authorityName
|
||||||
* @param values
|
* @param value
|
||||||
* @throws AlfrescoRuntimeException if either the list or the authority do not already exist.
|
* @throws AlfrescoRuntimeException if either the list or the authority do not already exist.
|
||||||
*/
|
*/
|
||||||
public void addRMConstraintListValue(String listName, String authorityName, String value)
|
public void addRMConstraintListValue(String listName, String authorityName, String value)
|
||||||
{
|
{
|
||||||
Map<String, List<String>> members = caveatConfig.get(listName);
|
Map<String, List<String>> members = null;
|
||||||
if(members == null)
|
try
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("unable to add to list, list not defined:"+ listName);
|
readLock.lock();
|
||||||
|
members = caveatConfig.get(listName);
|
||||||
|
if(members == null)
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("unable to add to list, list not defined:"+ listName);
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
readLock.unlock();
|
||||||
|
writeLock.lock();
|
||||||
|
// check again
|
||||||
|
members = caveatConfig.get(listName);
|
||||||
|
if(members == null)
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("unable to add to list, list not defined:"+ listName);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> values = members.get(authorityName);
|
||||||
|
if(values == null)
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("Unable to add to authority in list. Authority not member listName: "+ listName + " authorityName:" +authorityName);
|
||||||
|
}
|
||||||
|
values.add(value);
|
||||||
|
|
||||||
|
caveatConfig.put(listName, members);
|
||||||
|
updateOrCreateCaveatConfig(convertToJSONString(caveatConfig));
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
readLock.lock();
|
||||||
|
writeLock.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
List<String> values = members.get(authorityName);
|
finally
|
||||||
if(values == null)
|
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("Unable to add to authority in list. Authority not member listName: "+ listName + " authorityName:" +authorityName);
|
readLock.unlock();
|
||||||
}
|
}
|
||||||
values.add(value);
|
|
||||||
updateOrCreateCaveatConfig(convertToJSONString(caveatConfig));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -718,7 +799,24 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon
|
|||||||
*/
|
*/
|
||||||
public Map<String, List<String>> getListDetails(String listName)
|
public Map<String, List<String>> getListDetails(String listName)
|
||||||
{
|
{
|
||||||
return caveatConfig.get(listName);
|
Map<String, List<String>> listDetails = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
readLock.lock();
|
||||||
|
listDetails = caveatConfig.get(listName);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
readLock.unlock();
|
||||||
|
}
|
||||||
|
if (listDetails == null)
|
||||||
|
{
|
||||||
|
return Collections.emptyMap();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Collections.unmodifiableMap(listDetails);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<QName> getRMCaveatModels()
|
public List<QName> getRMCaveatModels()
|
||||||
@@ -738,20 +836,30 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon
|
|||||||
*/
|
*/
|
||||||
public void updateRMConstraintListAuthority(String listName, String authorityName, List<String>values)
|
public void updateRMConstraintListAuthority(String listName, String authorityName, List<String>values)
|
||||||
{
|
{
|
||||||
Map<String, List<String>> members = caveatConfig.get(listName);
|
Map<String, List<String>> members = null;
|
||||||
if(members == null)
|
try
|
||||||
{
|
{
|
||||||
// Create the new list, with the authority name
|
writeLock.lock();
|
||||||
Map<String, List<String>> constraint = new HashMap<String, List<String>>(0);
|
members = caveatConfig.get(listName);
|
||||||
constraint.put(authorityName, values);
|
if(members == null)
|
||||||
caveatConfig.put(listName, constraint);
|
{
|
||||||
}
|
// Create the new list, with the authority name
|
||||||
else
|
Map<String, List<String>> constraint = new HashMap<String, List<String>>(0);
|
||||||
{
|
constraint.put(authorityName, new ArrayList<String>(values));
|
||||||
members.put(authorityName, values);
|
members = constraint;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
members.put(authorityName, new ArrayList<String>(values));
|
||||||
|
}
|
||||||
|
|
||||||
updateOrCreateCaveatConfig(convertToJSONString(caveatConfig));
|
caveatConfig.put(listName, members);
|
||||||
|
updateOrCreateCaveatConfig(convertToJSONString(caveatConfig));
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
writeLock.unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -764,57 +872,19 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon
|
|||||||
public void updateRMConstraintListValue(String listName, String valueName, List<String>authorities)
|
public void updateRMConstraintListValue(String listName, String valueName, List<String>authorities)
|
||||||
{
|
{
|
||||||
|
|
||||||
// members contains member, values[]
|
Map<String, List<String>> members = null;
|
||||||
Map<String, List<String>> members = caveatConfig.get(listName);
|
try
|
||||||
|
|
||||||
if(members == null)
|
|
||||||
{
|
{
|
||||||
// Members List does not exist
|
writeLock.lock();
|
||||||
Map<String, List<String>> emptyConstraint = new HashMap<String, List<String>>(0);
|
|
||||||
caveatConfig.put(listName, emptyConstraint);
|
|
||||||
members = emptyConstraint;
|
|
||||||
|
|
||||||
}
|
|
||||||
// authorities contains authority, values[]
|
|
||||||
// pivot contains value, members[]
|
|
||||||
Map<String, List<String>> pivot = PivotUtil.getPivot(members);
|
|
||||||
|
|
||||||
// remove all authorities which have this value
|
if(members == null)
|
||||||
List<String> existingAuthorities = pivot.get(valueName);
|
|
||||||
if(existingAuthorities != null)
|
|
||||||
{
|
|
||||||
for(String authority : existingAuthorities)
|
|
||||||
{
|
{
|
||||||
List<String> vals = members.get(authority);
|
// Members List does not exist
|
||||||
vals.remove(valueName);
|
Map<String, List<String>> emptyConstraint = new HashMap<String, List<String>>(0);
|
||||||
|
caveatConfig.put(listName, emptyConstraint);
|
||||||
|
members = emptyConstraint;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// add the new authorities for this value
|
|
||||||
for(String authority : authorities)
|
|
||||||
{
|
|
||||||
List<String> vals = members.get(authority);
|
|
||||||
if(vals == null)
|
|
||||||
{
|
|
||||||
vals= new ArrayList<String>();
|
|
||||||
members.put(authority, vals);
|
|
||||||
}
|
|
||||||
vals.add(valueName);
|
|
||||||
}
|
|
||||||
|
|
||||||
updateOrCreateCaveatConfig(convertToJSONString(caveatConfig));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeRMConstraintListValue(String listName, String valueName)
|
|
||||||
{
|
|
||||||
// members contains member, values[]
|
|
||||||
Map<String, List<String>> members = caveatConfig.get(listName);
|
|
||||||
|
|
||||||
if(members == null)
|
|
||||||
{
|
|
||||||
// list does not exist
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// authorities contains authority, values[]
|
// authorities contains authority, values[]
|
||||||
// pivot contains value, members[]
|
// pivot contains value, members[]
|
||||||
Map<String, List<String>> pivot = PivotUtil.getPivot(members);
|
Map<String, List<String>> pivot = PivotUtil.getPivot(members);
|
||||||
@@ -829,8 +899,82 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon
|
|||||||
vals.remove(valueName);
|
vals.remove(valueName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// add the new authorities for this value
|
||||||
updateOrCreateCaveatConfig(convertToJSONString(caveatConfig));
|
for(String authority : authorities)
|
||||||
|
{
|
||||||
|
List<String> vals = members.get(authority);
|
||||||
|
if(vals == null)
|
||||||
|
{
|
||||||
|
vals= new ArrayList<String>();
|
||||||
|
members.put(authority, vals);
|
||||||
|
}
|
||||||
|
vals.add(valueName);
|
||||||
|
}
|
||||||
|
caveatConfig.put(listName, members);
|
||||||
|
updateOrCreateCaveatConfig(convertToJSONString(caveatConfig));
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
writeLock.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeRMConstraintListValue(String listName, String valueName)
|
||||||
|
{
|
||||||
|
Map<String, List<String>> members = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
readLock.lock();
|
||||||
|
|
||||||
|
members = caveatConfig.get(listName);
|
||||||
|
if(members == null)
|
||||||
|
{
|
||||||
|
// list does not exist
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
readLock.unlock();
|
||||||
|
writeLock.lock();
|
||||||
|
// check again
|
||||||
|
members = caveatConfig.get(listName);
|
||||||
|
if(members == null)
|
||||||
|
{
|
||||||
|
// list does not exist
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// authorities contains authority, values[]
|
||||||
|
// pivot contains value, members[]
|
||||||
|
Map<String, List<String>> pivot = PivotUtil.getPivot(members);
|
||||||
|
|
||||||
|
// remove all authorities which have this value
|
||||||
|
List<String> existingAuthorities = pivot.get(valueName);
|
||||||
|
if(existingAuthorities != null)
|
||||||
|
{
|
||||||
|
for(String authority : existingAuthorities)
|
||||||
|
{
|
||||||
|
List<String> vals = members.get(authority);
|
||||||
|
vals.remove(valueName);
|
||||||
|
}
|
||||||
|
caveatConfig.put(listName, members);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
updateOrCreateCaveatConfig(convertToJSONString(caveatConfig));
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
readLock.lock();
|
||||||
|
writeLock.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
readLock.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -843,26 +987,37 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon
|
|||||||
*/
|
*/
|
||||||
public void removeRMConstraintListAuthority(String listName, String authorityName)
|
public void removeRMConstraintListAuthority(String listName, String authorityName)
|
||||||
{
|
{
|
||||||
Map<String, List<String>> members = caveatConfig.get(listName);
|
Map<String, List<String>> members = null;
|
||||||
if(members != null)
|
try
|
||||||
{
|
{
|
||||||
members.remove(listName);
|
writeLock.lock();
|
||||||
|
members = caveatConfig.get(listName);
|
||||||
|
if(members != null)
|
||||||
|
{
|
||||||
|
members.remove(listName);
|
||||||
|
}
|
||||||
|
|
||||||
|
caveatConfig.put(listName, members);
|
||||||
|
updateOrCreateCaveatConfig(convertToJSONString(caveatConfig));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
updateOrCreateCaveatConfig(convertToJSONString(caveatConfig));
|
{
|
||||||
}
|
writeLock.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param config the configuration to convert
|
* @param config the configuration to convert
|
||||||
* @return a String containing the JSON representation of the configuration.
|
* @return a String containing the JSON representation of the configuration.
|
||||||
*/
|
*/
|
||||||
private String convertToJSONString(Map<String, Map<String, List<String>>> config)
|
private String convertToJSONString(SimpleCache<String, Map<String, List<String>>> config)
|
||||||
{
|
{
|
||||||
JSONObject obj = new JSONObject();
|
JSONObject obj = new JSONObject();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Set<String> listNames = config.keySet();
|
Collection<String> listNames = config.getKeys();
|
||||||
for(String listName : listNames)
|
for(String listName : listNames)
|
||||||
{
|
{
|
||||||
Map<String, List<String>> members = config.get(listName);
|
Map<String, List<String>> members = config.get(listName);
|
||||||
@@ -932,14 +1087,30 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon
|
|||||||
|
|
||||||
public void deleteRMConstraint(String listName)
|
public void deleteRMConstraint(String listName)
|
||||||
{
|
{
|
||||||
caveatConfig.remove(listName);
|
try
|
||||||
updateOrCreateCaveatConfig(convertToJSONString(caveatConfig));
|
{
|
||||||
|
writeLock.lock();
|
||||||
|
caveatConfig.remove(listName);
|
||||||
|
updateOrCreateCaveatConfig(convertToJSONString(caveatConfig));
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
writeLock.unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addRMConstraint(String listName)
|
public void addRMConstraint(String listName)
|
||||||
{
|
{
|
||||||
Map<String, List<String>> emptyConstraint = new HashMap<String, List<String>>(0);
|
try
|
||||||
caveatConfig.put(listName, emptyConstraint);
|
{
|
||||||
updateOrCreateCaveatConfig(convertToJSONString(caveatConfig));
|
writeLock.lock();
|
||||||
|
Map<String, List<String>> emptyConstraint = new HashMap<String, List<String>>(0);
|
||||||
|
caveatConfig.put(listName, emptyConstraint);
|
||||||
|
updateOrCreateCaveatConfig(convertToJSONString(caveatConfig));
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
writeLock.unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user