Search in sources :

Example 1 with KeepAliveTimer

use of org.netxms.ui.eclipse.console.KeepAliveTimer in project netxms by netxms.

the class LoginJob method run.

/*
    * (non-Javadoc)
    * 
    * @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor)
    */
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    monitor.beginTask(Messages.get(display).LoginJob_connecting, 100);
    try {
        final String hostName;
        int port = NXCSession.DEFAULT_CONN_PORT;
        // $NON-NLS-1$
        final String[] split = server.split(":");
        if (split.length == 2) {
            hostName = split[0];
            try {
                port = Integer.valueOf(split[1]);
            } catch (NumberFormatException e) {
            // ignore
            }
        } else {
            hostName = server;
        }
        final NXCSession session = createSession(hostName, port);
        session.setClientLanguage(language);
        // $NON-NLS-1$
        session.setClientInfo("nxweb/" + NXCommon.VERSION);
        session.setIgnoreProtocolVersion(ignoreProtocolVersion);
        session.setClientType(NXCSession.WEB_CLIENT);
        session.setClientAddress(clientAddress);
        monitor.worked(10);
        session.connect(new int[] { ProtocolVersion.INDEX_FULL });
        session.login(authMethod, (loginName != null) ? loginName : "?", password, certificate, signature);
        monitor.worked(40);
        monitor.setTaskName(Messages.get(display).LoginJob_sync_objects);
        session.syncObjects();
        monitor.worked(25);
        monitor.setTaskName(Messages.get(display).LoginJob_sync_users);
        session.syncUserDatabase();
        monitor.worked(5);
        monitor.setTaskName(Messages.get(display).LoginJob_sync_event_db);
        try {
            session.syncEventObjects();
        } catch (NXCException e) {
            if (e.getErrorCode() != RCC.ACCESS_DENIED)
                throw e;
        }
        try {
            session.syncAlarmCategories();
        } catch (NXCException e) {
            if (e.getErrorCode() != RCC.ACCESS_DENIED)
                throw e;
        }
        monitor.worked(5);
        monitor.setTaskName(Messages.get(display).LoginJob_subscribe);
        session.subscribe(NXCSession.CHANNEL_ALARMS);
        monitor.worked(5);
        RWT.getUISession(display).setAttribute(ConsoleSharedData.ATTRIBUTE_SESSION, session);
        display.syncExec(new Runnable() {

            @Override
            public void run() {
                SourceProvider.getInstance().updateAccessRights(session.getUserSystemRights());
            }
        });
        monitor.setTaskName(Messages.get(display).LoginJob_init_extensions);
        callLoginListeners(session);
        monitor.worked(5);
        new KeepAliveTimer(session).start();
    } catch (Exception e) {
        throw new InvocationTargetException(e);
    } finally {
        // $NON-NLS-1$
        monitor.setTaskName("");
        monitor.done();
    }
}
Also used : NXCSession(org.netxms.client.NXCSession) KeepAliveTimer(org.netxms.ui.eclipse.console.KeepAliveTimer) NXCException(org.netxms.client.NXCException) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException) NXCException(org.netxms.client.NXCException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)1 CoreException (org.eclipse.core.runtime.CoreException)1 NXCException (org.netxms.client.NXCException)1 NXCSession (org.netxms.client.NXCSession)1 KeepAliveTimer (org.netxms.ui.eclipse.console.KeepAliveTimer)1