mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-4619 - added cm:folder as accepted type and do the conversion onCommit - request doesn't have full info
This commit is contained in:
@@ -67,7 +67,7 @@ public class FilePlanType extends BaseBehaviourBean
|
||||
NodeServicePolicies.BeforeDeleteNodePolicy
|
||||
{
|
||||
private final static List<QName> ACCEPTED_UNIQUE_CHILD_TYPES = Arrays.asList(TYPE_HOLD_CONTAINER, TYPE_TRANSFER_CONTAINER, TYPE_UNFILED_RECORD_CONTAINER);
|
||||
private final static List<QName> ACCEPTED_NON_UNIQUE_CHILD_TYPES = Arrays.asList(TYPE_RECORD_CATEGORY);
|
||||
private final static List<QName> ACCEPTED_NON_UNIQUE_CHILD_TYPES = Arrays.asList(TYPE_RECORD_CATEGORY, ContentModel.TYPE_FOLDER);
|
||||
private static final String BEHAVIOUR_NAME = "onDeleteFilePlan";
|
||||
|
||||
/** file plan service */
|
||||
@@ -209,25 +209,38 @@ public class FilePlanType extends BaseBehaviourBean
|
||||
*/
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.ASSOCIATION,
|
||||
notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT
|
||||
kind = BehaviourKind.ASSOCIATION
|
||||
)
|
||||
@Override
|
||||
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean bNew)
|
||||
{
|
||||
// check the created child is of an accepted type
|
||||
validateNewChildAssociation(childAssocRef.getParentRef(), childAssocRef.getChildRef(), ACCEPTED_UNIQUE_CHILD_TYPES, ACCEPTED_NON_UNIQUE_CHILD_TYPES);
|
||||
}
|
||||
|
||||
/**
|
||||
* On transaction commit
|
||||
*
|
||||
* @see org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy#onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean)
|
||||
*/
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.ASSOCIATION,
|
||||
policy = "alf:onCreateChildAssociation",
|
||||
notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT
|
||||
)
|
||||
public void onCreateChildAssociationOnCommit(ChildAssociationRef childAssocRef, boolean bNew)
|
||||
{
|
||||
NodeRef child = childAssocRef.getChildRef();
|
||||
|
||||
// We need to automatically cast the created folder to category if it is a plain folder
|
||||
// This occurs if the RM folder has been created via IMap, WebDav, etc
|
||||
// Ignore hidden files. Some modules use hidden files to store information (see RM-3283)
|
||||
if (nodeService.getType(child) == ContentModel.TYPE_FOLDER &&
|
||||
if (nodeService.getType(child).equals(ContentModel.TYPE_FOLDER) &&
|
||||
!nodeService.hasAspect(child, ContentModel.ASPECT_HIDDEN))
|
||||
{
|
||||
nodeService.setType(child, TYPE_RECORD_CATEGORY);
|
||||
}
|
||||
|
||||
// check the created child is of an accepted type
|
||||
validateNewChildAssociation(childAssocRef.getParentRef(), childAssocRef.getChildRef(), ACCEPTED_UNIQUE_CHILD_TYPES, ACCEPTED_NON_UNIQUE_CHILD_TYPES);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -65,7 +65,7 @@ public class RecordCategoryType extends BaseBehaviourBean
|
||||
NodeServicePolicies.OnCreateNodePolicy
|
||||
{
|
||||
private final static List<QName> ACCEPTED_UNIQUE_CHILD_TYPES = new ArrayList<QName>();
|
||||
private final static List<QName> ACCEPTED_NON_UNIQUE_CHILD_TYPES = Arrays.asList(TYPE_RECORD_CATEGORY, TYPE_RECORD_FOLDER);
|
||||
private final static List<QName> ACCEPTED_NON_UNIQUE_CHILD_TYPES = Arrays.asList(TYPE_RECORD_CATEGORY, TYPE_RECORD_FOLDER, ContentModel.TYPE_FOLDER);
|
||||
|
||||
/** vital record service */
|
||||
protected VitalRecordService vitalRecordService;
|
||||
@@ -112,16 +112,7 @@ public class RecordCategoryType extends BaseBehaviourBean
|
||||
)
|
||||
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean bNew)
|
||||
{
|
||||
NodeRef child = childAssocRef.getChildRef();
|
||||
NodeRef parentRef = childAssocRef.getParentRef();
|
||||
|
||||
if (bNew)
|
||||
{
|
||||
// setup the record folder
|
||||
recordFolderService.setupRecordFolder(child);
|
||||
}
|
||||
|
||||
validateNewChildAssociation(parentRef, child, ACCEPTED_UNIQUE_CHILD_TYPES, ACCEPTED_NON_UNIQUE_CHILD_TYPES);
|
||||
validateNewChildAssociation(childAssocRef.getParentRef(), childAssocRef.getChildRef(), ACCEPTED_UNIQUE_CHILD_TYPES, ACCEPTED_NON_UNIQUE_CHILD_TYPES);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -135,19 +126,10 @@ public class RecordCategoryType extends BaseBehaviourBean
|
||||
policy = "alf:onCreateChildAssociation",
|
||||
notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT
|
||||
)
|
||||
public void onCreateChildAssociationOnCommit(ChildAssociationRef childAssocRef, boolean bNew)
|
||||
public void onCreateChildAssociationOnCommit(ChildAssociationRef childAssocRef, final boolean bNew)
|
||||
{
|
||||
final NodeRef child = childAssocRef.getChildRef();
|
||||
QName childType = nodeService.getType(child);
|
||||
|
||||
// We need to automatically cast the created folder to record folder if it is a plain folder
|
||||
// This occurs if the RM folder has been created via IMap, WebDav, etc
|
||||
// Ignore hidden files. Some modules use hidden files to store information (see RM-3283)
|
||||
if ( childType == ContentModel.TYPE_FOLDER &&
|
||||
!nodeService.hasAspect(child, ContentModel.ASPECT_HIDDEN))
|
||||
{
|
||||
nodeService.setType(child, TYPE_RECORD_FOLDER);
|
||||
}
|
||||
final QName childType = nodeService.getType(child);
|
||||
|
||||
behaviourFilter.disableBehaviour();
|
||||
try
|
||||
@@ -157,6 +139,21 @@ public class RecordCategoryType extends BaseBehaviourBean
|
||||
@Override
|
||||
public Void doWork()
|
||||
{
|
||||
// We need to automatically cast the created folder to record folder if it is a plain folder
|
||||
// This occurs if the RM folder has been created via IMap, WebDav, etc
|
||||
// Ignore hidden files. Some modules use hidden files to store information (see RM-3283)
|
||||
if ( childType.equals(ContentModel.TYPE_FOLDER) &&
|
||||
!nodeService.hasAspect(child, ContentModel.ASPECT_HIDDEN))
|
||||
{
|
||||
nodeService.setType(child, TYPE_RECORD_FOLDER);
|
||||
}
|
||||
|
||||
if (bNew)
|
||||
{
|
||||
// setup the record folder
|
||||
recordFolderService.setupRecordFolder(child);
|
||||
}
|
||||
|
||||
// setup vital record definition
|
||||
vitalRecordService.setupVitalRecordDefinition(child);
|
||||
|
||||
|
@@ -138,14 +138,7 @@ public class RMNodesImpl extends NodesImpl implements RMNodes
|
||||
|
||||
if (type == null)
|
||||
{
|
||||
if (filePlanService.isFilePlanComponent(nodeRef))
|
||||
{
|
||||
node = new FileplanComponentNode(originalNode);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidParameterException("The provided node is not a fileplan component");
|
||||
}
|
||||
node = new FileplanComponentNode(originalNode);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -195,7 +195,7 @@ public class FilePlanTypeUnitTest extends BaseUnitTest
|
||||
|
||||
try
|
||||
{
|
||||
filePlanType.onCreateChildAssociation(childAssocRef, true);
|
||||
filePlanType.onCreateChildAssociationOnCommit(childAssocRef, true);
|
||||
}
|
||||
catch(IntegrityException ex)
|
||||
{
|
||||
|
Reference in New Issue
Block a user