diff --git a/src/main/java/org/jenkinsci/plugins/workflow/job/AbstractItemDescriptor.java b/src/main/java/org/jenkinsci/plugins/workflow/job/AbstractItemDescriptor.java new file mode 100644 index 00000000..10113e98 --- /dev/null +++ b/src/main/java/org/jenkinsci/plugins/workflow/job/AbstractItemDescriptor.java @@ -0,0 +1,15 @@ +package org.jenkinsci.plugins.workflow.job; + +import hudson.util.FormValidation; +import jenkins.model.Jenkins; +import org.kohsuke.accmod.Restricted; +import org.kohsuke.accmod.restrictions.NoExternalUse; +import org.kohsuke.stapler.AncestorInPath; +import org.kohsuke.stapler.QueryParameter; + +public interface AbstractItemDescriptor { + @Restricted(NoExternalUse.class) + public default FormValidation doCheckDisplayNameOrNull(@AncestorInPath WorkflowJob job, @QueryParameter String value) { + return Jenkins.get().doCheckDisplayName(value, job.getName()); + } +} diff --git a/src/main/java/org/jenkinsci/plugins/workflow/job/WorkflowJob.java b/src/main/java/org/jenkinsci/plugins/workflow/job/WorkflowJob.java index 409ef336..076163e4 100644 --- a/src/main/java/org/jenkinsci/plugins/workflow/job/WorkflowJob.java +++ b/src/main/java/org/jenkinsci/plugins/workflow/job/WorkflowJob.java @@ -69,6 +69,7 @@ import hudson.triggers.TriggerDescriptor; import hudson.util.AlternativeUiTextProvider; import hudson.util.DescribableList; +import hudson.util.FormValidation; import hudson.widgets.HistoryWidget; import java.io.File; import java.io.IOException; @@ -98,12 +99,14 @@ import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.DoNotUse; import org.kohsuke.accmod.restrictions.NoExternalUse; +import org.kohsuke.stapler.AncestorInPath; +import org.kohsuke.stapler.QueryParameter; import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerResponse; import org.kohsuke.stapler.export.Exported; @SuppressWarnings({"unchecked", "rawtypes"}) -public final class WorkflowJob extends Job implements LazyBuildMixIn.LazyLoadingJob, ParameterizedJobMixIn.ParameterizedJob, TopLevelItem, Queue.FlyweightTask, SCMTriggerItem, BlockableResume { +public final class WorkflowJob extends Job implements LazyBuildMixIn.LazyLoadingJob, ParameterizedJobMixIn.ParameterizedJob, TopLevelItem, Queue.FlyweightTask, SCMTriggerItem, BlockableResume, AbstractItemDescriptor { private static final Logger LOGGER = Logger.getLogger(WorkflowJob.class.getName()); @@ -193,7 +196,6 @@ public void setDefinition(FlowDefinition definition) { getTriggersJobProperty().startTriggers(Items.currentlyUpdatingByXml()); } - @Override public void addProperty(JobProperty jobProp) throws IOException { super.addProperty(jobProp); if (jobProp instanceof PipelineTriggersJobProperty) { @@ -254,6 +256,7 @@ public void setDefinition(FlowDefinition definition) { return buildMixIn.getEstimatedDurationCandidates(); } + @Override protected HistoryWidget createHistoryWidget() { return buildMixIn.createHistoryWidget(); }