Skip to content

Instantly share code, notes, and snippets.

@douglascrp
Forked from yv84/runas.js
Created February 6, 2019 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save douglascrp/43162ec2f1224fc60198b0842034d185 to your computer and use it in GitHub Desktop.
Save douglascrp/43162ec2f1224fc60198b0842034d185 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