среда, 2 сентября 2015 г.

Alfresco: Execute java code from another user


First of all you should implement RunAsWork interface from AuthenticationUtil. Do everything what you need in doWork method.
        AuthenticationUtil.RunAsWork&ltObject&gt raw = new AuthenticationUtil.RunAsWork&ltObject&gt() {
            public Object doWork() throws Exception {

                // do what you need

 
                return null;
            }
        };
Next you need to execute runAs method from AuthenticationUtil, where the first parameter is RunAsWork object and second parameter is username. In my case code from doWork method will be executed by System user.

        AuthenticationUtil.runAs(raw, AuthenticationUtil.getSystemUserName());

Комментариев нет :

Отправить комментарий