Package org.pentaho.platform.api.repository

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


  @SuppressWarnings( "serial" )
  public static class JUnitServiceContentGenerator extends BaseContentGenerator {
    @Override
    public void createContent() throws Exception {
      try {
        IContentItem responseContentItem =
            outputHandler.getOutputContentItem( IOutputHandler.RESPONSE, IOutputHandler.CONTENT, null, null );
        // mime type setting will blow up since servlet api used by grizzly is too old
        try {
          responseContentItem.setMimeType( "text/plain" );
        } catch ( Throwable t ) {
          //ignored
        }
        OutputStream outputStream = responseContentItem.getOutputStream( null );
        IParameterProvider pathParams = parameterProviders.get( "path" );
        String command = pathParams.getStringParameter( "cmd", "" );

        Object testParamValue = parameterProviders.get( IParameterProvider.SCOPE_REQUEST ).getParameter( "testParam" );
        assertEquals( "testParam is missing from request", "testParamValue", testParamValue );
View Full Code Here


    if ( value == null ) {
      return;
    }

    if ( IOutputHandler.CONTENT.equalsIgnoreCase( name ) ) {
      IContentItem response = getOutputContentItem( "response", IOutputHandler.CONTENT, null, null ); //$NON-NLS-1$
      if ( response != null ) {
        if ( !( value instanceof IContentItem ) ) {
          if ( response.getMimeType() == null ) {
            response.setMimeType( "text/html" ); //$NON-NLS-1$
          }
          response.getOutputStream( null ).write( value.toString().getBytes() );
          contentGenerated = true;
        }
      }
    }
  }
View Full Code Here

            : getSolutionPath().substring( 1 ) );
    }
   
    filePath = replaceIllegalChars( filePath );
   
    IContentItem contentItem = null;
    String requestedFileExtension = MimeHelper.getExtension( getMimeType() );
    if ( requestedFileExtension == null ) {
      contentItem = new RepositoryFileContentItem( filePath );
    } else {
      String tempFilePath =
View Full Code Here

    return mimeTypeListener;
  }

  public IContentItem getOutputContentItem( final String outputName, final String contentName, final String instanceId,
      final String localMimeType ) {
    IContentItem outputContentItem = null;
    if ( outputName.equals( IOutputHandler.RESPONSE ) && contentName.equals( IOutputHandler.CONTENT ) ) {
      String requestedFileExtension = MimeHelper.getExtension( localMimeType );
      String currentExtension = FilenameUtils.getExtension( outputStream.getFilePath() );
      if ( requestedFileExtension == null ) {
        if ( currentExtension != null ) {
View Full Code Here

    }

    @Override
    public void createContent() throws Exception {
        final OutputStream out;
        final IContentItem contentItem;
        final IParameterProvider pathParams;
        final String method;
        final String payload;
        logger.info("CDF content generator took over: " + Long.toString((new Date()).getTime()));
        try {
            if (parameterProviders.get("path") != null
                    && parameterProviders.get("path").getParameter("httprequest") != null
                    && ((HttpServletRequest) parameterProviders.get("path").getParameter("httprequest")).getContextPath() != null) {
                RELATIVE_URL = ((HttpServletRequest) parameterProviders.get("path").getParameter("httprequest")).getContextPath();
            } else {
                RELATIVE_URL = getBaseUrl();
                /* If we detect an empty string, things will break.
                 * If we detect an absolute url, things will *probably* break.
                 * In either of these cases, we'll resort to Catalina's context,
                 * and its getContextPath() method for better results.
                 */
                if ("".equals(RELATIVE_URL) || RELATIVE_URL.matches("^http://.*")) {
                    Object context = PentahoSystem.getApplicationContext().getContext();
                    Method getContextPath = context.getClass().getMethod("getContextPath", null);
                    if (getContextPath != null) {
                        RELATIVE_URL = getContextPath.invoke(context, null).toString();
                    }
                }
            }

            if (RELATIVE_URL.endsWith("/")) {
                RELATIVE_URL = RELATIVE_URL.substring(0, RELATIVE_URL.length() - 1);
            }

            // If callbacks is properly setup, we assume we're being called from another plugin
            if (this.callbacks != null && callbacks.size() > 0 && HashMap.class.isInstance(callbacks.get(0))) {
                HashMap<String, Object> iface = (HashMap<String, Object>) callbacks.get(0);
                pathParams = parameterProviders.get("path");
                contentItem = outputHandler.getOutputContentItem("response", "content", "", instanceId, MIME_HTML);
                out = (OutputStream) iface.get("output");
                method = "/" + (String) iface.get("method");
                payload = (String) iface.get("payload");
                this.userSession = this.userSession != null ? this.userSession : (IPentahoSession) iface.get("usersession");
            } else { // if not, we handle the request normally
                pathParams = parameterProviders.get("path");
                contentItem = outputHandler.getOutputContentItem("response", "content", "", instanceId, MIME_HTML);
                out = contentItem.getOutputStream(null);
                method = pathParams.getStringParameter("path", null);
                payload = "";
            }

            // make sure we have a workable state
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.