RM-1835 (Error is generated when giving access on a list to a user)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.3@95742 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2015-02-02 17:32:11 +00:00
parent b1a6035e4e
commit 1b54651c6e

View File

@@ -18,6 +18,8 @@
*/ */
package org.alfresco.module.org_alfresco_module_rm.caveat; package org.alfresco.module.org_alfresco_module_rm.caveat;
import static org.apache.commons.lang.exception.ExceptionUtils.getFullStackTrace;
import java.io.File; import java.io.File;
import java.io.InputStream; import java.io.InputStream;
import java.io.Serializable; import java.io.Serializable;
@@ -992,10 +994,8 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon
*/ */
private String convertToJSONString(SimpleCache<String, Map<String, List<String>>> config) private String convertToJSONString(SimpleCache<String, Map<String, List<String>>> config)
{ {
JSONObject obj = new JSONObject(); JSONObject configJSONObject = new JSONObject();
try
{
Collection<String> listNames = config.getKeys(); Collection<String> listNames = config.getKeys();
for (String listName : listNames) for (String listName : listNames)
{ {
@@ -1006,17 +1006,46 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon
for (String authorityName : authorityNames) for (String authorityName : authorityNames)
{ {
listMembers.put(authorityName, members.get(authorityName)); List<String> authorities = members.get(authorityName);
try
{
listMembers.put(authorityName, authorities);
}
catch (JSONException error)
{
StringBuilder sb = new StringBuilder();
sb.append("Cannot add the key '");
sb.append(authorityName);
sb.append("' with the value '");
sb.append(authorities);
sb.append("' to the JSONObject 'listMembers' '");
sb.append(listMembers);
sb.append("': ");
sb.append(getFullStackTrace(error));
throw new AlfrescoRuntimeException(sb.toString());
}
} }
obj.put(listName, listMembers); try
}
}
catch (JSONException je)
{ {
throw new AlfrescoRuntimeException("Invalid caveat config syntax: "+ je); configJSONObject.put(listName, listMembers);
} }
return obj.toString(); catch (JSONException error)
{
StringBuilder sb = new StringBuilder();
sb.append("Cannot add the key '");
sb.append(listName);
sb.append("' with the value '");
sb.append(listMembers);
sb.append("' to the JSONObject 'configJSONObject' '");
sb.append(configJSONObject);
sb.append("': ");
sb.append(getFullStackTrace(error));
throw new AlfrescoRuntimeException(sb.toString());
}
}
return configJSONObject.toString();
} }
/** /**