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());
|
String lovConstraintQNameAsString = newLovConstraint.toPrefixString(getNamespaceService());
|
||||||
|
|
||||||
// Add the constraint - if it isn't already there.
|
// Add the constraint - if it isn't already there (there should only be one constraint).
|
||||||
String refOfExistingConstraint = null;
|
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)
|
if (refOfExistingConstraint != null)
|
||||||
{
|
{
|
||||||
targetProp.removeConstraintRef(refOfExistingConstraint);
|
targetProp.removeConstraintRef(refOfExistingConstraint);
|
||||||
|
@@ -37,6 +37,13 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.StringTokenizer;
|
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.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||||
import org.alfresco.repo.search.SimpleResultSetMetaData;
|
import org.alfresco.repo.search.SimpleResultSetMetaData;
|
||||||
@@ -62,13 +69,6 @@ import org.apache.commons.logging.Log;
|
|||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
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
|
* RM After Invocation Provider
|
||||||
*/
|
*/
|
||||||
@@ -285,11 +285,8 @@ public class RMAfterInvocationProvider extends RMSecurityCommon
|
|||||||
{
|
{
|
||||||
for (ConfigAttributeDefintion cad : supportedDefinitions)
|
for (ConfigAttributeDefintion cad : supportedDefinitions)
|
||||||
{
|
{
|
||||||
if (cad.parent && parentResult == AccessDecisionVoter.ACCESS_DENIED)
|
if ((cad.parent && parentResult == AccessDecisionVoter.ACCESS_DENIED)
|
||||||
{
|
|| (!cad.parent && childResult == AccessDecisionVoter.ACCESS_DENIED))
|
||||||
throw new AccessDeniedException("Access Denied");
|
|
||||||
}
|
|
||||||
else if (!cad.parent && childResult == AccessDecisionVoter.ACCESS_DENIED)
|
|
||||||
{
|
{
|
||||||
throw new AccessDeniedException("Access Denied");
|
throw new AccessDeniedException("Access Denied");
|
||||||
}
|
}
|
||||||
@@ -358,11 +355,8 @@ public class RMAfterInvocationProvider extends RMSecurityCommon
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cad.parent && parentReadCheck != AccessDecisionVoter.ACCESS_GRANTED)
|
if ((cad.parent && parentReadCheck != AccessDecisionVoter.ACCESS_GRANTED)
|
||||||
{
|
|| (childReadCheck != AccessDecisionVoter.ACCESS_GRANTED))
|
||||||
throw new AccessDeniedException("Access Denied");
|
|
||||||
}
|
|
||||||
else if (childReadCheck != AccessDecisionVoter.ACCESS_GRANTED)
|
|
||||||
{
|
{
|
||||||
throw new AccessDeniedException("Access Denied");
|
throw new AccessDeniedException("Access Denied");
|
||||||
}
|
}
|
||||||
|
@@ -94,17 +94,8 @@ public class MayBeScheduledCapabilityCondition extends AbstractCapabilityConditi
|
|||||||
*/
|
*/
|
||||||
private boolean checkDispositionLevel(NodeRef nodeRef, DispositionSchedule dispositionSchedule)
|
private boolean checkDispositionLevel(NodeRef nodeRef, DispositionSchedule dispositionSchedule)
|
||||||
{
|
{
|
||||||
boolean result = false;
|
|
||||||
boolean isRecordLevelDisposition = dispositionSchedule.isRecordLevelDisposition();
|
boolean isRecordLevelDisposition = dispositionSchedule.isRecordLevelDisposition();
|
||||||
if (recordService.isRecord(nodeRef) && isRecordLevelDisposition)
|
return (recordService.isRecord(nodeRef) && isRecordLevelDisposition)
|
||||||
{
|
|| (recordFolderService.isRecordFolder(nodeRef) && !isRecordLevelDisposition);
|
||||||
result = true;
|
|
||||||
}
|
|
||||||
else if (recordFolderService.isRecordFolder(nodeRef) && !isRecordLevelDisposition)
|
|
||||||
|
|
||||||
{
|
|
||||||
result = true;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -258,25 +258,11 @@ public class DispositionProperty extends BaseBehaviourBean
|
|||||||
*/
|
*/
|
||||||
private boolean isPropertyUpdated(Map<QName, Serializable> before, Map<QName, Serializable> after)
|
private boolean isPropertyUpdated(Map<QName, Serializable> before, Map<QName, Serializable> after)
|
||||||
{
|
{
|
||||||
boolean result = false;
|
|
||||||
|
|
||||||
Serializable beforeValue = before.get(propertyName);
|
Serializable beforeValue = before.get(propertyName);
|
||||||
Serializable afterValue = after.get(propertyName);
|
Serializable afterValue = after.get(propertyName);
|
||||||
|
|
||||||
if (beforeValue == null && afterValue != null)
|
return ((beforeValue == null && afterValue != null)
|
||||||
{
|
|| (beforeValue != null && afterValue == null)
|
||||||
result = true;
|
|| (beforeValue != null && afterValue != null && !beforeValue.equals(afterValue)));
|
||||||
}
|
|
||||||
else if (beforeValue != null && afterValue == null)
|
|
||||||
{
|
|
||||||
result = true;
|
|
||||||
}
|
|
||||||
else if (beforeValue != null && afterValue != null &&
|
|
||||||
!beforeValue.equals(afterValue))
|
|
||||||
{
|
|
||||||
result = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -27,12 +27,9 @@
|
|||||||
|
|
||||||
package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
|
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.io.Serializable;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService;
|
import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||||
@@ -203,18 +200,10 @@ public class RecordFolderType extends AbstractDisposableItem
|
|||||||
@Override
|
@Override
|
||||||
public boolean getMustCopy(QName classQName, CopyDetails copyDetails)
|
public boolean getMustCopy(QName classQName, CopyDetails copyDetails)
|
||||||
{
|
{
|
||||||
boolean result = true;
|
boolean targetParentIsRecordFolder = nodeService.getType(copyDetails.getTargetParentNodeRef())
|
||||||
|
.equals(TYPE_RECORD_FOLDER);
|
||||||
if (nodeService.getType(copyDetails.getTargetParentNodeRef()).equals(TYPE_RECORD_FOLDER))
|
boolean containsUnwantedAspect = ArrayUtils.contains(unwantedAspects, classQName);
|
||||||
{
|
return !(targetParentIsRecordFolder || containsUnwantedAspect);
|
||||||
result = false;
|
|
||||||
}
|
|
||||||
else if (ArrayUtils.contains(unwantedAspects, classQName))
|
|
||||||
{
|
|
||||||
result = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -253,7 +242,7 @@ public class RecordFolderType extends AbstractDisposableItem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On transaction commit
|
* On transaction commit
|
||||||
*
|
*
|
||||||
* @see org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy#onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean)
|
* @see org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy#onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean)
|
||||||
|
Reference in New Issue
Block a user