Skip to content

Commit

Permalink
TRUNK-4042 Application Data directory location read from system property
Browse files Browse the repository at this point in the history
  • Loading branch information
h3llborn authored and rkorytkowski committed Aug 12, 2013
1 parent 8e869e9 commit 2e04b5b
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions api/src/main/java/org/openmrs/util/OpenmrsUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -846,10 +846,10 @@ public static List<Concept> delimitedStringToConceptList(String delimitedString,

/**
* Parses and loads a delimited list of concept ids or names
*
* @param delimitedString the delimited list of concept ids or names
* @param delimiter the delimiter, e.g. ","
* @return the list of concepts
*
* @since 1.10, 1.9.2, 1.8.5
*/
public static List<Concept> delimitedStringToConceptList(String delimitedString, String delimiter) {
Expand Down Expand Up @@ -1149,6 +1149,9 @@ public static InputStream getResourceInputStream(final URL url) throws IOExcepti
* init parameter "application.data.directory." If not found, returns:
* a) "{user.home}/.OpenMRS" on UNIX-based systems
* b) "{user.home}\Application Data\OpenMRS" on Windows
*
* Path can be set via systemproperty OPENMRS_APPLICATION_DATA_DIRECTORY
* for development purposes.
* </pre>
*
* @return The path to the directory on the file system that will hold miscellaneous data about
Expand All @@ -1157,17 +1160,21 @@ public static InputStream getResourceInputStream(final URL url) throws IOExcepti
public static String getApplicationDataDirectory() {

String filepath = null;

if (OpenmrsConstants.APPLICATION_DATA_DIRECTORY != null) {
filepath = OpenmrsConstants.APPLICATION_DATA_DIRECTORY;
if (System.getProperty("OPENMRS_APPLICATION_DATA_DIRECTORY") != null) {
filepath = System.getProperty("OPENMRS_APPLICATION_DATA_DIRECTORY");
} else {
if (OpenmrsConstants.UNIX_BASED_OPERATING_SYSTEM)
filepath = System.getProperty("user.home") + File.separator + ".OpenMRS";
else
filepath = System.getProperty("user.home") + File.separator + "Application Data" + File.separator
+ "OpenMRS";

filepath = filepath + File.separator;
if (OpenmrsConstants.APPLICATION_DATA_DIRECTORY != null) {
filepath = OpenmrsConstants.APPLICATION_DATA_DIRECTORY;
} else {
if (OpenmrsConstants.UNIX_BASED_OPERATING_SYSTEM)
filepath = System.getProperty("user.home") + File.separator + ".OpenMRS";
else
filepath = System.getProperty("user.home") + File.separator + "Application Data" + File.separator
+ "OpenMRS";

filepath = filepath + File.separator;
}
}

File folder = new File(filepath);
Expand Down

0 comments on commit 2e04b5b

Please sign in to comment.