Search in sources :

Example 6 with ContactEntry

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

the class ContactRankings method remove.

public static void remove(String accountId, String email) throws ServiceException {
    if (!LC.contact_ranking_enabled.booleanValue())
        return;
    ContactRankings rankings = new ContactRankings(accountId);
    ContactEntry entry = rankings.mEntries.get(email.toLowerCase());
    if (entry != null)
        rankings.remove(entry);
    rankings.writeToDatabase();
}
Also used : ContactEntry(com.zimbra.cs.mailbox.ContactAutoComplete.ContactEntry)

Example 7 with ContactEntry

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

the class ContactRankings method readFromDatabase.

private synchronized void readFromDatabase() throws ServiceException {
    Mailbox mbox = MailboxManager.getInstance().getMailboxByAccountId(mAccountId);
    Metadata config = mbox.getConfig(null, CONFIG_KEY_CONTACT_RANKINGS);
    if (config == null) {
        config = new Metadata();
        mbox.setConfig(null, CONFIG_KEY_CONTACT_RANKINGS, config);
    }
    for (Map.Entry<Object, Object> entry : config.map.entrySet()) {
        if (entry.getValue() instanceof Map) {
            Map<?, ?> m = (Map<?, ?>) entry.getValue();
            ContactEntry contact = new ContactEntry();
            contact.mEmail = ((String) entry.getKey()).toLowerCase();
            Long num = (Long) m.get(KEY_RANKING);
            contact.mRanking = num.intValue();
            num = (Long) m.get(KEY_LAST_ACCESSED);
            contact.mLastAccessed = num.longValue();
            contact.setName((String) m.get(KEY_NAME));
            contact.mFolderId = ContactAutoComplete.FOLDER_ID_UNKNOWN;
            add(contact);
        }
    }
    dump("reading");
}
Also used : ContactEntry(com.zimbra.cs.mailbox.ContactAutoComplete.ContactEntry) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) Map(java.util.Map)

Aggregations

ContactEntry (com.zimbra.cs.mailbox.ContactAutoComplete.ContactEntry)7 HashMap (java.util.HashMap)2 Element (com.zimbra.common.soap.Element)1 AutoCompleteResult (com.zimbra.cs.mailbox.ContactAutoComplete.AutoCompleteResult)1 ParsedContact (com.zimbra.cs.mime.ParsedContact)1 ItemId (com.zimbra.cs.service.util.ItemId)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 InternetAddress (javax.mail.internet.InternetAddress)1 Test (org.junit.Test)1