use of com.zimbra.client.ZSearchHit in project zm-mailbox by Zimbra.
the class TestSearchHeaders method testSearchNonTopLevelHeaders.
@Test
public void testSearchNonTopLevelHeaders() throws ServiceException {
ZSearchParams params = new ZSearchParams("\"header search test\" #Content-Transfer-Encoding:8bit");
params.setTypes("message");
ZSearchResult result = mbox.search(params);
boolean found = false;
for (ZSearchHit hit : result.getHits()) {
if (found == false && hit.getId().equals(id)) {
found = true;
}
}
assertTrue(found);
}
use of com.zimbra.client.ZSearchHit in project zm-mailbox by Zimbra.
the class TestDataSource method testPop3.
@Test
public void testPop3() throws Exception {
Account pop3acct = TestUtil.getAccount(TEST_USER_NAME);
ZMailbox pop3mbox = TestUtil.getZMailbox(TEST_USER_NAME);
ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
String pop3DSFolder = NAME_PREFIX + " testPop3 source";
String pop3DSFolderId = createFolderForDataSource(mbox, pop3DSFolder);
String dsId = createPop3DataSource(mbox, pop3acct.getName(), pop3DSFolderId);
String subj = NAME_PREFIX + " testtrashpop3";
addMessage(pop3mbox, subj, "test");
refreshPop3DatasourceData(mbox, dsId);
ZSearchParams params = new ZSearchParams(String.format("subject:\"%s\"", subj));
params.setTypes("MESSAGE");
ZSearchResult result = mbox.search(params);
ZSearchHit hit = result.getHits().get(0);
String id = hit.getId();
try {
mbox.trashMessage(id);
} catch (SoapFaultException sfe) {
fail("SoapFaultException caught when deleting item from Pop3 datasource folder - " + sfe.getMessage());
}
params = new ZSearchParams("in:Trash");
params.setTypes("MESSAGE");
result = mbox.search(params);
List<ZSearchHit> hits = result.getHits();
assertEquals(1, hits.size());
assertEquals(id, hits.get(0).getId());
}
use of com.zimbra.client.ZSearchHit in project zm-mailbox by Zimbra.
the class TestUtil method searchMessageIds.
public static List<String> searchMessageIds(ZMailbox mbox, ZSearchParams params) throws ServiceException {
List<String> msgsIds = new ArrayList<String>();
ZSearchResult results = mbox.search(params);
for (ZSearchHit hit : results.getHits()) {
msgsIds.add(hit.getId());
}
return msgsIds;
}
use of com.zimbra.client.ZSearchHit in project zm-mailbox by Zimbra.
the class ZMailboxUtil method dumpConvSearch.
private void dumpConvSearch(ZSearchResult sr, boolean verbose) {
mConvSearchResult = sr;
if (verbose) {
stdout.println(sr.dump());
return;
}
int offset = sr.getOffset();
int first = offset + 1;
int last = offset + sr.getHits().size();
stdout.printf("num: %d, more: %s%n%n", sr.getHits().size(), sr.hasMore());
int width = colWidth(last);
if (sr.getHits().size() == 0) {
return;
}
int id_len = 4;
for (ZSearchHit hit : sr.getHits()) {
id_len = Math.max(id_len, hit.getId().length());
}
Calendar c = Calendar.getInstance();
String headerFormat = String.format("%%%d.%ds %%%d.%ds %%-20.20s %%-50.50s %%s%%n", width, width, id_len, id_len);
//String headerFormat = String.format("%10.10s %-20.20s %-50.50s %-6.6s %s%n");
String itemFormat = String.format("%%%d.%ds. %%%d.%ds %%-20.20s %%-50.50s %%tD %%<tR%%n", width, width, id_len, id_len);
//String itemFormat = "%10.10s %-20.20s %-50.50s %-6.6s %tD %5$tR%n";
stdout.format(headerFormat, "", "Id", "From", "Subject", "Date");
stdout.format(headerFormat, "", "----------------------------------------------------------------------------------------------------", "--------------------", "--------------------------------------------------", "--------------");
int i = first;
for (ZSearchHit hit : sr.getHits()) {
if (hit instanceof ZMessageHit) {
ZMessageHit mh = (ZMessageHit) hit;
c.setTimeInMillis(mh.getDate());
String sub = mh.getSubject();
String from = mh.getSender().getDisplay();
mIndexToId.put(i, mh.getId());
stdout.format(itemFormat, i++, mh.getId(), from, sub, c);
}
}
stdout.println();
}
use of com.zimbra.client.ZSearchHit in project zm-mailbox by Zimbra.
the class TestPurgeDataSource method doSearch.
private List<ZSearchHit> doSearch(String query) throws ServiceException {
ZSearchParams params = new ZSearchParams(query);
params.setFetch(Fetch.all);
params.setSortBy(SearchSortBy.dateDesc);
ZSearchResult result = mbox.search(params);
List<ZSearchHit> hits = result.getHits();
return hits;
}
Aggregations