use of com.zimbra.cs.dav.resource.AddressObject in project zm-mailbox by Zimbra.
the class AddressbookQuery method handle.
public void handle(DavContext ctxt) throws DavException, ServiceException {
DavResource rsc = ctxt.getRequestedResource();
if (!(rsc instanceof AddressbookCollection))
throw new DavException("not an addressbook resource", HttpServletResponse.SC_BAD_REQUEST, null);
Element query = ctxt.getRequestMessage().getRootElement();
if (!query.getQName().equals(DavElements.CardDav.E_ADDRESSBOOK_QUERY))
throw new DavException("msg " + query.getName() + " is not addressbook-query", HttpServletResponse.SC_BAD_REQUEST, null);
Element f = query.element(DavElements.CardDav.E_FILTER);
if (f == null)
throw new DavException("msg " + query.getName() + " is missing filter", HttpServletResponse.SC_BAD_REQUEST, null);
Filter filter = new Filter.PropFilter((Element) f.elementIterator().next());
Collection<AddressObject> contacts = filter.match(ctxt, ((AddressbookCollection) rsc));
RequestProp reqProp = ctxt.getRequestProp();
DavResponse resp = ctxt.getDavResponse();
resp.createResponse(ctxt);
for (AddressObject c : contacts) {
resp.addResource(ctxt, c, reqProp, false);
}
}
Aggregations