use of org.apache.struts.config.ActionConfig in project sonar-java by SonarSource.
the class TestAuthorizeAction method testAuthorizeOneRole.
public void testAuthorizeOneRole() throws Exception {
ActionConfig config = new ActionConfig();
config.setPath("/testAuthorizeOneRole");
config.setRoles("administrator");
this.saContext.setActionConfig(config);
boolean result = command.execute(saContext);
assertFalse(result);
}
use of org.apache.struts.config.ActionConfig in project sonar-java by SonarSource.
the class TestAuthorizeAction method testNotAuthorizedOneOfManyRoles.
public void testNotAuthorizedOneOfManyRoles() throws Exception {
ActionConfig config = new ActionConfig();
config.setPath("/testNotAuthorizedOneOfManyRoles");
config.setRoles("roustabout,memory");
this.saContext.setActionConfig(config);
try {
boolean result = command.execute(saContext);
} catch (UnauthorizedActionException ex) {
}
}
use of org.apache.struts.config.ActionConfig in project sonar-java 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 sonar-java by SonarSource.
the class AbstractSelectInput method execute.
// ---------------------------------------------------------- Public Methods
/**
* <p>Select and cache a <code>ForwardConfig</code> for the input page for
* the current request.</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 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();
// Cache an ForwardConfig back to our input page
ForwardConfig forwardConfig;
String input = actionConfig.getInput();
if (moduleConfig.getControllerConfig().getInputForward()) {
if (LOG.isTraceEnabled()) {
LOG.trace("Finding ForwardConfig for '" + input + "'");
}
forwardConfig = actionConfig.findForwardConfig(input);
if (forwardConfig == null) {
forwardConfig = moduleConfig.findForwardConfig(input);
}
} else {
if (LOG.isTraceEnabled()) {
LOG.trace("Delegating to forward() for '" + input + "'");
}
forwardConfig = forward(actionCtx, moduleConfig, input);
}
if (LOG.isDebugEnabled()) {
LOG.debug("Forwarding back to " + forwardConfig);
}
actionCtx.setForwardConfig(forwardConfig);
return (false);
}
use of org.apache.struts.config.ActionConfig in project sonar-java 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;
}
Aggregations