HashMap amap = new HashMap();
HashMap<String, Object> amap = new HashMap<String, Object>();
    public void renameAccount(String zimbraId, String newName) throws ServiceException {                DirContext ctxt = null;        try {            ctxt = LdapUtil.getDirContext(true);                        LdapAccount acc = (LdapAccount) getAccountById(zimbraId, ctxt);            if (acc == null)                throw AccountServiceException.NO_SUCH_ACCOUNT(zimbraId);            String oldEmail = acc.getName();                        newName = newName.toLowerCase().trim();            String[] parts = EmailUtil.getLocalPartAndDomain(newName);            if (parts == null)                throw ServiceException.INVALID_REQUEST("bad value for newName", null);            String newLocal = parts[0];            String newDomain = parts[1];                        Domain domain = getDomainByName(newDomain, ctxt);            if (domain == null)                throw AccountServiceException.NO_SUCH_DOMAIN(newDomain);                        String newDn = emailToDN(newLocal,domain.getName());            ctxt.rename(acc.mDn, newDn);            renameAddressInAllDistributionLists(oldEmail, newName); // doesn't throw exceptions, just logs                        // remove old account from cache            sAccountCache.remove(acc);            acc = (LdapAccount) getAccountById(zimbraId,ctxt);            HashMap amap = new HashMap();            amap.put(Provisioning.A_zimbraMailDeliveryAddress, newName);            String mail[] = acc.getMultiAttr(Provisioning.A_mail);            if (mail.length == 0) {                amap.put(Provisioning.A_mail, newName);            } else {                // not the most efficient, but renames dont' happen often                mail = LdapUtil.removeMultiValue(mail, oldEmail);                mail = addMultiValue(mail, newName);                amap.put(Provisioning.A_mail, mail);            }            // this is non-atomic. i.e., rename could succeed and updating zimbraMailDeliveryAddress            // could fail. So catch service exception here and log error                        try {                acc.modifyAttrsInternal(ctxt, amap);            } catch (ServiceException e) {                ZimbraLog.account.error("account renamed to "+newName+                        " but failed to update zimbraMailDeliveryAddress", e);                throw ServiceException.FAILURE("unable to rename account: "+zimbraId, e);            }        } catch (NameAlreadyBoundException nabe) {            throw AccountServiceException.ACCOUNT_EXISTS(newName);                    } catch (NamingException e) {            throw ServiceException.FAILURE("unable to rename account: "+zimbraId, e);        } finally {            LdapUtil.closeContext(ctxt);        }    }