diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/log4j.properties b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/log4j.properties index dbdb7913fc..76742abc10 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/log4j.properties +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/log4j.properties @@ -13,7 +13,7 @@ log4j.logger.org.alfresco.module.org_alfresco_module_rm.patch=info # Set to 'debug' to see details of capability failures when AccessDenied is thrown. May be # removed to enhance performance. # -log4j.logger.org.alfresco.module.org_alfresco_module_rm.security.RMMethodSecurityInterceptor=debug +log4j.logger.org.alfresco.module.org_alfresco_module_rm.security.RMMethodSecurityInterceptor=info # # RM permission debug diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/action-service.properties b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/action-service.properties index 3d36f0ec7c..eeac19f2e6 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/action-service.properties +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/action-service.properties @@ -39,10 +39,10 @@ rm.action.parameter-not-supplied=Add a ''{0}'' to continue. rm.action.delete-not-hold-type=We couldn't delete the hold because {1} isn't of type {0}. rm.action.cast-to-rm-type=You can't upload a custom folder type to the records management file plan. rm.action.record-folder-create=You can't create a record folder in another record folder. -rm.action.unique.child.type-error-message=Operation failed. Multiple children of this type are not allowed. -rm.action.multiple.children.type-error-message=Operation failed. Children of type {0} are not allowed -rm.action.create.transfer.container.child-error-message=Operation failed. Creation is not allowed in Transfer Container. -rm.action.create.transfer.child-error-message=Operation failed. Creation is not allowed in Transfer Folders. -rm.action.create.record.folder.child-error-message=Only records can be created in record folders but it was {0} -rm.action.transfer-non-editable=The metadata of transfer nodes is not editable. +rm.action.unique.child.type-error-message=You can't create multiple items of this type here. +rm.action.multiple.children.type-error-message=You can't create {0} here. +rm.action.create.transfer.container.child-error-message=You can't create items in the Transfer container. +rm.action.create.transfer.child-error-message=You can't create items in Transfer Folders. +rm.action.create.record.folder.child-error-message=You can only create records in record folders and this was a {0}. +rm.action.transfer-non-editable=You can't edit transfer folder or container metadata. diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service.properties b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service.properties index a42ee061f7..3287a0cbab 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service.properties +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service.properties @@ -20,5 +20,5 @@ rm.service.node-has-aspect=The record type {1} is already showing for record {0} rm.service.final-version=Final rm.service.final-version-description=The final archived record version rm.service.enable-autoversion-on-record-creation=Auto Version on Record Creation -rm.service.add-children-to-closed-record-folder=You can't add new items to a closed record folder -rm.service.update-record-content=Could not update content property as it's immutable for records. \ No newline at end of file +rm.service.add-children-to-closed-record-folder=You can't add new items to a closed record folder. +rm.service.update-record-content=You can't update a record's content property. \ No newline at end of file diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-ui-evaluators-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-ui-evaluators-context.xml index 3d8ea5c7e4..3c12a64720 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-ui-evaluators-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-ui-evaluators-context.xml @@ -35,9 +35,10 @@ - + + availableKinds; /** * @param permissions permissions @@ -258,6 +262,27 @@ public class DeclarativeCapability extends AbstractCapability { return checkConditions(nodeRef, conditions); } + + /** + * Get list of available kinds + * + * @return list of available kinds + */ + + private Set getAvailableKinds() + { + if (kinds != null && availableKinds == null) + { + availableKinds = new HashSet(kinds.size()); + for (String kindString : kinds) + { + FilePlanComponentKind kind = FilePlanComponentKind.valueOf(kindString); + availableKinds.add(kind); + } + } + + return availableKinds; + } /** * Checks that the node ref is of the expected kind @@ -273,23 +298,9 @@ public class DeclarativeCapability extends AbstractCapability if (actualKind != null) { - if (kinds != null && !kinds.isEmpty()) + Set availableKinds = getAvailableKinds(); + if (availableKinds == null || availableKinds.contains(actualKind)) { - // need to check the actual file plan kind is in the list specified - for (String kindString : kinds) - { - FilePlanComponentKind kind = FilePlanComponentKind.valueOf(kindString); - if (actualKind.equals(kind)) - { - result = true; - break; - } - } - } - else - { - // we don't have any specific kinds to check, so we pass since we have a file - // plan component in our hands result = true; } } diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/BaseEvaluator.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/BaseEvaluator.java index 2e734b6c2d..a75ed6d3d2 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/BaseEvaluator.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/BaseEvaluator.java @@ -40,20 +40,26 @@ import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; import org.alfresco.module.org_alfresco_module_rm.record.RecordService; import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; +import org.alfresco.module.org_alfresco_module_rm.util.TransactionalResourceHelper; +import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.security.AccessStatus; import org.alfresco.service.namespace.NamespaceService; +import org.springframework.beans.factory.BeanNameAware; /** * Base evaluator. * * @author Roy Wetherall */ -public abstract class BaseEvaluator implements RecordsManagementModel +public abstract class BaseEvaluator implements RecordsManagementModel, BeanNameAware { /** Name */ protected String name; + + /** bean name */ + protected String beanName; /** JSON conversion component */ protected JSONConversionComponent jsonConversionComponent; @@ -84,7 +90,19 @@ public abstract class BaseEvaluator implements RecordsManagementModel /** Record folder service */ protected RecordFolderService recordFolderService; + + /** transactional resource helper */ + protected TransactionalResourceHelper transactionalResourceHelper; + /** + * @param beanName bean name + */ + @Override + public void setBeanName(String beanName) + { + this.beanName = beanName; + } + /** * @param jsonConversionComponent json conversion component */ @@ -148,6 +166,14 @@ public abstract class BaseEvaluator implements RecordsManagementModel { this.recordFolderService = recordFolderService; } + + /** + * @param transactionalResourceHelper transactional resource helper + */ + public void setTransactionalResourceHelper(TransactionalResourceHelper transactionalResourceHelper) + { + this.transactionalResourceHelper = transactionalResourceHelper; + } /** * @param name @@ -217,17 +243,25 @@ public abstract class BaseEvaluator implements RecordsManagementModel */ public boolean evaluate(NodeRef nodeRef) { - boolean result = false; - - // Check that we are dealing with the correct kind of RM object - if ((kinds == null || checkKinds(nodeRef)) && - // Check we have the required capabilities - (capabilities == null || checkCapabilities(nodeRef))) + Map results = transactionalResourceHelper.getMap("BaseEvaluator.evaluate"); + String key = new StringBuffer(nodeRef.toString()).append(AuthenticationUtil.getRunAsUser()).append(beanName).toString(); + + if (!results.containsKey(key)) { - result = evaluateImpl(nodeRef); + boolean result = false; + + // Check that we are dealing with the correct kind of RM object + if ((kinds == null || checkKinds(nodeRef)) && + // Check we have the required capabilities + (capabilities == null || checkCapabilities(nodeRef))) + { + result = evaluateImpl(nodeRef); + } + + results.put(key, result); } - return result; + return results.get(key); } /** diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/util/StringUtils.java b/rm-community/rm-community-repo/source/java/org/alfresco/util/StringUtils.java new file mode 100644 index 0000000000..829c03c197 --- /dev/null +++ b/rm-community/rm-community-repo/source/java/org/alfresco/util/StringUtils.java @@ -0,0 +1,51 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2017 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * - + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * - + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * - + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * - + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.util; + +/** + * String utility methods. + * + * @author Tom Page + * @since 2.6 + */ +public class StringUtils +{ + /** Private constructor for the helper class. */ + private StringUtils() {} + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + public static String toIndentedString(Object o) + { + if (o == null) + { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +}