/** * Gets the URL that this Descriptor is bound to, relative to the nearest {@link DescriptorByNameOwner}. * Since {@link Jenkins} is a {@link DescriptorByNameOwner}, there's always one such ancestor to any request. */ public String getDescriptorUrl() { return "descriptorByName/"+getId(); }
/** * Gets the class name nicely escaped to be usable as a key in the structured form submission. */ public final String getJsonSafeClassName() { return getId().replace('.','-'); }
/** * Finds a descriptor from a collection by its ID. * @param id should match {@link #getId} * @since 1.610 */ public static @CheckForNull <T extends Descriptor> T findById(Collection<? extends T> list, String id) { for (T d : list) { if(d.getId().equals(id)) return d; } return null; }
/** * Finds a descriptor by their {@link Descriptor#getId()}. * @param id Descriptor ID * @return If none is found, {@code null} is returned. */ @CheckForNull public Descriptor<T> findByName(String id) { for (Descriptor<T> d : this) if(d.getId().equals(id)) return d; return null; }
/** * Finds a descriptor by their {@link Descriptor#getId()}. * * If none is found, null is returned. */ public @CheckForNull D findByName(String id) { for (D d : this) if(d.getId().equals(id)) return d; return null; }
/** * Binds items in the collection to URL. */ public T getDynamic(String id) { // by ID for (T t : data) if(t.getDescriptor().getId().equals(id)) return t; // by position try { return data.get(Integer.parseInt(id)); } catch (NumberFormatException e) { // fall through } return null; }
protected XmlFile getConfigFile() { return new XmlFile(new File(Jenkins.getInstance().getRootDir(),getId()+".xml")); }
public String getHelpFile(Klass<?> clazz, String fieldName) { HelpRedirect r = helpRedirect.get(fieldName); if (r!=null) return r.resolve(); for (Klass<?> c : clazz.getAncestors()) { String page = "/descriptor/" + getId() + "/help"; String suffix; if(fieldName==null) { suffix=""; } else { page += '/'+fieldName; suffix='-'+fieldName; } try { if(Stapler.getCurrentRequest().getView(c,"help"+suffix)!=null) return page; } catch (IOException e) { throw new Error(e); } if(getStaticHelpUrl(c, suffix) !=null) return page; } return null; }
@Initializer(after=EXTENSIONS_AUGMENTED) public void verify() { Jenkins h = Jenkins.getInstance(); for (Descriptor d : h.getExtensionList(Descriptor.class)) { PluginWrapper p = h.getPluginManager().whichPlugin(d.getClass()); String id; try { id = d.getId(); } catch (Throwable t) { LOGGER.log(Level.SEVERE,MessageFormat.format("Descriptor {0} from plugin {1} with display name {2} reported an exception for ID", d, p == null ? "???" : p.getLongName(), d.getDisplayName()),t); problems.add(d); continue; } if (id==null) { LOGGER.severe(MessageFormat.format("Descriptor {0} from plugin {1} with display name {2} has null ID", d, p==null?"???":p.getLongName(), d.getDisplayName())); problems.add(d); } } }
/** * Convenience method to find a location to install a tool. * @param tool the tool being installed * @param node the computer on which to install the tool * @return {@link ToolInstallation#getHome} if specified, else a path within the local * Jenkins work area named according to {@link ToolInstallation#getName} * @since 1.310 */ protected final FilePath preferredLocation(ToolInstallation tool, Node node) { if (node == null) { throw new IllegalArgumentException("must pass non-null node"); } String home = Util.fixEmptyAndTrim(tool.getHome()); if (home == null) { home = sanitize(tool.getDescriptor().getId()) + File.separatorChar + sanitize(tool.getName()); } FilePath root = node.getRootPath(); if (root == null) { throw new IllegalArgumentException("Node " + node.getDisplayName() + " seems to be offline"); } return root.child("tools").child(home); }
/** * Gets the URL that this Descriptor is bound to, relative to the nearest * {@link DescriptorByNameOwner}. Since {@link Hudson} is a * {@link DescriptorByNameOwner}, there's always one such ancestor to any * request. */ public String getDescriptorUrl() { return "descriptorByName/" + getId(); }
/** * Gets the URL that this Descriptor is bound to, relative to the nearest {@link DescriptorByNameOwner}. * Since {@link Jenkins} is a {@link DescriptorByNameOwner}, there's always one such ancestor to any request. */ public String getDescriptorUrl() { return "descriptorByName/"+getId(); }
/** * Gets the URL that this Descriptor is bound to, relative to the nearest {@link DescriptorByNameOwner}. * Since {@link Hudson} is a {@link DescriptorByNameOwner}, there's always one such ancestor to any request. */ public String getDescriptorUrl() { return "descriptorByName/"+getId(); }
/** * Finds a descriptor by their {@link Descriptor#getId()}. * * If none is found, null is returned. */ public Descriptor<T> findByName(String id) { for (Descriptor<T> d : this) if(d.getId().equals(id)) return d; return null; }
/** * Gets the class name nicely escaped to be usable as a key in the structured form submission. */ public final String getJsonSafeClassName() { return getId().replace('.','-'); }
/** * Finds a descriptor by their {@link Descriptor#getId()}. * * If none is found, null is returned. */ public Descriptor<T> findByName(String id) { for (Descriptor<T> d : this) if(d.getId().equals(id)) return d; return null; }
/** * Finds a descriptor by their {@link Descriptor#getId()}. * @param id Descriptor ID * @return If none is found, {@code null} is returned. */ @CheckForNull public Descriptor<T> findByName(String id) { for (Descriptor<T> d : this) if(d.getId().equals(id)) return d; return null; }
/** * Finds a descriptor from a collection by its ID. * @param id should match {@link #getId} * @since 1.610 */ public static @CheckForNull <T extends Descriptor> T findById(Collection<? extends T> list, String id) { for (T d : list) { if(d.getId().equals(id)) return d; } return null; }
/** * Finds a descriptor by their {@link Descriptor#getId()}. * * If none is found, null is returned. */ public @CheckForNull D findByName(String id) { for (D d : this) if(d.getId().equals(id)) return d; return null; }