Search in sources :

Example 1 with EphemeralLocation

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

the class MigrateAttributesTest method testAttributeMigration.

/*
     * Test end-to-end AttributeMigration
     */
@Test
public void testAttributeMigration() throws Exception {
    EphemeralStore destination = EphemeralStore.getFactory().getStore();
    EntrySource source = new DummyEntrySource(acct);
    Multimap<String, Object> deletedAttrs = LinkedListMultimap.create();
    List<String> attrsToMigrate = Arrays.asList(new String[] { Provisioning.A_zimbraAuthTokens, Provisioning.A_zimbraCsrfTokenData, Provisioning.A_zimbraLastLogonTimestamp });
    //DummyMigrationCallback will store attributes in InMemoryEphemeralStore, and track deletions in deletedAttrs map
    MigrationCallback callback = new DummyMigrationCallback(destination, deletedAttrs);
    AttributeMigration migration = new AttributeMigration(attrsToMigrate, source, callback, null);
    //disable running in separate thread
    //run migration
    migration.migrateAllAccounts();
    EphemeralLocation location = new LdapEntryLocation(acct);
    EphemeralResult result = destination.get(new EphemeralKey(Provisioning.A_zimbraAuthTokens, "1234"), location);
    assertEquals("server_1", result.getValue());
    result = destination.get(new EphemeralKey(Provisioning.A_zimbraAuthTokens, "5678"), location);
    assertEquals("server_2", result.getValue());
    result = destination.get(new EphemeralKey(Provisioning.A_zimbraCsrfTokenData, "crumb1"), location);
    assertEquals("data1", result.getValue());
    result = destination.get(new EphemeralKey(Provisioning.A_zimbraCsrfTokenData, "crumb2"), location);
    assertEquals("data2", result.getValue());
    result = destination.get(new EphemeralKey(Provisioning.A_zimbraLastLogonTimestamp), location);
    assertEquals("currentdate", result.getValue());
    Collection<Object> deleted = deletedAttrs.get(Provisioning.A_zimbraAuthTokens);
    assertTrue(deleted.contains(authToken1));
    assertTrue(deleted.contains(authToken2));
    deleted = deletedAttrs.get(Provisioning.A_zimbraCsrfTokenData);
    assertTrue(deleted.contains(csrfToken1));
    assertTrue(deleted.contains(csrfToken2));
    deleted = deletedAttrs.get(Provisioning.A_zimbraLastLogonTimestamp);
    assertTrue(deleted.contains(lastLogon));
}
Also used : EphemeralLocation(com.zimbra.cs.ephemeral.EphemeralLocation) MigrationCallback(com.zimbra.cs.ephemeral.migrate.AttributeMigration.MigrationCallback) EphemeralKey(com.zimbra.cs.ephemeral.EphemeralKey) EntrySource(com.zimbra.cs.ephemeral.migrate.AttributeMigration.EntrySource) EphemeralResult(com.zimbra.cs.ephemeral.EphemeralResult) LdapEntryLocation(com.zimbra.cs.ephemeral.LdapEntryLocation) FallbackEphemeralStore(com.zimbra.cs.ephemeral.FallbackEphemeralStore) LdapEphemeralStore(com.zimbra.cs.ephemeral.LdapEphemeralStore) EphemeralStore(com.zimbra.cs.ephemeral.EphemeralStore) InMemoryEphemeralStore(com.zimbra.cs.ephemeral.InMemoryEphemeralStore) Test(org.junit.Test)

Example 2 with EphemeralLocation

use of com.zimbra.cs.ephemeral.EphemeralLocation 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 3 with EphemeralLocation

use of com.zimbra.cs.ephemeral.EphemeralLocation 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 4 with EphemeralLocation

use of com.zimbra.cs.ephemeral.EphemeralLocation 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 5 with EphemeralLocation

use of com.zimbra.cs.ephemeral.EphemeralLocation 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)

Aggregations

EphemeralLocation (com.zimbra.cs.ephemeral.EphemeralLocation)9 EphemeralStore (com.zimbra.cs.ephemeral.EphemeralStore)9 LdapEntryLocation (com.zimbra.cs.ephemeral.LdapEntryLocation)9 LdapEphemeralStore (com.zimbra.cs.ephemeral.LdapEphemeralStore)9 EphemeralKey (com.zimbra.cs.ephemeral.EphemeralKey)5 EphemeralResult (com.zimbra.cs.ephemeral.EphemeralResult)2 AttributeInfo (com.zimbra.cs.account.AttributeInfo)1 FallbackEphemeralStore (com.zimbra.cs.ephemeral.FallbackEphemeralStore)1 InMemoryEphemeralStore (com.zimbra.cs.ephemeral.InMemoryEphemeralStore)1 AttributeConverter (com.zimbra.cs.ephemeral.migrate.AttributeConverter)1 EntrySource (com.zimbra.cs.ephemeral.migrate.AttributeMigration.EntrySource)1 MigrationCallback (com.zimbra.cs.ephemeral.migrate.AttributeMigration.MigrationCallback)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 Test (org.junit.Test)1