RM-4619 - added cm:folder as accepted type and do the conversion onCommit - request doesn't have full info

This commit is contained in:
Ana Bozianu
2017-01-30 12:05:48 +02:00
parent 444218a539
commit c52e2a7cf5
4 changed files with 41 additions and 38 deletions

View File

@@ -67,7 +67,7 @@ public class FilePlanType extends BaseBehaviourBean
NodeServicePolicies.BeforeDeleteNodePolicy 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_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"; private static final String BEHAVIOUR_NAME = "onDeleteFilePlan";
/** file plan service */ /** file plan service */
@@ -209,25 +209,38 @@ public class FilePlanType extends BaseBehaviourBean
*/ */
@Behaviour @Behaviour
( (
kind = BehaviourKind.ASSOCIATION, kind = BehaviourKind.ASSOCIATION
notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT
) )
@Override @Override
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean bNew) 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(); NodeRef child = childAssocRef.getChildRef();
// We need to automatically cast the created folder to category if it is a plain folder // 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 // 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) // 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.hasAspect(child, ContentModel.ASPECT_HIDDEN))
{ {
nodeService.setType(child, TYPE_RECORD_CATEGORY); 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);
} }
/** /**

View File

@@ -65,7 +65,7 @@ public class RecordCategoryType extends BaseBehaviourBean
NodeServicePolicies.OnCreateNodePolicy NodeServicePolicies.OnCreateNodePolicy
{ {
private final static List<QName> ACCEPTED_UNIQUE_CHILD_TYPES = new ArrayList<QName>(); 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 */ /** vital record service */
protected VitalRecordService vitalRecordService; protected VitalRecordService vitalRecordService;
@@ -112,16 +112,7 @@ public class RecordCategoryType extends BaseBehaviourBean
) )
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean bNew) public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean bNew)
{ {
NodeRef child = childAssocRef.getChildRef(); validateNewChildAssociation(childAssocRef.getParentRef(), childAssocRef.getChildRef(), ACCEPTED_UNIQUE_CHILD_TYPES, ACCEPTED_NON_UNIQUE_CHILD_TYPES);
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);
} }
/** /**
@@ -135,19 +126,10 @@ public class RecordCategoryType extends BaseBehaviourBean
policy = "alf:onCreateChildAssociation", policy = "alf:onCreateChildAssociation",
notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT
) )
public void onCreateChildAssociationOnCommit(ChildAssociationRef childAssocRef, boolean bNew) public void onCreateChildAssociationOnCommit(ChildAssociationRef childAssocRef, final boolean bNew)
{ {
final NodeRef child = childAssocRef.getChildRef(); final NodeRef child = childAssocRef.getChildRef();
QName childType = nodeService.getType(child); final 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);
}
behaviourFilter.disableBehaviour(); behaviourFilter.disableBehaviour();
try try
@@ -157,6 +139,21 @@ public class RecordCategoryType extends BaseBehaviourBean
@Override @Override
public Void doWork() 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 // setup vital record definition
vitalRecordService.setupVitalRecordDefinition(child); vitalRecordService.setupVitalRecordDefinition(child);

View File

@@ -138,14 +138,7 @@ public class RMNodesImpl extends NodesImpl implements RMNodes
if (type == null) if (type == null)
{ {
if (filePlanService.isFilePlanComponent(nodeRef)) node = new FileplanComponentNode(originalNode);
{
node = new FileplanComponentNode(originalNode);
}
else
{
throw new InvalidParameterException("The provided node is not a fileplan component");
}
} }
else else
{ {

View File

@@ -195,7 +195,7 @@ public class FilePlanTypeUnitTest extends BaseUnitTest
try try
{ {
filePlanType.onCreateChildAssociation(childAssocRef, true); filePlanType.onCreateChildAssociationOnCommit(childAssocRef, true);
} }
catch(IntegrityException ex) catch(IntegrityException ex)
{ {