Search in sources :

Example 1 with RefreshMountpoint

use of com.zimbra.cs.redolog.op.RefreshMountpoint in project zm-mailbox by Zimbra.

the class Mailbox method refreshMountpoint.

/**
 * Updates the remote owner and item id stored in the mountpoint to match the current location of the
 * target folder.  The target folder is identified by the remote UUID stored in the mountpoint's metadata.
 * @param octxt
 * @param mountpointId item id of the Mountpoint
 * @return
 * @throws ServiceException
 */
public Mountpoint refreshMountpoint(OperationContext octxt, int mountpointId) throws ServiceException {
    Mountpoint mp = getMountpointById(octxt, mountpointId);
    Provisioning prov = Provisioning.getInstance();
    ShareLocator shloc = prov.getShareLocatorById(mp.getRemoteUuid());
    if (shloc == null || mp.getOwnerId().equalsIgnoreCase(shloc.getShareOwnerAccountId())) {
        // Share apparently did not move.
        return mp;
    }
    // Look up remote folder by UUID to discover the new numeric id.
    Account shareOwner = Provisioning.getInstance().get(Key.AccountBy.id, shloc.getShareOwnerAccountId());
    AuthToken at = AuthToken.getCsrfUnsecuredAuthToken(octxt.getAuthToken());
    String pxyAuthToken = Provisioning.onLocalServer(shareOwner) ? null : at.getProxyAuthToken();
    ZAuthToken zat = null;
    if (pxyAuthToken == null) {
        zat = at.toZAuthToken();
        zat.resetProxyAuthToken();
    } else {
        zat = new ZAuthToken(pxyAuthToken);
    }
    ZMailbox.Options zoptions = new ZMailbox.Options(zat, AccountUtil.getSoapUri(shareOwner));
    zoptions.setNoSession(true);
    zoptions.setTargetAccount(shareOwner.getId());
    zoptions.setTargetAccountBy(Key.AccountBy.id);
    ZMailbox zmbx = ZMailbox.getMailbox(zoptions);
    zmbx.setName(shareOwner.getName());
    /* need this when logging in using another user's auth */
    ZFolder zfolder = zmbx.getFolderByUuid(shloc.getUuid());
    if (zfolder != null) {
        ItemId fid = new ItemId(zfolder.getId(), shareOwner.getId());
        return refreshMountpoint(octxt, mountpointId, shareOwner.getId(), fid.getId());
    } else {
        return null;
    }
}
Also used : Account(com.zimbra.cs.account.Account) ParsedMessageOptions(com.zimbra.cs.mime.ParsedMessageOptions) Options(com.zimbra.client.ZMailbox.Options) ZMailbox(com.zimbra.client.ZMailbox) Options(com.zimbra.client.ZMailbox.Options) AuthToken(com.zimbra.cs.account.AuthToken) ZAuthToken(com.zimbra.common.auth.ZAuthToken) ZFolder(com.zimbra.client.ZFolder) RefreshMountpoint(com.zimbra.cs.redolog.op.RefreshMountpoint) CreateMountpoint(com.zimbra.cs.redolog.op.CreateMountpoint) ZAuthToken(com.zimbra.common.auth.ZAuthToken) ItemId(com.zimbra.cs.service.util.ItemId) Provisioning(com.zimbra.cs.account.Provisioning) ShareLocator(com.zimbra.cs.account.ShareLocator)

Example 2 with RefreshMountpoint

use of com.zimbra.cs.redolog.op.RefreshMountpoint in project zm-mailbox by Zimbra.

the class Mailbox method refreshMountpoint.

public Mountpoint refreshMountpoint(OperationContext octxt, int mountpointId, String ownerId, int remoteId) throws ServiceException {
    RefreshMountpoint redoRecorder = new RefreshMountpoint(mId, mountpointId, ownerId, remoteId);
    boolean success = false;
    try {
        beginTransaction("refreshMountpoint", octxt, redoRecorder);
        Mountpoint mpt = getMountpointById(octxt, mountpointId);
        mpt.setRemoteInfo(ownerId, remoteId);
        success = true;
    } finally {
        endTransaction(success);
    }
    return getMountpointById(octxt, mountpointId);
}
Also used : RefreshMountpoint(com.zimbra.cs.redolog.op.RefreshMountpoint) RefreshMountpoint(com.zimbra.cs.redolog.op.RefreshMountpoint) CreateMountpoint(com.zimbra.cs.redolog.op.CreateMountpoint)

Aggregations

CreateMountpoint (com.zimbra.cs.redolog.op.CreateMountpoint)2 RefreshMountpoint (com.zimbra.cs.redolog.op.RefreshMountpoint)2 ZFolder (com.zimbra.client.ZFolder)1 ZMailbox (com.zimbra.client.ZMailbox)1 Options (com.zimbra.client.ZMailbox.Options)1 ZAuthToken (com.zimbra.common.auth.ZAuthToken)1 Account (com.zimbra.cs.account.Account)1 AuthToken (com.zimbra.cs.account.AuthToken)1 Provisioning (com.zimbra.cs.account.Provisioning)1 ShareLocator (com.zimbra.cs.account.ShareLocator)1 ParsedMessageOptions (com.zimbra.cs.mime.ParsedMessageOptions)1 ItemId (com.zimbra.cs.service.util.ItemId)1