Search in sources :

Example 6 with IPluginResourceLoader

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

the class SimpleDataAccessViewPermissionHandler method getDefaultAcls.

public int getDefaultAcls(IPentahoSession session) {
    IPluginResourceLoader resLoader = PentahoSystem.get(IPluginResourceLoader.class, null);
    String defaultAclsAsString = null;
    int defaultAcls = -1;
    try {
        defaultAclsAsString = // $NON-NLS-1$
        resLoader.getPluginSetting(getClass(), "settings/data-access-default-view-acls");
    } catch (Exception e) {
        logger.debug("Error getting plugin setting", e);
    }
    if (defaultAclsAsString != null && defaultAclsAsString.length() > 0) {
        defaultAcls = Integer.parseInt(defaultAclsAsString);
    }
    return defaultAcls;
}
Also used : IPluginResourceLoader(org.pentaho.platform.api.engine.IPluginResourceLoader)

Example 7 with IPluginResourceLoader

use of org.pentaho.platform.api.engine.IPluginResourceLoader 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 8 with IPluginResourceLoader

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

the class GwtRpcPluginProxyServlet method getSerializationPolicyUrl.

/**
 * The request path is broken up for processing like so: Ex: given a request for serialization file at
 * '/pentaho/content/data-access/resources/gwt/{strongName}'
 *
 * @param serializationPolicyFilename
 *          the name of the serialization policy file that GWT is looking for
 * @param appContextPath
 *          according to the example url, this would be '/pentaho'
 * @param servletContextPath
 *          according the the example url, this would be '/content/data-access/resources/gwt/{strongName}'
 * @return a URL to the serialization policy file, or <code>null</code> if none applies, in which case the default
 *         serialization policy will apply
 */
protected URL getSerializationPolicyUrl(String serializationPolicyFilename, String appContextPath, String servletContextPath) {
    // We will use the pluginContextPath to determine the service plugin for the serialization policy file
    // 
    ClassLoader serviceClassloader = PluginUtil.getClassLoaderForService(servletContextPath);
    if (serviceClassloader == null) {
        // if we get here, then the service is not supplied by a plugin and thus we cannot hope to find
        // the appropriate serialization policy
        logger.error(Messages.getInstance().getErrorString("GwtRpcPluginProxyServlet.ERROR_0005_FAILED_TO_FIND_PLUGIN", // $NON-NLS-1$
        appContextPath));
    }
    // We know what plugin is supposed to have the serialization policy file, now go find it
    // in the plugin's filesystem
    // 
    IPluginResourceLoader resLoader = PentahoSystem.get(IPluginResourceLoader.class, PentahoSessionHolder.getSession());
    List<URL> urls = resLoader.findResources(serviceClassloader, serializationPolicyFilename);
    if (urls.size() < 1) {
        logger.error(Messages.getInstance().getErrorString("GwtRpcPluginProxyServlet.ERROR_0006_FAILED_TO_FIND_FILE", // $NON-NLS-1$
        serializationPolicyFilename));
        return null;
    }
    if (urls.size() > 1) {
        logger.warn(Messages.getInstance().getString("GwtRpcPluginProxyServlet.WARN_MULTIPLE_RESOURCES_FOUND", // $NON-NLS-1$
        serializationPolicyFilename));
    }
    return urls.get(0);
}
Also used : IPluginResourceLoader(org.pentaho.platform.api.engine.IPluginResourceLoader) URL(java.net.URL)

Example 9 with IPluginResourceLoader

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

the class DefaultPluginManager method getPluginSetting.

@Override
public Object getPluginSetting(String pluginId, String key, String defaultValue) {
    IPluginResourceLoader resLoader = PentahoSystem.get(IPluginResourceLoader.class, null);
    ClassLoader classLoader = classLoaderMap.get(pluginId);
    return resLoader.getPluginSetting(classLoader, key, defaultValue);
}
Also used : IPluginResourceLoader(org.pentaho.platform.api.engine.IPluginResourceLoader)

Example 10 with IPluginResourceLoader

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

the class DefaultPluginManager method getStaticResource.

@Deprecated
public InputStream getStaticResource(String path) {
    for (IPlatformPlugin plugin : registeredPlugins.values()) {
        Map<String, String> resourceMap = plugin.getStaticResourceMap();
        for (String url : resourceMap.keySet()) {
            if (isRequested(url, path)) {
                IPluginResourceLoader resLoader = PentahoSystem.get(IPluginResourceLoader.class, null);
                ClassLoader classLoader = classLoaderMap.get(plugin.getId());
                String resourcePath = path.replace(url, resourceMap.get(url));
                return resLoader.getResourceAsStream(classLoader, resourcePath);
            }
        }
    }
    return null;
}
Also used : IPluginResourceLoader(org.pentaho.platform.api.engine.IPluginResourceLoader) IPlatformPlugin(org.pentaho.platform.api.engine.IPlatformPlugin)

Aggregations

IPluginResourceLoader (org.pentaho.platform.api.engine.IPluginResourceLoader)15 InputStream (java.io.InputStream)4 ArrayList (java.util.ArrayList)2 IPlatformPlugin (org.pentaho.platform.api.engine.IPlatformPlugin)2 IPluginManager (org.pentaho.platform.api.engine.IPluginManager)2 Authentication (org.springframework.security.core.Authentication)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 URL (java.net.URL)1 Properties (java.util.Properties)1 Document (org.dom4j.Document)1 DocumentException (org.dom4j.DocumentException)1 Element (org.dom4j.Element)1 Before (org.junit.Before)1 PluginLifecycleException (org.pentaho.platform.api.engine.PluginLifecycleException)1 IDatasourceMgmtService (org.pentaho.platform.api.repository.datasource.IDatasourceMgmtService)1 IUnifiedRepository (org.pentaho.platform.api.repository2.unified.IUnifiedRepository)1