use of com.zimbra.cs.dav.resource.DavResource 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);
}
}
use of com.zimbra.cs.dav.resource.DavResource in project zm-mailbox by Zimbra.
the class CalendarMultiget method handle.
public void handle(DavContext ctxt) throws ServiceException, DavException {
Element query = ctxt.getRequestMessage().getRootElement();
if (!query.getQName().equals(DavElements.E_CALENDAR_MULTIGET))
throw new DavException("msg " + query.getName() + " is not calendar-multiget", HttpServletResponse.SC_BAD_REQUEST, null);
DavResponse resp = ctxt.getDavResponse();
ArrayList<String> hrefs = new ArrayList<String>();
for (Object obj : query.elements(DavElements.E_HREF)) if (obj instanceof Element)
hrefs.add(((Element) obj).getText());
long ts = System.currentTimeMillis();
DavResource reqResource = ctxt.getRequestedResource();
if (!(reqResource instanceof CalendarCollection))
throw new DavException("requested resource is not a calendar collection", HttpServletResponse.SC_BAD_REQUEST, null);
CalendarCollection calResource = (CalendarCollection) reqResource;
long now = System.currentTimeMillis();
ZimbraLog.dav.debug("GetRequestedResource: " + (now - ts) + "ms");
RequestProp reqProp = ctxt.getRequestProp();
for (DavResource rs : calResource.getAppointmentsByUids(ctxt, hrefs)) resp.addResource(ctxt, rs, reqProp, false);
ts = now;
now = System.currentTimeMillis();
ZimbraLog.dav.debug("multiget: " + (now - ts) + "ms");
}
use of com.zimbra.cs.dav.resource.DavResource in project zm-mailbox by Zimbra.
the class Options method handle.
public void handle(DavContext ctxt) throws DavException, IOException, ServiceException {
HttpServletResponse resp = ctxt.getResponse();
DavServlet.setAllowHeader(resp);
if (ctxt.isMsft())
resp.addHeader(DavProtocol.HEADER_MS_AUTHOR_VIA, "DAV");
resp.setContentLength(0);
try {
DavResource rs = ctxt.getRequestedResource();
ctxt.setDavCompliance(DavProtocol.getComplianceString(rs.getComplianceList()));
} catch (Exception e) {
}
sendResponse(ctxt);
}
use of com.zimbra.cs.dav.resource.DavResource in project zm-mailbox by Zimbra.
the class PropPatch method handle.
@Override
public void handle(DavContext ctxt) throws DavException, IOException, ServiceException {
if (!ctxt.hasRequestMessage()) {
throw new DavException("empty request", HttpServletResponse.SC_BAD_REQUEST);
}
Document req = ctxt.getRequestMessage();
Element top = req.getRootElement();
if (!top.getName().equals(DavElements.P_PROPERTYUPDATE)) {
throw new DavException("msg " + top.getName() + " not allowed in PROPPATCH", HttpServletResponse.SC_BAD_REQUEST, null);
}
DavResource resource = ctxt.getRequestedResource();
handlePropertyUpdate(ctxt, top, resource, false, PROPPATCH);
DavResponse resp = ctxt.getDavResponse();
resp.addResource(ctxt, resource, ctxt.getResponseProp(), false);
sendResponse(ctxt);
}
use of com.zimbra.cs.dav.resource.DavResource in project zm-mailbox by Zimbra.
the class DavResponse method addResources.
public void addResources(DavContext ctxt, Collection<DavResource> rss, DavContext.RequestProp props) throws DavException {
ctxt.setStatus(DavProtocol.STATUS_MULTI_STATUS);
boolean first = true;
for (DavResource rs : rss) {
if (first)
ctxt.setDavCompliance(DavProtocol.getComplianceString(rs.getComplianceList()));
addResourceTo(ctxt, rs, props, false);
first = false;
}
}
Aggregations