Search in sources :

Example 11 with ZSearchHit

use of com.zimbra.client.ZSearchHit in project zm-mailbox by Zimbra.

the class TestUtil method deleteMessages.

private static void deleteMessages(ZMailbox mbox, String query) throws ServiceException {
    // Delete messages
    ZSearchParams params = new ZSearchParams(query);
    params.setTypes(ZSearchParams.TYPE_MESSAGE);
    List<ZSearchHit> hits = mbox.search(params).getHits();
    if (hits.size() > 0) {
        List<String> ids = new ArrayList<String>();
        for (ZSearchHit hit : hits) {
            ids.add(hit.getId());
        }
        mbox.deleteMessage(StringUtil.join(",", ids));
    }
}
Also used : ZSearchHit(com.zimbra.client.ZSearchHit) ZSearchParams(com.zimbra.client.ZSearchParams) ArrayList(java.util.ArrayList)

Example 12 with ZSearchHit

use of com.zimbra.client.ZSearchHit in project zm-mailbox by Zimbra.

the class TestUtil method search.

public static List<ZMessage> search(ZMailbox mbox, ZSearchParams params) throws ServiceException {
    List<ZMessage> msgs = new ArrayList<ZMessage>();
    for (ZSearchHit hit : mbox.search(params).getHits()) {
        ZGetMessageParams msgParams = new ZGetMessageParams();
        msgParams.setId(hit.getId());
        msgs.add(mbox.getMessage(msgParams));
    }
    return msgs;
}
Also used : ZMessage(com.zimbra.client.ZMessage) ZSearchHit(com.zimbra.client.ZSearchHit) ZGetMessageParams(com.zimbra.client.ZGetMessageParams) ArrayList(java.util.ArrayList)

Example 13 with ZSearchHit

use of com.zimbra.client.ZSearchHit in project zm-mailbox by Zimbra.

the class TestUtil method search.

public static List<String> search(ZMailbox mbox, String query, String type) throws ServiceException {
    List<String> ids = new ArrayList<String>();
    ZSearchParams params = new ZSearchParams(query);
    params.setTypes(type);
    for (ZSearchHit hit : mbox.search(params).getHits()) {
        ids.add(hit.getId());
    }
    return ids;
}
Also used : ZSearchHit(com.zimbra.client.ZSearchHit) ZSearchParams(com.zimbra.client.ZSearchParams) ArrayList(java.util.ArrayList)

Aggregations

ZSearchHit (com.zimbra.client.ZSearchHit)13 ZSearchParams (com.zimbra.client.ZSearchParams)9 ZSearchResult (com.zimbra.client.ZSearchResult)8 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)4 ZMessageHit (com.zimbra.client.ZMessageHit)3 ZMountpoint (com.zimbra.client.ZMountpoint)2 Calendar (java.util.Calendar)2 ZAppointmentHit (com.zimbra.client.ZAppointmentHit)1 ZContactHit (com.zimbra.client.ZContactHit)1 ZConversationHit (com.zimbra.client.ZConversationHit)1 ZDocument (com.zimbra.client.ZDocument)1 ZDocumentHit (com.zimbra.client.ZDocumentHit)1 ZGetMessageParams (com.zimbra.client.ZGetMessageParams)1 ZMailbox (com.zimbra.client.ZMailbox)1 ZMessage (com.zimbra.client.ZMessage)1 SoapFaultException (com.zimbra.common.soap.SoapFaultException)1 Account (com.zimbra.cs.account.Account)1