Search in sources :

Example 1 with MetadataList

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;
}
Also used : MetadataList(com.zimbra.cs.mailbox.MetadataList) HashSet(java.util.HashSet)

Example 2 with MetadataList

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()));
}
Also used : MetadataList(com.zimbra.cs.mailbox.MetadataList) ZMailbox(com.zimbra.client.ZMailbox) Mailbox(com.zimbra.cs.mailbox.Mailbox) ZMailbox(com.zimbra.client.ZMailbox) Metadata(com.zimbra.cs.mailbox.Metadata) Test(org.junit.Test)

Example 3 with MetadataList

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));
}
Also used : MetadataList(com.zimbra.cs.mailbox.MetadataList) Metadata(com.zimbra.cs.mailbox.Metadata)

Example 4 with MetadataList

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));
}
Also used : MetadataList(com.zimbra.cs.mailbox.MetadataList) Metadata(com.zimbra.cs.mailbox.Metadata) Test(org.junit.Test)

Example 5 with MetadataList

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;
}
Also used : MetadataList(com.zimbra.cs.mailbox.MetadataList) Metadata(com.zimbra.cs.mailbox.Metadata) ArrayList(java.util.ArrayList)

Aggregations

MetadataList (com.zimbra.cs.mailbox.MetadataList)9 Metadata (com.zimbra.cs.mailbox.Metadata)7 Test (org.junit.Test)3 ZMailbox (com.zimbra.client.ZMailbox)2 Mailbox (com.zimbra.cs.mailbox.Mailbox)2 HashSet (java.util.HashSet)2 Account (com.zimbra.cs.account.Account)1 RemoteImapMailboxStore (com.zimbra.cs.imap.RemoteImapMailboxStore)1 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)1 SaveIMAPSubscriptionsRequest (com.zimbra.soap.mail.message.SaveIMAPSubscriptionsRequest)1 SaveIMAPSubscriptionsResponse (com.zimbra.soap.mail.message.SaveIMAPSubscriptionsResponse)1 ArrayList (java.util.ArrayList)1