Created
April 1, 2016 02:41
-
-
Save yv84/b234a5f0f6c82d7ad0e094f68fe76437 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var RunAsUtil = { | |
execute: function(workFunction, runAsUser) { | |
Packages.org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(new Packages.org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork() | |
{ | |
doWork: workFunction | |
}, runAsUser); | |
}, | |
doInTransaction: function(workFunction) { | |
var txs = Packages.org.springframework.web.context.ContextLoader.getCurrentWebApplicationContext().getBean("TransactionService"); | |
var th = txs.getRetryingTransactionHelper(); | |
var callback = new Packages.org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback() { | |
execute: workFunction | |
}; | |
th.doInTransaction(callback, false, true); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment