Fixed critical issues reported by sonar (Simplify Conditional)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@63806 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2014-03-09 22:03:24 +00:00
parent b64f1467b4
commit 0ed42e691c
8 changed files with 54 additions and 55 deletions

View File

@@ -34,7 +34,7 @@ import org.alfresco.service.cmr.repository.NodeService;
* An extractor that uses a node context to determine the currently-authenticated * An extractor that uses a node context to determine the currently-authenticated
* user's RM roles. This is not a data generator because it can only function in * user's RM roles. This is not a data generator because it can only function in
* the context of a give node. * the context of a give node.
* *
* @author Derek Hulley * @author Derek Hulley
* @since 3.2 * @since 3.2
*/ */
@@ -74,7 +74,7 @@ public final class AuthenticatedUserRolesDataExtractor extends AbstractDataExtra
*/ */
public boolean isSupported(Serializable data) public boolean isSupported(Serializable data)
{ {
if (data == null || !(data instanceof NodeRef)) if (!(data instanceof NodeRef))
{ {
return false; return false;
} }
@@ -93,10 +93,10 @@ public final class AuthenticatedUserRolesDataExtractor extends AbstractDataExtra
// No-one is authenticated // No-one is authenticated
return null; return null;
} }
// Get the rm root // Get the rm root
NodeRef rmRootNodeRef = filePlanService.getFilePlan(nodeRef); NodeRef rmRootNodeRef = filePlanService.getFilePlan(nodeRef);
Set<Role> roles = filePlanRoleService.getRolesByUser(rmRootNodeRef, user); Set<Role> roles = filePlanRoleService.getRolesByUser(rmRootNodeRef, user);
StringBuilder sb = new StringBuilder(100); StringBuilder sb = new StringBuilder(100);
for (Role role : roles) for (Role role : roles)
@@ -107,7 +107,7 @@ public final class AuthenticatedUserRolesDataExtractor extends AbstractDataExtra
} }
sb.append(role.getDisplayLabel()); sb.append(role.getDisplayLabel());
} }
// Done // Done
return sb.toString(); return sb.toString();
} }

View File

@@ -29,7 +29,7 @@ import org.alfresco.service.cmr.repository.NodeService;
* An extractor that gets a node's {@link RecordsManagementModel#PROP_IDENTIFIER identifier} property. * An extractor that gets a node's {@link RecordsManagementModel#PROP_IDENTIFIER identifier} property.
* This will only extract data if the node is a * This will only extract data if the node is a
* {@link RecordsManagementModel#ASPECT_RECORD_COMPONENT_ID Record component identifier}. * {@link RecordsManagementModel#ASPECT_RECORD_COMPONENT_ID Record component identifier}.
* *
* @author Derek Hulley * @author Derek Hulley
* @since 3.2 * @since 3.2
*/ */
@@ -51,7 +51,7 @@ public final class FilePlanIdentifierDataExtractor extends AbstractDataExtractor
*/ */
public boolean isSupported(Serializable data) public boolean isSupported(Serializable data)
{ {
if (data == null || !(data instanceof NodeRef)) if (!(data instanceof NodeRef))
{ {
return false; return false;
} }
@@ -61,9 +61,9 @@ public final class FilePlanIdentifierDataExtractor extends AbstractDataExtractor
public Serializable extractData(Serializable value) throws Throwable public Serializable extractData(Serializable value) throws Throwable
{ {
NodeRef nodeRef = (NodeRef) value; NodeRef nodeRef = (NodeRef) value;
String identifier = (String) nodeService.getProperty(nodeRef, RecordsManagementModel.PROP_IDENTIFIER); String identifier = (String) nodeService.getProperty(nodeRef, RecordsManagementModel.PROP_IDENTIFIER);
// Done // Done
return identifier; return identifier;
} }

View File

@@ -65,7 +65,7 @@ public final class FilePlanNamePathDataExtractor extends AbstractDataExtractor
*/ */
public boolean isSupported(Serializable data) public boolean isSupported(Serializable data)
{ {
if (data == null || !(data instanceof NodeRef)) if (!(data instanceof NodeRef))
{ {
return false; return false;
} }

View File

@@ -61,7 +61,7 @@ public final class FilePlanNodeRefPathDataExtractor extends AbstractDataExtracto
*/ */
public boolean isSupported(Serializable data) public boolean isSupported(Serializable data)
{ {
if (data == null || !(data instanceof NodeRef)) if (!(data instanceof NodeRef))
{ {
return false; return false;
} }

View File

@@ -36,25 +36,25 @@ import org.alfresco.service.namespace.RegexQNamePattern;
/** /**
* @author Roy Wetherall * @author Roy Wetherall
*/ */
public class DispositionActionImpl implements DispositionAction, public class DispositionActionImpl implements DispositionAction,
RecordsManagementModel RecordsManagementModel
{ {
private RecordsManagementServiceRegistry services; private RecordsManagementServiceRegistry services;
private NodeRef dispositionNodeRef; private NodeRef dispositionNodeRef;
private DispositionActionDefinition dispositionActionDefinition; private DispositionActionDefinition dispositionActionDefinition;
/** /**
* Constructor * Constructor
* *
* @param services * @param services
* @param dispositionActionNodeRef * @param dispositionActionNodeRef
*/ */
public DispositionActionImpl(RecordsManagementServiceRegistry services, NodeRef dispositionActionNodeRef) public DispositionActionImpl(RecordsManagementServiceRegistry services, NodeRef dispositionActionNodeRef)
{ {
this.services = services; this.services = services;
this.dispositionNodeRef = dispositionActionNodeRef; this.dispositionNodeRef = dispositionActionNodeRef;
} }
/** /**
* @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#getDispositionActionDefinition() * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#getDispositionActionDefinition()
*/ */
@@ -64,13 +64,13 @@ public class DispositionActionImpl implements DispositionAction,
{ {
// Get the current action // Get the current action
String id = (String)services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_ACTION_ID); String id = (String)services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_ACTION_ID);
// Get the disposition instructions for the owning node // Get the disposition instructions for the owning node
NodeRef recordNodeRef = this.services.getNodeService().getPrimaryParent(this.dispositionNodeRef).getParentRef(); NodeRef recordNodeRef = this.services.getNodeService().getPrimaryParent(this.dispositionNodeRef).getParentRef();
if (recordNodeRef != null) if (recordNodeRef != null)
{ {
DispositionSchedule ds = this.services.getDispositionService().getDispositionSchedule(recordNodeRef); DispositionSchedule ds = this.services.getDispositionService().getDispositionSchedule(recordNodeRef);
if (ds != null) if (ds != null)
{ {
// Get the disposition action definition // Get the disposition action definition
@@ -78,9 +78,9 @@ public class DispositionActionImpl implements DispositionAction,
} }
} }
} }
return this.dispositionActionDefinition; return this.dispositionActionDefinition;
} }
/** /**
@@ -90,7 +90,7 @@ public class DispositionActionImpl implements DispositionAction,
{ {
return this.dispositionNodeRef; return this.dispositionNodeRef;
} }
/** /**
* @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#getLabel() * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#getLabel()
*/ */
@@ -98,14 +98,14 @@ public class DispositionActionImpl implements DispositionAction,
{ {
String name = getName(); String name = getName();
String label = name; String label = name;
// get the disposition action from the RM action service // get the disposition action from the RM action service
RecordsManagementAction action = this.services.getRecordsManagementActionService().getDispositionAction(name); RecordsManagementAction action = this.services.getRecordsManagementActionService().getDispositionAction(name);
if (action != null) if (action != null)
{ {
label = action.getLabel(); label = action.getLabel();
} }
return label; return label;
} }
@@ -116,7 +116,7 @@ public class DispositionActionImpl implements DispositionAction,
{ {
return (String)this.services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_ACTION_ID); return (String)this.services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_ACTION_ID);
} }
/** /**
* @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#getName() * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#getName()
*/ */
@@ -124,7 +124,7 @@ public class DispositionActionImpl implements DispositionAction,
{ {
return (String)this.services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_ACTION); return (String)this.services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_ACTION);
} }
/** /**
* @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#getAsOfDate() * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#getAsOfDate()
*/ */
@@ -132,7 +132,7 @@ public class DispositionActionImpl implements DispositionAction,
{ {
return (Date)this.services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_AS_OF); return (Date)this.services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_AS_OF);
} }
/** /**
* @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#isEventsEligible() * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#isEventsEligible()
*/ */
@@ -140,7 +140,7 @@ public class DispositionActionImpl implements DispositionAction,
{ {
return ((Boolean)this.services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_EVENTS_ELIGIBLE)).booleanValue(); return ((Boolean)this.services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_EVENTS_ELIGIBLE)).booleanValue();
} }
/** /**
* @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#getCompletedAt() * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#getCompletedAt()
*/ */
@@ -179,16 +179,16 @@ public class DispositionActionImpl implements DispositionAction,
public List<EventCompletionDetails> getEventCompletionDetails() public List<EventCompletionDetails> getEventCompletionDetails()
{ {
List<ChildAssociationRef> assocs = this.services.getNodeService().getChildAssocs( List<ChildAssociationRef> assocs = this.services.getNodeService().getChildAssocs(
this.dispositionNodeRef, this.dispositionNodeRef,
ASSOC_EVENT_EXECUTIONS, ASSOC_EVENT_EXECUTIONS,
RegexQNamePattern.MATCH_ALL); RegexQNamePattern.MATCH_ALL);
List<EventCompletionDetails> result = new ArrayList<EventCompletionDetails>(assocs.size()); List<EventCompletionDetails> result = new ArrayList<EventCompletionDetails>(assocs.size());
for (ChildAssociationRef assoc : assocs) for (ChildAssociationRef assoc : assocs)
{ {
Map<QName, Serializable> props = this.services.getNodeService().getProperties(assoc.getChildRef()); Map<QName, Serializable> props = this.services.getNodeService().getProperties(assoc.getChildRef());
String eventName = (String)props.get(PROP_EVENT_EXECUTION_NAME); String eventName = (String)props.get(PROP_EVENT_EXECUTION_NAME);
EventCompletionDetails ecd = new EventCompletionDetails( EventCompletionDetails ecd = new EventCompletionDetails(
assoc.getChildRef(), eventName, assoc.getChildRef(), eventName,
this.services.getRecordsManagementEventService().getEvent(eventName).getDisplayLabel(), this.services.getRecordsManagementEventService().getEvent(eventName).getDisplayLabel(),
getBooleanValue(props.get(PROP_EVENT_EXECUTION_AUTOMATIC), false), getBooleanValue(props.get(PROP_EVENT_EXECUTION_AUTOMATIC), false),
getBooleanValue(props.get(PROP_EVENT_EXECUTION_COMPLETE), false), getBooleanValue(props.get(PROP_EVENT_EXECUTION_COMPLETE), false),
@@ -196,13 +196,13 @@ public class DispositionActionImpl implements DispositionAction,
(String)props.get(PROP_EVENT_EXECUTION_COMPLETED_BY)); (String)props.get(PROP_EVENT_EXECUTION_COMPLETED_BY));
result.add(ecd); result.add(ecd);
} }
return result; return result;
} }
/** /**
* Helper method to deal with boolean values * Helper method to deal with boolean values
* *
* @param value * @param value
* @param defaultValue * @param defaultValue
* @return * @return
@@ -210,7 +210,7 @@ public class DispositionActionImpl implements DispositionAction,
private boolean getBooleanValue(Object value, boolean defaultValue) private boolean getBooleanValue(Object value, boolean defaultValue)
{ {
boolean result = defaultValue; boolean result = defaultValue;
if (value != null && value instanceof Boolean) if (value instanceof Boolean)
{ {
result = ((Boolean)value).booleanValue(); result = ((Boolean)value).booleanValue();
} }

View File

@@ -554,8 +554,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
} }
boolean propertyUnchanged = false; boolean propertyUnchanged = false;
if (beforeValue != null && afterValue != null && if (beforeValue instanceof Date && afterValue instanceof Date)
beforeValue instanceof Date && afterValue instanceof Date)
{ {
// deal with date values // deal with date values
propertyUnchanged = (((Date)beforeValue).compareTo((Date)afterValue) == 0); propertyUnchanged = (((Date)beforeValue).compareTo((Date)afterValue) == 0);

View File

@@ -34,7 +34,7 @@ import org.springframework.context.ApplicationContextAware;
/** /**
* Extended action service implementation. * Extended action service implementation.
* *
* @author Roy Wetherall * @author Roy Wetherall
* @since 2.1 * @since 2.1
*/ */
@@ -42,7 +42,7 @@ public class ExtendedActionServiceImpl extends ActionServiceImpl implements Appl
{ {
/** File plan service */ /** File plan service */
private FilePlanService filePlanService; private FilePlanService filePlanService;
/** Application context */ /** Application context */
private ApplicationContext extendedApplicationContext; private ApplicationContext extendedApplicationContext;
@@ -54,15 +54,15 @@ public class ExtendedActionServiceImpl extends ActionServiceImpl implements Appl
super.setApplicationContext(applicationContext); super.setApplicationContext(applicationContext);
extendedApplicationContext = applicationContext; extendedApplicationContext = applicationContext;
} }
/** /**
* @param filePlanService file plan service * @param filePlanService file plan service
*/ */
public void setFilePlanService(FilePlanService filePlanService) public void setFilePlanService(FilePlanService filePlanService)
{ {
this.filePlanService = filePlanService; this.filePlanService = filePlanService;
} }
/** /**
* @see org.alfresco.repo.action.ActionServiceImpl#getActionConditionDefinition(java.lang.String) * @see org.alfresco.repo.action.ActionServiceImpl#getActionConditionDefinition(java.lang.String)
*/ */
@@ -71,7 +71,7 @@ public class ExtendedActionServiceImpl extends ActionServiceImpl implements Appl
// get direct access to action condition definition (i.e. ignoring public flag of executer) // get direct access to action condition definition (i.e. ignoring public flag of executer)
ActionConditionDefinition definition = null; ActionConditionDefinition definition = null;
Object bean = extendedApplicationContext.getBean(name); Object bean = extendedApplicationContext.getBean(name);
if (bean != null && bean instanceof ActionConditionEvaluator) if (bean instanceof ActionConditionEvaluator)
{ {
ActionConditionEvaluator evaluator = (ActionConditionEvaluator) bean; ActionConditionEvaluator evaluator = (ActionConditionEvaluator) bean;
definition = evaluator.getActionConditionDefintion(); definition = evaluator.getActionConditionDefintion();
@@ -86,10 +86,10 @@ public class ExtendedActionServiceImpl extends ActionServiceImpl implements Appl
public List<ActionDefinition> getActionDefinitions(NodeRef nodeRef) public List<ActionDefinition> getActionDefinitions(NodeRef nodeRef)
{ {
List<ActionDefinition> result = null; List<ActionDefinition> result = null;
// first use the base implementation to get the list of action definitions // first use the base implementation to get the list of action definitions
List<ActionDefinition> actionDefinitions = super.getActionDefinitions(nodeRef); List<ActionDefinition> actionDefinitions = super.getActionDefinitions(nodeRef);
if (nodeRef == null) if (nodeRef == null)
{ {
// nothing to filter // nothing to filter
@@ -100,21 +100,21 @@ public class ExtendedActionServiceImpl extends ActionServiceImpl implements Appl
// get the file component kind of the node reference // get the file component kind of the node reference
FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(nodeRef); FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(nodeRef);
result = new ArrayList<ActionDefinition>(actionDefinitions.size()); result = new ArrayList<ActionDefinition>(actionDefinitions.size());
// check each action definition // check each action definition
for (ActionDefinition actionDefinition : actionDefinitions) for (ActionDefinition actionDefinition : actionDefinitions)
{ {
if (actionDefinition instanceof RecordsManagementActionDefinition) if (actionDefinition instanceof RecordsManagementActionDefinition)
{ {
if (kind != null) if (kind != null)
{ {
Set<FilePlanComponentKind> applicableKinds = ((RecordsManagementActionDefinition)actionDefinition).getApplicableKinds(); Set<FilePlanComponentKind> applicableKinds = ((RecordsManagementActionDefinition)actionDefinition).getApplicableKinds();
if (applicableKinds == null || applicableKinds.size() == 0 || applicableKinds.contains(kind)) if (applicableKinds == null || applicableKinds.size() == 0 || applicableKinds.contains(kind))
{ {
// an RM action can only act on a RM artifact // an RM action can only act on a RM artifact
result.add(actionDefinition); result.add(actionDefinition);
} }
} }
} }
else else
{ {
@@ -122,11 +122,11 @@ public class ExtendedActionServiceImpl extends ActionServiceImpl implements Appl
{ {
// a non-RM action can only act on a non-RM artifact // a non-RM action can only act on a non-RM artifact
result.add(actionDefinition); result.add(actionDefinition);
} }
} }
} }
} }
return result; return result;
} }
} }

View File

@@ -75,7 +75,7 @@ public class ParameterProcessorComponent implements ParameterSubstitutionSuggest
Object parameterValue = entry.getValue(); Object parameterValue = entry.getValue();
// only sub string property values // only sub string property values
if (parameterValue != null && parameterValue instanceof String) if (parameterValue instanceof String)
{ {
// set the updated parameter value // set the updated parameter value
ruleItem.setParameterValue(parameterName, process((String)parameterValue, actionedUponNodeRef)); ruleItem.setParameterValue(parameterName, process((String)parameterValue, actionedUponNodeRef));