use of com.zimbra.cs.gal.GalImport in project zm-mailbox by Zimbra.
the class SyncGalAccount method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Provisioning prov = Provisioning.getInstance();
ZimbraLog.addToContext(ZimbraLog.C_ANAME, getAuthenticatedAccount(zsc).getName());
for (Element accountEl : request.listElements(AdminConstants.E_ACCOUNT)) {
String accountId = accountEl.getAttribute(AdminConstants.A_ID);
Account account = prov.getAccountById(accountId);
if (account == null) {
throw AccountServiceException.NO_SUCH_ACCOUNT(accountId);
}
ZimbraLog.addToContext(ZimbraLog.C_NAME, account.getName());
for (Element dsEl : accountEl.listElements(AdminConstants.E_DATASOURCE)) {
String by = dsEl.getAttribute(AdminConstants.A_BY);
String name = dsEl.getText();
DataSource ds = by.equals("id") ? account.getDataSourceById(name) : account.getDataSourceByName(name);
if (ds == null) {
throw AccountServiceException.NO_SUCH_DATA_SOURCE(name);
}
if (!ds.getType().equals(DataSourceType.gal)) {
continue;
}
boolean fullSync = dsEl.getAttributeBool(AdminConstants.A_FULLSYNC, false);
boolean reset = dsEl.getAttributeBool(AdminConstants.A_RESET, false);
int fid = ds.getFolderId();
DataImport dataImport = DataSourceManager.getInstance().getDataImport(ds);
if (dataImport instanceof GalImport) {
((GalImport) dataImport).importGal(fid, (reset ? reset : fullSync), reset);
}
//flush domain gal group cache
Domain domain = prov.getDomain(account);
GalGroup.flushCache(domain);
}
}
return zsc.createElement(AdminConstants.SYNC_GAL_ACCOUNT_RESPONSE);
}
Aggregations