use of org.apache.struts.action.Action in project sonarqube by SonarSource.
the class AbstractCreateAction method execute.
// ---------------------------------------------------------- Public Methods
/**
* <p>Create (if necessary) and cache an <code>Action</code> for this
* request.</p>
*
* @param actionCtx The <code>Context</code> for the current request
* @return <code>false</code> so that processing continues
* @throws Exception if there are any problems instantiating the Action
* class.
*/
public boolean execute(ActionContext actionCtx) throws Exception {
// Skip processing if the current request is not valid
Boolean valid = actionCtx.getFormValid();
if ((valid == null) || !valid.booleanValue()) {
LOG.trace("Invalid form; not going to execute.");
return (false);
}
// Check to see if an action has already been created
if (actionCtx.getAction() != null) {
LOG.trace("already have an action [" + actionCtx.getAction() + "]");
return (false);
}
// Look up the class name for the desired Action
ActionConfig actionConfig = actionCtx.getActionConfig();
String type = actionConfig.getType();
if (type == null) {
String command = actionConfig.getCommand();
if ((command == null) && (actionConfig.getForward() == null) && (actionConfig.getInclude() == null)) {
LOG.error("no type or command for " + actionConfig.getPath());
} else {
LOG.trace("no type for " + actionConfig.getPath());
}
return (false);
}
// Create (if necessary) and cache an Action instance
Action action = getAction(actionCtx, type, actionConfig);
if (LOG.isTraceEnabled()) {
LOG.trace("setting action to " + action);
}
actionCtx.setAction(action);
return (false);
}
use of org.apache.struts.action.Action in project sonarqube by SonarSource.
the class AbstractExecuteAction method execute.
// ---------------------------------------------------------- Public Methods
/**
* <p>Invoke the appropriate <code>Action</code> for this request, and
* cache the returned <code>ActionForward</code>.</p>
*
* @param actionCtx The <code>Context</code> for the current request
* @return <code>false</code> so that processing continues
* @throws Exception if thrown by the Action class
*/
public boolean execute(ActionContext actionCtx) throws Exception {
// Skip processing if the current request is not valid
Boolean valid = actionCtx.getFormValid();
if ((valid == null) || !valid.booleanValue()) {
return (false);
}
// Acquire the resources we will need to send to the Action
Action action = actionCtx.getAction();
if (action == null) {
return (false);
}
ActionConfig actionConfig = actionCtx.getActionConfig();
ActionForm actionForm = actionCtx.getActionForm();
// Execute the Action for this request, caching returned ActionForward
ForwardConfig forwardConfig = execute(actionCtx, action, actionConfig, actionForm);
actionCtx.setForwardConfig(forwardConfig);
return (false);
}
use of org.apache.struts.action.Action in project sonarqube by SonarSource.
the class CreateAction method getAction.
/* :TODO The Action class' dependency on having its "servlet" property set
* requires this API-dependent subclass of AbstractCreateAction.
*/
protected synchronized Action getAction(ActionContext context, String type, ActionConfig actionConfig) throws Exception {
ModuleConfig moduleConfig = actionConfig.getModuleConfig();
String actionsKey = Constants.ACTIONS_KEY + moduleConfig.getPrefix();
Map actions = (Map) context.getApplicationScope().get(actionsKey);
if (actions == null) {
actions = new HashMap();
context.getApplicationScope().put(actionsKey, actions);
}
Action action = null;
synchronized (actions) {
action = (Action) actions.get(type);
if (action == null) {
action = createAction(context, type);
actions.put(type, action);
}
}
if (action.getServlet() == null) {
ServletActionContext saContext = (ServletActionContext) context;
ActionServlet actionServlet = saContext.getActionServlet();
action.setServlet(actionServlet);
}
return (action);
}
Aggregations