if (zid == null || args == null || zid.indexOf('@') < 0) {
if (zid == null || args == null || zid.indexOf('@') < 0)
    private String handleFolder(Map<String,Object> context, Element request, String operation, Element result)    throws ServiceException {        Element action = request.getElement(MailService.E_ACTION);        ZimbraSoapContext lc = getZimbraSoapContext(context);        Mailbox mbox = getRequestedMailbox(lc);        OperationContext octxt = lc.getOperationContext();        ItemId iid = new ItemId(action.getAttribute(MailService.A_ID), lc);        if (operation.equals(OP_EMPTY)) {            mbox.emptyFolder(octxt, iid.getId(), true);        } else if (operation.equals(OP_REFRESH)) {            mbox.synchronizeFolder(octxt, iid.getId());        } else if (operation.equals(OP_IMPORT)) {            String url = action.getAttribute(MailService.A_URL);            mbox.importFeed(octxt, iid.getId(), url, false);        } else if (operation.equals(OP_FREEBUSY)) {            boolean fb = action.getAttributeBool(MailService.A_EXCLUDE_FREEBUSY, false);            mbox.alterTag(octxt, iid.getId(), MailItem.TYPE_FOLDER, Flag.ID_FLAG_EXCLUDE_FREEBUSY, fb);        } else if (operation.equals(OP_CHECK) || operation.equals(OP_UNCHECK)) {            mbox.alterTag(octxt, iid.getId(), MailItem.TYPE_FOLDER, Flag.ID_FLAG_CHECKED, operation.equals(OP_CHECK));        } else if (operation.equals(OP_SET_URL)) {            String url = action.getAttribute(MailService.A_URL, "");            mbox.setFolderUrl(octxt, iid.getId(), url);            if (!url.equals(""))                mbox.synchronizeFolder(octxt, iid.getId());            if (action.getAttribute(MailService.A_EXCLUDE_FREEBUSY, null) != null) {                boolean fb = action.getAttributeBool(MailService.A_EXCLUDE_FREEBUSY, false);                mbox.alterTag(octxt, iid.getId(), MailItem.TYPE_FOLDER, Flag.ID_FLAG_EXCLUDE_FREEBUSY, fb);            }        } else if (operation.equals(OP_RENAME)) {            String name = action.getAttribute(MailService.A_NAME);            mbox.renameFolder(octxt, iid.getId(), name);        } else if (operation.equals(OP_REVOKE)) {        	String zid = action.getAttribute(MailService.A_ZIMBRA_ID);            mbox.revokeAccess(octxt, iid.getId(), zid);        } else if (operation.equals(OP_GRANT)) {            Element grant = action.getElement(MailService.E_GRANT);            boolean inherit = grant.getAttributeBool(MailService.A_INHERIT, false);            short rights = ACL.stringToRights(grant.getAttribute(MailService.A_RIGHTS));            byte gtype   = stringToType(grant.getAttribute(MailService.A_GRANT_TYPE));            String zid   = grant.getAttribute(MailService.A_ZIMBRA_ID, null);            String args   = grant.getAttribute(MailService.A_ARGS, null);            NamedEntry nentry = null;            if (gtype == ACL.GRANTEE_AUTHUSER)                zid = ACL.GUID_AUTHUSER;            else if (gtype == ACL.GRANTEE_PUBLIC)                zid = ACL.GUID_PUBLIC;            else if (gtype == ACL.GRANTEE_GUEST) {                zid = grant.getAttribute(MailService.A_DISPLAY);                if (zid == null || args == null || zid.indexOf('@') < 0) {                	throw ServiceException.INVALID_REQUEST("invalid guest id or password", null);                }            }            else if (zid != null)            	nentry = lookupGranteeByZimbraId(zid, gtype);            else {            	nentry = lookupGranteeByName(grant.getAttribute(MailService.A_DISPLAY), gtype, lc);            	zid = nentry.getId();            	if (gtype == ACL.GRANTEE_USER && nentry instanceof DistributionList)            		gtype = ACL.GRANTEE_GROUP;            }                        mbox.grantAccess(octxt, iid.getId(), zid, gtype, rights, inherit, args);            // kinda hacky -- return the zimbra id and name of the grantee in the response            result.addAttribute(MailService.A_ZIMBRA_ID, zid);            if (nentry != null)                result.addAttribute(MailService.A_DISPLAY, nentry.getName());        } else if (operation.equals(OP_UPDATE)) {            // duplicating code from ItemAction.java for now...            String newName = action.getAttribute(MailService.A_NAME, null);            ItemId iidFolder = new ItemId(action.getAttribute(MailService.A_FOLDER, "-1"), lc);            if (!iidFolder.belongsTo(mbox))                throw ServiceException.INVALID_REQUEST("cannot move folder between mailboxes", null);            String flags = action.getAttribute(MailService.A_FLAGS, null);            byte color = (byte) action.getAttributeLong(MailService.A_COLOR, -1);            ACL acl = null;            Element eAcl = action.getOptionalElement(MailService.E_ACL);            if (eAcl != null) {                acl = new ACL();                for (Element grant : eAcl.listElements(MailService.E_GRANT)) {                    String zid   = grant.getAttribute(MailService.A_ZIMBRA_ID);                    byte gtype   = stringToType(grant.getAttribute(MailService.A_GRANT_TYPE));                    short rights = ACL.stringToRights(grant.getAttribute(MailService.A_RIGHTS));                    boolean inherit = grant.getAttributeBool(MailService.A_INHERIT, false);                    String args   = grant.getAttribute(MailService.A_ARGS, null);                    acl.grantAccess(zid, gtype, rights, inherit, args);                }            }            if (flags != null)                mbox.setTags(octxt, iid.getId(), MailItem.TYPE_FOLDER, flags, null, null);            if (color >= 0)                mbox.setColor(octxt, iid.getId(), MailItem.TYPE_FOLDER, color);            if (acl != null)                mbox.setPermissions(octxt, iid.getId(), acl);            if (iidFolder.getId() > 0)                mbox.move(octxt, iid.getId(), MailItem.TYPE_FOLDER, iidFolder.getId(), null);            if (newName != null)                mbox.renameFolder(octxt, iid.getId(), newName);        } else {            throw ServiceException.INVALID_REQUEST("unknown operation: " + operation, null);        }        return lc.formatItemId(iid);    }