Search in sources :

Example 6 with Collection

use of com.zimbra.cs.dav.resource.Collection in project zm-mailbox by Zimbra.

the class Put method handle.

@Override
public void handle(DavContext ctxt) throws DavException, IOException {
    String user = ctxt.getUser();
    String name = ctxt.getItem();
    if (user == null || name == null)
        throw new DavException("invalid uri", HttpServletResponse.SC_NOT_ACCEPTABLE, null);
    Collection col = UrlNamespace.getCollectionAtUrl(ctxt, ctxt.getPath());
    DavResource rs = col.createItem(ctxt, name);
    if (rs.isNewlyCreated())
        ctxt.setStatus(HttpServletResponse.SC_CREATED);
    else
        ctxt.setStatus(HttpServletResponse.SC_NO_CONTENT);
    if (rs.hasEtag()) {
        ctxt.getResponse().setHeader(DavProtocol.HEADER_ETAG, rs.getEtag());
        ctxt.getResponse().setHeader(ETagHeaderFilter.ZIMBRA_ETAG_HEADER, rs.getEtag());
    }
}
Also used : DavResource(com.zimbra.cs.dav.resource.DavResource) DavException(com.zimbra.cs.dav.DavException) Collection(com.zimbra.cs.dav.resource.Collection)

Aggregations

Collection (com.zimbra.cs.dav.resource.Collection)6 DavException (com.zimbra.cs.dav.DavException)5 DavResource (com.zimbra.cs.dav.resource.DavResource)3 Document (org.dom4j.Document)3 Element (org.dom4j.Element)3 ZMountpoint (com.zimbra.client.ZMountpoint)1 ServiceException (com.zimbra.common.service.ServiceException)1 XmlParseException (com.zimbra.common.soap.XmlParseException)1 ResourceTypeProperty (com.zimbra.cs.dav.property.ResourceTypeProperty)1 CalendarCollection (com.zimbra.cs.dav.resource.CalendarCollection)1 MailItemResource (com.zimbra.cs.dav.resource.MailItemResource)1 DavResponse (com.zimbra.cs.dav.service.DavResponse)1 MailItem (com.zimbra.cs.mailbox.MailItem)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 List (java.util.List)1