use of com.zimbra.cs.account.DataSource.DataImport in project zm-mailbox by Zimbra.
the class DataSourceManager method test.
/*
* Tests connecting to a data source. Do not actually create the
* data source.
*/
public static void test(DataSource ds) throws ServiceException {
ZimbraLog.datasource.info("Testing: %s", ds);
try {
DataImport di = getInstance().getDataImport(ds, true);
di.test();
if (ds.isSmtpEnabled()) {
Session session = JMSession.getSession(ds);
Transport smtp = session.getTransport();
String emailAddress = ds.getEmailAddress();
if (smtp instanceof SmtpTransport) {
test((SmtpTransport) smtp, emailAddress);
} else {
test((SMTPTransport) smtp, emailAddress);
}
}
ZimbraLog.datasource.info("Test succeeded: %s", ds);
} catch (ServiceException x) {
ZimbraLog.datasource.info("Test failed: %s", ds, x);
throw x;
} catch (Exception e) {
ZimbraLog.datasource.info("Test failed: %s", ds, e);
throw ServiceException.INVALID_REQUEST("Datasource test failed", e);
}
}
use of com.zimbra.cs.account.DataSource.DataImport 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