Project

General

Profile

Revision 945508b5

ID945508b5043735f3c147216abe8ae0c366767223
Parent 4adf618f
Child 6ae3aa93

Added by Andreas Kohlbecker over 2 years ago

ref #8189 fallback method for getCdmHomeSubDir() and fixing bug in getCdmHomeDirFallback()

View differences:

cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/config/ConfigFileUtil.java
47 47
    }
48 48

  
49 49
    /**
50
     * @deprecated use {@link #perUserCdmFolder()} instead
51
     */
52
    @Deprecated
53
    public static File getCdmHomeDir() {
54
        return perUserCdmFolder;
55
    }
56

  
57
    /**
50 58
     * Provides the <code>${user.home}./cdmLibrary</code> folder without taking
51 59
     * additional property sources into account which could be configured in
52 60
     * the Spring application context.
......
66 74
    }
67 75

  
68 76
    /**
77
     * @deprecated use {@link #perUserCdmFolderFallback()} instead
78
     */
79
    @Deprecated
80
    public static File getCdmHomeDirFallback() {
81
        return perUserCdmFolderFallback();
82
    }
83

  
84
    /**
69 85
     * suggested sub folder for web app related data and configurations.
70 86
     * Each webapp instance should use a dedicated subfolder or file
71 87
     * which is named by the data source bean id.
......
79 95
        this.env = environment;
80 96
        if(userHome == null){
81 97
            ConfigFileUtil.userHome = env.getRequiredProperty("user.home");
82
            ConfigFileUtil.perUserCdmFolder = new File(userHome + File.separator + CDM_FOLDER_NAME );
98
            ConfigFileUtil.perUserCdmFolder = new File(userHome, CDM_FOLDER_NAME);
83 99
            logger.info("user.home is set to " + ConfigFileUtil.userHome);
84 100
        }
85 101
    }
86 102

  
87
    public static File getCdmHomeDir() {
88
       return perUserCdmFolder;
89
    }
90

  
91
    @Deprecated
92
    public static File getCdmHomeDirFallback() {
93
        return new File(perUserCdmFolder, CDM_FOLDER_NAME);
94
     }
95

  
96 103

  
97 104
    /**
98 105
     * Returns specified the sub folder of  {@link #CDM_FOLDER_NAME}.
......
104 111
     * @see {@link #SUBFOLDER_WEBAPP}
105 112
     */
106 113
    public static File getCdmHomeSubDir(String subFolderName) {
107
        try{
108
            File parentFolder = getCdmHomeDir();
109
            return ensureSubfolderExists(parentFolder, subFolderName);
110
        }catch(Exception e){
111
            File parentFolder = perUserCdmFolderFallback();
112
            return ensureSubfolderExists(parentFolder, subFolderName);
113
        }
114

  
115
        File parentFolder = getCdmHomeDir();
116
        return ensureSubfolderExists(parentFolder, subFolderName);
117
    }
118

  
119
    /**
120
     * Provides subfolders of <code>${user.home}./cdmLibrary</code> folder without taking
121
     * additional property sources into account which could be configured in
122
     * the Spring application context.
123
     * <p>
124
     * This method can be used if an application context is not (yet) available, but
125
     * should be used with caution, since this location might differ from the location
126
     * used by other components of the application which make use of the
127
     * {@link #perUserCdmFolder()} method.
128
     *
129
     * @deprecated Marked as deprecated as warning sign in the hope developers will
130
     * read the java doc for this method when using it.
131
     *
132
     */
133
    @Deprecated
134
    public static File getCdmHomeSubDirFallback(String subFolderName) {
135

  
136
        File parentFolder = perUserCdmFolderFallback();
137
        return ensureSubfolderExists(parentFolder, subFolderName);
114 138
    }
115 139

  
116 140
    /**
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/database/CdmPersistentDataSourceTest.java
41 41
 * @author a.mueller
42 42
 *
43 43
 */
44
@Ignore
44 45
public class CdmPersistentDataSourceTest {
45 46
	@SuppressWarnings("unused")
46 47
	private static final Logger logger = Logger.getLogger(CdmPersistentDataSourceTest.class);

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)