RM-4619 - doing the conversion at first event

This commit is contained in:
Ana Bozianu
2017-01-30 14:35:23 +02:00
parent abfc606428
commit d0401ea569
4 changed files with 28 additions and 45 deletions

View File

@@ -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, ContentModel.TYPE_FOLDER);
private final static List<QName> ACCEPTED_NON_UNIQUE_CHILD_TYPES = Arrays.asList(TYPE_RECORD_CATEGORY);
private static final String BEHAVIOUR_NAME = "onDeleteFilePlan";
/** file plan service */
@@ -214,35 +214,18 @@ public class FilePlanType extends BaseBehaviourBean
@Override
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean bNew)
{
// 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. Don't check subtypes.
// Some modules use hidden files to store information (see RM-3283)
if (nodeService.getType(childAssocRef.getChildRef()).equals(ContentModel.TYPE_FOLDER))
{
nodeService.setType(childAssocRef.getChildRef(), 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);
}
/**
* 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).equals(ContentModel.TYPE_FOLDER) &&
!nodeService.hasAspect(child, ContentModel.ASPECT_HIDDEN))
{
nodeService.setType(child, TYPE_RECORD_CATEGORY);
}
}
/**
* @see org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy#onCreateNode(org.alfresco.service.cmr.repository.ChildAssociationRef)
*/

View File

@@ -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, ContentModel.TYPE_FOLDER);
private final static List<QName> ACCEPTED_NON_UNIQUE_CHILD_TYPES = Arrays.asList(TYPE_RECORD_CATEGORY, TYPE_RECORD_FOLDER);
/** vital record service */
protected VitalRecordService vitalRecordService;
@@ -112,7 +112,23 @@ public class RecordCategoryType extends BaseBehaviourBean
)
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean bNew)
{
QName childType = nodeService.getType(childAssocRef.getChildRef());
// 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. Don't check subtypes.
// Some modules use hidden folders to store information (see RM-3283).
if (childType.equals(ContentModel.TYPE_FOLDER))
{
nodeService.setType(childAssocRef.getChildRef(), TYPE_RECORD_FOLDER);
}
validateNewChildAssociation(childAssocRef.getParentRef(), childAssocRef.getChildRef(), ACCEPTED_UNIQUE_CHILD_TYPES, ACCEPTED_NON_UNIQUE_CHILD_TYPES);
if (bNew)
{
// setup the record folder
recordFolderService.setupRecordFolder(childAssocRef.getChildRef());
}
}
/**
@@ -129,7 +145,6 @@ public class RecordCategoryType extends BaseBehaviourBean
public void onCreateChildAssociationOnCommit(ChildAssociationRef childAssocRef, final boolean bNew)
{
final NodeRef child = childAssocRef.getChildRef();
final QName childType = nodeService.getType(child);
behaviourFilter.disableBehaviour();
try
@@ -139,21 +154,6 @@ 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);

View File

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

View File

@@ -123,7 +123,7 @@ public class RecordCategoryTypeUnitTest extends BaseUnitTest
try
{
recordCategoryType.onCreateChildAssociationOnCommit(childAssocRef, true);
recordCategoryType.onCreateChildAssociation(childAssocRef, true);
}
catch(IntegrityException ex)
{