use of com.zimbra.cs.dav.DavException in project zm-mailbox by Zimbra.
the class ExpandProperty method handle.
@Override
public void handle(DavContext ctxt) throws ServiceException, DavException {
Element query = ctxt.getRequestMessage().getRootElement();
if (!query.getQName().equals(DavElements.E_EXPAND_PROPERTY))
throw new DavException("msg " + query.getName() + " is not expand-property", HttpServletResponse.SC_BAD_REQUEST, null);
DavResource rs = ctxt.getRequestedResource();
ctxt.setDavCompliance(DavProtocol.getComplianceString(rs.getComplianceList()));
ctxt.setStatus(DavProtocol.STATUS_MULTI_STATUS);
Element resp = ctxt.getDavResponse().getTop(DavElements.E_MULTISTATUS).addElement(DavElements.E_RESPONSE);
expandProperties(ctxt, rs, query, resp);
}
use of com.zimbra.cs.dav.DavException in project zm-mailbox by Zimbra.
the class FreeBusyQuery method handle.
public void handle(DavContext ctxt) throws DavException, IOException, ServiceException {
Element query = ctxt.getRequestMessage().getRootElement();
if (!query.getQName().equals(DavElements.E_FREE_BUSY_QUERY))
throw new DavException("msg " + query.getName() + " is not free-busy-query", HttpServletResponse.SC_BAD_REQUEST, null);
Element trElem = query.element(DavElements.E_TIME_RANGE);
if (trElem == null)
throw new DavException("need time-range", HttpServletResponse.SC_BAD_REQUEST, null);
TimeRange timeRange = new TimeRange(trElem);
DavResource rs = ctxt.getRequestedResource();
if (!(rs instanceof CalendarCollection))
throw new DavException("not a calendar collection", HttpServletResponse.SC_BAD_REQUEST, null);
try {
String freebusy = ((CalendarCollection) rs).getFreeBusyReport(ctxt, timeRange);
HttpServletResponse resp = ctxt.getResponse();
resp.setContentType(MimeConstants.CT_TEXT_CALENDAR);
resp.getOutputStream().write(freebusy.getBytes("UTF-8"));
ctxt.responseSent();
} catch (ServiceException se) {
throw new DavException("can't get freebusy report", HttpServletResponse.SC_INTERNAL_SERVER_ERROR, se);
}
}
use of com.zimbra.cs.dav.DavException in project zm-mailbox by Zimbra.
the class AclReports method handle.
@Override
public void handle(DavContext ctxt) throws DavException, ServiceException {
ctxt.setStatus(DavProtocol.STATUS_MULTI_STATUS);
Element query = ctxt.getRequestMessage().getRootElement();
if (query.getQName().equals(DavElements.E_PRINCIPAL_PROPERTY_SEARCH))
handlePrincipalPropertySearch(ctxt, query);
else if (query.getQName().equals(DavElements.E_ACL_PRINCIPAL_PROP_SET))
handleAclPrincipalPropSet(ctxt, query);
else if (query.getQName().equals(DavElements.E_PRINCIPAL_MATCH))
handlePrincipalMatch(ctxt, query);
else if (query.getQName().equals(DavElements.E_PRINCIPAL_SEARCH_PROPERTY_SET))
handlePrincipalSearchPropertySet(ctxt, query);
else
throw new DavException("msg " + query.getName() + " is not an ACL report", HttpServletResponse.SC_BAD_REQUEST);
}
use of com.zimbra.cs.dav.DavException 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.DavException 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");
}
Aggregations