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 (Performance - Inefficient use of keySet iterator instead of entrySet iterator)
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@65396 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -107,10 +107,10 @@ public class ApplyCustomTypeAction extends RMActionExecuterAbstractBase
|
||||
Map<String, Serializable> paramValues = action.getParameterValues();
|
||||
|
||||
Map<QName, Serializable> result = new HashMap<QName, Serializable>(paramValues.size());
|
||||
for (String paramName : paramValues.keySet())
|
||||
for (Map.Entry<String, Serializable> entry : paramValues.entrySet())
|
||||
{
|
||||
QName propQName = QName.createQName(paramName, this.namespaceService);
|
||||
result.put(propQName, paramValues.get(paramName));
|
||||
QName propQName = QName.createQName(entry.getKey(), this.namespaceService);
|
||||
result.put(propQName, entry.getValue());
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -132,11 +132,12 @@ public class ApplyCustomTypeAction extends RMActionExecuterAbstractBase
|
||||
|
||||
this.parameterDefinitions = new ArrayList<ParameterDefinition>(props.size());
|
||||
|
||||
for (QName qn : props.keySet())
|
||||
for (Map.Entry<QName, PropertyDefinition> entry : props.entrySet())
|
||||
{
|
||||
String paramName = qn.toPrefixString(namespaceService);
|
||||
QName paramType = props.get(qn).getDataType().getName();
|
||||
boolean paramIsMandatory = props.get(qn).isMandatory();
|
||||
String paramName = entry.getKey().toPrefixString(namespaceService);
|
||||
PropertyDefinition value = entry.getValue();
|
||||
QName paramType = value.getDataType().getName();
|
||||
boolean paramIsMandatory = value.isMandatory();
|
||||
parameterDefinitions.add(new ParameterDefinitionImpl(paramName, paramType, paramIsMandatory, null));
|
||||
}
|
||||
}
|
||||
|
@@ -575,9 +575,9 @@ public class RMAfterInvocationProvider extends RMSecurityCommon
|
||||
Map<Set<String>, ResultSet> map = returnedObject.getResults();
|
||||
Map<Set<String>, ResultSet> answer = new HashMap<Set<String>, ResultSet>(map.size(), 1.0f);
|
||||
|
||||
for (Set<String> group : map.keySet())
|
||||
for (Map.Entry<Set<String>, ResultSet> entry : map.entrySet())
|
||||
{
|
||||
ResultSet raw = map.get(group);
|
||||
ResultSet raw = entry.getValue();
|
||||
ResultSet permed;
|
||||
if (PagingLuceneResultSet.class.isAssignableFrom(raw.getClass()))
|
||||
{
|
||||
@@ -587,8 +587,9 @@ public class RMAfterInvocationProvider extends RMSecurityCommon
|
||||
{
|
||||
permed = decide(authentication, object, config, raw);
|
||||
}
|
||||
answer.put(group, permed);
|
||||
answer.put(entry.getKey(), permed);
|
||||
}
|
||||
|
||||
return new QueryEngineResults(answer);
|
||||
}
|
||||
|
||||
|
@@ -35,11 +35,12 @@ import java.util.Map;
|
||||
|
||||
Map<String, List<String>> pivot = new HashMap<String, List<String>>();
|
||||
|
||||
for(String authority : source.keySet())
|
||||
for (Map.Entry<String, List<String>> entry : source.entrySet())
|
||||
{
|
||||
List<String>values = source.get(authority);
|
||||
List<String>values = entry.getValue();
|
||||
for (String value : values)
|
||||
{
|
||||
String authority = entry.getKey();
|
||||
if (pivot.containsKey(value))
|
||||
{
|
||||
// already exists
|
||||
@@ -55,6 +56,7 @@ import java.util.Map;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return pivot;
|
||||
}
|
||||
}
|
||||
|
@@ -161,14 +161,14 @@ public class CustomEmailMappingServiceImpl extends AbstractLifecycleBean impleme
|
||||
|
||||
// load the contents of the extractors property file
|
||||
Map<String, Set<QName>> currentMapping = extracter.getCurrentMapping();
|
||||
for(String key : currentMapping.keySet())
|
||||
for (Map.Entry<String, Set<QName>> entry : currentMapping.entrySet())
|
||||
{
|
||||
Set<QName> set = currentMapping.get(key);
|
||||
Set<QName> set = entry.getValue();
|
||||
|
||||
for (QName qname : set)
|
||||
{
|
||||
CustomMapping value = new CustomMapping();
|
||||
value.setFrom(key);
|
||||
value.setFrom(entry.getKey());
|
||||
QName resolvedQname = qname.getPrefixedQName(nspr);
|
||||
value.setTo(resolvedQname.toPrefixString());
|
||||
customMappings.add(value);
|
||||
|
@@ -839,10 +839,10 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
|
||||
private Set<QName> determineChangedProps(Map<QName, Serializable> oldProps, Map<QName, Serializable> newProps)
|
||||
{
|
||||
Set<QName> result = new HashSet<QName>();
|
||||
for (QName qn : oldProps.keySet())
|
||||
for (Map.Entry<QName, Serializable> entry : oldProps.entrySet())
|
||||
{
|
||||
if (newProps.get(qn) == null ||
|
||||
!newProps.get(qn).equals(oldProps.get(qn)))
|
||||
QName qn = entry.getKey();
|
||||
if (newProps.get(qn) == null || !newProps.get(qn).equals(entry.getValue()))
|
||||
{
|
||||
result.add(qn);
|
||||
}
|
||||
|
@@ -336,8 +336,9 @@ public class ModelSecurityServiceImpl extends BaseBehaviourBean
|
||||
!AuthenticationUtil.isRunAsUserTheSystemUser() &&
|
||||
nodeService.exists(nodeRef))
|
||||
{
|
||||
for (QName property : after.keySet())
|
||||
for (Map.Entry<QName, Serializable> entry : after.entrySet())
|
||||
{
|
||||
QName property = entry.getKey();
|
||||
if (isProtectedProperty(property))
|
||||
{
|
||||
// always allow if this is the first time we are setting the protected property
|
||||
@@ -346,7 +347,7 @@ public class ModelSecurityServiceImpl extends BaseBehaviourBean
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EqualsHelper.nullSafeEquals(before.get(property), after.get(property)) &&
|
||||
if (!EqualsHelper.nullSafeEquals(before.get(property), entry.getValue()) &&
|
||||
!canEditProtectedProperty(nodeRef, property))
|
||||
{
|
||||
// the user can't edit the protected property
|
||||
|
@@ -539,20 +539,16 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
nodeService.exists(nodeRef) &&
|
||||
isRecord(nodeRef))
|
||||
{
|
||||
for (QName property : after.keySet())
|
||||
for (Map.Entry<QName, Serializable> entry : after.entrySet())
|
||||
{
|
||||
Serializable beforeValue = null;
|
||||
QName property = entry.getKey();
|
||||
if (before != null)
|
||||
{
|
||||
beforeValue = before.get(property);
|
||||
}
|
||||
|
||||
Serializable afterValue = null;
|
||||
if (after != null)
|
||||
{
|
||||
afterValue = after.get(property);
|
||||
}
|
||||
|
||||
Serializable afterValue = entry.getValue();
|
||||
boolean propertyUnchanged = false;
|
||||
if (beforeValue instanceof Date && afterValue instanceof Date)
|
||||
{
|
||||
|
@@ -201,12 +201,12 @@ public class RmActionPost extends DeclarativeWebScript
|
||||
{
|
||||
Map<NodeRef, RecordsManagementActionResult> resultMap = this.rmActionService.executeRecordsManagementAction(targetNodeRefs, actionName, actionParams);
|
||||
Map<String, String> results = new HashMap<String, String>(resultMap.size());
|
||||
for (NodeRef nodeRef : resultMap.keySet())
|
||||
for (Map.Entry<NodeRef, RecordsManagementActionResult> entry : resultMap.entrySet())
|
||||
{
|
||||
Object value = resultMap.get(nodeRef).getValue();
|
||||
Object value = entry.getValue().getValue();
|
||||
if (value != null)
|
||||
{
|
||||
results.put(nodeRef.toString(), resultMap.get(nodeRef).getValue().toString());
|
||||
results.put(entry.getKey().toString(), value.toString());
|
||||
}
|
||||
}
|
||||
model.put("results", results);
|
||||
|
@@ -267,13 +267,13 @@ public class NodeParameterProcessor extends ParameterProcessor implements Parame
|
||||
boolean gotMaximumSuggestions = false;
|
||||
if (properties != null)
|
||||
{
|
||||
for(QName key : properties.keySet())
|
||||
for (Map.Entry<QName, PropertyDefinition> entry : properties.entrySet())
|
||||
{
|
||||
PropertyDefinition propertyDefinition = properties.get(key);
|
||||
PropertyDefinition propertyDefinition = entry.getValue();
|
||||
QName type = propertyDefinition.getDataType().getName();
|
||||
if(ArrayUtils.contains(supportedDataTypes, type))
|
||||
{
|
||||
String suggestion = getName() + "." + key.getPrefixString();
|
||||
String suggestion = getName() + "." + entry.getKey().getPrefixString();
|
||||
if(suggestion.toLowerCase().contains(substitutionFragment))
|
||||
{
|
||||
if(suggestions.size() < this.maximumNumberSuggestions)
|
||||
|
Reference in New Issue
Block a user