mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
RM-4619 - after doing the automated conversion the record component identifier is editable
This commit is contained in:
@@ -65,7 +65,7 @@ import org.springframework.extensions.surf.util.I18NUtil;
|
||||
public class RecordComponentIdentifierAspect extends BaseBehaviourBean
|
||||
implements NodeServicePolicies.OnUpdatePropertiesPolicy,
|
||||
NodeServicePolicies.BeforeDeleteNodePolicy,
|
||||
NodeServicePolicies.OnCreateNodePolicy,
|
||||
NodeServicePolicies.OnAddAspectPolicy,
|
||||
CopyServicePolicies.OnCopyCompletePolicy
|
||||
{
|
||||
/** I18N */
|
||||
@@ -258,7 +258,7 @@ public class RecordComponentIdentifierAspect extends BaseBehaviourBean
|
||||
notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT
|
||||
)
|
||||
@Override
|
||||
public void onCreateNode(final ChildAssociationRef childAssocRef)
|
||||
public void onAddAspect(final NodeRef nodeRef, final QName aspectTypeQName)
|
||||
{
|
||||
AuthenticationUtil.runAsSystem(new RunAsWork<Object>()
|
||||
{
|
||||
@@ -268,10 +268,9 @@ public class RecordComponentIdentifierAspect extends BaseBehaviourBean
|
||||
* When creating a new record the identifier is writable to allow the upload in multiple steps.
|
||||
* On transaction commit make the identifier read only (remove the editable aspect).
|
||||
*/
|
||||
NodeRef newNode = childAssocRef.getChildRef();
|
||||
if(nodeService.exists(newNode))
|
||||
if(nodeService.exists(nodeRef))
|
||||
{
|
||||
nodeService.setProperty(newNode, RecordsManagementModel.PROP_ID_IS_TEMPORARILY_EDITABLE, false);
|
||||
nodeService.setProperty(nodeRef, RecordsManagementModel.PROP_ID_IS_TEMPORARILY_EDITABLE, false);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@@ -28,6 +28,7 @@ package org.alfresco.module.org_alfresco_module_rm.test.integration.issue;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.springframework.extensions.webscripts.GUID;
|
||||
|
||||
/**
|
||||
@@ -49,14 +50,30 @@ public class RM4619Test extends BaseRMTestCase
|
||||
*/
|
||||
public void testConvertFolderToCategory() throws Exception
|
||||
{
|
||||
/*
|
||||
* Create a folder in the unfiled record container and check it is immediately converted
|
||||
*/
|
||||
final NodeRef recordCategory = doTestInTransaction(new Test<NodeRef>()
|
||||
{
|
||||
@Override
|
||||
public NodeRef run() throws Exception
|
||||
{
|
||||
FileInfo info = fileFolderService.create(filePlan, GUID.generate(), TYPE_FOLDER);
|
||||
assertEquals(TYPE_RECORD_CATEGORY, info.getType());
|
||||
assertNotNull(info.getProperties().get(PROP_IDENTIFIER));
|
||||
return info.getNodeRef();
|
||||
}
|
||||
}, ADMIN_USER);
|
||||
|
||||
/*
|
||||
* Check that when the transaction ends the identifier is no longer editable
|
||||
*/
|
||||
doTestInTransaction(new Test<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void run() throws Exception
|
||||
{
|
||||
FileInfo info = fileFolderService.create(filePlan, GUID.generate(), TYPE_FOLDER);
|
||||
assertEquals(TYPE_RECORD_CATEGORY, info.getType());
|
||||
assertNotNull(info.getProperties().get(PROP_IDENTIFIER));
|
||||
assertFalse((Boolean)nodeService.getProperty(recordCategory, PROP_ID_IS_TEMPORARILY_EDITABLE));
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -70,14 +87,30 @@ public class RM4619Test extends BaseRMTestCase
|
||||
*/
|
||||
public void testConvertFolderToRecordFolder() throws Exception
|
||||
{
|
||||
/*
|
||||
* Create a folder in a record category and check it is immediately converted
|
||||
*/
|
||||
final NodeRef recordFolder = doTestInTransaction(new Test<NodeRef>()
|
||||
{
|
||||
@Override
|
||||
public NodeRef run() throws Exception
|
||||
{
|
||||
FileInfo info = fileFolderService.create(rmContainer, GUID.generate(), TYPE_FOLDER);
|
||||
assertEquals(TYPE_RECORD_FOLDER, info.getType());
|
||||
assertNotNull(info.getProperties().get(PROP_IDENTIFIER));
|
||||
return info.getNodeRef();
|
||||
}
|
||||
}, ADMIN_USER);
|
||||
|
||||
/*
|
||||
* Check that when the transaction ends the identifier is no longer editable
|
||||
*/
|
||||
doTestInTransaction(new Test<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void run() throws Exception
|
||||
{
|
||||
FileInfo info = fileFolderService.create(rmContainer, GUID.generate(), TYPE_FOLDER);
|
||||
assertEquals(TYPE_RECORD_FOLDER, info.getType());
|
||||
assertNotNull(info.getProperties().get(PROP_IDENTIFIER));
|
||||
assertFalse((Boolean)nodeService.getProperty(recordFolder, PROP_ID_IS_TEMPORARILY_EDITABLE));
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -94,18 +127,59 @@ public class RM4619Test extends BaseRMTestCase
|
||||
*/
|
||||
public void testConvertFolderToUnfiledRecordFolder() throws Exception
|
||||
{
|
||||
/*
|
||||
* Create a folder in the unfiled record container and check it is immediately converted
|
||||
*/
|
||||
final NodeRef folder1 = doTestInTransaction(new Test<NodeRef>()
|
||||
{
|
||||
@Override
|
||||
public NodeRef run() throws Exception
|
||||
{
|
||||
FileInfo folder = fileFolderService.create(unfiledContainer, GUID.generate(), TYPE_FOLDER);
|
||||
assertEquals(TYPE_UNFILED_RECORD_FOLDER, folder.getType());
|
||||
assertNotNull(folder.getProperties().get(PROP_IDENTIFIER));
|
||||
return folder.getNodeRef();
|
||||
}
|
||||
}, ADMIN_USER);
|
||||
|
||||
/*
|
||||
* Check that when the transaction ends the identified is no longer editable
|
||||
*/
|
||||
doTestInTransaction(new Test<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void run() throws Exception
|
||||
{
|
||||
FileInfo folder1 = fileFolderService.create(unfiledContainer, GUID.generate(), TYPE_FOLDER);
|
||||
assertEquals(TYPE_UNFILED_RECORD_FOLDER, folder1.getType());
|
||||
assertNotNull(folder1.getProperties().get(PROP_IDENTIFIER));
|
||||
assertFalse((Boolean)nodeService.getProperty(folder1, PROP_ID_IS_TEMPORARILY_EDITABLE));
|
||||
return null;
|
||||
}
|
||||
|
||||
}, ADMIN_USER);
|
||||
|
||||
FileInfo folder2 = fileFolderService.create(folder1.getNodeRef(), GUID.generate(), TYPE_FOLDER);
|
||||
assertEquals(TYPE_UNFILED_RECORD_FOLDER, folder2.getType());
|
||||
assertNotNull(folder2.getProperties().get(PROP_IDENTIFIER));
|
||||
/*
|
||||
* Create a folder in the unfiled record folder and check it is immediately converted
|
||||
*/
|
||||
final NodeRef folder2 = doTestInTransaction(new Test<NodeRef>()
|
||||
{
|
||||
@Override
|
||||
public NodeRef run() throws Exception
|
||||
{
|
||||
FileInfo folder = fileFolderService.create(folder1, GUID.generate(), TYPE_FOLDER);
|
||||
assertEquals(TYPE_UNFILED_RECORD_FOLDER, folder.getType());
|
||||
assertNotNull(folder.getProperties().get(PROP_IDENTIFIER));
|
||||
return folder.getNodeRef();
|
||||
}
|
||||
}, ADMIN_USER);
|
||||
|
||||
/*
|
||||
* Check that when the transaction ends the identified is no longer editable
|
||||
*/
|
||||
doTestInTransaction(new Test<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void run() throws Exception
|
||||
{
|
||||
assertFalse((Boolean)nodeService.getProperty(folder2, PROP_ID_IS_TEMPORARILY_EDITABLE));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user