private static transient Logger logger = Logger.getLogger(QbeEngineStartAction.class);
public static final String ENGINE_NAME = "SpagoBIQbeEngine";
public void service(SourceBean serviceRequest, SourceBean serviceResponse) {
QbeEngineInstance qbeEngineInstance = null;
QbeEngineAnalysisState analysisState;
Locale locale;
logger.debug("IN");
try {
setEngineName(ENGINE_NAME);
super.service(serviceRequest, serviceResponse);
//if(true) throw new SpagoBIEngineStartupException(getEngineName(), "Test exception");
logger.debug("User Id: " + getUserId());
logger.debug("Audit Id: " + getAuditId());
logger.debug("Document Id: " + getDocumentId());
logger.debug("Template: " + getTemplateAsSourceBean());
if(getAuditServiceProxy() != null) {
logger.debug("Audit enabled: [TRUE]");
getAuditServiceProxy().notifyServiceStartEvent();
} else {
logger.debug("Audit enabled: [FALSE]");
}
logger.debug("Creating engine instance ...");
try {
qbeEngineInstance = QbeEngine.createInstance( getTemplateAsSourceBean(), getEnv() );
} catch(Throwable t) {
SpagoBIEngineStartupException serviceException;
String msg = "Impossible to create engine instance for document [" + getDocumentId() + "].";
Throwable rootException = t;
while(rootException.getCause() != null) {
rootException = rootException.getCause();
}
String str = rootException.getMessage()!=null? rootException.getMessage(): rootException.getClass().getName();
msg += "\nThe root cause of the error is: " + str;
serviceException = new SpagoBIEngineStartupException(ENGINE_NAME, msg, t);
if(rootException instanceof QbeTemplateParseException) {
QbeTemplateParseException e = (QbeTemplateParseException)rootException;
serviceException.setDescription( e.getDescription());
serviceException.setHints( e.getHints() );
}
throw serviceException;
}
logger.debug("Engine instance succesfully created");
qbeEngineInstance.setAnalysisMetadata( getAnalysisMetadata() );
if( getAnalysisStateRowData() != null ) {
logger.debug("Loading subobject [" + qbeEngineInstance.getAnalysisMetadata().getName() + "] ...");
try {
analysisState = new QbeEngineAnalysisState( qbeEngineInstance.getDataSource() );
analysisState.load( getAnalysisStateRowData() );
qbeEngineInstance.setAnalysisState( analysisState );
} catch(Throwable t) {
SpagoBIEngineStartupException serviceException;
String msg = "Impossible load subobject [" + qbeEngineInstance.getAnalysisMetadata().getName() + "].";
Throwable rootException = t;
while(rootException.getCause() != null) {
rootException = rootException.getCause();
}
String str = rootException.getMessage()!=null? rootException.getMessage(): rootException.getClass().getName();
msg += "\nThe root cause of the error is: " + str;
serviceException = new SpagoBIEngineStartupException(ENGINE_NAME, msg, t);
throw serviceException;
}
logger.debug("Subobject [" + qbeEngineInstance.getAnalysisMetadata().getName() + "] succesfully loaded");
}
locale = (Locale)qbeEngineInstance.getEnv().get(EngineConstants.ENV_LOCALE);
setAttributeInSession( ENGINE_INSTANCE, qbeEngineInstance);
setAttribute(ENGINE_INSTANCE, qbeEngineInstance);
setAttribute(LANGUAGE, locale.getLanguage());