From 83f2f59bcb6e721333eac4309f6336de434a76bb Mon Sep 17 00:00:00 2001 From: Tuna Aksoy Date: Sun, 2 Mar 2014 16:40:09 +0000 Subject: [PATCH] Fixed critical issues reported by sonar (Empty If Stmt) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@63495 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../action/impl/CompleteEventAction.java | 24 ++++++++-------- .../caveat/RMCaveatConfigComponentImpl.java | 28 +++++++------------ .../fileplan/FilePlanServiceImpl.java | 8 ++---- 3 files changed, 24 insertions(+), 36 deletions(-) diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CompleteEventAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CompleteEventAction.java index c461bfde2d..82d258c4c6 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CompleteEventAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CompleteEventAction.java @@ -36,7 +36,7 @@ import org.alfresco.service.namespace.QName; /** * Complete event action - * + * * @author Roy Wetherall */ public class CompleteEventAction extends RMActionExecuterAbstractBase @@ -45,7 +45,7 @@ public class CompleteEventAction extends RMActionExecuterAbstractBase public static final String PARAM_EVENT_NAME = "eventName"; public static final String PARAM_EVENT_COMPLETED_BY = "eventCompletedBy"; public static final String PARAM_EVENT_COMPLETED_AT = "eventCompletedAt"; - + /** * @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#addParameterDefinitions(java.util.List) */ @@ -69,7 +69,7 @@ public class CompleteEventAction extends RMActionExecuterAbstractBase String eventName = (String)action.getParameterValue(PARAM_EVENT_NAME); String eventCompletedBy = (String)action.getParameterValue(PARAM_EVENT_COMPLETED_BY); Date eventCompletedAt = (Date)action.getParameterValue(PARAM_EVENT_COMPLETED_AT); - + if (this.nodeService.hasAspect(actionedUponNodeRef, ASPECT_DISPOSITION_LIFECYCLE) == true) { // Get the next disposition action @@ -84,12 +84,12 @@ public class CompleteEventAction extends RMActionExecuterAbstractBase { eventCompletedAt = new Date(); } - + if (eventCompletedBy == null) { eventCompletedBy = AuthenticationUtil.getRunAsUser(); } - + // Update the event so that it is complete NodeRef eventNodeRef = event.getNodeRef(); Map props = this.nodeService.getProperties(eventNodeRef); @@ -97,24 +97,24 @@ public class CompleteEventAction extends RMActionExecuterAbstractBase props.put(PROP_EVENT_EXECUTION_COMPLETED_AT, eventCompletedAt); props.put(PROP_EVENT_EXECUTION_COMPLETED_BY, eventCompletedBy); this.nodeService.setProperties(eventNodeRef, props); - + // Check to see if the events eligible property needs to be updated updateEventEligible(da); - + } - else - { + // else + // { // RM-695: Commenting error handling out. If the current disposition stage does not define the event being completed nothing should happen. // throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_EVENT_NO_DISP_LC, eventName)); - } + // } } } } } - + /** * Get the event from the dispostion action - * + * * @param da * @param eventName * @return 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 fdb49a7d95..903946ef6c 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 @@ -212,7 +212,7 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon validateAndReset(caveatConfigNodeRef); } } - + /** * @see org.alfresco.repo.content.ContentServicePolicies.OnContentUpdatePolicy#onContentUpdate(org.alfresco.service.cmr.repository.NodeRef, boolean) */ @@ -232,7 +232,7 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon * @see org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy#beforeDeleteNode(org.alfresco.service.cmr.repository.NodeRef) */ @Override - @Behaviour(kind = BehaviourKind.CLASS) + @Behaviour(kind = BehaviourKind.CLASS) public void beforeDeleteNode(NodeRef nodeRef) { if (logger.isInfoEnabled()) @@ -247,7 +247,7 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon * @see org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy#onCreateNode(org.alfresco.service.cmr.repository.ChildAssociationRef) */ @Override - @Behaviour(kind = BehaviourKind.CLASS) + @Behaviour(kind = BehaviourKind.CLASS) public void onCreateNode(ChildAssociationRef childAssocRef) { if (logger.isInfoEnabled()) @@ -352,6 +352,7 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon Map> caveatMap = (Map>)conEntry.getValue(); List allowedValues = null; + @SuppressWarnings("unused") boolean found = false; for (QName propertyName : props) @@ -382,10 +383,10 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon } } - if (! found) - { + //if (! found) + //{ //throw new AlfrescoRuntimeException("Constraint does not exist (or is not used): "+conStr); - } + //} if (allowedValues != null) { @@ -547,7 +548,7 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon if (! (AuthenticationUtil.isMtEnabled() && AuthenticationUtil.isRunAsUserTheSystemUser())) { // note: userName and userGroupNames must not be null - caveatConfig.get(constraintName); + caveatConfig.get(constraintName); Set userGroupFullNames = authorityService.getAuthoritiesForUser(userName); allowedValues = getRMAllowedValues(userName, userGroupFullNames, constraintName); @@ -922,11 +923,7 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon readLock.lock(); members = caveatConfig.get(listName); - if(members == null) - { - // list does not exist - } - else + if (members != null) { try { @@ -934,11 +931,7 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon writeLock.lock(); // check again members = caveatConfig.get(listName); - if(members == null) - { - // list does not exist - } - else + if (members != null) { // authorities contains authority, values[] // pivot contains value, members[] @@ -964,7 +957,6 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon readLock.lock(); writeLock.unlock(); } - } } finally diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java index 6648665cbf..cad28b48fa 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java @@ -603,12 +603,8 @@ public class FilePlanServiceImpl extends ServiceBaseImpl } // Prepend it to the path nodeRefPath.addFirst(nodeRef); - // Are we at the root - if (isFilePlan(nodeRef) == true) - { - // We're done - } - else + // Are we not at the root + if (isFilePlan(nodeRef) == false) { ChildAssociationRef assocRef = nodeService.getPrimaryParent(nodeRef); if (assocRef == null)