0

I am trying to get session parameters, e.g. user name, from a logged-in session in the Teamcenter 8 rich client using Java (and Eclipse).

public class SampleHandler extends AbstractHandler
{
    public Object execute(ExecutionEvent event) throws ExecutionException
    {
        // good, but useless
        IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
    
        // wrong
        AbstractAIFSession a = AIFUtility.getSessionManager().getDefaultSession();
    
        // wrong
        AbstractAIFUIApplication app = AIFUtility.getCurrentApplication();
        TCSession session = (TCSession)app.getSession();

        // wrong
        ISessionService iss = AifrcpPlugin.getSessionService();
        session = (TCSession)iss.getSession("com.teamcenter.rac.kernel.TCSession");

        return null;
    }
}

That snippet is taken from code that compiled, and when I run my plugin and try invoking some method in the AIFUtility class, AifrcpPlugin throws an exception.

Does anyone know how to get the user name of the current session?

std.approach
  • 51
  • 1
  • 7

1 Answers1

1

You can use AIFUtility.getCurrentApplication().getSession() to get the current session, and session.getUserName() to get the username of the currently-logged-in user.

AbstractAIFSession session = AIFUtility.getCurrentApplication().getSession();
String username = session.getUserName();
String registry = session.getRegistry();
Mohamed Iqzas
  • 976
  • 1
  • 14
  • 19