/** {@inheritDoc} */ public ActionForward execute( ActionMapping mapping, ActionForm formIn, HttpServletRequest request, HttpServletResponse response) { ListHelper helper = new ListHelper(this, request); helper.execute(); return mapping.findForward(RhnHelper.DEFAULT_FORWARD); }
/** {@inheritDoc} */ public ActionForward execute( ActionMapping mapping, ActionForm formIn, HttpServletRequest request, HttpServletResponse response) { RequestContext context = new RequestContext(request); User user = context.getCurrentUser(); Long sid = context.getRequiredParam("sid"); Server server = SystemManager.lookupByIdAndUser(sid, user); Long xid = context.getRequiredParam("xid"); XccdfTestResult testResult = ScapFactory.lookupTestResultByIdAndSid(xid, server.getId()); request.setAttribute("testResult", testResult); request.setAttribute("system", server); ListHelper helper = new ListHelper(this, request); helper.execute(); request.setAttribute( ListTagHelper.PARENT_URL, request.getRequestURI() + "?sid=" + sid + "&xid=" + xid); SdcHelper.ssmCheck(request, sid, user); return mapping.findForward(RhnHelper.DEFAULT_FORWARD); }
/** * The first step in the wizard * * @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 runFirst( ActionMapping mapping, DynaActionForm form, RequestContext ctx, HttpServletResponse response, WizardStep step) throws Exception { log.debug("runFirst"); Long sid = (Long) form.get(RequestContext.SID); User user = ctx.getCurrentUser(); KickstartScheduleCommand cmd = getKickstartScheduleCommand(sid, user); Server system = SystemManager.lookupByIdAndUser(sid, user); if (system.isVirtualGuest() && VirtualInstanceFactory.getInstance() .getParaVirtType() .equals(system.getVirtualInstance().getType())) { ctx.getRequest().setAttribute(IS_VIRTUAL_GUEST, Boolean.TRUE.toString()); ctx.getRequest().setAttribute(VIRT_HOST_IS_REGISTERED, Boolean.FALSE.toString()); if (system.getVirtualInstance().getHostSystem() != null) { Long hostSid = system.getVirtualInstance().getHostSystem().getId(); ctx.getRequest().setAttribute(VIRT_HOST_IS_REGISTERED, Boolean.TRUE.toString()); ctx.getRequest().setAttribute(HOST_SID, hostSid); } } else { ctx.getRequest().setAttribute(IS_VIRTUAL_GUEST, Boolean.FALSE.toString()); } addRequestAttributes(ctx, cmd, form); checkForKickstart(form, cmd, ctx); setupProxyInfo(ctx); if (StringUtils.isBlank(form.getString(PROXY_HOST))) { form.set(PROXY_HOST, ""); } // create and prepopulate the date picker. getStrutsDelegate() .prepopulateDatePicker(ctx.getRequest(), form, "date", DatePicker.YEAR_RANGE_POSITIVE); SdcHelper.ssmCheck(ctx.getRequest(), system.getId(), user); Map params = new HashMap<String, String>(); params.put(RequestContext.SID, sid); ListHelper helper = new ListHelper(new Profiles(), ctx.getRequest(), params); helper.execute(); if (!StringUtils.isBlank(form.getString(RequestContext.COBBLER_ID))) { ListTagHelper.selectRadioValue( ListHelper.LIST, form.getString(RequestContext.COBBLER_ID), ctx.getRequest()); } else if (system.getCobblerId() != null) { // if nothing is selected by the user yet, use the cobbler // system record to pre-select something. SystemRecord rec = SystemRecord.lookupById( CobblerXMLRPCHelper.getConnection(ConfigDefaults.get().getCobblerAutomatedUser()), system.getCobblerId()); if (rec != null) { ListTagHelper.selectRadioValue(ListHelper.LIST, rec.getProfile().getId(), ctx.getRequest()); } } ActionForward retval = mapping.findForward("first"); return retval; }
/** {@inheritDoc} */ public ActionForward execute( ActionMapping mapping, ActionForm formIn, HttpServletRequest request, HttpServletResponse response) { ActionErrors errors = new ActionErrors(); DynaActionForm form = (DynaActionForm) formIn; Map<String, Object> params = makeParamMap(request); RequestContext ctx = new RequestContext(request); // keep the cid if (ctx.hasParam("cid")) { params.put("cid", ctx.getParam("cid", true)); } if (!isSubmitted(form)) { setupForm(request, form); return getStrutsDelegate() .forwardParams(mapping.findForward(RhnHelper.DEFAULT_FORWARD), request.getParameterMap()); } if (ctx.hasParam("create_button")) { Long cid = create(form, errors, ctx); params.put("cid", cid); if (errors.isEmpty()) { createSuccessMessage(request, "message.channelcreated", form.getString("name")); } } else if (ctx.hasParam("edit_button")) { String sharing = (String) form.get("org_sharing"); if (hasSharingChanged(form, ctx) && ("private".equals(sharing) || "protected".equals(sharing))) { // forward to confirm page request.setAttribute("org", ctx.getCurrentUser().getOrg()); formToAttributes(request, form); Map urlParams = new HashMap(); urlParams.put(RequestContext.CID, ctx.getRequiredParam(RequestContext.CID)); ListHelper helper = new ListHelper(this, request, urlParams); helper.setDataSetName(getDataSetName()); helper.setListName(getListName()); // ignore the return helper.execute(); request.setAttribute("channel_name", form.getString("name")); return getStrutsDelegate().forwardParams(mapping.findForward(sharing), params); } edit(form, errors, ctx); if (errors.isEmpty()) { createSuccessMessage(request, "message.channelupdated", form.getString("name")); } // did they enable per user subscriptions? String sub = (String) form.get("per_user_subscriptions"); if (!sub.equals("all")) { addMessage(request, "message.channelsubscribers"); } } // handler for private confirmation page else if (ctx.hasParam(RequestContext.DISPATCH)) { makePrivate(form, errors, ctx); if (errors.isEmpty()) { createSuccessMessage(request, "message.channelupdated", form.getString("name")); } } else if (ctx.hasParam("deny")) { deny(form, errors, ctx); if (errors.isEmpty()) { createSuccessMessage(request, "message.channelupdated", form.getString("name")); } } else if (ctx.hasParam("grant")) { grant(form, errors, ctx); if (errors.isEmpty()) { createSuccessMessage(request, "message.channelupdated", form.getString("name")); } } if (!errors.isEmpty()) { request.setAttribute("channel_label", form.get("label")); request.setAttribute("channel_name", form.getString("name")); request.setAttribute("channel_arch", form.get("arch_name")); request.setAttribute("channel_arch_label", form.get("arch")); request.setAttribute("checksum", form.get("checksum")); addErrors(request, errors); prepDropdowns(new RequestContext(request)); return getStrutsDelegate() .forwardParams(mapping.findForward(RhnHelper.DEFAULT_FORWARD), params); } return getStrutsDelegate().forwardParams(mapping.findForward("success"), params); }
/** {@inheritDoc} */ @Override public ActionForward execute( ActionMapping mapping, ActionForm formIn, HttpServletRequest request, HttpServletResponse response) { RequestContext context = new RequestContext(request); User user = context.getCurrentUser(); long cid = context.getRequiredParam("cid"); Channel chan = ChannelFactory.lookupByIdAndUser(cid, user); request.setAttribute("channel_name", chan.getName()); request.setAttribute("cid", chan.getId()); Map params = new HashMap(); params.put(RequestContext.CID, chan.getId().toString()); ListHelper helper = new ListHelper(this, request, params); helper.execute(); TaskomaticApi taskomatic = new TaskomaticApi(); String oldCronExpr; try { oldCronExpr = taskomatic.getRepoSyncSchedule(chan, user); } catch (TaskomaticApiException except) { params.put("inactive", true); request.setAttribute("inactive", true); createErrorMessage(request, "repos.jsp.message.taskomaticdown", null); return mapping.findForward(RhnHelper.DEFAULT_FORWARD); } RecurringEventPicker picker = RecurringEventPicker.prepopulatePicker(request, "date", oldCronExpr); if (context.isSubmitted()) { StrutsDelegate strutsDelegate = getStrutsDelegate(); // check user permissions first if (!UserManager.verifyChannelAdmin(user, chan)) { createErrorMessage(request, "frontend.actions.channels.manager.add.permsfailure", null); return mapping.findForward(RhnHelper.DEFAULT_FORWARD); } if (chan.getSources().isEmpty()) { createErrorMessage(request, "repos.jsp.channel.norepos", null); return mapping.findForward(RhnHelper.DEFAULT_FORWARD); } try { if (context.wasDispatched("repos.jsp.button-sync")) { // schedule one time repo sync taskomatic.scheduleSingleRepoSync(chan, user); createSuccessMessage(request, "message.syncscheduled", chan.getName()); } else if (context.wasDispatched("schedule.button")) { if ((picker.isDisabled() || StringUtils.isEmpty(picker.getCronEntry())) && oldCronExpr != null) { taskomatic.unscheduleRepoSync(chan, user); createSuccessMessage(request, "message.syncschedule.disabled", chan.getName()); } else if (!StringUtils.isEmpty(picker.getCronEntry())) { Date date = taskomatic.scheduleRepoSync(chan, user, picker.getCronEntry()); createSuccessMessage(request, "message.syncscheduled", chan.getName()); } } } catch (TaskomaticApiException e) { if (e.getMessage().contains("InvalidParamException")) { createErrorMessage(request, "repos.jsp.message.invalidcron", picker.getCronEntry()); } else { createErrorMessage(request, "repos.jsp.message.schedulefailed", null); } return mapping.findForward(RhnHelper.DEFAULT_FORWARD); } Map forwardParams = new HashMap(); forwardParams.put("cid", chan.getId()); return getStrutsDelegate().forwardParams(mapping.findForward("success"), forwardParams); } return mapping.findForward(RhnHelper.DEFAULT_FORWARD); }