}
    public Element handle(Element request, Map context) throws ServiceException {        String n = request.getAttribute(AccountService.E_NAME);        ZimbraContext lc = getZimbraContext(context);        Element response = lc.createElement(AccountService.SEARCH_GAL_RESPONSE);        Account acct = getRequestedAccount(getZimbraContext(context));        while (n.endsWith("*"))            n = n.substring(0, n.length()-1);        String typeStr = request.getAttribute(AdminService.A_TYPE, "all");        Provisioning.GAL_SEARCH_TYPE type;        if (typeStr.equals("all"))            type = Provisioning.GAL_SEARCH_TYPE.ALL;        else if (typeStr.equals("account"))            type = Provisioning.GAL_SEARCH_TYPE.USER_ACCOUNT;        else if (typeStr.equals("resource"))            type = Provisioning.GAL_SEARCH_TYPE.CALENDAR_RESOURCE;        else            throw ServiceException.INVALID_REQUEST(                    "Invalid search type: " + typeStr, null);        SearchGalResult result = acct.getDomain().searchGal(n, type, null);        List contacts = result.matches;        for (Iterator it = contacts.iterator(); it.hasNext();) {            GalContact contact = (GalContact) it.next();            addContact(response, contact);        }        return response;    }