Fixed major issues reported by sonar (Unnecessary Local Before Return)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@64827 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2014-03-18 23:41:13 +00:00
parent 49f9e35640
commit bcfb1ba174
6 changed files with 51 additions and 65 deletions

View File

@@ -1196,31 +1196,28 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
invokeOnRemoveReference(fromNode, toNode, assocId); invokeOnRemoveReference(fromNode, toNode, assocId);
} }
/** /**
* @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#getCustomReferencesFrom(org.alfresco.service.cmr.repository.NodeRef) * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#getCustomReferencesFrom(org.alfresco.service.cmr.repository.NodeRef)
*/ */
public List<AssociationRef> getCustomReferencesFrom(NodeRef node) public List<AssociationRef> getCustomReferencesFrom(NodeRef node)
{ {
List<AssociationRef> retrievedAssocs = nodeService.getTargetAssocs(node, RegexQNamePattern.MATCH_ALL); return nodeService.getTargetAssocs(node, RegexQNamePattern.MATCH_ALL);
return retrievedAssocs; }
}
/** /**
* @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#getCustomChildReferences(org.alfresco.service.cmr.repository.NodeRef) * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#getCustomChildReferences(org.alfresco.service.cmr.repository.NodeRef)
*/ */
public List<ChildAssociationRef> getCustomChildReferences(NodeRef node) public List<ChildAssociationRef> getCustomChildReferences(NodeRef node)
{ {
List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(node); return nodeService.getChildAssocs(node);
return childAssocs; }
}
/** /**
* @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#getCustomReferencesTo(org.alfresco.service.cmr.repository.NodeRef) * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#getCustomReferencesTo(org.alfresco.service.cmr.repository.NodeRef)
*/ */
public List<AssociationRef> getCustomReferencesTo(NodeRef node) public List<AssociationRef> getCustomReferencesTo(NodeRef node)
{ {
List<AssociationRef> retrievedAssocs = nodeService.getSourceAssocs(node, RegexQNamePattern.MATCH_ALL); return nodeService.getSourceAssocs(node, RegexQNamePattern.MATCH_ALL);
return retrievedAssocs;
} }
/** /**
@@ -1228,8 +1225,7 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
*/ */
public List<ChildAssociationRef> getCustomParentReferences(NodeRef node) public List<ChildAssociationRef> getCustomParentReferences(NodeRef node)
{ {
List<ChildAssociationRef> result = nodeService.getParentAssocs(node); return nodeService.getParentAssocs(node);
return result;
} }
// note: currently RMC custom assocs only // note: currently RMC custom assocs only

View File

@@ -421,8 +421,7 @@ public class RMAfterInvocationProvider extends RMSecurityCommon
{ {
ResultSet raw = returnedObject.getWrapped(); ResultSet raw = returnedObject.getWrapped();
ResultSet filteredForPermissions = decide(authentication, object, config, raw); ResultSet filteredForPermissions = decide(authentication, object, config, raw);
PagingLuceneResultSet newPaging = new PagingLuceneResultSet(filteredForPermissions, returnedObject.getResultSetMetaData().getSearchParameters(), nodeService); return new PagingLuceneResultSet(filteredForPermissions, returnedObject.getResultSetMetaData().getSearchParameters(), nodeService);
return newPaging;
} }
private ResultSet decide(Authentication authentication, Object object, ConfigAttributeDefinition config, ResultSet returnedObject) throws AccessDeniedException private ResultSet decide(Authentication authentication, Object object, ConfigAttributeDefinition config, ResultSet returnedObject) throws AccessDeniedException

View File

@@ -108,8 +108,7 @@ public abstract class AbstractBasePolicy extends RMSecurityCommon
{ {
if (invocation.getArguments()[position] != null) if (invocation.getArguments()[position] != null)
{ {
QName qname = (QName) invocation.getArguments()[position]; return (QName) invocation.getArguments()[position];
return qname;
} }
} }
else if (NodeRef.class.isAssignableFrom(params[position]) && invocation.getArguments()[position] != null) else if (NodeRef.class.isAssignableFrom(params[position]) && invocation.getArguments()[position] != null)
@@ -133,8 +132,7 @@ public abstract class AbstractBasePolicy extends RMSecurityCommon
{ {
if (QName.class.isAssignableFrom(params[position]) && invocation.getArguments()[position] != null) if (QName.class.isAssignableFrom(params[position]) && invocation.getArguments()[position] != null)
{ {
QName qname = (QName) invocation.getArguments()[position]; return (QName) invocation.getArguments()[position];
return qname;
} }
throw new ACLEntryVoterException("Unknown type"); throw new ACLEntryVoterException("Unknown type");
} }
@@ -155,8 +153,7 @@ public abstract class AbstractBasePolicy extends RMSecurityCommon
} }
if (Serializable.class.isAssignableFrom(params[position]) && invocation.getArguments()[position] != null) if (Serializable.class.isAssignableFrom(params[position]) && invocation.getArguments()[position] != null)
{ {
Serializable property = (Serializable) invocation.getArguments()[position]; return (Serializable) invocation.getArguments()[position];
return property;
} }
throw new ACLEntryVoterException("Unknown type"); throw new ACLEntryVoterException("Unknown type");
} }
@@ -177,8 +174,7 @@ public abstract class AbstractBasePolicy extends RMSecurityCommon
} }
if (Map.class.isAssignableFrom(params[position]) && invocation.getArguments()[position] != null) if (Map.class.isAssignableFrom(params[position]) && invocation.getArguments()[position] != null)
{ {
Map<QName, Serializable> properties = (Map<QName, Serializable>) invocation.getArguments()[position]; return (Map<QName, Serializable>) invocation.getArguments()[position];
return properties;
} }
throw new ACLEntryVoterException("Unknown type"); throw new ACLEntryVoterException("Unknown type");
} }

View File

@@ -67,8 +67,7 @@ public class ScriptConstraint implements Serializable
public String getName() public String getName()
{ {
String xxx = info.getName().replace(":", "_"); return info.getName().replace(":", "_");
return xxx;
} }
public boolean isCaseSensitive() public boolean isCaseSensitive()
@@ -257,9 +256,7 @@ public class ScriptConstraint implements Serializable
} }
} }
return constraints.toArray(new ScriptConstraintValue[constraints.size()]);
ScriptConstraintValue[] retVal = constraints.toArray(new ScriptConstraintValue[constraints.size()]);
return retVal;
} }
} }

View File

@@ -44,7 +44,7 @@ public class ScriptRMCaveatConfigService extends BaseScopableProcessorExtension
{ {
return caveatConfigService; return caveatConfigService;
} }
public void setAuthorityService(AuthorityService authorityService) public void setAuthorityService(AuthorityService authorityService)
{ {
this.authorityService = authorityService; this.authorityService = authorityService;
@@ -54,36 +54,36 @@ public class ScriptRMCaveatConfigService extends BaseScopableProcessorExtension
{ {
return authorityService; return authorityService;
} }
public ScriptConstraint getConstraint(String listName) public ScriptConstraint getConstraint(String listName)
{ {
//TODO Temporary conversion //TODO Temporary conversion
String xxx = listName.replace("_", ":"); String xxx = listName.replace("_", ":");
RMConstraintInfo info = caveatConfigService.getRMConstraint(xxx); RMConstraintInfo info = caveatConfigService.getRMConstraint(xxx);
if(info != null) if(info != null)
{ {
return new ScriptConstraint(info, caveatConfigService, getAuthorityService()); return new ScriptConstraint(info, caveatConfigService, getAuthorityService());
} }
return null; return null;
} }
public ScriptConstraint[] getAllConstraints() public ScriptConstraint[] getAllConstraints()
{ {
return getConstraints(true); return getConstraints(true);
} }
public ScriptConstraint[] getConstraintsWithoutEmptyList() public ScriptConstraint[] getConstraintsWithoutEmptyList()
{ {
return getConstraints(false); return getConstraints(false);
} }
private ScriptConstraint[] getConstraints(boolean includeEmptyList) private ScriptConstraint[] getConstraints(boolean includeEmptyList)
{ {
Set<RMConstraintInfo> values = caveatConfigService.getAllRMConstraints(); Set<RMConstraintInfo> values = caveatConfigService.getAllRMConstraints();
List<ScriptConstraint> vals = new ArrayList<ScriptConstraint>(values.size()); List<ScriptConstraint> vals = new ArrayList<ScriptConstraint>(values.size());
for(RMConstraintInfo value : values) for(RMConstraintInfo value : values)
{ {
@@ -100,10 +100,10 @@ public class ScriptRMCaveatConfigService extends BaseScopableProcessorExtension
} }
} }
} }
return vals.toArray(new ScriptConstraint[vals.size()]); return vals.toArray(new ScriptConstraint[vals.size()]);
} }
/** /**
* Delete list * Delete list
* @param listName * @param listName
@@ -115,18 +115,18 @@ public class ScriptRMCaveatConfigService extends BaseScopableProcessorExtension
String xxx = listName.replace("_", ":"); String xxx = listName.replace("_", ":");
caveatConfigService.deleteRMConstraint(xxx); caveatConfigService.deleteRMConstraint(xxx);
} }
/** /**
* Update value * Update value
*/ */
public void updateConstraintValues(String listName, String authorityName, String[]values) public void updateConstraintValues(String listName, String authorityName, String[]values)
{ {
List<String> vals = new ArrayList<String>(); List<String> vals = new ArrayList<String>();
caveatConfigService.updateRMConstraintListAuthority(listName, authorityName, vals); caveatConfigService.updateRMConstraintListAuthority(listName, authorityName, vals);
} }
/** /**
* Delete the constraint values. i.e remove an authority from a constraint list * Delete the constraint values. i.e remove an authority from a constraint list
*/ */
@@ -134,10 +134,10 @@ public class ScriptRMCaveatConfigService extends BaseScopableProcessorExtension
{ {
//TODO Temporary conversion //TODO Temporary conversion
String xxx = listName.replace("_", ":"); String xxx = listName.replace("_", ":");
caveatConfigService.removeRMConstraintListAuthority(xxx, authorityName); caveatConfigService.removeRMConstraintListAuthority(xxx, authorityName);
} }
/** /**
* Delete the constraint values. i.e remove a value from a constraint list * Delete the constraint values. i.e remove a value from a constraint list
*/ */
@@ -145,22 +145,21 @@ public class ScriptRMCaveatConfigService extends BaseScopableProcessorExtension
{ {
//TODO Temporary conversion //TODO Temporary conversion
String xxx = listName.replace("_", ":"); String xxx = listName.replace("_", ":");
caveatConfigService.removeRMConstraintListValue(xxx, valueName); caveatConfigService.removeRMConstraintListValue(xxx, valueName);
} }
public ScriptConstraint createConstraint(String listName, String title, String[] allowedValues) public ScriptConstraint createConstraint(String listName, String title, String[] allowedValues)
{ {
//TODO Temporary conversion //TODO Temporary conversion
if(listName != null) if(listName != null)
{ {
listName = listName.replace("_", ":"); listName = listName.replace("_", ":");
} }
RMConstraintInfo info = caveatConfigService.addRMConstraint(listName, title, allowedValues); RMConstraintInfo info = caveatConfigService.addRMConstraint(listName, title, allowedValues);
ScriptConstraint c = new ScriptConstraint(info, caveatConfigService, getAuthorityService()); return new ScriptConstraint(info, caveatConfigService, getAuthorityService());
return c;
} }
} }

View File

@@ -27,7 +27,7 @@ import org.alfresco.service.cmr.repository.NodeRef;
/** /**
* Basic identifier generator implementation. * Basic identifier generator implementation.
* *
* @author Roy Wetherall * @author Roy Wetherall
*/ */
public class BasicIdentifierGenerator extends IdentifierGeneratorBase public class BasicIdentifierGenerator extends IdentifierGeneratorBase
@@ -48,10 +48,9 @@ public class BasicIdentifierGenerator extends IdentifierGeneratorBase
{ {
dbId = System.currentTimeMillis(); dbId = System.currentTimeMillis();
} }
Calendar fileCalendar = Calendar.getInstance(); Calendar fileCalendar = Calendar.getInstance();
String year = Integer.toString(fileCalendar.get(Calendar.YEAR)); String year = Integer.toString(fileCalendar.get(Calendar.YEAR));
String identifier = year + "-" + padString(dbId.toString(), 10); return year + "-" + padString(dbId.toString(), 10);
return identifier;
} }
} }