RM-4619 - add the rm search aspect when a record folder is created via conversion

This commit is contained in:
Ana Bozianu
2017-02-27 20:11:01 +02:00
parent 0b81dd90d6
commit 2e39b26c6a
2 changed files with 31 additions and 0 deletions

View File

@@ -234,6 +234,11 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
TYPE_RECORD_FOLDER, TYPE_RECORD_FOLDER,
new JavaBehaviour(this, "recordFolderCreate", NotificationFrequency.TRANSACTION_COMMIT)); new JavaBehaviour(this, "recordFolderCreate", NotificationFrequency.TRANSACTION_COMMIT));
this.policyComponent.bindClassBehaviour(
QName.createQName(NamespaceService.ALFRESCO_URI, "onSetNodeType"),
TYPE_RECORD_FOLDER,
new JavaBehaviour(this, "convertedToOrFromRecordFolder", NotificationFrequency.TRANSACTION_COMMIT));
// Vital Records Review Details Rollup // Vital Records Review Details Rollup
this.policyComponent.bindClassBehaviour( this.policyComponent.bindClassBehaviour(
QName.createQName(NamespaceService.ALFRESCO_URI, "onAddAspect"), QName.createQName(NamespaceService.ALFRESCO_URI, "onAddAspect"),
@@ -428,6 +433,30 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
}); });
} }
/**
* On update type to or from record folder behaviour implmentation
* @param nodeRef the updated node
* @param oldType the type the node had before update
* @param newType the type the node has after update
*/
public void convertedToOrFromRecordFolder(NodeRef nodeRef, QName oldType, QName newType)
{
AuthenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork<Void>()
{
@Override
public Void doWork() throws Exception
{
// If the node has been updated to a record folder
if (newType.equals(TYPE_RECORD_FOLDER) && nodeService.exists(nodeRef))
{
applySearchAspect(nodeRef);
setupDispositionScheduleProperties(nodeRef);
}
return null;
}
});
}
/** /**
* Helper method to setup the disposition schedule properties * Helper method to setup the disposition schedule properties
* *

View File

@@ -104,6 +104,7 @@ public class RM4619Test extends BaseRMTestCase
/* /*
* Check that when the transaction ends the identifier is no longer editable * Check that when the transaction ends the identifier is no longer editable
* And the record folder has the ASPECT_RM_SEARCH aspect
*/ */
doTestInTransaction(new Test<Void>() doTestInTransaction(new Test<Void>()
{ {
@@ -111,6 +112,7 @@ public class RM4619Test extends BaseRMTestCase
public Void run() throws Exception public Void run() throws Exception
{ {
assertFalse((Boolean)nodeService.getProperty(recordFolder, PROP_ID_IS_TEMPORARILY_EDITABLE)); assertFalse((Boolean)nodeService.getProperty(recordFolder, PROP_ID_IS_TEMPORARILY_EDITABLE));
assertTrue(nodeService.hasAspect(recordFolder, ASPECT_RM_SEARCH));
return null; return null;
} }