Fixed major issues reported by sonar (Simplify Boolean Expression)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@63886 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2014-03-11 09:04:52 +00:00
parent b92d582589
commit c3ac745ffb
156 changed files with 1724 additions and 1724 deletions

View File

@@ -130,7 +130,7 @@ public class NodeParameterProcessor extends ParameterProcessor implements Parame
}
QName type = propertyDefinition.getDataType().getName();
if (ArrayUtils.contains(supportedDataTypes, type) == true)
if (ArrayUtils.contains(supportedDataTypes, type))
{
Serializable propertyValue = nodeService.getProperty(actionedUponNodeRef, qname);
if (propertyValue != null)

View File

@@ -34,20 +34,20 @@ import org.springframework.beans.factory.config.BeanPostProcessor;
* Annotated behaviour bean post processor.
* <p>
* Registers the annotated methods on behaviour beans with the policy component.
*
*
* @author Roy Wetherall
*/
public class AnnotatedBehaviourPostProcessor implements BeanPostProcessor
{
/** logger */
private static Log logger = LogFactory.getLog(AnnotatedBehaviourPostProcessor.class);
/** policy component */
private PolicyComponent policyComponent;
/** namespace service */
private NamespaceService namespaceService;
/**
* @param policyComponent policy component
*/
@@ -55,7 +55,7 @@ public class AnnotatedBehaviourPostProcessor implements BeanPostProcessor
{
this.policyComponent = policyComponent;
}
/**
* @param namespaceService namespace service
*/
@@ -63,7 +63,7 @@ public class AnnotatedBehaviourPostProcessor implements BeanPostProcessor
{
this.namespaceService = namespaceService;
}
/**
* @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization(java.lang.Object, java.lang.String)
*/
@@ -72,7 +72,7 @@ public class AnnotatedBehaviourPostProcessor implements BeanPostProcessor
{
// register annotated behavior methods
registerBehaviours(bean, beanName);
// return the bean
return bean;
}
@@ -86,20 +86,20 @@ public class AnnotatedBehaviourPostProcessor implements BeanPostProcessor
// do nothing
return bean;
}
/**
* Register behaviours.
*
*
* @param bean bean
* @param beanName bean name
*/
private void registerBehaviours(Object bean, String beanName)
{
if (bean.getClass().isAnnotationPresent(BehaviourBean.class) == true)
{
if (bean.getClass().isAnnotationPresent(BehaviourBean.class))
{
BehaviourBean behaviourBean = bean.getClass().getAnnotation(BehaviourBean.class);
if (logger.isDebugEnabled() == true)
if (logger.isDebugEnabled())
{
logger.debug("Annotated behaviour post processing for " + beanName);
}
@@ -107,17 +107,17 @@ public class AnnotatedBehaviourPostProcessor implements BeanPostProcessor
Method[] methods = bean.getClass().getMethods();
for (Method method : methods)
{
if (method.isAnnotationPresent(Behaviour.class) == true)
{
if (method.isAnnotationPresent(Behaviour.class))
{
registerBehaviour(behaviourBean, bean, beanName, method);
}
}
}
}
/**
* Register behaviour.
*
*
* @param behaviourBean behaviour bean annotation
* @param bean bean
* @param beanName bean name
@@ -128,45 +128,45 @@ public class AnnotatedBehaviourPostProcessor implements BeanPostProcessor
Behaviour behaviour = method.getAnnotation(Behaviour.class);
QName policy = resolvePolicy(behaviour.policy(), method);
QName type = resolveType(behaviourBean, behaviour);
// assert that the policy and type have been set!!
ParameterCheck.mandatory("policy", policy);
if (behaviour.isService() == false)
{
ParameterCheck.mandatory("type", type);
}
if (logger.isDebugEnabled() == true)
if (logger.isDebugEnabled())
{
if (behaviour.isService() == false)
{
logger.debug(" ... binding " + behaviour.kind() + " behaviour for " + beanName + "." + method.getName() +
" for policy " + policy.toString() +
{
logger.debug(" ... binding " + behaviour.kind() + " behaviour for " + beanName + "." + method.getName() +
" for policy " + policy.toString() +
" and type " + type.toString());
}
else
{
logger.debug(" ... binding " + behaviour.kind() + " service behaviour for " + beanName + "." + method.getName() +
logger.debug(" ... binding " + behaviour.kind() + " service behaviour for " + beanName + "." + method.getName() +
" for policy " + policy.toString());
}
}
// create java behaviour object
JavaBehaviour javaBehaviour = new JavaBehaviour(bean, method.getName(), behaviour.notificationFrequency());
// determine whether we should register the behaviour
if (bean instanceof BehaviourRegistry && behaviour.name().isEmpty() == false)
{
if (logger.isDebugEnabled() == true)
if (logger.isDebugEnabled())
{
logger.debug(" ... adding behaviour to registry with name " + behaviour.name());
}
((BehaviourRegistry)bean).registerBehaviour(behaviour.name(), javaBehaviour);
}
// deal with class behaviours
if (BehaviourKind.CLASS.equals(behaviour.kind()) == true)
if (BehaviourKind.CLASS.equals(behaviour.kind()))
{
if (behaviour.isService() == false)
{
@@ -180,27 +180,27 @@ public class AnnotatedBehaviourPostProcessor implements BeanPostProcessor
}
}
// deal with association behaviours
else if (BehaviourKind.ASSOCIATION.equals(behaviour.kind()) == true)
else if (BehaviourKind.ASSOCIATION.equals(behaviour.kind()))
{
if (behaviour.isService() == false)
{
{
// bind association behaviour for given type and assoc type
policyComponent.bindAssociationBehaviour(policy,
type,
policyComponent.bindAssociationBehaviour(policy,
type,
toQName(behaviour.assocType()),
javaBehaviour);
javaBehaviour);
}
else
{
{
// bind association service behaviour
policyComponent.bindAssociationBehaviour(policy, bean, javaBehaviour);
policyComponent.bindAssociationBehaviour(policy, bean, javaBehaviour);
}
}
}
}
/**
* Resolve the policy qname, defaulting to the qualified name of the method if none specified.
*
*
* @param policyName policy name
* @param method method
* @return {@link QName} qualified name of the policy
@@ -208,7 +208,7 @@ public class AnnotatedBehaviourPostProcessor implements BeanPostProcessor
private QName resolvePolicy(String policyName, Method method)
{
QName policy = null;
if (policyName.isEmpty() == true)
if (policyName.isEmpty())
{
policy = QName.createQName(NamespaceService.ALFRESCO_URI, method.getName());
}
@@ -216,12 +216,12 @@ public class AnnotatedBehaviourPostProcessor implements BeanPostProcessor
{
policy = toQName(policyName);
}
return policy;
return policy;
}
/**
*
*
* @param behaviourBean
* @param typeName
* @return
@@ -231,7 +231,7 @@ public class AnnotatedBehaviourPostProcessor implements BeanPostProcessor
QName type = null;
if (behaviour.isService() == false)
{
if (behaviour.type().isEmpty() == true)
if (behaviour.type().isEmpty())
{
// get default
type = toQName(behaviourBean.defaultType());
@@ -244,9 +244,9 @@ public class AnnotatedBehaviourPostProcessor implements BeanPostProcessor
}
return type;
}
/**
*
*
* @param name
* @return
*/

View File

@@ -44,7 +44,7 @@ public class ExtendedRuleServiceImpl extends RuleServiceImpl
/** ignore types */
private Set<QName> ignoredTypes = new HashSet<QName>();
/** file plan service */
private FilePlanService filePlanService;
@@ -53,7 +53,7 @@ public class ExtendedRuleServiceImpl extends RuleServiceImpl
/** node service */
protected NodeService nodeService;
/**
* @param runAsRmAdmin true if run rules as rmadmin, false otherwise
*/
@@ -77,11 +77,11 @@ public class ExtendedRuleServiceImpl extends RuleServiceImpl
{
this.nodeService = nodeService;
}
/**
* @param filePlanService file plan service
*/
public void setFilePlanService(FilePlanService filePlanService)
public void setFilePlanService(FilePlanService filePlanService)
{
this.filePlanService = filePlanService;
}
@@ -107,7 +107,7 @@ public class ExtendedRuleServiceImpl extends RuleServiceImpl
@Override
public void saveRule(final NodeRef nodeRef, final Rule rule)
{
if (filePlanService.isFilePlanComponent(nodeRef) == true)
if (filePlanService.isFilePlanComponent(nodeRef))
{
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
{
@@ -132,7 +132,7 @@ public class ExtendedRuleServiceImpl extends RuleServiceImpl
@Override
public void removeRule(final NodeRef nodeRef, final Rule rule)
{
if (filePlanService.isFilePlanComponent(nodeRef) == true)
if (filePlanService.isFilePlanComponent(nodeRef))
{
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
{
@@ -157,24 +157,24 @@ public class ExtendedRuleServiceImpl extends RuleServiceImpl
@Override
public void executeRule(final Rule rule, final NodeRef nodeRef, final Set<ExecutedRuleData> executedRules)
{
if (nodeService.exists(nodeRef) == true)
if (nodeService.exists(nodeRef))
{
QName typeQName = nodeService.getType(nodeRef);
// check if this is a rm rule on a rm artifact
if (filePlanService.isFilePlanComponent(nodeRef) == true &&
isFilePlanComponentRule(rule) == true)
if (filePlanService.isFilePlanComponent(nodeRef) &&
isFilePlanComponentRule(rule))
{
// ignore and
if (isIgnoredType(typeQName) == false)
{
if (runAsRmAdmin == true)
if (runAsRmAdmin)
{
// run as rmadmin
filePlanAuthenticationService.runAsRmAdmin(new RunAsWork<Void>()
filePlanAuthenticationService.runAsRmAdmin(new RunAsWork<Void>()
{
@Override
public Void doWork() throws Exception
public Void doWork() throws Exception
{
ExtendedRuleServiceImpl.super.executeRule(rule, nodeRef, executedRules);
return null;
@@ -198,7 +198,7 @@ public class ExtendedRuleServiceImpl extends RuleServiceImpl
/**
* Indicates whether the rule is a file plan component
*
*
* @param rule rule
* @return boolean true if rule is set on a file plan component, false otherwise
*/
@@ -209,7 +209,7 @@ public class ExtendedRuleServiceImpl extends RuleServiceImpl
}
/**
* @param typeQName type qname
* @param typeQName type qname
* @return boolean true if ignore type, false otherwise
*/
private boolean isIgnoredType(QName typeQName)

View File

@@ -33,7 +33,7 @@ import org.apache.commons.logging.LogFactory;
/**
* Prevent multiple triggering of outbound rules when moving records.
*
*
* @author Roy Wetherall
*/
public class ExtendedBeforeDeleteChildAssociationRuleTrigger
@@ -44,33 +44,33 @@ public class ExtendedBeforeDeleteChildAssociationRuleTrigger
* The logger
*/
private static Log logger = LogFactory.getLog(BeforeDeleteChildAssociationRuleTrigger.class);
private static final String POLICY = "beforeDeleteChildAssociation";
private boolean isClassBehaviour = false;
public void setIsClassBehaviour(boolean isClassBehaviour)
{
this.isClassBehaviour = isClassBehaviour;
}
/**
* @see org.alfresco.repo.rule.ruletrigger.RuleTrigger#registerRuleTrigger()
*/
public void registerRuleTrigger()
{
if (isClassBehaviour == true)
if (isClassBehaviour)
{
this.policyComponent.bindClassBehaviour(
QName.createQName(NamespaceService.ALFRESCO_URI, POLICY),
this,
QName.createQName(NamespaceService.ALFRESCO_URI, POLICY),
this,
new JavaBehaviour(this, POLICY, NotificationFrequency.FIRST_EVENT));
}
else
{
this.policyComponent.bindAssociationBehaviour(
QName.createQName(NamespaceService.ALFRESCO_URI, POLICY),
this,
QName.createQName(NamespaceService.ALFRESCO_URI, POLICY),
this,
new JavaBehaviour(this, POLICY, NotificationFrequency.FIRST_EVENT));
}
}
@@ -91,12 +91,12 @@ public class ExtendedBeforeDeleteChildAssociationRuleTrigger
{
return;
}
if (logger.isDebugEnabled() == true)
if (logger.isDebugEnabled())
{
logger.debug("Single child assoc trigger (policy = " + POLICY + ") fired for parent node " + childAssocRef.getParentRef() + " and child node " + childAssocRef.getChildRef());
}
triggerRules(childAssocRef.getParentRef(), childNodeRef);
}

View File

@@ -39,7 +39,7 @@ import org.springframework.context.ApplicationEvent;
* permission.
* <p>
* This is required for SOLR support.
*
*
* @author Roy Wetherall
*/
public class RMPermissionServiceImpl extends PermissionServiceImpl
@@ -47,7 +47,7 @@ public class RMPermissionServiceImpl extends PermissionServiceImpl
{
/** Writers simple cache */
protected SimpleCache<Serializable, Set<String>> writersCache;
/**
* @see org.alfresco.repo.security.permissions.impl.PermissionServiceImpl#setAnyDenyDenies(boolean)
*/
@@ -57,7 +57,7 @@ public class RMPermissionServiceImpl extends PermissionServiceImpl
super.setAnyDenyDenies(anyDenyDenies);
writersCache.clear();
}
/**
* @param writersCache the writersCache to set
*/
@@ -65,44 +65,44 @@ public class RMPermissionServiceImpl extends PermissionServiceImpl
{
this.writersCache = writersCache;
}
/**
* @see org.alfresco.repo.security.permissions.impl.PermissionServiceImpl#onBootstrap(org.springframework.context.ApplicationEvent)
*/
@Override
protected void onBootstrap(ApplicationEvent event)
{
super.onBootstrap(event);
super.onBootstrap(event);
PropertyCheck.mandatory(this, "writersCache", writersCache);
}
/**
* Override to deal with the possibility of hard coded permission checks in core code.
*
*
* Note: Eventually we need to merge the RM permission model into the core to make this more rebust.
*
*
* @see org.alfresco.repo.security.permissions.impl.ExtendedPermissionService#hasPermission(org.alfresco.service.cmr.repository.NodeRef, java.lang.String)
*/
@Override
public AccessStatus hasPermission(NodeRef nodeRef, String perm)
{
AccessStatus acs = super.hasPermission(nodeRef, perm);
if (AccessStatus.DENIED.equals(acs) == true &&
PermissionService.READ.equals(perm) == true &&
nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT) == true)
if (AccessStatus.DENIED.equals(acs) &&
PermissionService.READ.equals(perm) &&
nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT))
{
return super.hasPermission(nodeRef, RMPermissionModel.READ_RECORDS);
}
else if (AccessStatus.DENIED.equals(acs) == true &&
PermissionService.WRITE.equals(perm) == true &&
nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT) == true)
else if (AccessStatus.DENIED.equals(acs) &&
PermissionService.WRITE.equals(perm) &&
nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT))
{
return super.hasPermission(nodeRef, RMPermissionModel.FILE_RECORDS);
}
return acs;
}
/**
* @see org.alfresco.repo.security.permissions.impl.PermissionServiceImpl#canRead(java.lang.Long)
*/
@@ -111,8 +111,8 @@ public class RMPermissionServiceImpl extends PermissionServiceImpl
{
Set<String> authorities = getAuthorisations();
// test denied
// test denied
if(anyDenyDenies)
{
@@ -125,12 +125,12 @@ public class RMPermissionServiceImpl extends PermissionServiceImpl
return AccessStatus.DENIED;
}
}
}
// test acl readers
Set<String> aclReaders = getReaders(aclId);
for(String auth : aclReaders)
{
if(authorities.contains(auth))
@@ -141,7 +141,7 @@ public class RMPermissionServiceImpl extends PermissionServiceImpl
return AccessStatus.DENIED;
}
/**
* @see org.alfresco.repo.security.permissions.impl.PermissionServiceImpl#getReaders(java.lang.Long)
*/
@@ -159,7 +159,7 @@ public class RMPermissionServiceImpl extends PermissionServiceImpl
{
return aclReaders;
}
HashSet<String> assigned = new HashSet<String>();
HashSet<String> readers = new HashSet<String>();
@@ -185,7 +185,7 @@ public class RMPermissionServiceImpl extends PermissionServiceImpl
/**
* Override with check for RM read
*
*
* @param aclId
* @return
*/
@@ -219,12 +219,12 @@ public class RMPermissionServiceImpl extends PermissionServiceImpl
denied.add(authority);
}
}
readersDeniedCache.put((Serializable)acl.getProperties(), denied);
return denied;
}
/**
* @see org.alfresco.repo.security.permissions.impl.ExtendedPermissionService#getWriters(java.lang.Long)
*/
@@ -241,7 +241,7 @@ public class RMPermissionServiceImpl extends PermissionServiceImpl
{
return aclWriters;
}
HashSet<String> assigned = new HashSet<String>();
HashSet<String> readers = new HashSet<String>();

View File

@@ -185,7 +185,7 @@ public class RmClassesGet extends DictionaryWebServiceBase implements RecordsMan
}
}
if (classdef.isEmpty() == true)
if (classdef.isEmpty())
{
for (QName qnameObj : qnames)
{
@@ -213,7 +213,7 @@ public class RmClassesGet extends DictionaryWebServiceBase implements RecordsMan
*/
private Collection<QName> getTypes(boolean isRM)
{
if (isRM == true)
if (isRM)
{
return this.dictionaryservice.getTypes(RM_MODEL);
}
@@ -231,7 +231,7 @@ public class RmClassesGet extends DictionaryWebServiceBase implements RecordsMan
*/
private Collection<QName> getAspects(boolean isRM)
{
if (isRM == true)
if (isRM)
{
return this.dictionaryservice.getAspects(RM_MODEL);
}

View File

@@ -43,12 +43,12 @@ public class RmDictionaryWebServiceUtils
{
boolean isRmSite = false;
String siteId = req.getParameter(SITE_ID);
if (StringUtils.isNotBlank(siteId) == true)
if (StringUtils.isNotBlank(siteId))
{
SiteInfo site = siteService.getSite(siteId);
if (site != null)
{
if (site.getSitePreset().equals(SITE_PRESET) == true)
if (site.getSitePreset().equals(SITE_PRESET))
{
isRmSite = true;
}

View File

@@ -139,7 +139,7 @@ public class RmPropertiesGet extends DictionaryWebServiceBase implements Records
for (Map.Entry<QName, PropertyDefinition> entry : propMap.entrySet())
{
if ((namespaceURI != null &&
namespaceURI.equals(entry.getKey().getNamespaceURI()) == true) ||
namespaceURI.equals(entry.getKey().getNamespaceURI())) ||
namespaceURI == null)
{
props.add(entry.getValue());
@@ -165,7 +165,7 @@ public class RmPropertiesGet extends DictionaryWebServiceBase implements Records
*/
private Collection<QName> getProperties(boolean isRM)
{
if (isRM == true)
if (isRM)
{
return dictionaryservice.getProperties(RM_MODEL);
}

View File

@@ -41,33 +41,33 @@ import org.springframework.extensions.webscripts.WebScriptRequest;
public class RmActionConditionDefinitionsGet extends DeclarativeWebScript
{
private ActionService actionService;
private RecordsManagementActionService recordsManagementActionService;
public void setActionService(ActionService actionService)
{
this.actionService = actionService;
}
public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService)
{
this.recordsManagementActionService = recordsManagementActionService;
}
/**
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache)
*/
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
List<ActionConditionDefinition> dmDefs = actionService.getActionConditionDefinitions();
List<ActionConditionDefinition> dmDefs = actionService.getActionConditionDefinitions();
List<RecordsManagementActionCondition> conditions = recordsManagementActionService.getRecordsManagementActionConditions();
List<ActionConditionDefinition> defs = new ArrayList<ActionConditionDefinition>(dmDefs.size()+conditions.size());
defs.addAll(dmDefs);
for (RecordsManagementActionCondition condition: conditions)
{
if (condition.isPublicCondition() == true)
if (condition.isPublicCondition())
{
defs.add(condition.getRecordsManagementActionConditionDefinition());
}

View File

@@ -41,12 +41,12 @@ import org.springframework.extensions.webscripts.WebScriptRequest;
public class RmActionDefinitionsGet extends DeclarativeWebScript
{
private RecordsManagementActionService recordsManagementActionService;
public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService)
{
this.recordsManagementActionService = recordsManagementActionService;
}
/**
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache)
*/
@@ -57,15 +57,15 @@ public class RmActionDefinitionsGet extends DeclarativeWebScript
Set<ActionDefinition> defs = new HashSet<ActionDefinition>(actions.size());
for (RecordsManagementAction action : actions)
{
if (action.isPublicAction() == true)
if (action.isPublicAction())
{
defs.add(action.getRecordsManagementActionDefinition());
}
}
Map<String, Object> model = new HashMap<String, Object>();
model.put("actiondefinitions", defs);
return model;
}
}

View File

@@ -243,7 +243,7 @@ public class RmSubstitutionSuggestionsGet extends DeclarativeWebScript
{
StoreRef storeRef = new StoreRef(storeType, storeId);
NodeRef nodeRef = new NodeRef(storeRef, id);
if (filePlanService.isFilePlan(nodeRef) == true)
if (filePlanService.isFilePlan(nodeRef))
{
filePlan = nodeRef;
}