mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
fix sonar issues
This commit is contained in:
@@ -294,13 +294,13 @@ public class HoldServiceImpl extends ServiceBaseImpl
|
|||||||
List<NodeRef> result = new ArrayList<>();
|
List<NodeRef> result = new ArrayList<>();
|
||||||
|
|
||||||
// get all the immediate parent holds
|
// get all the immediate parent holds
|
||||||
Set<NodeRef> holdsIncludingNodeRef = getParentHolds(nodeRef);
|
final Set<NodeRef> holdsIncludingNodeRef = getParentHolds(nodeRef);
|
||||||
|
|
||||||
// check whether the record is held by virtue of it's record folder
|
// check whether the record is held by virtue of it's record folder
|
||||||
if (isRecord(nodeRef))
|
if (isRecord(nodeRef))
|
||||||
{
|
{
|
||||||
final List<NodeRef> recordFolders = recordFolderService.getRecordFolders(nodeRef);
|
final List<NodeRef> recordFolders = recordFolderService.getRecordFolders(nodeRef);
|
||||||
for (NodeRef recordFolder : recordFolders)
|
for (final NodeRef recordFolder : recordFolders)
|
||||||
{
|
{
|
||||||
holdsIncludingNodeRef.addAll(getParentHolds(recordFolder));
|
holdsIncludingNodeRef.addAll(getParentHolds(recordFolder));
|
||||||
}
|
}
|
||||||
@@ -311,11 +311,11 @@ public class HoldServiceImpl extends ServiceBaseImpl
|
|||||||
final Set<NodeRef> filePlans = filePlanService.getFilePlans();
|
final Set<NodeRef> filePlans = filePlanService.getFilePlans();
|
||||||
if (!CollectionUtils.isEmpty(filePlans))
|
if (!CollectionUtils.isEmpty(filePlans))
|
||||||
{
|
{
|
||||||
List<NodeRef> holdsNotIncludingNodeRef = new ArrayList<>();
|
final List<NodeRef> holdsNotIncludingNodeRef = new ArrayList<>();
|
||||||
filePlans.forEach(filePlan ->
|
filePlans.forEach(filePlan ->
|
||||||
{
|
{
|
||||||
// invert list to get list of holds that do not contain this node
|
// invert list to get list of holds that do not contain this node
|
||||||
List<NodeRef> allHolds = getHolds(filePlan);
|
final List<NodeRef> allHolds = getHolds(filePlan);
|
||||||
holdsNotIncludingNodeRef.addAll(ListUtils.subtract(allHolds, new ArrayList<>(holdsIncludingNodeRef)));
|
holdsNotIncludingNodeRef.addAll(ListUtils.subtract(allHolds, new ArrayList<>(holdsIncludingNodeRef)));
|
||||||
});
|
});
|
||||||
result = holdsNotIncludingNodeRef;
|
result = holdsNotIncludingNodeRef;
|
||||||
@@ -559,7 +559,7 @@ public class HoldServiceImpl extends ServiceBaseImpl
|
|||||||
{
|
{
|
||||||
if (!isHold(hold))
|
if (!isHold(hold))
|
||||||
{
|
{
|
||||||
String holdName = (String) nodeService.getProperty(hold, ContentModel.PROP_NAME);
|
final String holdName = (String) nodeService.getProperty(hold, ContentModel.PROP_NAME);
|
||||||
throw new IntegrityException(I18NUtil.getMessage("rm.hold.not-hold", holdName), null);
|
throw new IntegrityException(I18NUtil.getMessage("rm.hold.not-hold", holdName), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -574,7 +574,7 @@ public class HoldServiceImpl extends ServiceBaseImpl
|
|||||||
// run as system to ensure we have all the appropriate permissions to perform the manipulations we require
|
// run as system to ensure we have all the appropriate permissions to perform the manipulations we require
|
||||||
authenticationUtil.runAsSystem((RunAsWork<Void>) () -> {
|
authenticationUtil.runAsSystem((RunAsWork<Void>) () -> {
|
||||||
// gather freeze properties
|
// gather freeze properties
|
||||||
Map<QName, Serializable> props = new HashMap<>(2);
|
final Map<QName, Serializable> props = new HashMap<>(2);
|
||||||
props.put(PROP_FROZEN_AT, new Date());
|
props.put(PROP_FROZEN_AT, new Date());
|
||||||
props.put(PROP_FROZEN_BY, AuthenticationUtil.getFullyAuthenticatedUser());
|
props.put(PROP_FROZEN_BY, AuthenticationUtil.getFullyAuthenticatedUser());
|
||||||
|
|
||||||
@@ -589,7 +589,7 @@ public class HoldServiceImpl extends ServiceBaseImpl
|
|||||||
// Mark all the folders contents as frozen
|
// Mark all the folders contents as frozen
|
||||||
if (isRecordFolder(nodeRef))
|
if (isRecordFolder(nodeRef))
|
||||||
{
|
{
|
||||||
List<NodeRef> records = recordService.getRecords(nodeRef);
|
final List<NodeRef> records = recordService.getRecords(nodeRef);
|
||||||
records.forEach(record -> addFrozenAspect(record, props));
|
records.forEach(record -> addFrozenAspect(record, props));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -608,7 +608,7 @@ public class HoldServiceImpl extends ServiceBaseImpl
|
|||||||
{
|
{
|
||||||
if (!isRecord(nodeRef) && !isRecordFolder(nodeRef) && !instanceOf(nodeRef, ContentModel.TYPE_CONTENT))
|
if (!isRecord(nodeRef) && !isRecordFolder(nodeRef) && !instanceOf(nodeRef, ContentModel.TYPE_CONTENT))
|
||||||
{
|
{
|
||||||
String nodeName = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
final String nodeName = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
||||||
throw new IntegrityException(I18NUtil.getMessage("rm.hold.add-to-hold-invalid-type", nodeName), null);
|
throw new IntegrityException(I18NUtil.getMessage("rm.hold.add-to-hold-invalid-type", nodeName), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -157,11 +157,7 @@ public class FrozenAspect extends BaseBehaviourBean
|
|||||||
)
|
)
|
||||||
public void onAddAspect(final NodeRef nodeRef, final QName aspectTypeQName)
|
public void onAddAspect(final NodeRef nodeRef, final QName aspectTypeQName)
|
||||||
{
|
{
|
||||||
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
|
AuthenticationUtil.runAsSystem((RunAsWork<Void>) () -> {
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public Void doWork()
|
|
||||||
{
|
|
||||||
if (nodeService.exists(nodeRef) && (isRecord(nodeRef) || instanceOf(nodeRef, TYPE_CONTENT)))
|
if (nodeService.exists(nodeRef) && (isRecord(nodeRef) || instanceOf(nodeRef, TYPE_CONTENT)))
|
||||||
{
|
{
|
||||||
// get the owning folder
|
// get the owning folder
|
||||||
@@ -173,20 +169,18 @@ public class FrozenAspect extends BaseBehaviourBean
|
|||||||
int currentCount = (Integer) nodeService.getProperty(parentRef, PROP_HELD_CHILDREN_COUNT);
|
int currentCount = (Integer) nodeService.getProperty(parentRef, PROP_HELD_CHILDREN_COUNT);
|
||||||
currentCount = currentCount + 1;
|
currentCount = currentCount + 1;
|
||||||
nodeService.setProperty(parentRef, PROP_HELD_CHILDREN_COUNT, currentCount);
|
nodeService.setProperty(parentRef, PROP_HELD_CHILDREN_COUNT, currentCount);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if (instanceOf(parentRef, TYPE_FOLDER) && !nodeService.hasAspect(parentRef, ASPECT_SITE_CONTAINER))
|
if (instanceOf(parentRef, TYPE_FOLDER) && !nodeService.hasAspect(parentRef, ASPECT_SITE_CONTAINER))
|
||||||
{
|
{
|
||||||
// add aspect and set count to 1
|
// add aspect and set count to 1
|
||||||
Map<QName, Serializable> props = new HashMap<>(1);
|
final Map<QName, Serializable> props = new HashMap<>(1);
|
||||||
props.put(PROP_HELD_CHILDREN_COUNT, 1);
|
props.put(PROP_HELD_CHILDREN_COUNT, 1);
|
||||||
getInternalNodeService().addAspect(parentRef, ASPECT_HELD_CHILDREN, props);
|
getInternalNodeService().addAspect(parentRef, ASPECT_HELD_CHILDREN, props);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user