Search in sources :

Example 1 with UrlComponents

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

the class DavContext method getInternalDestinationUrl.

private String getInternalDestinationUrl(String destinationUrl) throws ServiceException, DavException {
    UrlComponents uc = UrlNamespace.parseUrl(destinationUrl);
    Account targetAcct = Provisioning.getInstance().getAccountByName(uc.user);
    if (targetAcct == null)
        return destinationUrl;
    ZMailbox zmbx = getZMailbox(targetAcct);
    ItemId targetRoot = new ItemId("", Mailbox.ID_FOLDER_USER_ROOT);
    Pair<ZFolder, String> match = zmbx.getFolderByPathLongestMatch(targetRoot.toString(), uc.path);
    ZFolder targetFolder = match.getFirst();
    if (targetFolder instanceof ZMountpoint) {
        ZMountpoint zmp = (ZMountpoint) targetFolder;
        ItemId target = new ItemId(zmp.getOwnerId(), Integer.parseInt(zmp.getRemoteId()));
        Account acct = Provisioning.getInstance().getAccountById(zmp.getOwnerId());
        ZMailbox targetZmbx = getZMailbox(acct);
        ZFolder f = targetZmbx.getFolderById(target.toString());
        String extraPath = match.getSecond();
        destinationUrl = DavServlet.DAV_PATH + "/" + acct.getName() + f.getPath() + ((extraPath != null) ? "/" + extraPath : "");
    }
    return destinationUrl;
}
Also used : ZMountpoint(com.zimbra.client.ZMountpoint) Account(com.zimbra.cs.account.Account) ZMailbox(com.zimbra.client.ZMailbox) ZFolder(com.zimbra.client.ZFolder) UrlComponents(com.zimbra.cs.dav.resource.UrlNamespace.UrlComponents) ItemId(com.zimbra.cs.service.util.ItemId)

Aggregations

ZFolder (com.zimbra.client.ZFolder)1 ZMailbox (com.zimbra.client.ZMailbox)1 ZMountpoint (com.zimbra.client.ZMountpoint)1 Account (com.zimbra.cs.account.Account)1 UrlComponents (com.zimbra.cs.dav.resource.UrlNamespace.UrlComponents)1 ItemId (com.zimbra.cs.service.util.ItemId)1