mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
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:
@@ -34,7 +34,7 @@ import org.alfresco.service.cmr.repository.NodeService;
|
||||
* 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
|
||||
* the context of a give node.
|
||||
*
|
||||
*
|
||||
* @author Derek Hulley
|
||||
* @since 3.2
|
||||
*/
|
||||
@@ -74,7 +74,7 @@ public final class AuthenticatedUserRolesDataExtractor extends AbstractDataExtra
|
||||
*/
|
||||
public boolean isSupported(Serializable data)
|
||||
{
|
||||
if (data == null || !(data instanceof NodeRef))
|
||||
if (!(data instanceof NodeRef))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -93,10 +93,10 @@ public final class AuthenticatedUserRolesDataExtractor extends AbstractDataExtra
|
||||
// No-one is authenticated
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// Get the rm root
|
||||
NodeRef rmRootNodeRef = filePlanService.getFilePlan(nodeRef);
|
||||
|
||||
|
||||
Set<Role> roles = filePlanRoleService.getRolesByUser(rmRootNodeRef, user);
|
||||
StringBuilder sb = new StringBuilder(100);
|
||||
for (Role role : roles)
|
||||
@@ -107,7 +107,7 @@ public final class AuthenticatedUserRolesDataExtractor extends AbstractDataExtra
|
||||
}
|
||||
sb.append(role.getDisplayLabel());
|
||||
}
|
||||
|
||||
|
||||
// Done
|
||||
return sb.toString();
|
||||
}
|
||||
|
@@ -29,7 +29,7 @@ import org.alfresco.service.cmr.repository.NodeService;
|
||||
* An extractor that gets a node's {@link RecordsManagementModel#PROP_IDENTIFIER identifier} property.
|
||||
* This will only extract data if the node is a
|
||||
* {@link RecordsManagementModel#ASPECT_RECORD_COMPONENT_ID Record component identifier}.
|
||||
*
|
||||
*
|
||||
* @author Derek Hulley
|
||||
* @since 3.2
|
||||
*/
|
||||
@@ -51,7 +51,7 @@ public final class FilePlanIdentifierDataExtractor extends AbstractDataExtractor
|
||||
*/
|
||||
public boolean isSupported(Serializable data)
|
||||
{
|
||||
if (data == null || !(data instanceof NodeRef))
|
||||
if (!(data instanceof NodeRef))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -61,9 +61,9 @@ public final class FilePlanIdentifierDataExtractor extends AbstractDataExtractor
|
||||
public Serializable extractData(Serializable value) throws Throwable
|
||||
{
|
||||
NodeRef nodeRef = (NodeRef) value;
|
||||
|
||||
|
||||
String identifier = (String) nodeService.getProperty(nodeRef, RecordsManagementModel.PROP_IDENTIFIER);
|
||||
|
||||
|
||||
// Done
|
||||
return identifier;
|
||||
}
|
||||
|
@@ -65,7 +65,7 @@ public final class FilePlanNamePathDataExtractor extends AbstractDataExtractor
|
||||
*/
|
||||
public boolean isSupported(Serializable data)
|
||||
{
|
||||
if (data == null || !(data instanceof NodeRef))
|
||||
if (!(data instanceof NodeRef))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@@ -61,7 +61,7 @@ public final class FilePlanNodeRefPathDataExtractor extends AbstractDataExtracto
|
||||
*/
|
||||
public boolean isSupported(Serializable data)
|
||||
{
|
||||
if (data == null || !(data instanceof NodeRef))
|
||||
if (!(data instanceof NodeRef))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@@ -36,25 +36,25 @@ import org.alfresco.service.namespace.RegexQNamePattern;
|
||||
/**
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class DispositionActionImpl implements DispositionAction,
|
||||
public class DispositionActionImpl implements DispositionAction,
|
||||
RecordsManagementModel
|
||||
{
|
||||
private RecordsManagementServiceRegistry services;
|
||||
private NodeRef dispositionNodeRef;
|
||||
private DispositionActionDefinition dispositionActionDefinition;
|
||||
|
||||
private DispositionActionDefinition dispositionActionDefinition;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* Constructor
|
||||
*
|
||||
* @param services
|
||||
* @param dispositionActionNodeRef
|
||||
*/
|
||||
public DispositionActionImpl(RecordsManagementServiceRegistry services, NodeRef dispositionActionNodeRef)
|
||||
public DispositionActionImpl(RecordsManagementServiceRegistry services, NodeRef dispositionActionNodeRef)
|
||||
{
|
||||
this.services = services;
|
||||
this.dispositionNodeRef = dispositionActionNodeRef;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#getDispositionActionDefinition()
|
||||
*/
|
||||
@@ -64,13 +64,13 @@ public class DispositionActionImpl implements DispositionAction,
|
||||
{
|
||||
// Get the current action
|
||||
String id = (String)services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_ACTION_ID);
|
||||
|
||||
|
||||
// Get the disposition instructions for the owning node
|
||||
NodeRef recordNodeRef = this.services.getNodeService().getPrimaryParent(this.dispositionNodeRef).getParentRef();
|
||||
if (recordNodeRef != null)
|
||||
{
|
||||
DispositionSchedule ds = this.services.getDispositionService().getDispositionSchedule(recordNodeRef);
|
||||
|
||||
|
||||
if (ds != null)
|
||||
{
|
||||
// Get the disposition action definition
|
||||
@@ -78,9 +78,9 @@ public class DispositionActionImpl implements DispositionAction,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return this.dispositionActionDefinition;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,7 +90,7 @@ public class DispositionActionImpl implements DispositionAction,
|
||||
{
|
||||
return this.dispositionNodeRef;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#getLabel()
|
||||
*/
|
||||
@@ -98,14 +98,14 @@ public class DispositionActionImpl implements DispositionAction,
|
||||
{
|
||||
String name = getName();
|
||||
String label = name;
|
||||
|
||||
|
||||
// get the disposition action from the RM action service
|
||||
RecordsManagementAction action = this.services.getRecordsManagementActionService().getDispositionAction(name);
|
||||
if (action != null)
|
||||
{
|
||||
label = action.getLabel();
|
||||
}
|
||||
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ public class DispositionActionImpl implements DispositionAction,
|
||||
{
|
||||
return (String)this.services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_ACTION_ID);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @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();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#getCompletedAt()
|
||||
*/
|
||||
@@ -179,16 +179,16 @@ public class DispositionActionImpl implements DispositionAction,
|
||||
public List<EventCompletionDetails> getEventCompletionDetails()
|
||||
{
|
||||
List<ChildAssociationRef> assocs = this.services.getNodeService().getChildAssocs(
|
||||
this.dispositionNodeRef,
|
||||
ASSOC_EVENT_EXECUTIONS,
|
||||
this.dispositionNodeRef,
|
||||
ASSOC_EVENT_EXECUTIONS,
|
||||
RegexQNamePattern.MATCH_ALL);
|
||||
List<EventCompletionDetails> result = new ArrayList<EventCompletionDetails>(assocs.size());
|
||||
for (ChildAssociationRef assoc : assocs)
|
||||
{
|
||||
Map<QName, Serializable> props = this.services.getNodeService().getProperties(assoc.getChildRef());
|
||||
String eventName = (String)props.get(PROP_EVENT_EXECUTION_NAME);
|
||||
Map<QName, Serializable> props = this.services.getNodeService().getProperties(assoc.getChildRef());
|
||||
String eventName = (String)props.get(PROP_EVENT_EXECUTION_NAME);
|
||||
EventCompletionDetails ecd = new EventCompletionDetails(
|
||||
assoc.getChildRef(), eventName,
|
||||
assoc.getChildRef(), eventName,
|
||||
this.services.getRecordsManagementEventService().getEvent(eventName).getDisplayLabel(),
|
||||
getBooleanValue(props.get(PROP_EVENT_EXECUTION_AUTOMATIC), 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));
|
||||
result.add(ecd);
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper method to deal with boolean values
|
||||
*
|
||||
*
|
||||
* @param value
|
||||
* @param defaultValue
|
||||
* @return
|
||||
@@ -210,7 +210,7 @@ public class DispositionActionImpl implements DispositionAction,
|
||||
private boolean getBooleanValue(Object value, boolean defaultValue)
|
||||
{
|
||||
boolean result = defaultValue;
|
||||
if (value != null && value instanceof Boolean)
|
||||
if (value instanceof Boolean)
|
||||
{
|
||||
result = ((Boolean)value).booleanValue();
|
||||
}
|
||||
|
@@ -554,8 +554,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
}
|
||||
|
||||
boolean propertyUnchanged = false;
|
||||
if (beforeValue != null && afterValue != null &&
|
||||
beforeValue instanceof Date && afterValue instanceof Date)
|
||||
if (beforeValue instanceof Date && afterValue instanceof Date)
|
||||
{
|
||||
// deal with date values
|
||||
propertyUnchanged = (((Date)beforeValue).compareTo((Date)afterValue) == 0);
|
||||
|
@@ -34,7 +34,7 @@ import org.springframework.context.ApplicationContextAware;
|
||||
|
||||
/**
|
||||
* Extended action service implementation.
|
||||
*
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
@@ -42,7 +42,7 @@ public class ExtendedActionServiceImpl extends ActionServiceImpl implements Appl
|
||||
{
|
||||
/** File plan service */
|
||||
private FilePlanService filePlanService;
|
||||
|
||||
|
||||
/** Application context */
|
||||
private ApplicationContext extendedApplicationContext;
|
||||
|
||||
@@ -54,15 +54,15 @@ public class ExtendedActionServiceImpl extends ActionServiceImpl implements Appl
|
||||
super.setApplicationContext(applicationContext);
|
||||
extendedApplicationContext = applicationContext;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param filePlanService file plan service
|
||||
*/
|
||||
public void setFilePlanService(FilePlanService filePlanService)
|
||||
public void setFilePlanService(FilePlanService filePlanService)
|
||||
{
|
||||
this.filePlanService = filePlanService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @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)
|
||||
ActionConditionDefinition definition = null;
|
||||
Object bean = extendedApplicationContext.getBean(name);
|
||||
if (bean != null && bean instanceof ActionConditionEvaluator)
|
||||
if (bean instanceof ActionConditionEvaluator)
|
||||
{
|
||||
ActionConditionEvaluator evaluator = (ActionConditionEvaluator) bean;
|
||||
definition = evaluator.getActionConditionDefintion();
|
||||
@@ -86,10 +86,10 @@ public class ExtendedActionServiceImpl extends ActionServiceImpl implements Appl
|
||||
public List<ActionDefinition> getActionDefinitions(NodeRef nodeRef)
|
||||
{
|
||||
List<ActionDefinition> result = null;
|
||||
|
||||
|
||||
// first use the base implementation to get the list of action definitions
|
||||
List<ActionDefinition> actionDefinitions = super.getActionDefinitions(nodeRef);
|
||||
|
||||
|
||||
if (nodeRef == null)
|
||||
{
|
||||
// nothing to filter
|
||||
@@ -100,21 +100,21 @@ public class ExtendedActionServiceImpl extends ActionServiceImpl implements Appl
|
||||
// get the file component kind of the node reference
|
||||
FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(nodeRef);
|
||||
result = new ArrayList<ActionDefinition>(actionDefinitions.size());
|
||||
|
||||
|
||||
// check each action definition
|
||||
for (ActionDefinition actionDefinition : actionDefinitions)
|
||||
{
|
||||
if (actionDefinition instanceof RecordsManagementActionDefinition)
|
||||
{
|
||||
if (kind != null)
|
||||
{
|
||||
{
|
||||
Set<FilePlanComponentKind> applicableKinds = ((RecordsManagementActionDefinition)actionDefinition).getApplicableKinds();
|
||||
if (applicableKinds == null || applicableKinds.size() == 0 || applicableKinds.contains(kind))
|
||||
{
|
||||
// an RM action can only act on a RM artifact
|
||||
result.add(actionDefinition);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -122,11 +122,11 @@ public class ExtendedActionServiceImpl extends ActionServiceImpl implements Appl
|
||||
{
|
||||
// a non-RM action can only act on a non-RM artifact
|
||||
result.add(actionDefinition);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@@ -75,7 +75,7 @@ public class ParameterProcessorComponent implements ParameterSubstitutionSuggest
|
||||
Object parameterValue = entry.getValue();
|
||||
|
||||
// only sub string property values
|
||||
if (parameterValue != null && parameterValue instanceof String)
|
||||
if (parameterValue instanceof String)
|
||||
{
|
||||
// set the updated parameter value
|
||||
ruleItem.setParameterValue(parameterName, process((String)parameterValue, actionedUponNodeRef));
|
||||
|
Reference in New Issue
Block a user