use of org.apache.struts.config.ActionConfig in project sonarqube by SonarSource.
the class AbstractPopulateActionForm method execute.
// ---------------------------------------------------------- Public Methods
/**
* <p>Populate the form bean (if any) for this request.</p>
*
* @param actionCtx The <code>Context</code> for the current request
* @return <code>false</code> so that processing continues
* @throws Exception On an unexpected error
*/
public boolean execute(ActionContext actionCtx) throws Exception {
// Is there a form bean for this request?
ActionForm actionForm = actionCtx.getActionForm();
if (actionForm == null) {
return (false);
}
// Reset the form bean property values
ActionConfig actionConfig = actionCtx.getActionConfig();
reset(actionCtx, actionConfig, actionForm);
populate(actionCtx, actionConfig, actionForm);
handleCancel(actionCtx, actionConfig, actionForm);
return (false);
}
use of org.apache.struts.config.ActionConfig in project sonarqube by SonarSource.
the class AbstractSelectAction method execute.
// ---------------------------------------------------------- Public Methods
/**
* <p>Cache the <code>ActionConfig</code> instance for the action to be
* used for processing this request.</p>
*
* @param actionCtx The <code>Context</code> for the current request
* @return <code>false</code> so that processing continues
* @throws InvalidPathException if no valid action can be identified for
* this request
* @throws Exception if thrown by the Action class
*/
public boolean execute(ActionContext actionCtx) throws Exception {
// Identify the matching path for this request
String path = getPath(actionCtx);
// Cache the corresponding ActonConfig instance
ModuleConfig moduleConfig = actionCtx.getModuleConfig();
ActionConfig actionConfig = moduleConfig.findActionConfig(path);
if (actionConfig == null) {
// NOTE Shouldn't this be the responsibility of ModuleConfig?
// Locate the mapping for unknown paths (if any)
ActionConfig[] configs = moduleConfig.findActionConfigs();
for (int i = 0; i < configs.length; i++) {
if (configs[i].getUnknown()) {
actionConfig = configs[i];
break;
}
}
}
if (actionConfig == null) {
throw new InvalidPathException("No action config found for the specified url.", path);
}
actionCtx.setActionConfig(actionConfig);
return (false);
}
use of org.apache.struts.config.ActionConfig in project sonarqube by SonarSource.
the class AbstractSelectForward method execute.
// ---------------------------------------------------------- Public Methods
/**
* <p>Select and cache the <code>ActionForward</code> for this
* <code>ActionConfig</code> if specified.</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 configuration objects that we need
ActionConfig actionConfig = actionCtx.getActionConfig();
ModuleConfig moduleConfig = actionConfig.getModuleConfig();
ForwardConfig forwardConfig = null;
String forward = actionConfig.getForward();
if (forward != null) {
forwardConfig = forward(actionCtx, moduleConfig, forward);
if (LOG.isDebugEnabled()) {
LOG.debug("Forwarding to " + forwardConfig);
}
actionCtx.setForwardConfig(forwardConfig);
}
return (false);
}
use of org.apache.struts.config.ActionConfig in project sonarqube by SonarSource.
the class AbstractValidateActionForm method execute.
// ---------------------------------------------------------- Public Methods
/**
* <p>Validate the properties of the form bean for this request. If there
* are any validation errors, execute the child commands in our chain;
* otherwise, proceed normally.</p>
*
* @param actionCtx The <code>Context</code> for the current request
* @return <code>false</code> so that processing continues, if there are
* no validation errors; otherwise <code>true</code>
* @throws Exception if thrown by the Action class
*/
public boolean execute(ActionContext actionCtx) throws Exception {
// Set form valid until found otherwise
actionCtx.setFormValid(Boolean.TRUE);
// Is there a form bean for this request?
ActionForm actionForm = actionCtx.getActionForm();
if (actionForm == null) {
return false;
}
// Is validation disabled on this request?
ActionConfig actionConfig = actionCtx.getActionConfig();
if (!actionConfig.getValidate()) {
return false;
}
// Was this request cancelled?
if (isCancelled(actionCtx, actionConfig)) {
if (LOG.isDebugEnabled()) {
LOG.debug(" Cancelled transaction, skipping validation");
}
return false;
}
// Call the validate() method of this form bean
ActionErrors errors = validate(actionCtx, actionConfig, actionForm);
// If there were no errors, proceed normally
if ((errors == null) || (errors.isEmpty())) {
return false;
}
// Flag the validation failure and proceed
/* NOTE: Is there any concern that there might have already
* been errors, or that other errors might be coming?
*/
actionCtx.saveErrors(errors);
actionCtx.setFormValid(Boolean.FALSE);
return false;
}
use of org.apache.struts.config.ActionConfig in project sonarqube by SonarSource.
the class CreateActionForm method execute.
// ---------------------------------------------------------- Public Methods
/**
* <p>Create (if necessary) and cache a form bean for this request.</p>
*
* @param actionCtx The <code>Context</code> for the current request
* @return <code>false</code> so that processing continues
* @throws Exception on any error
*/
public boolean execute(ActionContext actionCtx) throws Exception {
// Is there a form bean associated with this ActionConfig?
ActionConfig actionConfig = actionCtx.getActionConfig();
String name = actionConfig.getName();
if (name == null) {
actionCtx.setActionForm(null);
return (false);
}
if (LOG.isTraceEnabled()) {
LOG.trace("Look up form-bean " + name);
}
// Look up the corresponding FormBeanConfig (if any)
FormBeanConfig formBeanConfig = actionConfig.getModuleConfig().findFormBeanConfig(name);
if (formBeanConfig == null) {
LOG.warn("No FormBeanConfig found in module " + actionConfig.getModuleConfig().getPrefix() + " under name " + name);
actionCtx.setActionForm(null);
return (false);
}
Map scope = actionCtx.getScope(actionConfig.getScope());
ActionForm instance;
instance = (ActionForm) scope.get(actionConfig.getAttribute());
// Can we recycle the existing instance (if any)?
if (!formBeanConfig.canReuse(instance)) {
instance = formBeanConfig.createActionForm(actionCtx);
}
// directly depends on ActionServlet
if (actionCtx instanceof ServletActionContext) {
// The servlet property of ActionForm is transient, so
// ActionForms which are restored from a serialized state
// need to have their servlet restored.
ServletActionContext sac = (ServletActionContext) actionCtx;
instance.setServlet(sac.getActionServlet());
}
actionCtx.setActionForm(instance);
scope.put(actionConfig.getAttribute(), instance);
return (false);
}
Aggregations