1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.wiki.internal.descriptor.document; |
21 |
|
|
22 |
|
import javax.inject.Inject; |
23 |
|
import javax.inject.Named; |
24 |
|
import javax.inject.Singleton; |
25 |
|
|
26 |
|
import org.xwiki.component.annotation.Component; |
27 |
|
import org.xwiki.model.reference.DocumentReference; |
28 |
|
import org.xwiki.model.reference.LocalDocumentReference; |
29 |
|
import org.xwiki.sheet.SheetBinder; |
30 |
|
|
31 |
|
import com.xpn.xwiki.XWiki; |
32 |
|
import com.xpn.xwiki.doc.XWikiDocument; |
33 |
|
import com.xpn.xwiki.internal.mandatory.AbstractMandatoryDocumentInitializer; |
34 |
|
import com.xpn.xwiki.objects.classes.BaseClass; |
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
@version |
40 |
|
@since |
41 |
|
|
42 |
|
@Component |
43 |
|
@Named("XWiki.XWikiServerClass") |
44 |
|
@Singleton |
|
|
| 100% |
Uncovered Elements: 0 (25) |
Complexity: 4 |
Complexity Density: 0.2 |
|
45 |
|
public class XWikiServerClassDocumentInitializer extends AbstractMandatoryDocumentInitializer |
46 |
|
{ |
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
public static final String DOCUMENT_NAME = "XWikiServerClass"; |
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
public static final LocalDocumentReference SERVER_CLASS = |
56 |
|
new LocalDocumentReference(XWiki.SYSTEM_SPACE, DOCUMENT_NAME); |
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
public static final String DEFAULT_FIELDS_SEPARATOR = "|"; |
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
public static final String FIELD_WIKIPRETTYNAME = "wikiprettyname"; |
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
public static final String FIELDPN_WIKIPRETTYNAME = "Wiki pretty name"; |
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
public static final String FIELD_OWNER = "owner"; |
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
public static final String FIELDPN_OWNER = "Owner"; |
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
public static final String FIELD_DESCRIPTION = "description"; |
87 |
|
|
88 |
|
|
89 |
|
|
90 |
|
|
91 |
|
public static final String FIELDPN_DESCRIPTION = "Description"; |
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
|
96 |
|
public static final String FIELD_SERVER = "server"; |
97 |
|
|
98 |
|
|
99 |
|
|
100 |
|
|
101 |
|
public static final String FIELDPN_SERVER = "Server"; |
102 |
|
|
103 |
|
|
104 |
|
|
105 |
|
|
106 |
|
public static final String FIELD_VISIBILITY = "visibility"; |
107 |
|
|
108 |
|
|
109 |
|
|
110 |
|
|
111 |
|
public static final String FIELDL_VISIBILITY_PUBLIC = "public"; |
112 |
|
|
113 |
|
|
114 |
|
|
115 |
|
|
116 |
|
public static final String FIELDL_VISIBILITY_PRIVATE = "private"; |
117 |
|
|
118 |
|
|
119 |
|
|
120 |
|
|
121 |
|
public static final String FIELDL_VISIBILITY = FIELDL_VISIBILITY_PUBLIC + DEFAULT_FIELDS_SEPARATOR |
122 |
|
+ FIELDL_VISIBILITY_PRIVATE + DEFAULT_FIELDS_SEPARATOR; |
123 |
|
|
124 |
|
|
125 |
|
|
126 |
|
|
127 |
|
public static final String FIELDPN_VISIBILITY = "Visibility"; |
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
public static final String FIELD_STATE = "state"; |
133 |
|
|
134 |
|
|
135 |
|
|
136 |
|
|
137 |
|
public static final String FIELDL_STATE_ACTIVE = "active"; |
138 |
|
|
139 |
|
|
140 |
|
|
141 |
|
|
142 |
|
public static final String FIELDL_STATE_INACTIVE = "inactive"; |
143 |
|
|
144 |
|
|
145 |
|
|
146 |
|
|
147 |
|
public static final String FIELDL_STATE_LOCKED = "locked"; |
148 |
|
|
149 |
|
|
150 |
|
|
151 |
|
|
152 |
|
public static final String FIELDL_STATE = FIELDL_STATE_ACTIVE + DEFAULT_FIELDS_SEPARATOR + FIELDL_STATE_INACTIVE |
153 |
|
+ DEFAULT_FIELDS_SEPARATOR + FIELDL_STATE_LOCKED; |
154 |
|
|
155 |
|
|
156 |
|
|
157 |
|
|
158 |
|
public static final String FIELDPN_STATE = "State"; |
159 |
|
|
160 |
|
|
161 |
|
|
162 |
|
|
163 |
|
public static final String FIELD_LANGUAGE = "language"; |
164 |
|
|
165 |
|
|
166 |
|
|
167 |
|
|
168 |
|
public static final String FIELDL_LANGUAGE = "en|fr"; |
169 |
|
|
170 |
|
|
171 |
|
|
172 |
|
|
173 |
|
public static final String FIELDPN_LANGUAGE = "Language"; |
174 |
|
|
175 |
|
|
176 |
|
|
177 |
|
|
178 |
|
public static final String FIELD_SECURE = "secure"; |
179 |
|
|
180 |
|
|
181 |
|
|
182 |
|
|
183 |
|
public static final String FIELDPN_SECURE = "Secure"; |
184 |
|
|
185 |
|
|
186 |
|
|
187 |
|
|
188 |
|
public static final String FIELDDT_SECURE = "checkbox"; |
189 |
|
|
190 |
|
|
191 |
|
|
192 |
|
|
193 |
|
public static final Boolean DEFAULT_SECURE = Boolean.FALSE; |
194 |
|
|
195 |
|
|
196 |
|
|
197 |
|
|
198 |
|
public static final String FIELD_HOMEPAGE = "homepage"; |
199 |
|
|
200 |
|
|
201 |
|
|
202 |
|
|
203 |
|
public static final String FIELDPN_HOMEPAGE = "Home page"; |
204 |
|
|
205 |
|
|
206 |
|
|
207 |
|
|
208 |
|
@Inject |
209 |
|
@Named("class") |
210 |
|
private SheetBinder classSheetBinder; |
211 |
|
|
212 |
|
|
213 |
|
|
214 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
215 |
60 |
public XWikiServerClassDocumentInitializer()... |
216 |
|
{ |
217 |
60 |
super(XWiki.SYSTEM_SPACE, DOCUMENT_NAME); |
218 |
|
} |
219 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
220 |
60 |
@Override... |
221 |
|
public boolean isMainWikiOnly() |
222 |
|
{ |
223 |
|
|
224 |
60 |
return true; |
225 |
|
} |
226 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 2 |
Complexity Density: 0.11 |
|
227 |
88 |
@Override... |
228 |
|
public boolean updateDocument(XWikiDocument document) |
229 |
|
{ |
230 |
88 |
boolean needsUpdate = false; |
231 |
|
|
232 |
|
|
233 |
88 |
BaseClass baseClass = document.getXClass(); |
234 |
|
|
235 |
88 |
needsUpdate |= baseClass.addTextField(FIELD_WIKIPRETTYNAME, FIELDPN_WIKIPRETTYNAME, 30); |
236 |
88 |
needsUpdate |= baseClass.addUsersField(FIELD_OWNER, FIELDPN_OWNER, false); |
237 |
88 |
needsUpdate |= baseClass.addTextAreaField(FIELD_DESCRIPTION, FIELDPN_DESCRIPTION, 40, 5); |
238 |
88 |
needsUpdate |= baseClass.addTextField(FIELD_SERVER, FIELDPN_SERVER, 30); |
239 |
88 |
needsUpdate |= baseClass.addStaticListField(FIELD_VISIBILITY, FIELDPN_VISIBILITY, FIELDL_VISIBILITY); |
240 |
88 |
needsUpdate |= baseClass.addStaticListField(FIELD_STATE, FIELDPN_STATE, FIELDL_STATE); |
241 |
88 |
needsUpdate |= baseClass.addStaticListField(FIELD_LANGUAGE, FIELDPN_LANGUAGE, FIELDL_LANGUAGE); |
242 |
88 |
needsUpdate |= baseClass.addBooleanField(FIELD_SECURE, FIELDPN_SECURE, FIELDDT_SECURE); |
243 |
88 |
needsUpdate |= updateBooleanClassDefaultValue(baseClass, FIELD_SECURE, DEFAULT_SECURE); |
244 |
88 |
needsUpdate |= baseClass.addTextField(FIELD_HOMEPAGE, FIELDPN_HOMEPAGE, 30); |
245 |
|
|
246 |
|
|
247 |
88 |
needsUpdate |= setClassDocumentFields(document, "XWiki Server Class"); |
248 |
|
|
249 |
|
|
250 |
|
|
251 |
88 |
if (this.classSheetBinder.getSheets(document).isEmpty()) { |
252 |
34 |
String wikiName = document.getDocumentReference().getWikiReference().getName(); |
253 |
34 |
DocumentReference sheet = new DocumentReference(wikiName, XWiki.SYSTEM_SPACE, "XWikiServerClassSheet"); |
254 |
34 |
needsUpdate |= this.classSheetBinder.bind(document, sheet); |
255 |
|
} |
256 |
|
|
257 |
88 |
return needsUpdate; |
258 |
|
} |
259 |
|
|
260 |
|
} |