From 0dd472ccabfbb60fcdfa191c59e65e12f4587b31 Mon Sep 17 00:00:00 2001 From: kohsuke Date: Thu, 18 Dec 2008 17:27:55 +0000 Subject: [PATCH] Always display the restart button on the update center page, if the current environment supports it. (report) git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@13720 71c3de6d-444a-0410-be80-ed276b4c234a --- .../main/java/hudson/lifecycle/Lifecycle.java | 16 ++++++++++++---- core/src/main/java/hudson/model/Hudson.java | 4 ++++ .../src/main/java/hudson/model/UpdateCenter.java | 8 +------- .../HudsonUpgradeJob/RestartNeeded/status.jelly | 7 ------- .../RestartNeeded/status.properties | 1 - .../RestartNeeded/status_fr.properties | 2 -- .../RestartNeeded/status_ja.properties | 2 -- .../hudson/model/UpdateCenter/index.jelly | 11 ++++++++--- 8 files changed, 25 insertions(+), 26 deletions(-) delete mode 100644 core/src/main/resources/hudson/model/UpdateCenter/HudsonUpgradeJob/RestartNeeded/status.jelly delete mode 100644 core/src/main/resources/hudson/model/UpdateCenter/HudsonUpgradeJob/RestartNeeded/status.properties delete mode 100644 core/src/main/resources/hudson/model/UpdateCenter/HudsonUpgradeJob/RestartNeeded/status_fr.properties delete mode 100644 core/src/main/resources/hudson/model/UpdateCenter/HudsonUpgradeJob/RestartNeeded/status_ja.properties diff --git a/core/src/main/java/hudson/lifecycle/Lifecycle.java b/core/src/main/java/hudson/lifecycle/Lifecycle.java index 84bceee975..6f77bd51ef 100644 --- a/core/src/main/java/hudson/lifecycle/Lifecycle.java +++ b/core/src/main/java/hudson/lifecycle/Lifecycle.java @@ -83,18 +83,19 @@ public abstract class Lifecycle implements ExtensionPoint { public boolean canRewriteHudsonWar() { // if we don't know where hudson.war is, it's impossible to replace. if(getHudsonWar()==null) return false; + return isOverridden("rewriteHudsonWar",File.class); + } + private boolean isOverridden(String methodName, Class... types) { // the rewriteHudsonWar method isn't overridden. try { - return !getClass().getMethod("rewriteHudsonWar",File.class).equals( - Lifecycle.class.getMethod("rewriteHudsonWar",File.class)); + return !getClass().getMethod(methodName, types).equals( + Lifecycle.class.getMethod(methodName,types)); } catch (NoSuchMethodException e) { throw new AssertionError(e); } } - - /** * If this life cycle supports a restart of Hudson, do so. * Otherwise, throw {@link UnsupportedOperationException}, @@ -111,4 +112,11 @@ public abstract class Lifecycle implements ExtensionPoint { public void restart() throws IOException, InterruptedException { throw new UnsupportedOperationException(); } + + /** + * Can the {@link #restart()} method restart Hudson? + */ + public boolean canRestart() { + return isOverridden("restart"); + } } diff --git a/core/src/main/java/hudson/model/Hudson.java b/core/src/main/java/hudson/model/Hudson.java index 6dcfc5dfe5..b6a96507bf 100644 --- a/core/src/main/java/hudson/model/Hudson.java +++ b/core/src/main/java/hudson/model/Hudson.java @@ -1162,6 +1162,10 @@ public final class Hudson extends View implements ItemGroup, Node, HudsonFilter.AUTHENTICATION_MANAGER.setDelegate(sc.manager); HudsonFilter.USER_DETAILS_SERVICE_PROXY.setDelegate(sc.userDetails); } + + public Lifecycle getLifecycle() { + return Lifecycle.get(); + } /** * Returns the root {@link ACL}. diff --git a/core/src/main/java/hudson/model/UpdateCenter.java b/core/src/main/java/hudson/model/UpdateCenter.java index fff7bba36d..34a030def8 100644 --- a/core/src/main/java/hudson/model/UpdateCenter.java +++ b/core/src/main/java/hudson/model/UpdateCenter.java @@ -838,19 +838,13 @@ public class UpdateCenter extends AbstractModelObject { } protected void onSuccess() { - status = new RestartNeeded(); + status = new Success(); } @Override protected void replace(File dst, File src) throws IOException { Lifecycle.get().rewriteHudsonWar(src); } - - /** - * Indicates that the upgrade needs a restart. - */ - public class RestartNeeded extends InstallationStatus { - } } /** diff --git a/core/src/main/resources/hudson/model/UpdateCenter/HudsonUpgradeJob/RestartNeeded/status.jelly b/core/src/main/resources/hudson/model/UpdateCenter/HudsonUpgradeJob/RestartNeeded/status.jelly deleted file mode 100644 index 5970c240b9..0000000000 --- a/core/src/main/resources/hudson/model/UpdateCenter/HudsonUpgradeJob/RestartNeeded/status.jelly +++ /dev/null @@ -1,7 +0,0 @@ - - - ${%blurb} -
- - -
\ No newline at end of file diff --git a/core/src/main/resources/hudson/model/UpdateCenter/HudsonUpgradeJob/RestartNeeded/status.properties b/core/src/main/resources/hudson/model/UpdateCenter/HudsonUpgradeJob/RestartNeeded/status.properties deleted file mode 100644 index f130d800f3..0000000000 --- a/core/src/main/resources/hudson/model/UpdateCenter/HudsonUpgradeJob/RestartNeeded/status.properties +++ /dev/null @@ -1 +0,0 @@ -blurb=Hudson needs to be restarted for this change to take effect. \ No newline at end of file diff --git a/core/src/main/resources/hudson/model/UpdateCenter/HudsonUpgradeJob/RestartNeeded/status_fr.properties b/core/src/main/resources/hudson/model/UpdateCenter/HudsonUpgradeJob/RestartNeeded/status_fr.properties deleted file mode 100644 index 87b2747cbb..0000000000 --- a/core/src/main/resources/hudson/model/UpdateCenter/HudsonUpgradeJob/RestartNeeded/status_fr.properties +++ /dev/null @@ -1,2 +0,0 @@ -blurb=Hudson doit être redémarré pour que ce changement prenne effet. -Restart\ Now=Redémarrer maintenant diff --git a/core/src/main/resources/hudson/model/UpdateCenter/HudsonUpgradeJob/RestartNeeded/status_ja.properties b/core/src/main/resources/hudson/model/UpdateCenter/HudsonUpgradeJob/RestartNeeded/status_ja.properties deleted file mode 100644 index 2bbbafe7f7..0000000000 --- a/core/src/main/resources/hudson/model/UpdateCenter/HudsonUpgradeJob/RestartNeeded/status_ja.properties +++ /dev/null @@ -1,2 +0,0 @@ -blurb=\u5909\u66F4\u3092\u53CD\u6620\u3059\u308B\u306B\u306F\u518D\u8D77\u52D5\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002 -Restart\ Now=\u4ECA\u3059\u3050\u518D\u8D77\u52D5 \ No newline at end of file diff --git a/core/src/main/resources/hudson/model/UpdateCenter/index.jelly b/core/src/main/resources/hudson/model/UpdateCenter/index.jelly index cec772a076..e84848eba4 100644 --- a/core/src/main/resources/hudson/model/UpdateCenter/index.jelly +++ b/core/src/main/resources/hudson/model/UpdateCenter/index.jelly @@ -7,9 +7,14 @@

${%Installing Plugins/Upgrades}

-

- ${%warning} -

+
+

+ ${%warning} + + + +

+
-- GitLab