AnsweredAssumed Answered

Why AuthenticationUtil.runAs() ?

Question asked by mohammed.amr on Jul 25, 2011
Latest reply on Jul 25, 2011 by mrogers
Question for all,

When i'm trying to locking a node for edit its properties, the lock was throw an exception as well as there is no User Context.

To set the user context i write the following snipe of code

      AuthenticationUtil.runAs(new RunAsWork<String>(){
         public String doWork()throws Exception{
            return doProcess();
      }, AuthenticationUtil.getSystemUserName());

and in the doProcess method i put the

RetryingTransactionCallback<String> callback = new RetryingTransactionCallback<String>() {
         public String execute() throws Throwable {
                        // My Business Code

And i need to ask

- Why i need to use AuthenticationUtil.runAs() to put the user context for the locking operation ?
   - Is to gain user context, or there are another several reasons ?
- Why i need to use RetryingTransactionCallback for put my business development lines ?
  - Is for retrying the action, even if the action failed for locking as example, or there are other reasons ?
Your advise is highly appreciated.

Mohammed Amr
Senior System Developer
Digital Series Co.