Search in sources :

Example 1 with RightsDoc

use of com.zimbra.cs.account.Provisioning.RightsDoc in project zm-mailbox by Zimbra.

the class ProvUtil method doGetRightsDoc.

private void doGetRightsDoc(String[] args) throws ServiceException {
    if (!(prov instanceof SoapProvisioning)) {
        throwSoapOnly();
    }
    String[] packages;
    StringBuilder argsDump = new StringBuilder();
    if (args.length > 1) {
        // args[0] is "grd", starting from args[1]
        packages = new String[args.length - 1];
        for (int i = 1; i < args.length; i++) {
            packages[i - 1] = args[i];
            argsDump.append(" " + args[i]);
        }
    } else {
        packages = new String[] { "com.zimbra.cs.service.admin", "com.zimbra.bp", "com.zimbra.cert", "com.zimbra.cs.network", "com.zimbra.cs.network.license.service", "com.zimbra.cs.service.backup", "com.zimbra.cs.service.hsm", "com.zimbra.xmbxsearch" };
    }
    console.println("#");
    console.println("#  Generated by: zmprov grd" + argsDump);
    console.println("#");
    console.println("#  Date: " + DateFormat.getDateInstance(DateFormat.LONG).format(new Date()));
    console.println("# ");
    console.println("#  Packages:");
    for (String pkg : packages) {
        console.println("#       " + pkg);
    }
    console.println("# ");
    console.println("\n");
    Map<String, List<RightsDoc>> allDocs = prov.getRightsDoc(packages);
    for (Map.Entry<String, List<RightsDoc>> docs : allDocs.entrySet()) {
        console.println("========================================");
        console.println("Package: " + docs.getKey());
        console.println("========================================");
        console.println();
        for (RightsDoc doc : docs.getValue()) {
            console.println("------------------------------");
            console.println(doc.getCmd() + "\n");
            console.println("    Related rights:");
            for (String r : doc.getRights()) {
                console.println("        " + r);
            }
            console.println();
            console.println("    Notes:");
            for (String n : doc.getNotes()) {
                console.println(FileGenUtil.wrapComments(StringUtil.escapeHtml(n), 70, "        ") + "\n");
            }
            console.println();
        }
    }
}
Also used : SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning) RightsDoc(com.zimbra.cs.account.Provisioning.RightsDoc) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map) TreeMap(java.util.TreeMap) SortedMap(java.util.SortedMap) HashMap(java.util.HashMap) Date(java.util.Date)

Example 2 with RightsDoc

use of com.zimbra.cs.account.Provisioning.RightsDoc in project zm-mailbox by Zimbra.

the class TestJaxbProvisioning method testGetRightsDoc.

@Test
public void testGetRightsDoc() throws Exception {
    ZimbraLog.test.debug("Starting testGetRightsDoc");
    Map<String, List<RightsDoc>> map = prov.getRightsDoc(null);
    assertTrue("Map size=" + map.size() + " should be >= 1", map.size() >= 1);
    String[] pkgs = { "com.zimbra.cs.service.admin" };
    map = prov.getRightsDoc(pkgs);
    assertEquals("Map for specified set of pkgs", 1, map.size());
    boolean seenTstRight = false;
    for (String key : map.keySet()) {
        assertEquals("key to map", pkgs[0], key);
        for (RightsDoc rightsDoc : map.get(key)) {
            assertNotNull("rightsDoc cmd name", rightsDoc.getCmd());
            if (rightsDoc.getCmd().equals("AddAccountAliasRequest")) {
                seenTstRight = true;
                assertEquals("Notes number", 3, rightsDoc.getNotes().size());
                assertEquals("Rights number", 3, rightsDoc.getRights().size());
            }
        }
    }
    assertTrue("AddAccountAliasRequest right in report", seenTstRight);
}
Also used : RightsDoc(com.zimbra.cs.account.Provisioning.RightsDoc) List(java.util.List) DistributionList(com.zimbra.cs.account.DistributionList) Test(org.junit.Test)

Aggregations

RightsDoc (com.zimbra.cs.account.Provisioning.RightsDoc)2 List (java.util.List)2 DistributionList (com.zimbra.cs.account.DistributionList)1 SoapProvisioning (com.zimbra.cs.account.soap.SoapProvisioning)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 SortedMap (java.util.SortedMap)1 TreeMap (java.util.TreeMap)1 Test (org.junit.Test)1