Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: openmrs/openmrs-core
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: cfa698b19357
Choose a base ref
...
head repository: openmrs/openmrs-core
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: cb7b6cae0681
Choose a head ref
  • 3 commits
  • 2 files changed
  • 2 contributors

Commits on Nov 17, 2013

  1. adds an fallback for APPLICATION_DATA_DIRECTORY

    as described in ticket TRUNK-3934: in some deployments using an application server such as Tomcat, we can not write to the current users home dir and instead should use a more generic and/or appropriate path
    Marv Cool committed Nov 17, 2013
    Copy the full SHA
    2f55c3e View commit details

Commits on Jan 28, 2014

  1. removed unesseary / from path

    Marv Cool committed Jan 28, 2014
    Copy the full SHA
    0675648 View commit details
  2. Merge pull request #454 from openmrs-codejam-hamburg/TRUNK-3934

    TRUNK-3934 - adds an fallback for APPLICATION_DATA_DIRECTORY
    dkayiwa committed Jan 28, 2014

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    cb7b6ca View commit details
Showing with 25 additions and 3 deletions.
  1. +11 −0 api/src/main/java/org/openmrs/util/OpenmrsConstants.java
  2. +14 −3 api/src/main/java/org/openmrs/util/OpenmrsUtil.java
11 changes: 11 additions & 0 deletions api/src/main/java/org/openmrs/util/OpenmrsConstants.java
Original file line number Diff line number Diff line change
@@ -233,6 +233,17 @@ private static String getVersion() {
*/
public static String APPLICATION_DATA_DIRECTORY = null;

/**
* The directory which OpenMRS should attempt to use as its application data directory
* in case the current users home dir is not writeable (e.g. when using application servers
* like tomcat to deploy OpenMRS).
*
* @see #APPLICATION_DATA_DIRECTORY_RUNTIME_PROPERTY
* @see OpenmrsUtil#getApplicationDataDirectory()
*/
public static String APPLICATION_DATA_DIRECTORY_FALLBACK_UNIX = "/var/lib";
public static String APPLICATION_DATA_DIRECTORY_FALLBACK_WIN = System.getenv("%appdata%");

/**
* The name of the runtime property that a user can set that will specify where openmrs's
* application directory is
17 changes: 14 additions & 3 deletions api/src/main/java/org/openmrs/util/OpenmrsUtil.java
Original file line number Diff line number Diff line change
@@ -1158,7 +1158,7 @@ public static InputStream getResourceInputStream(final URL url) throws IOExcepti
* the application (runtime properties, modules, etc)
*/
public static String getApplicationDataDirectory() {

String filepath = null;
if (System.getProperty("OPENMRS_APPLICATION_DATA_DIRECTORY") != null) {
filepath = System.getProperty("OPENMRS_APPLICATION_DATA_DIRECTORY");
@@ -1167,11 +1167,22 @@ public static String getApplicationDataDirectory() {
if (OpenmrsConstants.APPLICATION_DATA_DIRECTORY != null) {
filepath = OpenmrsConstants.APPLICATION_DATA_DIRECTORY;
} else {
if (OpenmrsConstants.UNIX_BASED_OPERATING_SYSTEM)
if (OpenmrsConstants.UNIX_BASED_OPERATING_SYSTEM) {
filepath = System.getProperty("user.home") + File.separator + ".OpenMRS";
else
if (!(new File(filepath)).canWrite()) {
log.warn("Unable to write to users home dir, fallback to: "
+ OpenmrsConstants.APPLICATION_DATA_DIRECTORY_FALLBACK_UNIX);
filepath = OpenmrsConstants.APPLICATION_DATA_DIRECTORY_FALLBACK_UNIX + File.separator + "OpenMRS";
}
} else {
filepath = System.getProperty("user.home") + File.separator + "Application Data" + File.separator
+ "OpenMRS";
if (!(new File(filepath)).canWrite()) {
log.warn("Unable to write to users home dir, fallback to: "
+ OpenmrsConstants.APPLICATION_DATA_DIRECTORY_FALLBACK_WIN);
filepath = OpenmrsConstants.APPLICATION_DATA_DIRECTORY_FALLBACK_WIN + File.separator + "OpenMRS";
}
}

filepath = filepath + File.separator;
}