* Update: Support notification of updates that cannot be downloaded

due to "constraints". Add constraint checks for java version,
   router version, configuration, and base permissions. (ticket #1024)
This commit is contained in:
zzz
2013-09-20 18:56:54 +00:00
parent 26c8201e03
commit 0ae2d92fcd
5 changed files with 181 additions and 19 deletions

View File

@@ -74,6 +74,17 @@ public class NewsHelper extends ContentHelper {
return mgr.getUpdateAvailable(ROUTER_SIGNED);
}
/**
* Translated message about new version available but constrained
* @return null if none
* @since 0.9.9
*/
public static String updateConstraint() {
ConsoleUpdateManager mgr = ConsoleUpdateManager.getInstance();
if (mgr == null) return null;
return mgr.getUpdateConstraint(ROUTER_SIGNED, "");
}
/**
* Already downloaded but not installed version
* @return null if none
@@ -259,9 +270,20 @@ public class NewsHelper extends ContentHelper {
* @since 0.9.4 moved from NewsFetcher
*/
public static boolean dontInstall(RouterContext ctx) {
boolean disabled = ctx.getBooleanProperty(ConfigUpdateHandler.PROP_UPDATE_DISABLED);
if (disabled)
return true;
return isUpdateDisabled(ctx) || isBaseReadonly(ctx);
}
/**
* @since 0.9.9
*/
public static boolean isUpdateDisabled(RouterContext ctx) {
return ctx.getBooleanProperty(ConfigUpdateHandler.PROP_UPDATE_DISABLED);
}
/**
* @since 0.9.9
*/
public static boolean isBaseReadonly(RouterContext ctx) {
File test = new File(ctx.getBaseDir(), "history.txt");
boolean readonly = ((test.exists() && !test.canWrite()) || (!ctx.getBaseDir().canWrite()));
return readonly;

View File

@@ -678,7 +678,22 @@ public class SummaryHelper extends HelperBase {
buf.append(' ').append(_("Version {0}", dver));
buf.append("</b></h4>");
}
if ((updateAvailable() || unsignedUpdateAvailable()) &&
boolean avail = updateAvailable();
boolean unsignedAvail = unsignedUpdateAvailable();
String constraint = avail ? NewsHelper.updateConstraint() : null;
if (avail && constraint != null &&
!NewsHelper.isUpdateInProgress() &&
!_context.router().gracefulShutdownInProgress()) {
if (needSpace)
buf.append("<hr>");
else
needSpace = true;
buf.append("<h4><b>").append(_("Update available")).append(":<br>");
buf.append(_("Version {0}", getUpdateVersion())).append("<br>");
buf.append(constraint).append("</h4>");
avail = false;
}
if ((avail || unsignedAvail) &&
!NewsHelper.isUpdateInProgress() &&
!_context.router().gracefulShutdownInProgress() &&
_context.portMapper().getPort(PortMapper.SVC_HTTP_PROXY) > 0 && // assume using proxy for now
@@ -694,13 +709,13 @@ public class SummaryHelper extends HelperBase {
String uri = getRequestURI();
buf.append("<form action=\"").append(uri).append("\" method=\"POST\">\n");
buf.append("<input type=\"hidden\" name=\"updateNonce\" value=\"").append(nonce).append("\" >\n");
if (updateAvailable()) {
if (avail) {
buf.append("<button type=\"submit\" class=\"download\" name=\"updateAction\" value=\"signed\" >")
// Note to translators: parameter is a version, e.g. "0.8.4"
.append(_("Download {0} Update", getUpdateVersion()))
.append("</button><br>\n");
}
if (unsignedUpdateAvailable()) {
if (unsignedAvail) {
buf.append("<button type=\"submit\" class=\"download\" name=\"updateAction\" value=\"Unsigned\" >")
// Note to translators: parameter is a date and time, e.g. "02-Mar 20:34 UTC"
// <br> is optional, to help the browser make the lines even in the button