/**
* SpagoBI - The Business Intelligence Free Platform
*
* Copyright (C) 2004 - 2008 Engineering Ingegneria Informatica S.p.A.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
**/
package it.eng.spagobi.engines.qbe.services.worksheet;
import java.io.IOException;
import org.apache.log4j.Logger;
import org.json.JSONObject;
import it.eng.qbe.serializer.SerializationManager;
import it.eng.spago.base.SourceBean;
import it.eng.spagobi.engines.qbe.FormState;
import it.eng.spagobi.engines.qbe.QbeEngineInstance;
import it.eng.spagobi.engines.qbe.services.core.AbstractQbeEngineAction;
import it.eng.spagobi.engines.qbe.worksheet.WorkSheetDefinition;
import it.eng.spagobi.utilities.assertion.Assert;
import it.eng.spagobi.utilities.engines.EngineConstants;
import it.eng.spagobi.utilities.engines.SpagoBIEngineServiceException;
import it.eng.spagobi.utilities.engines.SpagoBIEngineServiceExceptionHandler;
import it.eng.spagobi.utilities.service.JSONSuccess;
/**
* @authors Alberto Ghedin (alberto.ghedin@eng.it)
*/
public class GetWorkSheetPreviewAction extends AbstractQbeEngineAction {
private static final long serialVersionUID = 4009276536964480679L;
/** Logger component. */
public static transient Logger logger = Logger.getLogger(GetWorkSheetPreviewAction.class);
public void service(SourceBean request, SourceBean response) {
logger.debug("IN");
super.service(request, response);
try {
QbeEngineInstance engineInstance = getEngineInstance();
Assert.assertNotNull(engineInstance, "It's not possible to execute " + this.getActionName() + " service before having properly created an instance of EngineInstance class");
setAttribute(EngineConstants.ENGINE_INSTANCE, engineInstance);
// //get the worksheet from the engine instance
// WorkSheetDefinition workSheetDefinition = getEngineInstance().getWorkSheetDefinition();
// if(workSheetDefinition==null){
// workSheetDefinition = WorkSheetDefinition.EMPTY_WORKSHEET;
// }
// JSONObject workSheetDefinitionJSON = (JSONObject)SerializationManager.serialize(workSheetDefinition, "application/json");
// try {
// writeBackToClient( new JSONSuccess( workSheetDefinitionJSON ) );
// } catch (IOException e) {
// String message = "Impossible to write back the responce to the client";
// throw new SpagoBIEngineServiceException(getActionName(), message, e);
// }
} catch(Throwable t) {
throw SpagoBIEngineServiceExceptionHandler.getInstance().getWrappedException(getActionName(), getEngineInstance(), t);
} finally {
logger.debug("OUT");
}
}
}