use of com.zimbra.soap.admin.message.AddGalSyncDataSourceRequest in project zm-mailbox by Zimbra.
the class AddGalSyncDataSource method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Provisioning prov = Provisioning.getInstance();
AddGalSyncDataSourceRequest dsRequest = zsc.elementToJaxb(request);
String name = dsRequest.getName();
String domainStr = dsRequest.getDomain();
GalMode type = dsRequest.getType();
AccountSelector acctSelector = dsRequest.getAccount();
AccountBy acctBy = acctSelector.getBy();
String acctValue = acctSelector.getKey();
String folder = dsRequest.getFolder();
Domain domain = prov.getDomainByName(domainStr);
if (domain == null) {
throw AccountServiceException.NO_SUCH_DOMAIN(domainStr);
}
Account account = null;
try {
account = prov.get(acctBy.toKeyAccountBy(), acctValue, zsc.getAuthToken());
} catch (ServiceException se) {
ZimbraLog.gal.warn("error checking GalSyncAccount", se);
}
if (account == null) {
throw AccountServiceException.NO_SUCH_ACCOUNT(acctValue);
}
if (!Provisioning.onLocalServer(account)) {
String host = account.getMailHost();
Server server = prov.getServerByName(host);
return proxyRequest(request, context, server);
}
CreateGalSyncAccount.addDataSource(request, zsc, account, domain, folder, name, type);
Element response = zsc.createElement(AdminConstants.ADD_GAL_SYNC_DATASOURCE_RESPONSE);
ToXML.encodeAccount(response, account, false, emptySet, null);
return response;
}
Aggregations