From 862f17ccc36fd4c9d8f7b194c66b05451b7f1cdc Mon Sep 17 00:00:00 2001 From: Tuna Aksoy Date: Mon, 2 Feb 2015 17:32:11 +0000 Subject: [PATCH 1/2] 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 --- .../caveat/RMCaveatConfigComponentImpl.java | 63 ++++++++++++++----- 1 file changed, 46 insertions(+), 17 deletions(-) diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/RMCaveatConfigComponentImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/RMCaveatConfigComponentImpl.java index ea46bcbe21..84f39925c5 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/RMCaveatConfigComponentImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/RMCaveatConfigComponentImpl.java @@ -18,6 +18,8 @@ */ 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.InputStream; import java.io.Serializable; @@ -992,31 +994,58 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon */ private String convertToJSONString(SimpleCache>> config) { - JSONObject obj = new JSONObject(); + JSONObject configJSONObject = new JSONObject(); - try + Collection listNames = config.getKeys(); + for (String listName : listNames) { - Collection listNames = config.getKeys(); - for(String listName : listNames) + Map> members = config.get(listName); + + Set authorityNames = members.keySet(); + JSONObject listMembers = new JSONObject(); + + for (String authorityName : authorityNames) { - Map> members = config.get(listName); - - Set authorityNames = members.keySet(); - JSONObject listMembers = new JSONObject(); - - for(String authorityName : authorityNames) + List authorities = members.get(authorityName); + try { - listMembers.put(authorityName, members.get(authorityName)); + 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 + { + configJSONObject.put(listName, listMembers); + } + 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()); } } - catch (JSONException je) - { - throw new AlfrescoRuntimeException("Invalid caveat config syntax: "+ je); - } - return obj.toString(); + + return configJSONObject.toString(); } /** From e3c85e78e7ea64ba8763f47c0982a74e0ff73325 Mon Sep 17 00:00:00 2001 From: Tuna Aksoy Date: Mon, 2 Feb 2015 18:17:26 +0000 Subject: [PATCH 2/2] RM-1867 (Reject rule works incorrect if set up in File Plan) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.3@95746 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../FilePlanNamePathDataExtractor.java | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/FilePlanNamePathDataExtractor.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/FilePlanNamePathDataExtractor.java index c38636c8ff..ca86e30a5b 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/FilePlanNamePathDataExtractor.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/FilePlanNamePathDataExtractor.java @@ -77,19 +77,25 @@ public final class FilePlanNamePathDataExtractor extends AbstractDataExtractor */ public Serializable extractData(Serializable value) { + String extractedData = null; + NodeRef nodeRef = (NodeRef) value; - - // Get path from the RM root - List nodeRefPath = filePlanService.getNodeRefPath(nodeRef); - - StringBuilder sb = new StringBuilder(128); - for (NodeRef pathNodeRef : nodeRefPath) + if (nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT)) { - String name = (String)nodeService.getProperty(pathNodeRef, ContentModel.PROP_NAME); - sb.append("/").append(name); + // Get path from the RM root + List nodeRefPath = filePlanService.getNodeRefPath(nodeRef); + + StringBuilder sb = new StringBuilder(128); + for (NodeRef pathNodeRef : nodeRefPath) + { + String name = (String)nodeService.getProperty(pathNodeRef, ContentModel.PROP_NAME); + sb.append("/").append(name); + } + + // Done + extractedData = sb.toString(); } - // Done - return sb.toString(); + return extractedData; } }