use of com.zimbra.cs.mailbox.MetadataList in project zm-mailbox by Zimbra.
the class ImapCredentials method parseConfig.
private Set<String> parseConfig(Metadata config) throws ServiceException {
if (config == null || !config.containsKey(FN_SUBSCRIPTIONS))
return null;
MetadataList slist = config.getList(FN_SUBSCRIPTIONS, true);
if (slist == null || slist.isEmpty())
return null;
Set<String> subscriptions = new HashSet<String>(slist.size());
for (int i = 0; i < slist.size(); i++) subscriptions.add(slist.get(i));
return subscriptions;
}
use of com.zimbra.cs.mailbox.MetadataList in project zm-mailbox by Zimbra.
the class TestZClient method testListIMAPSubscriptions.
@Test
public void testListIMAPSubscriptions() throws Exception {
String path = NAME_PREFIX + "_testPath";
MetadataList slist = new MetadataList();
slist.add(path);
Mailbox mbox = TestUtil.getMailbox(USER_NAME);
// imitate subscription
mbox.setConfig(null, "imap", new Metadata().put("subs", slist));
// check that subscription was saved in mailbox configuration
Metadata config = mbox.getConfig(null, "imap");
assertNotNull(config);
MetadataList rlist = config.getList("subs", true);
assertNotNull(rlist);
assertNotNull(rlist.get(0));
assertTrue(rlist.get(0).equalsIgnoreCase(path));
ZMailbox zmbox = TestUtil.getZMailbox(USER_NAME);
Set<String> subs = zmbox.listIMAPSubscriptions();
assertNotNull(subs);
assertFalse(subs.isEmpty());
assertTrue(path.equalsIgnoreCase(subs.iterator().next()));
}
use of com.zimbra.cs.mailbox.MetadataList in project zm-mailbox by Zimbra.
the class ImapCredentials method saveConfig.
private void saveConfig(Set<String> subscriptions) throws ServiceException {
MetadataList slist = new MetadataList();
if (subscriptions != null && !subscriptions.isEmpty()) {
for (String sub : subscriptions) slist.add(sub);
}
getMailbox().setConfig(getContext(), SN_IMAP, new Metadata().put(FN_SUBSCRIPTIONS, slist));
}
use of com.zimbra.cs.mailbox.MetadataList in project zm-mailbox by Zimbra.
the class LocalImapMailboxStoreTest method testListSubscriptions.
@Test
public void testListSubscriptions() throws Exception {
String path = "testPath";
MetadataList slist = new MetadataList();
slist.add(path);
// imitate subscription
mbox.setConfig(null, "imap", new Metadata().put("subs", slist));
// check that subscription was saved in mailbox configuration
Metadata config = mbox.getConfig(null, "imap");
Assert.assertNotNull(config);
MetadataList rlist = config.getList("subs", true);
Assert.assertNotNull(rlist);
Assert.assertNotNull(rlist.get(0));
Assert.assertTrue(rlist.get(0).equalsIgnoreCase(path));
// test listSubscriptions method
LocalImapMailboxStore localStore = new LocalImapMailboxStore(mbox);
Set<String> subs = localStore.listSubscriptions(null);
Assert.assertNotNull(subs);
Assert.assertEquals(1, subs.size());
String sub = subs.iterator().next();
Assert.assertTrue(sub.equalsIgnoreCase(path));
}
use of com.zimbra.cs.mailbox.MetadataList in project zm-mailbox by Zimbra.
the class CalList method encodeMetadata.
Metadata encodeMetadata() {
Metadata meta = new Metadata();
List<Integer> list = new ArrayList<Integer>(mCalendars);
MetadataList calsMetaList = new MetadataList(list);
meta.put(FN_CALS, calsMetaList);
meta.put(FN_VERSION_PREFIX, mVerPrefix);
meta.put(FN_VERSION_SEQ, mVerSeq);
return meta;
}
Aggregations