diff --git a/libreplan-business/src/main/java/org/libreplan/business/common/VersionInformation.java b/libreplan-business/src/main/java/org/libreplan/business/common/VersionInformation.java index 6abf8f22a..4a4c6a5a5 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/common/VersionInformation.java +++ b/libreplan-business/src/main/java/org/libreplan/business/common/VersionInformation.java @@ -67,10 +67,10 @@ public class VersionInformation { private VersionInformation() { } - private void loadNewVersionFromURL(boolean allowToGatherUsageStatsEnabled) { + private void loadNewVersionFromURL() { lastVersionCachedDate = new Date(); try { - URL url = getURL(allowToGatherUsageStatsEnabled); + URL url = getURL(); String lastVersion = (new BufferedReader(new InputStreamReader( url.openStream()))).readLine(); if (projectVersion != null && lastVersion != null) { @@ -86,13 +86,8 @@ public class VersionInformation { } } - private URL getURL(boolean allowToGatherUsageStatsEnabled) - throws MalformedURLException { + private URL getURL() throws MalformedURLException { String url = LIBREPLAN_VERSION_URL; - if (allowToGatherUsageStatsEnabled) { - url += "?" + LIBREPLAN_USAGE_STATS_PARAM + "=1"; - url += "&" + LIBREPLAN_VERSION_PARAM + "=" + projectVersion; - } return new URL(url); } @@ -113,18 +108,14 @@ public class VersionInformation { public void setProjectVersion(String argVersion) { projectVersion = argVersion; - loadNewVersionFromURL(false); + loadNewVersionFromURL(); } /** * Returns true if a new version of the project is published. - * - * @param isCheckNewVersionEnabled - * If true LibrePlan developers will process the requests to check - * the new versions to generate usages statistics */ - public static boolean isNewVersionAvailable(boolean isCheckNewVersionEnabled) { - return singleton.checkIsNewVersionAvailable(isCheckNewVersionEnabled); + public static boolean isNewVersionAvailable() { + return singleton.checkIsNewVersionAvailable(); } /** @@ -132,15 +123,28 @@ public class VersionInformation { * Otherwise, during one day it returns the cached value. And it checks it * again after that time. */ - private boolean checkIsNewVersionAvailable(boolean isCheckNewVersionEnabled) { + private boolean checkIsNewVersionAvailable() { if ( !newVersionCached ) { long oneDayLater = lastVersionCachedDate.getTime() + DELAY_TO_CHECK_URL; if ( oneDayLater < new Date().getTime() ) { - loadNewVersionFromURL(isCheckNewVersionEnabled); + loadNewVersionFromURL(); } } return newVersionCached; } + public static String getLastVersion() { + String lastVersion = ""; + try { + URL url = new URL(LIBREPLAN_VERSION_URL); + lastVersion = (new BufferedReader(new InputStreamReader( + url.openStream()))).readLine(); + } catch (MalformedURLException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + return lastVersion; + } } diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/common/TemplateController.java b/libreplan-webapp/src/main/java/org/libreplan/web/common/TemplateController.java index 90f85d5ff..67cae5955 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/common/TemplateController.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/common/TemplateController.java @@ -49,6 +49,7 @@ import org.zkoss.zul.Window; * Controller to manage UI operations from main template. * * @author Manuel Rego Casasnovas + * @author Vova Perebykivskiy */ @org.springframework.stereotype.Component @Scope(BeanDefinition.SCOPE_PROTOTYPE) @@ -66,13 +67,14 @@ public class TemplateController extends GenericForwardComposer { private IMessagesForUser windowMessages; + private String lastVersionNumber = ""; + @Override public void doAfterCompose(Component comp) throws Exception { super.doAfterCompose(comp); - if (templateModel.isScenariosVisible()) { + if ( templateModel.isScenariosVisible() ) { window = (Window) comp.getFellow("changeScenarioWindow"); - windowMessages = new MessagesForUser(window - .getFellow("messagesContainer")); + windowMessages = new MessagesForUser(window.getFellow("messagesContainer")); } } @@ -219,11 +221,14 @@ public class TemplateController extends GenericForwardComposer { } public boolean isNewVersionAvailable() { - if ( !templateModel.isCheckNewVersionEnabled() ) { - return false; + if ( templateModel.isCheckNewVersionEnabled() ) { + if ( VersionInformation.isNewVersionAvailable() ){ + lastVersionNumber = VersionInformation.getLastVersion(); + return true; + } } - return VersionInformation.isNewVersionAvailable(templateModel.isCheckNewVersionEnabled()); + return false; } public String getUsername() { @@ -234,4 +239,9 @@ public class TemplateController extends GenericForwardComposer { return user.getUsername(); } + public String getVersionMessage(){ + return _("A new version ") + lastVersionNumber + + _(" of LibrePlan is available. Please check next link for more information:"); + } + } diff --git a/libreplan-webapp/src/main/resources/i18n/keys.pot b/libreplan-webapp/src/main/resources/i18n/keys.pot index 2255f22e5..252da9e64 100644 --- a/libreplan-webapp/src/main/resources/i18n/keys.pot +++ b/libreplan-webapp/src/main/resources/i18n/keys.pot @@ -5596,10 +5596,12 @@ msgstr "" msgid "Original" msgstr "" -#: libreplan-webapp/src/main/webapp/common/layout/template.zul:179 -msgid "" -"A new version of LibrePlan is available. Please check next link for more " -"information:" +#: libreplan-webapp/src/main/java/org/libreplan/web/common/TemplateController.java:245 +msgid "A new version " +msgstr "" + +#: libreplan-webapp/src/main/java/org/libreplan/web/common/TemplateController.java:246 +msgid " of LibrePlan is available. Please check next link for more information:" msgstr "" #: libreplan-webapp/src/main/webapp/planner/stretches_function.zul:31 @@ -9311,4 +9313,4 @@ msgstr "" #: libreplan-webapp/src/main/java/org/libreplan/web/common/ConfigurationController.java:247 msgid "Check fields" -msgstr "" \ No newline at end of file +msgstr "" diff --git a/libreplan-webapp/src/main/webapp/common/layout/template.zul b/libreplan-webapp/src/main/webapp/common/layout/template.zul index b87865311..a5449c3a9 100644 --- a/libreplan-webapp/src/main/webapp/common/layout/template.zul +++ b/libreplan-webapp/src/main/webapp/common/layout/template.zul @@ -25,14 +25,14 @@ + signature="java.lang.Boolean isDefaultPasswordsControl()"?> - - + idOutsourcing = templateController.getIdOutsourcingUser(); idReports = templateController.getIdReportsUser(); ]]> - - +
+ + + + - - - - + + + + + + + + + + + - - - - - - - - - - - + - + + + + + - - - - - + + + + +
+ ${i18n:_('scenario')}: +
+
+ ${i18n:_('user')}: ${templateCtrl.username} + [${i18n:_('Log out')}] +
+
+
+
+
- - - - -
- ${i18n:_('scenario')}: -
-
- ${i18n:_('user')}: ${templateCtrl.username} - [${i18n:_('Log out')}] -
-
-
-
-
+
+ + + + + +
- - - - - -
- ${i18n:_("The admin's account password remains the default one. This is insecure")}. - [${i18n:_('Change the password')}] -
-
- -
- [wsreader] - [wswriter] - [wssubcontracting] - [manager] - [hresources] - [outsourcing] - [reports] - - ${i18n:_('default password was not changed')}. - -
-
- -
- - ${i18n:_("A new version of LibrePlan is available. Please check next link for more information:")} - http://www.libreplan.com/download/ - -
-
-
- - -
-
-
- -
-