mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Fix some issues raised by Sonar.
Avoid NPE if calculateListOfEmptyFolders returns null in ScheduleXRecordLoaders. Fix equals method of a few classes to check against the other instance. Make synchonisation consistent in AppliedSourceServiceImpl and also remove a redundant null check. Use Arrays.toString to make a more readable string representation of an array. Combine a few if statement branches that do the same thing.
This commit is contained in:
@@ -876,15 +876,11 @@ public class RecordsManagementAdminServiceImpl extends RecordsManagementAdminBas
|
||||
}
|
||||
String lovConstraintQNameAsString = newLovConstraint.toPrefixString(getNamespaceService());
|
||||
|
||||
// Add the constraint - if it isn't already there.
|
||||
String refOfExistingConstraint = null;
|
||||
// Add the constraint - if it isn't already there (there should only be one constraint).
|
||||
String refOfExistingConstraint = (targetProp.getConstraints().isEmpty() ?
|
||||
null :
|
||||
targetProp.getConstraints().get(0).getRef());
|
||||
|
||||
for (M2Constraint c : targetProp.getConstraints())
|
||||
{
|
||||
// There should only be one constraint.
|
||||
refOfExistingConstraint = c.getRef();
|
||||
break;
|
||||
}
|
||||
if (refOfExistingConstraint != null)
|
||||
{
|
||||
targetProp.removeConstraintRef(refOfExistingConstraint);
|
||||
|
@@ -37,6 +37,13 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import net.sf.acegisecurity.AccessDeniedException;
|
||||
import net.sf.acegisecurity.Authentication;
|
||||
import net.sf.acegisecurity.ConfigAttribute;
|
||||
import net.sf.acegisecurity.ConfigAttributeDefinition;
|
||||
import net.sf.acegisecurity.afterinvocation.AfterInvocationProvider;
|
||||
import net.sf.acegisecurity.vote.AccessDecisionVoter;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.repo.search.SimpleResultSetMetaData;
|
||||
@@ -62,13 +69,6 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
import net.sf.acegisecurity.AccessDeniedException;
|
||||
import net.sf.acegisecurity.Authentication;
|
||||
import net.sf.acegisecurity.ConfigAttribute;
|
||||
import net.sf.acegisecurity.ConfigAttributeDefinition;
|
||||
import net.sf.acegisecurity.afterinvocation.AfterInvocationProvider;
|
||||
import net.sf.acegisecurity.vote.AccessDecisionVoter;
|
||||
|
||||
/**
|
||||
* RM After Invocation Provider
|
||||
*/
|
||||
@@ -285,11 +285,8 @@ public class RMAfterInvocationProvider extends RMSecurityCommon
|
||||
{
|
||||
for (ConfigAttributeDefintion cad : supportedDefinitions)
|
||||
{
|
||||
if (cad.parent && parentResult == AccessDecisionVoter.ACCESS_DENIED)
|
||||
{
|
||||
throw new AccessDeniedException("Access Denied");
|
||||
}
|
||||
else if (!cad.parent && childResult == AccessDecisionVoter.ACCESS_DENIED)
|
||||
if ((cad.parent && parentResult == AccessDecisionVoter.ACCESS_DENIED)
|
||||
|| (!cad.parent && childResult == AccessDecisionVoter.ACCESS_DENIED))
|
||||
{
|
||||
throw new AccessDeniedException("Access Denied");
|
||||
}
|
||||
@@ -358,11 +355,8 @@ public class RMAfterInvocationProvider extends RMSecurityCommon
|
||||
continue;
|
||||
}
|
||||
|
||||
if (cad.parent && parentReadCheck != AccessDecisionVoter.ACCESS_GRANTED)
|
||||
{
|
||||
throw new AccessDeniedException("Access Denied");
|
||||
}
|
||||
else if (childReadCheck != AccessDecisionVoter.ACCESS_GRANTED)
|
||||
if ((cad.parent && parentReadCheck != AccessDecisionVoter.ACCESS_GRANTED)
|
||||
|| (childReadCheck != AccessDecisionVoter.ACCESS_GRANTED))
|
||||
{
|
||||
throw new AccessDeniedException("Access Denied");
|
||||
}
|
||||
|
@@ -94,17 +94,8 @@ public class MayBeScheduledCapabilityCondition extends AbstractCapabilityConditi
|
||||
*/
|
||||
private boolean checkDispositionLevel(NodeRef nodeRef, DispositionSchedule dispositionSchedule)
|
||||
{
|
||||
boolean result = false;
|
||||
boolean isRecordLevelDisposition = dispositionSchedule.isRecordLevelDisposition();
|
||||
if (recordService.isRecord(nodeRef) && isRecordLevelDisposition)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
else if (recordFolderService.isRecordFolder(nodeRef) && !isRecordLevelDisposition)
|
||||
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
return (recordService.isRecord(nodeRef) && isRecordLevelDisposition)
|
||||
|| (recordFolderService.isRecordFolder(nodeRef) && !isRecordLevelDisposition);
|
||||
}
|
||||
}
|
||||
|
@@ -258,25 +258,11 @@ public class DispositionProperty extends BaseBehaviourBean
|
||||
*/
|
||||
private boolean isPropertyUpdated(Map<QName, Serializable> before, Map<QName, Serializable> after)
|
||||
{
|
||||
boolean result = false;
|
||||
|
||||
Serializable beforeValue = before.get(propertyName);
|
||||
Serializable afterValue = after.get(propertyName);
|
||||
|
||||
if (beforeValue == null && afterValue != null)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
else if (beforeValue != null && afterValue == null)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
else if (beforeValue != null && afterValue != null &&
|
||||
!beforeValue.equals(afterValue))
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
return ((beforeValue == null && afterValue != null)
|
||||
|| (beforeValue != null && afterValue == null)
|
||||
|| (beforeValue != null && afterValue != null && !beforeValue.equals(afterValue)));
|
||||
}
|
||||
}
|
||||
|
@@ -27,12 +27,9 @@
|
||||
|
||||
package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
|
||||
|
||||
import static org.alfresco.module.org_alfresco_module_rm.record.RecordUtils.generateRecordIdentifier;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
@@ -203,18 +200,10 @@ public class RecordFolderType extends AbstractDisposableItem
|
||||
@Override
|
||||
public boolean getMustCopy(QName classQName, CopyDetails copyDetails)
|
||||
{
|
||||
boolean result = true;
|
||||
|
||||
if (nodeService.getType(copyDetails.getTargetParentNodeRef()).equals(TYPE_RECORD_FOLDER))
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
else if (ArrayUtils.contains(unwantedAspects, classQName))
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
boolean targetParentIsRecordFolder = nodeService.getType(copyDetails.getTargetParentNodeRef())
|
||||
.equals(TYPE_RECORD_FOLDER);
|
||||
boolean containsUnwantedAspect = ArrayUtils.contains(unwantedAspects, classQName);
|
||||
return !(targetParentIsRecordFolder || containsUnwantedAspect);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user