Search in sources :

Example 11 with SearchRequest

use of com.zimbra.soap.mail.message.SearchRequest in project zm-mailbox by Zimbra.

the class TestJaxb method findMatchingAppointment.

private AppointmentHitInfo findMatchingAppointment(ZMailbox mbox, Date startDate, Date endDate, String subject) throws ServiceException {
    SearchRequest searchRequest = new SearchRequest();
    searchRequest.setSortBy("none");
    searchRequest.setLimit(500);
    searchRequest.setLocale("en_US");
    searchRequest.setCalItemExpandStart(startDate.getTime() - 1000);
    searchRequest.setCalItemExpandEnd(endDate.getTime() + 1000);
    searchRequest.setSearchTypes("appointment");
    searchRequest.setOffset(0);
    searchRequest.setQuery(subject);
    SearchResponse searchResp = mbox.invokeJaxb(searchRequest);
    Assert.assertNotNull("JAXB SearchResponse object", searchResp);
    List<SearchHit> hits = searchResp.getSearchHits();
    Assert.assertNotNull("JAXB SearchResponse hits", hits);
    Assert.assertEquals("JAXB SearchResponse hits", 1, hits.size());
    return (AppointmentHitInfo) hits.get(0);
}
Also used : SearchRequest(com.zimbra.soap.mail.message.SearchRequest) SearchHit(com.zimbra.soap.type.SearchHit) AppointmentHitInfo(com.zimbra.soap.mail.type.AppointmentHitInfo) SearchResponse(com.zimbra.soap.mail.message.SearchResponse)

Aggregations

SearchRequest (com.zimbra.soap.mail.message.SearchRequest)11 SearchResponse (com.zimbra.soap.mail.message.SearchResponse)10 SearchHit (com.zimbra.soap.type.SearchHit)10 Test (org.junit.Test)9 Account (com.zimbra.cs.account.Account)7 ZMailbox (com.zimbra.client.ZMailbox)5 Mailbox (com.zimbra.cs.mailbox.Mailbox)4 DeliveryOptions (com.zimbra.cs.mailbox.DeliveryOptions)3 Message (com.zimbra.cs.mailbox.Message)3 Element (com.zimbra.common.soap.Element)2 SoapTransport (com.zimbra.common.soap.SoapTransport)2 AppointmentHitInfo (com.zimbra.soap.mail.type.AppointmentHitInfo)2 Header (org.apache.commons.httpclient.Header)2 HttpClient (org.apache.commons.httpclient.HttpClient)2 ByteArrayRequestEntity (org.apache.commons.httpclient.methods.ByteArrayRequestEntity)2 GetMethod (org.apache.commons.httpclient.methods.GetMethod)2 PostMethod (org.apache.commons.httpclient.methods.PostMethod)2 ZInvite (com.zimbra.client.ZInvite)1 ZMessage (com.zimbra.client.ZMessage)1 ZAuthToken (com.zimbra.common.auth.ZAuthToken)1