Search in sources :

Example 41 with IUnifiedRepository

use of org.pentaho.platform.api.repository2.unified.IUnifiedRepository in project pentaho-platform by pentaho.

the class ActionSequenceParameterUiContentGenerator method createContent.

@Override
public void createContent(OutputStream outputStream) throws Exception {
    IParameterProvider requestParams = getRequestParameters();
    IParameterProvider pathParams = getPathParameters();
    if ((requestParams != null) && (requestParams.getStringParameter("path", null) != null)) {
        path = URLDecoder.decode(requestParams.getStringParameter("path", ""), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        "UTF-8");
    } else if ((pathParams != null) && (pathParams.getStringParameter("path", null) != null)) {
        // $NON-NLS-1$
        path = URLDecoder.decode(pathParams.getStringParameter("path", ""), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        "UTF-8");
    }
    if (path != null && path.length() > 0) {
        IUnifiedRepository unifiedRepository = PentahoSystem.get(IUnifiedRepository.class, null);
        RepositoryFile file = unifiedRepository.getFile(path);
        // $NON-NLS-1$
        HttpServletRequest httpRequest = (HttpServletRequest) pathParams.getParameter("httprequest");
        // $NON-NLS-1$
        HttpServletResponse httpResponse = (HttpServletResponse) pathParams.getParameter("httpresponse");
        String buffer = XactionUtil.executeScheduleUi(file, httpRequest, httpResponse, PentahoSessionHolder.getSession(), outputHandler.getMimeTypeListener());
        outputStream.write(buffer.toString().getBytes(LocaleHelper.getSystemEncoding()));
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) IParameterProvider(org.pentaho.platform.api.engine.IParameterProvider) HttpServletResponse(javax.servlet.http.HttpServletResponse) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository)

Example 42 with IUnifiedRepository

use of org.pentaho.platform.api.repository2.unified.IUnifiedRepository in project pentaho-platform by pentaho.

the class MondrianCatalogHelper method generateInMemoryDatasourcesXml.

public String generateInMemoryDatasourcesXml(IUnifiedRepository unifiedRepository) {
    String etcMondrian = ClientRepositoryPaths.getEtcFolderPath() + RepositoryFile.SEPARATOR + MONDRIAN_DATASOURCE_FOLDER;
    RepositoryFile etcMondrianFolder = unifiedRepository.getFile(etcMondrian);
    if (etcMondrianFolder == null) {
        return null;
    }
    StringBuffer datasourcesXML = new StringBuffer();
    // $NON-NLS-1$
    datasourcesXML.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
    // $NON-NLS-1$
    datasourcesXML.append("<DataSources>\n");
    // $NON-NLS-1$
    datasourcesXML.append("<DataSource>\n");
    if (useLegacyDbName) {
        // $NON-NLS-1$
        datasourcesXML.append("<DataSourceName>Provider=Mondrian</DataSourceName>\n");
    } else {
        // $NON-NLS-1$
        datasourcesXML.append("<DataSourceName>Pentaho Mondrian</DataSourceName>\n");
    }
    datasourcesXML.append(// $NON-NLS-1$
    "<DataSourceDescription>Pentaho BI Platform Datasources</DataSourceDescription>\n");
    datasourcesXML.append(// $NON-NLS-1$
    "<URL>" + contextPathFromRequestContextHolder() + "Xmla</URL>\n");
    // $NON-NLS-1$
    datasourcesXML.append("<DataSourceInfo>Provider=Mondrian</DataSourceInfo>\n");
    // $NON-NLS-1$
    datasourcesXML.append("<ProviderName>PentahoXMLA</ProviderName>\n");
    // $NON-NLS-1$
    datasourcesXML.append("<ProviderType>MDP</ProviderType>\n");
    // $NON-NLS-1$
    datasourcesXML.append("<AuthenticationMode>Unauthenticated</AuthenticationMode>\n");
    appendCatalogsSection(unifiedRepository, etcMondrian, etcMondrianFolder, datasourcesXML);
    // $NON-NLS-1$
    datasourcesXML.append("</DataSource>\n");
    // $NON-NLS-1$
    datasourcesXML.append("</DataSources>\n");
    return datasourcesXML.toString();
}
Also used : RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile)

Example 43 with IUnifiedRepository

use of org.pentaho.platform.api.repository2.unified.IUnifiedRepository in project data-access by pentaho.

the class AnalysisServiceTest method initPlatform.

@BeforeClass
public static void initPlatform() throws Exception {
    MicroPlatform platform = new MicroPlatform();
    metadataRepository = mock(IMetadataDomainRepository.class);
    platform.defineInstance(IMetadataDomainRepository.class, metadataRepository);
    importer = mock(IPlatformImporter.class);
    platform.defineInstance(IPlatformImporter.class, importer);
    policy = mock(IAuthorizationPolicy.class);
    platform.defineInstance(IAuthorizationPolicy.class, policy);
    catalogService = mock(IAclAwareMondrianCatalogService.class);
    platform.defineInstance(IMondrianCatalogService.class, catalogService);
    permissionHandler = mock(IDataAccessPermissionHandler.class);
    platform.defineInstance(IDataAccessPermissionHandler.class, permissionHandler);
    final IUnifiedRepository unifiedRepository = new FileSystemBackedUnifiedRepository("target/test-classes/solution1");
    platform.defineInstance(IUnifiedRepository.class, unifiedRepository);
    platform.start();
    acl.setOwner("owner");
    acl.setOwnerType(RepositoryFileSid.Type.USER.ordinal());
}
Also used : IAuthorizationPolicy(org.pentaho.platform.api.engine.IAuthorizationPolicy) IDataAccessPermissionHandler(org.pentaho.platform.dataaccess.datasource.wizard.service.impl.IDataAccessPermissionHandler) IAclAwareMondrianCatalogService(org.pentaho.platform.plugin.action.mondrian.catalog.IAclAwareMondrianCatalogService) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) IMetadataDomainRepository(org.pentaho.metadata.repository.IMetadataDomainRepository) IPlatformImporter(org.pentaho.platform.plugin.services.importer.IPlatformImporter) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository) FileSystemBackedUnifiedRepository(org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository) BeforeClass(org.junit.BeforeClass)

Example 44 with IUnifiedRepository

use of org.pentaho.platform.api.repository2.unified.IUnifiedRepository in project data-access by pentaho.

the class DataSourcePublishIT method setUp.

@Before
public void setUp() throws Exception {
    repositoryBase.setUp();
    repositoryBase.loginAsRepositoryAdmin();
    defaultTenant = repositoryBase.createTenant(repositoryBase.getSystemTenant(), TenantUtils.getDefaultTenant());
    singleTenantAdminUserName = (String) applicationContext.getBean("singleTenantAdminUserName");
    repositoryBase.createUser(defaultTenant, singleTenantAdminUserName, PASSWORD, new String[] { repositoryBase.getTenantAdminRoleName() });
    final String singleTenantAuthenticatedAuthorityName = (String) applicationContext.getBean("singleTenantAuthenticatedAuthorityName");
    repositoryBase.createUser(defaultTenant, USERNAME_SUZY, PASSWORD, new String[] { singleTenantAuthenticatedAuthorityName });
    repositoryBase.createUser(defaultTenant, USERNAME_TIFFANY, PASSWORD, new String[] { singleTenantAuthenticatedAuthorityName });
    repositoryBase.login(singleTenantAdminUserName, defaultTenant, new String[] { repositoryBase.getTenantAdminRoleName() });
    final IUnifiedRepository repo = PentahoSystem.get(IUnifiedRepository.class);
    String etcID = String.valueOf(repo.getFile(ClientRepositoryPaths.getEtcFolderPath()).getId());
    repo.createFolder(etcID, new RepositoryFile.Builder(MondrianCatalogHelper.MONDRIAN_DATASOURCE_FOLDER).folder(true).build(), "initialization");
    repo.createFolder(etcID, new RepositoryFile.Builder(PentahoMetadataDomainRepositoryInfo.getMetadataFolderName()).folder(true).build(), "initialization");
    final MicroPlatform mp = repositoryBase.getMp();
    mp.define(IMondrianCatalogService.class, MondrianCatalogHelper.class);
    mp.define(ISystemConfig.class, SystemConfig.class);
    mp.defineInstance(IPlatformMimeResolver.class, applicationContext.getBean("IPlatformImportMimeResolver"));
    mp.defineInstance(IPlatformImporter.class, applicationContext.getBean("IPlatformImporter"));
    mp.defineInstance(ICacheManager.class, applicationContext.getBean("ICacheManager"));
    mp.defineInstance(IMetadataDomainRepository.class, applicationContext.getBean("IMetadataDomainRepository"));
    final PluginResourceLoader pluginResourceLoader = (PluginResourceLoader) applicationContext.getBean("IPluginResourceLoader");
    pluginResourceLoader.setRootDir(new File("target/test-classes/solutionACL/system/data-access"));
    mp.defineInstance(IPluginResourceLoader.class, pluginResourceLoader);
    mp.define(IDataAccessPermissionHandler.class, SimpleDataAccessPermissionHandler.class);
    mp.define(IDataAccessViewPermissionHandler.class, SimpleDataAccessViewPermissionHandler.class);
    mp.defineInstance(IAclVoter.class, new PentahoAllowAllAclVoter());
    SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_GLOBAL);
    super.setUp();
}
Also used : PluginResourceLoader(org.pentaho.platform.plugin.services.pluginmgr.PluginResourceLoader) IPluginResourceLoader(org.pentaho.platform.api.engine.IPluginResourceLoader) PentahoAllowAllAclVoter(org.pentaho.platform.engine.security.acls.voter.PentahoAllowAllAclVoter) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) File(java.io.File) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository) Before(org.junit.Before)

Example 45 with IUnifiedRepository

use of org.pentaho.platform.api.repository2.unified.IUnifiedRepository in project data-access by pentaho.

the class SerializeMultiTableServiceIT method createMetadataDomainRepository.

public PentahoMetadataDomainRepository createMetadataDomainRepository() throws Exception {
    IUnifiedRepository repository = new FileSystemBackedUnifiedRepository("target/test-classes/solution1");
    booter.defineInstance(IUnifiedRepository.class, repository);
    Assert.assertNotNull(new RepositoryUtils(repository).getFolder("/etc/metadata", true, true, null));
    Assert.assertNotNull(new RepositoryUtils(repository).getFolder("/etc/mondrian", true, true, null));
    Assert.assertNotNull(new RepositoryUtils(repository).getFolder("/savetest", true, true, null));
    PentahoMetadataDomainRepository pentahoMetadataDomainRepository = new PentahoMetadataDomainRepository(repository);
    return pentahoMetadataDomainRepository;
}
Also used : RepositoryUtils(org.pentaho.platform.repository2.unified.RepositoryUtils) PentahoMetadataDomainRepository(org.pentaho.platform.plugin.services.metadata.PentahoMetadataDomainRepository) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository) FileSystemBackedUnifiedRepository(org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository)

Aggregations

IUnifiedRepository (org.pentaho.platform.api.repository2.unified.IUnifiedRepository)88 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)61 Test (org.junit.Test)51 Matchers.anyString (org.mockito.Matchers.anyString)37 ArrayList (java.util.ArrayList)18 List (java.util.List)10 StringObjectId (org.pentaho.di.repository.StringObjectId)10 Serializable (java.io.Serializable)9 DatabaseDialectService (org.pentaho.database.service.DatabaseDialectService)7 RepositoryFileTree (org.pentaho.platform.api.repository2.unified.RepositoryFileTree)7 DataNode (org.pentaho.platform.api.repository2.unified.data.node.DataNode)7 InputStream (java.io.InputStream)6 JobMeta (org.pentaho.di.job.JobMeta)6 SimpleRepositoryFileData (org.pentaho.platform.api.repository2.unified.data.simple.SimpleRepositoryFileData)6 FileSystemBackedUnifiedRepository (org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository)6 HashMap (java.util.HashMap)5 ObjectId (org.pentaho.di.repository.ObjectId)5 IDatasourceMgmtService (org.pentaho.platform.api.repository.datasource.IDatasourceMgmtService)5 Properties (java.util.Properties)4 Log (org.apache.commons.logging.Log)4