if (mLog.isDebugEnabled()) mLog.debug("Searching " + queryText);
    private static void extract(String authToken, Account account, Server server, String folder, File outdir) throws ServiceException, HttpException, SoapFaultException, IOException {        String soapURL = getSoapURL(server, false);        URL restURL = getServerURL(server, false);        HttpClient hc = new HttpClient();        HttpState state = new HttpState();        GetMethod gm = new GetMethod();        gm.setFollowRedirects(true);        Cookie authCookie = new Cookie(restURL.getHost(), ZimbraServlet.COOKIE_ZM_AUTH_TOKEN, authToken, "/", -1, false);        state.addCookie(authCookie);        hc.setState(state);        hc.getHostConfiguration().setHost(restURL.getHost(), restURL.getPort(), Protocol.getProtocol(restURL.getProtocol()));        hc.getHttpConnectionManager().getParams().setConnectionTimeout(30000);        if (mLog.isInfoEnabled()) mLog.info("Mailbox requests to: " + restURL);                boolean haveMore = true;        int offset = 0;        while (haveMore) {            SoapHttpTransport transport = new SoapHttpTransport(soapURL);            transport.setRetryCount(1);            transport.setTimeout(0);            transport.setAuthToken(authToken);            Element searchReq = new Element.XMLElement(MailService.SEARCH_REQUEST);            String queryText = "in:" + folder;            searchReq.setText(queryText);            searchReq.addAttribute(MailService.A_SEARCH_TYPES, TYPE_MESSAGE);            searchReq.addAttribute(MailService.A_QUERY_OFFSET, offset);            try {                if (mLog.isDebugEnabled()) mLog.debug("Searching " + queryText);                if (mLog.isDebugEnabled()) mLog.debug(searchReq.prettyPrint());                Element searchResp = transport.invoke(searchReq, false, true, true, account.getId());                if (mLog.isDebugEnabled()) mLog.debug(searchResp.prettyPrint());                                for (Iterator<Element> iter = searchResp.elementIterator(MailService.E_MSG); iter.hasNext();) {                    offset++;                    Element e = iter.next();                    String mid = e.getAttribute(MailService.A_ID);                    if (mid == null) {                        mLog.warn("null message id SOAP response");                        continue;                    }                    String path = "/service/user/" + account.getName() + "/" + folder + "?id=" + mid;                    extractMessage(hc, gm, offset, path, outdir);                }                                haveMore = false;                String more = searchResp.getAttribute(MailService.A_QUERY_MORE);                if (more != null && more.length() > 0) {                    try {                        int m = Integer.parseInt(more);                        if (m > 0) {                            haveMore = true;                        }                    } catch (NumberFormatException nfe) {                        mLog.warn("more flag from server not a number: " + more, nfe);                    }                }                            } finally {                gm.releaseConnection();            }        }    }