use of com.zimbra.soap.mail.message.SearchActionRequest in project zm-mailbox by Zimbra.
the class SearchAction method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Mailbox mbox = getRequestedMailbox(zsc);
OperationContext octxt = getOperationContext(zsc, context);
SearchActionRequest req = zsc.elementToJaxb(request);
SearchRequest searchRequest = req.getSearchRequest();
Account acct = mbox.getAccount();
Server server = Provisioning.getInstance().getServer(acct);
String url = URLUtil.getSoapURL(server, false);
com.zimbra.soap.mail.message.SearchResponse resp = null;
Element searchResponse;
SoapHttpTransport transport = new SoapHttpTransport(url);
transport.setTargetAcctId(acct.getId());
try {
transport.setAuthToken(octxt.getAuthToken().getEncoded());
searchResponse = transport.invokeWithoutSession(JaxbUtil.jaxbToElement(searchRequest));
resp = (com.zimbra.soap.mail.message.SearchResponse) JaxbUtil.elementToJaxb(searchResponse);
List<SearchHit> searchHits = resp.getSearchHits();
BulkAction action = req.getBulkAction();
performAction(action, searchRequest, searchHits, mbox, octxt);
} catch (AuthTokenException | IOException | HttpException e) {
throw ServiceException.FAILURE("Failed to execute search request", e);
}
SearchActionResponse searchActionResponse = new SearchActionResponse();
return zsc.jaxbToElement(searchActionResponse);
}
Aggregations