Search in sources :

Example 66 with Metadata

use of com.zimbra.cs.mailbox.Metadata 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)

Example 67 with Metadata

use of com.zimbra.cs.mailbox.Metadata 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 68 with Metadata

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

the class TestMetadata method testMetadata.

/**
     * Tests insert, update and delete operations for mailbox metadata.
     */
public void testMetadata() throws Exception {
    ZimbraLog.test.info("Starting testMetadata");
    Mailbox mbox = TestUtil.getMailbox(USER_NAME);
    assertNull(mbox.getConfig(null, METADATA_SECTION));
    // Insert
    Metadata config = new Metadata();
    config.put("string", "mystring");
    mbox.setConfig(null, METADATA_SECTION, config);
    config = mbox.getConfig(null, METADATA_SECTION);
    assertEquals("mystring", config.get("string"));
    // Update
    config.put("long", 87);
    mbox.setConfig(null, METADATA_SECTION, config);
    config = mbox.getConfig(null, METADATA_SECTION);
    assertEquals(87, config.getLong("long"));
    assertEquals("mystring", config.get("string"));
    // Delete
    mbox.setConfig(null, METADATA_SECTION, null);
    assertNull(mbox.getConfig(null, METADATA_SECTION));
}
Also used : Mailbox(com.zimbra.cs.mailbox.Mailbox) Metadata(com.zimbra.cs.mailbox.Metadata)

Aggregations

Metadata (com.zimbra.cs.mailbox.Metadata)68 Mailbox (com.zimbra.cs.mailbox.Mailbox)19 ArrayList (java.util.ArrayList)15 ServiceException (com.zimbra.common.service.ServiceException)13 DbConnection (com.zimbra.cs.db.DbPool.DbConnection)9 SQLException (java.sql.SQLException)9 IOException (java.io.IOException)8 PreparedStatement (java.sql.PreparedStatement)8 ResultSet (java.sql.ResultSet)8 MailItem (com.zimbra.cs.mailbox.MailItem)7 OperationContext (com.zimbra.cs.mailbox.OperationContext)7 ICalTimeZone (com.zimbra.common.calendar.ICalTimeZone)6 MetadataList (com.zimbra.cs.mailbox.MetadataList)6 HashMap (java.util.HashMap)6 Folder (com.zimbra.cs.mailbox.Folder)5 Map (java.util.Map)5 Entry (java.util.Map.Entry)5 ZMailbox (com.zimbra.client.ZMailbox)4 ZParameter (com.zimbra.common.calendar.ZCalendar.ZParameter)4 DataSource (com.zimbra.cs.account.DataSource)4