diff --git a/.travis.yml b/.travis.yml index 764b2334d4..41d8729532 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,6 +27,6 @@ after_success: - aws s3 --region us-east-1 cp --recursive s3://edalexdev/equella_artifacts/$TRAVIS_BRANCH/$TRAVIS_BUILD_NUMBER/ s3://edalexdev/equella_artifacts/$TRAVIS_BRANCH/latest/ env: global: - - secure: t1XK7R/R3+gYgJCL+YNFPfpew+QZXl5b7jFkfNOwKDG+gGEApZCrx5NNkA+anPbK4VLnmjGz4EgIItfsSOmEQL6W4jr1MiD6cQV8RV9tYHhPmfPiJy0aDWOgIWIxPtpzAcSvgkZzCheHxY8PGbTi+XStRMfF6/Iat6cN7erHcO9Ur3ri10uas01xPaJJC+naXZGx0JZDTRLmGc8GFzgOwaiIUWOzPZyqsqnBEytvyuJFGe1BUfVEvr4UUb/LBiH0UgpganncFy2WHX+CWT8VFemIoNCM7jAp5oKCTHWyEH72WzGGo6+RCnmJs3Loc+6IUT2M7qNhEm8+PmQwWL9d5ihb6OSnJG9u+Pmq88E+E0eOzZnhQ3XpRjI1CRYYOKi8RBPAjlGDYBMSOo0HRzDJnuU+ZdwdJCZ0x7a/2xCgpxA2YpH+FycGWQo9b+n5JYl++n7gfaJhVcbxrob5TfcgDyj4M3Mkr0bsAwueYG1hY9vFNq9wbgFXA5UPL/khJt9OtR3akEBnrx9lySK0tXtq7zj+KKit92Ty+EfhtEF29IHHHn/pyvFBzWjO1VqsRm+cnOIyY2nLz9D8SZGaaJy7elbXc+PLjd8eHSwX/dY7DyB4MO0td4E40H+Wwxy0pfZXW5x+tdo0UGLBb9i5OoLuKFcRjmj02WcIi6TqJ3EbNdQ= - - secure: fao/RBFgwO/kaxMGbAsR2xuQgnXebRSPgIrASx/W7ELrZoHB3Jvz5ES7danGYXfONUKaPCdqe1/JTm34aDrp/sER6CMYlz4LvlzzhxV+ajo1kFqgzaUWquzGtQ3STXu5BiPEITVqm4CYOZ8bB7yr3HnmPRBOPvJIG0xg3Cehwz0Ux8Yc/YFJbfpr9p97U+x+JJfa+g1sRRXTQHUPdTl3uBJOtk5shCWoDSJl0Axe1gJ37gNUnJOZUwL6Ejb2Hlv2CuxBjglIZ7mhJkOiL9ALbNDOsjp+Xx6ieSSEVAEmqtQdzAVO63GmXVBQcyWIrisgLzTRbMM0ZPtraUXgN6b44ijw6kS5miQvd0vDenFVailgyizjqO28n1xhYyX+uEqz+BMFS4VybTKSdZHjDHRHhFXK6oSqcmKN941X+LsGu7rWp5aVyu1hJjaKz3InjheZphILY7sbLEzoOckicH3TikliwxNEbUCFUOtkmutY+B3SVy9SNyoCW2vjhbiP9ZeXW0hxjG0SvJxOXzWJknY4cnpO7ee5UcBDYmlSdOlA192FO4UfyqgHrL5hVRCYKGB2xD+XHy+XYKFUV+VpWiiMQXCxV1FmRHeZlS144/07H+DIlkeUapLn7Cdj/NhDjSn9fXnSNbA/qbs9aIYm1Wx4pRoj0S2iVRe4FE6RFJWMgyk= + - secure: m/3VbdtVnnEb8J4MrEhH4w8ELHTu4yGPkHcLQ9WSVNnZ6PskuHvxxpsAVVHz9WKj/9WVI4RJdpv5iouj+gugYUOo2cRGcg9hW9He554fbRfudnkAzBLUV4an71vnoxbSTdc+doGNpyF4rt/jdgVDzpGEsgv61By8C+oPpPjZiXcnjPmuVUyPaJWaJpp9/BpQusAiRjFqcphWeHAAd5Gp76D7OhEGL+y8q4fWXsvN58kbDKMXzs8F3aGyZ0QIApHDdT4FdgVFrt2kjrw/4V8ZaB4poR/8slK1pbsiklY+oamXk+e0Xkwf/B23KEWZZObWlUGIZX40EuzVBSGGq1eLWE96SM+HXN39PYvGPSRJ2lGuGvAr1NSlFwFIukTpW58ZiOVsK/IDoahj1zmhr1xvPmoc6YceSpVqqh2g4UDWJU3mQwNnGwhfn2K/td4pDsazaWYhnm2DjW5e7a03uA5ccf4Cfb2AaqE5ED7hGnTifkQbnykaNXtVLyDVzHf44022FM6ldpEWP2yWrLUhKJ9yNMsmMeYYdWRj/itSdZ895hzXtFO4kcY4NR8MF+7njTx1rwFk1kTsLZ0OX6Z36LUvnVpisLxaRuiN+LGSoTRzPpzVDnGa3lL9TQw3eVbqEUuRDlg1rDOf42KNMhT6nttCwqTthKTewuXA9QuYV5VTuXs= + - secure: kUfo8ful+ObyD6zPttIxB5dHwCbvUhgZBhvb7cJQ+6xnqdI5WPnSDes2zYyPklh9+p7bt00v3vGLhNem719a3Me3Ju2QjTSZiOtLvZod3klZRokNsgDkJNjNRhtgflThSvcYUbclNZe9pyQ6lz1EOffbTSMJx09OcdkF/gN7B0xK04ha+pWyNb6lqPeKx6q44k+qVotflpFh56eiyNoC4VZ6MgF+N51A/dDQyJJpPhqWkIup7Q8uD2bzPWcz5PN4YBqezrwT4qxbdeejzQ+fwCIT0Ls7B59rivyDp7Esp35TamTbZLK24Je0/Lg/hsW5ybA3/PmFOU2QUdzc2YZ8aT6p9QQjr1F3EDRsyMYmqYUtuFI9KzROoNaQ21If1HoGXZkL83RvCuE36xTDOuLifVWNiEOdII2hb62lW2s/JBcSUS0BlFd2UoxsrPzohBF4gQjQTbWwV9HW+sdHxk20YpU4IG7pyEiQO2Hsuau/M9iCdp0lsgKo6My43kzQSGZTPgESNKWg+YKxy07mgptttErHuDyVrVq6qMMFX+OI8QmUb31GR5j0g3lTPrfpAYyL/Vzlg/T9b8BUc7WYWWL5P41TIb9WMIgmLtARsGkEz/fsa1Cb9tMiZ7jOQLRxq455f54tC55LzhgrO+2elFku8a/cbWXguHzyKf301qHoZGI= - NODE_JS_VERSION=8.11.3 diff --git a/Installer/build.sbt b/Installer/build.sbt index 4d3150af10..59c7184906 100644 --- a/Installer/build.sbt +++ b/Installer/build.sbt @@ -27,7 +27,7 @@ lazy val upgradeManager = LocalProject("UpgradeManager") installerZip := { val log = streams.value.log val ver = equellaVersion.value - val dirname = s"equella-installer-${ver.majorMinor}" + val dirname = s"equella-installer-${ver.semanticVersion}" val outZip = target.value / s"$dirname.zip" val serverData = baseDirectory.value / "data/server" val allServerFiles = serverData ** "*" pair (relativeTo(serverData), false) diff --git a/Source/Plugins/Core/com.equella.core/js/package.json b/Source/Plugins/Core/com.equella.core/js/package.json index fd4eafb868..120a5dc798 100644 --- a/Source/Plugins/Core/com.equella.core/js/package.json +++ b/Source/Plugins/Core/com.equella.core/js/package.json @@ -24,19 +24,20 @@ "bundleps:langbundle": "cross-env-shell \"purs bundle \"${npm_package_config_psglob}\" -m Tools.GenLangStrings --main Tools.GenLangStrings -o target/genlang.js\"" }, "dependencies": { - "@date-io/luxon": "1.3.5", + "@date-io/luxon": "1.3.7", "@material-ui/core": "3.9.3", "@material-ui/icons": "3.0.2", "@material-ui/lab": "3.0.0-alpha.30", "@material-ui/styles": "3.0.0-alpha.10", - "@tinymce/tinymce-react": "3.1.1", + "@tinymce/tinymce-react": "3.2.0", "axios": "0.19.0", "create-react-class": "15.6.3", "downshift": "2.2.3", "es6-object-assign": "1.1.0", - "history": "4.7.2", + "history": "4.9.0", "jspolyfill-array.prototype.find": "0.1.3", - "luxon": "1.11.4", + "luxon": "1.16.0", + "lodash": "4.17.11", "material-ui-pickers": "2.2.4", "oeq-cloudproviders": "git+https://github.com/apereo/openEQUELLA-cloudprovidersdk.git#32d958ddfff64ca748e7e1b2eae0f0487946a487", "parcel-bundler": "1.12.1", @@ -66,16 +67,17 @@ "license": "Apache-2.0", "devDependencies": { "@types/jest": "22.2.3", - "@types/luxon": "1.11.1", + "@types/luxon": "1.15.1", + "@types/lodash": "4.14.136", "@types/tinymce": "4.5.22", - "@types/node": "9.6.48", - "@types/react": "16.8.19", - "@types/react-autosuggest": "9.3.8", + "@types/node": "9.6.49", + "@types/react": "16.8.23", + "@types/react-autosuggest": "9.3.9", "@types/react-color": "2.17.0", "@types/react-dom": "16.8.4", "@types/react-redux": "5.0.21", - "@types/react-router": "5.0.1", - "@types/react-router-dom": "4.3.3", + "@types/react-router": "5.0.2", + "@types/react-router-dom": "4.3.4", "@types/react-swipeable-views": "0.12.2", "@types/redux-logger": "3.0.7", "@types/sprintf-js": "1.1.2", diff --git a/Source/Plugins/Core/com.equella.core/js/tsrc/components/AppBarQuery.tsx b/Source/Plugins/Core/com.equella.core/js/tsrc/components/AppBarQuery.tsx index dbc379eaf8..abd35f5a24 100644 --- a/Source/Plugins/Core/com.equella.core/js/tsrc/components/AppBarQuery.tsx +++ b/Source/Plugins/Core/com.equella.core/js/tsrc/components/AppBarQuery.tsx @@ -3,13 +3,16 @@ import { WithStyles, Icon, withStyles, Theme } from "@material-ui/core"; import { fade } from "@material-ui/core/styles/colorManipulator"; import { createStyles } from "@material-ui/core/styles"; import { commonString } from "../util/commonstrings"; +import { debounce } from "lodash"; interface AppBarQueryProps { onSearch?: (query?: string) => void; onChange: (query: string) => void; query: string; } - +interface AppBarQueryState { + searchText: string; +} const styles = (theme: Theme) => createStyles({ queryWrapper: { @@ -46,17 +49,39 @@ const styles = (theme: Theme) => }); class AppBarQuery extends React.Component< - AppBarQueryProps & WithStyles<"queryWrapper" | "queryIcon" | "queryField"> + AppBarQueryProps & WithStyles<"queryWrapper" | "queryIcon" | "queryField">, + AppBarQueryState > { constructor( props: AppBarQueryProps & WithStyles<"queryWrapper" | "queryIcon" | "queryField"> ) { super(props); + this.state = { + searchText: "" + }; } + // Do a search after user stops typing for 500 milliseconds. + // Purescript passes a concrete search function to onChange. + debouncedSearch = debounce(() => { + this.props.onChange(this.state.searchText); + }, 500); + + handleTextChange = (e: React.ChangeEvent) => { + this.setState( + { + searchText: e.target.value + }, + () => { + this.debouncedSearch(); + } + ); + }; + render() { - const { classes, onChange, query } = this.props; + const { classes } = this.props; + const { searchText } = this.state; return (
@@ -66,8 +91,8 @@ class AppBarQuery extends React.Component< type="text" aria-label={commonString.action.search} className={classes.queryField} - value={query} - onChange={e => onChange(e.target.value)} + value={searchText} + onChange={this.handleTextChange} />
); diff --git a/Source/Plugins/Core/com.equella.core/scalasrc/com/tle/web/api/wizard/WizardApi.scala b/Source/Plugins/Core/com.equella.core/scalasrc/com/tle/web/api/wizard/WizardApi.scala index 66e62eabb2..af2af88cd0 100644 --- a/Source/Plugins/Core/com.equella.core/scalasrc/com/tle/web/api/wizard/WizardApi.scala +++ b/Source/Plugins/Core/com.equella.core/scalasrc/com/tle/web/api/wizard/WizardApi.scala @@ -45,6 +45,7 @@ import javax.servlet.http.HttpServletRequest import javax.ws.rs._ import javax.ws.rs.core.Response.{ResponseBuilder, Status} import javax.ws.rs.core.{Context, Response, StreamingOutput, UriInfo} +import org.jboss.resteasy.annotations.cache.NoCache import scala.collection.JavaConverters._ import scala.concurrent.ExecutionContext.Implicits @@ -82,6 +83,7 @@ class WizardApi { } @GET + @NoCache @Path("state") def getState(@PathParam("wizid") wizid: String, @Context req: HttpServletRequest): ItemState = { withWizardState(wizid, req, false) { wsi => @@ -182,6 +184,7 @@ class WizardApi { } + @NoCache @GET @Path("provider/{providerId}/{serviceId}") def proxyGET(@PathParam("wizid") wizid: String, diff --git a/Source/Plugins/Core/com.equella.core/src/com/tle/core/qti/service/impl/QtiAssessmentResultServiceImpl.java b/Source/Plugins/Core/com.equella.core/src/com/tle/core/qti/service/impl/QtiAssessmentResultServiceImpl.java index 026ab57d4a..812c388905 100644 --- a/Source/Plugins/Core/com.equella.core/src/com/tle/core/qti/service/impl/QtiAssessmentResultServiceImpl.java +++ b/Source/Plugins/Core/com.equella.core/src/com/tle/core/qti/service/impl/QtiAssessmentResultServiceImpl.java @@ -65,7 +65,7 @@ @Singleton public class QtiAssessmentResultServiceImpl implements QtiAssessmentResultService { private static final URI URI_SOURCE = - URI.create("uri://equella/" + ApplicationVersion.get().getMmr()); + URI.create("uri://equella/" + ApplicationVersion.get().getSemanticVersion()); @Inject private QtiAssessmentResultDao dao; diff --git a/Source/Plugins/Core/com.equella.core/src/com/tle/web/institution/tab/HealthTab.java b/Source/Plugins/Core/com.equella.core/src/com/tle/web/institution/tab/HealthTab.java index 25bd42506d..0e204b47e0 100644 --- a/Source/Plugins/Core/com.equella.core/src/com/tle/web/institution/tab/HealthTab.java +++ b/Source/Plugins/Core/com.equella.core/src/com/tle/web/institution/tab/HealthTab.java @@ -273,7 +273,7 @@ public SectionResult renderHtml(RenderEventContext context) throws Exception { .getBody() .addReadyStatements( CHECK_VERSION, - version.getMmr(), + version.getSemanticVersion(), version.getCommit(), version.getDisplay(), VERSION_SERVER_URL, diff --git a/Source/Plugins/Core/com.equella.core/src/com/tle/web/resources/ResourcesService.java b/Source/Plugins/Core/com.equella.core/src/com/tle/web/resources/ResourcesService.java index 3739be0ed4..d5a07e822e 100644 --- a/Source/Plugins/Core/com.equella.core/src/com/tle/web/resources/ResourcesService.java +++ b/Source/Plugins/Core/com.equella.core/src/com/tle/web/resources/ResourcesService.java @@ -26,7 +26,7 @@ @SuppressWarnings("nls") @NonNullByDefault public class ResourcesService { - private static String baseUrl = "p/r/" + ApplicationVersion.get().getMmr() + '/'; + private static String baseUrl = "p/r/" + ApplicationVersion.get().getSemanticVersion() + '/'; private static Map renamed = ImmutableMap.builder() diff --git a/Source/Plugins/Core/com.equella.core/src/com/tle/web/template/section/FooterSection.java b/Source/Plugins/Core/com.equella.core/src/com/tle/web/template/section/FooterSection.java index cb7dbbbe0e..1ce94a4563 100644 --- a/Source/Plugins/Core/com.equella.core/src/com/tle/web/template/section/FooterSection.java +++ b/Source/Plugins/Core/com.equella.core/src/com/tle/web/template/section/FooterSection.java @@ -65,7 +65,8 @@ public SectionResult renderHtml(RenderEventContext context) { if (!guest) { Version version = ApplicationVersion.get(); model.setDisplayVersion(version.getDisplay()); - model.setFullVersion(MessageFormat.format("{0} {1}", version.getMmr(), version.getCommit())); + model.setFullVersion( + MessageFormat.format("{0} {1}", version.getSemanticVersion(), version.getCommit())); } model.setDisplayLinks(!guest); diff --git a/Source/Plugins/Core/com.equella.serverbase/src/com/tle/core/replicatedcache/impl/ReplicatedCacheServiceImpl.java b/Source/Plugins/Core/com.equella.serverbase/src/com/tle/core/replicatedcache/impl/ReplicatedCacheServiceImpl.java index 5376f82243..9cba3cff8d 100644 --- a/Source/Plugins/Core/com.equella.serverbase/src/com/tle/core/replicatedcache/impl/ReplicatedCacheServiceImpl.java +++ b/Source/Plugins/Core/com.equella.serverbase/src/com/tle/core/replicatedcache/impl/ReplicatedCacheServiceImpl.java @@ -51,9 +51,12 @@ import java.io.Serializable; import java.util.Date; import java.util.Iterator; +import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import javax.inject.Inject; import javax.inject.Singleton; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; @Singleton @NonNullByDefault @@ -71,6 +74,8 @@ public class ReplicatedCacheServiceImpl /** Caches identified by cacheId. */ private final Cache> caches = CacheBuilder.newBuilder().build(); + private static final Log LOGGER = LogFactory.getLog(ReplicatedCacheServiceImpl.class); + @Override public synchronized ReplicatedCache getCache( String cacheId, long maxLocalCacheSize, long ttl, TimeUnit ttlUnit) { @@ -144,15 +149,21 @@ public Optional> load(String key) @Override public synchronized Optional get(@NonNull String key) { checkNotNull(key); + if (zookeeperService.isCluster()) { + cache.refresh(CurrentInstitution.get()); + } - LoadingCache>> c = - cache.getIfPresent(CurrentInstitution.get()); - if (c != null) { + LoadingCache>> c; + try { + c = cache.get(CurrentInstitution.get()); Optional> op = c.getUnchecked(key); if (op.isPresent()) { V ev = op.get().getValue(); return Optional.fromNullable(ev); } + + } catch (ExecutionException e) { + LOGGER.error("Fail to access cache of institution " + CurrentInstitution.get()); } return Optional.absent(); } diff --git a/Source/Plugins/Core/com.equella.serverbase/src/com/tle/core/services/impl/ClusteredTaskServiceImpl.java b/Source/Plugins/Core/com.equella.serverbase/src/com/tle/core/services/impl/ClusteredTaskServiceImpl.java index 180fc6daf0..5f9ab4da50 100644 --- a/Source/Plugins/Core/com.equella.serverbase/src/com/tle/core/services/impl/ClusteredTaskServiceImpl.java +++ b/Source/Plugins/Core/com.equella.serverbase/src/com/tle/core/services/impl/ClusteredTaskServiceImpl.java @@ -130,7 +130,7 @@ public void init() { if (version.isDevelopment()) { prefix = "tasksdev/"; } else { - prefix = "tasks-" + version.getMmr() + '/'; + prefix = "tasks-" + version.getSemanticVersion() + '/'; } ZK_TASKPATH = prefix + ZK_TASKPATH; ZK_GLOBALTASKPATH = prefix + ZK_GLOBALTASKPATH; diff --git a/Source/Plugins/Platform/com.tle.platform.equella/src/com/dytech/edge/common/Version.java b/Source/Plugins/Platform/com.tle.platform.equella/src/com/dytech/edge/common/Version.java index d0e24468b4..8c006121bc 100644 --- a/Source/Plugins/Platform/com.tle.platform.equella/src/com/dytech/edge/common/Version.java +++ b/Source/Plugins/Platform/com.tle.platform.equella/src/com/dytech/edge/common/Version.java @@ -27,8 +27,8 @@ @SuppressWarnings("nls") public final class Version { - private final String mmr; // MMR = major.minor.revision - private final String display; + private final String displayName; + private final String semanticVersion; private final String commit; private boolean dev; @@ -49,17 +49,15 @@ public static Version load(Properties p) { if (p == null) { return new Version("dev" + new Random().nextInt(1000), "Development", "dev (dev)", true); } else { - return new Version( - p.getProperty("version.mmr"), - p.getProperty("version.display"), - p.getProperty("version.commit"), - false); + String displayName = p.getProperty("version.display"); + String semanticVersion = displayName.substring(0, displayName.indexOf("-")); + return new Version(semanticVersion, displayName, p.getProperty("version.commit"), false); } } - private Version(String mmr, String display, String commit, boolean dev) { - this.mmr = mmr; - this.display = display; + private Version(String semanticVersion, String displayName, String commit, boolean dev) { + this.semanticVersion = semanticVersion; + this.displayName = displayName; this.commit = commit; this.dev = dev; } @@ -72,16 +70,16 @@ public String getCommit() { return commit; } - public String getMmr() { - return mmr; + public String getSemanticVersion() { + return semanticVersion; } public String getDisplay() { - return display; + return displayName; } public String getFull() { - return MessageFormat.format("{0} ({1})", mmr, display); + return MessageFormat.format("{0} ({1})", semanticVersion, displayName); } /** @@ -111,11 +109,11 @@ public boolean greaterVersionThan(String otherVersion) { // Empty or non-digit this.version? Allow anything. Either way return // false. - if (Check.isEmpty(mmr) || !Character.isDigit(mmr.charAt(0))) { + if (Check.isEmpty(semanticVersion) || !Character.isDigit(semanticVersion.charAt(0))) { return false; } - return getMajorMinorValue(mmr) > getMajorMinorValue(otherVersion); + return getMajorMinorValue(semanticVersion) > getMajorMinorValue(otherVersion); } /** diff --git a/Source/Server/equellaserver/build.sbt b/Source/Server/equellaserver/build.sbt index 37f78df150..183e13f7cc 100644 --- a/Source/Server/equellaserver/build.sbt +++ b/Source/Server/equellaserver/build.sbt @@ -1,4 +1,6 @@ import Path.rebase +import java.time.LocalDate +import java.time.format.DateTimeFormatter javacOptions ++= Seq("-source", "1.8") @@ -18,7 +20,7 @@ val axis2Version = "1.6.2" val TomcatVersion = "8.5.41" val SwaggerVersion = "1.5.22" val RestEasyVersion = "3.5.0.Final" -val simpledbaVersion = "0.1.8-SNAPSHOT" +val simpledbaVersion = "0.1.9" val circeVersion = "0.11.1" val jsoupVersion = "1.11.3" val sttpVersion = "1.5.11" @@ -328,10 +330,11 @@ additionalPlugins := { } upgradeZip := { - val log = streams.value.log - val ver = equellaVersion.value + val log = streams.value.log + val ver = equellaVersion.value + var releaseDate = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")) val outZip - : File = target.value / s"tle-upgrade-${ver.majorMinor}.r${ver.commits} (${ver.majorMinor}-${ver.releaseType}).zip" + : File = target.value / s"tle-upgrade-${ver.major}.${ver.minor}.r${releaseDate} (${ver.semanticVersion}-${ver.releaseType}).zip" val plugVer = ver.fullVersion val zipFiles = Seq( assembly.value -> "equella-server.jar", diff --git a/Source/Tools/UpgradeInstallation/src/com/tle/upgrade/upgraders/UpgradeToEmbeddedTomcat.java b/Source/Tools/UpgradeInstallation/src/com/tle/upgrade/upgraders/UpgradeToEmbeddedTomcat.java index 70ada367ce..951c6a7abc 100644 --- a/Source/Tools/UpgradeInstallation/src/com/tle/upgrade/upgraders/UpgradeToEmbeddedTomcat.java +++ b/Source/Tools/UpgradeInstallation/src/com/tle/upgrade/upgraders/UpgradeToEmbeddedTomcat.java @@ -197,9 +197,10 @@ public void upgrade(UpgradeResult result, File tleInstallDir) throws Exception { private File getUpgradeZip(Path installPath, File versionProps) throws ConfigurationException { final PropertiesConfiguration props = new PropertiesConfiguration(versionProps); - final String mmr = (String) props.getProperty("version.mmr"); - final String display = (String) props.getProperty("version.display"); - String filename = MessageFormat.format("tle-upgrade-{0} ({1}).zip", mmr, display); + final String displayName = (String) props.getProperty("version.display"); + final String semanticVersion = displayName.substring(0, displayName.indexOf("-")); + String filename = + MessageFormat.format("tle-upgrade-{0} ({1}).zip", semanticVersion, displayName); return installPath.resolve("manager/updates/" + filename).toFile(); } diff --git a/Source/Tools/UpgradeManager/resources/templates/main.st b/Source/Tools/UpgradeManager/resources/templates/main.st index 8d05b9fcc3..e2af5ad865 100644 --- a/Source/Tools/UpgradeManager/resources/templates/main.st +++ b/Source/Tools/UpgradeManager/resources/templates/main.st @@ -44,7 +44,7 @@ $("templates/page")(script={
Deployed Version:
-
$version.displayName$ ($version.mmr$)
+
$version.displayName$ ($version.semanticVersion$)
Server Status:
...
diff --git a/Source/Tools/UpgradeManager/resources/templates/version-set.st b/Source/Tools/UpgradeManager/resources/templates/version-set.st index 86bf7facbf..24662f3c68 100644 --- a/Source/Tools/UpgradeManager/resources/templates/version-set.st +++ b/Source/Tools/UpgradeManager/resources/templates/version-set.st @@ -1,9 +1,9 @@ $("templates/heading-content")(heading=heading, content={ $if(versions)$
    - $versions:{
  • }$ + $versions:{
  • }$
$else$ No versions found $endif$ -})$ \ No newline at end of file +})$ diff --git a/Source/Tools/UpgradeManager/src/com/tle/upgrademanager/ManagerConfig.java b/Source/Tools/UpgradeManager/src/com/tle/upgrademanager/ManagerConfig.java index 47db73ed5d..8b89a73862 100644 --- a/Source/Tools/UpgradeManager/src/com/tle/upgrademanager/ManagerConfig.java +++ b/Source/Tools/UpgradeManager/src/com/tle/upgrademanager/ManagerConfig.java @@ -55,7 +55,6 @@ public class ManagerDetails { private static final String LOADING_TIME_OUT_DEFAULT = "6000"; private static final String SERVER_PORT_DEFAULT = "3000"; - private static final String VERSION_MMR = "version.mmr"; private static final String VERSION_DISPLAY = "version.display"; private static final String VERSION_COMMIT = "version.commit"; @@ -80,10 +79,7 @@ protected ManagerDetails(File managerConfigFile, InputStream inputStream) throws vp.load(inputStream); fullVersion = MessageFormat.format( - "{0} {1} ({2})", - vp.getProperty(VERSION_MMR), - vp.getProperty(VERSION_DISPLAY), - vp.getProperty(VERSION_COMMIT)); + "{0} ({1})", vp.getProperty(VERSION_DISPLAY), vp.getProperty(VERSION_COMMIT)); } else { fullVersion = "Unknown"; } diff --git a/Source/Tools/UpgradeManager/src/com/tle/upgrademanager/Utils.java b/Source/Tools/UpgradeManager/src/com/tle/upgrademanager/Utils.java index 2cb8075d4b..43c3d66b4d 100644 --- a/Source/Tools/UpgradeManager/src/com/tle/upgrademanager/Utils.java +++ b/Source/Tools/UpgradeManager/src/com/tle/upgrademanager/Utils.java @@ -24,8 +24,15 @@ import java.util.regex.Pattern; public final class Utils { + // The below pattern supports both the old automatic versioning scheme (`..r` - + // `2019.1.r123`) + // as well as the newer semver hotfix scheme (.. - `2019.1.1`). Hence the optional + // `r?`. public static final Pattern VERSION_EXTRACT = - Pattern.compile("^tle-upgrade-(\\d+\\.\\d+\\.r\\d+) \\((.+)\\)\\.zip$"); // $NON-NLS-1$ + Pattern.compile("^tle-upgrade-(\\d+\\.\\d+\\.r?\\d+) \\((.+)\\)\\.zip$"); + + /** Support display versions such as 2019.1.1-Stable.OSE or 6.6-Stable.OSE. */ + public static final Pattern VERSION_DISPLAY = Pattern.compile("^[\\d.]+-[\\w.]+$"); public static final Comparator VERSION_COMPARATOR = new InverseComparator( @@ -34,7 +41,7 @@ public final class Utils { @Override public String convertToString(WebVersion wv) { - return wv.getMmr(); + return wv.getSemanticVersion(); } }); diff --git a/Source/Tools/UpgradeManager/src/com/tle/upgrademanager/handlers/PagesHandler.java b/Source/Tools/UpgradeManager/src/com/tle/upgrademanager/handlers/PagesHandler.java index 8c3e28627a..95a375a030 100644 --- a/Source/Tools/UpgradeManager/src/com/tle/upgrademanager/handlers/PagesHandler.java +++ b/Source/Tools/UpgradeManager/src/com/tle/upgrademanager/handlers/PagesHandler.java @@ -158,33 +158,33 @@ public void run() { public static class WebVersion { private String displayName; - private String mmr; + private String semanticVersion; private String filename; - public WebVersion(String dn, String mmr, String fn) { - this.displayName = dn; - this.mmr = mmr; - this.filename = fn; + public WebVersion(String displayName, String semanticVersion, String filename) { + this.displayName = displayName; + this.filename = filename; + this.semanticVersion = semanticVersion; } public WebVersion() { // Nothing } - public String getDisplayName() { - return displayName; + public void setSemanticVersion(String semanticVersion) { + this.semanticVersion = semanticVersion; } - public void setDisplayName(String displayName) { - this.displayName = displayName; + public String getSemanticVersion() { + return semanticVersion; } - public String getMmr() { - return mmr; + public String getDisplayName() { + return displayName; } - public void setMmr(String mmr) { - this.mmr = mmr; + public void setDisplayName(String displayName) { + this.displayName = displayName; } public String getFilename() { diff --git a/Source/Tools/UpgradeManager/src/com/tle/upgrademanager/helpers/Version.java b/Source/Tools/UpgradeManager/src/com/tle/upgrademanager/helpers/Version.java index 964f6e0ba5..612c112385 100644 --- a/Source/Tools/UpgradeManager/src/com/tle/upgrademanager/helpers/Version.java +++ b/Source/Tools/UpgradeManager/src/com/tle/upgrademanager/helpers/Version.java @@ -18,7 +18,6 @@ package com.tle.upgrademanager.helpers; -import com.google.common.base.Function; import com.tle.upgrademanager.ManagerConfig; import com.tle.upgrademanager.Utils; import com.tle.upgrademanager.handlers.PagesHandler.WebVersion; @@ -44,7 +43,7 @@ public SortedSet getVersions() { final SortedSet versions = new TreeSet(Utils.VERSION_COMPARATOR); final File upgradeFolder = config.getUpdatesDir(); - if (upgradeFolder.exists()) { + if (upgradeFolder.isDirectory()) { for (String file : upgradeFolder.list()) { if (file != null && Utils.VERSION_EXTRACT.matcher(file).matches()) { versions.add(getWebVersionFromFile(file)); @@ -57,66 +56,26 @@ public SortedSet getVersions() { return versions; } - private WebVersion getWebVersionFromFile(String fn) { - return new WebVersion( - DISPLAY_NAME_ONLY.apply(fn), VERSION_NUMBER_ONLY.apply(fn), FULL_FILENAME.apply(fn)); - } - - public static final Function FULL_FILENAME = - new Function() { - @Override - public String apply(String filename) { - Matcher m1 = Utils.VERSION_EXTRACT.matcher(filename); - return m1.matches() ? filename : null; - } - }; - - public static final Function VERSION_NUMBER_ONLY = - new Function() { - @Override - public String apply(String filename) { - Matcher m1 = Utils.VERSION_EXTRACT.matcher(filename); - if (m1.matches()) { - return m1.group(1); - } - return null; - } - }; - - public static final Function DISPLAY_NAME_ONLY = - new Function() { - @Override - public String apply(String filename) { - Matcher m = Utils.VERSION_EXTRACT.matcher(filename); - if (m.matches()) { - return m.group(2); - } - return null; - } - }; - public WebVersion getDeployedVersion() { WebVersion version = new WebVersion(); File versionFile = new File(getVersionPropertiesDirectory(), "version.properties"); try (FileInputStream in = new FileInputStream(versionFile)) { Properties p = new Properties(); p.load(in); - version.setDisplayName(p.getProperty("version.display")); - version.setMmr(p.getProperty("version.mmr")); + + String displayName = p.getProperty("version.display"); + String semanticVersion = getSemanticVersion(displayName); + + version.setDisplayName(displayName); + version.setSemanticVersion(semanticVersion); version.setFilename( - MessageFormat.format( - "tle-upgrade-{0} ({1}).zip", - p.getProperty("version.mmr"), p.getProperty("version.display"))); + MessageFormat.format("tle-upgrade-{0} ({1}).zip", semanticVersion, displayName)); } catch (IOException ex) { version.setDisplayName(Utils.UNKNOWN_VERSION); } return version; } - private File getVersionPropertiesDirectory() { - return new File(config.getInstallDir(), Utils.EQUELLASERVER_DIR); - } - public File getUpgradeFile(String filename) { File vdir = config.getUpdatesDir(); if (vdir.exists()) { @@ -128,4 +87,29 @@ public File getUpgradeFile(String filename) { return null; } + + private File getVersionPropertiesDirectory() { + return new File(config.getInstallDir(), Utils.EQUELLASERVER_DIR); + } + + private static String getSemanticVersion(String displayName) { + // semanticVersion is part of displayName, e.g. 2019.1.1-Stable.OSE + Matcher matcher = Utils.VERSION_DISPLAY.matcher(displayName); + if (!matcher.matches()) { + throw new IllegalArgumentException("Provided display name (" + displayName + ") is invalid."); + } + + return displayName.substring(0, displayName.indexOf("-")); + } + + private WebVersion getWebVersionFromFile(String filename) { + Matcher matcher = Utils.VERSION_EXTRACT.matcher(filename); + + if (!matcher.matches()) { + throw new IllegalArgumentException("Unrecognised filename format for: " + filename); + } + + final String displayName = matcher.group(2); + return new WebVersion(displayName, getSemanticVersion(displayName), filename); + } } diff --git a/autotest/build.sbt b/autotest/build.sbt index e9e058e0fd..b2d0f7d4af 100644 --- a/autotest/build.sbt +++ b/autotest/build.sbt @@ -69,9 +69,18 @@ installOptions := { def optPath(bc: Config, p: String) = if (bc.hasPath(p)) Some(file(bc.getString(p))) else None autotestInstallerZip := { - val bc = autotestBuildConfig.value - optPath(bc, "install.zip").orElse(optPath(bc, "install.dir").map(d => - (d * "equella-installer-*.zip").get.head)) + val bc = autotestBuildConfig.value + val equellaFullVersion = equellaVersion.value + val installerFileName = s"equella-installer-${equellaFullVersion.semanticVersion}.zip" + val installerDirectory = (target in LocalProject("Installer")).value + val installerAbsolutePath = installerDirectory / installerFileName + // If the Installer named as installerFileName exists then return it, otherwise returns the default Installer + if (installerAbsolutePath.exists) { + Some(installerAbsolutePath) + } else { + optPath(bc, "install.zip").orElse(optPath(bc, "install.dir").map(d => + (d * "equella-installer-*.zip").get.head)) + } } sourceZip := optPath(autotestBuildConfig.value, "install.sourcezip") diff --git a/build.sbt b/build.sbt index 0e70f5cfa0..a8047c80b9 100644 --- a/build.sbt +++ b/build.sbt @@ -111,23 +111,22 @@ oracleDriverJar in ThisBuild := { name := "Equella" -equellaMajorMinor in ThisBuild := "2019.1" +equellaMajor in ThisBuild := 2019 +equellaMinor in ThisBuild := 1 +equellaPatch in ThisBuild := 1 equellaStream in ThisBuild := "Stable" equellaBuild in ThisBuild := buildConfig.value.getString("build.buildname") -git.useGitDescribe := true +version := { + val shortCommit = git.gitHeadCommit.value.map { sha => + "g" + sha.take(7) + }.get -val TagRegex = """(.*)-(.*)-(\d*)-(.*)""".r -git.gitTagToVersionNumber := { - val streamName = equellaStream.value - val majorMinor = equellaMajorMinor.value - val buildName = equellaBuild.value - - { - case TagRegex(_, _, v, sha) => - Some(EquellaVersion(majorMinor, s"$streamName.$buildName", v.toInt, sha).fullVersion) - case _ => None - } + EquellaVersion(equellaMajor.value, + equellaMinor.value, + equellaPatch.value, + s"${equellaStream.value}.${equellaBuild.value}", + shortCommit).fullVersion } equellaVersion in ThisBuild := EquellaVersion(version.value) @@ -137,9 +136,7 @@ versionProperties in ThisBuild := { val props = new Properties props.putAll( Map( - "version.mm" -> eqVersion.majorMinor, - "version.mmr" -> s"${eqVersion.majorMinor}.r${eqVersion.commits}", - "version.display" -> s"${eqVersion.majorMinor}-${eqVersion.releaseType}", + "version.display" -> s"${eqVersion.semanticVersion}-${eqVersion.releaseType}", "version.commit" -> eqVersion.sha ).asJava) val f = target.value / "version.properties" diff --git a/project/CommonSettings.scala b/project/CommonSettings.scala index 85bd8eb948..85b3047f4f 100644 --- a/project/CommonSettings.scala +++ b/project/CommonSettings.scala @@ -10,7 +10,9 @@ object CommonSettings extends AutoPlugin { lazy val versionProperties = taskKey[File]("Version property file") lazy val upgradeZip = taskKey[File]("Create upgrade zip") lazy val installerZip = taskKey[File]("Create the installer zip") - lazy val equellaMajorMinor = settingKey[String]("The major minor equella version") + lazy val equellaMajor = settingKey[Int]("The major equella version") + lazy val equellaMinor = settingKey[Int]("The minor equella version") + lazy val equellaPatch = settingKey[Int]("The patch equella version") lazy val equellaStream = settingKey[String]("The equella stream name") lazy val equellaBuild = settingKey[String]("The equella build version") lazy val equellaVersion = settingKey[EquellaVersion]("The full equella version") diff --git a/project/EquellaVersion.scala b/project/EquellaVersion.scala index 9fb74172fe..240d29dac9 100644 --- a/project/EquellaVersion.scala +++ b/project/EquellaVersion.scala @@ -1,11 +1,13 @@ -case class EquellaVersion(majorMinor: String, releaseType: String, commits: Int, sha: String) { - def fullVersion = s"$majorMinor-$releaseType-r$commits-$sha" +case class EquellaVersion(major: Int, minor: Int, patch: Int, releaseType: String, sha: String) { + def semanticVersion = s"$major.$minor.$patch" + def fullVersion = s"$semanticVersion-$releaseType-$sha" } object EquellaVersion { - val RegEx = """(.*)-(.*)-r(\d*)-(.*)""".r + val RegEx = """(\d+).(\d+).(\d+)-(.+)-(.+)""".r def apply(s: String): EquellaVersion = s match { - case RegEx(mm, rt, c, sha) => EquellaVersion(mm, rt, c.toInt, sha) - case _ => EquellaVersion("6.5", "Unknown", 0, "00000") + case RegEx(major, minor, patch, rt, sha) => + EquellaVersion(major.toInt, minor.toInt, patch.toInt, rt, sha) + case _ => EquellaVersion(6, 5, 0, "Unknown", "00000") } }