Search in sources :

Example 11 with IPentahoObjectFactory

use of org.pentaho.platform.api.engine.IPentahoObjectFactory in project pentaho-platform by pentaho.

the class PentahoBoot method configure.

/**
 * Sets up the defaults: - File-based repository - SQL datasource connections - MXL datasources - File outputs
 */
@Override
protected void configure(String solutionPath, String baseUrl, IPentahoDefinableObjectFactory factory) {
    super.configure(null, null, null);
    IPentahoObjectFactory objectFactory = getFactory();
    if (objectFactory instanceof IPentahoDefinableObjectFactory) {
        define(ISolutionEngine.class, SolutionEngine.class, Scope.LOCAL);
        define(IUnifiedRepository.class, FileSystemBackedUnifiedRepository.class, Scope.SESSION);
        // $NON-NLS-1$
        define("connection-XML", XQConnection.class, Scope.LOCAL);
        // $NON-NLS-1$
        define("connection-SQL", SQLConnection.class, Scope.LOCAL);
        // $NON-NLS-1$
        define("file", FileOutputHandler.class, Scope.LOCAL);
    }
}
Also used : IPentahoDefinableObjectFactory(org.pentaho.platform.api.engine.IPentahoDefinableObjectFactory) IPentahoObjectFactory(org.pentaho.platform.api.engine.IPentahoObjectFactory)

Example 12 with IPentahoObjectFactory

use of org.pentaho.platform.api.engine.IPentahoObjectFactory in project pentaho-platform by pentaho.

the class DefaultBackingRepositoryLifecycleManager method getTenantManager.

/**
 * @return the {@link IBackingRepositoryLifecycleManager} that this instance will use. If none has been
 *         specified, it will default to getting the information from {@link PentahoSystem.get()}
 */
public ITenantManager getTenantManager() {
    // Check ... if we haven't been injected with a lifecycle manager, get one from PentahoSystem
    try {
        IPentahoObjectFactory objectFactory = PentahoSystem.getObjectFactory();
        IPentahoSession pentahoSession = PentahoSessionHolder.getSession();
        return (null != tenantManager ? tenantManager : objectFactory.get(ITenantManager.class, "tenantMgrProxy", pentahoSession));
    } catch (ObjectFactoryException e) {
        return null;
    }
}
Also used : IPentahoObjectFactory(org.pentaho.platform.api.engine.IPentahoObjectFactory) ObjectFactoryException(org.pentaho.platform.api.engine.ObjectFactoryException) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession)

Example 13 with IPentahoObjectFactory

use of org.pentaho.platform.api.engine.IPentahoObjectFactory in project pentaho-platform by pentaho.

the class BaseTest method setUp.

@Override
public void setUp() {
    // used by test repository impl such as FileSystemRepositoryFileDao
    System.setProperty("solution.root.dir", getSolutionPath());
    messages = TestManager.getMessagesList();
    if (messages == null) {
        messages = new ArrayList<String>();
    }
    if (initOk) {
        return;
    }
    PentahoSystem.setSystemSettingsService(new PathBasedSystemSettings());
    if (PentahoSystem.getApplicationContext() == null) {
        // $NON-NLS-1$
        StandaloneApplicationContext applicationContext = new StandaloneApplicationContext(getSolutionPath(), "");
        // set the base url assuming there is a running server on port 8080
        applicationContext.setFullyQualifiedServerURL(getFullyQualifiedServerURL());
        // $NON-NLS-1$ //$NON-NLS-2$
        String inContainer = System.getProperty("incontainer", "false");
        if (inContainer.equalsIgnoreCase("false")) {
            // $NON-NLS-1$
            // Setup simple-jndi for datasources
            // $NON-NLS-1$ //$NON-NLS-2$
            System.setProperty("java.naming.factory.initial", "org.osjava.sj.SimpleContextFactory");
            // $NON-NLS-1$ //$NON-NLS-2$
            System.setProperty("org.osjava.sj.root", getSolutionPath() + "/system/simple-jndi");
            // $NON-NLS-1$ //$NON-NLS-2$
            System.setProperty("org.osjava.sj.delimiter", "/");
        }
        ApplicationContext springApplicationContext = getSpringApplicationContext();
        IPentahoObjectFactory pentahoObjectFactory = new StandaloneSpringPentahoObjectFactory();
        pentahoObjectFactory.init(null, springApplicationContext);
        PentahoSystem.registerObjectFactory(pentahoObjectFactory);
        // force Spring to inject PentahoSystem, there has got to be a better way than this, perhaps an alternate way
        // of
        // initting spring's app context
        // $NON-NLS-1$
        springApplicationContext.getBean("pentahoSystemProxy");
        // Initialize SecurityHelper with a mock for testing
        SecurityHelper.setMockInstance(new MockSecurityHelper());
        initOk = PentahoSystem.init(applicationContext);
    } else {
        initOk = true;
    }
    // $NON-NLS-1$
    assertTrue(Messages.getInstance().getString("BaseTest.ERROR_0001_FAILED_INITIALIZATION"), initOk);
}
Also used : MockSecurityHelper(org.pentaho.test.platform.engine.security.MockSecurityHelper) StandaloneApplicationContext(org.pentaho.platform.engine.core.system.StandaloneApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) IPentahoObjectFactory(org.pentaho.platform.api.engine.IPentahoObjectFactory) StandaloneApplicationContext(org.pentaho.platform.engine.core.system.StandaloneApplicationContext) PathBasedSystemSettings(org.pentaho.platform.engine.core.system.PathBasedSystemSettings) StandaloneSpringPentahoObjectFactory(org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory)

Example 14 with IPentahoObjectFactory

use of org.pentaho.platform.api.engine.IPentahoObjectFactory in project data-access by pentaho.

the class DatasourceServiceTest method setUpClass.

@BeforeClass
public static void setUpClass() throws ObjectFactoryException {
    authorizationPolicy = mock(IAuthorizationPolicy.class);
    when(authorizationPolicy.isAllowed(RepositoryReadAction.NAME)).thenReturn(true);
    when(authorizationPolicy.isAllowed(RepositoryCreateAction.NAME)).thenReturn(true);
    IPentahoObjectFactory pentahoObjectFactory = mock(IPentahoObjectFactory.class);
    when(pentahoObjectFactory.objectDefined(anyString())).thenReturn(true);
    when(pentahoObjectFactory.get(anyClass(), anyString(), any(IPentahoSession.class))).thenAnswer((Answer<Object>) invocation -> {
        if (invocation.getArguments()[0].equals(IAuthorizationPolicy.class)) {
            return authorizationPolicy;
        }
        return null;
    });
    PentahoSystem.registerObjectFactory(pentahoObjectFactory);
}
Also used : RepositoryCreateAction(org.pentaho.platform.security.policy.rolebased.actions.RepositoryCreateAction) BeforeClass(org.junit.BeforeClass) PublishAction(org.pentaho.platform.security.policy.rolebased.actions.PublishAction) RepositoryReadAction(org.pentaho.platform.security.policy.rolebased.actions.RepositoryReadAction) LogicalModel(org.pentaho.metadata.model.LogicalModel) PentahoSystem(org.pentaho.platform.engine.core.system.PentahoSystem) Matchers.anyString(org.mockito.Matchers.anyString) Domain(org.pentaho.metadata.model.Domain) ArrayList(java.util.ArrayList) ArgumentMatcher(org.mockito.ArgumentMatcher) Answer(org.mockito.stubbing.Answer) IAuthorizationPolicy(org.pentaho.platform.api.engine.IAuthorizationPolicy) PentahoAccessControlException(org.pentaho.platform.api.engine.PentahoAccessControlException) Assert.fail(org.junit.Assert.fail) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) ObjectFactoryException(org.pentaho.platform.api.engine.ObjectFactoryException) Matchers.any(org.mockito.Matchers.any) AdministerSecurityAction(org.pentaho.platform.security.policy.rolebased.actions.AdministerSecurityAction) List(java.util.List) Matchers.argThat(org.mockito.Matchers.argThat) Assert.assertFalse(org.junit.Assert.assertFalse) IPentahoObjectFactory(org.pentaho.platform.api.engine.IPentahoObjectFactory) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) Mockito.mock(org.mockito.Mockito.mock) IAuthorizationPolicy(org.pentaho.platform.api.engine.IAuthorizationPolicy) IPentahoObjectFactory(org.pentaho.platform.api.engine.IPentahoObjectFactory) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) BeforeClass(org.junit.BeforeClass)

Example 15 with IPentahoObjectFactory

use of org.pentaho.platform.api.engine.IPentahoObjectFactory in project pentaho-platform by pentaho.

the class SystemResourceIT method setUp.

@Before
public void setUp() throws Exception {
    mp = new MicroPlatform();
    mp.defineInstance(IAuthorizationPolicy.class, new TestAuthorizationPolicy());
    mp.start();
    ISystemConfig systemConfig = new SystemConfig();
    IConfiguration securityConfig = mock(IConfiguration.class);
    Properties props = new Properties();
    props.setProperty("provider", "jackrabbit");
    when(securityConfig.getProperties()).thenReturn(props);
    when(securityConfig.getId()).thenReturn("security");
    systemConfig.registerConfiguration(securityConfig);
    systemResource = new SystemResource(systemConfig);
    // $NON-NLS-1$
    StandaloneApplicationContext applicationContext = new StandaloneApplicationContext(getSolutionPath(), "");
    ApplicationContext springApplicationContext = getSpringApplicationContext();
    IPentahoObjectFactory pentahoObjectFactory = new StandaloneSpringPentahoObjectFactory();
    pentahoObjectFactory.init(null, springApplicationContext);
    PentahoSystem.registerObjectFactory(pentahoObjectFactory);
    // force Spring to populate PentahoSystem
    boolean initOk = PentahoSystem.init(applicationContext);
/*
     * StandaloneSession session = new StandaloneSession();
     * 
     * StandaloneSpringPentahoObjectFactory factory = new StandaloneSpringPentahoObjectFactory( );
     * 
     * File f = new File(TestResourceLocation.TEST_RESOURCES + "/solution/system/pentahoObjects.spring.xml"); FileSystemResource fsr = new
     * FileSystemResource(f); GenericApplicationContext appCtx = new GenericApplicationContext();
     * XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(appCtx); xmlReader.loadBeanDefinitions(fsr);
     * 
     * factory.init(TestResourceLocation.TEST_RESOURCES + "/solution/system/pentahoObjects.spring.xml", appCtx );
     */
}
Also used : ISystemConfig(org.pentaho.platform.api.engine.ISystemConfig) SystemConfig(org.pentaho.platform.config.SystemConfig) StandaloneApplicationContext(org.pentaho.platform.engine.core.system.StandaloneApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) IPentahoObjectFactory(org.pentaho.platform.api.engine.IPentahoObjectFactory) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) ISystemConfig(org.pentaho.platform.api.engine.ISystemConfig) FileSystemResource(org.springframework.core.io.FileSystemResource) StandaloneApplicationContext(org.pentaho.platform.engine.core.system.StandaloneApplicationContext) IConfiguration(org.pentaho.platform.api.engine.IConfiguration) Properties(java.util.Properties) StandaloneSpringPentahoObjectFactory(org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory) Before(org.junit.Before)

Aggregations

IPentahoObjectFactory (org.pentaho.platform.api.engine.IPentahoObjectFactory)30 StandaloneSpringPentahoObjectFactory (org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory)9 Test (org.junit.Test)7 StandaloneApplicationContext (org.pentaho.platform.engine.core.system.StandaloneApplicationContext)7 IPentahoDefinableObjectFactory (org.pentaho.platform.api.engine.IPentahoDefinableObjectFactory)6 IPentahoObjectReference (org.pentaho.platform.api.engine.IPentahoObjectReference)6 PathBasedSystemSettings (org.pentaho.platform.engine.core.system.PathBasedSystemSettings)6 ArrayList (java.util.ArrayList)5 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)5 ObjectFactoryException (org.pentaho.platform.api.engine.ObjectFactoryException)5 PentahoSystemBoot (org.pentaho.platform.engine.core.system.boot.PentahoSystemBoot)5 GenericApplicationContext (org.springframework.context.support.GenericApplicationContext)5 HashSet (java.util.HashSet)3 ISystemConfig (org.pentaho.platform.api.engine.ISystemConfig)3 ApplicationContext (org.springframework.context.ApplicationContext)3 File (java.io.File)2 Map (java.util.Map)2 Properties (java.util.Properties)2 IConfiguration (org.pentaho.platform.api.engine.IConfiguration)2 ISolutionEngine (org.pentaho.platform.api.engine.ISolutionEngine)2