org.apache.struts.action.DynaActionForm Java Examples

The following examples show how to use org.apache.struts.action.DynaActionForm. 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: OrgDetailsActionTest.java    From uyuni with GNU General Public License v2.0 6 votes vote down vote up
public void testExecute() throws Exception {
    user.getOrg().addRole(RoleFactory.SAT_ADMIN);
    user.addPermanentRole(RoleFactory.SAT_ADMIN);
    addRequestParameter("oid", user.getOrg().getId().toString());
    setRequestPathInfo("/admin/multiorg/OrgDetails");
    actionPerform();
    DynaActionForm form = (DynaActionForm) getActionForm();
    assertNotNull(form.get("orgName"));
    assertNotNull(form.get("id"));
    assertNotNull(form.get("users"));
    assertNotNull(form.get("systems"));
    assertNotNull(form.get("actkeys"));
    assertNotNull(form.get("ksprofiles"));
    assertNotNull(form.get("groups"));
    assertNotNull(form.get("cfgchannels"));

}
 
Example #2
Source File: CurricularCourseEquivalenciesDA.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    final DynaActionForm actionForm = (DynaActionForm) form;

    final String degreeCurricularPlanIDString = (String) actionForm.get("degreeCurricularPlanID");
    final String curricularCourseIDString = (String) actionForm.get("curricularCourseID");
    final String oldCurricularCourseIDString = (String) actionForm.get("oldCurricularCourseID");
    if (isValidObjectID(degreeCurricularPlanIDString) && isValidObjectID(curricularCourseIDString)
            && isValidObjectID(oldCurricularCourseIDString)) {

        try {
            CreateCurricularCourseEquivalency.run(degreeCurricularPlanIDString, curricularCourseIDString,
                    oldCurricularCourseIDString);
        } catch (DomainException e) {
            addActionMessage(request, e.getMessage());
        }
    }

    return prepare(mapping, form, request, response);
}
 
Example #3
Source File: ChannelOverviewAction.java    From uyuni with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create the init.sls file for channel
 * @param request the incoming request
 * @param channel the channel to be affected
 * @param form the form to be filled in
 */
private void createInitSlsFile(ConfigChannel channel,
                                 HttpServletRequest request, DynaActionForm form) {
    if (channel.isStateChannel()) {
        channel = (ConfigChannel) HibernateFactory.reload(channel);
        ConfigFileData data = new SLSFileData(StringUtil.webToLinux(
                                form.getString(ConfigFileForm.REV_CONTENTS)));
        try {
            RequestContext ctx = new RequestContext(request);
            ConfigFileBuilder.getInstance().create(data, ctx.getCurrentUser(), channel);
        }
        catch (ValidatorException ve) {
            getStrutsDelegate().saveMessages(request, ve.getResult());
        }
        catch (Exception e) {
            LOG.error("Error creating init.sls file ", e);
        }
    }
}
 
Example #4
Source File: StrutsDelegate.java    From uyuni with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a date picker object with the given name and prepopulates the date
 * with values from the given request's parameters. Prepopulates the form with
 * these values as well.
 * Your dyna action picker must either be a struts datePickerForm, or
 * possess all of datePickerForm's fields.
 * @param request The request from which to get initial form field values.
 * @param form The datePickerForm
 * @param name The prefix for the date picker form fields, usually "date"
 * @param yearDirection One of DatePicker's year range static variables.
 * @return The created and prepopulated date picker object
 * @see com.redhat.rhn.common.util.DatePicker
 */
public DatePicker prepopulateDatePicker(HttpServletRequest request, DynaActionForm form,
        String name, int yearDirection) {
    //Create the date picker.
    DatePicker p = getDatePicker(name, yearDirection);

    //prepopulate the date for this picker
    p.readMap(request.getParameterMap());

    //prepopulate the form for this picker
    p.writeToForm(form);
    if (!StringUtils.isEmpty(request.getParameter(DatePicker.USE_DATE))) {
        Boolean preset = Boolean.valueOf(request.getParameter(DatePicker.USE_DATE));
        form.set(DatePicker.USE_DATE, preset);
    }
    else if (form.getMap().containsKey(DatePicker.USE_DATE)) {
        form.set(DatePicker.USE_DATE, Boolean.FALSE);
    }
    request.setAttribute(name, p);
    //give back the date picker
    return p;
}
 
Example #5
Source File: ShowMonitors.java    From iaf with Apache License 2.0 6 votes vote down vote up
public void initForm(DynaActionForm monitorForm) {
	MonitorManager mm = MonitorManager.getInstance();

	monitorForm.set("monitorManager",mm);
	List destinations=new ArrayList();
	for (int i=0;i<mm.getMonitors().size();i++) {
		Monitor m=mm.getMonitor(i);
		Set d=m.getDestinationSet();
		for (Iterator it=d.iterator();it.hasNext();) {
			destinations.add(i+","+it.next());				
		}
	}
	String[] selDest=new String[destinations.size()];
	selDest=(String[])destinations.toArray(selDest);
	monitorForm.set("selDestinations",selDest);
	monitorForm.set("enabled",new Boolean(mm.isEnabled()));
	monitorForm.set("eventTypes",EventTypeEnum.getEnumList());
	monitorForm.set("severities",SeverityEnum.getEnumList());
}
 
Example #6
Source File: ExecutionCourseBibliographyDA.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
public ActionForward createBibliographicReference(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    final DynaActionForm dynaActionForm = (DynaActionForm) form;
    final String title = dynaActionForm.getString("title");
    final String authors = dynaActionForm.getString("authors");
    final String reference = dynaActionForm.getString("reference");
    final String year = dynaActionForm.getString("year");
    final String optional = dynaActionForm.getString("optional");

    final ExecutionCourse executionCourse = (ExecutionCourse) request.getAttribute("executionCourse");

    CreateBibliographicReference.runCreateBibliographicReference(executionCourse.getExternalId(), title, authors, reference,
            year, Boolean.valueOf(optional));

    return forward(request, "/teacher/executionCourse/bibliographicReference.jsp");
}
 
Example #7
Source File: CoordinationTeamDispatchAction.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
public ActionForward removeCoordinators(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws FenixActionException, FenixServiceException {
    DynaActionForm removeCoordinatorsForm = (DynaActionForm) form;
    String[] coordinatorsIds = (String[]) removeCoordinatorsForm.get("coordinatorsIds");
    List<String> coordinators = Arrays.asList(coordinatorsIds);

    String infoExecutionDegreeIdString = request.getParameter("infoExecutionDegreeId");
    request.setAttribute("infoExecutionDegreeId", infoExecutionDegreeIdString);
    try {
        RemoveCoordinators.runRemoveCoordinators(infoExecutionDegreeIdString, coordinators);
    } catch (FenixServiceException e) {
        throw new FenixActionException(e);
    }

    return viewTeam(mapping, form, request, response);
}
 
Example #8
Source File: EditExecutionCourseDispatchAction.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
private InfoExecutionCourseEditor fillInfoExecutionCourseFromForm(ActionForm actionForm, HttpServletRequest request) {

        InfoExecutionCourseEditor infoExecutionCourse = new InfoExecutionCourseEditor();

        DynaActionForm editExecutionCourseForm = (DynaActionForm) actionForm;

        try {
            infoExecutionCourse.setExternalId((String) editExecutionCourseForm.get("executionCourseId"));
            infoExecutionCourse.setNome((String) editExecutionCourseForm.get("name"));
            infoExecutionCourse.setSigla((String) editExecutionCourseForm.get("code"));
            infoExecutionCourse.setComment((String) editExecutionCourseForm.get("comment"));
            infoExecutionCourse.setAvailableGradeSubmission(Boolean.valueOf(editExecutionCourseForm
                    .getString("availableGradeSubmission")));
            infoExecutionCourse.setEntryPhase(EntryPhase.valueOf(editExecutionCourseForm.getString("entryPhase")));

        } catch (Exception e) {
            logger.error(e.getMessage(), e);
        }

        return infoExecutionCourse;
    }
 
Example #9
Source File: SsmScheduleXccdfAction.java    From spacewalk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public ActionForward execute(ActionMapping mapping,
        ActionForm formIn,
        HttpServletRequest request,
        HttpServletResponse response) {
    DynaActionForm form = (DynaActionForm) formIn;

    if (isSubmitted(form)) {
        ActionErrors errors = RhnValidationHelper.validateDynaActionForm(this, form);
        if (errors.isEmpty()) {
            return getStrutsDelegate().forwardParams(mapping.findForward("submit"),
                    request.getParameterMap());
        }
        getStrutsDelegate().saveMessages(request, errors);
    }
    setupDatePicker(request, form);
    setupListHelper(request);
    return getStrutsDelegate().forwardParams(
        mapping.findForward(RhnHelper.DEFAULT_FORWARD),
        request.getParameterMap());
}
 
Example #10
Source File: ProvisionVirtualizationWizardAction.java    From uyuni with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected ProvisionVirtualInstanceCommand getScheduleCommand(DynaActionForm form,
        RequestContext ctx, Date scheduleTime, String host) {
    Profile cobblerProfile = getCobblerProfile(ctx);
    User user = ctx.getCurrentUser();
    ProvisionVirtualInstanceCommand cmd;
    KickstartData data = KickstartFactory.
            lookupKickstartDataByCobblerIdAndOrg(user.getOrg(), cobblerProfile.getId());

    if (data != null) {
        cmd =
                new ProvisionVirtualInstanceCommand(
                        (Long) form.get(RequestContext.SID),
                        data,
                        ctx.getCurrentUser(),
                        scheduleTime,
                        host);
    }
    else {
        cmd = ProvisionVirtualInstanceCommand.createCobblerScheduleCommand((Long)
                form.get(RequestContext.SID), cobblerProfile.getName(),
                user, scheduleTime,  host);
    }
    return cmd;
}
 
Example #11
Source File: DeleteProfileAction.java    From spacewalk with GNU General Public License v2.0 6 votes vote down vote up
private ActionMessages processForm(Profile profile, DynaActionForm f) {

        if (log.isDebugEnabled()) {
            log.debug("Processing form.");
        }

        ActionMessages msgs = new ActionMessages();

        int numDeleted = ProfileManager.deleteProfile(profile);
        if (numDeleted > 0) {
            msgs.add(ActionMessages.GLOBAL_MESSAGE,
                    new ActionMessage("deleteconfirm.jsp.profiledeleted",
                            profile.getName()));
        }

        return msgs;
    }
 
Example #12
Source File: ScheduleKickstartWizardAction.java    From spacewalk with GNU General Public License v2.0 6 votes vote down vote up
protected boolean validateFirstSelections(DynaActionForm form,
        RequestContext ctx) {
    String cobblerId = ListTagHelper.getRadioSelection(ListHelper.LIST,
            ctx.getRequest());
    if (StringUtils.isBlank(cobblerId)) {
        cobblerId = ctx.getParam(RequestContext.COBBLER_ID, true);
    }

    boolean retval = false;
    form.set(RequestContext.COBBLER_ID, cobblerId);
    ctx.getRequest().setAttribute(RequestContext.COBBLER_ID, cobblerId);
    if (form.get("scheduleAsap") != null) {
        retval = true;
    }
    else if (form.get(RequestContext.COBBLER_ID) != null) {
        return true;
    }
    return retval;
}
 
Example #13
Source File: ScheduleKickstartWizardAction.java    From spacewalk with GNU General Public License v2.0 6 votes vote down vote up
private void setupNetworkInfo(DynaActionForm form, RequestContext context,
        KickstartScheduleCommand cmd) {
    Server server = cmd.getServer();
    List<NetworkInterface> nics = getPublicNetworkInterfaces(server);

    if (nics.isEmpty()) {
        return;
    }

    context.getRequest().setAttribute(NETWORK_INTERFACES, nics);

    if (StringUtils.isBlank(form.getString(NETWORK_INTERFACE))) {
        String defaultInterface = ConfigDefaults.get().
                getDefaultKickstartNetworkInterface();
        for (NetworkInterface nic : nics) {
            if (nic.getName().equals(defaultInterface)) {
                form.set(NETWORK_INTERFACE, ConfigDefaults.get().
                        getDefaultKickstartNetworkInterface());
            }
        }
        if (StringUtils.isBlank(form.getString(NETWORK_INTERFACE))) {
            form.set(NETWORK_INTERFACE, server.
                    findPrimaryNetworkInterface().getName());
        }
    }
}
 
Example #14
Source File: ExecuteJdbcQueryExecute.java    From iaf with Apache License 2.0 6 votes vote down vote up
public void StoreFormData(String query, String result, DynaActionForm executeJdbcQueryExecuteForm) {
	List jmsRealms = JmsRealmFactory.getInstance().getRegisteredRealmNamesAsList();
	if (jmsRealms.size() == 0)
		jmsRealms.add("no realms defined");
	executeJdbcQueryExecuteForm.set("jmsRealms", jmsRealms);
	List queryTypes = new ArrayList();
	queryTypes.add("select");
	queryTypes.add("other");
	executeJdbcQueryExecuteForm.set("queryTypes", queryTypes);

	List resultTypes = new ArrayList();
	resultTypes.add("csv");
	resultTypes.add("xml");
	executeJdbcQueryExecuteForm.set("resultTypes", resultTypes);
	if (null != query)
		executeJdbcQueryExecuteForm.set("query", query);
	if (null != result) {
		executeJdbcQueryExecuteForm.set("result", result);

	}
}
 
Example #15
Source File: OrgDetailsAction.java    From uyuni with GNU General Public License v2.0 6 votes vote down vote up
/**
 *
 * @param request coming in
 * @param form to validate against
 * @param oid ID of Org we're operating on
 * @param currOrg Org object for oid
 * @return if it passed
 */
private boolean validateForm(HttpServletRequest request, DynaActionForm form,
                Long oid, Org currOrg) {
    boolean retval = true;

    String orgName = form.getString("orgName");
    RequestContext requestContext = new RequestContext(request);

    if (currOrg.getName().equals(orgName)) {
        getStrutsDelegate().saveMessage("message.org_name_not_updated",
                new String[] {"orgName"}, request);
        retval = false;
    }
    else {
        try {
            OrgManager.checkOrgName(orgName);
        }
        catch (ValidatorException ve) {
            getStrutsDelegate().saveMessages(request, ve.getResult());
            retval = false;
        }
    }
    return retval;
}
 
Example #16
Source File: EnableSubmitAction.java    From spacewalk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Enables the selected set of systems for configuration management
 * @param mapping struts ActionMapping
 * @param formIn struts ActionForm
 * @param request HttpServletRequest
 * @param response HttpServletResponse
 * @return forward to the summary page.
 */
public ActionForward enable(ActionMapping mapping,
        ActionForm formIn,
        HttpServletRequest request,
        HttpServletResponse response) {
    User user = new RequestContext(request).getCurrentUser();
    RhnSetDecl set = RhnSetDecl.SYSTEMS;

    //get the earliest schedule for package install actions.
    DynaActionForm form = (DynaActionForm) formIn;
    Date earliest = getStrutsDelegate().readDatePicker(form, "date",
            DatePicker.YEAR_RANGE_POSITIVE);
    try {
        ConfigurationManager.getInstance().enableSystems(set, user, earliest);
    }
    catch (MultipleChannelsWithPackageException e) {
        ValidatorError verrors = new ValidatorError("config.multiple.channels");
        ActionErrors errors = RhnValidationHelper.validatorErrorToActionErrors(verrors);
        getStrutsDelegate().saveMessages(request, errors);
        return mapping.findForward("default");
    }

    return mapping.findForward("summary");
}
 
Example #17
Source File: AddClassesDA.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
public ActionForward add(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws Exception {

    InfoShift infoShift = (InfoShift) request.getAttribute(PresentationConstants.SHIFT);

    DynaActionForm addClassesForm = (DynaActionForm) form;
    String[] selectedClasses = (String[]) addClassesForm.get("selectedItems");

    List classOIDs = new ArrayList();
    for (String selectedClasse : selectedClasses) {
        classOIDs.add(selectedClasse);
    }

    try {
        AddSchoolClassesToShift.run(infoShift, classOIDs);
    } catch (FenixServiceException ex) {
        // No probem, the user refreshed the page after adding classes
        request.setAttribute("selectMultipleItemsForm", null);
        return mapping.getInputForward();
    }

    request.setAttribute("selectMultipleItemsForm", null);

    return mapping.findForward("BackToEditShift");
}
 
Example #18
Source File: AdvancedModeDetailsAction.java    From spacewalk with GNU General Public License v2.0 6 votes vote down vote up
private void loadVirtualizationTypes(KickstartWizardHelper cmd, DynaActionForm form,
        RequestContext context) {

    List<KickstartVirtualizationType> types = cmd.getVirtualizationTypes();
    form.set(VIRTUALIZATION_TYPES_PARAM, types);

    if (isCreateMode(context.getRequest())) {
        form.set(VIRTUALIZATION_TYPE_LABEL_PARAM,
                KickstartVirtualizationType.NONE);
    }
    else {
        KickstartRawData data = getKsData(context);
        form.set(VIRTUALIZATION_TYPE_LABEL_PARAM, data.getKickstartDefaults().
                getVirtualizationType().getLabel());
    }
}
 
Example #19
Source File: BaseRankChannels.java    From uyuni with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets up the rangling widget.
 * @param context the request context of the current request
 * @param form the dynaform  related to the current request.
 * @param set the rhnset holding the channel ids.
 */
protected void setupWidget(RequestContext context,
                                 DynaActionForm form,
                                 RhnSet set) {
    User user = context.getCurrentUser();
    LinkedHashSet labelValues = new LinkedHashSet();
    populateWidgetLabels(labelValues, context);
    for (Iterator itr = set.getElements().iterator(); itr.hasNext();) {
        Long ccid = ((RhnSetElement) itr.next()).getElement();
        ConfigChannel channel = ConfigurationManager.getInstance()
                                    .lookupConfigChannel(user, ccid);
        String optionstr = channel.getName() + " (" + channel.getLabel() + ")";
        labelValues.add(lv(optionstr, channel.getId().toString()));
    }

    //set the form variables for the widget to read.
    form.set(POSSIBLE_CHANNELS, labelValues);
    if (!labelValues.isEmpty()) {
        if (form.get(SELECTED_CHANNEL) == null) {
            String selected = ((LabelValueBean)labelValues.iterator().next())
                                                    .getValue();
            form.set(SELECTED_CHANNEL, selected);
        }
    }
}
 
Example #20
Source File: EditSlaveSetupAction.java    From uyuni with GNU General Public License v2.0 6 votes vote down vote up
private void setupFormValues(HttpServletRequest request,
        DynaActionForm daForm) {

    RequestContext requestContext = new RequestContext(request);
    Long sid = requestContext.getParamAsLong(IssSlave.SID);

    if (sid == null) { // Creating new
        daForm.set(IssSlave.ID, IssSlave.NEW_SLAVE_ID);
        daForm.set(IssSlave.ENABLED, true);
        daForm.set(IssSlave.ALLOWED_ALL_ORGS, true);
    }
    else {
        IssSlave slave = IssFactory.lookupSlaveById(sid);

        daForm.set(IssSlave.ID, sid);
        daForm.set(IssSlave.SLAVE, slave.getSlave());
        daForm.set(IssSlave.ENABLED, "Y".equals(slave.getEnabled()));
        daForm.set(IssSlave.ALLOWED_ALL_ORGS, "Y".equals(slave.getAllowAllOrgs()));

        request.setAttribute(IssSlave.SID, sid);
    }
}
 
Example #21
Source File: RepoDetailsAction.java    From uyuni with GNU General Public License v2.0 5 votes vote down vote up
private void setup(HttpServletRequest request, DynaActionForm form,
        boolean createMode) {
    RequestContext context = new RequestContext(request);
    setupContentTypes(context);
    setupCryptoKeys(context);
    if (!createMode) {
        request.setAttribute("id", context.getParamAsLong("id"));
        setupRepo(request, form, ChannelFactory.lookupContentSource(
                context.getParamAsLong("id"), context.getCurrentUser().getOrg()));
    }
}
 
Example #22
Source File: RhnLookupDispatchAction.java    From spacewalk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Simple util to check if the Form was submitted
 * @param form to check
 * @return if or not it was submitted.
 */
protected boolean isSubmitted(DynaActionForm form) {
    if (form != null) {
        try {
            return BooleanUtils.toBoolean((Boolean)form.get(SUBMITTED));
        }
        catch (IllegalArgumentException iae) {
            throw new IllegalArgumentException("Your form-bean failed to define '" +
                    SUBMITTED + "'");
        }
    }
    return false;
}
 
Example #23
Source File: SystemDetailsEditAction.java    From spacewalk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets up the form bean for viewing
 * @param mapping Struts action mapping
 * @param dynaForm related form instance
 * @param request related request
 * @param response related response
 * @return jsp to render
 * @throws Exception when error occurs - this should be handled by the app
 * framework
 */
public ActionForward viewSystemDetails(ActionMapping mapping,
        DynaActionForm dynaForm, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    RequestContext ctx = new RequestContext(request);
    KickstartData ksdata = lookupKickstart(ctx, dynaForm);
    prepareForm(dynaForm, ksdata, ctx);
    request.setAttribute(RequestContext.KICKSTART, ksdata);
    return mapping.findForward("display");
}
 
Example #24
Source File: SystemDetailsEditAction.java    From spacewalk with GNU General Public License v2.0 5 votes vote down vote up
private void transferRootPasswordEdits(DynaActionForm form,
        SystemDetailsCommand command) {
    String rootPw = form.getString("rootPassword");
    String rootPwConfirm = form.getString("rootPasswordConfirm");
    if (!StringUtils.isBlank(rootPw) || !StringUtils.isBlank(rootPwConfirm)) {
        command.updateRootPassword(rootPw, rootPwConfirm);
    }
}
 
Example #25
Source File: KickstartScriptEditAction.java    From spacewalk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected void setupFormValues(RequestContext ctx, DynaActionForm form,
        BaseKickstartCommand cmd) {
    super.setupFormValues(ctx, form, cmd);
    ctx.getRequest().setAttribute(RequestContext.KICKSTART_SCRIPT_ID,
            ctx.getRequiredParam(RequestContext.KICKSTART_SCRIPT_ID));
}
 
Example #26
Source File: DocSearchSetupAction.java    From uyuni with GNU General Public License v2.0 5 votes vote down vote up
protected ActionForward doExecute(HttpServletRequest request, ActionMapping mapping,
                DynaActionForm form)
    throws MalformedURLException, XmlRpcFault {

    RequestContext ctx = new RequestContext(request);
    String searchString = form.getString(SEARCH_STR);
    String viewmode = form.getString(VIEW_MODE);

    List<Map<String, String>> searchOptions = new ArrayList<Map<String, String>>();
    addOption(searchOptions, "docsearch.content_title", OPT_CONTENT_TITLE);
    addOption(searchOptions, "docsearch.free_form", OPT_FREE_FORM);
    addOption(searchOptions, "docsearch.content", OPT_CONTENT_ONLY);
    addOption(searchOptions, "docsearch.title", OPT_TITLE_ONLY);

    request.setAttribute(SEARCH_STR, searchString);
    request.setAttribute(VIEW_MODE, viewmode);
    request.setAttribute(SEARCH_OPT, searchOptions);


    if (!StringUtils.isBlank(searchString)) {
        List results = performSearch(ctx.getWebSession().getId(),
                                     searchString,
                                     viewmode, request);
        log.debug("GET search: " + results);
        request.setAttribute(RequestContext.PAGE_LIST,
                results != null ? results : Collections.emptyList());
    }
    else {
        request.setAttribute(RequestContext.PAGE_LIST, Collections.emptyList());
    }
    return mapping.findForward(RhnHelper.DEFAULT_FORWARD);
}
 
Example #27
Source File: EditMonitor.java    From iaf with Apache License 2.0 5 votes vote down vote up
protected String performAction(DynaActionForm monitorForm, String action, int index, int triggerIndex, HttpServletResponse response) {
	MonitorManager mm = MonitorManager.getInstance();

	if (index>=0) {
		Monitor monitor = mm.getMonitor(index);
		monitorForm.set("monitor",monitor);
	}
	
	return null;
}
 
Example #28
Source File: KickstartFileDownloadAction.java    From spacewalk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected void setupFormValues(RequestContext ctx,
        DynaActionForm form, BaseKickstartCommand cmdIn) {
    HttpServletRequest request = ctx.getRequest();
    KickstartFileDownloadCommand cmd = (KickstartFileDownloadCommand) cmdIn;
    KickstartData data = cmd.getKickstartData();
    KickstartHelper helper = new KickstartHelper(request);


    /*
     * To generate the file data, our kickstart channel must have at least
     * a minimum list of packages. Verify that those are there before even
     * trying to render the file. However, the auto-kickstart packages are
     * not needed.
     */
    if (helper.verifyKickstartChannel(
                cmdIn.getKickstartData(), ctx.getCurrentUser(), false)) {
        try {
            request.setAttribute(FILEDATA, StringEscapeUtils.escapeHtml(
                    KickstartManager.getInstance().renderKickstart(data)));
            request.setAttribute(KSURL, KickstartUrlHelper.getCobblerProfileUrl(data));
        }
        catch (DownloadException de) {
            request.setAttribute(FILEERROR,
                            StringEscapeUtils.escapeHtml(de.getContent()));
            createErrorMessage(request, "kickstart.jsp.error.template_message", null);
        }
    }
    else {
        request.setAttribute(INVALID_CHANNEL, "true");
    }
}
 
Example #29
Source File: EditGroupAction.java    From uyuni with GNU General Public License v2.0 5 votes vote down vote up
private void edit(DynaActionForm form, ActionErrors errors,
        RequestContext ctx) {

    validate(form, errors, ctx);

    if (errors.isEmpty()) {
        ManagedServerGroup sg = ctx.lookupAndBindServerGroup();
        sg.setName(form.getString("name"));
        sg.setDescription(form.getString("description"));
        ServerGroupFactory.save(sg);
    }
}
 
Example #30
Source File: RebootSystemConfirmAction.java    From spacewalk with GNU General Public License v2.0 5 votes vote down vote up
private ActionForward handleDispatch(
        ActionMapping mapping,
        DynaActionForm formIn,
        HttpServletRequest request) {

    RequestContext context = new RequestContext(request);
    User user = context.getCurrentUser();
    RhnSet set = getSetDecl().get(user);

    Date earliest = getStrutsDelegate().readDatePicker(formIn,
            "date", DatePicker.YEAR_RANGE_POSITIVE);
    ActionChain actionChain = ActionChainHelper.readActionChain(formIn, user);

    MessageQueue.publish(new SsmSystemRebootEvent(user.getId(), earliest, actionChain,
        set.getElementValues()));

    int n = set.size();

    String messageKeySuffix = n == 1 ? "singular" : "plural";
    LocalizationService ls = LocalizationService.getInstance();

    if (actionChain == null) {
        createMessage(request, "ssm.misc.reboot.message.success." + messageKeySuffix,
                new String[] {ls.formatNumber(n, request.getLocale()),
                        ls.formatDate(earliest, request.getLocale())});
    }
    else {
        createMessage(request, "ssm.misc.reboot.message.queued." + messageKeySuffix,
                new String[] {ls.formatNumber(n, request.getLocale()),
                        actionChain.getId().toString(), actionChain.getLabel()});
    }

    set.clear();
    RhnSetManager.store(set);

    return mapping.findForward(RhnHelper.CONFIRM_FORWARD);
}