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;
}
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();
}
}
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);
}
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;
}
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;
}
Aggregations