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;
}
}
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);
}
Aggregations