Java Code Examples for org.apache.struts.action.DynaActionForm#set()

The following examples show how to use org.apache.struts.action.DynaActionForm#set() . 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: VariablesAction.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) {
    RequestContext ctx = new RequestContext(request);
    Server server = ctx.lookupAndBindServer();
    User user = ctx.getCurrentUser();
    SdcHelper.ssmCheck(ctx.getRequest(), server.getId(), user);
    DynaActionForm form = (DynaActionForm)formIn;
    SystemRecord rec = (SystemRecord)
                    getCobblerObject(server.getCobblerId(), user);
    if (isSubmitted(form)) {
        if (!Boolean.valueOf(rec.isNetbootEnabled()).
                                equals(form.get(NETBOOT_ENABLED))) {
            rec.enableNetboot(Boolean.TRUE.equals(form.get(NETBOOT_ENABLED)));
            rec.save();
        }

    }
    form.set(NETBOOT_ENABLED, rec.isNetbootEnabled());
    return super.execute(mapping, formIn, request, response);
}
 
Example 2
Source File: UserLocalePrefAction.java    From spacewalk with GNU General Public License v2.0 6 votes vote down vote up
private ActionForward display(ActionMapping mapping, RequestContext ctx,
        User currentUser, DynaActionForm form) {
    ctx.getRequest().setAttribute("targetuser", currentUser);
    ctx.getRequest().setAttribute("supportedLocales", buildImageMap());
    ctx.getRequest().setAttribute("noLocale", buildNoneLocale());
    setCurrentLocale(ctx, currentUser);
    ctx.getRequest().setAttribute("timezones", getTimeZones());
    if (currentUser.getTimeZone() != null) {
        form.set("timezone",
                new Integer(currentUser.getTimeZone().getTimeZoneId()));
    }
    else {
        form.set("timezone", new Integer(UserManager.getDefaultTimeZone()
                .getTimeZoneId()));
    }
    form.set("uid", currentUser.getId());

    return mapping.findForward(RhnHelper.DEFAULT_FORWARD);
}
 
Example 3
Source File: ScheduleKickstartWizardAction.java    From uyuni 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 4
Source File: SystemNoteDeleteAction.java    From uyuni with GNU General Public License v2.0 6 votes vote down vote up
protected void setupPageAndFormValues(HttpServletRequest request,
        DynaActionForm daForm, Server s, Note n) {

    request.setAttribute("system", s);
    request.setAttribute("n", n);
    request.setAttribute("id", n.getId());
    request.setAttribute("server_id", s.getId());
    request.setAttribute("subject", n.getSubject());
    request.setAttribute("note", n.getNote());

    request.setAttribute("sid", s.getId());

    daForm.set("sid", s.getId());
    daForm.set("subject", n.getSubject());
    daForm.set("note", n.getNote());
}
 
Example 5
Source File: AdvancedModeDetailsAction.java    From spacewalk with GNU General Public License v2.0 5 votes vote down vote up
private void loadTrees(KickstartWizardHelper cmd, DynaActionForm form,
        RequestContext context) {

    List<KickstartableTree> trees = cmd.getKickstartableTrees();
    if (trees == null || trees.size() == 0) {
        context.getRequest().setAttribute(NOTREES_PARAM, Boolean.TRUE);
        form.set(KSTREE_ID_PARAM, null);
    }
    else {
        form.set(KSTREES_PARAM, trees);

        if (isCreateMode(context.getRequest())) {
            form.set(KSTREE_ID_PARAM, null);
        }
        else {
            KickstartRawData data = getKsData(context);
            KickstartableTree tree = data.getTree();
            if (tree == null) {
                form.set(KSTREE_ID_PARAM, null);
            }
            else {
                form.set(KSTREE_ID_PARAM, tree.getId());
            }
            KickstartTreeUpdateType updateType = data.getRealUpdateType();
            if (updateType.equals(KickstartTreeUpdateType.ALL)) {
                context.getRequest().setAttribute(USING_UPDATE_ALL, "true");
            }
            else if (updateType.equals(KickstartTreeUpdateType.RED_HAT)) {
                context.getRequest().setAttribute(USING_UPDATE_RED_HAT, "true");
            }
        }
    }
}
 
Example 6
Source File: CurriculumDispatchAction.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
private ActionForward getStudentCP(final Registration registration, final ActionMapping mapping, DynaActionForm actionForm,
        final HttpServletRequest request) {
    request.setAttribute("registration", registration);

    String studentCPID = getStudentCPID(request, actionForm);
    if (StringUtils.isEmpty(studentCPID)) {
        studentCPID = getDefaultStudentCPID(registration).getId().toString();
        actionForm.set("studentCPID", studentCPID);
    }
    request.setAttribute("selectedStudentCurricularPlans", getSelectedStudentCurricularPlans(registration, studentCPID));
    request.setAttribute("scpsLabelValueBeanList", getSCPsLabelValueBeanList(registration.getStudentCurricularPlansSet()));

    if (StringUtils.isEmpty(actionForm.getString("viewType"))) {
        actionForm.set("viewType", ViewType.ALL.name());
    }

    if (StringUtils.isEmpty(actionForm.getString("select"))) {
        actionForm
                .set("select",
                        AcademicPredicates.VIEW_FULL_STUDENT_CURRICULUM.evaluate(AccessControl.getPerson()) ? EnrolmentStateFilterType.ALL
                                .name() : EnrolmentStateFilterType.APPROVED_OR_ENROLED.name());
    }

    if (StringUtils.isEmpty(actionForm.getString("organizedBy"))) {
        String organizedBy =
                registration.getDegreeType().isPreBolonhaMasterDegree() ? OrganizationType.EXECUTION_YEARS.name() : OrganizationType.GROUPS
                        .name();
        actionForm.set("organizedBy", organizedBy);
    }

    computeCurricularInfo(request, registration);

    if (StringUtils.isEmpty(request.getParameter("degreeCurricularPlanID"))) {
        return mapping.findForward("ShowStudentCurriculum");
    } else {
        request.setAttribute("degreeCurricularPlanID", request.getParameter("degreeCurricularPlanID"));
        return mapping.findForward("ShowStudentCurriculumForCoordinator");
    }
}
 
Example 7
Source File: ScheduleDetailAction.java    From uyuni with GNU General Public License v2.0 5 votes vote down vote up
private void setupForm(HttpServletRequest request, DynaActionForm form) {
    RequestContext ctx = new RequestContext(request);
    User loggedInUser = ctx.getCurrentUser();
    Long schid = ctx.getParamAsLong("schid");

    if (schid != null) {
        try {
            TaskomaticApi tapi = new TaskomaticApi();
            Map schedule = tapi.lookupScheduleById(loggedInUser, schid);
            String scheduleName = (String) schedule.get("job_label");
            String bunchName = (String) schedule.get("bunch");
            request.setAttribute("schedulename", scheduleName);
            form.set("schedulename", scheduleName);
            request.setAttribute("bunch", bunchName);
            Map bunch = tapi.lookupBunchByName(loggedInUser, bunchName);
            request.setAttribute("bunchdescription", bunch.get("description"));
            RecurringEventPicker.prepopulatePicker(request, "date",
                    (String) schedule.get(("cron_expr")));
        }
        catch (TaskomaticApiException e) {
            createErrorMessage(request,
                    "repos.jsp.message.taskomaticdown", null);
        }
    }
    else {
        RecurringEventPicker.prepopulatePicker(request, "date", null);
    }
}
 
Example 8
Source File: KickstartIpRangeAction.java    From uyuni with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param form DynaActionForm
 */
private void setupFormValues(DynaActionForm form) {
    form.set(OCTET1A, 0L);
    form.set(OCTET1B, 0L);
    form.set(OCTET1C, 0L);
    form.set(OCTET1D, 0L);
    form.set(OCTET2A, 0L);
    form.set(OCTET2B, 0L);
    form.set(OCTET2C, 0L);
    form.set(OCTET2D, 0L);
}
 
Example 9
Source File: ShiftStudentEnrollmentManagerDispatchAction.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
private ActionForward prepareSelectCoursesInformation(ActionMapping mapping, ActionForm actionForm,
        HttpServletRequest request, final Registration registration, final ExecutionSemester executionSemester) {

    final DynaActionForm form = (DynaActionForm) actionForm;

    final List<ExecutionDegree> executionDegrees =
            executionSemester.getExecutionYear().getExecutionDegreesFor(DegreeType::isPreBolonhaDegree);
    executionDegrees.addAll(executionSemester.getExecutionYear().getExecutionDegreesFor(DegreeType::isBolonhaDegree));
    executionDegrees
            .addAll(executionSemester.getExecutionYear().getExecutionDegreesFor(DegreeType::isIntegratedMasterDegree));
    executionDegrees.addAll(executionSemester.getExecutionYear().getExecutionDegreesFor(DegreeType::isBolonhaMasterDegree));

    if (executionDegrees.isEmpty()) {
        addActionMessage(request, "errors.impossible.operation");
        return mapping.getInputForward();
    }

    final ExecutionDegree selectedExecutionDegree =
            getSelectedExecutionDegree(form, registration, executionSemester, executionDegrees);
    if (selectedExecutionDegree == null) {
        addActionMessage(request, "errors.impossible.operation");
        return mapping.getInputForward();
    }

    request.setAttribute("selectedExecutionDegree", selectedExecutionDegree);
    form.set("degree", selectedExecutionDegree.getExternalId());

    sortExecutionDegreesByDegreeName(executionDegrees);
    request.setAttribute("executionDegrees", ExecutionDegreesFormat.buildLabelValueBeansForExecutionDegree(executionDegrees));

    request.setAttribute("attendingExecutionCourses", registration.getAttendingExecutionCoursesFor(executionSemester));
    request.setAttribute("executionCoursesFromExecutionDegree", selectedExecutionDegree.getDegreeCurricularPlan()
            .getExecutionCoursesByExecutionPeriod(executionSemester));

    return mapping.findForward("selectCourses");
}
 
Example 10
Source File: CobblerSnippetDetailsAction.java    From spacewalk with GNU General Public License v2.0 5 votes vote down vote up
private void setupSnippet(HttpServletRequest request, DynaActionForm form,
        CobblerSnippet snip) {
    request.setAttribute(PREFIX, snip.getPrefix());
    form.set(NAME, snip.getName());
    form.set(OLD_NAME, snip.getName());
    form.set(CONTENTS, snip.getContents());
    bindSnippet(request, snip);
    request.setAttribute(ORG, snip.getOrg().getName());
}
 
Example 11
Source File: KickstartDetailsEditAction.java    From uyuni with GNU General Public License v2.0 5 votes vote down vote up
private static void setFormValueOrDefault(DynaActionForm form, String key,
                                        Object value, Object defaultValue) {
    if (value == null || StringUtils.isBlank(value.toString()) || value.equals(0)) {
        form.set(key, defaultValue);
    }
    else {
        form.set(key, value);
    }
}
 
Example 12
Source File: KickstartIpRangeAction.java    From spacewalk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param form DynaActionForm
 */
private void setupFormValues(DynaActionForm form) {
    form.set(OCTET1A, new Long(0));
    form.set(OCTET1B, new Long(0));
    form.set(OCTET1C, new Long(0));
    form.set(OCTET1D, new Long(0));
    form.set(OCTET2A, new Long(0));
    form.set(OCTET2B, new Long(0));
    form.set(OCTET2C, new Long(0));
    form.set(OCTET2D, new Long(0));
}
 
Example 13
Source File: AdvancedModeDetailsAction.java    From uyuni with GNU General Public License v2.0 5 votes vote down vote up
private void loadTrees(KickstartWizardHelper cmd, DynaActionForm form,
        RequestContext context) {

    List<KickstartableTree> trees = cmd.getKickstartableTrees();
    if (trees == null || trees.size() == 0) {
        context.getRequest().setAttribute(NOTREES_PARAM, Boolean.TRUE);
        form.set(KSTREE_ID_PARAM, null);
    }
    else {
        form.set(KSTREES_PARAM, trees);

        if (isCreateMode(context.getRequest())) {
            form.set(KSTREE_ID_PARAM, null);
        }
        else {
            KickstartRawData data = getKsData(context);
            KickstartableTree tree = data.getTree();
            if (tree == null) {
                form.set(KSTREE_ID_PARAM, null);
            }
            else {
                form.set(KSTREE_ID_PARAM, tree.getId());
            }
            KickstartTreeUpdateType updateType = data.getRealUpdateType();
            if (updateType.equals(KickstartTreeUpdateType.ALL)) {
                context.getRequest().setAttribute(USING_UPDATE_ALL, "true");
            }
            else if (updateType.equals(KickstartTreeUpdateType.RED_HAT)) {
                context.getRequest().setAttribute(USING_UPDATE_RED_HAT, "true");
            }
        }
    }
}
 
Example 14
Source File: KickstartLocaleEditAction.java    From uyuni with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 * {@inheritDoc}
 */
protected void setupFormValues(RequestContext ctx, DynaActionForm form,
        BaseKickstartCommand cmdIn) {
    KickstartLocaleCommand cmd = (KickstartLocaleCommand) cmdIn;

    ArrayList timezones = cmd.getValidTimezones();
    ctx.getRequest().setAttribute(TIMEZONE_OPTIONS, timezones);

    form.set(TIMEZONE, cmd.getTimezone());
    form.set(USE_UTC, cmd.getKickstartData().isUsingUtc());
}
 
Example 15
Source File: ScheduleDetailAction.java    From spacewalk with GNU General Public License v2.0 5 votes vote down vote up
private void setupForm(HttpServletRequest request, DynaActionForm form) {
    RequestContext ctx = new RequestContext(request);
    User loggedInUser = ctx.getCurrentUser();
    Long schid = ctx.getParamAsLong("schid");

    if (schid != null) {
        try {
            TaskomaticApi tapi = new TaskomaticApi();
            Map schedule = tapi.lookupScheduleById(loggedInUser, schid);
            String scheduleName = (String) schedule.get("job_label");
            String bunchName = (String) schedule.get("bunch");
            request.setAttribute("schedulename", scheduleName);
            form.set("schedulename", scheduleName);
            request.setAttribute("bunch", bunchName);
            Map bunch = tapi.lookupBunchByName(loggedInUser, bunchName);
            request.setAttribute("bunchdescription", bunch.get("description"));
            RecurringEventPicker.prepopulatePicker(request, "date",
                    (String) schedule.get(("cron_expr")));
        }
        catch (TaskomaticApiException e) {
            createErrorMessage(request,
                    "repos.jsp.message.taskomaticdown", null);
        }
    }
    else {
        RecurringEventPicker.prepopulatePicker(request, "date", null);
    }
}
 
Example 16
Source File: RepoDetailsAction.java    From uyuni with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public ActionForward execute(ActionMapping mapping,
                              ActionForm formIn,
                              HttpServletRequest request,
                              HttpServletResponse response) {
    DynaActionForm form = (DynaActionForm) formIn;
    RequestContext ctx = new RequestContext(request);
    Map<String, Object> params = makeParamMap(request);
    String cid = null;
    request.setAttribute(mapping.getParameter(), Boolean.TRUE);
    if (ctx.hasParam("cid")) {
        cid = ctx.getParam("cid", false);
        request.setAttribute("cid", cid);
    }
    if (ctx.isSubmitted()) {

        ValidatorResult result = RhnValidationHelper.validate(this.getClass(),
                        makeValidationMap(form), null,
                            VALIDATION_XSD);
        if (!result.isEmpty()) {
            getStrutsDelegate().saveMessages(request, result);
            RhnValidationHelper.setFailedValidation(request);
        }
        else {
            try {
                ActionErrors errors = new ActionErrors();
                ContentSource repo = submit(request, errors, form);
                if (!errors.isEmpty()) {
                    addErrors(request, errors);
                    setupContentTypes(ctx);
                    setupCryptoKeys(ctx);
                    bindRepo(request, repo);
                    return mapping.findForward(RhnHelper.DEFAULT_FORWARD);
                }
                if (isCreateMode(request)) {
                    createSuccessMessage(request,
                            "repos.jsp.create.success", repo.getLabel());
                }
                else {
                    createSuccessMessage(request,
                            "repos.jsp.update.success", repo.getLabel());
                }
                request.removeAttribute(CREATE_MODE);
                /*
                If cid isn't specified, repo will be created as usual. Otherwise repo
                 will be created and will be automatically assigned to channel cid
                 with redirection to channel repo page
                 */
                if (cid != null) {
                    params.put("cid", cid);
                    Channel chan = ChannelFactory.lookupById(Long.parseLong(cid));
                    Set<ContentSource> sources = chan.getSources();
                    sources.add(repo);
                    ChannelFactory.save(chan);
                    createSuccessMessage(request,
                            "channel.edit.repo.updated", chan.getLabel());
                    return getStrutsDelegate().forwardParams(
                            mapping.findForward("channelSub"), params);
                }
                setupRepo(request, form, repo);
                params.put("id", repo.getId());
                return getStrutsDelegate().forwardParams(
                        mapping.findForward("success"), params);
            }
            catch (ValidatorException ve) {
                getStrutsDelegate().saveMessages(request, ve.getResult());
                RhnValidationHelper.setFailedValidation(request);
            }
        }
    }
    if (isCreateMode(request)) {
        // default for has signed metadata should be true
        form.set(METADATA_SIGNED, Boolean.valueOf(true));
    }
    setup(request, form, isCreateMode(request));

    return getStrutsDelegate().forwardParams(mapping.findForward(RhnHelper
            .DEFAULT_FORWARD), params);
}
 
Example 17
Source File: CreateUserSetupAction.java    From spacewalk with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public ActionForward execute(ActionMapping mapping,
                             ActionForm formIn,
                             HttpServletRequest request,
                             HttpServletResponse response) {
    DynaActionForm form = (DynaActionForm)formIn;
    RequestContext ctx = new RequestContext(request);
    User currentUser = ctx.getCurrentUser();

    // We have to set these on the Session because struts throws them away
    // if we set them on the request itself and validation fails.
    request.setAttribute("availablePrefixes",
                              UserActionHelper.getPrefixes());
    request.setAttribute("countries",
                              UserActionHelper.getCountries());

    if (!RhnValidationHelper.getFailedValidation(request)) {
        form.set("country", "US");
        form.set("contact_email", Boolean.TRUE);
        form.set("contact_partner", Boolean.TRUE);
        form.set("prefix",
            LocalizationService.getInstance().getMessage("user prefix Mr."));
    }

    //make sure we don't put the user's password on the form in cleartext
    form.set("desiredpassword", "");
    form.set("desiredpasswordConfirm", "");

    /*
     * If we are a sat, then we for sure want to display the PAM section
     */
    request.setAttribute("displaypam", "true");
    /*
    * If we are a sat and we have setup pam authentication already, display the
    * checkbox and instructions
    */
    String pamAuthService = Config.get().getString(ConfigDefaults.WEB_PAM_AUTH_SERVICE);
    if (pamAuthService != null && pamAuthService.trim().length() > 0) {
        request.setAttribute("displaypamcheckbox", "true");
    }

    request.setAttribute("timezones", getTimeZones());
    if (currentUser.getTimeZone() != null) {
        request.setAttribute("default_tz", new Integer(currentUser.getTimeZone()
            .getTimeZoneId()));
    }
    else {
        request.setAttribute("default_tz", new Integer(UserManager
            .getDefaultTimeZone().getTimeZoneId()));
    }
    request.setAttribute("noLocale", buildNoneLocale());
    request.setAttribute("supportedLocales", buildImageMap());
    setCurrentLocale(ctx, currentUser);

    return mapping.findForward(RhnHelper.DEFAULT_FORWARD);
}
 
Example 18
Source File: ProvisionVirtualizationWizardAction.java    From spacewalk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public ActionForward runSecond(ActionMapping mapping, DynaActionForm form,
        RequestContext ctx, HttpServletResponse response,
        WizardStep step) throws Exception {
    if (!validateFirstSelections(form, ctx)) {
        return runFirst(mapping, form, ctx, response, step);
    }
    ActionErrors errors = validateInput(form);
    if (!errors.isEmpty()) {
        addErrors(ctx.getRequest(), errors);
        //saveMessages(ctx.getRequest(), errors);
        return runFirst(mapping, form, ctx, response, step);
    }
    ActionForward forward = super.runSecond(mapping, form, ctx, response, step);

    Profile pf = getCobblerProfile(ctx);
    KickstartData ksdata = ctx.lookupAndBindKickstartData();
    if (StringUtils.isEmpty(form.getString(VIRTUAL_FILE_PATH))) {
        form.set(VIRTUAL_FILE_PATH, ProvisionVirtualInstanceCommand.
                makeDefaultVirtPath(form.getString(GUEST_NAME),
                        ksdata.getKickstartDefaults().getVirtualizationType()));
    }
    if (StringUtils.isEmpty(form.getString(MEMORY_ALLOCATION))) {
        form.set(MEMORY_ALLOCATION, String.valueOf(pf.getVirtRam()));
    }

    if (StringUtils.isEmpty(form.getString(VIRTUAL_CPUS))) {
        form.set(VIRTUAL_CPUS, String.valueOf(pf.getVirtCpus()));
    }

    if (StringUtils.isEmpty(form.getString(LOCAL_STORAGE_GB))) {
        form.set(LOCAL_STORAGE_GB, String.valueOf(pf.getVirtFileSize()));
    }

    if (StringUtils.isEmpty(form.getString(VIRTUAL_BRIDGE))) {
        form.set(VIRTUAL_BRIDGE, String.valueOf(pf.getVirtBridge()));
    }

    if (StringUtils.isEmpty(form.getString(TARGET_PROFILE_TYPE))) {
        form.set(TARGET_PROFILE_TYPE,
                KickstartScheduleCommand.TARGET_PROFILE_TYPE_NONE);
    }
    return forward;
}
 
Example 19
Source File: ChangeEmailSetupAction.java    From uyuni with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public ActionForward execute(ActionMapping mapping,
                             ActionForm formIn,
                             HttpServletRequest request,
                             HttpServletResponse response) {
    DynaActionForm form = (DynaActionForm)formIn;
    LocalizationService ls = LocalizationService.getInstance();

    RequestContext requestContext = new RequestContext(request);

    //set logged in user and target user
    User loggedInUser = requestContext.getCurrentUser();
    User targetUser;
    Long uid = requestContext.getParamAsLong("uid");
    if (uid == null) {
        targetUser = loggedInUser; //We are editing ourself
    }
    else {
        targetUser = UserManager.lookupUser(loggedInUser, uid);
    }
    request.setAttribute(RhnHelper.TARGET_USER, targetUser);
    // If targetUser is null we must have gotten a bad uid
    if (targetUser == null) {
        throw new BadParameterException("Invalid uid, targetUser not found");
    }

    String email = targetUser.getEmail();

    String pageInstructions;
    String buttonLabel;
    /*
     * ** Logic from Sniglests/Users.pm - rhn_email_change_form **
     * If this is a satellite, we don't care about whether or not this addr is verified.
     */
    pageInstructions = ls.getMessage("yourchangeemail.instructions");
    buttonLabel = ls.getMessage("message.Update");

    //Set request and form vars for page
    request.setAttribute("pageinstructions", pageInstructions);
    request.setAttribute("button_label", buttonLabel);
    form.set("email", email);

    return getStrutsDelegate().forwardParam(
            mapping.findForward(RhnHelper.DEFAULT_FORWARD), "uid",
            String.valueOf(targetUser.getId()));
}
 
Example 20
Source File: ScheduleKickstartWizardAction.java    From spacewalk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Setup the system for provisioning with cobbler.
 *
 * @param mapping ActionMapping for struts
 * @param form DynaActionForm representing the form
 * @param ctx RequestContext request context
 * @param response HttpServletResponse response object
 * @param step WizardStep what step are we on?
 *
 * @return ActionForward struts action forward
 * @throws Exception if something goes amiss
 */
public ActionForward runFourth(ActionMapping mapping, DynaActionForm form,
        RequestContext ctx, HttpServletResponse response, WizardStep step)
                throws Exception {

    log.debug("runFourth");
    if (!validateFirstSelections(form, ctx)) {
        return runFirst(mapping, form, ctx, response, step);
    }
    Long sid = (Long) form.get(RequestContext.SID);
    String cobblerId = form.getString(RequestContext.COBBLER_ID);

    log.debug("runFourth.cobblerId: " + cobblerId);

    User user = ctx.getCurrentUser();
    Server server = SystemManager.lookupByIdAndUser(sid, user);

    Map<String, Object> params = new HashMap<String, Object>();
    params.put(RequestContext.SID, sid);

    log.debug("Creating cobbler system record");
    org.cobbler.Profile profile = org.cobbler.Profile.lookupById(
            CobblerXMLRPCHelper.getConnection(user), cobblerId);

    KickstartData data = KickstartFactory.lookupKickstartDataByCobblerIdAndOrg(
            user.getOrg(), profile.getUid());

    if (showDiskWarning(data, form)) {
        form.set(NEXT_ACTION, "fourth");
        ctx.getRequest().setAttribute(RequestContext.SYSTEM, server);
        return mapping.findForward("fifth");
    }

    CobblerSystemCreateCommand cmd = new CobblerSystemCreateCommand(server,
            profile.getName(), data);
    cmd.store();
    log.debug("cobbler system record created.");
    String[] args = new String[2];
    args[0] = server.getName();
    args[1] = profile.getName();
    createMessage(ctx.getRequest(), "kickstart.schedule.cobblercreate",
            args);
    return getStrutsDelegate().forwardParams(
            mapping.findForward("cobbler-success"), params);
}