Class | Line # | Actions | |||||
---|---|---|---|---|---|---|---|
LegacyEnvironmentConfiguration | 41 | 6 | 0% | 3 | 3 |
1 | /* | |
2 | * See the NOTICE file distributed with this work for additional | |
3 | * information regarding copyright ownership. | |
4 | * | |
5 | * This is free software; you can redistribute it and/or modify it | |
6 | * under the terms of the GNU Lesser General Public License as | |
7 | * published by the Free Software Foundation; either version 2.1 of | |
8 | * the License, or (at your option) any later version. | |
9 | * | |
10 | * This software is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | * Lesser General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU Lesser General Public | |
16 | * License along with this software; if not, write to the Free | |
17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | |
19 | */ | |
20 | package org.xwiki.container.servlet.internal; | |
21 | ||
22 | import javax.inject.Inject; | |
23 | import javax.inject.Singleton; | |
24 | ||
25 | import org.slf4j.Logger; | |
26 | import org.xwiki.component.annotation.Component; | |
27 | import org.xwiki.environment.internal.DefaultEnvironmentConfiguration; | |
28 | ||
29 | /** | |
30 | * Overrides the {@link DefaultEnvironmentConfiguration} component in order to take into account the deprecated | |
31 | * permanent directory configuration property "container.persistentDirectory" and use it if the newer | |
32 | * "environment.permanentDirectory" property isn't set. | |
33 | * | |
34 | * @version $Id: 0accea72128cfdbb878d32605f7fbaf0e7a916bc $ | |
35 | * @since 3.5M1 | |
36 | * @deprecated starting with 3.5M1 use the "environment.permanentDirectory" property instead | |
37 | */ | |
38 | @Component | |
39 | @Singleton | |
40 | @Deprecated | |
41 | public class LegacyEnvironmentConfiguration extends DefaultEnvironmentConfiguration | |
42 | { | |
43 | /** | |
44 | * The name of the property for configuring the permanent directory. | |
45 | */ | |
46 | private static final String PROPERTY_DEPRECATED_PERMANENTDIRECTORY = "container.persistentDirectory"; | |
47 | ||
48 | /** | |
49 | * The logger to log. | |
50 | */ | |
51 | @Inject | |
52 | private Logger logger; | |
53 | ||
54 | 67 | ![]() |
55 | public String getPermanentDirectoryPath() | |
56 | { | |
57 | 67 | String dirPath = super.getPermanentDirectoryPath(); |
58 | 67 | if (dirPath == null) { |
59 | // Fallback to the old deprecated permanent directory configuration property | |
60 | 67 | dirPath = getConfigurationSource().getProperty(PROPERTY_DEPRECATED_PERMANENTDIRECTORY, String.class); |
61 | // Display a warning to the user so that he upgrades | |
62 | 67 | if (dirPath != null) { |
63 | 0 | this.logger.warn("You're using the deprecated [{}] configuration property. You should instead use the " |
64 | + "newer [{}] one", PROPERTY_DEPRECATED_PERMANENTDIRECTORY, "environment.permanentDirectory"); | |
65 | } | |
66 | } | |
67 | 67 | return dirPath; |
68 | } | |
69 | } |