mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
get default file plan only if node is not a file plan component
This commit is contained in:
@@ -303,7 +303,7 @@ public class HoldServiceImpl extends ServiceBaseImpl
|
|||||||
if (!includedInHold)
|
if (!includedInHold)
|
||||||
{
|
{
|
||||||
// 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
|
||||||
NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
|
NodeRef filePlan = isFilePlanComponent(nodeRef) ? filePlanService.getFilePlan(nodeRef) : filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
|
||||||
List<NodeRef> allHolds = getHolds(filePlan);
|
List<NodeRef> allHolds = getHolds(filePlan);
|
||||||
result = ListUtils.subtract(allHolds, new ArrayList<>(holdsNotIncludingNodeRef));
|
result = ListUtils.subtract(allHolds, new ArrayList<>(holdsNotIncludingNodeRef));
|
||||||
}
|
}
|
||||||
@@ -575,63 +575,55 @@ public class HoldServiceImpl extends ServiceBaseImpl
|
|||||||
if (!getHeld(hold).contains(nodeRef))
|
if (!getHeld(hold).contains(nodeRef))
|
||||||
{
|
{
|
||||||
// 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(new RunAsWork<Void>()
|
authenticationUtil.runAsSystem((RunAsWork<Void>) () -> {
|
||||||
{
|
// gather freeze properties
|
||||||
@Override
|
Map<QName, Serializable> props = new HashMap<>(2);
|
||||||
public Void doWork()
|
props.put(PROP_FROZEN_AT, new Date());
|
||||||
|
props.put(PROP_FROZEN_BY, AuthenticationUtil.getFullyAuthenticatedUser());
|
||||||
|
|
||||||
|
addFrozenAspect(nodeRef, props);
|
||||||
|
|
||||||
|
// Link the record to the hold
|
||||||
|
nodeService.addChild(hold, nodeRef, ASSOC_FROZEN_RECORDS, ASSOC_FROZEN_RECORDS);
|
||||||
|
|
||||||
|
// audit item being added to the hold
|
||||||
|
recordsManagementAuditService.auditEvent(nodeRef, AUDIT_ADD_TO_HOLD);
|
||||||
|
|
||||||
|
// Mark all the folders contents as frozen
|
||||||
|
if (isRecordFolder(nodeRef))
|
||||||
{
|
{
|
||||||
// gather freeze properties
|
List<NodeRef> records = recordService.getRecords(nodeRef);
|
||||||
Map<QName, Serializable> props = new HashMap<>(2);
|
records.forEach(record -> addFrozenAspect(record, props));
|
||||||
props.put(PROP_FROZEN_AT, new Date());
|
|
||||||
props.put(PROP_FROZEN_BY, AuthenticationUtil.getFullyAuthenticatedUser());
|
|
||||||
|
|
||||||
if (!nodeService.hasAspect(nodeRef, ASPECT_FROZEN))
|
|
||||||
{
|
|
||||||
// add freeze aspect
|
|
||||||
nodeService.addAspect(nodeRef, ASPECT_FROZEN, props);
|
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
|
||||||
{
|
|
||||||
StringBuilder msg = new StringBuilder();
|
|
||||||
msg.append("Frozen aspect applied to '").append(nodeRef).append("'.");
|
|
||||||
logger.debug(msg.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Link the record to the hold
|
|
||||||
nodeService.addChild(hold, nodeRef, ASSOC_FROZEN_RECORDS, ASSOC_FROZEN_RECORDS);
|
|
||||||
|
|
||||||
// audit item being added to the hold
|
|
||||||
recordsManagementAuditService.auditEvent(nodeRef, AUDIT_ADD_TO_HOLD);
|
|
||||||
|
|
||||||
// Mark all the folders contents as frozen
|
|
||||||
if (isRecordFolder(nodeRef))
|
|
||||||
{
|
|
||||||
List<NodeRef> records = recordService.getRecords(nodeRef);
|
|
||||||
for (NodeRef record : records)
|
|
||||||
{
|
|
||||||
// no need to freeze if already frozen!
|
|
||||||
if (!nodeService.hasAspect(record, ASPECT_FROZEN))
|
|
||||||
{
|
|
||||||
nodeService.addAspect(record, ASPECT_FROZEN, props);
|
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
|
||||||
{
|
|
||||||
StringBuilder msg = new StringBuilder();
|
|
||||||
msg.append("Frozen aspect applied to '").append(record).append("'.");
|
|
||||||
logger.debug(msg.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add Frozen aspect only if node isn't already frozen
|
||||||
|
*
|
||||||
|
* @param nodeRef node on which aspect will be added
|
||||||
|
* @param props aspect properties map
|
||||||
|
*/
|
||||||
|
private void addFrozenAspect(NodeRef nodeRef, Map<QName, Serializable> props)
|
||||||
|
{
|
||||||
|
if (!nodeService.hasAspect(nodeRef, ASPECT_FROZEN))
|
||||||
|
{
|
||||||
|
// add freeze aspect
|
||||||
|
nodeService.addAspect(nodeRef, ASPECT_FROZEN, props);
|
||||||
|
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
StringBuilder msg = new StringBuilder();
|
||||||
|
msg.append("Frozen aspect applied to '").append(nodeRef).append("'.");
|
||||||
|
logger.debug(msg.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#addToHolds(java.util.List, java.util.List)
|
* @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#addToHolds(java.util.List, java.util.List)
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user