/*************************************************************************************
 * 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 javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

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
	{
		HttpServletRequest request = context.getRequest( );
		HttpServletResponse response = context.getResponse();
		
		String docName = null;// TODO: Do we need document name?
		String imageId = request.getParameter( ParameterAccessor.PARAM_IMAGEID );
		
		response.setContentType( imageId.endsWith(".svg") ? "image/svg+xml" : "image" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
		ServletOutputStream out = response.getOutputStream( );

		InputOptions options = new InputOptions( );
		options.setOption( InputOptions.OPT_REQUEST, request );
		
		getReportService( ).getImage( docName, imageId, out, options );
	}
}

@@ -1624,106 +1624,41 @@
 pe( 
-imageId.endsWith(%22.svg%22) ? %22image/svg+xml%22 : %22image%22 ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
+__getContentTypeByID( imageId ));
 %0A%09%09S
@@ -1819,16 +1819,16 @@
 t );%0A%09%09%0A
-
 %09%09getRep
@@ -1888,10 +1888,297 @@
 s );%0A%09%7D%0A
+%09%0A%09private String __getContentTypeByID (String imageId)%0A%09%7B%0A%09%09if(imageId.endsWith(%22.svg%22)) //$NON-NLS-1$%0A%09%09%7B%0A%09%09%09return %22image/svg+xml%22; //$NON-NLS-1$%0A%09%09%7D%0A%09%09else if (imageId.endsWith(%22.ico%22)) //$NON-NLS-1$%0A%09%09%7B%0A%09%09%09return %22image/x-icon%22; //$NON-NLS-1$%0A%09%09%7D%0A%09%09return %22image%22; //$NON-NLS-1$%0A%09%7D%0A
 %7D%0A

Set content type for ico images. (52781)