if (!actionLink.getSessionID().equals(session.getId())) {
throw new TMLInvalidActionLinkException("The action was registered for a different session ID");
}
// Try to retrieve action context - defaults to context of this tag
TMLContext actionContext = getTMLContext();
if (!actionLink.getContextPath().equals(TMLActionLink.EMPTY_PARAM)) {
actionContext = actionContext.context(actionLink.getContextPath(), false);
// Could not retrieve context. Too dangerous to execute action under the wrong context.
if (actionContext == null) {
throw new TMLActionException("Unable to retrieve action context: " + actionLink.getContextPath());
}
} else {
//B00004602
// no context path - switch to dummy context of the given db
actionContext = getTMLContext().context("db:" + actionLink.getDbKey(), false);
// Could not retrieve dummy context. Too dangerous to execute action under the wrong context.
if (actionContext == null) {
throw new TMLActionException("Unable to retrieve action context: db:" + actionLink.getDbKey());
}
}
// Temporarily set portlet namespace, WebTML scope
BaseTagStatus tag = getTMLContext().getDesignContext().getTag();
TMLOptionPreserver preserver = new TMLOptionPreserver(tag);
preserver.preserve(Base.OPTION_PORTLET_NAMESPACE, actionLink.getPortletKey());
preserver.preserve(Base.OPTION_WEBTML_SCOPE, actionLink.getWebtmlScope());
try {
// Inner call, depends, if this a default action or not
if (actionLink.isDefaultAction()) {
actionContext.callDefaultAction(actionLink.getDefaultAction(), params);
if (actionLink.getPortletmode() != null && actionContext.getportlet() != null) {
actionContext.getportlet().setmode(actionLink.getPortletmode());
}
applyPortletContext(actionLink, actionContext);
return null;
}
else {
TMLAction tmlAction = (TMLAction) getTMLContext().getActionRegistration().get(actionLink.getActionKeyInteger());
if (tmlAction == null) {
throw new TMLActionException("Could not find action for key " + actionLink.getActionKey());
}
actionContext.callCustomAction(tmlAction, params);
if (actionLink.getPortletmode() != null && actionContext.getportlet() != null) {
if (getTMLContext().isdefined("actionresult")) {
ExpressionResult expressionResult = (ExpressionResult) getTMLContext().item("actionresult");
if (!expressionResult.isError() && (expressionResult.getResult() == null || expressionResult.getResult() instanceof String || !expressionResult.isFalse())) {
actionContext.getportlet().setmode(actionLink.getPortletmode());
}
}
}
applyPortletContext(actionLink, actionContext);
return tmlAction;