Search in sources :

Example 21 with DataSource

use of com.zimbra.cs.account.DataSource in project zm-mailbox by Zimbra.

the class TestAccess method ModifyDataSource.

public void ModifyDataSource(Role role, Perm perm) throws Exception {
    String dateSourceName = "datasource-modify-" + random();
    DataSource ds = mProvAdmin.setup_createDataSource(this, role, perm, ACCT_1_EMAIL, dateSourceName);
    XMLElement req = new XMLElement(MailConstants.MODIFY_DATA_SOURCE_REQUEST);
    Element dataSource = req.addElement(MailConstants.E_DS_POP3);
    dataSource.addAttribute(MailConstants.A_ID, ds.getId());
    dataSource.addAttribute(MailConstants.A_DS_IS_ENABLED, "false");
    accessTest(role, perm, req);
}
Also used : XMLElement(com.zimbra.common.soap.Element.XMLElement) Element(com.zimbra.common.soap.Element) XMLElement(com.zimbra.common.soap.Element.XMLElement) DataSource(com.zimbra.cs.account.DataSource)

Example 22 with DataSource

use of com.zimbra.cs.account.DataSource in project zm-mailbox by Zimbra.

the class TestLdapProvRenameDomain method createDataSources.

private void createDataSources(Account acct, String[] sigIds) throws Exception {
    for (int i = 0; i < NUM_DATASOURCES; i++) {
        Map<String, Object> attrs = new HashMap<String, Object>();
        attrs.put(Provisioning.A_zimbraDataSourceEnabled, "TRUE");
        attrs.put(Provisioning.A_zimbraDataSourceConnectionType, "ssl");
        attrs.put(Provisioning.A_zimbraDataSourceFolderId, "inbox");
        attrs.put(Provisioning.A_zimbraDataSourceHost, "pop.google.com");
        attrs.put(Provisioning.A_zimbraDataSourceLeaveOnServer, "TRUE");
        attrs.put(Provisioning.A_zimbraDataSourcePassword, PASSWORD);
        attrs.put(Provisioning.A_zimbraDataSourcePort, "9999");
        attrs.put(Provisioning.A_zimbraDataSourceUsername, "mickymouse");
        attrs.put(Provisioning.A_zimbraDataSourceEmailAddress, "micky@google.com");
        // just some random id, not used anywhere
        attrs.put(Provisioning.A_zimbraPrefDefaultSignatureId, LdapUtil.generateUUID());
        attrs.put(Provisioning.A_zimbraPrefFromDisplay, "Micky Mouse");
        attrs.put(Provisioning.A_zimbraPrefReplyToAddress, "goofy@yahoo.com");
        attrs.put(Provisioning.A_zimbraPrefReplyToDisplay, "Micky");
        if (i < NUM_SIGNATURES)
            attrs.put(Provisioning.A_zimbraPrefDefaultSignatureId, sigIds[i]);
        DataSource entry = prov.createDataSource(acct, DataSourceType.pop3, DATASOURCE_NAME(acct, i), attrs);
    }
}
Also used : HashMap(java.util.HashMap) DataSource(com.zimbra.cs.account.DataSource)

Example 23 with DataSource

use of com.zimbra.cs.account.DataSource in project zm-mailbox by Zimbra.

the class TestLdapProvDataSource method createDataSourceAlreadyExists.

@Test
public void createDataSourceAlreadyExists() 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);
    boolean caughtException = false;
    try {
        createDataSourceRaw(acct, DATA_SOURCE_NAME);
    } catch (AccountServiceException e) {
        if (AccountServiceException.DATA_SOURCE_EXISTS.equals(e.getCode())) {
            caughtException = true;
        }
    }
    assertTrue(caughtException);
    deleteDataSource(acct, dataSource);
    deleteAccount(acct);
}
Also used : Account(com.zimbra.cs.account.Account) AccountServiceException(com.zimbra.cs.account.AccountServiceException) DataSource(com.zimbra.cs.account.DataSource)

Example 24 with DataSource

use of com.zimbra.cs.account.DataSource in project zm-mailbox by Zimbra.

the class TestLdapProvDataSource method createDataSource.

@Test
public void createDataSource() 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);
    assertEquals(acct.getId(), dataSource.getAccount().getId());
    deleteDataSource(acct, dataSource);
    deleteAccount(acct);
}
Also used : Account(com.zimbra.cs.account.Account) DataSource(com.zimbra.cs.account.DataSource)

Example 25 with DataSource

use of com.zimbra.cs.account.DataSource in project zm-mailbox by Zimbra.

the class TestLdapProvAccount method createDataSource.

private DataSource createDataSource(Account acct, String dataSourceName) throws Exception {
    Map<String, Object> attrs = new HashMap<String, Object>();
    attrs.put(Provisioning.A_zimbraDataSourceEnabled, LdapConstants.LDAP_TRUE);
    attrs.put(Provisioning.A_zimbraDataSourceFolderId, "123");
    attrs.put(Provisioning.A_zimbraDataSourceConnectionType, "ssl");
    attrs.put(Provisioning.A_zimbraDataSourceHost, "zimbra.com");
    attrs.put(Provisioning.A_zimbraDataSourcePort, "9999");
    DataSource ds = prov.createDataSource(acct, DataSourceType.pop3, dataSourceName, attrs);
    return ds;
}
Also used : HashMap(java.util.HashMap) DataSource(com.zimbra.cs.account.DataSource)

Aggregations

DataSource (com.zimbra.cs.account.DataSource)71 Account (com.zimbra.cs.account.Account)29 HashMap (java.util.HashMap)21 Provisioning (com.zimbra.cs.account.Provisioning)18 DbDataSource (com.zimbra.cs.db.DbDataSource)18 ServiceException (com.zimbra.common.service.ServiceException)15 Element (com.zimbra.common.soap.Element)14 Mailbox (com.zimbra.cs.mailbox.Mailbox)11 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)11 ArrayList (java.util.ArrayList)11 ZDataSource (com.zimbra.client.ZDataSource)8 AccountServiceException (com.zimbra.cs.account.AccountServiceException)7 Folder (com.zimbra.cs.mailbox.Folder)7 DataSourceType (com.zimbra.soap.admin.type.DataSourceType)7 HashSet (java.util.HashSet)7 Test (org.junit.Test)7 DataSourceItem (com.zimbra.cs.db.DbDataSource.DataSourceItem)6 ZMailbox (com.zimbra.client.ZMailbox)5 LdapDataSource (com.zimbra.cs.account.ldap.entry.LdapDataSource)5 MailServiceException (com.zimbra.cs.mailbox.MailServiceException)5