Search in sources :

Example 6 with DataSource

use of com.zimbra.soap.type.DataSource in project zm-mailbox by Zimbra.

the class ZMailbox method testDataSource.

/**
 * Tests a data source.
 *
 * @return <tt>null</tt> on success, or the error string on failure
 */
public String testDataSource(ZDataSource source) throws ServiceException {
    TestDataSourceRequest req = new TestDataSourceRequest();
    DataSource jaxbObj = source.toJaxb();
    req.setDataSource(jaxbObj);
    TestDataSourceResponse resp = (TestDataSourceResponse) invokeJaxb(req);
    List<TestDataSource> dataSources = resp.getDataSources();
    int success = 0;
    if (dataSources.size() > 0 && dataSources.get(0) != null) {
        TestDataSource ds = dataSources.get(0);
        success = ds.getSuccess();
        if (success < 1) {
            return ds.getError();
        } else {
            return null;
        }
    }
    return null;
}
Also used : TestDataSourceRequest(com.zimbra.soap.mail.message.TestDataSourceRequest) TestDataSource(com.zimbra.soap.mail.type.TestDataSource) TestDataSourceResponse(com.zimbra.soap.mail.message.TestDataSourceResponse) RssDataSource(com.zimbra.soap.type.RssDataSource) TestDataSource(com.zimbra.soap.mail.type.TestDataSource) DataSource(com.zimbra.soap.type.DataSource) Pop3DataSource(com.zimbra.soap.type.Pop3DataSource) ImapDataSource(com.zimbra.soap.type.ImapDataSource) CalDataSource(com.zimbra.soap.type.CalDataSource)

Example 7 with DataSource

use of com.zimbra.soap.type.DataSource in project zm-mailbox by Zimbra.

the class ZMailbox method getAllDataSources.

public List<ZDataSource> getAllDataSources() throws ServiceException {
    GetDataSourcesResponse res = invokeJaxb(new GetDataSourcesRequest());
    List<ZDataSource> result = new ArrayList<ZDataSource>();
    for (DataSource ds : res.getDataSources()) {
        if (ds instanceof Pop3DataSource) {
            result.add(new ZPop3DataSource((Pop3DataSource) ds));
        } else if (ds instanceof ImapDataSource) {
            result.add(new ZImapDataSource((ImapDataSource) ds));
        } else if (ds instanceof CalDataSource) {
            result.add(new ZCalDataSource((CalDataSource) ds));
        } else if (ds instanceof RssDataSource) {
            result.add(new ZRssDataSource((RssDataSource) ds));
        } else {
            result.add(new ZDataSource(ds));
        }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) ImapDataSource(com.zimbra.soap.type.ImapDataSource) GetDataSourcesResponse(com.zimbra.soap.mail.message.GetDataSourcesResponse) CalDataSource(com.zimbra.soap.type.CalDataSource) RssDataSource(com.zimbra.soap.type.RssDataSource) TestDataSource(com.zimbra.soap.mail.type.TestDataSource) DataSource(com.zimbra.soap.type.DataSource) Pop3DataSource(com.zimbra.soap.type.Pop3DataSource) ImapDataSource(com.zimbra.soap.type.ImapDataSource) CalDataSource(com.zimbra.soap.type.CalDataSource) Pop3DataSource(com.zimbra.soap.type.Pop3DataSource) RssDataSource(com.zimbra.soap.type.RssDataSource) GetDataSourcesRequest(com.zimbra.soap.mail.message.GetDataSourcesRequest)

Aggregations

DataSource (com.zimbra.soap.type.DataSource)7 MailCalDataSource (com.zimbra.soap.mail.type.MailCalDataSource)4 MailCaldavDataSource (com.zimbra.soap.mail.type.MailCaldavDataSource)4 MailDataSource (com.zimbra.soap.mail.type.MailDataSource)4 MailGalDataSource (com.zimbra.soap.mail.type.MailGalDataSource)4 MailImapDataSource (com.zimbra.soap.mail.type.MailImapDataSource)4 MailPop3DataSource (com.zimbra.soap.mail.type.MailPop3DataSource)4 MailRssDataSource (com.zimbra.soap.mail.type.MailRssDataSource)4 JAXBContext (javax.xml.bind.JAXBContext)4 Unmarshaller (javax.xml.bind.Unmarshaller)4 Test (org.junit.Test)4 TestDataSource (com.zimbra.soap.mail.type.TestDataSource)3 CalDataSource (com.zimbra.soap.type.CalDataSource)3 ImapDataSource (com.zimbra.soap.type.ImapDataSource)3 Pop3DataSource (com.zimbra.soap.type.Pop3DataSource)3 RssDataSource (com.zimbra.soap.type.RssDataSource)3 CreateDataSourceRequest (com.zimbra.soap.mail.message.CreateDataSourceRequest)2 GetDataSourcesResponse (com.zimbra.soap.mail.message.GetDataSourcesResponse)2 TestDataSourceRequest (com.zimbra.soap.mail.message.TestDataSourceRequest)2 CreateDataSourceResponse (com.zimbra.soap.mail.message.CreateDataSourceResponse)1