From fbe6f44c217cb0482d4596890981cdc1afa0fbf1 Mon Sep 17 00:00:00 2001 From: Mark Hibbins Date: Fri, 3 Jan 2014 11:47:59 +0000 Subject: [PATCH] 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 --- .../capability/RMAfterInvocationProvider.java | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMAfterInvocationProvider.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMAfterInvocationProvider.java index 04912286be..c9d348949f 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMAfterInvocationProvider.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMAfterInvocationProvider.java @@ -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; } }