Search in sources :

Example 11 with IPluginResourceLoader

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

the class PentahoSystemPluginManager method getStaticResource.

@Override
public InputStream getStaticResource(String path) {
    for (IPlatformPlugin plugin : PentahoSystem.getAll(IPlatformPlugin.class)) {
        Map<String, String> resourceMap = plugin.getStaticResourceMap();
        for (String url : resourceMap.keySet()) {
            if (isRequested(url, path)) {
                IPluginResourceLoader resLoader = PentahoSystem.get(IPluginResourceLoader.class, null);
                ClassLoader classLoader = PentahoSystem.get(ClassLoader.class, null, Collections.singletonMap(PLUGIN_ID, 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)

Example 12 with IPluginResourceLoader

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

the class ParameterUIContentGenerator method createContent.

@Override
public void createContent(OutputStream outputStream) throws Exception {
    IPluginResourceLoader resourceLoader = PentahoSystem.get(IPluginResourceLoader.class);
    IPluginManager pluginManager = PentahoSystem.get(IPluginManager.class);
    ClassLoader classLoader = pluginManager.getClassLoader(pluginId);
    String filePath = !viewerFilePath.startsWith("/") ? "/" + viewerFilePath : viewerFilePath;
    String viewer = IOUtils.toString(resourceLoader.getResourceAsStream(classLoader, filePath), LocaleHelper.getSystemEncoding());
    viewer = doResourceReplacement(viewer);
    InputStream is = IOUtils.toInputStream(viewer, LocaleHelper.getSystemEncoding());
    IOUtils.copy(is, outputStream);
    outputStream.flush();
}
Also used : InputStream(java.io.InputStream) IPluginManager(org.pentaho.platform.api.engine.IPluginManager) IPluginResourceLoader(org.pentaho.platform.api.engine.IPluginResourceLoader)

Example 13 with IPluginResourceLoader

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

the class AgileMartDatasourceLifecycleManager method getInstance.

public static AgileMartDatasourceLifecycleManager getInstance() {
    if (instance == null) {
        TransactionTemplate txnTemplate = PentahoSystem.get(TransactionTemplate.class, "jcrTransactionTemplate", PentahoSessionHolder.getSession());
        JcrTemplate adminJcrTemplate = PentahoSystem.get(JcrTemplate.class, "adminJcrTemplate", PentahoSessionHolder.getSession());
        IPathConversionHelper pathConversionHelper = PentahoSystem.get(IPathConversionHelper.class, "pathConversionHelper", PentahoSessionHolder.getSession());
        IPluginResourceLoader resLoader = PentahoSystem.get(IPluginResourceLoader.class, PentahoSessionHolder.getSession());
        IDatasourceMgmtService datasourceMgmtService = PentahoSystem.get(IDatasourceMgmtService.class, PentahoSessionHolder.getSession());
        instance = new AgileMartDatasourceLifecycleManager(txnTemplate, adminJcrTemplate, pathConversionHelper, datasourceMgmtService, resLoader);
    }
    return instance;
}
Also used : JcrTemplate(org.springframework.extensions.jcr.JcrTemplate) TransactionTemplate(org.springframework.transaction.support.TransactionTemplate) IPathConversionHelper(org.pentaho.platform.repository2.unified.jcr.IPathConversionHelper) IPluginResourceLoader(org.pentaho.platform.api.engine.IPluginResourceLoader) IDatasourceMgmtService(org.pentaho.platform.api.repository.datasource.IDatasourceMgmtService)

Example 14 with IPluginResourceLoader

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

the class DataAccessLifecycleListener method ready.

@Override
public void ready() throws PluginLifecycleException {
    // the platform is booted, spring initialized, all plugins init and loaded
    boolean enableAgilemartDatasource = false;
    try {
        IPluginResourceLoader resLoader = PentahoSystem.get(IPluginResourceLoader.class, null);
        enableAgilemartDatasource = Boolean.parseBoolean(resLoader.getPluginSetting(DataAccessLifecycleListener.class, ENABLE_AGILEMART_DATASOURCE, "false"));
    } catch (Throwable t) {
        log.warn(t.getMessage(), t);
    }
    if (enableAgilemartDatasource) {
        try {
            SecurityHelper.getInstance().runAsSystem(new Callable<Void>() {

                public Void call() throws Exception {
                    AgileMartDatasourceLifecycleManager.getInstance().startup();
                    return null;
                }
            });
        } catch (Exception e) {
            log.warn(e.getMessage(), e);
        }
        DelegatingBackingRepositoryLifecycleManager manager = PentahoSystem.get(DelegatingBackingRepositoryLifecycleManager.class, "backingRepositoryLifecycleManager", null);
        manager.addLifeCycleManager(AgileMartDatasourceLifecycleManager.getInstance());
    }
}
Also used : IPluginResourceLoader(org.pentaho.platform.api.engine.IPluginResourceLoader) PluginLifecycleException(org.pentaho.platform.api.engine.PluginLifecycleException) DelegatingBackingRepositoryLifecycleManager(org.pentaho.platform.repository2.unified.lifecycle.DelegatingBackingRepositoryLifecycleManager)

Example 15 with IPluginResourceLoader

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

the class SimpleDataAccessViewPermissionHandler method getPermittedRoleList.

public List<String> getPermittedRoleList(IPentahoSession session) {
    List<String> roleList = new ArrayList<String>();
    Authentication auth = SecurityHelper.getInstance().getAuthentication(session, true);
    IPluginResourceLoader resLoader = PentahoSystem.get(IPluginResourceLoader.class, null);
    String roles = null;
    try {
        // $NON-NLS-1$
        roles = resLoader.getPluginSetting(getClass(), "settings/data-access-view-roles");
    } catch (Exception e) {
        logger.debug("Error getting plugin setting", e);
    }
    if (roles != null && roles.length() > 0) {
        // $NON-NLS-1$
        String[] roleArr = roles.split(",");
        for (String role : roleArr) {
            if (role != null && role.trim().length() > 0) {
                roleList.add(role);
            }
        }
    }
    return roleList;
}
Also used : Authentication(org.springframework.security.core.Authentication) ArrayList(java.util.ArrayList) IPluginResourceLoader(org.pentaho.platform.api.engine.IPluginResourceLoader)

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