added command line switch -ignore-protocol-version
authorVictor Kirhenshtein <victor@netxms.org>
Tue, 12 Nov 2013 16:28:45 +0000 (18:28 +0200)
committerVictor Kirhenshtein <victor@netxms.org>
Tue, 12 Nov 2013 16:28:45 +0000 (18:28 +0200)
src/java/netxms-client/src/main/java/org/netxms/client/NXCSession.java
src/java/netxms-eclipse/core/src/org/netxms/ui/eclipse/console/LoginJob.java
src/java/netxms-eclipse/core/src/org/netxms/ui/eclipse/console/NXMCWorkbenchWindowAdvisor.java

index 04ded46..b56180c 100644 (file)
@@ -1340,11 +1340,10 @@ public class NXCSession
          sendMessage(request);
          NXCPMessage response = waitForMessage(NXCPCodes.CMD_REQUEST_COMPLETED, request.getMessageId());
 
-         if ((response
-            .getVariableAsInteger(NXCPCodes.VID_PROTOCOL_VERSION) != CLIENT_PROTOCOL_VERSION) && !ignoreProtocolVersion)
+         if ((response.getVariableAsInteger(NXCPCodes.VID_PROTOCOL_VERSION) != CLIENT_PROTOCOL_VERSION) && !ignoreProtocolVersion)
          {
-            Logger.warning("NXCSession.connect", "connection failed, server protocol version is " + response
-               .getVariableAsInteger(NXCPCodes.VID_PROTOCOL_VERSION));
+            Logger.warning("NXCSession.connect", "connection failed, server protocol version is " + 
+               response.getVariableAsInteger(NXCPCodes.VID_PROTOCOL_VERSION));
             throw new NXCException(RCC.BAD_PROTOCOL);
          }
 
index b7c64a1..59e89f6 100644 (file)
@@ -61,6 +61,7 @@ public class LoginJob implements IRunnableWithProgress
    private String server;
    private String loginName;
    private boolean encryptSession;
+   private boolean ignoreProtocolVersion;
    private int authMethod;
    private String password;
    private Signature signature;
@@ -71,12 +72,13 @@ public class LoginJob implements IRunnableWithProgress
     * @param loginName
     * @param encryptSession
     */
-   public LoginJob(Display display, String server, String loginName, boolean encryptSession)
+   public LoginJob(Display display, String server, String loginName, boolean encryptSession, boolean ignoreProtocolVersion)
    {
       this.display = display;
       this.server = server;
       this.loginName = loginName;
       this.encryptSession = encryptSession;
+      this.ignoreProtocolVersion = ignoreProtocolVersion;
       authMethod = NXCSession.AUTH_TYPE_PASSWORD;
    }
 
@@ -113,6 +115,7 @@ public class LoginJob implements IRunnableWithProgress
 
          NXCSession session = createSession(hostName, port);
          session.setConnClientInfo("nxmc/" + NXCommon.VERSION); //$NON-NLS-1$
+         session.setIgnoreProtocolVersion(ignoreProtocolVersion);
          monitor.worked(1);
 
          session.connect();
index a1e6c48..6626151 100644 (file)
@@ -152,6 +152,7 @@ public class NXMCWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor implement
       IDialogSettings settings = Activator.getDefault().getDialogSettings();
       boolean success = false;
       boolean autoConnect = false;
+      boolean ignoreProtocolVersion = false;
       String password = ""; //$NON-NLS-1$
 
       CertificateManager certMgr = CertificateManagerProvider.provideCertificateManager();
@@ -177,6 +178,10 @@ public class NXMCWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor implement
          {
             autoConnect = true;
          }
+         else if (s.equals("-ignore-protocol-version"))
+         {
+            ignoreProtocolVersion = true;
+         }
       }
 
       boolean encrypt = true;
@@ -198,7 +203,7 @@ public class NXMCWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor implement
          LoginJob job = new LoginJob(display, 
                        settings.get("Connect.Server"), //$NON-NLS-1$ 
                settings.get("Connect.Login"), //$NON-NLS-1$
-               encrypt);
+               encrypt, ignoreProtocolVersion);
 
          int authMethod;
          try