Add ASPECT_HELD_CHILDREN on active content parent

This commit is contained in:
cagache
2019-07-24 17:30:15 +03:00
parent f61992f047
commit 2aeb78b57c
4 changed files with 26 additions and 18 deletions

View File

@@ -28,6 +28,9 @@
package org.alfresco.module.org_alfresco_module_rm.freeze;
import static org.alfresco.model.ContentModel.TYPE_FOLDER;
import static org.alfresco.repo.site.SiteModel.ASPECT_SITE_CONTAINER;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
@@ -273,8 +276,9 @@ public class FreezeServiceImpl extends ServiceBaseImpl
boolean result = false;
// check that we are dealing with a record folder
if (isRecordFolder(nodeRef))
// check that we are dealing with a record folder or a collaboration folder
if (isRecordFolder(nodeRef) ||
(instanceOf(nodeRef, TYPE_FOLDER) && !nodeService.hasAspect(nodeRef, ASPECT_SITE_CONTAINER)))
{
int heldCount = 0;
@@ -303,8 +307,8 @@ public class FreezeServiceImpl extends ServiceBaseImpl
{
for (ChildAssociationRef childAssociationRef : childAssocs)
{
NodeRef record = childAssociationRef.getChildRef();
if (childAssociationRef.isPrimary() && isRecord(record) && isFrozen(record))
NodeRef childRef = childAssociationRef.getChildRef();
if (childAssociationRef.isPrimary() && isFrozen(childRef))
{
heldCount ++;
}

View File

@@ -539,19 +539,23 @@ public class HoldServiceImpl extends ServiceBaseImpl
ParameterCheck.mandatoryCollection("holds", holds);
ParameterCheck.mandatory("nodeRef", nodeRef);
String nodeName = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
if (!isRecord(nodeRef) && !isRecordFolder(nodeRef) && !instanceOf(nodeRef, ContentModel.TYPE_CONTENT))
{
String nodeName = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
// TODO error message needs to be changed
throw new AlfrescoRuntimeException("'" + nodeName + "' is neither a record nor a record folder. Only records or record folders can be added to a hold.");
throw new AlfrescoRuntimeException("'" + nodeName + "' is neither a record nor a record folder nor a document. " +
"Only records, record folders or active content can be added to a hold.");
}
if ((isRecord(nodeRef) || isRecordFolder(nodeRef)) &&
permissionService.hasPermission(nodeRef, RMPermissionModel.FILING) == AccessStatus.DENIED)
{
String nodeName = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
throw new AlfrescoRuntimeException("Filing permission on '" + nodeName + "' is needed.");
}
else if (instanceOf(nodeRef, ContentModel.TYPE_CONTENT) &&
permissionService.hasPermission(nodeRef, PermissionService.WRITE) == AccessStatus.DENIED)
{
throw new AlfrescoRuntimeException("Write permission on '" + nodeName + "' is needed.");
}
for (final NodeRef hold : holds)
{
@@ -563,7 +567,6 @@ public class HoldServiceImpl extends ServiceBaseImpl
if (permissionService.hasPermission(hold, RMPermissionModel.FILING) == AccessStatus.DENIED)
{
String nodeName = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
String holdName = (String) nodeService.getProperty(hold, ContentModel.PROP_NAME);
throw new AlfrescoRuntimeException("'" + nodeName + "' can't be added to the hold container as filing permission for '" + holdName + "' is needed.");
}

View File

@@ -27,6 +27,8 @@
package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect;
import static org.alfresco.model.ContentModel.TYPE_CONTENT;
import java.util.List;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
@@ -148,25 +150,24 @@ public class FrozenAspect extends BaseBehaviourBean
kind = BehaviourKind.CLASS,
notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT
)
public void onAddAspect(final NodeRef record, final QName aspectTypeQName)
public void onAddAspect(final NodeRef nodeRef, final QName aspectTypeQName)
{
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
{
@Override
public Void doWork()
{
if (nodeService.exists(record) &&
isRecord(record))
if (nodeService.exists(nodeRef) && (isRecord(nodeRef) || instanceOf(nodeRef, TYPE_CONTENT)))
{
// get the owning record folder
NodeRef recordFolder = nodeService.getPrimaryParent(record).getParentRef();
// get the owning nodeRef folder
NodeRef parentRef = nodeService.getPrimaryParent(nodeRef).getParentRef();
// check that the aspect has been added
if (nodeService.hasAspect(recordFolder, ASPECT_HELD_CHILDREN))
if (nodeService.hasAspect(parentRef, ASPECT_HELD_CHILDREN))
{
// increment current count
int currentCount = (Integer)nodeService.getProperty(recordFolder, PROP_HELD_CHILDREN_COUNT);
int currentCount = (Integer) nodeService.getProperty(parentRef, PROP_HELD_CHILDREN_COUNT);
currentCount = currentCount + 1;
nodeService.setProperty(recordFolder, PROP_HELD_CHILDREN_COUNT, currentCount);
nodeService.setProperty(parentRef, PROP_HELD_CHILDREN_COUNT, currentCount);
}
}
return null;