Fixed minor issues ("Collapsible If Statements") reported in Sonar

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@71949 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2014-05-27 21:09:29 +00:00
parent a5c415e3b3
commit f50e604b7e
6 changed files with 56 additions and 73 deletions

View File

@@ -444,12 +444,9 @@ public class DispositionServiceImpl extends ServiceBaseImpl
result.add(item); result.add(item);
} }
} }
else if (filePlanService.isRecordCategory(item)) else if (filePlanService.isRecordCategory(item) && getAssociatedDispositionScheduleImpl(item) == null)
{ {
if (getAssociatedDispositionScheduleImpl(item) == null) result.addAll(getDisposableItemsImpl(isRecordLevelDisposition, item));
{
result.addAll(getDisposableItemsImpl(isRecordLevelDisposition, item));
}
} }
} }
return result; return result;
@@ -972,7 +969,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl
applyCutoff(nodeRef); applyCutoff(nodeRef);
// close the record folder if it isn't already closed! // close the record folder if it isn't already closed!
if (recordFolderService.isRecordFolder(nodeRef) && if (recordFolderService.isRecordFolder(nodeRef) &&
!recordFolderService.isRecordFolderClosed(nodeRef)) !recordFolderService.isRecordFolderClosed(nodeRef))
{ {
recordFolderService.closeRecordFolder(nodeRef); recordFolderService.closeRecordFolder(nodeRef);
@@ -987,7 +984,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl
/** /**
* Helper method to apply the cut off * Helper method to apply the cut off
* *
* @param nodeRef node to cut off * @param nodeRef node to cut off
*/ */
private void applyCutoff(final NodeRef nodeRef) private void applyCutoff(final NodeRef nodeRef)
@@ -1000,7 +997,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl
Map<QName, Serializable> cutOffProps = new HashMap<QName, Serializable>(1); Map<QName, Serializable> cutOffProps = new HashMap<QName, Serializable>(1);
cutOffProps.put(PROP_CUT_OFF_DATE, new Date()); cutOffProps.put(PROP_CUT_OFF_DATE, new Date());
nodeService.addAspect(nodeRef, ASPECT_CUT_OFF, cutOffProps); nodeService.addAspect(nodeRef, ASPECT_CUT_OFF, cutOffProps);
return null; return null;
} }
}); });

View File

@@ -203,18 +203,15 @@ public class DispositionProperty extends BaseBehaviourBean
if (dispositionAction != null) if (dispositionAction != null)
{ {
DispositionActionDefinition daDefinition = dispositionAction.getDispositionActionDefinition(); DispositionActionDefinition daDefinition = dispositionAction.getDispositionActionDefinition();
if (daDefinition != null) // check whether the next disposition action matches this disposition property
if (daDefinition != null && propertyName.equals(daDefinition.getPeriodProperty()))
{ {
// check whether the next disposition action matches this disposition property Period period = daDefinition.getPeriod();
if (propertyName.equals(daDefinition.getPeriodProperty())) Date updatedAsOf = period.getNextDate(updatedDateValue);
{
Period period = daDefinition.getPeriod();
Date updatedAsOf = period.getNextDate(updatedDateValue);
// update asOf date on the disposition action based on the new property value // update asOf date on the disposition action based on the new property value
NodeRef daNodeRef = dispositionAction.getNodeRef(); NodeRef daNodeRef = dispositionAction.getNodeRef();
nodeService.setProperty(daNodeRef, PROP_DISPOSITION_AS_OF, updatedAsOf); nodeService.setProperty(daNodeRef, PROP_DISPOSITION_AS_OF, updatedAsOf);
}
} }
} }
} }

View File

@@ -148,15 +148,12 @@ public class FilePlanServiceImpl extends ServiceBaseImpl
SiteService siteService = getSiteService(); SiteService siteService = getSiteService();
SiteInfo siteInfo = siteService.getSite(siteId); SiteInfo siteInfo = siteService.getSite(siteId);
if (siteInfo != null) if (siteInfo != null && siteService.hasContainer(siteId, FILE_PLAN_CONTAINER))
{ {
if (siteService.hasContainer(siteId, FILE_PLAN_CONTAINER)) NodeRef nodeRef = siteService.getContainer(siteId, FILE_PLAN_CONTAINER);
if (instanceOf(nodeRef, TYPE_FILE_PLAN))
{ {
NodeRef nodeRef = siteService.getContainer(siteId, FILE_PLAN_CONTAINER); filePlan = nodeRef;
if (instanceOf(nodeRef, TYPE_FILE_PLAN))
{
filePlan = nodeRef;
}
} }
} }

View File

@@ -345,18 +345,16 @@ public class RecordsManagementNodeFormFilter extends RecordsManagementFormFilter
// as read only // as read only
QName qname = QName.createQName(prefixName, namespaceService); QName qname = QName.createQName(prefixName, namespaceService);
Serializable value = nodeService.getProperty(nodeRef, qname); Serializable value = nodeService.getProperty(nodeRef, qname);
if (value != null) if (value != null &&
(prefixName.equals("cm:title") ||
prefixName.equals("cm:author") ||
prefixName.equals("dod:originator") ||
prefixName.equals("dod:publicationDate") ||
prefixName.equals("dod:dateReceived") ||
prefixName.equals("dod:address") ||
prefixName.equals("dod:otherAddress")))
{ {
if (prefixName.equals("cm:title") || fieldDef.setProtectedField(true);
prefixName.equals("cm:author") ||
prefixName.equals("dod:originator") ||
prefixName.equals("dod:publicationDate") ||
prefixName.equals("dod:dateReceived") ||
prefixName.equals("dod:address") ||
prefixName.equals("dod:otherAddress"))
{
fieldDef.setProtectedField(true);
}
} }
} }

View File

@@ -59,7 +59,7 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl
{ {
/** Permission service */ /** Permission service */
protected PermissionService permissionService; protected PermissionService permissionService;
/** Ownable service */ /** Ownable service */
protected OwnableService ownableService; protected OwnableService ownableService;
@@ -99,7 +99,7 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl
{ {
this.policyComponent = policyComponent; this.policyComponent = policyComponent;
} }
/** /**
* @param ownableService ownable service * @param ownableService ownable service
*/ */
@@ -124,12 +124,12 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl
// setup category permissions // setup category permissions
NodeRef parentNodeRef = nodeService.getPrimaryParent(recordCategory).getParentRef(); NodeRef parentNodeRef = nodeService.getPrimaryParent(recordCategory).getParentRef();
setupPermissions(parentNodeRef, recordCategory); setupPermissions(parentNodeRef, recordCategory);
} }
/** /**
* Setup permissions on new unfiled record folder * Setup permissions on new unfiled record folder
* *
* @param childAssocRef child association reference * @param childAssocRef child association reference
*/ */
@Behaviour @Behaviour
@@ -146,7 +146,7 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl
/** /**
* Setup permissions on new record folder * Setup permissions on new record folder
* *
* @param childAssocRef child association reference * @param childAssocRef child association reference
*/ */
@Behaviour @Behaviour
@@ -160,10 +160,10 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl
{ {
setupPermissions(childAssocRef.getParentRef(), childAssocRef.getChildRef()); setupPermissions(childAssocRef.getParentRef(), childAssocRef.getChildRef());
} }
/** /**
* Setup permissions on newly created hold. * Setup permissions on newly created hold.
* *
* @param childAssocRef child association reference * @param childAssocRef child association reference
*/ */
@Behaviour @Behaviour
@@ -177,10 +177,10 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl
{ {
setupPermissions(childAssocRef.getParentRef(), childAssocRef.getChildRef()); setupPermissions(childAssocRef.getParentRef(), childAssocRef.getChildRef());
} }
/** /**
* Setup permissions on newly created transfer. * Setup permissions on newly created transfer.
* *
* @param childAssocRef child association reference * @param childAssocRef child association reference
*/ */
@Behaviour @Behaviour
@@ -194,10 +194,10 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl
{ {
setupPermissions(childAssocRef.getParentRef(), childAssocRef.getChildRef()); setupPermissions(childAssocRef.getParentRef(), childAssocRef.getChildRef());
} }
/** /**
* Helper method to setup permissions. * Helper method to setup permissions.
* *
* @param parent parent node reference * @param parent parent node reference
* @param nodeRef child node reference * @param nodeRef child node reference
*/ */
@@ -205,12 +205,12 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl
{ {
ParameterCheck.mandatory("parent", parent); ParameterCheck.mandatory("parent", parent);
ParameterCheck.mandatory("nodeRef", nodeRef); ParameterCheck.mandatory("nodeRef", nodeRef);
if (nodeService.exists(nodeRef)) if (nodeService.exists(nodeRef))
{ {
// initialise permissions // initialise permissions
initPermissions(nodeRef); initPermissions(nodeRef);
if (nodeService.exists(parent)) if (nodeService.exists(parent))
{ {
runAsSystem(new AuthenticationUtil.RunAsWork<Object>() runAsSystem(new AuthenticationUtil.RunAsWork<Object>()
@@ -236,7 +236,7 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl
{ {
allow = true; allow = true;
} }
// set the permission on the target node // set the permission on the target node
permissionService.setPermission( permissionService.setPermission(
nodeRef, nodeRef,
@@ -246,17 +246,17 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl
} }
} }
} }
return null; return null;
} }
}); });
} }
} }
} }
/** /**
* Helper method to determine whether all or just filling permissions should be inherited. * Helper method to determine whether all or just filling permissions should be inherited.
* *
* @param parent parent node * @param parent parent node
* @param child child node * @param child child node
* @return boolean true if inherit filling only, false otherwise * @return boolean true if inherit filling only, false otherwise
@@ -264,7 +264,7 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl
private boolean inheritFillingOnly(NodeRef parent, NodeRef child) private boolean inheritFillingOnly(NodeRef parent, NodeRef child)
{ {
boolean result = false; boolean result = false;
// if root category or // if root category or
// if in root of unfiled container or // if in root of unfiled container or
// if in root of hold container // if in root of hold container
@@ -274,8 +274,8 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl
{ {
result = true; result = true;
} }
return result; return result;
} }
/** /**
@@ -326,15 +326,12 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl
for (AccessPermission perm : origionalRecordPerms) for (AccessPermission perm : origionalRecordPerms)
{ {
if (!ExtendedReaderDynamicAuthority.EXTENDED_READER.equals(perm.getAuthority()) && if (!ExtendedReaderDynamicAuthority.EXTENDED_READER.equals(perm.getAuthority()) &&
!ExtendedWriterDynamicAuthority.EXTENDED_WRITER.equals(perm.getAuthority())) !ExtendedWriterDynamicAuthority.EXTENDED_WRITER.equals(perm.getAuthority()) &&
(perm.getPermission().equals(RMPermissionModel.FILING) || perm.getPermission().equals(RMPermissionModel.FILE_RECORDS)) &&
!origionalParentPerms.contains(perm))
{ {
if ((perm.getPermission().equals(RMPermissionModel.FILING) || // then we can assume this is a permission we want to preserve
perm.getPermission().equals(RMPermissionModel.FILE_RECORDS)) && keepPerms.add(perm);
!origionalParentPerms.contains(perm))
{
// then we can assume this is a permission we want to preserve
keepPerms.add(perm);
}
} }
} }
@@ -371,14 +368,14 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl
{ {
// break inheritance // break inheritance
permissionService.setInheritParentPermissions(nodeRef, false); permissionService.setInheritParentPermissions(nodeRef, false);
// clear all existing permissions // clear all existing permissions
permissionService.clearPermission(nodeRef, null); permissionService.clearPermission(nodeRef, null);
// set extended reader permissions // set extended reader permissions
permissionService.setPermission(nodeRef, ExtendedReaderDynamicAuthority.EXTENDED_READER, RMPermissionModel.READ_RECORDS, true); permissionService.setPermission(nodeRef, ExtendedReaderDynamicAuthority.EXTENDED_READER, RMPermissionModel.READ_RECORDS, true);
permissionService.setPermission(nodeRef, ExtendedWriterDynamicAuthority.EXTENDED_WRITER, RMPermissionModel.FILING, true); permissionService.setPermission(nodeRef, ExtendedWriterDynamicAuthority.EXTENDED_WRITER, RMPermissionModel.FILING, true);
// remove owner // remove owner
ownableService.setOwner(nodeRef, OwnableService.NO_OWNER); ownableService.setOwner(nodeRef, OwnableService.NO_OWNER);
@@ -413,7 +410,7 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl
{ {
// set read permission to the parents of the node // set read permission to the parents of the node
setReadPermissionUp(nodeRef, authority); setReadPermissionUp(nodeRef, authority);
// set the permission on the node and it's children // set the permission on the node and it's children
setPermissionDown(nodeRef, authority, permission); setPermissionDown(nodeRef, authority, permission);
} }

View File

@@ -46,12 +46,9 @@ public final class RmDictionaryWebServiceUtils
if (StringUtils.isNotBlank(siteId)) if (StringUtils.isNotBlank(siteId))
{ {
SiteInfo site = siteService.getSite(siteId); SiteInfo site = siteService.getSite(siteId);
if (site != null) if (site != null && site.getSitePreset().equals(SITE_PRESET))
{ {
if (site.getSitePreset().equals(SITE_PRESET)) isRmSite = true;
{
isRmSite = true;
}
} }
} }
return isRmSite; return isRmSite;