Search in sources :

Example 6 with CustomMetadataList

use of com.zimbra.cs.mailbox.MailItem.CustomMetadata.CustomMetadataList in project zm-mailbox by Zimbra.

the class MailItem method decodeMetadata.

void decodeMetadata(Metadata meta) throws ServiceException {
    if (meta == null)
        return;
    mRGBColor = Color.fromMetadata(meta.getLong(Metadata.FN_COLOR, DEFAULT_COLOR));
    mMetaVersion = (int) meta.getLong(Metadata.FN_METADATA_VERSION, 1);
    mVersion = (int) meta.getLong(Metadata.FN_VERSION, 1);
    mExtendedData = null;
    for (Map.Entry<String, ?> entry : meta.asMap().entrySet()) {
        String key = entry.getKey();
        if (key.startsWith(CUSTOM_META_PREFIX)) {
            if (mExtendedData == null) {
                mExtendedData = new CustomMetadataList();
            }
            mExtendedData.addSection(key.substring(CUSTOM_META_PREFIX.length()), entry.getValue().toString());
        }
    }
    ACL acl = null;
    if (meta.containsKey(Metadata.FN_RIGHTS_MAP)) {
        //new format
        acl = makeACLFromMap(Metadata.FN_RIGHTS_MAP, meta);
    } else if (meta.containsKey(Metadata.FN_RIGHTS)) {
        try {
            //try the HELIX list format
            MetadataList mlistACL = meta.getList(Metadata.FN_RIGHTS, true);
            if (mlistACL != null) {
                acl = new ACL(mlistACL);
            }
        } catch (ServiceException se) {
            //map may exist in old attr for a short time between bug 60048 and bug 68928
            ZimbraLog.mailbox.warn("Metadata.FN_RIGHTS exists, but is not list. Should never see this outside CF/DF!");
            acl = makeACLFromMap(Metadata.FN_RIGHTS, meta);
        }
    }
    if (acl != null) {
        rights = acl.isEmpty() ? null : acl;
        if (!isTagged(Flag.FlagInfo.NO_INHERIT)) {
            alterTag(mMailbox.getFlagById(Flag.ID_NO_INHERIT), true);
        }
    }
}
Also used : CustomMetadataList(com.zimbra.cs.mailbox.MailItem.CustomMetadata.CustomMetadataList) ServiceException(com.zimbra.common.service.ServiceException) CustomMetadataList(com.zimbra.cs.mailbox.MailItem.CustomMetadata.CustomMetadataList) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap)

Aggregations

CustomMetadataList (com.zimbra.cs.mailbox.MailItem.CustomMetadata.CustomMetadataList)6 ImmutableMap (com.google.common.collect.ImmutableMap)1 ServiceException (com.zimbra.common.service.ServiceException)1 DbMailItem (com.zimbra.cs.db.DbMailItem)1 DbTag (com.zimbra.cs.db.DbTag)1 ParsedMessage (com.zimbra.cs.mime.ParsedMessage)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1