Search in sources :

Example 36 with XMLElement

use of com.zimbra.common.soap.Element.XMLElement in project zm-mailbox by Zimbra.

the class SoapProvisioning method getAllXMPPComponents.

@Override
public List<XMPPComponent> getAllXMPPComponents() throws ServiceException {
    XMLElement req = new XMLElement(AdminConstants.GET_ALL_XMPPCOMPONENTS_REQUEST);
    Element response = invoke(req);
    List<XMPPComponent> toRet = new ArrayList<XMPPComponent>();
    for (Element e : response.listElements(AdminConstants.E_XMPP_COMPONENT)) {
        toRet.add(new SoapXMPPComponent(e, this));
    }
    return toRet;
}
Also used : Element(com.zimbra.common.soap.Element) XMLElement(com.zimbra.common.soap.Element.XMLElement) ArrayList(java.util.ArrayList) XMLElement(com.zimbra.common.soap.Element.XMLElement) XMPPComponent(com.zimbra.cs.account.XMPPComponent)

Example 37 with XMLElement

use of com.zimbra.common.soap.Element.XMLElement in project zm-mailbox by Zimbra.

the class SoapProvisioning method getAllDataSources.

@Override
public List<DataSource> getAllDataSources(Account account) throws ServiceException {
    List<DataSource> result = new ArrayList<DataSource>();
    XMLElement req = new XMLElement(AdminConstants.GET_DATA_SOURCES_REQUEST);
    req.addElement(AdminConstants.E_ID).setText(account.getId());
    Element resp = invoke(req);
    for (Element dataSource : resp.listElements(AccountConstants.E_DATA_SOURCE)) {
        result.add(new SoapDataSource(account, dataSource, this));
    }
    return result;
}
Also used : Element(com.zimbra.common.soap.Element) XMLElement(com.zimbra.common.soap.Element.XMLElement) ArrayList(java.util.ArrayList) XMLElement(com.zimbra.common.soap.Element.XMLElement) DataSource(com.zimbra.cs.account.DataSource)

Example 38 with XMLElement

use of com.zimbra.common.soap.Element.XMLElement in project zm-mailbox by Zimbra.

the class SoapProvisioning method soapAdminAuthenticate.

/**
 * used to authenticate via admin AuthRequest. can only be called after setting the URI with setURI.
 *
 * @param name
 * @param password
 * @throws ServiceException
 * @throws IOException
 */
public void soapAdminAuthenticate(String name, String password) throws ServiceException {
    if (mTransport == null)
        throw ZClientException.CLIENT_ERROR("must call setURI before calling adminAuthenticate", null);
    // TODO: Need to resolve issues with AuthToken support before we can
    // migrate to JAXB?
    // The ZAuthToken constructor below ends up invoking :
    // ZAuthToken.fromSoap(Element eAuthToken, boolean isAdmin)
    // which expects <authToken> to have a value but also optional
    // <a> sub-elements.  Would probably need @XmlMixed to support
    // that as @XmlElement and @XmlValue are mutually exclusive
    XMLElement req = new XMLElement(AdminConstants.AUTH_REQUEST);
    req.addElement(AdminConstants.E_NAME).setText(name);
    req.addElement(AdminConstants.E_PASSWORD).setText(password);
    Element response = invoke(req);
    mAuthToken = new ZAuthToken(response.getElement(AdminConstants.E_AUTH_TOKEN), true);
    mAuthTokenLifetime = response.getAttributeLong(AdminConstants.E_LIFETIME);
    mAuthTokenExpiration = System.currentTimeMillis() + mAuthTokenLifetime;
    mTransport.setAuthToken(mAuthToken);
    mTransport.setVoidOnExpired(true);
}
Also used : Element(com.zimbra.common.soap.Element) XMLElement(com.zimbra.common.soap.Element.XMLElement) XMLElement(com.zimbra.common.soap.Element.XMLElement) ZAuthToken(com.zimbra.common.auth.ZAuthToken)

Example 39 with XMLElement

use of com.zimbra.common.soap.Element.XMLElement in project zm-mailbox by Zimbra.

the class SoapProvisioning method getConfigSMIMEConfig.

@Override
public Map<String, Map<String, Object>> getConfigSMIMEConfig(String configName) throws ServiceException {
    XMLElement req = new XMLElement(AdminConstants.GET_SMIME_CONFIG_REQUEST);
    if (configName != null) {
        Element eConfig = req.addElement(AdminConstants.E_CONFIG);
        eConfig.addAttribute(AdminConstants.A_NAME, configName);
    }
    Element resp = invoke(req);
    Map<String, Map<String, Object>> result = new HashMap<String, Map<String, Object>>();
    for (Element eConfig : resp.listElements(AdminConstants.E_CONFIG)) {
        result.put(eConfig.getAttribute(AdminConstants.A_NAME), getAttrs(eConfig));
    }
    return result;
}
Also used : HashMap(java.util.HashMap) Element(com.zimbra.common.soap.Element) XMLElement(com.zimbra.common.soap.Element.XMLElement) XMLElement(com.zimbra.common.soap.Element.XMLElement) Map(java.util.Map) TreeMap(java.util.TreeMap) HashMap(java.util.HashMap)

Example 40 with XMLElement

use of com.zimbra.common.soap.Element.XMLElement in project zm-mailbox by Zimbra.

the class SoapProvisioning method createDataSource.

@Override
public DataSource createDataSource(Account account, DataSourceType dsType, String dsName, Map<String, Object> attrs) throws ServiceException {
    XMLElement req = new XMLElement(AdminConstants.CREATE_DATA_SOURCE_REQUEST);
    req.addElement(AdminConstants.E_ID).setText(account.getId());
    Element ds = req.addElement(AccountConstants.E_DATA_SOURCE);
    ds.addAttribute(AccountConstants.A_NAME, dsName);
    ds.addAttribute(AccountConstants.A_TYPE, dsType.name());
    addAttrElements(ds, attrs);
    Element response = invoke(req).getElement(AccountConstants.E_DATA_SOURCE);
    return new SoapDataSource(account, response, this);
}
Also used : Element(com.zimbra.common.soap.Element) XMLElement(com.zimbra.common.soap.Element.XMLElement) XMLElement(com.zimbra.common.soap.Element.XMLElement)

Aggregations

XMLElement (com.zimbra.common.soap.Element.XMLElement)146 Element (com.zimbra.common.soap.Element)116 JSONElement (com.zimbra.common.soap.Element.JSONElement)33 Test (org.junit.Test)32 XmlAnyElement (javax.xml.bind.annotation.XmlAnyElement)28 XmlElement (javax.xml.bind.annotation.XmlElement)28 FilterTest (com.zimbra.soap.mail.type.FilterTest)26 SoapHttpTransport (com.zimbra.common.soap.SoapHttpTransport)9 HashMap (java.util.HashMap)8 KeyValuePair (com.zimbra.soap.type.KeyValuePair)7 ArrayList (java.util.ArrayList)7 Account (com.zimbra.cs.account.Account)6 ZAuthToken (com.zimbra.common.auth.ZAuthToken)5 ByteBuilder (com.zimbra.common.mime.HeaderUtils.ByteBuilder)4 ServiceException (com.zimbra.common.service.ServiceException)4 DataSource (com.zimbra.cs.account.DataSource)4 Auth (com.zimbra.cs.service.account.Auth)4 URL (java.net.URL)4 Cookie (javax.servlet.http.Cookie)4 HttpException (org.apache.http.HttpException)4