protected void doGet()

in src/main/java/org/apache/sling/tenant/internal/console/WebConsolePlugin.java [142:197]


    protected void doGet(final HttpServletRequest req, final HttpServletResponse res) throws IOException {
        final PrintWriter pw = res.getWriter();

        pw.println("<form method='POST' name='cmd'>" + "<input type='hidden' name='action' value=''/>"
            + "<input type='hidden' name='tenantId' value=''/>" + "</form>");
        pw.println("<script type='text/javascript'>");
        pw.println("function cmdsubmit(action, tenantId) {" + " document.forms['cmd'].action.value = action;"
            + " document.forms['cmd'].tenantId.value = tenantId;" + " document.forms['cmd'].submit();" + "} "
            + "function createsubmit() {" + " document.forms['editorForm'].submit();" + "} " + "</script>");
        pw.printf("<p class='statline ui-state-highlight'>Apache Sling Tenant Support</p>");

        pw.println("<div class='ui-widget-header ui-corner-top buttonGroup'>");
        pw.println("<span style='float: left; margin-left: 1em'>Add New Tenant </span>");
        pw.println("<button class='ui-state-default ui-corner-all' onclick='javascript:createsubmit();'> Create </button></div></td></tr>");
        pw.println("</div>");
        pw.println("<table id='editortable' class='nicetable'><tbody>");

        pw.println("<tr width='100%'><td colspan='2'><form id='editorForm' method='POST'>");
        pw.println("<input name='action' type='hidden' value='create' class='ui-state-default ui-corner-all'>");
        pw.println("<table border='0' width='100%'><tbody>");
        pw.println("<tr><td style='width: 30%;'>Identifier</td><td>");
        pw.println("<div><input name='tenantId' type='text' value=''></div>");
        pw.println("</td></tr>");
        pw.println("<tr><td style='width: 30%;'>Name</td><td>");
        pw.println("<div><input name='tenantName' type='text' value=''></div>");
        pw.println("</td></tr>");
        pw.println("<tr><td style='width: 30%;'>Description</td><td>");
        pw.println("<div><input name='tenantDesc' type='text' value=''></div>");
        pw.println("</td></tr>");
        pw.println("</tbody></table></form>");
        pw.println("</tbody></table>");

        Iterator<Tenant> tenants = this.tenantProvider.getTenants();
        int count = 0;
        while (tenants.hasNext()) {
            count++;
            Tenant tenant = tenants.next();
            if (count == 1) {
                pw.printf("<p class='statline ui-state-highlight'>Registered Tenants</p>");
            }
            pw.println("<div class='ui-widget-header ui-corner-top buttonGroup'>");
            pw.printf("<span style='float: left; margin-left: 1em'>Tenant : %s </span>", xss.encodeForHTML(tenant.getName()));
            this.printForm(pw, tenant, "Remove", "remove");
            pw.println("</div>");
            pw.println("<table class='nicetable'><tbody>");

            pw.printf("<tr><td style='width: 30%%;'>Identifier</td><td>%s</td></tr>", xss.encodeForHTML(tenant.getId()));
            pw.printf("<tr><td style='width: 30%%;'>Name</td><td>%s</td></tr>", xss.encodeForHTML(tenant.getName()));
            pw.printf("<tr><td style='width: 30%%;'>Description</td><td>%s</td></tr>", xss.encodeForHTML(tenant.getDescription()));
            pw.println("</tbody></table>");
        }
        // no existing tenants
        if (count == 0) {
            pw.printf("<p class='statline ui-state-highlight'>There are no registered tenants</p>");
        }
    }