/*************************************************************************************
 * Copyright (c) 2004 Actuate Corporation and others.
 * All rights reserved. This program and the accompanying materials 
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     Actuate Corporation - Initial implementation.
 ************************************************************************************/

package org.eclipse.birt.report.service.actionhandler;

import javax.servlet.ServletOutputStream;

import org.eclipse.birt.report.context.IContext;
import org.eclipse.birt.report.service.api.InputOptions;
import org.eclipse.birt.report.soapengine.api.GetUpdatedObjectsResponse;
import org.eclipse.birt.report.soapengine.api.Operation;
import org.eclipse.birt.report.utility.ParameterAccessor;

abstract public class AbstractRenderImageActionHandler
		extends
			AbstractBaseActionHandler
{

	public AbstractRenderImageActionHandler( IContext context,
			Operation operation, GetUpdatedObjectsResponse response )
	{
		super( context, operation, response );
	}

	public void __execute( ) throws Exception
	{
		context.getResponse( ).setContentType( "image" ); //$NON-NLS-1$
		String imageId = context.getRequest( ).getParameter(
				ParameterAccessor.PARAM_IMAGEID );
		ServletOutputStream out;
		String docName = null;// TODO: Do we need document name?

		InputOptions options = new InputOptions( );
		options.setOption( InputOptions.OPT_REQUEST, context.getRequest( ) );
		out = context.getResponse( ).getOutputStream( );
		getReportService( ).getImage( docName, imageId, out, options );
	}
}

@@ -640,16 +640,109 @@
 tStream;
+%0Aimport javax.servlet.http.HttpServletRequest;%0Aimport javax.servlet.http.HttpServletResponse;
 %0A%0Aimport
@@ -1348,71 +1348,177 @@
 %7B%0A%09%09
-context.getResponse( ).setContentType( %22image%22 ); //$NON-NLS-1$
+HttpServletRequest request = context.getRequest( );%0A%09%09HttpServletResponse response = context.getResponse();%0A%09%09%0A%09%09String docName = null;// TODO: Do we need document name?
 %0A%09%09S
@@ -1533,37 +1533,23 @@
 ageId = 
-context.getR
+r
 equest
-( )
 .getPara
@@ -1558,13 +1558,9 @@
 ter(
-%0A%09%09%09%09
+ 
 Para
@@ -1596,91 +1596,191 @@
 ;%0A%09%09
-ServletOutputStream out;%0A%09%09String docName = null;// TODO: Do we need document name?
+%0A%09%09response.setContentType( imageId.endsWith(%22.svg%22) ? %22image/svg+xml%22 : %22image%22 ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ %0A%09%09ServletOutputStream out = response.getOutputStream( );
 %0A%0A%09%09
@@ -1874,83 +1874,21 @@
 ST, 
-context.getR
+r
 equest
-( )
  );%0A%09%09
-out = context.getResponse( ).getOutputStream( );
 %0A%09%09g

Set contentType of the response to "image/svg+xml" if it is an svg file.