Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIXED JENKINS-18680] Update members of a ListView using a regular li…
…stener, not View.onJobRenamed which does not work with folders.
- Loading branch information
Showing
11 changed files
with
97 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ | |
import hudson.Util; | ||
import hudson.diagnosis.OldDataMonitor; | ||
import hudson.model.Descriptor.FormException; | ||
import hudson.model.listeners.ItemListener; | ||
import hudson.util.CaseInsensitiveComparator; | ||
import hudson.util.DescribableList; | ||
import hudson.util.FormValidation; | ||
|
@@ -37,13 +38,18 @@ | |
|
||
import java.io.IOException; | ||
import java.util.*; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
import java.util.regex.Pattern; | ||
import java.util.regex.PatternSyntaxException; | ||
|
||
import javax.annotation.concurrent.GuardedBy; | ||
import javax.servlet.ServletException; | ||
import jenkins.model.Jenkins; | ||
|
||
import net.sf.json.JSONObject; | ||
import org.kohsuke.accmod.Restricted; | ||
import org.kohsuke.accmod.restrictions.NoExternalUse; | ||
|
||
import org.kohsuke.stapler.DataBoundConstructor; | ||
import org.kohsuke.stapler.HttpResponse; | ||
|
@@ -302,12 +308,6 @@ public HttpResponse doRemoveJobFromView(@QueryParameter String name) throws IOEx | |
return HttpResponses.ok(); | ||
} | ||
|
||
@Override | ||
public synchronized void onJobRenamed(Item item, String oldName, String newName) { | ||
if(jobNames.remove(oldName) && newName!=null) | ||
jobNames.add(newName); | ||
} | ||
|
||
/** | ||
* Handles the configuration submission. | ||
* | ||
|
@@ -387,4 +387,56 @@ public FormValidation doCheckIncludeRegex( @QueryParameter String value ) throws | |
public static List<ListViewColumn> getDefaultColumns() { | ||
return ListViewColumn.createDefaultInitialColumnList(); | ||
} | ||
|
||
@Restricted(NoExternalUse.class) | ||
@Extension public static final class Listener extends ItemListener { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jglick
Author
Member
|
||
@Override public void onLocationChanged(Item item, String oldFullName, String newFullName) { | ||
for (Item g : Jenkins.getInstance().getAllItems()) { | ||
if (g instanceof ViewGroup) { | ||
ViewGroup vg = (ViewGroup) g; | ||
for (View v : vg.getViews()) { | ||
if (v instanceof ListView) { | ||
ListView lv = (ListView) v; | ||
synchronized (lv) { | ||
Set<String> oldJobNames = new HashSet<String>(lv.jobNames); | ||
lv.jobNames.clear(); | ||
for (String oldName : oldJobNames) { | ||
lv.jobNames.add(Items.computeRelativeNamesAfterRenaming(oldFullName, newFullName, oldName, vg.getItemGroup())); | ||
} | ||
if (!oldJobNames.equals(lv.jobNames)) { | ||
try { | ||
g.save(); | ||
This comment has been minimized.
Sorry, something went wrong.
olivergondza
Member
|
||
} catch (IOException x) { | ||
Logger.getLogger(ListView.class.getName()).log(Level.WARNING, null, x); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
@Override public void onDeleted(Item item) { | ||
for (Item g : Jenkins.getInstance().getAllItems()) { | ||
if (g instanceof ViewGroup) { | ||
ViewGroup vg = (ViewGroup) g; | ||
for (View v : vg.getViews()) { | ||
if (v instanceof ListView) { | ||
ListView lv = (ListView) v; | ||
synchronized (lv) { | ||
if (lv.jobNames.remove(item.getRelativeNameFrom(vg.getItemGroup()))) { | ||
try { | ||
g.save(); | ||
} catch (IOException x) { | ||
Logger.getLogger(ListView.class.getName()).log(Level.WARNING, null, x); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From reading the code this seems to miss an
ACL.impersonate
, otherwise it won't get everything in case the actions are initiated by a low-privilege user (missingView.READ
).