Skip to content

Commit

Permalink
[ML-DOSSIER] Add logs to page execution
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Libanori committed Mar 21, 2024
1 parent d1df3ce commit 37bb3c7
Showing 1 changed file with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@
import it.eng.spagobi.commons.utilities.GeneralUtilities;
import it.eng.spagobi.commons.utilities.ObjectsAccessVerifier;
import it.eng.spagobi.commons.utilities.SpagoBIUtilities;
import it.eng.spagobi.container.IContainer;
import it.eng.spagobi.engines.config.bo.Engine;
import it.eng.spagobi.utilities.engines.EngineConstants;
import it.eng.spagobi.utilities.engines.EngineStartServletIOManager;
import it.eng.spagobi.utilities.engines.SpagoBIEngineServiceExceptionHandler;
import it.eng.spagobi.utilities.exceptions.SpagoBIRuntimeException;

Expand Down Expand Up @@ -223,6 +225,7 @@ private Object openPageInternal(String pageName) {
response.setContentType(MediaType.TEXT_HTML);
response.setCharacterEncoding(UTF_8.name());

EngineStartServletIOManager ioManager = getIOManager();
if ("execute".equals(pageName)) {
String outputType = request.getParameter(OUTPUT_TYPE);
if ("xls".equalsIgnoreCase(outputType) || "xlsx".equalsIgnoreCase(outputType)) {
Expand All @@ -234,9 +237,19 @@ private Object openPageInternal(String pageName) {
} else if ("PNG".equalsIgnoreCase(outputType)) {
return createRedirect("/png");
} else {
engineInstance = CockpitEngine.createInstance(getIOManager().getTemplateAsString(),
getIOManager().getEnv());
getIOManager().getHttpSession().setAttribute(EngineConstants.ENGINE_INSTANCE, engineInstance);
IContainer requestContainer = ioManager.getRequestContainer();
Map env = ioManager.getEnv();
List<String> keys = requestContainer.getKeys();

LOGGER.warn("Request container contains:");
keys.forEach((key) -> LOGGER.warn("{} - {}", key, requestContainer.getString(key)));

LOGGER.warn("Environment vars are:");
env.forEach((key, value) -> LOGGER.warn("{} - {}", key, value));

String templateAsString = ioManager.getTemplateAsString();
engineInstance = CockpitEngine.createInstance(templateAsString, env);
ioManager.getHttpSession().setAttribute(EngineConstants.ENGINE_INSTANCE, engineInstance);

String editMode = request.getParameter("documentMode");
if (editMode != null) {
Expand All @@ -262,8 +275,8 @@ private Object openPageInternal(String pageName) {
template = buildBaseTemplate();
// create a new engine instance
engineInstance = CockpitEngine.createInstance(template.toString(), // servletIOManager.getTemplateAsString(),
getIOManager().getEnvForWidget());
getIOManager().getHttpSession().setAttribute(EngineConstants.ENGINE_INSTANCE, engineInstance);
ioManager.getEnvForWidget());
ioManager.getHttpSession().setAttribute(EngineConstants.ENGINE_INSTANCE, engineInstance);
dispatchUrl = "/WEB-INF/jsp/ngCockpit.jsp";
} else {
// error
Expand Down

0 comments on commit 37bb3c7

Please sign in to comment.