public boolean equals(Object obj) {
    if (super.equals(obj)) return true;

    if (!(obj instanceof TransactionConfigEditorInput)) return false;

    TransactionConfigEditorInput other = (TransactionConfigEditorInput) obj;

    return protocol.equals(other.protocol) && name.equals(other.name);
  }
Example #2
0
  private boolean controlServer(int messageType, IPCProtocol protocol) {
    NBFields fields = new NBFields();

    fields.put(IPC.NB_MSG_TYPE, messageType);
    fields.put(IPC.NB_LOAD_CLASS, "com.nabsys.management.server.ControlServer");

    try {

      fields = protocol.execute(fields);

      if ((Integer) fields.get(IPC.NB_MSG_RETURN) == IPC.FAIL) {
        IMessageBox.Error(shell, (String) fields.get("RTN_MSG"));
        return false;
      } else {
        return true;
      }
    } catch (SocketClosedException e) {
      IMessageBox.Error(shell, NBLabel.get(0x0090));
      closeConnection();
      return false;
    } catch (TimeoutException e) {
      IMessageBox.Error(shell, e.getMessage());
      return false;
    } catch (NetException e) {
      IMessageBox.Error(shell, NBLabel.get(0x0090));
      closeConnection();
      return false;
    } catch (UnsupportedEncodingException e) {
      IMessageBox.Error(shell, NBLabel.get(0x0090));
      closeConnection();
      return false;
    } catch (NoSuchAlgorithmException e) {
      IMessageBox.Error(shell, NBLabel.get(0x0090));
      closeConnection();
      return false;
    } catch (DataTypeException e) {
      IMessageBox.Error(shell, NBLabel.get(0x0090));
      closeConnection();
      return false;
    } catch (ProtocolException e) {
      IMessageBox.Error(shell, NBLabel.get(0x0090));
      closeConnection();
      return false;
    }
  }
Example #3
0
  private NBFields getServerConfigInfo(IPCProtocol protocol) {
    NBFields fields = new NBFields();
    fields.put(IPC.NB_LOAD_CLASS, "com.nabsys.management.server.ServerConfig");
    fields.put("CMD_CODE", "R");

    try {
      fields = protocol.execute(fields);

      if ((Integer) fields.get(IPC.NB_MSG_RETURN) == IPC.FAIL) {
        IMessageBox.Error(shell, (String) fields.get("RTN_MSG"));
      }
    } catch (SocketClosedException e) {
      IMessageBox.Error(shell, NBLabel.get(0x0090));
      closeConnection();
      fields = null;
    } catch (TimeoutException e) {
      IMessageBox.Error(shell, e.getMessage());
      fields = null;
    } catch (NetException e) {
      IMessageBox.Error(shell, NBLabel.get(0x0090));
      closeConnection();
      fields = null;
    } catch (UnsupportedEncodingException e) {
      IMessageBox.Error(shell, NBLabel.get(0x0090));
      closeConnection();
      fields = null;
    } catch (NoSuchAlgorithmException e) {
      IMessageBox.Error(shell, NBLabel.get(0x0090));
      closeConnection();
      fields = null;
    } catch (DataTypeException e) {
      IMessageBox.Error(shell, NBLabel.get(0x0090));
      closeConnection();
      fields = null;
    } catch (ProtocolException e) {
      IMessageBox.Error(shell, NBLabel.get(0x0090));
      closeConnection();
      fields = null;
    }

    return fields;
  }
Example #4
0
  public boolean connectServer(HashMap<String, String> params) {
    ServerConnect connect = null;
    Server server = null;

    if (!treeViewer.getSelection().isEmpty()) {
      IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();

      if (selection.getFirstElement() instanceof Server) {
        server = (Server) selection.getFirstElement();
        connect = server.getConnect();
      } else {
        IMessageBox.Error(shell, NBLabel.get(0x0090));
        return true;
      }

      if (params.containsKey("SAVE_FLAG") && params.get("SAVE_FLAG").equals("true"))
        connect.setPassword(params.get("PASSWORD"));

      params.put("IP_ADDRESS", connect.getHostAddr());
      params.put("PORT", Integer.toString(connect.getHostPort()));
      params.put("ENCODING", connect.getServerEncoding());
    } else if (params.containsKey("SERVER_NAME")) {
      String serverName = params.get("SERVER_NAME");

      ArrayList<Model> children = ((Model) treeViewer.getInput()).getChildren();
      for (int i = 0; i < children.size(); i++) {
        if (serverName.equals(children.get(i).getName())) {
          server = (Server) children.get(i);
          connect = ((Server) children.get(i)).getConnect();
        }
      }

    } else {
      IMessageBox.Error(shell, NBLabel.get(0x0090));
      return true;
    }

    try {
      Socket socket =
          new Socket(params.get("IP_ADDRESS"), Integer.parseInt(params.get("PORT")), 4096, 30);

      InstanceHeaderFields fields = new InstanceHeaderFields();
      fields.put(
          "LENGTH", new TelegramFieldContext("LENGTH", "LENGTH", 0, 4, true, ' ', ' ', 'I', ""));
      fields.put(
          "MSG_TYPE",
          new TelegramFieldContext("MSG_TYPE", "MSG_TYPE", 1, 4, true, ' ', ' ', 'I', ""));
      fields.put(
          "RETURN", new TelegramFieldContext("RETURN", "RETURN", 2, 4, true, ' ', ' ', 'I', ""));
      fields.setLengthFieldIndex("LENGTH");
      fields.setMsgTypeFieldIndex("MSG_TYPE");
      fields.setReturnFieldIndex("RETURN");

      IPCProtocol protocol =
          new IPCProtocol(
              socket, params.get("USER"), params.get("PASSWORD"), fields, params.get("ENCODING"));
      connect.setProtocol(protocol);

      NBFields netFields = new NBFields();
      netFields.put(IPC.NB_LOAD_CLASS, "com.nabsys.management.instance.InstanceConfig");
      netFields.put("CMD_CODE", "L");

      netFields = protocol.execute(netFields);

      if (protocol.getUserAuthority().equals("Admin")) {
        new ServerConfig(
            server,
            NBLabel.get(0x0049),
            Activator.getImageDescriptor("/icons/config_obj.gif").createImage(display));
        new UserList(
            server,
            NBLabel.get(0x009D),
            Activator.getImageDescriptor("/icons/user_view.gif").createImage(display));
        new InstanceList(
            server,
            NBLabel.get(0x0093),
            Activator.getImageDescriptor("/icons/pview.gif").createImage(display));
        terminateAction.setEnabled(true);
      } else if (protocol.getUserAuthority().equals("Operator")) {
        new UserList(
            server,
            NBLabel.get(0x009D),
            Activator.getImageDescriptor("/icons/user_view.gif").createImage(display));
        new InstanceList(
            server,
            NBLabel.get(0x0093),
            Activator.getImageDescriptor("/icons/pview.gif").createImage(display));
      } else if (protocol.getUserAuthority().equals("Developer")) {
        new InstanceList(
            server,
            NBLabel.get(0x0093),
            Activator.getImageDescriptor("/icons/pview.gif").createImage(display));
      }

      server.setImage(Activator.getImageDescriptor("/icons/conserver.gif").createImage(display));
      treeViewer.refresh();

      connectAction.setEnabled(false);
      disconnectAction.setEnabled(true);

      treeViewer.expandToLevel(server, 1);

      openInstanceView(server.getName(), server.getInstance(), netFields, server);

    } catch (NumberFormatException e) {
      try {
        if (connect.getProtocol() != null) connect.getProtocol()._close();
      } catch (IOException e1) {
      }
      IMessageBox.Error(shell, e.getMessage());
      return true;
    } catch (NetException e) {
      try {
        if (connect.getProtocol() != null) connect.getProtocol()._close();
      } catch (IOException e1) {
      }
      IMessageBox.Error(shell, e.getMessage());
      return false;
    } catch (SocketClosedException e) {
      try {
        if (connect.getProtocol() != null) connect.getProtocol()._close();
      } catch (IOException e1) {
      }
      IMessageBox.Error(shell, e.getMessage());
      return true;
    } catch (ClassNotFoundException e) {
      try {
        if (connect.getProtocol() != null) connect.getProtocol()._close();
      } catch (IOException e1) {
      }
      IMessageBox.Error(shell, e.getMessage());
      return true;
    } catch (TimeoutException e) {
      try {
        if (connect.getProtocol() != null) connect.getProtocol()._close();
      } catch (IOException e1) {
      }
      IMessageBox.Error(shell, e.getMessage());
      return false;
    } catch (UnsupportedEncodingException e) {
      try {
        if (connect.getProtocol() != null) connect.getProtocol()._close();
      } catch (IOException e1) {
      }
      IMessageBox.Error(shell, e.getMessage());
      return true;
    } catch (NoSuchAlgorithmException e) {
      try {
        if (connect.getProtocol() != null) connect.getProtocol()._close();
      } catch (IOException e1) {
      }
      IMessageBox.Error(shell, e.getMessage());
      return true;
    } catch (DataTypeException e) {
      try {
        if (connect.getProtocol() != null) connect.getProtocol()._close();
      } catch (IOException e1) {
      }
      IMessageBox.Error(shell, e.getMessage());
      return true;
    } catch (ProtocolException e) {
      try {
        if (connect.getProtocol() != null) connect.getProtocol()._close();
      } catch (IOException e1) {
      }
      IMessageBox.Error(shell, e.getMessage());
      return true;
    } catch (Exception e) {
      try {
        if (connect.getProtocol() != null) connect.getProtocol()._close();
      } catch (IOException e1) {
      }
      IMessageBox.Error(shell, e.getMessage());
      return true;
    }
    return true;
  }