Feature/rm 7103 changes from governance pr#1421 (#508)

* RM-7103: [AGS] Updating record retention schedule to a longer period fails - Run as system user when setting the disposition property on the node.

* RM-7103: [AGS] Updating record retention schedule to a longer period fails - Added test

* RM-7103: [AGS] Updating record retention schedule to a longer period fails - Removed unnecessary parentheses

* RM-7103: [AGS] Updating record retention schedule to a longer period fails - Added missing constants

* RM-7103: [AGS] Updating record retention schedule to a longer period fails - Replaced with lambda expression

Co-authored-by: Raluca Munteanu <raluca.munteanu@ness.com>
This commit is contained in:
Rodica Sutu
2021-06-02 09:29:04 +03:00
committed by GitHub
parent f6423903d7
commit 96011e4fe9
3 changed files with 111 additions and 17 deletions

View File

@@ -59,6 +59,7 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
@@ -330,18 +331,23 @@ public class DispositionServiceImpl extends ServiceBaseImpl
final String dispositionActionName = dsNextAction.getNextActionName();
final Date dispositionActionDate = dsNextAction.getNextActionDateAsOf();
// check if current transaction is a READ ONLY one and if true set the property on the node
RunAsWork<Void> runAsWork = () -> {
nodeService.setProperty(action, PROP_DISPOSITION_AS_OF, dispositionActionDate);
return null;
};
// if the current transaction is READ ONLY set the property on the node
// in a READ WRITE transaction
if (AlfrescoTransactionSupport.getTransactionReadState().equals(TxnReadState.TXN_READ_ONLY))
{
transactionService.getRetryingTransactionHelper().doInTransaction((RetryingTransactionCallback<Void>) () -> {
getInternalNodeService().setProperty(action, PROP_DISPOSITION_AS_OF, dispositionActionDate);
AuthenticationUtil.runAsSystem(runAsWork);
return null;
}, false, true);
}
else
{
getInternalNodeService().setProperty(action, PROP_DISPOSITION_AS_OF, dispositionActionDate);
AuthenticationUtil.runAsSystem(runAsWork);
}
if (dsNextAction.getWriteMode().equals(WriteMode.DATE_AND_NAME))