RM-1105: Adding the RM module causes exceptions when listing the existing audit applications through the audit webscript - Added a try/catch for a ClassCastException around the check to see if the returned object contained a PROP_HOLD_REASON in the RMAfterInvocationProvider. The reason for this is that the containsKeys method will throw a class cast exception if we attempt to see if the keys contain an instance of QName if the returnedObject instance is a TreeMap containing strings as is the case when listing the audit applications through the RESTful interface.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.1@59361 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Mark Hibbins
2014-01-03 11:47:59 +00:00
parent b584da0c79
commit fbe6f44c21

View File

@@ -951,24 +951,31 @@ public class RMAfterInvocationProvider extends RMSecurityCommon
@SuppressWarnings({"unchecked", "rawtypes" })
private Map decide(Authentication authentication, Object object, ConfigAttributeDefinition config, Map returnedObject) throws AccessDeniedException
{
if (returnedObject.containsKey(RecordsManagementModel.PROP_HOLD_REASON))
{
HashMap filtered = new HashMap();
filtered.putAll(returnedObject);
// get the node ref from the properties or delete
String protocol = DefaultTypeConverter.INSTANCE.convert(String.class, filtered.get(ContentModel.PROP_STORE_PROTOCOL));
String identifier = DefaultTypeConverter.INSTANCE.convert(String.class, filtered.get(ContentModel.PROP_STORE_IDENTIFIER));
String uuid = DefaultTypeConverter.INSTANCE.convert(String.class, filtered.get(ContentModel.PROP_NODE_UUID));
StoreRef storeRef = new StoreRef(protocol, identifier);
NodeRef nodeRef = new NodeRef(storeRef, uuid);
if ((nodeRef == null) || (permissionService.hasPermission(filePlanService.getFilePlan(nodeRef), RMPermissionModel.VIEW_UPDATE_REASONS_FOR_FREEZE) != AccessStatus.ALLOWED))
try {
if (returnedObject.containsKey(RecordsManagementModel.PROP_HOLD_REASON))
{
filtered.remove(RecordsManagementModel.PROP_HOLD_REASON);
HashMap filtered = new HashMap();
filtered.putAll(returnedObject);
// get the node ref from the properties or delete
String protocol = DefaultTypeConverter.INSTANCE.convert(String.class, filtered.get(ContentModel.PROP_STORE_PROTOCOL));
String identifier = DefaultTypeConverter.INSTANCE.convert(String.class, filtered.get(ContentModel.PROP_STORE_IDENTIFIER));
String uuid = DefaultTypeConverter.INSTANCE.convert(String.class, filtered.get(ContentModel.PROP_NODE_UUID));
StoreRef storeRef = new StoreRef(protocol, identifier);
NodeRef nodeRef = new NodeRef(storeRef, uuid);
if ((nodeRef == null) || (permissionService.hasPermission(filePlanService.getFilePlan(nodeRef), RMPermissionModel.VIEW_UPDATE_REASONS_FOR_FREEZE) != AccessStatus.ALLOWED))
{
filtered.remove(RecordsManagementModel.PROP_HOLD_REASON);
}
return filtered;
}
else
{
return returnedObject;
}
return filtered;
}
else
catch(ClassCastException ex)
{
// This will happen if returnedObject is an instance of TreeMap containing anything other than instances of QName
return returnedObject;
}
}