Search in sources :

Example 76 with XMLElement

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

the class FbCli method pushFreeBusyForAccounts.

public void pushFreeBusyForAccounts(Collection<String> accounts) throws ServiceException, IOException {
    try {
        auth();
        XMLElement req = new XMLElement(AdminConstants.PUSH_FREE_BUSY_REQUEST);
        for (String acct : accounts) req.addElement(AdminConstants.E_ACCOUNT).addAttribute(AdminConstants.A_ID, acct);
        mTransport.invoke(req);
    } finally {
        mTransport.shutdown();
    }
}
Also used : XMLElement(com.zimbra.common.soap.Element.XMLElement)

Example 77 with XMLElement

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

the class FbCli method auth.

private void auth() throws ServiceException, IOException {
    XMLElement req = new XMLElement(AdminConstants.AUTH_REQUEST);
    req.addElement(AdminConstants.E_NAME).setText(LC.zimbra_ldap_user.value());
    req.addElement(AdminConstants.E_PASSWORD).setText(LC.zimbra_ldap_password.value());
    Element resp = mTransport.invoke(req);
    mTransport.setAuthToken(resp.getElement(AccountConstants.E_AUTH_TOKEN).getText());
}
Also used : XMLElement(com.zimbra.common.soap.Element.XMLElement) Element(com.zimbra.common.soap.Element) XMLElement(com.zimbra.common.soap.Element.XMLElement)

Example 78 with XMLElement

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

the class FbCli method purgeFreeBusyQueue.

public void purgeFreeBusyQueue(String provider) throws ServiceException, IOException {
    try {
        auth();
        XMLElement req = new XMLElement(AdminConstants.PURGE_FREE_BUSY_QUEUE_REQUEST);
        if (provider != null)
            req.addElement(AdminConstants.E_PROVIDER).addAttribute(AdminConstants.A_NAME, provider);
        mTransport.invoke(req);
    } finally {
        mTransport.shutdown();
    }
}
Also used : XMLElement(com.zimbra.common.soap.Element.XMLElement)

Example 79 with XMLElement

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

the class FbCli method getAllFreeBusyProviders.

public Collection<FbProvider> getAllFreeBusyProviders() throws ServiceException, IOException {
    ArrayList<FbProvider> providers = new ArrayList<FbProvider>();
    try {
        auth();
        XMLElement req = new XMLElement(AdminConstants.GET_ALL_FREE_BUSY_PROVIDERS_REQUEST);
        Element resp = mTransport.invoke(req);
        for (Element provElem : resp.listElements(AdminConstants.E_PROVIDER)) {
            FbProvider prov = new FbProvider();
            prov.name = provElem.getAttribute(AdminConstants.A_NAME, null);
            prov.propagate = provElem.getAttributeBool(AdminConstants.A_PROPAGATE, false);
            prov.fbstart = provElem.getAttributeLong(AdminConstants.A_START, 0);
            prov.fbend = provElem.getAttributeLong(AdminConstants.A_END, 0);
            prov.queue = provElem.getAttribute(AdminConstants.A_QUEUE, null);
            prov.prefix = provElem.getAttribute(AdminConstants.A_PREFIX, null);
            providers.add(prov);
        }
    } finally {
        mTransport.shutdown();
    }
    return providers;
}
Also used : XMLElement(com.zimbra.common.soap.Element.XMLElement) Element(com.zimbra.common.soap.Element) ArrayList(java.util.ArrayList) XMLElement(com.zimbra.common.soap.Element.XMLElement)

Example 80 with XMLElement

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

the class JaxbToJsonTest method mixedHandlingJustText.

/**
     * {@link XmlMixed} handling
     * In the places we use XmlMixed, we typically have either just text or just elements
     * This tests where we have just text.
     */
@Test
public void mixedHandlingJustText() throws Exception {
    String textStr = "text string";
    List<Object> elems = Lists.newArrayList();
    MixedTester jaxb = new MixedTester();
    elems.add(textStr);
    jaxb.setElems(elems);
    Element xmlElem = JaxbUtil.jaxbToElement(jaxb, Element.XMLElement.mFactory, true, false);
    xmlElem = JaxbUtil.jaxbToElement(jaxb, Element.XMLElement.mFactory, true, false);
    logDebug("XmlElement (for comparison) [Mixed has just text] ---> prettyPrint\n%1$s", xmlElem.prettyPrint());
    MixedTester roundtrippedX = JaxbUtil.elementToJaxb(xmlElem, MixedTester.class);
    Assert.assertEquals("roundtrippedX [Mixed has just text] num elems", 1, roundtrippedX.getElems().size());
    Assert.assertEquals("roundtrippedX [Mixed has just text] str", textStr, (String) roundtrippedX.getElems().get(0));
    Element jsonJaxbElem = JacksonUtil.jaxbToJSONElement(jaxb);
    logDebug("JSONElement from JAXB [Mixed has just text] ---> prettyPrint\n%1$s", jsonJaxbElem.prettyPrint());
    MixedTester roundtripped = JaxbUtil.elementToJaxb(jsonJaxbElem, MixedTester.class);
    Assert.assertEquals("roundtripped [Mixed has just text] num elems", 1, roundtripped.getElems().size());
    Assert.assertEquals("roundtripped [Mixed has just text] str", textStr, (String) roundtripped.getElems().get(0));
}
Also used : MixedTester(com.zimbra.soap.jaxb.MixedTester) XmlAnyElement(javax.xml.bind.annotation.XmlAnyElement) Element(com.zimbra.common.soap.Element) XMLElement(com.zimbra.common.soap.Element.XMLElement) JSONElement(com.zimbra.common.soap.Element.JSONElement) XmlElement(javax.xml.bind.annotation.XmlElement) FilterTest(com.zimbra.soap.mail.type.FilterTest) Test(org.junit.Test)

Aggregations

XMLElement (com.zimbra.common.soap.Element.XMLElement)140 Element (com.zimbra.common.soap.Element)111 Test (org.junit.Test)30 JSONElement (com.zimbra.common.soap.Element.JSONElement)29 XmlAnyElement (javax.xml.bind.annotation.XmlAnyElement)25 XmlElement (javax.xml.bind.annotation.XmlElement)25 FilterTest (com.zimbra.soap.mail.type.FilterTest)24 SoapHttpTransport (com.zimbra.common.soap.SoapHttpTransport)9 HashMap (java.util.HashMap)8 Account (com.zimbra.cs.account.Account)6 ArrayList (java.util.ArrayList)6 ZAuthToken (com.zimbra.common.auth.ZAuthToken)5 KeyValuePair (com.zimbra.soap.type.KeyValuePair)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 Signature (com.zimbra.cs.account.Signature)3