Search in sources :

Example 6 with MetadataList

use of com.zimbra.cs.mailbox.MetadataList in project zm-mailbox by Zimbra.

the class LocalImapMailboxStore method saveSubscriptions.

@Override
public void saveSubscriptions(OperationContext octxt, Set<String> subs) throws ServiceException {
    MetadataList slist = new MetadataList();
    if (subs != null && !subs.isEmpty()) {
        for (String sub : subs) slist.add(sub);
    }
    mailbox.setConfig(octxt, AccountUtil.SN_IMAP, new Metadata().put(AccountUtil.FN_SUBSCRIPTIONS, slist));
}
Also used : MetadataList(com.zimbra.cs.mailbox.MetadataList) Metadata(com.zimbra.cs.mailbox.Metadata)

Example 7 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)

Example 8 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 9 with MetadataList

use of com.zimbra.cs.mailbox.MetadataList in project zm-mailbox by Zimbra.

the class TestRemoteImapMailboxStore method testListIMAPSubscriptions.

@Test
public void testListIMAPSubscriptions() throws Exception {
    String path = NAME_PREFIX + "_testPath";
    MetadataList slist = new MetadataList();
    slist.add(path);
    // imitate subscription
    Mailbox mbox = TestUtil.getMailbox(USER_NAME);
    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
    ZMailbox zmbox = TestUtil.getZMailbox(USER_NAME);
    RemoteImapMailboxStore remoteStore = new RemoteImapMailboxStore(zmbox, TestUtil.getAccount(USER_NAME).getId());
    Set<String> subs = remoteStore.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) ZMailbox(com.zimbra.client.ZMailbox) Mailbox(com.zimbra.cs.mailbox.Mailbox) ZMailbox(com.zimbra.client.ZMailbox) RemoteImapMailboxStore(com.zimbra.cs.imap.RemoteImapMailboxStore) Metadata(com.zimbra.cs.mailbox.Metadata) Test(org.junit.Test)

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