Package org.pentaho.platform.api.repository

Examples of org.pentaho.platform.api.repository.IContentItem


      String outputName = output.getName();
      outputName = COMPATIBILITY_FORMATTER.format( outputName );

      // if streaming output, add it to the context and don't try to get it from the Action bean
      if ( outputContentItems.containsKey( outputName ) ) {
        IContentItem contentItem = outputContentItems.get( outputName );

        if ( !( contentItem instanceof SimpleContentItem ) ) {
          // this is a special output for streaming actions and does not require a bean accessor
          output.setValue( contentItem );
        }
View Full Code Here


      if ( StringUtils.isEmpty( mimeType ) ) {
        throw new ActionValidationException( Messages.getInstance().getErrorString(
            "ActionDelegate.ERROR_0001_MIMETYPE_NOT_DECLARED" ) ); //$NON-NLS-1$
      }

      IContentItem contentItem = null;

      //
      // If the output is mapped publicly and has a destination associated with it, then we will be asking
      // the current IOuputHandler to create an IContentItem (OuputStream) for us. Otherwise, we will asking the
      // IContentOutputHandler impl registered to handle content destined for "contentrepo" to create
      // an IContentItem (OutputStream) for us.
      //
      if ( hasPublicDestination( curActionOutput ) ) {
        // most output handlers will manage multiple destinations for us and hand us back a MultiContentItem
        contentItem = getRuntimeContext().getOutputContentItem( curActionOutput.getPublicName(), mimeType );
      } else {
        String extension = MimeHelper.getExtension( mimeType );
        if ( extension == null ) {
          extension = ".bin"; //$NON-NLS-1$
        }
        contentItem = getRuntimeContext().getOutputItem( curActionOutput.getName(), mimeType, extension );
      }

      if ( contentItem == null ) {
        // this is the best I can do here to point users to a tangible problem without unwrapping code in
        // RuntimeEngine
        // - AP
        throw new ActionValidationException( Messages.getInstance().getErrorString(
            "ActionDelegate.ERROR_0003_OUTPUT_STREAM_NOT_AVAILABLE_1", //$NON-NLS-1$
            curActionOutput.getPublicName() ) );
      }

      // this will be a MultiOutputStream in the case where there is more than one destination for the content
      // output
      OutputStream contentOutputStream = contentItem.getOutputStream( getActionName() );
      if ( contentOutputStream == null ) {
        throw new ActionExecutionException( Messages.getInstance().getErrorString(
            "ActionDelegate.ERROR_0004_OUTPUT_STREAM_NOT_AVAILABLE_2", //$NON-NLS-1$
            actionBean.getClass().getSimpleName() ) );
      }
View Full Code Here

        // TODO get this info
        output.setInstanceId( instanceId );
        output.setSolutionPath( filePath );
        output.setMimeType( mimeType );
        output.setSession( session );
        IContentItem contentItem = output.getFileOutputContentItem();
        setOutputValue( outputName, contentItem );
        return contentItem;
      }
    } catch ( Exception e ) {
      //ignored
View Full Code Here

    return outputHandler.getOutputContentItem( IOutputHandler.RESPONSE, IOutputHandler.CONTENT, instanceId, mimeType );
  }

  public IContentItem getOutputContentItem( final String outputName, final String mimeType ) {

    IContentItem contentItem = null;
    IActionParameter parameter = (IActionParameter) actionSequence.getOutputDefinitions().get( outputName );
    if ( parameter == null ) {
      warn( Messages.getInstance().getErrorString(
          "RuntimeContext.ERROR_0021_INVALID_OUTPUT_REQUEST", outputName, actionSequence.getSequenceName() ) ); //$NON-NLS-1$
    } else {
      List destinationsList = parameter.getVariables();
      Iterator destinationsIterator = destinationsList.iterator();
      if ( destinationsList.size() > 1 ) {
        contentItem = new MultiContentItem();
      }
      while ( destinationsIterator.hasNext() ) {
        ActionParameterSource destination = (ActionParameterSource) destinationsIterator.next();

        String objectName = destination.getSourceName();
        String contentName = destination.getValue();
        contentName = TemplateUtil.applyTemplate( contentName, this );
        outputHandler.setSession( session );
        IContentItem tmpContentItem =
            outputHandler.getOutputContentItem( objectName, contentName, instanceId, mimeType );
        if ( contentItem instanceof MultiContentItem ) {
          ( (MultiContentItem) contentItem ).addContentItem( tmpContentItem );
        } else {
          contentItem = tmpContentItem;
View Full Code Here

      throw new InvalidParameterException( Messages.getInstance().getErrorString(
          "RuntimeContext.ERROR_0019_INVALID_INPUT_REQUEST", parameterName, actionSequence.getSequenceName() ) ); //$NON-NLS-1$
    }
    Object value = inputParameter.getValue();
    if ( value instanceof IContentItem ) {
      IContentItem contentItem = (IContentItem) value;
      inputStream = contentItem.getInputStream();
    }
    return inputStream;
  }
View Full Code Here

            XForm.completeXForm( XForm.OUTPUT_HTML_PAGE, RuntimeContext.PARAMETER_FORM, xformHeader, new StringBuffer(
                parameterTemplate ), getSession(), resolver );
        if ( RuntimeContext.debug ) {
          debug( Messages.getInstance().getString( "RuntimeContext.DEBUG_PARAMETER_HTML", html ) ); //$NON-NLS-1$
        }
        IContentItem contentItem = outputHandler.getFeedbackContentItem();
        contentItem.setMimeType( "text/html" ); //$NON-NLS-1$
        OutputStream os = contentItem.getOutputStream( getActionName() );
        os.write( html.getBytes( LocaleHelper.getSystemEncoding() ) );
        os.close();
      } else if ( parameterXsl.endsWith( ".xsl" ) ) { //$NON-NLS-1$
        String id = actionSequence.getSequenceName();
        int pos = id.indexOf( '.' );
        if ( pos > -1 ) {
          id = id.substring( 0, pos );
        }
        // make sure the id can form a valid javascript variable or
        // function name
        id = id.replace( '-', '_' );
        id = id.replace( ' ', '_' );
        String actionUrl = urlFactory.getActionUrlBuilder().getUrl();
        String displayUrl = urlFactory.getDisplayUrlBuilder().getUrl();
        // String target = (parameterTarget == null) ? "" : parameterTarget; //$NON-NLS-1$
        XForm.completeXFormHeader( RuntimeContext.PARAMETER_FORM, xformHeader );
        Document document =
            XmlDom4JHelper
                .getDocFromString(
                    "<?xml version=\"1.0\" encoding=\"" + LocaleHelper.getSystemEncoding() + "\" ?><filters xmlns:xf=\"http://www.w3.org/2002/xforms\">" + //$NON-NLS-1$ //$NON-NLS-2$
                        xformHeader
                        + "<id><![CDATA[" + //$NON-NLS-1$
                        id
                        + "]]></id><title><![CDATA[" + //$NON-NLS-1$
                        Messages.getInstance().getEncodedString( actionSequence.getTitle() )
                        + "]]></title><description><![CDATA[" + //$NON-NLS-1$
                        Messages.getInstance().getEncodedString( actionSequence.getDescription() )
                        + "]]></description><icon><![CDATA[" + //$NON-NLS-1$
                        actionSequence.getIcon() + "]]></icon><help><![CDATA[" + //$NON-NLS-1$
                        Messages.getInstance().getEncodedString( actionSequence.getHelp() ) + "]]></help>" + //$NON-NLS-1$
                        "<action><![CDATA[" + actionUrl + "]]></action>" + //$NON-NLS-1$ //$NON-NLS-2$
                        "<display><![CDATA[" + displayUrl + "]]></display>" + //$NON-NLS-1$ //$NON-NLS-2$
                        ( ( parameterTarget != null ) ? "<target>" + parameterTarget + "</target>" : "" ) + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                        xformBody.toString() + "</filters>", null ); //$NON-NLS-1$
        // add any subscription information here
        Element root = document.getRootElement();

        // notify the xsl whether we're in parameter view or not.
        root.addAttribute(
            "parameterView", ( getOutputPreference() == IOutputHandler.OUTPUT_TYPE_PARAMETERS ) ? "true" : "false" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

        Map<String, String> parameters = new HashMap<String, String>();
        parameters.put( "baseUrl", PentahoSystem.getApplicationContext().getBaseUrl() ); //$NON-NLS-1$
        parameters.put( "actionUrl", this.getUrlFactory().getActionUrlBuilder().getUrl() ); //$NON-NLS-1$
        parameters.put( "displayUrl", this.getUrlFactory().getDisplayUrlBuilder().getUrl() ); //$NON-NLS-1$
        // Uncomment this line for troubleshooting the XSL.
        StringBuffer content =
            XmlHelper.transformXml( parameterXsl, getSolutionPath(), document.asXML(), parameters, resolver );

        IContentItem contentItem = outputHandler.getFeedbackContentItem();
        contentItem.setMimeType( "text/html" ); //$NON-NLS-1$
        OutputStream os = contentItem.getOutputStream( getActionName() );
        try {
          os.write( content.toString().getBytes( LocaleHelper.getSystemEncoding() ) );
        } finally {
          if ( os != null ) {
            os.close();
View Full Code Here

  protected void setOutputValue( final String outputName, final Object value ) {
    runtimeContext.setOutputValue( outputName, value );
  }

  protected OutputStream getDefaultOutputStream( final String mimeType ) {
    IContentItem contentItem = runtimeContext.getOutputContentItem( mimeType );
    if ( contentItem != null ) {
      try {
        return contentItem.getOutputStream( getActionName() );
      } catch ( Exception e ) {
        //ignore
      }
    }
    return null;
View Full Code Here

  protected boolean isPromptPending() {
    return runtimeContext.isPromptPending();
  }

  protected void setFeedbackMimeType( final String mimeType ) {
    IContentItem feedbackContentItem = runtimeContext.getFeedbackContentItem();
    feedbackContentItem.setMimeType( mimeType );
  }
View Full Code Here

    IContentItem feedbackContentItem = runtimeContext.getFeedbackContentItem();
    feedbackContentItem.setMimeType( mimeType );
  }

  protected void setOutputMimeType( final String mimeType ) {
    IContentItem outputContentItem = runtimeContext.getOutputContentItem( mimeType );
    outputContentItem.setMimeType( mimeType );
  }
View Full Code Here

    IContentItem outputContentItem = runtimeContext.getOutputContentItem( mimeType );
    outputContentItem.setMimeType( mimeType );
  }

  protected OutputStream getFeedbackOutputStream() {
    IContentItem feedbackContentItem = runtimeContext.getFeedbackContentItem();
    if ( feedbackContentItem != null ) {
      try {
        return feedbackContentItem.getOutputStream( getActionName() );
      } catch ( Exception e ) {
        //ignore
      }
    }
    return null;
View Full Code Here

TOP

Related Classes of org.pentaho.platform.api.repository.IContentItem

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.