/** {@inheritDoc} */ public ActionForward execute( ActionMapping mapping, ActionForm formIn, HttpServletRequest request, HttpServletResponse response) { RequestContext requestContext = new RequestContext(request); if (request.getParameter("dispatch") != null) { if (requestContext.wasDispatched("installconfirm.jsp.confirm")) { return executePackageAction(mapping, formIn, request, response); } } List<PackageListItem> items = getDataResult(request); Server server = requestContext.lookupAndBindServer(); /* * If we are removing a package that is not in a channel the server is * subscribed to, then the rollback will not work, lets give the user * a message telling them that. */ if (this instanceof RemoveConfirmSetupAction && server.hasEntitlement(EntitlementManager.PROVISIONING)) { for (PackageListItem item : items) { Map<String, Long> map = item.getKeyMap(); if (!SystemManager.hasPackageAvailable( server, map.get("name_id"), map.get("arch_id"), map.get("evr_id"))) { ActionMessages msgs = new ActionMessages(); msgs.add( ActionMessages.GLOBAL_MESSAGE, new ActionMessage("package.remove.cant.rollback")); getStrutsDelegate().saveMessages(request, msgs); break; } } } DynaActionForm dynaForm = (DynaActionForm) formIn; DatePicker picker = getStrutsDelegate() .prepopulateDatePicker(request, dynaForm, "date", DatePicker.YEAR_RANGE_POSITIVE); request.setAttribute("date", picker); ActionChainHelper.prepopulateActionChains(request); request.setAttribute("system", server); requestContext.copyParamToAttributes(RequestContext.SID); request.setAttribute( ListTagHelper.PARENT_URL, request.getRequestURI() + "?sid=" + server.getId()); request.setAttribute(WIDGET_SUMMARY, getWidgetSummary()); request.setAttribute(HEADER_KEY, getHeaderKey()); request.setAttribute(DATA_SET, items); return getStrutsDelegate() .forwardParams(mapping.findForward(RhnHelper.DEFAULT_FORWARD), request.getParameterMap()); }
/** {@inheritDoc} */ public ActionForward execute( ActionMapping mapping, ActionForm formIn, HttpServletRequest request, HttpServletResponse response) { RequestContext requestContext = new RequestContext(request); User user = requestContext.getCurrentUser(); Long sid = requestContext.getRequiredParam("sid"); RhnSet set = getSetDecl(sid).get(user); ListRhnSetHelper help = new ListRhnSetHelper(this, request, getSetDecl(sid)); help.setListName(LIST_NAME); String parentURL = request.getRequestURI() + "?sid=" + sid; help.setParentUrl(parentURL); help.execute(); if (help.isDispatched()) { if (requestContext.wasDispatched("errata.jsp.apply")) { return applyErrata(mapping, formIn, request, response); } } String showButton = "true"; // Show the "Apply Errata" button only when unapplied errata exist: if (!SystemManager.hasUnscheduledErrata(user, sid)) { showButton = "false"; } Map params = new HashMap(); Set keys = request.getParameterMap().keySet(); for (Iterator i = keys.iterator(); i.hasNext(); ) { String key = (String) i.next(); params.put(key, request.getParameter(key)); } Server server = SystemManager.lookupByIdAndUser(sid, user); SdcHelper.ssmCheck(request, server.getId(), user); request.setAttribute("showApplyErrata", showButton); request.setAttribute("set", set); request.setAttribute("system", server); request.setAttribute("combo", getComboList(request)); request.setAttribute(SELECTOR, request.getParameter(SELECTOR)); return getStrutsDelegate() .forwardParams(mapping.findForward(RhnHelper.DEFAULT_FORWARD), params); }
/** {@inheritDoc} */ @Override public ActionForward execute( ActionMapping mapping, ActionForm formIn, HttpServletRequest request, HttpServletResponse response) { RequestContext requestContext = new RequestContext(request); User user = requestContext.getCurrentUser(); long cid = requestContext.getRequiredParam(RequestContext.CID); Channel chan = ChannelFactory.lookupByIdAndUser(cid, user); String syncType = request.getParameter(SYNC_TYPE); if (!UserManager.verifyChannelAdmin(user, chan)) { throw new PermissionException(RoleFactory.CHANNEL_ADMIN); } if (chan.getOrg() == null) { throw new PermissionCheckFailureException(); } String selectedChan = request.getParameter(SELECTED_CHANNEL); request.setAttribute(RequestContext.CID, chan.getId()); request.setAttribute(CHANNEL_NAME, chan.getName()); if (requestContext.wasDispatched("channel.jsp.package.mergebutton")) { Map<String, Object> params = new HashMap<String, Object>(); params.put(RequestContext.CID, cid); params.put(OTHER_ID, selectedChan); params.put(SYNC_TYPE, syncType); return getStrutsDelegate() .forwardParams(mapping.findForward(RhnHelper.CONFIRM_FORWARD), params); } // selected channel id long scid = 0; String sname = ""; // If a channel isn't selected, select one smartly if (selectedChan == null) { if (chan.isCloned()) { scid = chan.getOriginal().getId(); } } else if (!NO_PACKAGES.equals(selectedChan)) { scid = Long.parseLong(selectedChan); } // Add Red Hat Base Channels, and custom base channels to the list, and if one // is selected, select it List<SelectableChannel> chanList = findChannels(user, scid); DataResult result = null; if (scid != 0) { sname = ChannelFactory.lookupByIdAndUser(scid, user).getName(); result = PackageManager.comparePackagesBetweenChannels(cid, scid); TagHelper.bindElaboratorTo(listName, result.getElaborator(), request); } request.setAttribute(CHANNEL_LIST, chanList); request.setAttribute(OTHER_CHANNEL, sname); request.setAttribute(SYNC_TYPE, syncType); request.setAttribute(ListTagHelper.PARENT_URL, request.getRequestURI()); request.setAttribute(RequestContext.PAGE_LIST, result); return mapping.findForward(RhnHelper.DEFAULT_FORWARD); }
/** {@inheritDoc} */ public ActionForward execute( ActionMapping mapping, ActionForm formIn, HttpServletRequest request, HttpServletResponse response) { RequestContext requestContext = new RequestContext(request); User user = requestContext.getCurrentUser(); Long cid = Long.parseLong(request.getParameter(CID)); Channel currentChan = ChannelFactory.lookupByIdAndUser(cid, user); Channel selectedChannel = null; PublishErrataHelper.checkPermissions(user, cid); request.setAttribute(CID, cid); request.setAttribute("user", user); request.setAttribute("channel_name", currentChan.getName()); request.setAttribute(ListTagHelper.PARENT_URL, request.getRequestURI()); List<SelectableChannelVersion> versionList = SelectableChannelVersion.getCurrentChannelVersionList(); List<SelectableChannel> channelList = null; request.setAttribute(VERSION_LIST, versionList); String selectedVersionStr = null; String selectedChannelStr = null; Boolean checked = true; // Set initail strings selectedChannelStr = request.getParameter(SELECTED_CHANNEL_OLD); selectedVersionStr = request.getParameter(SELECTED_VERSION_OLD); if (selectedVersionStr == null) { selectedVersionStr = versionList.get(0).getVersion(); } // If the channel submit button was clicked if (requestContext.wasDispatched(CHANNEL_SUBMIT)) { selectedChannelStr = request.getParameter(SELECTED_CHANNEL); // selectedChannelStr might be null } // if the version submit button was clicked else if (requestContext.wasDispatched(VERSION_SUBMIT)) { selectedVersionStr = request.getParameter(SELECTED_VERSION); // selectedChannelStr might be null selectedChannelStr = null; } if (!requestContext.isSubmitted()) { // If this is a clone, go ahead and pre-select the original Channel Channel original = ChannelFactory.lookupOriginalChannel(currentChan); while (original != null) { selectedChannel = original; selectedChannelStr = selectedChannel.getId().toString(); String tmp = findVersionFromChannel(selectedChannel); if (tmp == null) { // if we haven't found channel version, let's try to check its parent if (!selectedChannel.isBaseChannel()) { tmp = findVersionFromChannel(selectedChannel.getParentChannel()); } } if (tmp != null) { selectedVersionStr = tmp; break; } original = ChannelFactory.lookupOriginalChannel(original); } } if (selectedVersionStr != null) { // set selected version based off version selected for (SelectableChannelVersion chanVer : versionList) { if (chanVer.getVersion().equals(selectedVersionStr)) { chanVer.setSelected(true); request.setAttribute(SELECTED_VERSION_NAME, chanVer.getName()); break; } } List<Channel> channelSet = findChannelsByVersion(user, selectedVersionStr); channelList = new ArrayList(); if (channelSet != null) { sortChannelsAndChildify(channelSet, channelList, user, selectedChannelStr); request.setAttribute(CHANNEL_LIST, channelList); } } if (requestContext.isSubmitted() && request.getParameter(CHECKED) == null) { checked = false; } request.setAttribute(CHECKED, checked); request.setAttribute(SELECTED_CHANNEL, selectedChannelStr); request.setAttribute(SELECTED_VERSION, selectedVersionStr); if (requestContext.wasDispatched(SUBMITTED)) { Map params = new HashMap(); params.put(CID, request.getParameter(CID)); params.put(SELECTED_CHANNEL, selectedChannelStr); params.put(CHECKED, request.getParameter(CHECKED)); return getStrutsDelegate().forwardParams(mapping.findForward("submit"), params); } // If we clicked on the channel selection, clear the set if (requestContext.wasDispatched(CHANNEL_SUBMIT) || requestContext.wasDispatched(VERSION_SUBMIT) || !requestContext.isSubmitted()) { RhnSet eset = getSetDecl(currentChan).get(user); eset.clear(); RhnSetManager.store(eset); } if (selectedChannelStr != null) { selectedChannel = ChannelFactory.lookupByIdAndUser(Long.parseLong(selectedChannelStr), user); } RhnListSetHelper helper = new RhnListSetHelper(request); RhnSet set = getSetDecl(currentChan).get(user); DataResult dr = getData(request, selectedChannel, currentChan, channelList, checked, user); request.setAttribute(RequestContext.PAGE_LIST, dr); if (ListTagHelper.getListAction("errata", request) != null) { helper.execute(set, "errata", dr); } if (!set.isEmpty()) { helper.syncSelections(set, dr); ListTagHelper.setSelectedAmount("errata", set.size(), request); } TagHelper.bindElaboratorTo("errata", dr.getElaborator(), request); ListTagHelper.bindSetDeclTo("errata", getSetDecl(currentChan), request); return mapping.findForward(RhnHelper.DEFAULT_FORWARD); }
/** {@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); }