提交 62850d86 编写于 作者: K kohsuke

moving the abort permission check to Task from Executable so that the same...

moving the abort permission check to Task from Executable so that the same logic can be used to cancel items in the queue.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@6582 71c3de6d-444a-0410-be80-ed276b4c234a
上级 ce759e4b
......@@ -586,10 +586,6 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
}
}
public void checkAbortPermission() {
getParent().getACL().checkPermission(AbstractProject.ABORT);
}
//
//
// web methods
......
......@@ -507,6 +507,10 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
return newBuild();
}
public void checkAbortPermission() {
checkPermission(AbstractProject.ABORT);
}
/**
* Gets the {@link Resource} that represents the workspace of this project.
*/
......
......@@ -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;
......
......@@ -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;
......
......@@ -20,9 +20,9 @@
<tr>
<td class="pane" colspan="2" style="white-space: normal;">
${%Hudson is going to shut down. No further builds will be performed.}
<l:isAdmin>
<j:if test="${h.checkPermission(app.ADMINISTER)">
<a href="${rootURL}/cancelQuietDown">(${%cancel})</a>
</l:isAdmin>
</j:if>
</td>
</tr>
</j:if>
......@@ -34,9 +34,9 @@
</a>
</td>
<td class="pane" width="16" align="center" valign="middle">
<l:isAdmin>
<j:if test="${item.hasCancelPermission()}">
<a href="${rootURL}/${item.task.url}cancelQueue"><img src="${imagesURL}/16x16/stop.gif" alt="cancel this build" /></a>
</l:isAdmin>
</j:if>
</td>
</tr>
</j:forEach>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册