use of com.zimbra.soap.mail.type.ConvActionSelector in project zm-mailbox by Zimbra.
the class JaxbToElementTest method ConvActionRequestJaxbSubclassHandlingTestDisabled.
/**
* Explore handling of Jaxb classes which specify an @XmlElement with
* a super class. How do subclasses get treated with this?
* WSDLJaxbTest.ConvActionRequestJaxbSubclassHandlingTest passes,
* i.e. it successfully unmarshalls to a ConvActionRequest with
* a FolderActionSelector member.
* However, even if I use those class files (with package name changed)
* in place of the committed ones, this test only seems to unmarshall
* with an ActionSelector member - i.e. the "recursive" and "url"
* attribute information gets lost.
*/
// @Test
public void ConvActionRequestJaxbSubclassHandlingTestDisabled() throws Exception {
ConvActionSelector actionSelector = ConvActionSelector.createForIdsAndOperation("ids", "op");
actionSelector.setAcctRelativePath("folder");
ConvActionRequest car = new ConvActionRequest(actionSelector);
Element carE = JaxbUtil.jaxbToElement(car);
String eXml = carE.toString();
ZimbraLog.test.debug("ConvActionRequestJaxbSubclassHandling: marshalled XML=%s", eXml);
Assert.assertTrue("Xml should contain acctRelPath attribute", eXml.contains("acctRelPath=\"folder\""));
carE = Element.XMLElement.mFactory.createElement(MailConstants.CONV_ACTION_REQUEST);
Element actionE = carE.addNonUniqueElement(MailConstants.E_ACTION);
actionE.addAttribute(MailConstants.A_OPERATION, "op");
actionE.addAttribute(MailConstants.A_ID, "ids");
actionE.addAttribute(MailConstants.A_ACCT_RELATIVE_PATH, "folder");
ZimbraLog.test.debug("ConvActionRequestJaxbSubclassHandling: half baked XML=%s", carE.toString());
car = JaxbUtil.elementToJaxb(carE);
carE = JaxbUtil.jaxbToElement(car);
eXml = carE.toString();
ZimbraLog.test.debug("ConvActionRequestJaxbSubclassHandling: round tripped XML=%s", eXml);
ConvActionSelector as = car.getAction();
Assert.assertEquals("acctRelPath attr value", "folder", as.getAcctRelativePath());
}
use of com.zimbra.soap.mail.type.ConvActionSelector in project zm-mailbox by Zimbra.
the class SearchAction method getConvActionRequest.
public static ConvActionRequest getConvActionRequest(List<SearchHit> searchHits, String op) {
StringBuilder Ids = new StringBuilder();
for (SearchHit searchHit : searchHits) {
String id = searchHit.getId();
Ids.append(id);
Ids.append(",");
}
String IdsStr = Ids.length() > 0 ? Ids.substring(0, Ids.length() - 1) : "";
ConvActionSelector convActionSelector = ConvActionSelector.createForIdsAndOperation(IdsStr, op);
ConvActionRequest req = new ConvActionRequest(convActionSelector);
return req;
}
use of com.zimbra.soap.mail.type.ConvActionSelector in project zm-mailbox by Zimbra.
the class TestDataSource method testRss.
/**
* Creates a folder that syncs to another folder via RSS, and verifies that an
* RSS data source was implicitly created.
*/
@Test
public void testRss() throws Exception {
// Create source folder, make it publicly readable, and add a message to it.
ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
String parentId = Integer.toString(Mailbox.ID_FOLDER_USER_ROOT);
ZFolder sourceFolder = TestUtil.createFolder(mbox, "/" + NAME_PREFIX + " testRss source");
mbox.modifyFolderGrant(sourceFolder.getId(), GranteeType.pub, null, "r", null);
String subject = NAME_PREFIX + " testRss";
TestUtil.addMessage(mbox, subject, sourceFolder.getId());
// Create destination folder that syncs to the source folder via RSS.
String urlString = String.format("https://%s:%s/home/%s%s.rss", TestUtil.getServerAttr(Provisioning.A_zimbraServiceHostname), TestUtil.getServerAttr(Provisioning.A_zimbraMailSSLPort), USER_NAME, sourceFolder.getPath());
urlString = HttpUtil.encodePath(urlString);
ZFolder rssFolder = mbox.createFolder(parentId, NAME_PREFIX + " testRss destination", null, null, null, urlString);
// Get the data source that was implicitly created.
ZRssDataSource ds = (ZRssDataSource) getDataSource(mbox, rssFolder.getId());
assertNotNull(ds);
assertNull(mbox.testDataSource(ds));
// Import data and validate the synced message.
List<ZDataSource> list = new ArrayList<ZDataSource>();
list.add(ds);
mbox.importData(list);
waitForData(mbox, rssFolder);
ZMessage syncedMsg = TestUtil.getMessage(mbox, "in:\"" + rssFolder.getPath() + "\"");
assertEquals(subject, syncedMsg.getSubject());
/*
* Bug 102261 - simulate ZWC deleting an item from the folder
*/
ConvActionSelector sel = ConvActionSelector.createForIdsAndOperation(syncedMsg.getConversationId(), "trash");
sel.setConstraint("-dtjs");
sel.setFolder(syncedMsg.getFolderId());
try {
mbox.invokeJaxb(new ConvActionRequest(sel));
} catch (SoapFaultException sfe) {
fail("SoapFaultException caught when deleting item from RSS datasource folder - " + sfe.getMessage());
}
// Delete folder, import data, and make sure that the data source was deleted.
// Data source import runs asynchronously, so poll until the data source is gone.
mbox.deleteFolder(rssFolder.getId());
// JBF - do not do the import; it will fail if DS is already deleted
// mbox.importData(list);
// XXX bburtin: disabled check to avoid false positives (bug 54816). Some sort
// of race condition is causing this check to fail intermittently. I was unable
// to consistently repro.
/*
for (int i = 1; i <= 10; i++) {
ds = (ZRssDataSource) getDataSource(mbox, rssFolder.getId());
if (ds == null) {
break;
}
Thread.sleep(500);
}
assertNull(ds);
*/
}
Aggregations