Skip to content

Instantly share code, notes, and snippets.

@yv84
Created April 1, 2016 02:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save yv84/b234a5f0f6c82d7ad0e094f68fe76437 to your computer and use it in GitHub Desktop.
Save yv84/b234a5f0f6c82d7ad0e094f68fe76437 to your computer and use it in GitHub Desktop.
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