use of org.apache.struts.chain.contexts.ServletActionContext in project sonarqube by SonarSource.
the class SetOriginalURI method setOriginalURI.
// ------------------------------------------------------- Protected Methods
protected void setOriginalURI(ActionContext context) {
ServletActionContext swcontext = (ServletActionContext) context;
HttpServletRequest request = swcontext.getRequest();
request.setAttribute(Globals.ORIGINAL_URI_KEY, request.getServletPath());
}
use of org.apache.struts.chain.contexts.ServletActionContext in project sonarqube by SonarSource.
the class ValidateActionForm method validate.
// ------------------------------------------------------- Protected Methods
/**
* <p>Call the <code>validate()</code> method of the specified form bean,
* and return the resulting <code>ActionErrors</code> object.</p>
*
* @param context The context for this request
* @param actionForm The form bean for this request
*/
protected ActionErrors validate(ActionContext context, ActionConfig actionConfig, ActionForm actionForm) {
ServletActionContext saContext = (ServletActionContext) context;
ActionErrors errors = (actionForm.validate((ActionMapping) actionConfig, saContext.getRequest()));
// Special handling for multipart request
if ((errors != null) && !errors.isEmpty()) {
if (actionForm.getMultipartRequestHandler() != null) {
if (log.isTraceEnabled()) {
log.trace(" Rolling back multipart request");
}
actionForm.getMultipartRequestHandler().rollback();
}
}
return errors;
}
use of org.apache.struts.chain.contexts.ServletActionContext in project sonarqube by SonarSource.
the class AuthorizeAction method isAuthorized.
// ------------------------------------------------------- Protected Methods
protected boolean isAuthorized(ActionContext context, String[] roles, ActionConfig mapping) throws Exception {
// Identify the HTTP request object
ServletActionContext servletActionContext = (ServletActionContext) context;
HttpServletRequest request = servletActionContext.getRequest();
// Check the current user against the list of required roles
for (int i = 0; i < roles.length; i++) {
if (request.isUserInRole(roles[i])) {
return (true);
}
}
// Default to unauthorized
return (false);
}
use of org.apache.struts.chain.contexts.ServletActionContext in project sonarqube by SonarSource.
the class AuthorizeAction method getErrorMessage.
protected String getErrorMessage(ActionContext context, ActionConfig actionConfig) {
ServletActionContext servletActionContext = (ServletActionContext) context;
// Retrieve internal message resources
ActionServlet servlet = servletActionContext.getActionServlet();
MessageResources resources = servlet.getInternal();
return resources.getMessage("notAuthorized", actionConfig.getPath());
}
use of org.apache.struts.chain.contexts.ServletActionContext 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