public static String executeHtml( RepositoryFile file, HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse, IPentahoSession userSession,
IMimeTypeListener mimeTypeListener )
throws Exception {
IParameterProvider requestParams = new HttpRequestParameterProvider( httpServletRequest );
IRuntimeContext runtime = null;
try {
HttpSessionParameterProvider sessionParameters = new HttpSessionParameterProvider( userSession );
HttpRequestParameterProvider requestParameters = new HttpRequestParameterProvider( httpServletRequest );
boolean doMessages = "true".equalsIgnoreCase(
requestParams.getStringParameter( "debug", "false" ) ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
boolean doWrapper = "true".equalsIgnoreCase(
requestParams.getStringParameter( "wrapper", "true" ) ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
IOutputHandler outputHandler =
createOutputHandler( httpServletResponse, getOutputStream( httpServletResponse, doMessages ) );
// configure output handler, this is necessary so that the right content
// disposition is set on the response header
if ( mimeTypeListener == null ) {
mimeTypeListener = new HttpMimeTypeListener( httpServletRequest, httpServletResponse, null );
}
outputHandler.setMimeTypeListener( mimeTypeListener );
outputHandler.setSession( userSession );
Map parameterProviders = new HashMap();
parameterProviders.put( "request", requestParameters ); //$NON-NLS-1$
parameterProviders.put( "session", sessionParameters ); //$NON-NLS-1$
createOutputFileName( file, outputHandler );
int outputPreference = IOutputHandler.OUTPUT_TYPE_DEFAULT;
outputHandler.setOutputPreference( outputPreference );
boolean forcePrompt = "true".equalsIgnoreCase(
requestParams.getStringParameter( "prompt", "false" ) ); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
List messages = new ArrayList();
runtime =
executeInternal( file, requestParams, httpServletRequest, outputHandler, parameterProviders, userSession,
forcePrompt, messages );
String str =
postExecute( runtime, doMessages, doWrapper, outputHandler, parameterProviders, httpServletRequest,
httpServletResponse, messages );
return str;
} catch ( Exception e ) {
logger.error(
Messages.getInstance().getString( "XactionUtil.ERROR_EXECUTING_ACTION_SEQUENCE", file.getName() ),
e ); //$NON-NLS-1$
throw e;
} finally {
if ( runtime != null ) {
runtime.dispose();
}
}
}