use of com.zimbra.cs.account.DataSource in project zm-mailbox by Zimbra.
the class AccountUtil method getImapPop3EmailAddresses.
/**
* Gets all email addresses for the imap and pop3 external accounts for the given account.
* @param acct
* @return
* @throws ServiceException
*/
public static Set<String> getImapPop3EmailAddresses(Account acct) throws ServiceException {
List<DataSource> dataSources = acct.getAllDataSources();
Set<String> addrs = new HashSet<String>();
for (DataSource dataSource : dataSources) {
DataSourceType dataSourceType = dataSource.getType();
if (dataSourceType == DataSourceType.imap || dataSourceType == DataSourceType.pop3) {
addrs.add(dataSource.getEmailAddress().toLowerCase());
}
}
return addrs;
}
use of com.zimbra.cs.account.DataSource in project zm-mailbox by Zimbra.
the class TestLdapProvDataSource method modifyDataSource.
@Test
public void modifyDataSource() throws Exception {
String ACCT_NAME_LOCALPART = Names.makeAccountNameLocalPart(genAcctNameLocalPart());
String DATA_SOURCE_NAME = Names.makeDataSourceName(genDataSourceName());
Account acct = createAccount(ACCT_NAME_LOCALPART);
DataSource dataSource = createDataSource(acct, DATA_SOURCE_NAME);
Map<String, Object> attrs = new HashMap<String, Object>();
String MODIFIED_ATTR_NAME = Provisioning.A_zimbraDataSourceHost;
String MODIFIED_ATTR_VALUE = "modifyDataSource.com";
attrs.put(MODIFIED_ATTR_NAME, MODIFIED_ATTR_VALUE);
prov.modifyDataSource(acct, dataSource.getId(), attrs);
acct = getFresh(acct);
dataSource = prov.get(acct, Key.DataSourceBy.name, DATA_SOURCE_NAME);
assertEquals(MODIFIED_ATTR_VALUE, dataSource.getAttr(MODIFIED_ATTR_NAME));
deleteDataSource(acct, dataSource);
deleteAccount(acct);
}
use of com.zimbra.cs.account.DataSource in project zm-mailbox by Zimbra.
the class TestLdapProvDataSource method getAllDataSources.
@Test
public void getAllDataSources() throws Exception {
String ACCT_NAME_LOCALPART = Names.makeAccountNameLocalPart(genAcctNameLocalPart());
String DATA_SOURCE_NAME_1 = Names.makeDataSourceName(genDataSourceName("1"));
String DATA_SOURCE_NAME_2 = Names.makeDataSourceName(genDataSourceName("2"));
String DATA_SOURCE_NAME_3 = Names.makeDataSourceName(genDataSourceName("3"));
Account acct = createAccount(ACCT_NAME_LOCALPART);
DataSource dataSource1 = createDataSource(acct, DATA_SOURCE_NAME_1);
DataSource dataSource2 = createDataSource(acct, DATA_SOURCE_NAME_2);
DataSource dataSource3 = createDataSource(acct, DATA_SOURCE_NAME_3);
acct = getFresh(acct);
List<DataSource> allDataSources = prov.getAllDataSources(acct);
assertEquals(3, allDataSources.size());
Set<String> allDataSourceIds = new HashSet<String>();
for (DataSource dataSource : allDataSources) {
allDataSourceIds.add(dataSource.getId());
}
assertTrue(allDataSourceIds.contains(dataSource1.getId()));
assertTrue(allDataSourceIds.contains(dataSource2.getId()));
assertTrue(allDataSourceIds.contains(dataSource3.getId()));
deleteDataSource(acct, dataSource1);
deleteDataSource(acct, dataSource2);
deleteDataSource(acct, dataSource3);
deleteAccount(acct);
}
use of com.zimbra.cs.account.DataSource in project zm-mailbox by Zimbra.
the class TestLdapProvDataSource method getDataSource.
@Test
public void getDataSource() throws Exception {
String ACCT_NAME_LOCALPART = Names.makeAccountNameLocalPart(genAcctNameLocalPart());
String DATA_SOURCE_NAME = Names.makeDataSourceName(genDataSourceName());
Account acct = createAccount(ACCT_NAME_LOCALPART);
DataSource dataSource = createDataSource(acct, DATA_SOURCE_NAME);
String dataSourceId = dataSource.getId();
acct = getFresh(acct);
dataSource = prov.get(acct, Key.DataSourceBy.id, dataSourceId);
assertNotNull(dataSource);
acct = getFresh(acct);
dataSource = prov.get(acct, Key.DataSourceBy.name, DATA_SOURCE_NAME);
assertNotNull(dataSource);
deleteDataSource(acct, dataSource);
deleteAccount(acct);
}
use of com.zimbra.cs.account.DataSource in project zm-mailbox by Zimbra.
the class TestLdapProvDataSource method renameDataSource.
@Test
public void renameDataSource() throws Exception {
String ACCT_NAME_LOCALPART = Names.makeAccountNameLocalPart(genAcctNameLocalPart());
String DATA_SOURCE_NAME = Names.makeDataSourceName(genDataSourceName());
Account acct = createAccount(ACCT_NAME_LOCALPART);
DataSource dataSource = createDataSource(acct, DATA_SOURCE_NAME);
Map<String, Object> attrs = new HashMap<String, Object>();
// modifying zimbraDataSourceName will rename the data source and trigger a LDAP moddn
String MODIFIED_ATTR_NAME = Provisioning.A_zimbraDataSourceName;
String NEW_DATA_SOURCE_NAME = Names.makeDataSourceName(genDataSourceName("new"));
String MODIFIED_ATTR_VALUE = NEW_DATA_SOURCE_NAME;
attrs.put(MODIFIED_ATTR_NAME, MODIFIED_ATTR_VALUE);
prov.modifyDataSource(acct, dataSource.getId(), attrs);
acct = getFresh(acct);
dataSource = prov.get(acct, Key.DataSourceBy.name, NEW_DATA_SOURCE_NAME);
assertEquals(MODIFIED_ATTR_VALUE, dataSource.getAttr(MODIFIED_ATTR_NAME));
deleteDataSource(acct, dataSource);
deleteAccount(acct);
}
Aggregations