Simplify implementation as suggested by jglick
@@ -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.
*/
