From: <rv...@us...> - 2010-01-13 17:31:37
|
Revision: 427 http://treebase.svn.sourceforge.net/treebase/?rev=427&view=rev Author: rvos Date: 2010-01-13 17:31:31 +0000 (Wed, 13 Jan 2010) Log Message: ----------- Implemented getDomainName() method, which returns the domain name as specified in the treebase.properties file. This domain name is to be used in the view layer if we want to display absolute URLs that cannot be computed by the web app (e.g. if we start using PURLs). Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/TreebaseUtil.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/TreebaseUtil.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/TreebaseUtil.java 2010-01-13 17:29:26 UTC (rev 426) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/TreebaseUtil.java 2010-01-13 17:31:31 UTC (rev 427) @@ -3,6 +3,8 @@ import java.io.BufferedReader; import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.text.ParseException; @@ -12,6 +14,7 @@ import java.util.Collection; import java.util.Date; import java.util.Iterator; +import java.util.Properties; import java.util.TimeZone; import org.cipres.treebase.domain.study.Citation; @@ -422,6 +425,27 @@ return date + " GMT"; } + + /** + * This method returns the domain name (possibly with port number) + * which can be used to construct URLs by prefixing with "http://" + * and suffixing with the full path (e.g. "/treebase-web") + * + * @return domain name + */ + public static String getDomainName() { + Properties properties = new Properties(); + String domainName = ""; + try { + properties.load( new FileInputStream("treebase.properties") ); + domainName = properties.getProperty("treebase.domain.name"); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + return domainName; + } /** * This method appends header information upon formatting to the nexus file. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |