Example usage for org.w3c.dom.html HTMLTableElement getRows

List of usage examples for org.w3c.dom.html HTMLTableElement getRows

Introduction

In this page you can find the example usage for org.w3c.dom.html HTMLTableElement getRows.

Prototype

public HTMLCollection getRows();

Source Link

Document

Returns a collection of all the rows in the table, including all in THEAD , TFOOT , all TBODY elements.

Usage

From source file:org.sakaiproject.kernel.mailman.impl.MailmanManagerImpl.java

public List<String> getLists() throws MailmanException {
    HttpClient client = new HttpClient(proxyClientService.getHttpConnectionManager());
    GetMethod get = new GetMethod(getMailmanUrl("/admin"));
    List<String> lists = new ArrayList<String>();
    try {//from  w ww . j a  v a2  s .c om
        int result = client.executeMethod(get);
        if (result != HttpServletResponse.SC_OK) {
            LOGGER.warn("Got " + result + " from http request");
            throw new MailmanException("Unable to list mailinglists");
        }
        DOMParser parser = new DOMParser();
        parser.parse(new InputSource(get.getResponseBodyAsStream()));
        Document doc = parser.getDocument();
        NodeList tableNodes = doc.getElementsByTagName("table");
        if (tableNodes.getLength() < 2) {
            throw new MailmanException("Unrecognised page format.");
        }
        HTMLTableElement mainTable = (HTMLTableElement) tableNodes.item(0);
        HTMLCollection rows = mainTable.getRows();
        for (int i = 4; i < rows.getLength(); i++) {
            lists.add(parseListNameFromRow((HTMLTableRowElement) rows.item(i)));
        }
    } catch (SAXException e) {
        throw new MailmanException("Error parsing mailman response", e);
    } catch (HttpException e) {
        throw new MailmanException("HTTP Exception communicating with mailman server", e);
    } catch (IOException e) {
        throw new MailmanException("IOException communicating with mailman server", e);
    } finally {
        get.releaseConnection();
    }
    return lists;
}