Skip to content

Commit

Permalink
adjust method name to avoid conflict with old implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
mawinter69 committed Apr 9, 2024
1 parent eb9afd1 commit 0e06d65
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
5 changes: 0 additions & 5 deletions core/src/main/java/hudson/model/AbstractProject.java
Original file line number Diff line number Diff line change
Expand Up @@ -1940,11 +1940,6 @@ public boolean isApplicable(Descriptor descriptor) {
return true;
}

@Restricted(DoNotUse.class)
public FormValidation doCheckDisplayNameOrNull(@AncestorInPath AbstractProject project, @QueryParameter String value) {
return Jenkins.get().doCheckDisplayName(value, project);
}

@Restricted(DoNotUse.class)
public FormValidation doCheckAssignedLabelString(@AncestorInPath AbstractProject<?, ?> project,
@QueryParameter String value) {
Expand Down
9 changes: 5 additions & 4 deletions core/src/main/java/jenkins/model/Jenkins.java
Original file line number Diff line number Diff line change
Expand Up @@ -5276,7 +5276,7 @@ public View getStaplerFallback() {
*/
boolean isDisplayNameUnique(ItemGroup<?> itemGroup, String displayName, String currentJobName) {

Collection<TopLevelItem> itemCollection = itemGroup.getAllItems(TopLevelItem.class);
Collection<TopLevelItem> itemCollection = (Collection<TopLevelItem>) itemGroup.getItems(t -> t instanceof TopLevelItem);

// if there are a lot of projects, we'll have to store their
// display names in a HashSet or something for a quick check
Expand Down Expand Up @@ -5324,7 +5324,7 @@ else if (item.getName().equals(currentJobName)) {
* @param displayName The display name to test
* @param jobName The name of the job the user is configuring
*
* @deprecated use {@link Jenkins#doCheckDisplayName(String, Item)}
* @deprecated use {@link TopLevelItemDescriptor#doCheckDisplayNameOrNull(TopLevelItem, String)}
*/
@Deprecated
public FormValidation doCheckDisplayName(@QueryParameter String displayName,
Expand All @@ -5350,8 +5350,9 @@ else if (!isDisplayNameUnique(this, displayName, jobName)) {
* @param displayName The display name to test
* @param item The item to check for duplicates
*/
public FormValidation doCheckDisplayName(String displayName,
Item item) {
@Restricted(NoExternalUse.class)
public FormValidation checkDisplayName(String displayName,
TopLevelItem item) {
displayName = displayName.trim();
String jobName = item.getName();

Expand Down
6 changes: 3 additions & 3 deletions test/src/test/java/jenkins/model/JenkinsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public void testDoCheckDisplayNameUnique() throws Exception {
p.setDisplayName("displayName");

Jenkins jenkins = Jenkins.get();
FormValidation v = jenkins.doCheckDisplayName("1displayName", curProject);
FormValidation v = jenkins.checkDisplayName("1displayName", curProject);
assertEquals(FormValidation.ok(), v);
}

Expand All @@ -297,7 +297,7 @@ public void testDoCheckDisplayNameSameAsDisplayName() throws Exception {
p.setDisplayName(displayName);

Jenkins jenkins = Jenkins.get();
FormValidation v = jenkins.doCheckDisplayName(displayName, curProject);
FormValidation v = jenkins.checkDisplayName(displayName, curProject);
assertEquals(FormValidation.Kind.WARNING, v.kind);
}

Expand All @@ -313,7 +313,7 @@ public void testDoCheckDisplayNameSameAsJobName() throws Exception {
p.setDisplayName(displayName);

Jenkins jenkins = Jenkins.get();
FormValidation v = jenkins.doCheckDisplayName(jobName, curProject);
FormValidation v = jenkins.checkDisplayName(jobName, curProject);
assertEquals(FormValidation.Kind.WARNING, v.kind);
}

Expand Down

0 comments on commit 0e06d65

Please sign in to comment.