/*
 *  $ProjectName: V:/projects/ins2001/java/java-insx.pj $
 *  $Header: /repository/sources/java/com/insx/misc/InsVirtualMappingResolver.java,v 1.3 2005/05/27 19:23:46 kevin Exp $
 *  -----------------------------------------------------------------------
 *  Revision 1.2  2005/05/23 19:51:55  qing
 *  Port to tomcat
 *  -----------------------------------------------------------------------
 */


package com.insx.isomorphic.ds;
import com.isomorphic.rpc.RPCManager;
import com.isomorphic.rpc.ClientMustResubmitException;
import com.isomorphic.datasource.DSRequest;
import com.isomorphic.datasource.DSResponse;
 
import com.isomorphic.datasource.DataSource;
import com.isomorphic.servlet.IDACall; 
import com.isomorphic.servlet.RequestContext; 
import com.isomorphic.js.JSTranslater;
import com.ins.base.InsResourceMgr;
import com.insx.isomorphic.ds.FSReportDS;

import java.io.IOException;
import javax.servlet.*;

/**
 * Description of the Class
 *
 * @author  Qing Wang
 
 */

public class InsIDACall extends IDACall
{
	public DSResponse handleDSRequest(DSRequest dsRequest,
									  RPCManager rpc,
									  RequestContext context)
		throws java.lang.Exception{
		
		String dsName = dsRequest.getDataSourceName();
		if(dsName != null && dsName.equals("FSReportDS")){
			String docStr = FSReportDS.getXMLContents("FSReportDS", dsRequest.getHttpServletRequest());
			InsResourceMgr.getDefaultLog().logInfo("server docStr");
			InsResourceMgr.getDefaultLog().logInfo(docStr);
			DataSource ds = DataSource.fromXML(docStr);
		
			String dsStr = JSTranslater.get().toJS(ds);
			InsResourceMgr.getDefaultLog().logInfo("server dsStr");
			InsResourceMgr.getDefaultLog().logInfo(dsStr);
			return ds.execute(dsRequest);
		} else{
			return super.handleDSRequest(dsRequest, rpc, context);
		}
	}
}
