Package org.dspace.app.util
Class IndexVersion
- java.lang.Object
-
- org.dspace.app.util.IndexVersion
-
public class IndexVersion extends Object
This utility class simply determines the version of a given Solr/Lucene index, so that they can be upgraded to the latest version.You must pass it the full path of the index directory, e.g.
[dspace]/solr/statistics/data/index/The response is simply a version number (e.g. 4.4), as this is utilized by the
ant update_solr_indexestarget in[src]/dspace/src/main/config/build.xml- Author:
- tdonohue
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intcompareSoftwareVersions(String firstVersion, String secondVersion)Compare two software version numbers to see which is greater.static StringgetIndexVersion(String indexDirPath)Determine the version of Solr/Lucene which was used to create a given index directory.static StringgetLatestVersion()Determine the version of Solr/Lucene which DSpace is currently running.static voidmain(String[] argv)
-
-
-
Method Detail
-
main
public static void main(String[] argv) throws IOException
- Throws:
IOException
-
getIndexVersion
public static String getIndexVersion(String indexDirPath) throws IOException
Determine the version of Solr/Lucene which was used to create a given index directory.- Parameters:
indexDirPath- Full path of the Solr/Lucene index directory- Returns:
- version as a string (e.g. "4.4"), empty string ("") if index directory is empty, or null if directory doesn't exist.
- Throws:
IOException- if IO error
-
compareSoftwareVersions
public static int compareSoftwareVersions(String firstVersion, String secondVersion) throws IOException
Compare two software version numbers to see which is greater. ONLY does a comparison of *major* and *minor* versions (any sub-minor versions are stripped and ignored).This method returns -1 if firstVersion is less than secondVersion, 1 if firstVersion is greater than secondVersion, and 0 if equal.
However, since we ignore sub-minor versions, versions "4.2.1" and "4.2.5" will be seen as EQUAL (as "4.2" = "4.2").
NOTE: In case it is not obvious, software version numbering does NOT behave like normal decimal numbers. For example, in software versions the following statement is TRUE:
4.1 < 4.4 < 4.5 < 4.10 < 4.21 < 4.51- Parameters:
firstVersion- First version to compare, as a StringsecondVersion- Second version to compare as a String- Returns:
- -1 if first less than second, 1 if first greater than second, 0 if equal
- Throws:
IOException- if IO error
-
getLatestVersion
public static String getLatestVersion()
Determine the version of Solr/Lucene which DSpace is currently running. This is the latest version of Solr/Lucene which we can upgrade the index to.- Returns:
- version as a string (e.g. "4.4")
-
-