Search in sources :

Example 6 with ResourceProperty

use of com.zimbra.cs.dav.property.ResourceProperty in project zm-mailbox by Zimbra.

the class RemoteCollection method getMountpointTarget.

protected void getMountpointTarget(DavContext ctxt) throws ServiceException {
    ZAuthToken zat = AuthProvider.getAuthToken(ctxt.getAuthAccount()).toZAuthToken();
    ZMailbox zmbx = getRemoteMailbox(zat, mRemoteOwnerId);
    if (zmbx == null)
        return;
    ZFolder folder = zmbx.getFolder(new ItemId(mRemoteOwnerId, mRemoteId).toString(mOwnerId));
    if (folder == null)
        return;
    mCtag = CtagInfo.makeCtag(folder);
    setProperty(DavElements.E_GETCTAG, mCtag);
    mRights = ACL.stringToRights(folder.getEffectivePerms());
    addProperty(Acl.getCurrentUserPrivilegeSet(mRights));
    addProperty(Acl.getMountpointTargetPrivilegeSet(mRights));
    String targetUrl = UrlNamespace.getResourceUrl(Provisioning.getInstance().get(Key.AccountBy.id, mRemoteOwnerId), folder.getPath() + "/");
    ResourceProperty mp = new ResourceProperty(DavElements.E_MOUNTPOINT_TARGET_URL);
    mp.addChild(DavElements.E_HREF).setText(targetUrl);
    addProperty(mp);
}
Also used : ResourceProperty(com.zimbra.cs.dav.property.ResourceProperty) ZMailbox(com.zimbra.client.ZMailbox) ZFolder(com.zimbra.client.ZFolder) ZAuthToken(com.zimbra.common.auth.ZAuthToken) ItemId(com.zimbra.cs.service.util.ItemId)

Example 7 with ResourceProperty

use of com.zimbra.cs.dav.property.ResourceProperty in project zm-mailbox by Zimbra.

the class DavResource method getPropertiesAsText.

protected String getPropertiesAsText(DavContext ctxt) throws IOException {
    Element e = org.dom4j.DocumentHelper.createElement(DavElements.E_PROP);
    for (ResourceProperty rp : mProps.values()) rp.toElement(ctxt, e, false);
    OutputFormat format = OutputFormat.createPrettyPrint();
    format.setTrimText(false);
    format.setOmitEncoding(false);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    XMLWriter writer = new XMLWriter(baos, format);
    writer.write(e);
    return new String(baos.toByteArray());
}
Also used : ResourceProperty(com.zimbra.cs.dav.property.ResourceProperty) Element(org.dom4j.Element) OutputFormat(org.dom4j.io.OutputFormat) ByteArrayOutputStream(java.io.ByteArrayOutputStream) XMLWriter(org.dom4j.io.XMLWriter)

Aggregations

ResourceProperty (com.zimbra.cs.dav.property.ResourceProperty)7 Element (org.dom4j.Element)4 DavException (com.zimbra.cs.dav.DavException)3 QName (org.dom4j.QName)2 ZFolder (com.zimbra.client.ZFolder)1 ZMailbox (com.zimbra.client.ZMailbox)1 ZAuthToken (com.zimbra.common.auth.ZAuthToken)1 Pair (com.zimbra.common.util.Pair)1 RequestProp (com.zimbra.cs.dav.DavContext.RequestProp)1 DavResource (com.zimbra.cs.dav.resource.DavResource)1 PropStat (com.zimbra.cs.dav.service.DavResponse.PropStat)1 ItemId (com.zimbra.cs.service.util.ItemId)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Iterator (java.util.Iterator)1 OutputFormat (org.dom4j.io.OutputFormat)1 XMLWriter (org.dom4j.io.XMLWriter)1