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