queueElem.addAttribute(AdminService.A_MORE, more);
queueElem.addAttribute(AdminService.A_SCAN, stillScanning); queueElem.addAttribute(AdminService.A_MORE, ((offset + limit) < rmq.getNumMessages()));
	public Element handle(Element request, Map context) throws ServiceException {        ZimbraContext lc = getZimbraContext(context);        Provisioning prov = Provisioning.getInstance();                Element serverElem = request.getElement(AdminService.E_SERVER);        String serverName = serverElem.getAttribute(AdminService.A_NAME);                Server server = prov.getServerByName(serverName);        if (server == null) {            throw ServiceException.INVALID_REQUEST("server with name " + serverName + " could not be found", null);        }                Element queueElem = serverElem.getElement(AdminService.E_QUEUE);        String queueName = queueElem.getAttribute(AdminService.A_NAME);        boolean scan = queueElem.getAttributeBool(AdminService.A_SCAN, false);        long waitMillis = (queueElem.getAttributeLong(AdminService.A_WAIT, MAIL_QUEUE_SCAN_DEFUALT_WAIT_SECONDS)) * 1000;                Element queryElem = queueElem.getElement(AdminService.E_QUERY);        int offset = (int)queryElem.getAttributeLong(AdminService.A_OFFSET, 0);        int limit = (int)queryElem.getAttributeLong(AdminService.A_LIMIT, MAIL_QUEUE_QUERY_DEFAULT_LIMIT);        String queryText = queryElem.getText();                RemoteMailQueue rmq = RemoteMailQueue.getRemoteMailQueue(server, queueName, scan);        boolean more = rmq.waitForScan(waitMillis);        RemoteMailQueue.SearchResult sr = rmq.search(queryText, offset, limit);                Element response = lc.createElement(AdminService.GET_MAIL_QUEUE_RESPONSE);        serverElem = response.addElement(AdminService.E_SERVER);        serverElem.addAttribute(AdminService.A_NAME, serverName);             queueElem = serverElem.addElement(AdminService.E_QUEUE);        queueElem.addAttribute(AdminService.A_NAME, queueName);        queueElem.addAttribute(AdminService.A_TIME, rmq.getScanTime());        queueElem.addAttribute(AdminService.A_MORE, more);                for (QueueAttr attr : sr.sitems.keySet()) {            List<SummaryItem> slist = sr.sitems.get(attr);            Collections.sort(slist);            Element qsElem = queueElem.addElement(AdminService.A_QUEUE_SUMMARY);            qsElem.addAttribute(AdminService.A_TYPE, attr.toString());            int i = 0;            for (SummaryItem sitem : slist) {                i++;                if (i > MAIL_QUEUE_SUMMARY_CUTOFF) {                    break;                }                Element qsiElem = qsElem.addElement(AdminService.A_QUEUE_SUMMARY_ITEM);                qsiElem.addAttribute(AdminService.A_N, sitem.count());                qsiElem.addAttribute(AdminService.A_T, sitem.term());            }        }        for (Map<QueueAttr,String> qitem : sr.qitems) {            Element qiElem = queueElem.addElement(AdminService.A_QUEUE_ITEM);            for (QueueAttr attr : qitem.keySet()) {                qiElem.addAttribute(attr.toString(), qitem.get(attr));            }        }	    return response;	}