Examples of IPluginManager


Examples of org.pentaho.platform.api.engine.IPluginManager

      if ( PentahoSystem.debug ) {
        debug( "GenericServlet contentGeneratorId=" + contentGeneratorId ); //$NON-NLS-1$
        debug( "GenericServlet urlPath=" + urlPath ); //$NON-NLS-1$
      }
      IPentahoSession session = getPentahoSession( request );
      IPluginManager pluginManager = PentahoSystem.get( IPluginManager.class, session );
      if ( pluginManager == null ) {
        OutputStream out = response.getOutputStream();
        String message =
          Messages.getInstance().getErrorString(
            "GenericServlet.ERROR_0001_BAD_OBJECT", IPluginManager.class.getSimpleName() ); //$NON-NLS-1$
        error( message );
        out.write( message.getBytes() );
        return;
      }

      // TODO make doing the HTTP headers configurable per content generator
      SimpleParameterProvider headerParams = new SimpleParameterProvider();
      Enumeration names = request.getHeaderNames();
      while ( names.hasMoreElements() ) {
        String name = (String) names.nextElement();
        String value = request.getHeader( name );
        headerParams.setParameter( name, value );
      }

      String pluginId = pluginManager.getServicePlugin( pathInfo );

      if ( pluginId != null && pluginManager.isStaticResource( pathInfo ) ) {
        boolean cacheOn = "true".equals( pluginManager
          .getPluginSetting( pluginId, "settings/cache", "false" ) ); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
        String maxAge = (String) pluginManager.getPluginSetting( pluginId, "settings/max-age", null ); //$NON-NLS-1$
        allowBrowserCache( maxAge, pathParams );

        String mimeType = MimeHelper.getMimeTypeFromFileName( pathInfo );
        if ( mimeType != null ) {
          response.setContentType( mimeType );
        }
        OutputStream out = response.getOutputStream();

        // do we have this resource cached?
        ByteArrayOutputStream byteStream = null;

        if ( cacheOn ) {
          byteStream = (ByteArrayOutputStream) cache.getFromRegionCache( CACHE_FILE, pathInfo );
        }

        if ( byteStream != null ) {
          IOUtils.write( byteStream.toByteArray(), out );
          return;
        }
        InputStream resourceStream = pluginManager.getStaticResource( pathInfo );
        if ( resourceStream != null ) {
          try {
            byteStream = new ByteArrayOutputStream();
            IOUtils.copy( resourceStream, byteStream );

            // if cache is enabled, drop file in cache
            if ( cacheOn ) {
              cache.putInRegionCache( CACHE_FILE, pathInfo, byteStream );
            }

            // write it out
            IOUtils.write( byteStream.toByteArray(), out );
            return;
          } finally {
            IOUtils.closeQuietly( resourceStream );
          }
        }
        logger.error( Messages.getInstance().getErrorString(
          "GenericServlet.ERROR_0004_RESOURCE_NOT_FOUND", pluginId, pathInfo ) ); //$NON-NLS-1$
        response.sendError( 404 );
        return;
      }

      // content generators defined in plugin.xml are registered with 2 aliases, one is the id, the other is type
      // so, we can still retrieve a content generator by id, even though this is not the correct way to find
      // it. the correct way is to look up a content generator by pluginManager.getContentGenerator(type,
      // perspectiveName)
      IContentGenerator contentGenerator = (IContentGenerator) pluginManager.getBean( contentGeneratorId );
      if ( contentGenerator == null ) {
        OutputStream out = response.getOutputStream();
        String message =
          Messages.getInstance().getErrorString(
            "GenericServlet.ERROR_0002_BAD_GENERATOR",
            ESAPI.encoder().encodeForHTML( contentGeneratorId ) ); //$NON-NLS-1$
        error( message );
        out.write( message.getBytes() );
        return;
      }

      // set the classloader of the current thread to the class loader of
      // the plugin so that it can load its libraries
      // Note: we cannot ask the contentGenerator class for it's classloader, since the cg may
      // actually be a proxy object loaded by main the WebAppClassloader
      Thread.currentThread().setContextClassLoader( pluginManager.getClassLoader( pluginId ) );

      // String proxyClass = PentahoSystem.getSystemSetting( module+"/plugin.xml" ,
      // "plugin/content-generators/"+contentGeneratorId,
      // "content generator not found");
      IParameterProvider requestParameters = new HttpRequestParameterProvider( request );
View Full Code Here

Examples of org.pentaho.platform.api.engine.IPluginManager

@Path("/saiku/api/{username}/tags")
public class PentahoTagRepositoryResource extends BasicTagRepositoryResource {
 
  @Override
  public void setPath(String path) throws Exception {
    final IPluginManager pluginManager = (IPluginManager) PentahoSystem.get(IPluginManager.class, PentahoSessionHolder.getSession());
    final PluginClassLoader pluginClassloader = (PluginClassLoader)pluginManager.getClassLoader(PluginConfig.PLUGIN_NAME);
    File pluginDir = pluginClassloader.getPluginDir();
    String absolute = "file:" +pluginDir.getAbsolutePath();
    if (!absolute.endsWith("" + File.separatorChar)) {
       absolute += File.separatorChar;
    }
View Full Code Here

Examples of org.pentaho.platform.api.engine.IPluginManager

            File searchRootFile = new File(searchRootDir);
            if (searchRootFile.exists()) {
                List<File> solutionFiles = getJsFiles(searchRootFile);
                files.addAll(solutionFiles);
            }
            final IPluginManager pluginManager = (IPluginManager) PentahoSystem.get(IPluginManager.class, PentahoSessionHolder.getSession());
            Long start = (new Date()).getTime();
            for (String plugin : pluginManager.getRegisteredPlugins()) {
                final PluginClassLoader pluginClassloader = (PluginClassLoader) pluginManager.getClassLoader(plugin);
                File pluginDir = pluginClassloader.getPluginDir();
                File saikuDir = new File(pluginDir, "saiku");
                if (saikuDir.exists()) {
                    File saikuPluginDir = new File(saikuDir, "plugins");
                    if (saikuPluginDir.exists()) {
View Full Code Here

Examples of org.pentaho.platform.api.engine.IPluginManager

@Path("/saiku/api/{username}/filters")
public class PentahoFilterRepositoryResource extends FilterRepositoryResource {
 
  @Override
  public void setPath(String path) throws Exception {
    final IPluginManager pluginManager = (IPluginManager) PentahoSystem.get(IPluginManager.class, PentahoSessionHolder.getSession());
    final PluginClassLoader pluginClassloader = (PluginClassLoader)pluginManager.getClassLoader(PluginConfig.PLUGIN_NAME);
    File pluginDir = pluginClassloader.getPluginDir();
    String absolute = "file:" +pluginDir.getAbsolutePath();
    if (!absolute.endsWith("" + File.separatorChar)) {
       absolute += File.separatorChar;
    }
View Full Code Here

Examples of org.pentaho.platform.api.engine.IPluginManager

        List<File> solutionFiles = getJsFiles(searchRootFile);
        files.addAll(solutionFiles);
      }


      final IPluginManager pluginManager = (IPluginManager) PentahoSystem.get(IPluginManager.class, PentahoSessionHolder.getSession());

      Long start = (new Date()).getTime();
      for (String plugin : pluginManager.getRegisteredPlugins()) {
        final PluginClassLoader pluginClassloader = (PluginClassLoader) pluginManager.getClassLoader(plugin);
        File pluginDir = pluginClassloader.getPluginDir();
        File saikuDir = new File(pluginDir, "saiku");
        if (saikuDir.exists()) {
          File saikuPluginDir = new File(saikuDir, "plugins");
          if (saikuPluginDir.exists()) {
View Full Code Here

Examples of org.pentaho.platform.api.engine.IPluginManager

public class PentahoFilterRepositoryResource extends FilterRepositoryResource {
 
  @Override
  public void setPath(String path) throws Exception {
    final IPluginManager pluginManager = (IPluginManager) PentahoSystem.get(IPluginManager.class, PentahoSessionHolder.getSession());
    final PluginClassLoader pluginClassloader = (PluginClassLoader)pluginManager.getClassLoader(PluginConfig.PLUGIN_NAME);
    File pluginDir = pluginClassloader.getPluginDir();
    String absolute = "file:" +pluginDir.getAbsolutePath();
    if (!absolute.endsWith("" + File.separatorChar)) {
       absolute += File.separatorChar;
    }
View Full Code Here

Examples of org.pentaho.platform.api.engine.IPluginManager

public class PentahoTagRepositoryResource extends BasicTagRepositoryResource {
 
  @Override
  public void setPath(String path) throws Exception {
    final IPluginManager pluginManager = (IPluginManager) PentahoSystem.get(IPluginManager.class, PentahoSessionHolder.getSession());
    final PluginClassLoader pluginClassloader = (PluginClassLoader)pluginManager.getClassLoader(PluginConfig.PLUGIN_NAME);
    File pluginDir = pluginClassloader.getPluginDir();
    String absolute = "file:" +pluginDir.getAbsolutePath();
    if (!absolute.endsWith("" + File.separatorChar)) {
       absolute += File.separatorChar;
    }
View Full Code Here

Examples of org.pentaho.platform.api.engine.IPluginManager

  }

  @Override
  public void createContent( OutputStream outputStream ) throws Exception {
    IPluginResourceLoader pluginResourceLoader = PentahoSystem.get( IPluginResourceLoader.class );
    IPluginManager pluginManager = PentahoSystem.get( IPluginManager.class );
    ClassLoader classLoader = pluginManager.getClassLoader( pluginId );
    String filePath = !relativeFilePath.startsWith( "/" ) ? "/" + relativeFilePath : relativeFilePath;
    InputStream inputStream = pluginResourceLoader.getResourceAsStream( classLoader, filePath );
    int val;
    while ( ( val = inputStream.read() ) != -1 ) {
      outputStream.write( val );
View Full Code Here

Examples of org.pentaho.platform.api.engine.IPluginManager

        .define( IPluginManager.class, DefaultPluginManager.class, IPentahoDefinableObjectFactory.Scope.GLOBAL );

    PentahoSystem.setSystemSettingsService( new PathBasedSystemSettings() );
    PentahoSessionHolder.setSession( session );

    IPluginManager pluginManager = PentahoSystem.get( IPluginManager.class );
    microPlatform.define( IPluginProvider.class, TestPluginProvider.class );
    microPlatform.start();

    pluginManager.reload( session );
  }
View Full Code Here

Examples of org.pentaho.platform.api.engine.IPluginManager

  public void testBadConfig1() {
    startTest();

    IPentahoSession session = new StandaloneSession( "test user" ); //$NON-NLS-1$
    IPluginManager pluginManager = PentahoSystem.get( IPluginManager.class, session );
    assertNull( pluginManager );

    finishTest();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.