Search in sources :

Example 6 with SessionCachingMetadataDomainRepository

use of org.pentaho.platform.plugin.services.metadata.SessionCachingMetadataDomainRepository in project pentaho-platform by pentaho.

the class SessionCachingMetadataDomainRepositoryIT method testGetDomain_null_session.

public void testGetDomain_null_session() throws Exception {
    final String SESSION_ID = null;
    // $NON-NLS-1$
    final String ID = "1";
    MockSessionAwareMetadataDomainRepository mock = new MockSessionAwareMetadataDomainRepository();
    mock.storeDomain(getTestDomain(ID), false);
    SessionCachingMetadataDomainRepository repo = new SessionCachingMetadataDomainRepository(mock);
    // $NON-NLS-1$
    PentahoSessionHolder.setSession(new StandaloneSession("Standalone Session", SESSION_ID));
    Domain domain = repo.getDomain(ID);
    // Description will equal the id when no description is provided (null session)
    assertEquals(ID, domain.getDescription(TEST_LOCALE));
}
Also used : StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) SessionCachingMetadataDomainRepository(org.pentaho.platform.plugin.services.metadata.SessionCachingMetadataDomainRepository) Domain(org.pentaho.metadata.model.Domain)

Example 7 with SessionCachingMetadataDomainRepository

use of org.pentaho.platform.plugin.services.metadata.SessionCachingMetadataDomainRepository in project pentaho-platform by pentaho.

the class SessionCachingMetadataDomainRepositoryIT method testRemoveDomain.

/**
 * Make sure removing a domain removes all cached instances of the domain
 */
public void testRemoveDomain() throws Exception {
    // $NON-NLS-1$
    final String ID1 = "1";
    // $NON-NLS-1$
    final String ID2 = "2";
    MockSessionAwareMetadataDomainRepository mock = new MockSessionAwareMetadataDomainRepository();
    mock.storeDomain(getTestDomain(ID1), false);
    mock.storeDomain(getTestDomain(ID2), false);
    SessionCachingMetadataDomainRepository repo = new SessionCachingMetadataDomainRepository(mock);
    // $NON-NLS-1$ //$NON-NLS-2$
    PentahoSessionHolder.setSession(new StandaloneSession("Standalone Session", "1"));
    Domain domainFromSession1 = repo.getDomain(ID1);
    assertNotNull(domainFromSession1);
    // $NON-NLS-1$
    assertEquals(1, mock.getInvocationCount("getDomain"));
    // $NON-NLS-1$ //$NON-NLS-2$
    PentahoSessionHolder.setSession(new StandaloneSession("Standalone Session", "2"));
    Domain domainFromSession2 = repo.getDomain(ID1);
    assertNotNull(domainFromSession2);
    // $NON-NLS-1$
    assertEquals(2, mock.getInvocationCount("getDomain"));
    assertEquals(2, PentahoSystem.getCacheManager(null).getAllKeysFromRegionCache(CACHE_NAME).size());
    repo.removeDomain(ID1);
    assertEquals(0, PentahoSystem.getCacheManager(null).getAllKeysFromRegionCache(CACHE_NAME).size());
    // Calling getDomain() now should increment the call count to the delegate
    repo.getDomain(ID2);
    // $NON-NLS-1$
    assertEquals(3, mock.getInvocationCount("getDomain"));
    // There should now only be one in the cache
    assertEquals(1, PentahoSystem.getCacheManager(null).getAllKeysFromRegionCache(CACHE_NAME).size());
}
Also used : StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) SessionCachingMetadataDomainRepository(org.pentaho.platform.plugin.services.metadata.SessionCachingMetadataDomainRepository) Domain(org.pentaho.metadata.model.Domain)

Example 8 with SessionCachingMetadataDomainRepository

use of org.pentaho.platform.plugin.services.metadata.SessionCachingMetadataDomainRepository in project pentaho-platform by pentaho.

the class SessionCachingMetadataDomainRepositoryIT method testOnLogout.

public void testOnLogout() throws Exception {
    // $NON-NLS-1$
    final String ID1 = "1";
    // $NON-NLS-1$
    final String ID2 = "2";
    MockSessionAwareMetadataDomainRepository mock = new MockSessionAwareMetadataDomainRepository();
    SessionCachingMetadataDomainRepository repo = new SessionCachingMetadataDomainRepository(mock);
    repo.storeDomain(getTestDomain(ID1), false);
    repo.storeDomain(getTestDomain(ID2), false);
    // $NON-NLS-1$ //$NON-NLS-2$
    PentahoSessionHolder.setSession(new StandaloneSession("Standalone Session", "1"));
    repo.getDomain(ID1);
    // $NON-NLS-1$ //$NON-NLS-2$
    IPentahoSession session2 = new StandaloneSession("Standalone Session", "2");
    PentahoSessionHolder.setSession(session2);
    repo.getDomain(ID2);
    assertEquals(2, PentahoSystem.getCacheManager(null).getAllKeysFromRegionCache(CACHE_NAME).size());
    // Logging out session 2 should only remove cached domains from session 2
    repo.onLogout(session2);
    assertEquals(1, PentahoSystem.getCacheManager(null).getAllKeysFromRegionCache(CACHE_NAME).size());
}
Also used : StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) SessionCachingMetadataDomainRepository(org.pentaho.platform.plugin.services.metadata.SessionCachingMetadataDomainRepository)

Example 9 with SessionCachingMetadataDomainRepository

use of org.pentaho.platform.plugin.services.metadata.SessionCachingMetadataDomainRepository in project pentaho-platform by pentaho.

the class SessionCachingMetadataDomainRepositoryIT method testGenerateRowLevelSecurityConstraint.

public void testGenerateRowLevelSecurityConstraint() throws Exception {
    MockSessionAwareMetadataDomainRepository mock = new MockSessionAwareMetadataDomainRepository();
    SessionCachingMetadataDomainRepository repo = new SessionCachingMetadataDomainRepository(mock);
    // Only thing to do here is make sure the return value is the same; cache shouldn't do anything here
    assertEquals(mock.generateRowLevelSecurityConstraint(null), repo.generateRowLevelSecurityConstraint(null));
    // $NON-NLS-1$
    assertEquals(2, mock.getInvocationCount("generateRowLevelSecurityConstraint"));
}
Also used : SessionCachingMetadataDomainRepository(org.pentaho.platform.plugin.services.metadata.SessionCachingMetadataDomainRepository)

Example 10 with SessionCachingMetadataDomainRepository

use of org.pentaho.platform.plugin.services.metadata.SessionCachingMetadataDomainRepository in project pentaho-platform by pentaho.

the class SessionCachingMetadataDomainRepositoryIT method testFlushDomains.

public void testFlushDomains() throws Exception {
    // $NON-NLS-1$
    final String ID = "1";
    MockSessionAwareMetadataDomainRepository mock = new MockSessionAwareMetadataDomainRepository();
    SessionCachingMetadataDomainRepository repo = new SessionCachingMetadataDomainRepository(mock);
    // $NON-NLS-1$ //$NON-NLS-2$
    PentahoSessionHolder.setSession(new StandaloneSession("Standalone Session", "1"));
    repo.storeDomain(getTestDomain(ID), false);
    repo.getDomain(ID);
    assertEquals(1, PentahoSystem.getCacheManager(null).getAllKeysFromRegionCache(CACHE_NAME).size());
    // $NON-NLS-1$ //$NON-NLS-2$
    PentahoSessionHolder.setSession(new StandaloneSession("Standalone Session", "2"));
    repo.getDomain(ID);
    assertEquals(2, PentahoSystem.getCacheManager(null).getAllKeysFromRegionCache(CACHE_NAME).size());
    assertEquals(1, repo.getDomainIds().size());
    repo.flushDomains();
    // $NON-NLS-1$
    assertEquals(1, mock.getInvocationCount("flushDomains"));
    assertEquals(0, repo.getDomainIds().size());
    assertEquals(0, mock.getDomainIds().size());
    assertEquals(1, PentahoSystem.getCacheManager(null).getAllKeysFromRegionCache(CACHE_NAME).size());
}
Also used : StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) SessionCachingMetadataDomainRepository(org.pentaho.platform.plugin.services.metadata.SessionCachingMetadataDomainRepository)

Aggregations

SessionCachingMetadataDomainRepository (org.pentaho.platform.plugin.services.metadata.SessionCachingMetadataDomainRepository)14 StandaloneSession (org.pentaho.platform.engine.core.system.StandaloneSession)11 Domain (org.pentaho.metadata.model.Domain)5 EnumSet (java.util.EnumSet)1 LogicalModel (org.pentaho.metadata.model.LogicalModel)1 DomainAlreadyExistsException (org.pentaho.metadata.repository.DomainAlreadyExistsException)1 IPentahoObjectFactory (org.pentaho.platform.api.engine.IPentahoObjectFactory)1 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)1 IAclNodeHelper (org.pentaho.platform.api.repository2.unified.IAclNodeHelper)1 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)1 AggregateObjectFactory (org.pentaho.platform.engine.core.system.objfac.AggregateObjectFactory)1 SimpleObjectFactory (org.pentaho.test.platform.engine.core.SimpleObjectFactory)1