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();
}
}
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());
}
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();
}
}
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;
}
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));
}
Aggregations