Skip to content
Permalink
Browse files

[JENKINS-26781] set $class in submitted form to use descriptor.id, so…

… descriptor can be retrieved by ID, which _may_ not be clazz.name
  • Loading branch information...
ndeloof committed Feb 4, 2015
1 parent a944634 commit 094d1cf723885e2c62e4acecb8fb0a32b45ff8ab
Showing with 14 additions and 13 deletions.
  1. +13 −12 core/src/main/java/hudson/model/Descriptor.java
  2. +1 −1 core/src/main/resources/lib/form/class-entry.jelly
@@ -1,18 +1,18 @@
/*
* The MIT License
*
*
* Copyright (c) 2004-2011, Sun Microsystems, Inc., Kohsuke Kawaguchi
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -117,7 +117,7 @@
* {@link Descriptor} defines addition to the standard Java reflection
* and provides reflective information about its corresponding {@link Describable}.
* These are primarily used by tag libraries to
* keep the Jelly scripts concise.
* keep the Jelly scripts concise.
*
* @author Kohsuke Kawaguchi
* @see Describable
@@ -222,7 +222,7 @@ public Descriptor getItemTypeDescriptorOrDie() {
/**
* Help file redirect, keyed by the field name to the path.
*
* @see #getHelpFile(String)
* @see #getHelpFile(String)
*/
private transient final Map<String,HelpRedirect> helpRedirect = new HashMap<String,HelpRedirect>();

@@ -260,7 +260,7 @@ protected Descriptor(Class<? extends T> clazz) {
* Infers the type of the corresponding {@link Describable} from the outer class.
* This version works when you follow the common convention, where a descriptor
* is written as the static nested class of the describable class.
*
*
* @since 1.278
*/
protected Descriptor() {
@@ -309,7 +309,7 @@ protected Descriptor() {
*
* @return
* Stick to valid Java identifier character, plus '.', which had to be allowed for historical reasons.
*
*
* @since 1.391
*/
public String getId() {
@@ -510,7 +510,7 @@ public final String getJsonSafeClassName() {
/**
* @deprecated
* Implement {@link #newInstance(StaplerRequest, JSONObject)} method instead.
* Deprecated as of 1.145.
* Deprecated as of 1.145.
*/
public T newInstance(StaplerRequest req) throws FormException {
throw new UnsupportedOperationException(getClass()+" should implement newInstance(StaplerRequest,JSONObject)");
@@ -656,7 +656,7 @@ public String getHelpFile(Klass<?> clazz, String fieldName) {
}
return null;
}

/**
* Tells Jenkins that the help file for the field 'fieldName' is defined in the help file for
* the 'fieldNameToRedirectTo' in the 'owner' class.
@@ -711,7 +711,7 @@ public String getConfigPage() {
public String getGlobalConfigPage() {
return getViewPage(clazz, getPossibleViewNames("global"), null);
}

private String getViewPage(Class<?> clazz, String pageName, String defaultValue) {
return getViewPage(clazz,Collections.singleton(pageName),defaultValue);
}
@@ -918,6 +918,7 @@ private URL getStaticHelpUrl(Klass<?> c, String suffix) {
if (d != null) {
items.add(d.newInstance(req, jo));
}
LOGGER.warning("Received unexpected formData for descriptor " + kind);
}
}

@@ -929,7 +930,7 @@ private URL getStaticHelpUrl(Klass<?> c, String suffix) {
*/
public static @CheckForNull <T extends Descriptor> T find(Collection<? extends T> list, String className) {
for (T d : list) {
if(d.getClass().getName().equals(className))
if(d.clazz.getName().equals(className))
return d;
}
// Since we introduced Descriptor.getId(), it is a preferred method of identifying descriptor by a string.
@@ -34,7 +34,7 @@ THE SOFTWARE.
structured form submission. Mutually exclusive with clazz.
</st:attribute>
</st:documentation>
<j:set var="clazz" value="${attrs.clazz ?: attrs.descriptor.clazz.name}" />
<j:set var="clazz" value="${attrs.clazz ?: attrs.descriptor.id}" />
<f:invisibleEntry>
<!-- Legacy: Remove once plugins have been staged onto $class -->
<input type="hidden" name="stapler-class" value="${clazz}" />

0 comments on commit 094d1cf

Please sign in to comment.
You can’t perform that action at this time.