mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

jvergara
05.17.2009 d76a9a256b814a4a770738bb5243325fdaf6ec0c
opends/src/server/org/opends/server/tools/status/StatusCli.java
@@ -42,7 +42,6 @@
import javax.naming.NamingException;
import javax.naming.ldap.InitialLdapContext;
import javax.swing.table.TableModel;
import org.opends.admin.ads.util.ApplicationTrustManager;
import org.opends.guitools.controlpanel.datamodel.BackendDescriptor;
@@ -801,7 +800,7 @@
      ConnectionHandlerTableModel connHandlersTableModel =
        new ConnectionHandlerTableModel(false);
      connHandlersTableModel.setData(connectionHandlers);
      writeTableModel(connHandlersTableModel, desc);
      writeConnectionHandlersTableModel(connHandlersTableModel, desc);
    }
  }
@@ -909,25 +908,37 @@
  /**
   * Writes the contents of the provided table model simulating a table layout
   * using text.
   * @param tableModel the TableModel.
   * @param tableModel the connection handler table model.
   * @param desc the Server Status descriptor.
   */
  private void writeTableModel(TableModel tableModel,
  private void writeConnectionHandlersTableModel(
      ConnectionHandlerTableModel tableModel,
      ServerDescriptor desc)
  {
    if (isScriptFriendly())
    {
      for (int i=0; i<tableModel.getRowCount(); i++)
      {
        getOutputStream().println("-");
        for (int j=0; j<tableModel.getColumnCount(); j++)
        // Get the host name, it can be multivalued.
        String[] hostNames = getHostNames(tableModel, i);
        for (String hostName : hostNames)
        {
          MessageBuilder line = new MessageBuilder();
          line.append(tableModel.getColumnName(j)+": ");
          line.append(getCellValue(tableModel.getValueAt(i, j), desc));
          getOutputStream().println(wrapText(line.toMessage()));
          getOutputStream().println("-");
          for (int j=0; j<tableModel.getColumnCount(); j++)
          {
            MessageBuilder line = new MessageBuilder();
            line.append(tableModel.getColumnName(j)+": ");
            if (j == 0)
            {
              // It is the hostName
              line.append(getCellValue(hostName, desc));
            }
            else
            {
              line.append(getCellValue(tableModel.getValueAt(i, j), desc));
            }
            getOutputStream().println(wrapText(line.toMessage()));
          }
        }
      }
    }
@@ -940,10 +951,23 @@
      }
      for (int i=0; i<tableModel.getRowCount(); i++)
      {
        table.startRow();
        for (int j=0; j<tableModel.getColumnCount(); j++)
//      Get the host name, it can be multivalued.
        String[] hostNames = getHostNames(tableModel, i);
        for (String hostName : hostNames)
        {
          table.appendCell(getCellValue(tableModel.getValueAt(i, j), desc));
          table.startRow();
          for (int j=0; j<tableModel.getColumnCount(); j++)
          {
            if (j == 0)
            {
              // It is the hostName
              table.appendCell(getCellValue(hostName, desc));
            }
            else
            {
              table.appendCell(getCellValue(tableModel.getValueAt(i, j), desc));
            }
          }
        }
      }
      TextTablePrinter printer = new TextTablePrinter(getOutputStream());
@@ -952,6 +976,17 @@
    }
  }
  private String[] getHostNames(ConnectionHandlerTableModel tableModel,
      int row)
  {
   String v = (String)tableModel.getValueAt(row, 0);
   String htmlTag = "<html>";
   if (v.toLowerCase().startsWith(htmlTag))
   {
     v = v.substring(htmlTag.length());
   }
   return v.split("<br>");
  }
  private Message getCellValue(Object v, ServerDescriptor desc)
  {