mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-4681 Add behaviours to restrict where rm items can be created.
Record categories can only go in the file plan, or under other record categories. Record folders can only have categories as a primary parent, and holds or transfers as secondary parents.
This commit is contained in:
@@ -178,13 +178,18 @@ public class RecordCategoryType extends BaseBehaviourBean
|
|||||||
@Override
|
@Override
|
||||||
public Void doWork()
|
public Void doWork()
|
||||||
{
|
{
|
||||||
|
// Check the parent is either a file plan or a category.
|
||||||
|
if (!isFilePlan(childAssocRef.getParentRef()) && !isRecordCategory(childAssocRef.getParentRef()))
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("Operation failed: Record categories must go under file plans or categories.");
|
||||||
|
}
|
||||||
|
|
||||||
// setup record category permissions
|
// setup record category permissions
|
||||||
filePlanPermissionService.setupRecordCategoryPermissions(childAssocRef.getChildRef());
|
filePlanPermissionService.setupRecordCategoryPermissions(childAssocRef.getChildRef());
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -64,6 +64,7 @@ import org.springframework.extensions.surf.util.I18NUtil;
|
|||||||
)
|
)
|
||||||
public class RecordFolderType extends AbstractDisposableItem
|
public class RecordFolderType extends AbstractDisposableItem
|
||||||
implements NodeServicePolicies.OnMoveNodePolicy,
|
implements NodeServicePolicies.OnMoveNodePolicy,
|
||||||
|
NodeServicePolicies.OnCreateNodePolicy,
|
||||||
NodeServicePolicies.OnCreateChildAssociationPolicy
|
NodeServicePolicies.OnCreateChildAssociationPolicy
|
||||||
{
|
{
|
||||||
/** record service */
|
/** record service */
|
||||||
@@ -123,6 +124,7 @@ public class RecordFolderType extends AbstractDisposableItem
|
|||||||
|
|
||||||
AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Object>()
|
AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Object>()
|
||||||
{
|
{
|
||||||
|
@Override
|
||||||
public Object doWork()
|
public Object doWork()
|
||||||
{
|
{
|
||||||
// clean record folder
|
// clean record folder
|
||||||
@@ -270,4 +272,40 @@ public class RecordFolderType extends AbstractDisposableItem
|
|||||||
behaviourFilter.enableBehaviour();
|
behaviourFilter.enableBehaviour();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** {@inheritDoc}} */
|
||||||
|
@Override
|
||||||
|
@Behaviour
|
||||||
|
(
|
||||||
|
kind = BehaviourKind.CLASS,
|
||||||
|
notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT
|
||||||
|
)
|
||||||
|
public void onCreateNode(final ChildAssociationRef childAssocRef)
|
||||||
|
{
|
||||||
|
// execute behaviour code as system user
|
||||||
|
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public Void doWork()
|
||||||
|
{
|
||||||
|
if (childAssocRef.isPrimary())
|
||||||
|
{
|
||||||
|
// Check the primary parent is a category.
|
||||||
|
if (!isRecordFolder(childAssocRef.getParentRef()))
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("Operation failed: Record folders must go under categories.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Check the secondary parent is a hold or transfer.
|
||||||
|
if (!isHold(childAssocRef.getParentRef()) && !isTransfer(childAssocRef.getParentRef()))
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("Operation failed: Record folders can only have secondary parents of holds or transfers.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user