use of org.apache.struts.config.ActionConfig in project sonar-java by SonarSource.
the class TestAuthorizeAction method testAuthorizeOneOfManyRoles.
public void testAuthorizeOneOfManyRoles() throws Exception {
ActionConfig config = new ActionConfig();
config.setPath("/testAuthorizeOneOfManyRoles");
config.setRoles("administrator,roustabout,memory");
this.saContext.setActionConfig(config);
boolean result = command.execute(saContext);
assertFalse(result);
}
use of org.apache.struts.config.ActionConfig in project sonarqube by SonarSource.
the class SelectInclude method execute.
// ---------------------------------------------------------- Public Methods
/**
* <p>Select and cache the include uri 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 on any error
*/
public boolean execute(ActionContext actionCtx) throws Exception {
// Acquire configuration objects that we need
ActionConfig actionConfig = actionCtx.getActionConfig();
// Cache an include uri if found
String include = actionConfig.getInclude();
if (include != null) {
if (LOG.isDebugEnabled()) {
LOG.debug("Including " + include);
}
actionCtx.setInclude(include);
}
return (false);
}
use of org.apache.struts.config.ActionConfig in project sonarqube by SonarSource.
the class CopyFormToContext method findOrCreateForm.
/**
* <p>Based on the properties of this command and the given
* <code>ActionContext</code>, find or create an ActionForm instance for
* preparation.</p>
*
* @param context ActionContextBase class that we are processing
* @return ActionForm instance
* @throws IllegalArgumentException On ActionConfig not found
* @throws IllegalStateException On undefined scope and formbean
* @throws IllegalAccessException On failed instantiation
* @throws InstantiationException If ActionContext is not subsclass of
* ActionContextBase
*/
protected ActionForm findOrCreateForm(ActionContext context) throws IllegalAccessException, InstantiationException {
String effectiveFormName;
String effectiveScope;
if (!(isEmpty(this.getActionPath()))) {
ActionConfig actionConfig = context.getModuleConfig().findActionConfig(this.getActionPath());
if (actionConfig == null) {
throw new IllegalArgumentException("No ActionConfig found for path " + this.getActionPath());
}
effectiveFormName = actionConfig.getName();
effectiveScope = actionConfig.getScope();
} else {
effectiveFormName = this.getFormName();
effectiveScope = this.getScope();
}
if (isEmpty(effectiveScope) || isEmpty(effectiveFormName)) {
throw new IllegalStateException("Both scope [" + effectiveScope + "] and formName [" + effectiveFormName + "] must be defined.");
}
return findOrCreateForm(context, effectiveFormName, effectiveScope);
}
use of org.apache.struts.config.ActionConfig in project sonarqube 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 sonarqube by SonarSource.
the class AbstractExceptionHandler 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> if a <code>ForwardConfig</code> is returned,
* else <code>true</code> to complete processing
* @throws Exception if thrown by the Action class and not declared by an
* Exception Handler
*/
public boolean execute(ActionContext actionCtx) throws Exception {
// Look up the exception that was thrown
Exception exception = actionCtx.getException();
if (exception == null) {
LOG.warn("No Exception found in ActionContext");
return (true);
}
// Look up the local or global exception handler configuration
ExceptionConfig exceptionConfig = null;
ActionConfig actionConfig = actionCtx.getActionConfig();
ModuleConfig moduleConfig = actionCtx.getModuleConfig();
if (actionConfig != null) {
if (LOG.isDebugEnabled()) {
LOG.debug("See if actionConfig " + actionConfig + " has an exceptionConfig for " + exception.getClass().getName());
}
exceptionConfig = actionConfig.findException(exception.getClass());
} else if (moduleConfig != null) {
if (LOG.isDebugEnabled()) {
LOG.debug("No action yet, see if moduleConfig " + moduleConfig + " has an exceptionConfig " + exception.getClass().getName());
}
exceptionConfig = moduleConfig.findException(exception.getClass());
}
// Handle the exception in the configured manner
if (exceptionConfig == null) {
LOG.warn("Unhandled exception", exception);
throw exception;
}
ForwardConfig forwardConfig = handle(actionCtx, exception, exceptionConfig, actionConfig, moduleConfig);
if (forwardConfig != null) {
actionCtx.setForwardConfig(forwardConfig);
return (false);
} else {
return (true);
}
}
Aggregations