1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.mail.internal.configuration; |
21 |
|
|
22 |
|
import javax.inject.Named; |
23 |
|
import javax.inject.Singleton; |
24 |
|
|
25 |
|
import org.xwiki.component.annotation.Component; |
26 |
|
import org.xwiki.configuration.internal.AbstractDocumentConfigurationSource; |
27 |
|
import org.xwiki.model.reference.DocumentReference; |
28 |
|
import org.xwiki.model.reference.LocalDocumentReference; |
29 |
|
|
30 |
|
import com.xpn.xwiki.XWikiException; |
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
@version |
38 |
|
@since |
39 |
|
|
40 |
|
@Component |
41 |
|
@Named("mailsend") |
42 |
|
@Singleton |
|
|
| 90.5% |
Uncovered Elements: 2 (21) |
Complexity: 7 |
Complexity Density: 0.54 |
|
43 |
|
public class SendMailConfigClassDocumentConfigurationSource extends AbstractDocumentConfigurationSource |
44 |
|
{ |
45 |
|
private static final String MAIL_SPACE = "Mail"; |
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
private static final LocalDocumentReference CLASS_REFERENCE = |
51 |
|
new LocalDocumentReference(MAIL_SPACE, "SendMailConfigClass"); |
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
private static final LocalDocumentReference DOC_REFERENCE = |
57 |
|
new LocalDocumentReference(MAIL_SPACE, "MailConfig"); |
58 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
59 |
84 |
@Override... |
60 |
|
protected String getCacheId() |
61 |
|
{ |
62 |
84 |
return "configuration.document.mail.send"; |
63 |
|
} |
64 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
65 |
404 |
@Override... |
66 |
|
protected DocumentReference getDocumentReference() |
67 |
|
{ |
68 |
404 |
return new DocumentReference(DOC_REFERENCE, getCurrentWikiReference()); |
69 |
|
} |
70 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
71 |
53 |
@Override... |
72 |
|
protected LocalDocumentReference getClassReference() |
73 |
|
{ |
74 |
53 |
return CLASS_REFERENCE; |
75 |
|
} |
76 |
|
|
|
|
| 85.7% |
Uncovered Elements: 2 (14) |
Complexity: 4 |
Complexity Density: 0.4 |
|
77 |
255 |
@Override... |
78 |
|
public <T> T getProperty(String key, T defaultValue) |
79 |
|
{ |
80 |
255 |
T result; |
81 |
255 |
if (defaultValue != null) { |
82 |
2 |
try { |
83 |
2 |
if (getBaseObject() == null) { |
84 |
|
|
85 |
1 |
result = super.getProperty(key, defaultValue); |
86 |
|
} else { |
87 |
|
|
88 |
|
|
89 |
1 |
result = super.getProperty(key, (Class<? extends T>) defaultValue.getClass()); |
90 |
|
} |
91 |
|
} catch (XWikiException e) { |
92 |
0 |
this.logger.error("Failed to access configuration property [{}]", key, e); |
93 |
0 |
result = null; |
94 |
|
} |
95 |
|
} else { |
96 |
253 |
result = super.getProperty(key); |
97 |
|
} |
98 |
255 |
return result; |
99 |
|
} |
100 |
|
} |