Search in sources :

Example 21 with Zimlet

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

the class ZimletUtil method orderZimletsByPriority.

public static List<Zimlet> orderZimletsByPriority(List<Zimlet> zimlets) {
    // create a sortable collection, sort, then return List<Zimlet> in the
    // sorted order.  version is not comparable in String format.
    List<Pair<Version, Zimlet>> plist = new ArrayList<Pair<Version, Zimlet>>();
    for (Zimlet z : zimlets) {
        String pstring = z.getPriority();
        if (pstring == null) {
            // no priority.  put it at the end of priority list
            pstring = Integer.toString(Integer.MAX_VALUE);
        }
        Version v = new Version(pstring);
        plist.add(new Pair<Version, Zimlet>(v, z));
    }
    Collections.sort(plist, new Comparator<Pair<Version, Zimlet>>() {

        @Override
        public int compare(Pair<Version, Zimlet> first, Pair<Version, Zimlet> second) {
            return first.getFirst().compareTo(second.getFirst());
        }
    });
    List<Zimlet> ret = new ArrayList<Zimlet>();
    for (Pair<Version, Zimlet> p : plist) {
        ret.add(p.getSecond());
    }
    return ret;
}
Also used : Zimlet(com.zimbra.cs.account.Zimlet) ArrayList(java.util.ArrayList) Pair(com.zimbra.common.util.Pair)

Example 22 with Zimlet

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

the class ZimletUtil method listInstalledZimletsInLdap.

/**
     *
     * Print all the Zimlets on LDAP.
     *
     * @throws ZimletException
     */
public static void listInstalledZimletsInLdap(boolean everything) throws ServiceException, ZimletException {
    Provisioning prov = Provisioning.getInstance();
    for (Zimlet z : prov.listAllZimlets()) {
        boolean isExtension = z.isExtension();
        if (!everything && isExtension) {
            continue;
        }
        System.out.print("\t" + z.getName());
        if (!z.isEnabled()) {
            System.out.print(" (disabled)");
        }
        if (isExtension) {
            System.out.print(" (ext)");
        }
        System.out.println();
    }
}
Also used : Zimlet(com.zimbra.cs.account.Zimlet) Provisioning(com.zimbra.cs.account.Provisioning) SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning)

Example 23 with Zimlet

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

the class TestACLAttrRight method grantRight.

/*
     * TODO: following methods (grantRight and verify) copied from legacy
     *       com.zimbra.qa.unittest.TestACL.
     *       Move to ACLTestUtil if used in other classes as we continue to renovate ACL
     *       unit tests.
     *
     *
     * utility methods to grant/revoke right
     *
     * To simulate how grants are done in the real server/zmprov, we first call TargetType.lookupTarget to
     * "look for" the taret, then use the returned entry instead of giving the target entry passed in
     * directly to RightUtil.
     *
     * This is for testing user rights, which goes to RightUtil directly (i.e. not through RightCommand)
     *
     */
private List<ZimbraACE> grantRight(TargetType targetType, Entry target, Set<ZimbraACE> aces) throws ServiceException {
    /*
         * make sure all rights are user right, tests written earlier could still be using
         * this to grant
         */
    for (ZimbraACE ace : aces) {
        assertTrue(ace.getRight().isUserRight());
    }
    Entry targetEntry;
    if (target instanceof Zimlet) {
        // must be by name
        String targetName = ((Zimlet) target).getName();
        targetEntry = TargetType.lookupTarget(prov, targetType, TargetBy.name, targetName);
    } else {
        String targetId = (target instanceof NamedEntry) ? ((NamedEntry) target).getId() : null;
        targetEntry = TargetType.lookupTarget(prov, targetType, TargetBy.id, targetId);
    }
    return ACLUtil.grantRight(prov, targetEntry, aces);
}
Also used : ZimbraACE(com.zimbra.cs.account.accesscontrol.ZimbraACE) NamedEntry(com.zimbra.cs.account.NamedEntry) NamedEntry(com.zimbra.cs.account.NamedEntry) Entry(com.zimbra.cs.account.Entry) Zimlet(com.zimbra.cs.account.Zimlet)

Example 24 with Zimlet

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

the class LdapProvisioning method listAllZimlets.

@Override
public List<Zimlet> listAllZimlets() throws ServiceException {
    List<Zimlet> result = new ArrayList<Zimlet>();
    try {
        ZSearchResultEnumeration ne = helper.searchDir(mDIT.zimletBaseDN(), filterFactory.allZimlets(), ZSearchControls.SEARCH_CTLS_SUBTREE());
        while (ne.hasMore()) {
            ZSearchResultEntry sr = ne.next();
            result.add(new LdapZimlet(sr.getDN(), sr.getAttributes(), this));
        }
        ne.close();
    } catch (ServiceException e) {
        throw ServiceException.FAILURE("unable to list all zimlets", e);
    }
    Collections.sort(result);
    return result;
}
Also used : Zimlet(com.zimbra.cs.account.Zimlet) LdapZimlet(com.zimbra.cs.account.ldap.entry.LdapZimlet) AccountServiceException(com.zimbra.cs.account.AccountServiceException) AuthFailedServiceException(com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException) ServiceException(com.zimbra.common.service.ServiceException) ZSearchResultEnumeration(com.zimbra.cs.ldap.ZSearchResultEnumeration) LdapZimlet(com.zimbra.cs.account.ldap.entry.LdapZimlet) ArrayList(java.util.ArrayList) ZSearchResultEntry(com.zimbra.cs.ldap.ZSearchResultEntry)

Example 25 with Zimlet

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

the class GetAllZimlets method handle.

public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    String exclude = request.getAttribute(AdminConstants.A_EXCLUDE, AdminConstants.A_NONE);
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Provisioning prov = Provisioning.getInstance();
    List<Zimlet> zimlets = prov.listAllZimlets();
    AdminAccessControl aac = AdminAccessControl.getAdminAccessControl(zsc);
    Element response = zsc.createElement(AdminConstants.GET_ALL_ZIMLETS_RESPONSE);
    if (AdminConstants.A_EXTENSION.equalsIgnoreCase(exclude)) {
        for (Zimlet zimlet : zimlets) {
            if (!zimlet.isExtension()) {
                if (aac.hasRightsToList(zimlet, Admin.R_listZimlet, null))
                    GetZimlet.encodeZimlet(response, zimlet, null, aac.getAttrRightChecker(zimlet));
            }
        }
    } else if (AdminConstants.A_MAIL.equalsIgnoreCase(exclude)) {
        for (Zimlet zimlet : zimlets) {
            if (zimlet.isExtension()) {
                if (aac.hasRightsToList(zimlet, Admin.R_listZimlet, null))
                    GetZimlet.encodeZimlet(response, zimlet, null, aac.getAttrRightChecker(zimlet));
            }
        }
    } else {
        for (Zimlet zimlet : zimlets) {
            if (aac.hasRightsToList(zimlet, Admin.R_listZimlet, null))
                GetZimlet.encodeZimlet(response, zimlet, null, aac.getAttrRightChecker(zimlet));
        }
    }
    return response;
}
Also used : Zimlet(com.zimbra.cs.account.Zimlet) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) Provisioning(com.zimbra.cs.account.Provisioning)

Aggregations

Zimlet (com.zimbra.cs.account.Zimlet)37 Provisioning (com.zimbra.cs.account.Provisioning)16 SoapProvisioning (com.zimbra.cs.account.soap.SoapProvisioning)11 Element (com.zimbra.common.soap.Element)8 HashMap (java.util.HashMap)8 ServiceException (com.zimbra.common.service.ServiceException)7 AccountServiceException (com.zimbra.cs.account.AccountServiceException)7 Cos (com.zimbra.cs.account.Cos)4 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)4 Entry (com.zimbra.cs.account.Entry)3 NamedEntry (com.zimbra.cs.account.NamedEntry)3 LdapZimlet (com.zimbra.cs.account.ldap.entry.LdapZimlet)3 AuthFailedServiceException (com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException)2 CacheEntry (com.zimbra.cs.account.Provisioning.CacheEntry)2 ZimbraACE (com.zimbra.cs.account.accesscontrol.ZimbraACE)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Key (com.zimbra.common.account.Key)1 AccountBy (com.zimbra.common.account.Key.AccountBy)1 DistributionListBy (com.zimbra.common.account.Key.DistributionListBy)1