Package org.apache.sling.tenant

Examples of org.apache.sling.tenant.Tenant


            if (matcher.find()) {
                // assuming that first group is tenantId in the path, we can
                // make group number configurable.
                if (matcher.groupCount() >= 1) {
                    String tenantId = matcher.group(1);
                    final Tenant tenant = this.tenantProvider.getTenant(tenantId);
                    if (tenant != null) {
                        return tenant;
                    }
                }
            }
View Full Code Here


    @Override
    protected void doPost(final HttpServletRequest req, final HttpServletResponse resp) throws IOException {
        String msg = null;
        final String cmd = req.getParameter("action");
        if ("create".equals(cmd)) {
            Tenant t = this.createTenant(req);
            if (t != null) {
                msg = String.format("Created Tenant %s (%s)", t.getName(), t.getDescription());
            } else {
                msg = "Cannot create tenant";
            }
        } else if ("remove".equals(cmd)) {
            this.removeTenant(req);
View Full Code Here

        resp.sendRedirect(redirectTo);
    }

    private void removeTenant(HttpServletRequest request) {
        final String tenantId = request.getParameter(REQ_PRM_TENANT_ID);
        final Tenant tenant = this.tenantProvider.getTenant(tenantId);

        if (tenant != null) {
            this.tenantProvider.remove(tenant);
        }
    }
View Full Code Here

        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>", escape(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>", escape(tenant.getId()));
            pw.printf("<tr><td style='width: 30%%;'>Name</td><td>%s</td></tr>", escape(tenant.getName()));
            pw.printf("<tr><td style='width: 30%%;'>Description</td><td>%s</td></tr>", escape(tenant.getDescription()));
            pw.println("</tbody></table>");
        }
        // no existing tenants
        if (count == 0) {
            pw.printf("<p class='statline ui-state-highlight'>There are not registered tenants</p>");
View Full Code Here

    };

    @Test
    public void test_id() {
        Resource r = new MockResource(pt1, new HashMap<String, Object>());
        Tenant tenant1 = new TenantImpl(r);

        TestCase.assertEquals(t1, tenant1.getId());
        TestCase.assertNull(tenant1.getName());
        TestCase.assertNull(tenant1.getDescription());

        TestCase.assertFalse(tenant1.getPropertyNames().hasNext());

        TestCase.assertNull(tenant1.getProperty(Tenant.PROP_NAME));
        TestCase.assertNull(tenant1.getProperty(Tenant.PROP_DESCRIPTION));
        TestCase.assertNull(tenant1.getProperty(p1));
    }
View Full Code Here

            {
                put(Tenant.PROP_NAME, n1);
                put(Tenant.PROP_DESCRIPTION, d1);
            }
        });
        Tenant tenant1 = new TenantImpl(r);

        TestCase.assertEquals(t1, tenant1.getId());
        TestCase.assertEquals(n1, tenant1.getName());
        TestCase.assertEquals(d1, tenant1.getDescription());

        Iterator<String> pi = tenant1.getPropertyNames();
        TestCase.assertTrue(propNamesDefault.contains(pi.next()));
        TestCase.assertTrue(propNamesDefault.contains(pi.next()));
        TestCase.assertFalse(pi.hasNext());

        TestCase.assertEquals(n1, tenant1.getProperty(Tenant.PROP_NAME));
        TestCase.assertEquals(d1, tenant1.getProperty(Tenant.PROP_DESCRIPTION));
        TestCase.assertNull(tenant1.getProperty(p1));

    }
View Full Code Here

        Resource r = new MockResource(pt1, new HashMap<String, Object>() {
            {
                put(p1, p1);
            }
        });
        Tenant tenant1 = new TenantImpl(r);

        TestCase.assertEquals(t1, tenant1.getId());
        TestCase.assertNull(tenant1.getName());
        TestCase.assertNull(tenant1.getDescription());

        Iterator<String> pi = tenant1.getPropertyNames();
        TestCase.assertTrue(propNamesTest.contains(pi.next()));
        TestCase.assertFalse(pi.hasNext());

        TestCase.assertNull(tenant1.getProperty(Tenant.PROP_NAME));
        TestCase.assertNull(tenant1.getProperty(Tenant.PROP_DESCRIPTION));
        TestCase.assertEquals(p1, tenant1.getProperty(p1));
    }
View Full Code Here

TOP

Related Classes of org.apache.sling.tenant.Tenant

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.