Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-26781] lookup descriptor by ID, then by class if explicitly set
to match some specific use cases.
  • Loading branch information
ndeloof committed Feb 4, 2015
1 parent a944634 commit 8881703
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
15 changes: 10 additions & 5 deletions core/src/main/java/hudson/model/Descriptor.java
Expand Up @@ -909,14 +909,19 @@ List<T> newInstancesFromHeteroList(StaplerRequest req, Object formData,
if (formData!=null) {
for (Object o : JSONArray.fromObject(formData)) {
JSONObject jo = (JSONObject)o;
String kind = jo.optString("$class", null);
if (kind == null) {
// Legacy: Remove once plugins have been staged onto $class
kind = jo.getString("kind");
Descriptor<T> d = null;
String kind = jo.optString("kind", null);
if (kind != null) {
d = find(descriptors, kind);
}
if (d == null) {
kind = jo.getString("$class");
d = find(descriptors, kind);
}
Descriptor<T> d = find(descriptors, kind);
if (d != null) {
items.add(d.newInstance(req, jo));
} else {
LOGGER.warning("Received unexpected formData for descriptor " + kind);
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions core/src/main/resources/lib/form/class-entry.jelly
Expand Up @@ -36,12 +36,11 @@ THE SOFTWARE.
</st:documentation>
<j:set var="clazz" value="${attrs.clazz ?: attrs.descriptor.clazz.name}" />
<f:invisibleEntry>
<!-- Legacy: Remove once plugins have been staged onto $class -->
<input type="hidden" name="stapler-class" value="${clazz}" />
<!-- Legacy: Remove once plugins have been staged onto $class -->
<j:if test="${attrs.descriptor != null}">
<input type="hidden" name="kind" value="${attrs.descriptor.id}" />
</j:if>
<!-- Legacy: Remove once plugins have been staged onto $class -->
<input type="hidden" name="stapler-class" value="${clazz}" />
<input type="hidden" name="$class" value="${clazz}" />
</f:invisibleEntry>
</j:jelly>
</j:jelly>

0 comments on commit 8881703

Please sign in to comment.