public Element handle(Element request, Map<String, Object> context) throws ServiceException { ZimbraSoapContext zsc = getZimbraSoapContext(context); Provisioning prov = Provisioning.getInstance(); String id = request.getAttribute(AdminConstants.E_ID); DistributionList distributionList = prov.get(DistributionListBy.id, id); if (distributionList == null) throw AccountServiceException.NO_SUCH_DISTRIBUTION_LIST(id); checkDistributionListRight(zsc, distributionList, Admin.R_deleteDistributionList); prov.deleteDistributionList(distributionList.getId()); ZimbraLog.security.info( ZimbraLog.encodeAttrs( new String[] { "cmd", "DeleteDistributionList", "name", distributionList.getName(), "id", distributionList.getId() })); Element response = zsc.createElement(AdminConstants.DELETE_DISTRIBUTION_LIST_RESPONSE); return response; }
public static String getTargetDomainName(Provisioning prov, Entry target) throws ServiceException { if (target instanceof CalendarResource) { CalendarResource cr = (CalendarResource) target; return cr.getDomainName(); } else if (target instanceof Account) { Account acct = (Account) target; return acct.getDomainName(); } else if (target instanceof DistributionList) { DistributionList dl = (DistributionList) target; return dl.getDomainName(); } else return null; }