private static final String ENGINE_NAME = "SpagoBIConsoleEngine";
public void service(SourceBean serviceRequest, SourceBean serviceResponse) {
logger.debug("IN");
Monitor monitor =MonitorFactory.start("SpagoBI_Console.ConsoleEngineStartAction.service");
Locale locale;
DataSetServiceProxy proxyDS = null;
ConsoleEngineInstance consoleEngineInstance = null;
try {
setEngineName(ENGINE_NAME);
super.service(serviceRequest, serviceResponse);
logger.debug("User Id: " + getUserId());
logger.debug("Audit Id: " + getAuditId());
logger.debug("Document Id: " + getDocumentId());
logger.debug("Template: " + getTemplateAsString());
if(getAuditServiceProxy() != null) {
logger.debug("Audit enabled: [TRUE]");
getAuditServiceProxy().notifyServiceStartEvent();
} else {
logger.debug("Audit enabled: [FALSE]");
}
logger.debug("Creating engine instance ...");
try {
consoleEngineInstance = ConsoleEngine.createInstance( getTemplateAsJSONObject(), 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);
throw serviceException;
}
logger.debug("Engine instance succesfully created");
locale = (Locale)consoleEngineInstance.getEnv().get(EngineConstants.ENV_LOCALE);
setAttributeInSession( ENGINE_INSTANCE, consoleEngineInstance);
setAttribute(ENGINE_INSTANCE, consoleEngineInstance);
setAttribute(LANGUAGE, locale.getLanguage());
setAttribute(COUNTRY, locale.getCountry());
} catch (Exception e) {
SpagoBIEngineStartupException serviceException = null;
if(e instanceof SpagoBIEngineStartupException) {
serviceException = (SpagoBIEngineStartupException)e;
} else {
Throwable rootException = e;
while(rootException.getCause() != null) {
rootException = rootException.getCause();
}
String str = rootException.getMessage()!=null? rootException.getMessage(): rootException.getClass().getName();
String message = "An unpredicted error occurred while executing " + getEngineName() + " service."
+ "\nThe root cause of the error is: " + str;
serviceException = new SpagoBIEngineStartupException(getEngineName(), message, e);
}
throw serviceException;
} finally {
monitor.stop();
logger.debug("OUT");
}
}