diff --git a/core/src/main/java/hudson/model/AbstractBuild.java b/core/src/main/java/hudson/model/AbstractBuild.java index 572a3c6f42bbf11b0e0b61c42a0a268f0bed83da..3e949090015851801ec5b71364a2173c72a890e9 100644 --- a/core/src/main/java/hudson/model/AbstractBuild.java +++ b/core/src/main/java/hudson/model/AbstractBuild.java @@ -586,10 +586,6 @@ public abstract class AbstractBuild

,R extends Abs } } - public void checkAbortPermission() { - getParent().getACL().checkPermission(AbstractProject.ABORT); - } - // // // web methods diff --git a/core/src/main/java/hudson/model/AbstractProject.java b/core/src/main/java/hudson/model/AbstractProject.java index 4f3103b2cfd2dc17908adea1c66c9132ad151333..58c21b49a5d07a92140e24f42dc5686de352700b 100644 --- a/core/src/main/java/hudson/model/AbstractProject.java +++ b/core/src/main/java/hudson/model/AbstractProject.java @@ -507,6 +507,10 @@ public abstract class AbstractProject

,R extends A return newBuild(); } + public void checkAbortPermission() { + checkPermission(AbstractProject.ABORT); + } + /** * Gets the {@link Resource} that represents the workspace of this project. */ diff --git a/core/src/main/java/hudson/model/Executor.java b/core/src/main/java/hudson/model/Executor.java index 71c8b32f6b6dae2aee73b9285252115a9995bb05..327dcdbc9357d9cf3711c11af7c8daf017789a8b 100644 --- a/core/src/main/java/hudson/model/Executor.java +++ b/core/src/main/java/hudson/model/Executor.java @@ -158,7 +158,7 @@ public class Executor extends Thread implements ModelObject { * Stops the current build. */ public void doStop( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException { - executable.checkAbortPermission(); + executable.getParent().checkAbortPermission(); interrupt(); rsp.forwardToPreviousPage(req); } @@ -168,7 +168,7 @@ public class Executor extends Thread implements ModelObject { */ public boolean hasStopPermission() { try { - executable.checkAbortPermission(); + executable.getParent().checkAbortPermission(); return true; } catch (AccessDeniedException e) { return false; diff --git a/core/src/main/java/hudson/model/Queue.java b/core/src/main/java/hudson/model/Queue.java index 84d60ed26cf9a0a15a6d2fea474dbfc714188aea..30bcb3124011b2f0ceeae26cc78a491120ae9bcd 100644 --- a/core/src/main/java/hudson/model/Queue.java +++ b/core/src/main/java/hudson/model/Queue.java @@ -579,6 +579,14 @@ public class Queue extends ResourceController { * Creates {@link Executable}, which performs the actual execution of the task. */ Executable createExecutable() throws IOException; + + /** + * Checks the permission to see if the current user can abort this executable. + * Returns normally from this method if it's OK. + * + * @throws AccessDeniedException if the permission is not granted. + */ + void checkAbortPermission(); } public interface Executable extends Runnable { @@ -591,14 +599,6 @@ public class Queue extends ResourceController { * Called by {@link Executor} to perform the task */ void run(); - - /** - * Checks the permission to see if the current user can abort this executable. - * Returns normally from this method if it's OK. - * - * @throws AccessDeniedException if the permission is not granted. - */ - void checkAbortPermission(); } /** @@ -693,6 +693,15 @@ public class Queue extends ResourceController { return "???"; } + public boolean hasCancelPermission() { + try { + task.checkAbortPermission(); + return true; + } catch (AccessDeniedException e) { + return false; + } + } + public int compareTo(Item that) { int r = this.timestamp.getTime().compareTo(that.timestamp.getTime()); if(r!=0) return r; diff --git a/core/src/main/resources/lib/hudson/queue.jelly b/core/src/main/resources/lib/hudson/queue.jelly index 324d9617e3682e7fc46e0c2db604309f6973ca3e..fa867a5d9da59e6e705f5c5dacf3c0d81e6d56c9 100644 --- a/core/src/main/resources/lib/hudson/queue.jelly +++ b/core/src/main/resources/lib/hudson/queue.jelly @@ -20,9 +20,9 @@ ${%Hudson is going to shut down. No further builds will be performed.} - + (${%cancel}) - + @@ -34,9 +34,9 @@ - + cancel this build - +