use of com.zimbra.client.ZMailbox.ZMiniCalError in project zm-mailbox by Zimbra.
the class GetMiniCal method doRemoteFolders.
private static void doRemoteFolders(ZimbraSoapContext zsc, String remoteAccountId, List<String> remoteFolders, long rangeStart, long rangeEnd, Set<String> busyDates, Element response, Map<ItemId, ItemId> reverseIidMap, ItemIdFormatter ifmt) {
try {
Account target = Provisioning.getInstance().get(Key.AccountBy.id, remoteAccountId);
if (target == null)
throw AccountServiceException.NO_SUCH_ACCOUNT(remoteAccountId);
AuthToken authToken = AuthToken.getCsrfUnsecuredAuthToken(zsc.getAuthToken());
ZMailbox.Options zoptions = new ZMailbox.Options(authToken.toZAuthToken(), AccountUtil.getSoapUri(target));
zoptions.setTargetAccount(remoteAccountId);
zoptions.setTargetAccountBy(AccountBy.id);
zoptions.setNoSession(true);
ZMailbox zmbx = ZMailbox.getMailbox(zoptions);
zmbx.setName(target.getName());
/* need this when logging in using another user's auth */
String[] remoteIds = new String[remoteFolders.size()];
for (int i = 0; i < remoteIds.length; i++) remoteIds[i] = remoteFolders.get(i).toString();
ZGetMiniCalResult result = zmbx.getMiniCal(rangeStart, rangeEnd, remoteIds);
Set<String> dates = result.getDates();
if (dates != null) {
for (String datestamp : dates) {
busyDates.add(datestamp);
}
}
List<ZMiniCalError> errors = result.getErrors();
if (errors != null) {
for (ZMiniCalError error : errors) {
try {
ItemId iid = new ItemId(error.getFolderId(), zsc);
// Error must mention folder id requested by client.
ItemId reqIid = reverseIidMap.get(iid);
String fid = ifmt.formatItemId(reqIid != null ? reqIid : iid);
addError(response, fid, error.getErrCode(), error.getErrMsg());
} catch (ServiceException e) {
}
}
}
} catch (ServiceException e) {
ZimbraLog.calendar.warn("Error making remote GetMiniCalRequest", e);
// Mark all remote folders with the same error.
for (String remoteFid : remoteFolders) {
try {
ItemId iid = new ItemId(remoteFid, zsc);
// Error must mention folder id requested by client.
ItemId reqIid = reverseIidMap.get(iid);
String fid = ifmt.formatItemId(reqIid != null ? reqIid : iid);
addError(response, fid, e.getCode(), e.getMessage());
} catch (ServiceException e2) {
}
}
}
}
Aggregations