public Boolean resolve(String name) { for (LabelAtom a : labels) if (a.getName().equals(name)) return true; return false; } });
/** * Returns the label atom of the given name. * @return non-null iff name is non-null */ public @Nullable LabelAtom getLabelAtom(@CheckForNull String name) { if (name==null) return null; while(true) { Label l = labels.get(name); if(l!=null) return (LabelAtom)l; // non-existent LabelAtom la = new LabelAtom(name); if (labels.putIfAbsent(name, la)==null) la.load(); } }
/** * If the label contains 'unsafe' chars, escape them. */ @Override public String getExpression() { return escape(name); }
public void load() { XmlFile file = getConfigFile(); if(file.exists()) { try { file.unmarshal(this); } catch (IOException e) { LOGGER.log(Level.WARNING, "Failed to load "+file, e); } } properties.setOwner(this); updateTransientActions(); }
/** * Accepts the update to the node configuration. */ @RequirePOST public void doConfigSubmit( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException, FormException { final Jenkins app = Jenkins.getInstance(); app.checkPermission(Jenkins.ADMINISTER); properties.rebuild(req, req.getSubmittedForm(), getApplicablePropertyDescriptors()); this.description = req.getSubmittedForm().getString("description"); updateTransientActions(); save(); FormApply.success(".").generateResponse(req, rsp, null); }
if (l.isEmpty()) { for (LabelAtom a : l.listAtoms()) { if (a.isEmpty()) { LabelAtom nearest = LabelAtom.findNearest(a.getName()); return FormValidation.warning(Messages.AbstractProject_AssignedLabelString_NoMatch_DidYouMean(a.getName(),nearest.getDisplayName()));
/** * Gets the special label that represents this node itself. */ @Nonnull @WithBridgeMethods(Label.class) public LabelAtom getSelfLabel() { return LabelAtom.get(getNodeName()); }
public String buildLabelCheckBox(LabelAtom la, LabelAxis instance) { return jsstr("<input type='checkbox' name='values' json='%s' ", Functions.htmlAttributeEscape(la.getName())) +String.format("+has(%s)+",jsstr(la.getName())) +jsstr("/><label class='attach-previous'>%s (%s)</label>", la.getName(),la.getDescription()); // '${h.jsStringEscape('<input type="checkbox" name="values" json="'+h.htmlAttributeEscape(l.name)+'" ')}'+has("${h.jsStringEscape(l.name)}")+'${h.jsStringEscape('/><label class="attach-previous">'+l.name+' ('+l.description+')</label>')}' } }
/** * Returns projects that are tied on this node. */ public List<AbstractProject> getTiedJobs() { Node node = getNode(); return (node != null) ? node.getSelfLabel().getTiedJobs() : Collections.EMPTY_LIST; }
public static String escape(String name) { if (needsEscape(name)) return QuotedStringTokenizer.quote(name); return name; }
public void save() throws IOException { if(BulkChange.contains(this)) return; try { getConfigFile().write(this); SaveableListener.fireOnChange(this, getConfigFile()); } catch (IOException e) { LOGGER.log(Level.WARNING, "Failed to save "+getConfigFile(),e); } }
public NodeAssignmentAction(String label) { this.labelAtom = new LabelAtom(label); }
protected void updateTransientActions() { Vector<Action> ta = new Vector<Action>(); // add the config link if (!getApplicablePropertyDescriptors().isEmpty()) { // if there's no property descriptor, there's nothing interesting to configure. ta.add(new Action() { public String getIconFileName() { if (Hudson.getInstance().hasPermission(Hudson.ADMINISTER)) return "setting.gif"; else return null; } public String getDisplayName() { return "Configure"; } public String getUrlName() { return "configure"; } }); } for (LabelAtomProperty p : properties) ta.addAll(p.getActions(this)); transientActions = ta; }
public void setDescription(String description) throws IOException { this.description = description; save(); }
/** * Accepts the update to the node configuration. */ public void doConfigSubmit( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException, FormException { final Hudson app = Hudson.getInstance(); app.checkPermission(Hudson.ADMINISTER); properties.rebuild(req, req.getSubmittedForm(), getApplicablePropertyDescriptors()); updateTransientActions(); save(); // take the user back to the label top page. rsp.sendRedirect2("."); }
public void load() { XmlFile file = getConfigFile(); if(file.exists()) { try { file.unmarshal(this); } catch (IOException e) { LOGGER.log(Level.WARNING, "Failed to load "+file, e); } } properties.setOwner(this); updateTransientActions(); }
if (l.isEmpty()) { for (LabelAtom a : l.listAtoms()) { if (a.isEmpty()) { LabelAtom nearest = LabelAtom.findNearest(a.getName()); return FormValidation.warning(Messages.AbstractProject_AssignedLabelString_NoMatch_DidYouMean(a.getName(),nearest.getDisplayName()));