* Note: this action must be invoked against a specific instance (the instance number must be in the request URL).
* @return a page showing what action was taken (with regard to EOAdaptorDebugging), if any.
*/
public WOActionResults eoAdaptorDebuggingAction() {
if (canPerformActionWithPasswordKey("er.extensions.ERXEOAdaptorDebuggingPassword")) {
ERXStringHolder result = pageWithName(ERXStringHolder.class);
result.setEscapeHTML(false);
String message;
boolean currentState = ERXExtensions.adaptorLogging();
int instance = request().applicationNumber();
if (instance == -1) {
log.info("EOAdaptorDebuggingAction requested without a specific instance.");
message = "<p>You must invoke this action on a <em>specific</em> instance.</p>" +
"<p>Your url should look like: <code>.../WebObjects/1/wa/...</code>, where '1' would be the first instance of the target application.</p>";
} else {
String debugParam = request().stringFormValueForKey("debug");
log.debug("EOAdaptorDebuggingAction requested with 'debug' param:" + debugParam);
if (debugParam == null || debugParam.trim().length() == 0) {
message = "<p>EOAdaptorDebugging is currently <strong>" + (currentState ? "ON" : "OFF") + "</strong> for instance <strong>" + instance + "</strong>.</p>";
message += "<p>To change the setting, provide the 'debug' parameter to this action, e.g.: <code>...eoAdaptorDebugging?debug=on&pw=secret</code></p>";
} else {
if (debugParam.trim().equalsIgnoreCase("on")) {
debugParam = "true";
} else if (debugParam.trim().equalsIgnoreCase("off")) {
debugParam = "false";
}
boolean desiredState = ERXValueUtilities.booleanValueWithDefault(debugParam, false);
log.debug("EOAdaptorDebuggingAction requested 'debug' state change to: '" + desiredState + "' for instance: " + instance + ".");
if (currentState != desiredState) {
ERXExtensions.setAdaptorLogging(desiredState);
message = "<p>Turned EOAdaptorDebugging <strong>" + (desiredState ? "ON" : "OFF") + "</strong> for instance <strong>" + instance + "</strong>.</p>";
} else {
message = "<p>EOAdaptorDebugging setting <strong>not changed</strong>.</p>";
}
}
}
message += "<p><em>Please be mindful of using EOAdaptorDebugging as it may have a large impact on application performance.</em></p>";
result.setValue(message);
return result;
}
return forbiddenResponse();
}