Skip to content
Permalink
Browse files

[FIXED JENKINS-20522] Proper usage of TopLevelItemDescriptor.

  • Loading branch information...
jglick committed Dec 5, 2014
1 parent 0c51c06 commit fb754c204acebc22c08111e5c4aa38f53e7d858a
@@ -2,9 +2,9 @@
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.395</version>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.424</version>
</parent>

<artifactId>view-job-filters</artifactId>
@@ -1,13 +1,13 @@
package hudson.views;

import hudson.DescriptorExtensionList;
import hudson.Extension;
import hudson.model.Descriptor;
import hudson.model.DescriptorVisibilityFilter;
import hudson.model.ItemGroup;
import hudson.model.Items;
import hudson.model.TopLevelItem;
import hudson.model.TopLevelItemDescriptor;

import java.util.ArrayList;
import java.util.List;

import org.kohsuke.stapler.DataBoundConstructor;
@@ -29,20 +29,17 @@ public JobTypeFilter(String jobType, String includeExcludeTypeString) {

public TopLevelItemDescriptor getJobType() {
for (TopLevelItemDescriptor type: Items.all()) {
if (matches(type)) {
if (type.getId().equals(jobType)) {
return type;
}
}
return null;
}

private boolean matches(TopLevelItemDescriptor type) {
return type.clazz.getName().equals(jobType);
}

@Override
protected boolean matches(TopLevelItem item) {
return matches(item.getDescriptor());
TopLevelItemDescriptor d = getJobType();
return d != null && d.testInstance(item);
}

@Extension
@@ -51,13 +48,8 @@ protected boolean matches(TopLevelItem item) {
public String getDisplayName() {
return "Job Type Filter";
}
public List<TopLevelItemDescriptor> getJobTypes() {
List<TopLevelItemDescriptor> types = new ArrayList<TopLevelItemDescriptor>();
DescriptorExtensionList<TopLevelItem, TopLevelItemDescriptor> all = Items.all();
for (TopLevelItemDescriptor one: all) {
types.add(one);
}
return types;
public List<TopLevelItemDescriptor> getJobTypes(ItemGroup<?> context) {
return DescriptorVisibilityFilter.apply(context, Items.all());
}
}
}
@@ -21,8 +21,7 @@
if (item instanceof MavenModuleSet) {
MavenModuleSet set = (MavenModuleSet) item;

List<BuildWrapper> wrappers = set.getBuildWrappersList().toList();
for (BuildWrapper wrapper : wrappers) {
for (BuildWrapper wrapper : set.getBuildWrappers()) {
if (wrapper instanceof M2ExtraStepsWrapper) {
M2ExtraStepsWrapper mwrap = (M2ExtraStepsWrapper) wrapper;
MavenValuesHelper.addValues(values, mwrap
@@ -3,8 +3,8 @@
xmlns:i="jelly:fmt" xmlns:p="/lib/hudson/project">
<f:entry title="${%Job Type}" field="jobType">
<select name="jobType" class="setting-input">
<j:forEach var="type" items="${descriptor.getJobTypes()}">
<f:option value="${type.clazz.name}" selected="${instance.jobType == type}">${type.displayName}</f:option>
<j:forEach var="type" items="${descriptor.getJobTypes(it.ownerItemGroup)}">
<f:option value="${type.id}" selected="${instance.jobType == type}">${type.displayName}</f:option>
</j:forEach>
</select>
</f:entry>

0 comments on commit fb754c2

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