Commits

Tim Olsen committed 902da54 Merge

Merge Version fix into recent development

Comments (0)

Files changed (3)

plugin-resources/webapp/xnat/java/org/nrg/xnat/restlet/resources/VersionRepresentation.java

 
 	@Override
 	public Representation represent(Variant variant) {
-		final String location = XFT.GetConfDir();
 		if (logger.isDebugEnabled()) {
-			logger.debug("Getting XNAT version from the configuration folder: " + location);
+			logger.debug("Getting XNAT version from the default configuration folder");
 		}
 		try {
-			return new StringRepresentation(FileUtils.getXNATVersion(location));
+			return new StringRepresentation(FileUtils.getXNATVersion());
 		} catch (IOException exception) {
 			return new StringRepresentation("Unknown version");
 		}

plugin-resources/webapp/xnat/java/org/nrg/xnat/turbine/modules/actions/ReportIssue.java

 		context.put("java_version", System.getProperty(JAVA_VERSION));
 		context.put("java_vendor", System.getProperty(JAVA_VENDOR));
 
-		context.put("xnat_version", getXNATVersion(data.getServletContext()));
+		context.put("xnat_version", FileUtils.getXNATVersion());
 
 		context.put("user", user);
-		context.put("postgres_version", (String) PoolDBUtils.ReturnStatisticQuery("SELECT version();", "version", user.getDBName(), user
-				.getLogin()));
+		context.put("postgres_version", (String) PoolDBUtils.ReturnStatisticQuery("SELECT version();", "version", user.getDBName(), user.getLogin()));
 
 		final StringWriter sw = new StringWriter();
 		Velocity.getTemplate("/screens/email/issue_report.vm").merge(context, sw);
 		return sw.toString();
 	}
 
-	private String getXNATVersion(ServletContext servletContext) throws IOException {
-		final String location = servletContext.getRealPath(location("WEB-INF", "conf", "VERSION"));
-		if (logger.isDebugEnabled()) {
-			logger.debug("Getting XNAT version from the configuration folder: " + location);
-		}
-		return FileUtils.getXNATVersion(location);
-	}
-
 	private void checkFolder(String path) {
 		final File f = new File(path);
 		if (!f.exists()) {

plugin-resources/webapp/xnat/java/org/nrg/xnat/utils/FileUtils.java

 	}
 
 	/**
-	 * This attempts to retrieve the XNAT version from the tags file. Failing
-	 * that, it will use the previous VERSION file. The tags file is copied in
-	 * from the .hgtags file in the Mercurial repository and works for
-	 * installations that are built from source in a connected HG repository.
+         * This attempts to retrieve the XNAT version from the tags file in the {@link
+         * XFT#GetConfDir() default configuration folder}. Failing that, it will use
+         * the VERSION file. The tags file is copied in from the .hgtags file in the
+         * Mercurial repository and works for installations that are built from source
+         * in a connected HG repository.
 	 * 
-	 * @param location
-	 *            The location of the tags and VERSION files. This is usually
-	 *            the WEB-INF/conf folder in your web application installation.
 	 * @return The current version of XNAT as a String.
 	 */
-	public static String getXNATVersion(final String location) throws IOException {
-		if (org.apache.commons.lang.StringUtils.isEmpty(location)) {
+        public static String getXNATVersion() throws IOException {
+                final String location = XFT.GetConfDir();
+
+                if (StringUtils.isEmpty(location)) {
 			throw new IOException("Can't look for version in empty location.");
 		}