Search in sources :

Example 56 with Metadata

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

the class Period method encodeMetadata.

public Metadata encodeMetadata() {
    Metadata meta = new Metadata();
    meta.put(FN_START, mStart.getDateTimePartString(false));
    if (mHasEnd)
        meta.put(FN_END, mEnd.getDateTimePartString(false));
    else
        meta.put(FN_DURATION, mDuration);
    return meta;
}
Also used : Metadata(com.zimbra.cs.mailbox.Metadata)

Example 57 with Metadata

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

the class Util method decodeXParamsFromMetadata.

public static List<ZParameter> decodeXParamsFromMetadata(Metadata meta) throws ServiceException {
    int xparamCount = (int) meta.getLong(FN_NUM_XPROPS_OR_XPARAMS, 0);
    if (xparamCount > 0) {
        List<ZParameter> list = new ArrayList<ZParameter>(xparamCount);
        for (int paramNum = 0; paramNum < xparamCount; paramNum++) {
            Metadata paramMeta = meta.getMap(FN_XPROP_OR_XPARAM + paramNum, true);
            if (paramMeta == null)
                continue;
            String paramName = paramMeta.get(FN_NAME, null);
            if (paramName == null)
                continue;
            String paramValue = paramMeta.get(FN_VALUE, null);
            ZParameter xparam = new ZParameter(paramName, paramValue);
            list.add(xparam);
        }
        return list;
    }
    return null;
}
Also used : ArrayList(java.util.ArrayList) Metadata(com.zimbra.cs.mailbox.Metadata) ZParameter(com.zimbra.common.calendar.ZCalendar.ZParameter)

Example 58 with Metadata

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

the class SetConfig method redo.

@Override
public void redo() throws Exception {
    Mailbox mbox = MailboxManager.getInstance().getMailboxById(getMailboxId());
    mbox.setConfig(getOperationContext(), mSection, mConfig.equals("") ? null : new Metadata(mConfig));
}
Also used : Mailbox(com.zimbra.cs.mailbox.Mailbox) Metadata(com.zimbra.cs.mailbox.Metadata)

Example 59 with Metadata

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

the class ICalReply method deserializeData.

@Override
protected void deserializeData(RedoLogInput in) throws IOException {
    try {
        ICalTimeZone localTz = Util.decodeTimeZoneFromMetadata(new Metadata(in.readUTF()));
        mInvite = Invite.decodeMetadata(getMailboxId(), new Metadata(in.readUTF()), null, localTz);
        mSender = in.readUTF();
    } catch (ServiceException ex) {
        ex.printStackTrace();
        throw new IOException("Cannot read serialized entry for ICalReply " + ex.toString());
    }
}
Also used : ServiceException(com.zimbra.common.service.ServiceException) Metadata(com.zimbra.cs.mailbox.Metadata) IOException(java.io.IOException) ICalTimeZone(com.zimbra.common.calendar.ICalTimeZone)

Example 60 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)60 Mailbox (com.zimbra.cs.mailbox.Mailbox)16 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 OperationContext (com.zimbra.cs.mailbox.OperationContext)7 ICalTimeZone (com.zimbra.common.calendar.ICalTimeZone)6 MailItem (com.zimbra.cs.mailbox.MailItem)5 HashMap (java.util.HashMap)5 ZParameter (com.zimbra.common.calendar.ZCalendar.ZParameter)4 DataSource (com.zimbra.cs.account.DataSource)4 DbDataSource (com.zimbra.cs.db.DbDataSource)4 DataSourceItem (com.zimbra.cs.db.DbDataSource.DataSourceItem)4 Map (java.util.Map)4 Entry (java.util.Map.Entry)4 ParsedDateTime (com.zimbra.common.calendar.ParsedDateTime)3