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

jvergara
05.17.2009 d76a9a256b814a4a770738bb5243325fdaf6ec0c
Fix for issue 3688 (unexpected html tags in the output of status command)

Fix the issue and provide support to connection handlers with multiple listening addresses.
1 files modified
47 ■■■■ changed files
opends/src/server/org/opends/server/tools/status/StatusCli.java 47 ●●●● patch | view | raw | blame | history
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,28 +908,40 @@
  /**
   * 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++)
      {
        // Get the host name, it can be multivalued.
        String[] hostNames = getHostNames(tableModel, i);
        for (String hostName : hostNames)
        {
        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()));
        }
      }
    }
    }
    else
    {
      TableBuilder table = new TableBuilder();
@@ -940,18 +951,42 @@
      }
      for (int i=0; i<tableModel.getRowCount(); i++)
      {
//      Get the host name, it can be multivalued.
        String[] hostNames = getHostNames(tableModel, i);
        for (String hostName : hostNames)
        {
        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());
      printer.setColumnSeparator(ToolConstants.LIST_TABLE_SEPARATOR);
      table.print(printer);
    }
  }
  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)
  {