1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.container; |
21 |
|
|
22 |
|
import java.io.File; |
23 |
|
|
24 |
|
import org.slf4j.Logger; |
25 |
|
import org.slf4j.LoggerFactory; |
26 |
|
import org.xwiki.component.manager.ComponentLookupException; |
27 |
|
import org.xwiki.component.manager.ComponentManager; |
28 |
|
import org.xwiki.configuration.ConfigurationSource; |
29 |
|
|
30 |
|
|
31 |
|
@link |
32 |
|
|
33 |
|
@version |
34 |
|
@deprecated |
35 |
|
|
36 |
|
@Deprecated |
|
|
| 5.4% |
Uncovered Elements: 35 (37) |
Complexity: 10 |
Complexity Density: 0.45 |
|
37 |
|
public abstract class AbstractApplicationContext implements ApplicationContext |
38 |
|
{ |
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractApplicationContext.class); |
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
private static final String PROPERTY_PERSISTENTDIRECTORY = "container.persistentDirectory"; |
48 |
|
|
49 |
|
|
50 |
|
@link |
51 |
|
|
52 |
|
private final ComponentManager componentManager; |
53 |
|
|
54 |
|
|
55 |
|
@see |
56 |
|
|
57 |
|
private File permanentDirectory; |
58 |
|
|
59 |
|
|
60 |
|
@param@link |
61 |
|
@link@link |
62 |
|
|
63 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
64 |
116 |
public AbstractApplicationContext(ComponentManager componentManager)... |
65 |
|
{ |
66 |
116 |
this.componentManager = componentManager; |
67 |
|
} |
68 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 4 |
Complexity Density: 0.57 |
|
69 |
0 |
@Override... |
70 |
|
public File getPermanentDirectory() |
71 |
|
{ |
72 |
0 |
if (this.permanentDirectory == null) { |
73 |
0 |
try { |
74 |
0 |
this.permanentDirectory = getConfiguredPermanentDirectory(); |
75 |
|
} catch (Exception e) { |
76 |
0 |
LOGGER.error("Failed to get configured permanent directory", e); |
77 |
|
} |
78 |
|
|
79 |
0 |
if (this.permanentDirectory == null) { |
80 |
|
|
81 |
0 |
this.permanentDirectory = getTemporaryDirectory(); |
82 |
|
} |
83 |
|
} |
84 |
|
|
85 |
0 |
return this.permanentDirectory; |
86 |
|
} |
87 |
|
|
88 |
|
|
89 |
|
@return |
90 |
|
@throws@link |
91 |
|
|
|
|
| 0% |
Uncovered Elements: 22 (22) |
Complexity: 5 |
Complexity Density: 0.36 |
|
92 |
0 |
private File getConfiguredPermanentDirectory() throws ComponentLookupException... |
93 |
|
{ |
94 |
0 |
File directory = null; |
95 |
|
|
96 |
0 |
ConfigurationSource source = this.componentManager.getInstance(ConfigurationSource.class, "xwikiproperties"); |
97 |
0 |
String directoryName = source.getProperty(PROPERTY_PERSISTENTDIRECTORY); |
98 |
0 |
if (directoryName != null) { |
99 |
0 |
directory = new File(directoryName); |
100 |
0 |
if (directory.exists()) { |
101 |
0 |
if (!directory.isDirectory()) { |
102 |
0 |
LOGGER.error("Configured permanent storage directory [{}] is not a directory", |
103 |
|
directory.getAbsolutePath()); |
104 |
0 |
directory = null; |
105 |
0 |
} else if (!directory.canWrite()) { |
106 |
0 |
LOGGER.error("Configured permanent storage directory [{}] is not writable", |
107 |
|
directory.getAbsolutePath()); |
108 |
0 |
directory = null; |
109 |
|
} |
110 |
|
} else { |
111 |
0 |
directory.mkdirs(); |
112 |
|
} |
113 |
|
} |
114 |
|
|
115 |
0 |
return directory; |
116 |
|
} |
117 |
|
} |