提交 23f4809e 编写于 作者: D Daniel Beck 提交者: Jesse Glick

[SECURITY-412] Simplify implementation as suggested by jglick

上级 eeb699ed
......@@ -3369,6 +3369,7 @@ public class Jenkins extends AbstractCIBase implements DirectlyModifiableTopLeve
*
* This first replaces "app" to {@link HudsonIsRestarting}
*/
@CLIMethod(name="restart")
public void doRestart(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, RestartNotSupportedException {
checkPermission(ADMINISTER);
if (req != null && req.getMethod().equals("GET")) {
......@@ -3376,20 +3377,13 @@ public class Jenkins extends AbstractCIBase implements DirectlyModifiableTopLeve
return;
}
if (req != null && req.getMethod().equals("POST")) {
if (req == null || req.getMethod().equals("POST")) {
restart();
}
rsp.sendRedirect2(".");
}
@CLIMethod(name="restart")
@Restricted(NoExternalUse.class)
public void cliRestart() throws RestartNotSupportedException {
checkPermission(ADMINISTER);
restart();
}
/**
* Queues up a restart of Jenkins for when there are no builds running, if we can.
*
......@@ -3397,25 +3391,19 @@ public class Jenkins extends AbstractCIBase implements DirectlyModifiableTopLeve
*
* @since 1.332
*/
@CLIMethod(name="safe-restart")
public HttpResponse doSafeRestart(StaplerRequest req) throws IOException, ServletException, RestartNotSupportedException {
checkPermission(ADMINISTER);
if (req != null && req.getMethod().equals("GET"))
return HttpResponses.forwardToView(this,"_safeRestart.jelly");
if (req != null && req.getMethod().equals("POST")) {
if (req == null || req.getMethod().equals("POST")) {
safeRestart();
}
return HttpResponses.redirectToDot();
}
@CLIMethod(name="safe-restart")
@Restricted(NoExternalUse.class)
public void cliSafeRestart() throws RestartNotSupportedException {
checkPermission(ADMINISTER);
safeRestart();
}
/**
* Performs a restart.
*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册