Java Code Examples for org.apache.struts.action.DynaActionForm#get()
The following examples show how to use
org.apache.struts.action.DynaActionForm#get() .
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: KickstartPartitionActionTest.java From spacewalk with GNU General Public License v2.0 | 6 votes |
public void testCleanSubmit() throws Exception { String data = "part swap --size=1000 --grow --maxsize=3000\n" + "logvol swap --fstype swap --name=lvswap --vgname=Volume00 --size=2048\n" + "volgroup myvg --fstype swap --level 0 --device 1 raid.05 raid.06 raid.07 raid.08"; setRequestPathInfo("/kickstart/KickstartPartitionEdit"); addRequestParameter(KickstartPartitionEditAction.SUBMITTED, Boolean.TRUE.toString()); addRequestParameter(KickstartPartitionEditAction.PARTITIONS, data); actionPerform(); DynaActionForm form = (DynaActionForm) getActionForm(); String formval = (String)form.get(KickstartPartitionEditAction.PARTITIONS); assertNotNull(formval); assertTrue(formval.length() > 0); assertEquals(data, formval); String[] keys = {"kickstart.partition.success", "kickstart.software.changeencryption"}; verifyActionMessages(keys); assertNotNull(ksdata.getPartitionData()); assertEquals(data, ksdata.getPartitionData()); }
Example 2
Source File: AuditSearchAction.java From uyuni with GNU General Public License v2.0 | 6 votes |
private Long processEndMilli(DynaActionForm dform, HttpServletRequest request) { Long endMilli = (Long)dform.get("endMilli"); String endDisp; if (endMilli != null && endMilli > 0 && endMilli != Long.MAX_VALUE) { endDisp = (new Date(endMilli)).toString(); } else { endMilli = Calendar.getInstance().getTime().getTime(); endDisp = ">>"; } request.setAttribute("endDisp", endDisp); request.setAttribute("endMilli", endMilli); return endMilli; }
Example 3
Source File: ScheduleKickstartWizardAction.java From spacewalk with GNU General Public License v2.0 | 6 votes |
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: ScheduleXccdfAction.java From uyuni with GNU General Public License v2.0 | 6 votes |
private ActionMessages processForm(User user, Server server, DynaActionForm f) { String params = (String) f.get("params"); String path = (String) f.get("path"); Date earliest = getStrutsDelegate().readDatePicker(f, "date", DatePicker.YEAR_RANGE_POSITIVE); try { ScapAction action = ActionManager.scheduleXccdfEval(user, server, path, params, earliest); ActionMessages msgs = new ActionMessages(); msgs.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("message.xccdfeval", action.getId().toString(), server.getId().toString(), StringUtil.htmlifyText(server.getName()))); return msgs; } catch (TaskomaticApiException e) { log.error("Could not schedule package refresh:"); log.error(e); ActionErrors errors = new ActionErrors(); getStrutsDelegate().addError(errors, "taskscheduler.down"); return errors; } }
Example 5
Source File: CurricularCourseEquivalenciesDA.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 6 votes |
@EntryPoint public ActionForward prepare(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { final User userView = Authenticate.getUser(); final DynaActionForm actionForm = (DynaActionForm) form; setInfoDegreesToManage(request, userView); final String degreeIDString = (String) actionForm.get("degreeID"); if (isValidObjectID(degreeIDString)) { setInfoDegreeCurricularPlans(request, userView, degreeIDString, "infoDegreeCurricularPlans"); final String degreeCurricularPlanIDString = (String) actionForm.get("degreeCurricularPlanID"); if (isValidObjectID(degreeCurricularPlanIDString)) { DegreeCurricularPlan degreeCurricularPlan = FenixFramework.getDomainObject(degreeCurricularPlanIDString); List<CurricularCourseEquivalence> equivalences = new ArrayList<CurricularCourseEquivalence>(degreeCurricularPlan.getCurricularCourseEquivalencesSet()); sortInfoCurricularCourseEquivalences(equivalences); request.setAttribute("curricularCourseEquivalences", equivalences); } } return mapping.findForward("showEquivalencies"); }
Example 6
Source File: ActivationKeyChildChannelsAction.java From spacewalk with GNU General Public License v2.0 | 6 votes |
private ActivationKey update(DynaActionForm form, RequestContext context) { User user = context.getCurrentUser(); ActivationKeyManager manager = ActivationKeyManager.getInstance(); ActivationKey key = context.lookupAndBindActivationKey(); Channel base = key.getBaseChannel(); key.clearChannels(); if (base != null) { key.addChannel(base); } for (String id : (String[])form.get("childChannels")) { key.addChannel(ChannelFactory.lookupById(Long.parseLong(id.trim()))); } ActivationKeyFactory.save(key); ActionMessages msg = new ActionMessages(); addToMessage(msg, "activation-key.java.modified", key.getNote()); getStrutsDelegate().saveMessages(context.getRequest(), msg); return key; }
Example 7
Source File: BaseRankChannels.java From spacewalk with GNU General Public License v2.0 | 5 votes |
/** * Returns the the channel Ids info retrieved after one * has clicked Update Channel Rankings or Apply Subscriptions. * @param form the submitted form.. * @return List containing the channel ids in the order of * their new rankings. */ protected List getChannelIds(DynaActionForm form) { List channels = new ArrayList(); String rankedValues = (String)form.get(RANKED_VALUES); if (StringUtils.isNotBlank(rankedValues)) { String [] values = rankedValues.split(","); for (int i = 0; i < values.length; i++) { channels.add(new Long(values[i])); } } return channels; }
Example 8
Source File: AdvancedModeDetailsAction.java From spacewalk with GNU General Public License v2.0 | 5 votes |
private String getData(RequestContext context, DynaActionForm form) { FormFile file = (FormFile) form.get(FILE_UPLOAD); String contents = form.getString(CONTENTS); if (!file.getFileName().equals("")) { StrutsDelegate delegate = getStrutsDelegate(); return delegate.extractString(file); } else if (!contents.equals("")) { return StringUtil.webToLinux(contents); } else { return null; } }
Example 9
Source File: ErrataSearchAction.java From uyuni with GNU General Public License v2.0 | 5 votes |
/** * Make sure we have appropriate defaults no matter how we got here * Set the defaults (where needed) back into the form so that the rest of the action * can find them * @param form where we expect values to be */ protected void insureFormDefaults(HttpServletRequest request, DynaActionForm form) { String viewmode = form.getString(VIEW_MODE); if (viewmode.equals("")) { //first time viewing page form.set(VIEW_MODE, "errata_search_by_all_fields"); } Boolean fineGrained = (Boolean)form.get(FINE_GRAINED); if (fineGrained == null) { fineGrained = false; form.set(FINE_GRAINED, fineGrained); } Boolean issueDateSrch = (Boolean)form.get(OPT_ISSUE_DATE); if (issueDateSrch == null) { form.set(OPT_ISSUE_DATE, Boolean.FALSE); } Boolean eTypeBug = (form.get(ERRATA_BUG) == null ? Boolean.FALSE : (Boolean)form.get(ERRATA_BUG)); Boolean eTypeSec = (form.get(ERRATA_SEC) == null ? Boolean.FALSE : (Boolean)form.get(ERRATA_SEC)); Boolean eTypeEnh = (form.get(ERRATA_ENH) == null ? Boolean.FALSE : (Boolean)form.get(ERRATA_ENH)); // If no errata-type is set, set them all if (!(eTypeBug || eTypeSec || eTypeEnh)) { form.set(ERRATA_BUG, Boolean.TRUE); form.set(ERRATA_SEC, Boolean.TRUE); form.set(ERRATA_ENH, Boolean.TRUE); } Map m = form.getMap(); Set<String> keys = m.keySet(); for (String key : keys) { Object vObj = m.get(key); request.setAttribute(key, vObj); } }
Example 10
Source File: ShowMonitors.java From iaf with Apache License 2.0 | 5 votes |
public void debugFormData(HttpServletRequest request, ActionForm form) { for (Enumeration enumeration=request.getParameterNames();enumeration.hasMoreElements();) { String name=(String)enumeration.nextElement(); String[] values=request.getParameterValues(name); if (values.length==1) { log.debug("Parameter ["+name+"] value ["+values[0]+"]"); } else { for (int i=0;i<values.length;i++) { log.debug("Parameter ["+name+"]["+i+"] value ["+values[i]+"]"); } } } if (form instanceof DynaActionForm) { DynaActionForm daf=(DynaActionForm)form; log.debug("class ["+daf.getDynaClass().getName()+"]"); for (Iterator it=daf.getMap().keySet().iterator();it.hasNext();) { String key=(String)it.next(); Object value=daf.get(key); log.debug("key ["+key+"] class ["+ClassUtils.nameOf(value)+"] value ["+value+"]"); if (value!=null) { if (value instanceof Monitor) { Monitor monitor=(Monitor)value; log.debug("Monitor :"+monitor.toXml().toXML()); } } } } }
Example 11
Source File: ShiftStudentEnrollmentManagerLookupDispatchAction.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 5 votes |
public ActionForward removeCourses(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws FenixTransactionException { this.validateToken(request, actionForm, mapping, "error.transaction.enrollment"); final Registration registration = getAndSetRegistration(request); if (registration == null) { addActionMessage(request, "errors.impossible.operation"); return mapping.getInputForward(); } checkParameter(request); final DynaActionForm form = (DynaActionForm) actionForm; final Integer executionCourseId = (Integer) form.get("removedCourse"); if (executionCourseId == null) { return mapping.findForward("prepareShiftEnrollment"); } // try { // ServiceManagerServiceFactory.executeService("DeleteStudentAttendingCourse", new Object[] { registration, // executionCourseId }); // // } catch (DomainException e) { // addActionMessage(request, e.getMessage()); // return mapping.getInputForward(); // // } catch (FenixServiceException e) { // addActionMessage(request, "errors.impossible.operation"); // return mapping.getInputForward(); // } // // return mapping.findForward("prepareShiftEnrollment"); throw new UnsupportedOperationException("Service DeleteStudentAttendingCourse no longer exists!"); }
Example 12
Source File: StrutsDelegate.java From spacewalk with GNU General Public License v2.0 | 5 votes |
/** * Writes the values of a date picker form to the <code>requestParams</code> * for remembering form values across requests. * Your dyna action picker must either be a struts datePickerForm, or * possess all of datePickerForm's fields. * @param requestParams The map to which to copy form fields * @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. * @see com.redhat.rhn.common.util.DatePicker */ public void rememberDatePicker(Map requestParams, DynaActionForm form, String name, int yearDirection) { //Write the option use_date field if it is there. if (form.get(DatePicker.USE_DATE) != null) { requestParams.put(DatePicker.USE_DATE, form.get(DatePicker.USE_DATE)); } //The datepicker itself can write the rest. DatePicker p = getDatePicker(name, yearDirection); p.readForm(form); p.writeToMap(requestParams); }
Example 13
Source File: SystemDetailsEditAction.java From uyuni with GNU General Public License v2.0 | 4 votes |
/** * Adds/removes add-on entitlements for the system. * * @param request the current HTTP request * @param daForm the DynaActionForm submitted by the user. * @param s the server to apply changes * @param user the user applying changes * @return true if validation succeeds, false otherwise. */ private boolean applyAddonEntitlementChanges(HttpServletRequest request, DynaActionForm daForm, Server s, User user) { boolean success = true; // Tracks whether or not a change has been made that requires a new snapshot // to be made boolean needsSnapshot = false; for (Entitlement e : user.getOrg().getValidAddOnEntitlementsForOrg()) { log.debug("Entitlement: " + e.getLabel()); log.debug("form.get: " + daForm.get(e.getLabel())); if (Boolean.TRUE.equals(daForm.get(e.getLabel())) && systemEntitlementManager.canEntitleServer(s, e)) { log.debug("Entitling server with: " + e); ValidatorResult vr = systemEntitlementManager.addEntitlementToServer(s, e); if (vr.getWarnings().size() > 0) { getStrutsDelegate().saveMessages(request, RhnValidationHelper.validatorWarningToActionMessages( vr.getWarnings().toArray(new ValidatorWarning[] {}))); } if (vr.getErrors().size() > 0) { ValidatorError ve = vr.getErrors().get(0); log.debug("Got error: " + ve); getStrutsDelegate().saveMessages(request, RhnValidationHelper.validatorErrorToActionErrors(ve)); success = false; } else { needsSnapshot = true; if (log.isDebugEnabled()) { log.debug("entitling worked?: " + s.hasEntitlement(e)); } log.debug("adding entitlement success msg"); if (ConfigDefaults.get().isDocAvailable()) { createSuccessMessage(request, "system.entitle.added." + e.getLabel(), s.getId().toString()); } else { createSuccessMessage(request, "system.entitle.added." + e.getLabel() + ".nodoc", s.getId().toString()); } } } else if ((daForm.get(e.getLabel()) == null || daForm.get(e.getLabel()).equals(Boolean.FALSE)) && s.hasEntitlement(e)) { log.debug("removing entitlement: " + e); systemEntitlementManager.removeServerEntitlement(s, e); needsSnapshot = true; } } if (needsSnapshot) { String message = LocalizationService.getInstance().getMessage("snapshots.entitlements"); SystemManager.snapshotServer(s, message); } return success; }
Example 14
Source File: ActivationKeyDetailsAction.java From uyuni with GNU General Public License v2.0 | 4 votes |
private ActivationKey update(DynaActionForm form, RequestContext context) { User user = context.getCurrentUser(); ActivationKeyManager manager = ActivationKeyManager.getInstance(); ActivationKey key = context.lookupAndBindActivationKey(); String[] selected = (String[])form.get(SELECTED_ENTS); List<String> selectedList = Arrays.asList(selected); if (selected != null) { manager.removeEntitlements(key, entitlementsToRemove(user.getOrg(), selectedList)); manager.addEntitlements(key, selectedList); } if (StringUtils.isBlank(form.getString(DESCRIPTION))) { key.setNote(ActivationKeyFactory.DEFAULT_DESCRIPTION); } else { key.setNote(form.getString(DESCRIPTION)); } key.setBaseChannel(lookupChannel(form, user)); updateChildChannels(form, key); key.getToken().setOrgDefault(Boolean.TRUE.equals(form.get(ORG_DEFAULT))); Long usageLimit = null; if (!StringUtils.isBlank(form.getString(USAGE_LIMIT))) { usageLimit = Long.valueOf(form.getString(USAGE_LIMIT)); } key.setDeployConfigs(Boolean.TRUE.equals(form.get(AUTO_DEPLOY))); key.setUsageLimit(usageLimit); // Set the contact method long contactId = (Long) form.get(CONTACT_METHOD); if (contactId != key.getContactMethod().getId()) { key.setContactMethod(ServerFactory.findContactMethodById(contactId)); } ActivationKeyFactory.save(key); ActionMessages msg = new ActionMessages(); addToMessage(msg, "activation-key.java.modified", key.getNote()); String newKey = form.getString(KEY); if (StringUtils.isBlank(newKey)) { newKey = ActivationKeyFactory.generateKey(); } newKey = ActivationKey.sanitize(key.getOrg(), newKey); String enteredKey = form.getString(KEY); if (!enteredKey.equals(key.getKey()) && !newKey.equals(key.getKey())) { manager.changeKey(newKey, key, user); if (!StringUtils.isBlank(enteredKey) && !enteredKey.equals(key.getKey())) { addToMessage(msg, "activation-key.java.org_prefixed", key, newKey); } } getStrutsDelegate().saveMessages(context.getRequest(), msg); return key; }
Example 15
Source File: SystemDetailsEditAction.java From spacewalk with GNU General Public License v2.0 | 4 votes |
/** * Proccesses the system details edit form * @param request to add messages to. * @param daForm DynaActionForm to be processed * @param user User submitting the form * @param s Server whose details are being update * @return true if the submission process didnot produce any errors. */ private boolean processSubmission(HttpServletRequest request, DynaActionForm daForm, User user, Server s) { boolean success = true; s.setName(daForm.getString(NAME)); s.setDescription(daForm.getString(DESCRIPTION)); // Process the base entitlement selection. Need to // do this first because the below code is effected by the // base entitlement chosen String selectedEnt = daForm.getString(BASE_ENTITLEMENT); Entitlement base = EntitlementManager.getByName(selectedEnt); log.debug("base: " + base); if (base != null) { s.setBaseEntitlement(base); } else if (selectedEnt.equals(UNENTITLE)) { SystemManager.removeAllServerEntitlements(s.getId()); } // setup location information if (s.getLocation() == null) { Location l = new Location(); s.setLocation(l); l.setServer(s); } s.getLocation().setCountry(daForm.getString(COUNTRY)); s.getLocation().setAddress1(daForm.getString(ADDRESS_ONE)); s.getLocation().setAddress2(daForm.getString(ADDRESS_TWO)); s.getLocation().setState(daForm.getString(STATE)); s.getLocation().setCity(daForm.getString(CITY)); s.getLocation().setBuilding(daForm.getString(BUILDING)); s.getLocation().setRoom(daForm.getString(ROOM)); s.getLocation().setRack(daForm.getString(RACK)); /* If the server does not have a Base Entitlement * the user should not be updating these values * no matter what the form they are submitting looks * like */ if (s.getBaseEntitlement() != null) { if (Boolean.TRUE.equals(daForm.get(AUTO_UPDATE)) && s.getAutoUpdate().equals("N")) { // only set it if it has changed s.setAutoUpdate("Y"); ActionManager.scheduleAllErrataUpdate(user, s, new Date()); createSuccessMessage(request, "sdc.details.edit.propertieschangedupdate", s.getName()); } else if (daForm.get(AUTO_UPDATE) == null) { s.setAutoUpdate("N"); } boolean flag = Boolean.TRUE.equals( daForm.get(UserServerPreferenceId.INCLUDE_IN_DAILY_SUMMARY)); UserManager.setUserServerPreferenceValue(user, s, UserServerPreferenceId.INCLUDE_IN_DAILY_SUMMARY, flag); flag = Boolean.TRUE.equals( daForm.get(UserServerPreferenceId.RECEIVE_NOTIFICATIONS)); UserManager.setUserServerPreferenceValue(user, s, UserServerPreferenceId.RECEIVE_NOTIFICATIONS, flag); if (log.isDebugEnabled()) { log.debug("looping on addon entitlements"); } Set validAddons = user.getOrg().getValidAddOnEntitlementsForOrg(); success = checkVirtEntitlements(request, daForm, validAddons, s, user); } return success; }
Example 16
Source File: ErrataSearchAction.java From uyuni with GNU General Public License v2.0 | 4 votes |
protected ActionForward doExecute(HttpServletRequest request, ActionMapping mapping, DynaActionForm form) throws MalformedURLException, XmlRpcFault { RequestContext ctx = new RequestContext(request); String search = form.getString(SEARCH_STR); String viewmode = form.getString(VIEW_MODE); Boolean fineGrained = (Boolean)form.get(FINE_GRAINED); List searchOptions = new ArrayList(); // setup the option list for select box (view_mode). addOption(searchOptions, OPT_ALL_FIELDS, OPT_ALL_FIELDS); addOption(searchOptions, OPT_ADVISORY, OPT_ADVISORY); addOption(searchOptions, OPT_PKG_NAME, OPT_PKG_NAME); addOption(searchOptions, OPT_CVE, OPT_CVE); request.setAttribute(SEARCH_STR, search); request.setAttribute(VIEW_MODE, viewmode); request.setAttribute(SEARCH_OPT, searchOptions); request.setAttribute(FINE_GRAINED, fineGrained); // Process the dates, default the start date to yesterday // and end date to today. Calendar today = Calendar.getInstance(); today.setTime(new Date()); Calendar yesterday = Calendar.getInstance(); yesterday.setTime(new Date()); yesterday.add(Calendar.DAY_OF_YEAR, -1); DateRangePicker picker = new DateRangePicker(form, request, yesterday.getTime(), today.getTime(), DatePicker.YEAR_RANGE_NEGATIVE, "erratasearch.jsp.start_date", "erratasearch.jsp.end_date"); DatePickerResults dates = null; Boolean dateSearch = getOptionIssueDateSearch(request); /* * If search/viewmode aren't null, we need to search and set * pageList to the resulting DataResult. * * NOTE: There is a special case when called from rhn/Search.do * (header search bar) * that we will be coming into this action and running the * performSearch on the first run through this action, i.e. * we'll never have been called with search being blank, * therefore normal setup of the form vars will not have happened. */ if (!StringUtils.isBlank(search) || dateSearch) { // If doing a dateSearch use the DatePicker values from the // request params otherwise use the defaults. dates = picker.processDatePickers(dateSearch, true); if (LOG.isDebugEnabled()) { LOG.debug("search is NOT blank"); LOG.debug("Issue Start Date = " + dates.getStart().getDate()); LOG.debug("End Start Date = " + dates.getEnd().getDate()); } List results = performSearch(request, ctx.getWebSession().getId(), search, viewmode, form); request.setAttribute(RequestContext.PAGE_LIST, results != null ? results : Collections.EMPTY_LIST); } else { // Reset info on date pickers dates = picker.processDatePickers(false, true); if (LOG.isDebugEnabled()) { LOG.debug("search is blank"); LOG.debug("Issue Start Date = " + dates.getStart().getDate()); LOG.debug("End Start Date = " + dates.getEnd().getDate()); } request.setAttribute(RequestContext.PAGE_LIST, Collections.EMPTY_LIST); } ActionMessages dateErrors = dates.getErrors(); addErrors(request, dateErrors); return mapping.findForward(RhnHelper.DEFAULT_FORWARD); }
Example 17
Source File: KickstartSoftwareEditAction.java From uyuni with GNU General Public License v2.0 | 4 votes |
/** * {@inheritDoc} */ @Override protected ValidatorError processFormValues(HttpServletRequest request, DynaActionForm form, BaseKickstartCommand cmdIn) { KickstartData ksdata = cmdIn.getKickstartData(); boolean wasRhel5OrLess = ksdata.isRHEL5OrLess(); RequestContext ctx = new RequestContext(request); KickstartTreeUpdateType updateType = null; KickstartableTree tree = null; Long channelId = (Long) form.get(CHANNEL); String url = form.getString(URL); Org org = ctx.getCurrentUser().getOrg(); if (form.get(USE_NEWEST_KSTREE_PARAM) != null) { updateType = KickstartTreeUpdateType.ALL; tree = KickstartFactory.getNewestTree(updateType, channelId, org); } else if (form.get(USE_NEWEST_RH_KSTREE_PARAM) != null) { updateType = KickstartTreeUpdateType.RED_HAT; tree = KickstartFactory.getNewestTree(updateType, channelId, org); } else { updateType = KickstartTreeUpdateType.NONE; tree = KickstartFactory.lookupKickstartTreeByIdAndOrg( (Long) form.get(TREE), org); } if (tree == null) { return new ValidatorError("kickstart.softwaredit.tree.required"); } Distro distro = CobblerProfileCommand.getCobblerDistroForVirtType(tree, ksdata.getKickstartDefaults().getVirtualizationType(), ctx.getCurrentUser()); if (distro == null) { return new ValidatorError("kickstart.cobbler.profile.invalidtreeforvirt"); } KickstartEditCommand cmd = (KickstartEditCommand) cmdIn; ValidatorError ve = cmd.updateKickstartableTree(channelId, org.getId(), tree.getId(), url); if (ve == null) { String [] repos = form.getStrings(SELECTED_REPOS); cmd.updateRepos(repos); } ksdata.setRealUpdateType(updateType); // need to reset auth field if (wasRhel5OrLess != cmd.getKickstartData().isRHEL5OrLess()) { KickstartCommand auth = cmd.getKickstartData().getCommand("auth"); if (auth != null) { auth.setArguments(cmd.getKickstartData().defaultAuthArgs()); } } CobblerProfileEditCommand cpec = new CobblerProfileEditCommand(ksdata, ctx.getCurrentUser()); cpec.store(); // Process the selected child channels String[] childchannelIds = request.getParameterValues(CHILD_CHANNELS); cmd.updateChildChannels(childchannelIds); if (ve != null) { return ve; } return null; }
Example 18
Source File: EditSlaveAction.java From spacewalk with GNU General Public License v2.0 | 4 votes |
private Long updateSlaveDetails(ActionMapping mapping, DynaActionForm dynaForm, HttpServletRequest request, HttpServletResponse response) throws Exception { Long sid = null; sid = (Long) dynaForm.get(IssSlave.ID); boolean isNew = (IssSlave.NEW_SLAVE_ID == sid); IssSlave slave = null; if (isNew) { slave = new IssSlave(); } else { slave = IssFactory.lookupSlaveById(sid); } String fqdn = dynaForm.getString(IssSlave.SLAVE); slave.setSlave(fqdn); Boolean enabled = (Boolean) dynaForm.get(IssSlave.ENABLED); if (enabled == null) { enabled = Boolean.FALSE; } slave.setEnabled(enabled ? "Y" : "N"); Boolean allowAll = (Boolean) dynaForm.get(IssSlave.ALLOWED_ALL_ORGS); if (allowAll == null) { allowAll = Boolean.FALSE; } slave.setAllowAllOrgs(allowAll ? "Y" : "N"); if (isNew) { IssFactory.save(slave); slave = (IssSlave) IssFactory.reload(slave); sid = slave.getId(); } ActionMessages msg = new ActionMessages(); if (isNew) { msg.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage( "message.iss_slave_created", fqdn)); } else { msg.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage( "message.iss_slave_updated", fqdn)); } getStrutsDelegate().saveMessages(request, msg); return sid; }
Example 19
Source File: ScheduleKickstartWizardAction.java From uyuni with GNU General Public License v2.0 | 4 votes |
protected boolean validateBondSelections(DynaActionForm form, RequestContext ctx) { if (!StringUtils.isBlank(form.getString(HIDDEN_BOND_SLAVE_INTERFACES))) { form.set(BOND_SLAVE_INTERFACES, form.getString(HIDDEN_BOND_SLAVE_INTERFACES).split(",")); } String[] slaves = (String[]) form.get(BOND_SLAVE_INTERFACES); ActionErrors errors = new ActionErrors(); // if we are trying to create a bond but have not specified a name or at // least one slave interface if (form.getString(BOND_TYPE).equals(CREATE_BOND_VALUE) && (StringUtils.isBlank(form.getString(BOND_INTERFACE)) || slaves.length < 1 || StringUtils.isBlank(slaves[0]))) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage( "kickstart.bond.not.defined.jsp")); } final String ipv4addressPattern = "^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." + "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." + "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." + "([01]?\\d\\d?|2[0-4]\\d|25[0-5])$"; /* * The IPv6 address regex was created by Stephen Ryan at Dartware * and taken from this forum: http://forums.intermapper.com/viewtopic.php?t=452 * It is licenced under a Creative Commons Attribution-ShareAlike 3.0 Unported * License. We can freely use it in (even in commercial products) as long as * we attribute its creation to him, so don't remove this message. */ final String ipv6addressPattern = "^(((?=(?>.*?::)(?!.*::)))(::)?([0-9A-" + "F]{1,4}::?){0,5}|([0-9A-F]{1,4}:){6})(\\2([0-9A-F]{1,4}(::?|$))" + "{0,2}|((25[0-5]|(2[0-4]|1\\d|[1-9])?\\d)(\\.|$)){4}|[0-9A-F]{1," + "4}:[0-9A-F]{1,4})(?<![^:]:|\\.)\\z"; if (form.getString(BOND_STATIC).equals(STATIC_BOND_VALUE)) { String address = form.getString(BOND_IP_ADDRESS); String netmask = form.getString(BOND_NETMASK); String gateway = form.getString(BOND_GATEWAY); if (!address.matches(ipv4addressPattern) && !address.matches(ipv6addressPattern)) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage( "kickstart.bond.bad.ip.address.jsp")); } if (!netmask.matches(ipv4addressPattern) && !netmask.matches(ipv6addressPattern)) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage( "kickstart.bond.bad.netmask.jsp")); } if (!gateway.matches(ipv4addressPattern) && !gateway.matches(ipv6addressPattern)) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage( "kickstart.bond.bad.ip.address.jsp")); } } if (errors.size() > 0) { addErrors(ctx.getRequest(), errors); return false; } return true; }
Example 20
Source File: RhnMockStrutsTestCase.java From uyuni with GNU General Public License v2.0 | 3 votes |
/** * Verify that the attribute "pageList" is setup properly: * * 1) not null * 2) size greater than 0 * 3) first item in list is instance of classIn * @param attribName name of list in Request attributes * @param classIn to check first item against. */ protected void verifyFormList(String attribName, Class classIn) { DynaActionForm form = (DynaActionForm) getActionForm(); List dr = (List) form.get(attribName); assertNotNull(dr); assertTrue(dr.size() > 0); assertEquals(classIn, dr.iterator().next().getClass()); }