Search in sources :

Example 6 with EphemeralStore

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

the class Entry method purgeEphemeralAttr.

public void purgeEphemeralAttr(String key) throws ServiceException {
    EphemeralLocation location = new LdapEntryLocation(this);
    EphemeralStore store = EphemeralStore.getFactory().getStore();
    store.purgeExpired(new EphemeralKey(key), location);
}
Also used : LdapEntryLocation(com.zimbra.cs.ephemeral.LdapEntryLocation) EphemeralLocation(com.zimbra.cs.ephemeral.EphemeralLocation) LdapEphemeralStore(com.zimbra.cs.ephemeral.LdapEphemeralStore) EphemeralStore(com.zimbra.cs.ephemeral.EphemeralStore) EphemeralKey(com.zimbra.cs.ephemeral.EphemeralKey)

Example 7 with EphemeralStore

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

the class Entry method modifyEphemeralAttr.

public void modifyEphemeralAttr(String key, String dynamicComponent, String[] values, boolean update, Expiration expiration) throws ServiceException {
    EphemeralLocation location = new LdapEntryLocation(this);
    EphemeralStore store = EphemeralStore.getFactory().getStore();
    for (String value : values) {
        modifyEphemeralAttrInternal(key, dynamicComponent, value, update, expiration, store, location);
    }
}
Also used : LdapEntryLocation(com.zimbra.cs.ephemeral.LdapEntryLocation) EphemeralLocation(com.zimbra.cs.ephemeral.EphemeralLocation) LdapEphemeralStore(com.zimbra.cs.ephemeral.LdapEphemeralStore) EphemeralStore(com.zimbra.cs.ephemeral.EphemeralStore)

Example 8 with EphemeralStore

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

the class Entry method modifyEphemeralAttr.

public void modifyEphemeralAttr(EphemeralInput input, boolean update) throws ServiceException {
    EphemeralLocation location = new LdapEntryLocation(this);
    EphemeralStore store = EphemeralStore.getFactory().getStore();
    if (update) {
        store.update(input, location);
    } else {
        store.set(input, location);
    }
}
Also used : LdapEntryLocation(com.zimbra.cs.ephemeral.LdapEntryLocation) EphemeralLocation(com.zimbra.cs.ephemeral.EphemeralLocation) LdapEphemeralStore(com.zimbra.cs.ephemeral.LdapEphemeralStore) EphemeralStore(com.zimbra.cs.ephemeral.EphemeralStore)

Example 9 with EphemeralStore

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

the class Entry method modifyEphemeralAttr.

public void modifyEphemeralAttr(String key, String dynamicComponent, String value, boolean update, Expiration expiration) throws ServiceException {
    EphemeralLocation location = new LdapEntryLocation(this);
    EphemeralStore store = EphemeralStore.getFactory().getStore();
    modifyEphemeralAttrInternal(key, dynamicComponent, value, update, expiration, store, location);
}
Also used : LdapEntryLocation(com.zimbra.cs.ephemeral.LdapEntryLocation) EphemeralLocation(com.zimbra.cs.ephemeral.EphemeralLocation) LdapEphemeralStore(com.zimbra.cs.ephemeral.LdapEphemeralStore) EphemeralStore(com.zimbra.cs.ephemeral.EphemeralStore)

Example 10 with EphemeralStore

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

the class Entry method getEphemeralAttrs.

/**
 * Returns values for non-dynamic ephemeral attributes.
 */
public Map<String, Object> getEphemeralAttrs() {
    Map<String, Object> attrs = new HashMap<String, Object>();
    try {
        EphemeralStore.Factory ephemeralFactory = EphemeralStore.getFactory(FailureMode.safe);
        if (ephemeralFactory == null || ephemeralFactory instanceof LdapEphemeralStore.Factory) {
            // This also catches scenarios where the EphemeralStore is not available.
            return attrs;
        }
        Map<String, AttributeInfo> ephemeralAttrs = mAttrMgr.getNonDynamicEphemeralAttrs(getEntryType());
        if (ephemeralAttrs == null) {
            return attrs;
        }
        for (Map.Entry<String, AttributeInfo> entry : ephemeralAttrs.entrySet()) {
            String attrName = entry.getKey();
            AttributeInfo info = entry.getValue();
            EphemeralResult result = getEphemeralAttr(attrName);
            if (!result.isEmpty()) {
                switch(info.getType()) {
                    case TYPE_BOOLEAN:
                        attrs.put(attrName, result.getBoolValue());
                        break;
                    case TYPE_INTEGER:
                        attrs.put(attrName, result.getIntValue());
                        break;
                    case TYPE_LONG:
                        attrs.put(attrName, result.getLongValue());
                        break;
                    default:
                        attrs.put(attrName, result.getValue());
                        break;
                }
            }
        }
    } catch (ServiceException e) {
        // don't propagate this exception, since we don't want to interrupt getAttrs() calls
        ZimbraLog.ephemeral.warn("unable to get ephemeral attributes for %s %s", getEntryType().getName(), getLabel());
    }
    return attrs;
}
Also used : LdapEphemeralStore(com.zimbra.cs.ephemeral.LdapEphemeralStore) HashMap(java.util.HashMap) EphemeralResult(com.zimbra.cs.ephemeral.EphemeralResult) ServiceException(com.zimbra.common.service.ServiceException) ZJSONObject(com.zimbra.client.ZJSONObject) ToZJSONObject(com.zimbra.client.ToZJSONObject) HashMap(java.util.HashMap) Map(java.util.Map) LdapEphemeralStore(com.zimbra.cs.ephemeral.LdapEphemeralStore) EphemeralStore(com.zimbra.cs.ephemeral.EphemeralStore)

Aggregations

EphemeralStore (com.zimbra.cs.ephemeral.EphemeralStore)15 LdapEphemeralStore (com.zimbra.cs.ephemeral.LdapEphemeralStore)11 EphemeralLocation (com.zimbra.cs.ephemeral.EphemeralLocation)9 LdapEntryLocation (com.zimbra.cs.ephemeral.LdapEntryLocation)9 EphemeralKey (com.zimbra.cs.ephemeral.EphemeralKey)5 EphemeralResult (com.zimbra.cs.ephemeral.EphemeralResult)3 EntrySource (com.zimbra.cs.ephemeral.migrate.AttributeMigration.EntrySource)3 MigrationCallback (com.zimbra.cs.ephemeral.migrate.AttributeMigration.MigrationCallback)3 Test (org.junit.Test)3 ServiceException (com.zimbra.common.service.ServiceException)2 Factory (com.zimbra.cs.ephemeral.EphemeralStore.Factory)2 FallbackEphemeralStore (com.zimbra.cs.ephemeral.FallbackEphemeralStore)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ToZJSONObject (com.zimbra.client.ToZJSONObject)1 ZJSONObject (com.zimbra.client.ZJSONObject)1 Level (com.zimbra.common.util.Log.Level)1 AttributeInfo (com.zimbra.cs.account.AttributeInfo)1 Server (com.zimbra.cs.account.Server)1