Package org.pentaho.platform.api.engine

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


    return Response.seeOther( ( new URL( url ) ).toURI() ).build();
  }

  protected Response getContentGeneratorResponse( CGFactory fac ) {
    rsc( "Is [{0}] a content generator ID?", fac.getContentGeneratorId() ); //$NON-NLS-1$
    final IContentGenerator contentGenerator;
    try {
      contentGenerator = fac.create();
    } catch ( NoSuchBeanDefinitionException e ) {
      rsc( "Nope, [{0}] is not a content generator ID.", fac.getContentGeneratorId() ); //$NON-NLS-1$
      return null;
View Full Code Here


      }
    }
    boolean hasParameters = false;
    if ( hasParameterUi ) {
      try {
        IContentGenerator parameterContentGenerator = getContentGenerator( repositoryFile );
        if ( parameterContentGenerator != null ) {
          ByteArrayOutputStream outputStream = getByteArrayOutputStream();
          parameterContentGenerator.setOutputHandler( new SimpleOutputHandler( outputStream, false ) );
          parameterContentGenerator.setMessagesList( new ArrayList<String>() );

          Map<String, IParameterProvider> parameterProviders = new HashMap<String, IParameterProvider>();

          SimpleParameterProvider parameterProvider = getSimpleParameterProvider();
          parameterProvider.setParameter( "path", encode( repositoryFile.getPath() ) );
          parameterProvider.setParameter( "renderMode", "PARAMETER" );
          parameterProviders.put( IParameterProvider.SCOPE_REQUEST, parameterProvider );

          parameterContentGenerator.setParameterProviders( parameterProviders );
          parameterContentGenerator.setSession( getSession() );
          parameterContentGenerator.createContent();

          if ( outputStream.size() > 0 ) {
            Document document = parseText( outputStream.toString() );

            // exclude all parameters that are of type "system", xactions set system params that have to be ignored.
View Full Code Here

    return bean;
  }

  @Override
  public IContentGenerator getContentGenerator( String type, String perspectiveName ) {
    IContentGenerator cg = null;
    if ( perspectiveName == null || perspectiveName.equals( DEFAULT_PERSPECTIVE ) ) {
      cg = (IContentGenerator) getBean( type, IContentGenerator.class );
    } else {
      String beanId = ( perspectiveName == null ) ? type : type + "." + perspectiveName; //$NON-NLS-1$
      try {
View Full Code Here

    RepositoryFile mockRepositoryFile = mock( RepositoryFile.class );
    doReturn( mockRepositoryFile ).when( fileResource.repository ).getFile( path );

    doReturn( true ).when( fileResource ).hasParameterUi( mockRepositoryFile );

    IContentGenerator mockContentGenerator = mock( IContentGenerator.class );
    doReturn( mockContentGenerator ).when( fileResource ).getContentGenerator( mockRepositoryFile );

    SimpleParameterProvider mockSimpleParameterProvider = mock( SimpleParameterProvider.class );
    doReturn( mockSimpleParameterProvider ).when( fileResource ).getSimpleParameterProvider();
View Full Code Here

      // 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 );
      // see if this is an upload

      // File uploading is a service provided by UploadFileServlet where appropriate protections
      // are in place to prevent uploads that are too large.

      // boolean isMultipart = ServletFileUpload.isMultipartContent(request);
      // if (isMultipart) {
      // requestParameters = new SimpleParameterProvider();
      // // Create a factory for disk-based file items
      // FileItemFactory factory = new DiskFileItemFactory();
      //
      // // Create a new file upload handler
      // ServletFileUpload upload = new ServletFileUpload(factory);
      //
      // // Parse the request
      // List<?> /* FileItem */items = upload.parseRequest(request);
      // Iterator<?> iter = items.iterator();
      // while (iter.hasNext()) {
      // FileItem item = (FileItem) iter.next();
      //
      // if (item.isFormField()) {
      // ((SimpleParameterProvider) requestParameters).setParameter(item.getFieldName(), item.getString());
      // } else {
      // String name = item.getName();
      // ((SimpleParameterProvider) requestParameters).setParameter(name, item.getInputStream());
      // }
      // }
      // }

      response.setCharacterEncoding( LocaleHelper.getSystemEncoding() );

      IMimeTypeListener listener = new HttpMimeTypeListener( request, response );

      outputHandler = getOutputHandler( response, true );
      outputHandler.setMimeTypeListener( listener );

      IParameterProvider sessionParameters = new HttpSessionParameterProvider( session );
      IPentahoRequestContext requestContext = PentahoRequestContextHolder.getRequestContext();
      Map<String, IParameterProvider> parameterProviders = new HashMap<String, IParameterProvider>();
      parameterProviders.put( IParameterProvider.SCOPE_REQUEST, requestParameters );
      parameterProviders.put( IParameterProvider.SCOPE_SESSION, sessionParameters );
      parameterProviders.put( "headers", headerParams ); //$NON-NLS-1$
      parameterProviders.put( "path", pathParams ); //$NON-NLS-1$
      SimpleUrlFactory urlFactory =
        new SimpleUrlFactory( requestContext.getContextPath() + urlPath + "?" ); //$NON-NLS-1$ //$NON-NLS-2$
      List<String> messages = new ArrayList<String>();
      contentGenerator.setOutputHandler( outputHandler );
      contentGenerator.setMessagesList( messages );
      contentGenerator.setParameterProviders( parameterProviders );
      contentGenerator.setSession( session );
      contentGenerator.setUrlFactory( urlFactory );
      // String contentType = request.getContentType();
      // contentGenerator.setInput(input);
      contentGenerator.createContent();
      if ( PentahoSystem.debug ) {
        debug( "Generic Servlet content generate successfully" ); //$NON-NLS-1$
      }

    } catch ( Exception e ) {
View Full Code Here

   */

  @Test
  public void testExecuteUrlListed() throws Exception {

    IContentGenerator serviceLister = new StyledHtmlAxisServiceLister();

    String html = ContentGeneratorUtil.getContentAsString( serviceLister );
    System.out.println( html );

    assertTrue( "Run URL is missing", html.contains( "/content/ws-run/echoService" ) );
View Full Code Here

    assertTrue( "Run URL is missing", html.contains( "/content/ws-run/echoService" ) );
  }

  @Test
  public void testWsdlUrlListed() throws Exception {
    IContentGenerator serviceLister = new StyledHtmlAxisServiceLister();

    String html = ContentGeneratorUtil.getContentAsString( serviceLister );
    System.out.println( html );

    assertTrue( "WSDL URL is missing", html.contains( "/content/ws-wsdl/echoService" ) );
View Full Code Here

    File styleDotSCC = new File( microPlatform.getFilePath() + "system/axis/themes/onyx/styles.css" );
    context.setResource( "/test-module/themes/onyx/styles.css", styleDotSCC.toURI().toURL() );
    context.setResourceAsStream( "/test-module/themes/onyx/styles.css", new FileInputStream( styleDotSCC ) );
    PentahoSystem.getApplicationContext().setContext( context );

    IContentGenerator serviceLister = new StyledHtmlAxisServiceLister();

    String html = ContentGeneratorUtil.getContentAsString( serviceLister );
    System.out.println( html );

    assertTrue( "style is missing", html.contains( "styles.css" ) );
View Full Code Here

    assertTrue( "style is missing", html.contains( "styles.css" ) );
  }

  @Test
  public void testMetaInf() throws Exception {
    IContentGenerator serviceLister = new StyledHtmlAxisServiceLister();

    String html = ContentGeneratorUtil.getContentAsString( serviceLister );
    System.out.println( html );

    assertTrue( "title is not displayed", html.contains( "junit echo service" ) );
View Full Code Here

    assertNotNull( "Could not get content generator test9b by id",
      pluginManager.getContentGenerator( "test9btype",
        null ) );

    // see if we can access the content generator by type
    IContentGenerator contentGenerator = pluginManager.getContentGeneratorForType( "test9type", session );
    assertNotNull( "Should have gotten an instance of a cg for content type", contentGenerator );
    assertTrue( contentGenerator instanceof ContentGenerator1 );
  }
View Full Code Here

TOP

Related Classes of org.pentaho.platform.api.engine.IContentGenerator

Copyright © 2018 www.massapicom. 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.