InputStream in = request.getInputStream();
String servletPath = request.getServletPath();
String pathInfo = request.getPathInfo();
String contentGeneratorId = ""; //$NON-NLS-1$
String urlPath = ""; //$NON-NLS-1$
SimpleParameterProvider pathParams = new SimpleParameterProvider();
if ( StringUtils.isEmpty( pathInfo ) ) {
logger.error(
Messages.getInstance().getErrorString( "GenericServlet.ERROR_0005_NO_RESOURCE_SPECIFIED" ) ); //$NON-NLS-1$
response.sendError( 403 );
return;
}
String path = pathInfo.substring( 1 );
int slashPos = path.indexOf( '/' );
if ( slashPos != -1 ) {
pathParams.setParameter( "path", pathInfo.substring( slashPos + 1 ) ); //$NON-NLS-1$
contentGeneratorId = path.substring( 0, slashPos );
} else {
contentGeneratorId = path;
}
urlPath = "content/" + contentGeneratorId; //$NON-NLS-1$
pathParams.setParameter( "query", request.getQueryString() ); //$NON-NLS-1$
pathParams.setParameter( "contentType", request.getContentType() ); //$NON-NLS-1$
pathParams.setParameter( "inputstream", in ); //$NON-NLS-1$
pathParams.setParameter( "httpresponse", response ); //$NON-NLS-1$
pathParams.setParameter( "httprequest", request ); //$NON-NLS-1$
pathParams.setParameter( "remoteaddr", request.getRemoteAddr() ); //$NON-NLS-1$
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 ) ) {