Search in sources :

Example 16 with IPluginResourceLoader

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

the class PluginGwtRpc 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/'
 *
 * @param serializationPolicyFilename the name of the serialization policy file that GWT is looking for
 * @param moduleContextPath           according to the example url, this would be
 *                                    '/content/data-access/resources/gwt/'
 * @return a URL to the serialization policy file, or <code>null</code> if none applies, in which case the default
 * serialization policy will apply
 */
@Nullable
private URL getSerializationPolicyUrl(@NonNull String serializationPolicyFilename, String moduleContextPath) {
    ClassLoader serviceClassloader = PluginUtil.getClassLoaderForService(moduleContextPath);
    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", getAppContextPath()));
        return null;
    }
    // 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", serializationPolicyFilename));
        return null;
    }
    if (urls.size() > 1) {
        logger.warn(Messages.getInstance().getString("GwtRpcPluginProxyServlet.WARN_MULTIPLE_RESOURCES_FOUND", serializationPolicyFilename));
    }
    return urls.get(0);
}
Also used : IPluginResourceLoader(org.pentaho.platform.api.engine.IPluginResourceLoader) URL(java.net.URL) Nullable(edu.umd.cs.findbugs.annotations.Nullable)

Example 17 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)

Example 18 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 19 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)

Aggregations

IPluginResourceLoader (org.pentaho.platform.api.engine.IPluginResourceLoader)19 InputStream (java.io.InputStream)6 URL (java.net.URL)4 SerializationPolicy (com.google.gwt.user.server.rpc.SerializationPolicy)3 IOException (java.io.IOException)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 Test (org.junit.Test)3 PentahoSystem (org.pentaho.platform.engine.core.system.PentahoSystem)3 PluginUtil (org.pentaho.platform.plugin.services.pluginmgr.PluginUtil)3 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 Nullable (edu.umd.cs.findbugs.annotations.Nullable)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 Properties (java.util.Properties)1 Document (org.dom4j.Document)1