Java Code Examples for org.apache.struts.action.ActionMapping#getParameter()

The following examples show how to use org.apache.struts.action.ActionMapping#getParameter() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ForwardWithQueryParametersAction.java    From rice with Educational Community License v2.0 6 votes vote down vote up
public ActionForward execute(
    ActionMapping mapping,
    ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response)
    throws Exception {

    String path = mapping.getParameter();
    if (request.getQueryString() != null) {
    	path = path + "?" + request.getQueryString();
    }
    ActionForward retVal = new ActionForward(path);
    retVal.setModule("");

    return retVal;
}
 
Example 2
Source File: ConfigHandler.java    From iaf with Apache License 2.0 6 votes vote down vote up
public ActionForward executeSub(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
	String adapterName = null;
	String receiverName = null;
	// Initialize action
	initAction(request);

	if (null == ibisManager) {
		return (mapping.findForward("noconfig"));
	}
	String action = request.getParameter("action");
	if (null == action)
		action = mapping.getParameter();

	if (action.equals("showoriginalconfig")) {
		AppConstants.getInstance().put("showConfiguration.original", "true");
	} else {
		AppConstants.getInstance().put("showConfiguration.original", "false");
	}
	
	// Report any errors we have discovered back to the original form
	if (!errors.isEmpty()) {
		saveErrors(request, errors);
	} // Forward control to the specified success URI
	log.debug("forward to success");
	return (mapping.findForward("success"));
}
 
Example 3
Source File: CobblerSnippetListSetupAction.java    From uyuni with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ${@inheritDoc}
 */
public ActionForward execute(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {

    request.setAttribute(mapping.getParameter(), Boolean.TRUE);
    RequestContext context = new RequestContext(request);
    User user = context.getCurrentUser();
    List<CobblerSnippet> result = new ArrayList<CobblerSnippet>();
    try {
        if (ALL.equals(mapping.getParameter())) {
            result = CobblerSnippetLister.getInstance().list(user);
        }
        else if (RhnHelper.DEFAULT_FORWARD.equals(mapping.getParameter())) {
            result = CobblerSnippetLister.getInstance().listDefault(user);
        }
        else if (CUSTOM.equals(mapping.getParameter())) {
            result = CobblerSnippetLister.getInstance().listCustom(user);
        }
        else {
            throw new BadParameterException("Invalid mapping parameter passed!! [" +
                                                    mapping.getParameter() + "]");
        }
    }
    catch (ValidatorException ve) {
        List<ValidatorError> errors = ve.getResult().getErrors();
        errors.add(new ValidatorError("cobbler.snippet.invalidfilename.details",
                CobblerSnippet.getPrefixFor(user.getOrg())));
        getStrutsDelegate().saveMessages(request, errors, ve.getResult().getWarnings());
        RhnValidationHelper.setFailedValidation(request);
    }
    Collections.sort(result, NAME_COMPARATOR);
    request.setAttribute(RequestContext.PAGE_LIST, result);
    request.setAttribute(ListTagHelper.PARENT_URL, request.getRequestURI());
    return mapping.findForward(RhnHelper.DEFAULT_FORWARD);
}
 
Example 4
Source File: CobblerSnippetListSetupAction.java    From spacewalk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ${@inheritDoc}
 */
public ActionForward execute(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {

    request.setAttribute(mapping.getParameter(), Boolean.TRUE);
    RequestContext context = new RequestContext(request);
    User user = context.getCurrentUser();
    List<CobblerSnippet> result = new ArrayList<CobblerSnippet>();
    try {
        if (ALL.equals(mapping.getParameter())) {
            result = CobblerSnippetLister.getInstance().list(user);
        }
        else if (RhnHelper.DEFAULT_FORWARD.equals(mapping.getParameter())) {
            result = CobblerSnippetLister.getInstance().listDefault(user);
        }
        else if (CUSTOM.equals(mapping.getParameter())) {
            result = CobblerSnippetLister.getInstance().listCustom(user);
        }
        else {
            throw new BadParameterException("Invalid mapping parameter passed!! [" +
                                                    mapping.getParameter() + "]");
        }
    }
    catch (ValidatorException ve) {
        List<ValidatorError> errors = ve.getResult().getErrors();
        errors.add(new ValidatorError("cobbler.snippet.invalidfilename.details",
                CobblerSnippet.getPrefixFor(user.getOrg())));
        getStrutsDelegate().saveMessages(request, errors, ve.getResult().getWarnings());
        RhnValidationHelper.setFailedValidation(request);
    }
    Collections.sort(result, NAME_COMPARATOR);
    request.setAttribute(RequestContext.PAGE_LIST, result);
    request.setAttribute(ListTagHelper.PARENT_URL, request.getRequestURI());
    return mapping.findForward(RhnHelper.DEFAULT_FORWARD);
}
 
Example 5
Source File: AdapterHandler.java    From iaf with Apache License 2.0 5 votes vote down vote up
public ActionForward executeSub(
	ActionMapping mapping,
	ActionForm form,
	HttpServletRequest request,
	HttpServletResponse response)
	throws IOException, ServletException {
	String configurationName=null;
	String adapterName=null;
	String receiverName=null;
	// Initialize action
	initAction(request);

	if (null == ibisManager) {
		return (mapping.findForward("noconfig"));
	}
	String action = request.getParameter("action");
	if (null == action)
		action = mapping.getParameter();
		
	configurationName = request.getParameter("configurationName");
	adapterName = request.getParameter("adapterName");
	receiverName = request.getParameter("receiverName");
	log.debug("action ["+action+"] adapterName ["+adapterName+"] receiverName ["+receiverName+"]");

	//commandIssuedBy containes information about the location the
	// command is sent from
	String commandIssuedBy= HttpUtils.getCommandIssuedBy(request);

	ibisManager.handleAdapter(action, configurationName, adapterName, receiverName, commandIssuedBy, isAdmin);

	// Report any errors we have discovered back to the original form
	if (!errors.isEmpty()) {
		saveErrors(request, errors);
	} // Forward control to the specified success URI
	log.debug("forward to success");
	return (mapping.findForward("success"));
}
 
Example 6
Source File: ComOptimizationScheduleForm.java    From openemm with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {

	
	String method = mapping.getParameter() ; // struts-config.xml <action ... parameter ="method">
	String action =	request.getParameter(method);
	
	if("showSchedule".equals(action)) {
		return super.validate(mapping, request);
	}
	
	ActionErrors errors = new ActionErrors();

	DateValidator dateValidator = DateValidator.getInstance();

	if (!dateValidator.isValid(resultSendDateAsString, DATE_PATTERN_FULL)) {
		errors.add( ActionMessages.GLOBAL_MESSAGE,  new ActionMessage("mailing.autooptimization.errors.resultsenddate" , Constants.DATE_PATTERN_FULL));
	}

	if (!dateValidator.isValid(testMailingsSendDateAsString, DATE_PATTERN_FULL)) {
		errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("mailing.autooptimization.errors.resultsenddate" ,Constants.DATE_PATTERN_FULL));
	}

	if (!errors.isEmpty()) { // something is wrong with the supplied 'dates' , it doesn't make sense to parse dates from them.
		return errors;
	}

	Date testmailingsSenddate = null;
	Date resultSenddate = null;
	try {
		testmailingsSenddate = DateUtil.parseFullDate(testMailingsSendDateAsString);
		resultSenddate = DateUtil.parseFullDate(resultSendDateAsString);
	} catch (ParseException e) {
		logger.error("Error occured: " + e.getMessage(), e);
	}
		
	Date now = new Date();

	if (resultSenddate == null) {
		throw new RuntimeException("resultSenddate was null");
	}
	
	if (!resultSenddate.after(testmailingsSenddate)) {
		errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(
				"mailing.autooptimization.errors.result_is_not_after_test"));
	}

	if (now.after(resultSenddate)) {
		errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(
				"mailing.autooptimization.errors.resultsenddate_is_not_in_future"));
	}

	if (now.after(testmailingsSenddate)) {
		errors
				.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(
				"mailing.autooptimization.errors.testmailingssenddate_is_not_infuture"));
	}
	return errors;
}