From 822a53b8c38132f04378c11839b3d816856f783b Mon Sep 17 00:00:00 2001 From: Tuna Aksoy Date: Tue, 18 Mar 2014 23:22:27 +0000 Subject: [PATCH] Fixed major issues reported by sonar (Simplify Boolean Return) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@64825 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../capability/RMAfterInvocationProvider.java | 14 +++++----- .../capability/RMEntryVoter.java | 26 +++++++++---------- 2 files changed, 20 insertions(+), 20 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 2bcf6201fa..68a7ae5722 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 @@ -57,6 +57,7 @@ import org.alfresco.service.cmr.search.PermissionEvaluationMode; import org.alfresco.service.cmr.search.ResultSet; import org.alfresco.service.cmr.security.AccessStatus; import org.aopalliance.intercept.MethodInvocation; +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.InitializingBean; @@ -76,16 +77,15 @@ public class RMAfterInvocationProvider extends RMSecurityCommon private long maxPermissionCheckTimeMillis; - public boolean supports(ConfigAttribute attribute) + public boolean supports(ConfigAttribute configAttribute) { - if ((attribute.getAttribute() != null) && (attribute.getAttribute().startsWith(AFTER_RM))) + boolean supports = false; + String attribute = configAttribute.getAttribute(); + if (StringUtils.isNotBlank(attribute) && attribute.startsWith(AFTER_RM)) { - return true; - } - else - { - return false; + supports = true; } + return supports; } @SuppressWarnings("rawtypes") diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMEntryVoter.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMEntryVoter.java index 0cd20a2a86..bb607675ca 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMEntryVoter.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMEntryVoter.java @@ -36,6 +36,7 @@ import org.alfresco.repo.transaction.TransactionalResourceHelper; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.NamespacePrefixResolver; import org.aopalliance.intercept.MethodInvocation; +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.InitializingBean; @@ -90,22 +91,21 @@ public class RMEntryVoter extends RMSecurityCommon * @see net.sf.acegisecurity.vote.AccessDecisionVoter#supports(net.sf.acegisecurity.ConfigAttribute) */ @Override - public boolean supports(ConfigAttribute attribute) + public boolean supports(ConfigAttribute configAttribute) { - if ((attribute.getAttribute() != null) && - (attribute.getAttribute().equals(ConfigAttributeDefinition.RM_ABSTAIN) || - attribute.getAttribute().equals(ConfigAttributeDefinition.RM_QUERY) || - attribute.getAttribute().equals(ConfigAttributeDefinition.RM_ALLOW) || - attribute.getAttribute().equals(ConfigAttributeDefinition.RM_DENY) || - attribute.getAttribute().startsWith(ConfigAttributeDefinition.RM_CAP) || - attribute.getAttribute().startsWith(ConfigAttributeDefinition.RM))) + boolean supports = false; + String attribute = configAttribute.getAttribute(); + if (StringUtils.isNotBlank(attribute) && + (attribute.equals(ConfigAttributeDefinition.RM_ABSTAIN) || + attribute.equals(ConfigAttributeDefinition.RM_QUERY) || + attribute.equals(ConfigAttributeDefinition.RM_ALLOW) || + attribute.equals(ConfigAttributeDefinition.RM_DENY) || + attribute.startsWith(ConfigAttributeDefinition.RM_CAP) || + attribute.startsWith(ConfigAttributeDefinition.RM))) { - return true; - } - else - { - return false; + supports = true; } + return supports; } /**