Search in sources :

Example 6 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(String[] zimlets) {
    Provisioning prov = Provisioning.getInstance();
    List<Zimlet> zlist = new ArrayList<Zimlet>();
    for (int i = 0; i < zimlets.length; i++) {
        try {
            Zimlet z = prov.getZimlet(zimlets[i]);
            if (z != null) {
                zlist.add(z);
            }
        } catch (ServiceException se) {
            // ignore error and continue on
            ZimbraLog.zimlet.warn("unable to get zimlet " + zimlets[i], se);
        }
    }
    return orderZimletsByPriority(zlist);
}
Also used : Zimlet(com.zimbra.cs.account.Zimlet) AccountServiceException(com.zimbra.cs.account.AccountServiceException) ServiceException(com.zimbra.common.service.ServiceException) ArrayList(java.util.ArrayList) Provisioning(com.zimbra.cs.account.Provisioning) SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning)

Example 7 with Zimlet

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

the class ZimletUtil method deployZimletLocally.

/**
     * Deploys the specified Zimlet on local server, be it service node or ui node. The following actions are taken.
     * 1.  Install the Zimlet files on the machine.
     * 2.  Check the LDAP for the Zimlet entry.  If the entry already exists, stop.
     * 3.  Install the LDAP entry for the Zimlet.
     * 4.  Install Zimlet config.
     * 5.  Activate the zimlet on default COS.
     * 6.  Enable the Zimlet.
     *
     * @param zimlet
     * @throws IOException
     * @throws ZimletException
     */
public static void deployZimletLocally(ZimletFile zf) throws IOException, ZimletException, ServiceException {
    Provisioning prov = Provisioning.getInstance();
    String zimletName = zf.getZimletName();
    ZimletDescription zd = zf.getZimletDescription();
    Zimlet z;
    Action action = Action.INSTALL;
    String priority = null;
    boolean enable = true;
    // check if the zimlet already exists in LDAP.
    z = prov.getZimlet(zimletName);
    if (z != null) {
        Version ver = new Version(z.getAttr(Provisioning.A_zimbraZimletVersion));
        if (zd.getVersion().compareTo(ver) < 0) {
            ZimbraLog.zimlet.info("Zimlet " + zimletName + " being installed is of an older version.");
        }
        if (zd.getVersion().compareTo(ver) == 0) {
            action = Action.REPAIR;
        } else {
            action = Action.UPGRADE;
        }
        // save priority
        priority = z.getPriority();
        enable = z.isEnabled();
    }
    // update LDAP
    z = ldapDeploy(zf);
    // install files
    installZimletLocally(zf);
    if (action == Action.REPAIR) {
        return;
    }
    // upgrade
    ZimbraLog.zimlet.info("Upgrading Zimlet " + zimletName + " to " + zd.getVersion().toString());
    // set the priority
    if (priority == null) {
        setPriority(zimletName, P_MAX);
    }
    // install the config
    if (zf.hasZimletConfig()) {
        installConfig(zf.getZimletConfig());
    }
    // activate
    if (!zd.isExtension()) {
        activateZimlet(zimletName, ZIMLET_DEFAULT_COS);
    }
    if (!enable) {
        // it was an upgrade of previously disabled zimlet.  leave it alone.
        return;
    }
    // enable
    enableZimlet(zimletName);
}
Also used : Zimlet(com.zimbra.cs.account.Zimlet) Provisioning(com.zimbra.cs.account.Provisioning) SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning)

Example 8 with Zimlet

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

the class ZimletUtil method setPriority.

public static void setPriority(String zimlet, int priority) throws ServiceException {
    List<Zimlet> plist = orderZimletsByPriority();
    Provisioning prov = Provisioning.getInstance();
    Zimlet z = prov.getZimlet(zimlet);
    if (z == null) {
        throw AccountServiceException.NO_SUCH_ZIMLET(zimlet);
    }
    setPriority(z, priority, plist);
}
Also used : Zimlet(com.zimbra.cs.account.Zimlet) Provisioning(com.zimbra.cs.account.Provisioning) SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning)

Example 9 with Zimlet

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

the class ZimletUtil method undeployZimletLocally.

/**
     *
     * Delete the Zimlet from LDAP and remove the associated Zimlet files.
     *
     * @param zimlet
     * @throws ZimletException
     */
public static void undeployZimletLocally(String zimlet) throws ServiceException {
    ZimbraLog.zimlet.info("Uninstalling Zimlet " + zimlet + " from LDAP.");
    Provisioning prov = Provisioning.getInstance();
    Zimlet z = prov.getZimlet(zimlet);
    if (z != null) {
        List<Cos> cos = prov.getAllCos();
        for (Cos c : cos) {
            try {
                deactivateZimlet(zimlet, c.getName());
            } catch (Exception e) {
                ZimbraLog.zimlet.warn("Error deactiving Zimlet " + zimlet + " in LDAP.", e);
            }
        }
        try {
            prov.deleteZimlet(zimlet);
        } catch (ServiceException se) {
            z = prov.getZimlet(zimlet);
            if (z != null) {
                ZimbraLog.zimlet.warn("Error deleting Zimlet " + zimlet + " in LDAP.", se);
            }
        }
    }
    ZimletFile zf = sZimlets.get(zimlet);
    if (zf != null) {
        sZimlets.remove(zimlet);
    }
    ZimbraLog.zimlet.info("undeploying zimlet %s", zimlet);
    try {
        File zimletDir = ZimletUtil.getZimletRootDir(zimlet);
        FileUtil.deleteDir(zimletDir);
        ZimbraLog.zimlet.info("zimlet directory %s is deleted", zimletDir.getName());
    } catch (IOException e) {
        throw ServiceException.FAILURE("error occurred when deleting zimlet directory", e);
    } catch (ZimletException e) {
        throw ServiceException.FAILURE("error occurred when deleting zimlet directory", e);
    }
}
Also used : Zimlet(com.zimbra.cs.account.Zimlet) AccountServiceException(com.zimbra.cs.account.AccountServiceException) ServiceException(com.zimbra.common.service.ServiceException) Cos(com.zimbra.cs.account.Cos) IOException(java.io.IOException) File(java.io.File) Provisioning(com.zimbra.cs.account.Provisioning) SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning) AccountServiceException(com.zimbra.cs.account.AccountServiceException) ServiceException(com.zimbra.common.service.ServiceException) IOException(java.io.IOException)

Example 10 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() throws ServiceException {
    Provisioning prov = Provisioning.getInstance();
    List<Zimlet> allzimlets = prov.listAllZimlets();
    return orderZimletsByPriority(allzimlets);
}
Also used : Zimlet(com.zimbra.cs.account.Zimlet) Provisioning(com.zimbra.cs.account.Provisioning) SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning)

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