1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package com.xpn.xwiki; |
21 |
|
|
22 |
|
import java.io.ByteArrayInputStream; |
23 |
|
import java.io.File; |
24 |
|
import java.io.FileInputStream; |
25 |
|
import java.io.FileNotFoundException; |
26 |
|
import java.io.IOException; |
27 |
|
import java.io.InputStream; |
28 |
|
import java.io.PrintWriter; |
29 |
|
import java.io.StringWriter; |
30 |
|
import java.lang.reflect.Field; |
31 |
|
import java.lang.reflect.InvocationTargetException; |
32 |
|
import java.lang.reflect.Method; |
33 |
|
import java.lang.reflect.Type; |
34 |
|
import java.net.MalformedURLException; |
35 |
|
import java.net.URL; |
36 |
|
import java.text.DateFormatSymbols; |
37 |
|
import java.text.SimpleDateFormat; |
38 |
|
import java.util.ArrayList; |
39 |
|
import java.util.Arrays; |
40 |
|
import java.util.Collections; |
41 |
|
import java.util.Comparator; |
42 |
|
import java.util.Date; |
43 |
|
import java.util.Enumeration; |
44 |
|
import java.util.HashMap; |
45 |
|
import java.util.HashSet; |
46 |
|
import java.util.List; |
47 |
|
import java.util.ListIterator; |
48 |
|
import java.util.Locale; |
49 |
|
import java.util.Map; |
50 |
|
import java.util.Set; |
51 |
|
import java.util.TimeZone; |
52 |
|
import java.util.Vector; |
53 |
|
import java.util.concurrent.ConcurrentHashMap; |
54 |
|
import java.util.regex.Pattern; |
55 |
|
import java.util.zip.ZipOutputStream; |
56 |
|
|
57 |
|
import javax.annotation.Priority; |
58 |
|
import javax.inject.Provider; |
59 |
|
import javax.mail.Message; |
60 |
|
import javax.mail.Session; |
61 |
|
import javax.mail.internet.InternetAddress; |
62 |
|
import javax.mail.internet.MimeMessage; |
63 |
|
import javax.naming.NamingException; |
64 |
|
import javax.script.ScriptContext; |
65 |
|
import javax.servlet.http.Cookie; |
66 |
|
import javax.servlet.http.HttpServletRequest; |
67 |
|
import javax.servlet.http.HttpServletResponse; |
68 |
|
|
69 |
|
import org.apache.commons.httpclient.Credentials; |
70 |
|
import org.apache.commons.httpclient.HttpClient; |
71 |
|
import org.apache.commons.httpclient.URIException; |
72 |
|
import org.apache.commons.httpclient.UsernamePasswordCredentials; |
73 |
|
import org.apache.commons.httpclient.auth.AuthScope; |
74 |
|
import org.apache.commons.httpclient.methods.GetMethod; |
75 |
|
import org.apache.commons.httpclient.util.URIUtil; |
76 |
|
import org.apache.commons.io.FileUtils; |
77 |
|
import org.apache.commons.io.IOUtils; |
78 |
|
import org.apache.commons.lang3.ArrayUtils; |
79 |
|
import org.apache.commons.lang3.LocaleUtils; |
80 |
|
import org.apache.commons.lang3.RandomStringUtils; |
81 |
|
import org.apache.commons.lang3.StringUtils; |
82 |
|
import org.apache.commons.lang3.exception.ExceptionUtils; |
83 |
|
import org.apache.commons.lang3.math.NumberUtils; |
84 |
|
import org.apache.commons.lang3.reflect.FieldUtils; |
85 |
|
import org.apache.velocity.VelocityContext; |
86 |
|
import org.hibernate.HibernateException; |
87 |
|
import org.slf4j.Logger; |
88 |
|
import org.slf4j.LoggerFactory; |
89 |
|
import org.xwiki.bridge.event.DocumentCreatedEvent; |
90 |
|
import org.xwiki.bridge.event.DocumentCreatingEvent; |
91 |
|
import org.xwiki.bridge.event.DocumentDeletedEvent; |
92 |
|
import org.xwiki.bridge.event.DocumentDeletingEvent; |
93 |
|
import org.xwiki.bridge.event.DocumentRolledBackEvent; |
94 |
|
import org.xwiki.bridge.event.DocumentRollingBackEvent; |
95 |
|
import org.xwiki.bridge.event.DocumentUpdatedEvent; |
96 |
|
import org.xwiki.bridge.event.DocumentUpdatingEvent; |
97 |
|
import org.xwiki.bridge.event.WikiCopiedEvent; |
98 |
|
import org.xwiki.bridge.event.WikiDeletedEvent; |
99 |
|
import org.xwiki.cache.Cache; |
100 |
|
import org.xwiki.classloader.ClassLoaderManager; |
101 |
|
import org.xwiki.component.event.ComponentDescriptorAddedEvent; |
102 |
|
import org.xwiki.component.manager.ComponentLookupException; |
103 |
|
import org.xwiki.component.manager.ComponentManager; |
104 |
|
import org.xwiki.component.manager.NamespacedComponentManager; |
105 |
|
import org.xwiki.component.util.DefaultParameterizedType; |
106 |
|
import org.xwiki.configuration.ConfigurationSource; |
107 |
|
import org.xwiki.context.Execution; |
108 |
|
import org.xwiki.edit.EditConfiguration; |
109 |
|
import org.xwiki.job.Job; |
110 |
|
import org.xwiki.job.JobException; |
111 |
|
import org.xwiki.job.JobExecutor; |
112 |
|
import org.xwiki.job.annotation.Serializable; |
113 |
|
import org.xwiki.job.event.status.JobProgressManager; |
114 |
|
import org.xwiki.job.event.status.JobStatus.State; |
115 |
|
import org.xwiki.localization.ContextualLocalizationManager; |
116 |
|
import org.xwiki.mail.MailListener; |
117 |
|
import org.xwiki.mail.MailSender; |
118 |
|
import org.xwiki.mail.MailSenderConfiguration; |
119 |
|
import org.xwiki.mail.MailStatusResultSerializer; |
120 |
|
import org.xwiki.mail.XWikiAuthenticator; |
121 |
|
import org.xwiki.model.EntityType; |
122 |
|
import org.xwiki.model.reference.AttachmentReference; |
123 |
|
import org.xwiki.model.reference.AttachmentReferenceResolver; |
124 |
|
import org.xwiki.model.reference.DocumentReference; |
125 |
|
import org.xwiki.model.reference.DocumentReferenceResolver; |
126 |
|
import org.xwiki.model.reference.EntityReference; |
127 |
|
import org.xwiki.model.reference.EntityReferenceResolver; |
128 |
|
import org.xwiki.model.reference.EntityReferenceSerializer; |
129 |
|
import org.xwiki.model.reference.LocalDocumentReference; |
130 |
|
import org.xwiki.model.reference.ObjectReference; |
131 |
|
import org.xwiki.model.reference.RegexEntityReference; |
132 |
|
import org.xwiki.model.reference.SpaceReference; |
133 |
|
import org.xwiki.model.reference.WikiReference; |
134 |
|
import org.xwiki.observation.EventListener; |
135 |
|
import org.xwiki.observation.ObservationManager; |
136 |
|
import org.xwiki.observation.event.CancelableEvent; |
137 |
|
import org.xwiki.observation.event.Event; |
138 |
|
import org.xwiki.query.QueryException; |
139 |
|
import org.xwiki.query.QueryFilter; |
140 |
|
import org.xwiki.rendering.block.Block; |
141 |
|
import org.xwiki.rendering.block.Block.Axes; |
142 |
|
import org.xwiki.rendering.block.MetaDataBlock; |
143 |
|
import org.xwiki.rendering.block.match.MetadataBlockMatcher; |
144 |
|
import org.xwiki.rendering.internal.transformation.MutableRenderingContext; |
145 |
|
import org.xwiki.rendering.listener.MetaData; |
146 |
|
import org.xwiki.rendering.parser.ParseException; |
147 |
|
import org.xwiki.rendering.syntax.Syntax; |
148 |
|
import org.xwiki.rendering.syntax.SyntaxContent; |
149 |
|
import org.xwiki.rendering.syntax.SyntaxFactory; |
150 |
|
import org.xwiki.rendering.transformation.RenderingContext; |
151 |
|
import org.xwiki.resource.ResourceReference; |
152 |
|
import org.xwiki.resource.ResourceReferenceManager; |
153 |
|
import org.xwiki.resource.ResourceReferenceResolver; |
154 |
|
import org.xwiki.resource.ResourceType; |
155 |
|
import org.xwiki.resource.ResourceTypeResolver; |
156 |
|
import org.xwiki.resource.entity.EntityResourceReference; |
157 |
|
import org.xwiki.script.ScriptContextManager; |
158 |
|
import org.xwiki.skin.Resource; |
159 |
|
import org.xwiki.skin.Skin; |
160 |
|
import org.xwiki.skin.SkinManager; |
161 |
|
import org.xwiki.template.TemplateManager; |
162 |
|
import org.xwiki.url.ExtendedURL; |
163 |
|
import org.xwiki.velocity.VelocityManager; |
164 |
|
import org.xwiki.wiki.descriptor.WikiDescriptor; |
165 |
|
import org.xwiki.wiki.descriptor.WikiDescriptorManager; |
166 |
|
import org.xwiki.wiki.manager.WikiManager; |
167 |
|
import org.xwiki.wiki.manager.WikiManagerException; |
168 |
|
import org.xwiki.xml.XMLUtils; |
169 |
|
|
170 |
|
import com.xpn.xwiki.api.Api; |
171 |
|
import com.xpn.xwiki.api.Document; |
172 |
|
import com.xpn.xwiki.api.User; |
173 |
|
import com.xpn.xwiki.criteria.api.XWikiCriteriaService; |
174 |
|
import com.xpn.xwiki.doc.DeletedAttachment; |
175 |
|
import com.xpn.xwiki.doc.MandatoryDocumentInitializer; |
176 |
|
import com.xpn.xwiki.doc.XWikiAttachment; |
177 |
|
import com.xpn.xwiki.doc.XWikiDeletedDocument; |
178 |
|
import com.xpn.xwiki.doc.XWikiDocument; |
179 |
|
import com.xpn.xwiki.doc.XWikiDocument.XWikiAttachmentToRemove; |
180 |
|
import com.xpn.xwiki.doc.XWikiDocumentArchive; |
181 |
|
import com.xpn.xwiki.internal.WikiInitializerJob; |
182 |
|
import com.xpn.xwiki.internal.WikiInitializerRequest; |
183 |
|
import com.xpn.xwiki.internal.XWikiCfgConfigurationSource; |
184 |
|
import com.xpn.xwiki.internal.XWikiConfigDelegate; |
185 |
|
import com.xpn.xwiki.internal.XWikiInitializerJob; |
186 |
|
import com.xpn.xwiki.internal.event.XObjectPropertyAddedEvent; |
187 |
|
import com.xpn.xwiki.internal.event.XObjectPropertyDeletedEvent; |
188 |
|
import com.xpn.xwiki.internal.event.XObjectPropertyEvent; |
189 |
|
import com.xpn.xwiki.internal.event.XObjectPropertyUpdatedEvent; |
190 |
|
import com.xpn.xwiki.internal.render.OldRendering; |
191 |
|
import com.xpn.xwiki.internal.render.groovy.ParseGroovyFromString; |
192 |
|
import com.xpn.xwiki.internal.skin.InternalSkinConfiguration; |
193 |
|
import com.xpn.xwiki.internal.skin.InternalSkinManager; |
194 |
|
import com.xpn.xwiki.internal.skin.WikiSkin; |
195 |
|
import com.xpn.xwiki.internal.skin.WikiSkinUtils; |
196 |
|
import com.xpn.xwiki.job.JobRequestContext; |
197 |
|
import com.xpn.xwiki.objects.BaseObject; |
198 |
|
import com.xpn.xwiki.objects.PropertyInterface; |
199 |
|
import com.xpn.xwiki.objects.classes.BaseClass; |
200 |
|
import com.xpn.xwiki.objects.classes.PasswordClass; |
201 |
|
import com.xpn.xwiki.objects.classes.PropertyClass; |
202 |
|
import com.xpn.xwiki.objects.meta.MetaClass; |
203 |
|
import com.xpn.xwiki.plugin.XWikiPluginInterface; |
204 |
|
import com.xpn.xwiki.plugin.XWikiPluginManager; |
205 |
|
import com.xpn.xwiki.render.groovy.XWikiPageClassLoader; |
206 |
|
import com.xpn.xwiki.stats.api.XWikiStatsService; |
207 |
|
import com.xpn.xwiki.stats.impl.SearchEngineRule; |
208 |
|
import com.xpn.xwiki.stats.impl.XWikiStatsServiceImpl; |
209 |
|
import com.xpn.xwiki.store.AttachmentRecycleBinStore; |
210 |
|
import com.xpn.xwiki.store.AttachmentVersioningStore; |
211 |
|
import com.xpn.xwiki.store.XWikiAttachmentStoreInterface; |
212 |
|
import com.xpn.xwiki.store.XWikiCacheStore; |
213 |
|
import com.xpn.xwiki.store.XWikiCacheStoreInterface; |
214 |
|
import com.xpn.xwiki.store.XWikiHibernateStore; |
215 |
|
import com.xpn.xwiki.store.XWikiRecycleBinStoreInterface; |
216 |
|
import com.xpn.xwiki.store.XWikiStoreInterface; |
217 |
|
import com.xpn.xwiki.store.XWikiVersioningStoreInterface; |
218 |
|
import com.xpn.xwiki.user.api.XWikiAuthService; |
219 |
|
import com.xpn.xwiki.user.api.XWikiGroupService; |
220 |
|
import com.xpn.xwiki.user.api.XWikiRightService; |
221 |
|
import com.xpn.xwiki.user.api.XWikiUser; |
222 |
|
import com.xpn.xwiki.user.impl.xwiki.XWikiAuthServiceImpl; |
223 |
|
import com.xpn.xwiki.user.impl.xwiki.XWikiGroupServiceImpl; |
224 |
|
import com.xpn.xwiki.user.impl.xwiki.XWikiRightServiceImpl; |
225 |
|
import com.xpn.xwiki.util.Util; |
226 |
|
import com.xpn.xwiki.util.XWikiStubContextProvider; |
227 |
|
import com.xpn.xwiki.web.Utils; |
228 |
|
import com.xpn.xwiki.web.XWikiEngineContext; |
229 |
|
import com.xpn.xwiki.web.XWikiMessageTool; |
230 |
|
import com.xpn.xwiki.web.XWikiRequest; |
231 |
|
import com.xpn.xwiki.web.XWikiURLFactory; |
232 |
|
import com.xpn.xwiki.web.XWikiURLFactoryService; |
233 |
|
import com.xpn.xwiki.web.XWikiURLFactoryServiceImpl; |
234 |
|
import com.xpn.xwiki.web.includeservletasstring.IncludeServletAsString; |
235 |
|
|
236 |
|
@Serializable(false) |
|
|
| 53% |
Uncovered Elements: 1,652 (3,515) |
Complexity: 955 |
Complexity Density: 0.42 |
|
237 |
|
public class XWiki implements EventListener |
238 |
|
{ |
239 |
|
|
240 |
|
public static final String DEFAULT_MAIN_WIKI = "xwiki"; |
241 |
|
|
242 |
|
|
243 |
|
public static final String DEFAULT_HOME_SPACE = "Main"; |
244 |
|
|
245 |
|
|
246 |
|
public static final String SYSTEM_SPACE = "XWiki"; |
247 |
|
|
248 |
|
|
249 |
|
public static final String DEFAULT_SPACE_HOMEPAGE = "WebHome"; |
250 |
|
|
251 |
|
public static final String CKEY_SKIN = InternalSkinManager.CKEY_SKIN; |
252 |
|
|
253 |
|
public static final String CKEY_BASESKIN = InternalSkinManager.CKEY_PARENTSKIN; |
254 |
|
|
255 |
|
public static final String DEFAULT_SKIN = InternalSkinConfiguration.DEFAULT_SKIN; |
256 |
|
|
257 |
|
|
258 |
|
protected static final Logger LOGGER = LoggerFactory.getLogger(XWiki.class); |
259 |
|
|
260 |
|
|
261 |
|
private static final DocumentReference VIRTUAL_WIKI_DEFINITION_CLASS_REFERENCE = |
262 |
|
new DocumentReference(DEFAULT_MAIN_WIKI, SYSTEM_SPACE, "XWikiServerClass"); |
263 |
|
|
264 |
|
|
265 |
|
public static final String DEFAULT_ENCODING = "UTF-8"; |
266 |
|
|
267 |
|
|
268 |
|
private static final String NO_VALUE = "---"; |
269 |
|
|
270 |
|
|
271 |
|
private XWikiStoreInterface store; |
272 |
|
|
273 |
|
|
274 |
|
private XWikiAttachmentStoreInterface attachmentStore; |
275 |
|
|
276 |
|
|
277 |
|
private AttachmentVersioningStore attachmentVersioningStore; |
278 |
|
|
279 |
|
|
280 |
|
private XWikiVersioningStoreInterface versioningStore; |
281 |
|
|
282 |
|
|
283 |
|
private XWikiRecycleBinStoreInterface recycleBinStore; |
284 |
|
|
285 |
|
|
286 |
|
|
287 |
|
|
288 |
|
@since |
289 |
|
|
290 |
|
private AttachmentRecycleBinStore attachmentRecycleBinStore; |
291 |
|
|
292 |
|
private XWikiPluginManager pluginManager; |
293 |
|
|
294 |
|
private XWikiAuthService authService; |
295 |
|
|
296 |
|
private XWikiRightService rightService; |
297 |
|
|
298 |
|
private XWikiGroupService groupService; |
299 |
|
|
300 |
|
private XWikiStatsService statsService; |
301 |
|
|
302 |
|
private XWikiURLFactoryService urlFactoryService; |
303 |
|
|
304 |
|
private XWikiCriteriaService criteriaService; |
305 |
|
|
306 |
|
|
307 |
|
private final Object AUTH_SERVICE_LOCK = new Object(); |
308 |
|
|
309 |
|
|
310 |
|
private final Object RIGHT_SERVICE_LOCK = new Object(); |
311 |
|
|
312 |
|
|
313 |
|
private final Object GROUP_SERVICE_LOCK = new Object(); |
314 |
|
|
315 |
|
|
316 |
|
private final Object STATS_SERVICE_LOCK = new Object(); |
317 |
|
|
318 |
|
|
319 |
|
private final Object URLFACTORY_SERVICE_LOCK = new Object(); |
320 |
|
|
321 |
|
private MetaClass metaclass; |
322 |
|
|
323 |
|
private String version; |
324 |
|
|
325 |
|
private XWikiEngineContext engine_context; |
326 |
|
|
327 |
|
private String database; |
328 |
|
|
329 |
|
private String fullNameSQL; |
330 |
|
|
331 |
|
|
332 |
|
|
333 |
|
|
334 |
|
private Map<String, WikiInitializerJob> initializedWikis = new ConcurrentHashMap<>(); |
335 |
|
|
336 |
|
private boolean isReadOnly = false; |
337 |
|
|
338 |
|
|
339 |
|
@deprecated@link |
340 |
|
|
341 |
|
@Deprecated |
342 |
|
public static final String CFG_ENV_NAME = XWikiCfgConfigurationSource.CFG_ENV_NAME; |
343 |
|
|
344 |
|
public static final String MACROS_FILE = "/templates/macros.txt"; |
345 |
|
|
346 |
|
|
347 |
|
|
348 |
|
|
349 |
|
private static final String VERSION_FILE = "/WEB-INF/version.properties"; |
350 |
|
|
351 |
|
|
352 |
|
@link |
353 |
|
|
354 |
|
private static final String VERSION_FILE_PROPERTY = "version"; |
355 |
|
|
356 |
|
private static XWikiInitializerJob job; |
357 |
|
|
358 |
|
|
359 |
|
private List<String> configuredSyntaxes; |
360 |
|
|
361 |
|
|
362 |
|
private EntityReferenceSerializer<String> defaultEntityReferenceSerializer; |
363 |
|
|
364 |
|
|
365 |
|
|
366 |
|
|
367 |
|
|
368 |
|
private DocumentReferenceResolver<String> currentMixedDocumentReferenceResolver; |
369 |
|
|
370 |
|
private DocumentReferenceResolver<EntityReference> currentReferenceDocumentReferenceResolver; |
371 |
|
|
372 |
|
private EntityReferenceResolver<String> currentMixedEntityReferenceResolver; |
373 |
|
|
374 |
|
private EntityReferenceResolver<String> relativeEntityReferenceResolver; |
375 |
|
|
376 |
|
private EntityReferenceSerializer<String> localStringEntityReferenceSerializer; |
377 |
|
|
378 |
|
private SyntaxFactory syntaxFactory; |
379 |
|
|
380 |
|
private ResourceReferenceManager resourceReferenceManager; |
381 |
|
|
382 |
|
private JobExecutor jobExecutor; |
383 |
|
|
384 |
|
private InternalSkinManager internalSkinManager; |
385 |
|
|
386 |
|
private TemplateManager templateManager; |
387 |
|
|
388 |
|
private RenderingContext renderingContext; |
389 |
|
|
390 |
|
|
391 |
|
|
392 |
|
|
393 |
|
@since |
394 |
|
|
395 |
|
private Boolean hasBacklinks; |
396 |
|
|
397 |
|
private ConfigurationSource xwikicfg; |
398 |
|
|
399 |
|
private ConfigurationSource wikiConfiguration; |
400 |
|
|
401 |
|
private ConfigurationSource userConfiguration; |
402 |
|
|
403 |
|
private ConfigurationSource spaceConfiguration; |
404 |
|
|
405 |
|
private EditConfiguration editConfiguration; |
406 |
|
|
407 |
|
private ObservationManager observationManager; |
408 |
|
|
409 |
|
private Provider<XWikiContext> xcontextProvider; |
410 |
|
|
411 |
|
private ContextualLocalizationManager localization; |
412 |
|
|
413 |
|
private Provider<OldRendering> oldRenderingProvider; |
414 |
|
|
415 |
|
private ParseGroovyFromString parseGroovyFromString; |
416 |
|
|
417 |
|
private JobProgressManager progress; |
418 |
|
|
419 |
|
private Provider<DocumentReference> defaultDocumentReferenceProvider; |
420 |
|
|
421 |
|
private DocumentReferenceResolver<EntityReference> currentgetdocumentResolver; |
422 |
|
|
423 |
|
private AttachmentReferenceResolver<EntityReference> currentAttachmentReferenceResolver; |
424 |
|
|
425 |
|
private WikiSkinUtils wikiSkinUtils; |
426 |
|
|
427 |
|
|
428 |
|
|
429 |
|
|
430 |
|
|
431 |
|
private List<String> SKIN_RESOURCE_SPACE_NAMES = Arrays.asList("skins", "resources"); |
432 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
433 |
1285888 |
private ConfigurationSource getConfiguration()... |
434 |
|
{ |
435 |
1285893 |
if (this.xwikicfg == null) { |
436 |
156 |
this.xwikicfg = Utils.getComponent(ConfigurationSource.class, XWikiCfgConfigurationSource.ROLEHINT); |
437 |
|
} |
438 |
|
|
439 |
1285885 |
return this.xwikicfg; |
440 |
|
} |
441 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
442 |
467106 |
private ConfigurationSource getWikiConfiguration()... |
443 |
|
{ |
444 |
467102 |
if (this.wikiConfiguration == null) { |
445 |
95 |
this.wikiConfiguration = Utils.getComponent(ConfigurationSource.class, "wiki"); |
446 |
|
} |
447 |
|
|
448 |
467088 |
return this.wikiConfiguration; |
449 |
|
} |
450 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
451 |
76029 |
private ConfigurationSource getSpaceConfiguration()... |
452 |
|
{ |
453 |
76029 |
if (this.spaceConfiguration == null) { |
454 |
34 |
this.spaceConfiguration = Utils.getComponent(ConfigurationSource.class, "space"); |
455 |
|
} |
456 |
|
|
457 |
76024 |
return this.spaceConfiguration; |
458 |
|
} |
459 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
460 |
7930 |
private ConfigurationSource getUserConfiguration()... |
461 |
|
{ |
462 |
7928 |
if (this.userConfiguration == null) { |
463 |
29 |
this.userConfiguration = Utils.getComponent(ConfigurationSource.class, "user"); |
464 |
|
} |
465 |
|
|
466 |
7928 |
return this.userConfiguration; |
467 |
|
} |
468 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
469 |
92 |
private EditConfiguration getEditConfiguration()... |
470 |
|
{ |
471 |
92 |
if (this.editConfiguration == null) { |
472 |
12 |
this.editConfiguration = Utils.getComponent(EditConfiguration.class); |
473 |
|
} |
474 |
|
|
475 |
92 |
return this.editConfiguration; |
476 |
|
} |
477 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
478 |
50810 |
private InternalSkinManager getInternalSkinManager()... |
479 |
|
{ |
480 |
50811 |
if (this.internalSkinManager == null) { |
481 |
36 |
this.internalSkinManager = Utils.getComponent(InternalSkinManager.class); |
482 |
|
} |
483 |
|
|
484 |
50807 |
return this.internalSkinManager; |
485 |
|
} |
486 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
487 |
78482 |
private TemplateManager getTemplateManager()... |
488 |
|
{ |
489 |
78479 |
if (this.templateManager == null) { |
490 |
35 |
this.templateManager = Utils.getComponent(TemplateManager.class); |
491 |
|
} |
492 |
|
|
493 |
78471 |
return this.templateManager; |
494 |
|
} |
495 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
496 |
12149 |
private RenderingContext getRenderingContext()... |
497 |
|
{ |
498 |
12193 |
if (this.renderingContext == null) { |
499 |
33 |
this.renderingContext = Utils.getComponent(RenderingContext.class); |
500 |
|
} |
501 |
|
|
502 |
12182 |
return this.renderingContext; |
503 |
|
} |
504 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
505 |
0 |
private MutableRenderingContext getMutableRenderingContext()... |
506 |
|
{ |
507 |
0 |
return getRenderingContext() instanceof MutableRenderingContext |
508 |
|
? (MutableRenderingContext) getRenderingContext() : null; |
509 |
|
} |
510 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
511 |
4145 |
private ObservationManager getObservationManager()... |
512 |
|
{ |
513 |
4145 |
if (this.observationManager == null) { |
514 |
103 |
this.observationManager = Utils.getComponent(ObservationManager.class); |
515 |
|
} |
516 |
|
|
517 |
4145 |
return this.observationManager; |
518 |
|
} |
519 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
520 |
0 |
private XWikiContext getXWikiContext()... |
521 |
|
{ |
522 |
0 |
if (this.xcontextProvider == null) { |
523 |
0 |
this.xcontextProvider = Utils.getComponent(XWikiContext.TYPE_PROVIDER); |
524 |
|
} |
525 |
|
|
526 |
0 |
return this.xcontextProvider.get(); |
527 |
|
} |
528 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
529 |
1069 |
private ContextualLocalizationManager getLocalization()... |
530 |
|
{ |
531 |
1069 |
if (this.localization == null) { |
532 |
66 |
this.localization = Utils.getComponent(ContextualLocalizationManager.class); |
533 |
|
} |
534 |
|
|
535 |
1069 |
return this.localization; |
536 |
|
} |
537 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
538 |
54 |
private OldRendering getOldRendering()... |
539 |
|
{ |
540 |
54 |
if (this.oldRenderingProvider == null) { |
541 |
8 |
this.oldRenderingProvider = Utils.getComponent(OldRendering.TYPE_PROVIDER); |
542 |
|
} |
543 |
|
|
544 |
54 |
return this.oldRenderingProvider.get(); |
545 |
|
} |
546 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
547 |
0 |
private ParseGroovyFromString getParseGroovyFromString()... |
548 |
|
{ |
549 |
0 |
if (this.parseGroovyFromString == null) { |
550 |
0 |
this.parseGroovyFromString = Utils.getComponent(ParseGroovyFromString.class); |
551 |
|
} |
552 |
|
|
553 |
0 |
return this.parseGroovyFromString; |
554 |
|
} |
555 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
556 |
522 |
private JobProgressManager getProgress()... |
557 |
|
{ |
558 |
522 |
if (this.progress == null) { |
559 |
87 |
this.progress = Utils.getComponent(JobProgressManager.class); |
560 |
|
} |
561 |
|
|
562 |
522 |
return this.progress; |
563 |
|
} |
564 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
565 |
0 |
private Provider<DocumentReference> getDefaultDocumentReferenceProvider()... |
566 |
|
{ |
567 |
0 |
if (this.defaultDocumentReferenceProvider == null) { |
568 |
0 |
this.defaultDocumentReferenceProvider = Utils.getComponent(DocumentReference.TYPE_PROVIDER); |
569 |
|
} |
570 |
|
|
571 |
0 |
return this.defaultDocumentReferenceProvider; |
572 |
|
} |
573 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
574 |
3052 |
private DocumentReferenceResolver<EntityReference> getCurrentGetDocumentResolver()... |
575 |
|
{ |
576 |
3052 |
if (this.currentgetdocumentResolver == null) { |
577 |
65 |
this.currentgetdocumentResolver = |
578 |
|
Utils.getComponent(DocumentReferenceResolver.TYPE_REFERENCE, "currentgetdocument"); |
579 |
|
} |
580 |
|
|
581 |
3052 |
return this.currentgetdocumentResolver; |
582 |
|
} |
583 |
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
584 |
1 |
private AttachmentReferenceResolver<EntityReference> getCurrentAttachmentResolver()... |
585 |
|
{ |
586 |
1 |
if (this.currentAttachmentReferenceResolver == null) { |
587 |
1 |
this.currentAttachmentReferenceResolver = |
588 |
|
Utils.getComponent(AttachmentReferenceResolver.TYPE_REFERENCE, "current"); |
589 |
|
} |
590 |
|
|
591 |
1 |
return this.currentAttachmentReferenceResolver; |
592 |
|
} |
593 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
594 |
87 |
private EntityReferenceSerializer<String> getDefaultEntityReferenceSerializer()... |
595 |
|
{ |
596 |
87 |
if (this.defaultEntityReferenceSerializer == null) { |
597 |
11 |
this.defaultEntityReferenceSerializer = Utils.getComponent(EntityReferenceSerializer.TYPE_STRING); |
598 |
|
} |
599 |
|
|
600 |
87 |
return this.defaultEntityReferenceSerializer; |
601 |
|
} |
602 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
603 |
53798 |
private DocumentReferenceResolver<String> getCurrentMixedDocumentReferenceResolver()... |
604 |
|
{ |
605 |
53798 |
if (this.currentMixedDocumentReferenceResolver == null) { |
606 |
41 |
this.currentMixedDocumentReferenceResolver = |
607 |
|
Utils.getComponent(DocumentReferenceResolver.TYPE_STRING, "currentmixed"); |
608 |
|
} |
609 |
|
|
610 |
53790 |
return this.currentMixedDocumentReferenceResolver; |
611 |
|
} |
612 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
613 |
2107 |
private DocumentReferenceResolver<EntityReference> getCurrentReferenceDocumentReferenceResolver()... |
614 |
|
{ |
615 |
2107 |
if (this.currentReferenceDocumentReferenceResolver == null) { |
616 |
60 |
this.currentReferenceDocumentReferenceResolver = |
617 |
|
Utils.getComponent(DocumentReferenceResolver.TYPE_REFERENCE, "current"); |
618 |
|
} |
619 |
|
|
620 |
2107 |
return this.currentReferenceDocumentReferenceResolver; |
621 |
|
} |
622 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
623 |
0 |
private EntityReferenceResolver<String> getCurrentMixedEntityReferenceResolver()... |
624 |
|
{ |
625 |
0 |
if (this.currentMixedEntityReferenceResolver == null) { |
626 |
0 |
this.currentMixedEntityReferenceResolver = |
627 |
|
Utils.getComponent(EntityReferenceResolver.TYPE_STRING, "currentmixed"); |
628 |
|
} |
629 |
|
|
630 |
0 |
return this.currentMixedEntityReferenceResolver; |
631 |
|
} |
632 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
633 |
29 |
private EntityReferenceResolver<String> getRelativeEntityReferenceResolver()... |
634 |
|
{ |
635 |
29 |
if (this.relativeEntityReferenceResolver == null) { |
636 |
10 |
this.relativeEntityReferenceResolver = Utils.getComponent(EntityReferenceResolver.TYPE_STRING, "relative"); |
637 |
|
} |
638 |
|
|
639 |
29 |
return this.relativeEntityReferenceResolver; |
640 |
|
} |
641 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
642 |
44315 |
private EntityReferenceSerializer<String> getLocalStringEntityReferenceSerializer()... |
643 |
|
{ |
644 |
44315 |
if (this.localStringEntityReferenceSerializer == null) { |
645 |
32 |
this.localStringEntityReferenceSerializer = |
646 |
|
Utils.getComponent(EntityReferenceSerializer.TYPE_STRING, "local"); |
647 |
|
} |
648 |
|
|
649 |
44313 |
return this.localStringEntityReferenceSerializer; |
650 |
|
} |
651 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
652 |
0 |
private SyntaxFactory getSyntaxFactory()... |
653 |
|
{ |
654 |
0 |
if (this.syntaxFactory == null) { |
655 |
0 |
this.syntaxFactory = Utils.getComponent(SyntaxFactory.class); |
656 |
|
} |
657 |
|
|
658 |
0 |
return this.syntaxFactory; |
659 |
|
} |
660 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
661 |
10251 |
private ResourceReferenceManager getResourceReferenceManager()... |
662 |
|
{ |
663 |
10241 |
if (this.resourceReferenceManager == null) { |
664 |
34 |
this.resourceReferenceManager = Utils.getComponent(ResourceReferenceManager.class); |
665 |
|
} |
666 |
|
|
667 |
10199 |
return this.resourceReferenceManager; |
668 |
|
} |
669 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
670 |
32 |
private JobExecutor getJobExecutor()... |
671 |
|
{ |
672 |
32 |
if (this.jobExecutor == null) { |
673 |
29 |
this.jobExecutor = Utils.getComponent(JobExecutor.class); |
674 |
|
} |
675 |
|
|
676 |
32 |
return this.jobExecutor; |
677 |
|
} |
678 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
679 |
0 |
private DocumentReference getDefaultDocumentReference()... |
680 |
|
{ |
681 |
0 |
return getDefaultDocumentReferenceProvider().get(); |
682 |
|
} |
683 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
684 |
0 |
private WikiSkinUtils getWikiSkinUtils()... |
685 |
|
{ |
686 |
0 |
if (this.wikiSkinUtils == null) { |
687 |
0 |
this.wikiSkinUtils = Utils.getComponent(WikiSkinUtils.class); |
688 |
|
} |
689 |
|
|
690 |
0 |
return this.wikiSkinUtils; |
691 |
|
} |
692 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
693 |
1069 |
private String localizePlainOrKey(String key, Object... parameters)... |
694 |
|
{ |
695 |
1069 |
return StringUtils.defaultString(getLocalization().getTranslationPlain(key, parameters), key); |
696 |
|
} |
697 |
|
|
698 |
|
|
699 |
|
@param@link |
700 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
701 |
0 |
public static XWiki getMainXWiki(XWikiContext context) throws XWikiException... |
702 |
|
{ |
703 |
0 |
return getMainXWiki(true, context); |
704 |
|
} |
705 |
|
|
706 |
|
|
707 |
|
@param@link |
708 |
|
@param@link |
709 |
|
|
|
|
| 89.3% |
Uncovered Elements: 3 (28) |
Complexity: 7 |
Complexity Density: 0.35 |
|
710 |
11433 |
public static XWiki getMainXWiki(boolean wait, XWikiContext context) throws XWikiException... |
711 |
|
{ |
712 |
11436 |
String xwikiname = DEFAULT_MAIN_WIKI; |
713 |
|
|
714 |
11413 |
context.setMainXWiki(xwikiname); |
715 |
|
|
716 |
11419 |
XWiki xwiki; |
717 |
|
|
718 |
11427 |
try { |
719 |
11427 |
XWikiEngineContext econtext = context.getEngineContext(); |
720 |
|
|
721 |
11404 |
xwiki = (XWiki) econtext.getAttribute(xwikiname); |
722 |
11449 |
if (xwiki == null) { |
723 |
|
|
724 |
36 |
synchronized (XWiki.class) { |
725 |
36 |
xwiki = (XWiki) econtext.getAttribute(xwikiname); |
726 |
36 |
if (xwiki == null && job == null) { |
727 |
32 |
job = Utils.getComponent((Type) Job.class, XWikiInitializerJob.JOBTYPE); |
728 |
|
|
729 |
32 |
if (job.getStatus() == null) { |
730 |
|
|
731 |
32 |
Utils.<XWikiStubContextProvider>getComponent(XWikiStubContextProvider.class) |
732 |
|
.initialize(context); |
733 |
|
|
734 |
32 |
job.startAsync(); |
735 |
|
} |
736 |
|
} |
737 |
|
} |
738 |
|
|
739 |
|
|
740 |
36 |
if (wait) { |
741 |
36 |
job.join(); |
742 |
36 |
xwiki = (XWiki) econtext.getAttribute(xwikiname); |
743 |
|
} |
744 |
|
} |
745 |
|
|
746 |
11449 |
context.setWiki(xwiki); |
747 |
|
|
748 |
11448 |
return xwiki; |
749 |
|
} catch (Exception e) { |
750 |
0 |
throw new XWikiException(XWikiException.MODULE_XWIKI, XWikiException.ERROR_XWIKI_INIT_FAILED, |
751 |
|
"Could not initialize main XWiki instance", e); |
752 |
|
} |
753 |
|
} |
754 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
755 |
0 |
public static boolean isInitializing(XWikiContext xcontext)... |
756 |
|
{ |
757 |
0 |
return Boolean.TRUE.equals(xcontext.getEngineContext().getAttribute("xwiki.init")); |
758 |
|
} |
759 |
|
|
760 |
|
|
761 |
|
|
762 |
|
|
763 |
|
@param@link |
764 |
|
@return |
765 |
|
@throws |
766 |
|
|
767 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
768 |
1796 |
public static XWiki getXWiki(XWikiContext context) throws XWikiException... |
769 |
|
{ |
770 |
1796 |
return getXWiki(true, context); |
771 |
|
} |
772 |
|
|
773 |
|
|
774 |
|
|
775 |
|
|
776 |
|
|
777 |
|
|
778 |
|
@param |
779 |
|
@param@link |
780 |
|
@return |
781 |
|
@throws |
782 |
|
|
783 |
|
|
|
|
| 74.1% |
Uncovered Elements: 7 (27) |
Complexity: 6 |
Complexity Density: 0.32 |
|
784 |
11445 |
public static XWiki getXWiki(boolean wait, XWikiContext xcontext) throws XWikiException... |
785 |
|
{ |
786 |
11442 |
XWiki xwiki = getMainXWiki(wait, xcontext); |
787 |
|
|
788 |
11449 |
if (xwiki == null) { |
789 |
0 |
return null; |
790 |
|
} |
791 |
|
|
792 |
|
|
793 |
11449 |
EntityResourceReference entityResourceReference = initializeResourceFromURL(xcontext); |
794 |
|
|
795 |
|
|
796 |
11449 |
String wikiId = entityResourceReference.getEntityReference().extractReference(EntityType.WIKI).getName(); |
797 |
11442 |
if (wikiId.equals(xcontext.getMainXWiki())) { |
798 |
|
|
799 |
11371 |
return xwiki; |
800 |
|
} |
801 |
|
|
802 |
|
|
803 |
65 |
WikiDescriptorManager wikiDescriptorManager = Utils.getComponent(WikiDescriptorManager.class); |
804 |
65 |
WikiDescriptor descriptor; |
805 |
65 |
try { |
806 |
65 |
descriptor = wikiDescriptorManager.getById(wikiId); |
807 |
|
} catch (WikiManagerException e) { |
808 |
0 |
throw new XWikiException(XWikiException.MODULE_XWIKI, XWikiException.ERROR_XWIKI_STORE_MISC, |
809 |
|
String.format("Failed find wiki descriptor for wiki id [%s]", wikiId), e); |
810 |
|
} |
811 |
65 |
if (descriptor == null) { |
812 |
0 |
throw new XWikiException(XWikiException.MODULE_XWIKI, XWikiException.ERROR_XWIKI_DOES_NOT_EXIST, |
813 |
|
String.format("The wiki [%s] does not exist", wikiId)); |
814 |
|
} |
815 |
|
|
816 |
|
|
817 |
|
|
818 |
65 |
xcontext.setWikiId(wikiId); |
819 |
65 |
xcontext.setOriginalWikiId(wikiId); |
820 |
|
|
821 |
64 |
if (!xwiki.initializeWiki(wikiId, wait, xcontext)) { |
822 |
|
|
823 |
0 |
return null; |
824 |
|
} |
825 |
|
|
826 |
65 |
return xwiki; |
827 |
|
} |
828 |
|
|
829 |
|
|
830 |
|
@param |
831 |
|
@return@link |
832 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
833 |
0 |
public Job getWikiInitializerJob(String wikiId)... |
834 |
|
{ |
835 |
0 |
return this.initializedWikis.get(wikiId); |
836 |
|
} |
837 |
|
|
838 |
|
|
839 |
|
|
840 |
|
|
841 |
|
@param |
842 |
|
@param |
843 |
|
@return |
844 |
|
@param |
845 |
|
@throws |
846 |
|
@since |
847 |
|
|
|
|
| 73.9% |
Uncovered Elements: 6 (23) |
Complexity: 7 |
Complexity Density: 0.47 |
|
848 |
96 |
public boolean initializeWiki(String wikiId, boolean wait, XWikiContext xcontext) throws XWikiException... |
849 |
|
{ |
850 |
96 |
Job wikiJob = this.initializedWikis.get(wikiId); |
851 |
|
|
852 |
|
|
853 |
97 |
if (wikiJob == null) { |
854 |
32 |
try { |
855 |
32 |
wikiJob = initializeWiki(wikiId, xcontext); |
856 |
|
} catch (JobException e) { |
857 |
0 |
throw new XWikiException(XWikiException.MODULE_XWIKI, XWikiException.ERROR_XWIKI_INIT_FAILED, |
858 |
|
"Could not start [" + wikiId + "] wiki initialization", e); |
859 |
|
} |
860 |
|
} |
861 |
|
|
862 |
|
|
863 |
97 |
if (wikiJob.getStatus().getState() == State.FINISHED) { |
864 |
64 |
return true; |
865 |
|
} |
866 |
|
|
867 |
|
|
868 |
32 |
if (wait) { |
869 |
32 |
try { |
870 |
32 |
wikiJob.join(); |
871 |
|
} catch (InterruptedException e) { |
872 |
0 |
throw new XWikiException(XWikiException.MODULE_XWIKI, XWikiException.ERROR_XWIKI_INIT_FAILED, |
873 |
|
"Wiki [" + wikiId + "] initialization was interrupted unexpectedly", e); |
874 |
|
} |
875 |
|
|
876 |
32 |
if (wikiJob.getStatus().getError() != null) { |
877 |
0 |
throw new XWikiException(XWikiException.MODULE_XWIKI, XWikiException.ERROR_XWIKI_INIT_FAILED, |
878 |
|
"Wiki [" + wikiId + "] initialization failed", wikiJob.getStatus().getError()); |
879 |
|
} |
880 |
|
|
881 |
32 |
return true; |
882 |
|
} |
883 |
|
|
884 |
|
|
885 |
0 |
return false; |
886 |
|
} |
887 |
|
|
|
|
| 90% |
Uncovered Elements: 1 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
888 |
32 |
private Job initializeWiki(String wikiId, XWikiContext xcontext) throws JobException... |
889 |
|
{ |
890 |
32 |
synchronized (this.initializedWikis) { |
891 |
32 |
WikiInitializerJob wikiJob = this.initializedWikis.get(wikiId); |
892 |
|
|
893 |
32 |
if (wikiJob == null) { |
894 |
32 |
WikiInitializerRequest request = new WikiInitializerRequest(wikiId); |
895 |
|
|
896 |
32 |
JobRequestContext.set(request, xcontext); |
897 |
|
|
898 |
32 |
wikiJob = (WikiInitializerJob) getJobExecutor().execute(WikiInitializerJob.JOBTYPE, request); |
899 |
32 |
this.initializedWikis.put(wikiId, wikiJob); |
900 |
|
} |
901 |
|
|
902 |
32 |
return wikiJob; |
903 |
|
} |
904 |
|
} |
905 |
|
|
|
|
| 90.9% |
Uncovered Elements: 1 (11) |
Complexity: 2 |
Complexity Density: 0.18 |
|
906 |
11446 |
private static EntityResourceReference initializeResourceFromURL(XWikiContext context) throws XWikiException... |
907 |
|
{ |
908 |
|
|
909 |
|
|
910 |
|
|
911 |
|
|
912 |
11445 |
@SuppressWarnings("deprecation") |
913 |
|
EntityResourceReference entityResourceReference; |
914 |
11447 |
URL url = context.getURL(); |
915 |
11438 |
try { |
916 |
11436 |
ExtendedURL extendedURL = new ExtendedURL(url, context.getRequest().getContextPath()); |
917 |
11447 |
ResourceTypeResolver<ExtendedURL> typeResolver = |
918 |
|
Utils.getComponent(new DefaultParameterizedType(null, ResourceTypeResolver.class, ExtendedURL.class)); |
919 |
11449 |
ResourceType type = typeResolver.resolve(extendedURL, Collections.<String, Object>emptyMap()); |
920 |
11449 |
ResourceReferenceResolver<ExtendedURL> resourceResolver = Utils |
921 |
|
.getComponent(new DefaultParameterizedType(null, ResourceReferenceResolver.class, ExtendedURL.class)); |
922 |
11449 |
entityResourceReference = (EntityResourceReference) resourceResolver.resolve(extendedURL, type, |
923 |
|
Collections.<String, Object>emptyMap()); |
924 |
|
} catch (Exception e) { |
925 |
0 |
throw new XWikiException(XWikiException.MODULE_XWIKI, XWikiException.ERROR_XWIKI_APP_URL_EXCEPTION, |
926 |
|
String.format("Failed to extract Entity Resource Reference from URL [%s]", url), e); |
927 |
|
} |
928 |
11448 |
Utils.getComponent(Execution.class).getContext().setProperty(ResourceReferenceManager.RESOURCE_CONTEXT_PROPERTY, |
929 |
|
entityResourceReference); |
930 |
|
|
931 |
11449 |
return entityResourceReference; |
932 |
|
} |
933 |
|
|
|
|
| 88.9% |
Uncovered Elements: 1 (9) |
Complexity: 4 |
Complexity Density: 0.57 |
|
934 |
11438 |
public static URL getRequestURL(XWikiRequest request) throws XWikiException... |
935 |
|
{ |
936 |
11438 |
try { |
937 |
11439 |
StringBuffer requestURL = request.getRequestURL(); |
938 |
11435 |
String qs = request.getQueryString(); |
939 |
11437 |
if ((qs != null) && (!qs.equals(""))) { |
940 |
8081 |
return new URL(requestURL.toString() + "?" + qs); |
941 |
|
} else { |
942 |
3340 |
return new URL(requestURL.toString()); |
943 |
|
} |
944 |
|
} catch (Exception e) { |
945 |
0 |
throw new XWikiException(XWikiException.MODULE_XWIKI_APP, XWikiException.ERROR_XWIKI_APP_URL_EXCEPTION, |
946 |
|
"Exception while getting URL from request", e); |
947 |
|
} |
948 |
|
} |
949 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
950 |
0 |
public static Object callPrivateMethod(Object obj, String methodName)... |
951 |
|
{ |
952 |
0 |
return callPrivateMethod(obj, methodName, null, null); |
953 |
|
} |
954 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 4 |
Complexity Density: 0.44 |
|
955 |
0 |
public static Object callPrivateMethod(Object obj, String methodName, Class<?>[] classes, Object[] args)... |
956 |
|
{ |
957 |
0 |
try { |
958 |
0 |
Method method = obj.getClass().getDeclaredMethod(methodName, classes); |
959 |
0 |
method.setAccessible(true); |
960 |
0 |
return method.invoke(obj, args); |
961 |
|
} catch (IllegalAccessException e) { |
962 |
0 |
LOGGER.error("Failed to call private method [{}]: [{}]", methodName, e); |
963 |
|
|
964 |
0 |
return null; |
965 |
|
} catch (NoSuchMethodException e) { |
966 |
0 |
return null; |
967 |
|
} catch (InvocationTargetException e) { |
968 |
0 |
LOGGER.error("Private method [{}] failed: [{}]", methodName, e); |
969 |
|
|
970 |
0 |
return null; |
971 |
|
} |
972 |
|
} |
973 |
|
|
|
|
| 0% |
Uncovered Elements: 26 (26) |
Complexity: 8 |
Complexity Density: 0.44 |
|
974 |
0 |
public static HttpClient getHttpClient(int timeout, String userAgent)... |
975 |
|
{ |
976 |
0 |
HttpClient client = new HttpClient(); |
977 |
|
|
978 |
0 |
if (timeout != 0) { |
979 |
0 |
client.getParams().setSoTimeout(timeout); |
980 |
0 |
client.getParams().setParameter("http.connection.timeout", Integer.valueOf(timeout)); |
981 |
|
} |
982 |
|
|
983 |
0 |
client.getParams().setParameter("http.useragent", userAgent); |
984 |
|
|
985 |
0 |
String proxyHost = System.getProperty("http.proxyHost"); |
986 |
0 |
String proxyPort = System.getProperty("http.proxyPort"); |
987 |
0 |
if ((proxyHost != null) && (!proxyHost.equals(""))) { |
988 |
0 |
int port = 3128; |
989 |
0 |
if ((proxyPort != null) && (!proxyPort.equals(""))) { |
990 |
0 |
port = Integer.parseInt(proxyPort); |
991 |
|
} |
992 |
0 |
client.getHostConfiguration().setProxy(proxyHost, port); |
993 |
|
} |
994 |
|
|
995 |
0 |
String proxyUser = System.getProperty("http.proxyUser"); |
996 |
0 |
if ((proxyUser != null) && (!proxyUser.equals(""))) { |
997 |
0 |
String proxyPassword = System.getProperty("http.proxyPassword"); |
998 |
0 |
Credentials defaultcreds = new UsernamePasswordCredentials(proxyUser, proxyPassword); |
999 |
0 |
client.getState().setProxyCredentials(AuthScope.ANY, defaultcreds); |
1000 |
|
} |
1001 |
|
|
1002 |
0 |
return client; |
1003 |
|
} |
1004 |
|
|
1005 |
|
|
1006 |
|
|
1007 |
|
|
1008 |
|
@param |
1009 |
|
@param |
1010 |
|
@return |
1011 |
|
@deprecated@link |
1012 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 3 |
Complexity Density: 0.43 |
|
1013 |
0 |
@Deprecated... |
1014 |
|
public static Object getPrivateField(Object obj, String fieldName) |
1015 |
|
{ |
1016 |
0 |
try { |
1017 |
0 |
Field field = obj.getClass().getDeclaredField(fieldName); |
1018 |
0 |
field.setAccessible(true); |
1019 |
0 |
return field.get(obj); |
1020 |
|
} catch (NoSuchFieldException e) { |
1021 |
0 |
return null; |
1022 |
|
} catch (IllegalAccessException e) { |
1023 |
0 |
LOGGER.error("Failed to get private field with name [{}]: [{}]", fieldName, e); |
1024 |
|
|
1025 |
0 |
return null; |
1026 |
|
} finally { |
1027 |
|
} |
1028 |
|
} |
1029 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1030 |
10631 |
public static String getServerWikiPage(String servername)... |
1031 |
|
{ |
1032 |
10631 |
return "XWiki.XWikiServer" + StringUtils.capitalize(servername); |
1033 |
|
} |
1034 |
|
|
1035 |
|
|
1036 |
|
@param |
1037 |
|
@param@link |
1038 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
1039 |
0 |
public static String getTextArea(String content, XWikiContext context)... |
1040 |
|
{ |
1041 |
0 |
StringBuilder result = new StringBuilder(); |
1042 |
|
|
1043 |
|
|
1044 |
|
|
1045 |
|
|
1046 |
0 |
result.append("<textarea name=\"content\" id=\"content\" rows=\"25\" cols=\"80\">\n"); |
1047 |
0 |
result.append(XMLUtils.escape(content)); |
1048 |
0 |
result.append("</textarea>"); |
1049 |
|
|
1050 |
0 |
return result.toString(); |
1051 |
|
} |
1052 |
|
|
1053 |
|
|
1054 |
|
|
1055 |
|
|
1056 |
|
|
1057 |
|
|
1058 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
1059 |
483 |
public XWiki()... |
1060 |
|
{ |
1061 |
|
|
1062 |
|
} |
1063 |
|
|
1064 |
|
|
1065 |
|
|
1066 |
|
|
1067 |
|
@param@link |
1068 |
|
@param@link |
1069 |
|
|
1070 |
|
@param |
1071 |
|
|
1072 |
|
@throws |
1073 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1074 |
32 |
public XWiki(XWikiContext context, XWikiEngineContext engineContext, boolean noupdate) throws XWikiException... |
1075 |
|
{ |
1076 |
32 |
initXWiki(context, engineContext, noupdate); |
1077 |
|
} |
1078 |
|
|
1079 |
|
|
1080 |
|
|
1081 |
|
|
1082 |
|
@param@link |
1083 |
|
@throws |
1084 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1085 |
0 |
public XWiki(XWikiContext context) throws XWikiException... |
1086 |
|
{ |
1087 |
0 |
this(context, null, false); |
1088 |
|
} |
1089 |
|
|
1090 |
|
|
1091 |
|
|
1092 |
|
|
1093 |
|
@param@link |
1094 |
|
@param@link |
1095 |
|
|
1096 |
|
@param |
1097 |
|
|
1098 |
|
@throws |
1099 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1100 |
32 |
public void initXWiki(XWikiContext context, XWikiEngineContext engineContext, boolean noupdate)... |
1101 |
|
throws XWikiException |
1102 |
|
{ |
1103 |
32 |
initXWiki(null, context, engineContext, noupdate); |
1104 |
|
} |
1105 |
|
|
1106 |
|
|
1107 |
|
|
1108 |
|
|
1109 |
|
@param |
1110 |
|
@param@link |
1111 |
|
@param@link |
1112 |
|
|
1113 |
|
@param |
1114 |
|
|
1115 |
|
@throws |
1116 |
|
@deprecated@link |
1117 |
|
|
|
|
| 89.8% |
Uncovered Elements: 5 (49) |
Complexity: 7 |
Complexity Density: 0.19 |
|
1118 |
87 |
@Deprecated... |
1119 |
|
public void initXWiki(XWikiConfig config, XWikiContext context, XWikiEngineContext engineContext, boolean noupdate) |
1120 |
|
throws XWikiException |
1121 |
|
{ |
1122 |
87 |
getProgress().pushLevelProgress(4, this); |
1123 |
|
|
1124 |
87 |
try { |
1125 |
87 |
getProgress().startStep(this); |
1126 |
|
|
1127 |
87 |
setDatabase(context.getMainXWiki()); |
1128 |
|
|
1129 |
87 |
setEngineContext(engineContext); |
1130 |
87 |
context.setWiki(this); |
1131 |
|
|
1132 |
|
|
1133 |
|
|
1134 |
87 |
Utils.<XWikiStubContextProvider>getComponent(XWikiStubContextProvider.class).initialize(context); |
1135 |
|
|
1136 |
|
|
1137 |
87 |
if (config != null) { |
1138 |
55 |
setConfig(config); |
1139 |
|
} |
1140 |
|
|
1141 |
87 |
XWikiStoreInterface mainStore = Utils.getComponent(XWikiStoreInterface.class, |
1142 |
|
getConfiguration().getProperty("xwiki.store.main.hint", "hibernate")); |
1143 |
|
|
1144 |
|
|
1145 |
87 |
boolean nocache = "0".equals(getConfiguration().getProperty("xwiki.store.cache", "1")); |
1146 |
87 |
if (!nocache) { |
1147 |
87 |
XWikiCacheStoreInterface cachestore = new XWikiCacheStore(mainStore, context); |
1148 |
87 |
setStore(cachestore); |
1149 |
|
} else { |
1150 |
0 |
setStore(mainStore); |
1151 |
|
} |
1152 |
|
|
1153 |
87 |
setCriteriaService((XWikiCriteriaService) createClassFromConfig("xwiki.criteria.class", |
1154 |
|
"com.xpn.xwiki.criteria.impl.XWikiCriteriaServiceImpl", context)); |
1155 |
|
|
1156 |
87 |
setAttachmentStore(Utils.<XWikiAttachmentStoreInterface>getComponent(XWikiAttachmentStoreInterface.class, |
1157 |
|
getConfiguration().getProperty("xwiki.store.attachment.hint", "hibernate"))); |
1158 |
|
|
1159 |
87 |
setVersioningStore(Utils.<XWikiVersioningStoreInterface>getComponent(XWikiVersioningStoreInterface.class, |
1160 |
|
getConfiguration().getProperty("xwiki.store.versioning.hint", "hibernate"))); |
1161 |
|
|
1162 |
87 |
setAttachmentVersioningStore(Utils.<AttachmentVersioningStore>getComponent(AttachmentVersioningStore.class, |
1163 |
87 |
hasAttachmentVersioning(context) |
1164 |
|
? getConfiguration().getProperty("xwiki.store.attachment.versioning.hint", "hibernate") : "void")); |
1165 |
|
|
1166 |
87 |
if (hasRecycleBin(context)) { |
1167 |
87 |
setRecycleBinStore( |
1168 |
|
Utils.<XWikiRecycleBinStoreInterface>getComponent(XWikiRecycleBinStoreInterface.class, |
1169 |
|
getConfiguration().getProperty("xwiki.store.recyclebin.hint", "hibernate"))); |
1170 |
|
} |
1171 |
|
|
1172 |
87 |
if (hasAttachmentRecycleBin(context)) { |
1173 |
87 |
setAttachmentRecycleBinStore( |
1174 |
|
Utils.<AttachmentRecycleBinStore>getComponent(AttachmentRecycleBinStore.class, |
1175 |
|
getConfiguration().getProperty("xwiki.store.attachment.recyclebin.hint", "hibernate"))); |
1176 |
|
} |
1177 |
|
|
1178 |
|
|
1179 |
|
|
1180 |
87 |
Utils.<XWikiStubContextProvider>getComponent(XWikiStubContextProvider.class).initialize(context); |
1181 |
|
|
1182 |
87 |
getProgress().startStep(this); |
1183 |
|
|
1184 |
|
|
1185 |
87 |
if (noupdate) { |
1186 |
60 |
initializeMandatoryDocuments(context); |
1187 |
60 |
getStatsService(context); |
1188 |
|
} |
1189 |
|
|
1190 |
87 |
getProgress().startStep(this); |
1191 |
|
|
1192 |
|
|
1193 |
87 |
preparePlugins(context); |
1194 |
|
|
1195 |
87 |
getProgress().startStep(this); |
1196 |
|
|
1197 |
87 |
String ro = getConfiguration().getProperty("xwiki.readonly", "no"); |
1198 |
87 |
this.isReadOnly = ("yes".equalsIgnoreCase(ro) || "true".equalsIgnoreCase(ro) || "1".equalsIgnoreCase(ro)); |
1199 |
|
|
1200 |
|
|
1201 |
87 |
String syntaxes = getConfiguration().getProperty("xwiki.rendering.syntaxes", "xwiki/1.0"); |
1202 |
87 |
this.configuredSyntaxes = Arrays.asList(StringUtils.split(syntaxes, " ,")); |
1203 |
|
|
1204 |
87 |
getObservationManager().addListener(this); |
1205 |
|
} finally { |
1206 |
87 |
getProgress().popLevelProgress(this); |
1207 |
|
} |
1208 |
|
} |
1209 |
|
|
1210 |
|
|
1211 |
|
|
1212 |
|
|
1213 |
|
|
1214 |
|
@param@link |
1215 |
|
|
|
|
| 85.7% |
Uncovered Elements: 1 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
1216 |
92 |
public void initializeMandatoryDocuments(XWikiContext context)... |
1217 |
|
{ |
1218 |
92 |
if (context.get("initdone") == null) { |
1219 |
92 |
@SuppressWarnings("deprecation") |
1220 |
|
List<MandatoryDocumentInitializer> initializers = |
1221 |
|
Utils.getComponentList(MandatoryDocumentInitializer.class); |
1222 |
|
|
1223 |
|
|
1224 |
92 |
Collections.sort(initializers, new Comparator<MandatoryDocumentInitializer>() |
1225 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
1226 |
2103 |
@Override... |
1227 |
|
public int compare(MandatoryDocumentInitializer left, MandatoryDocumentInitializer right) |
1228 |
|
{ |
1229 |
2103 |
Priority leftPriority = left.getClass().getAnnotation(Priority.class); |
1230 |
2103 |
int leftPriorityValue = |
1231 |
2103 |
leftPriority != null ? leftPriority.value() : MandatoryDocumentInitializer.DEFAULT_PRIORITY; |
1232 |
|
|
1233 |
2103 |
Priority rightPriority = right.getClass().getAnnotation(Priority.class); |
1234 |
2103 |
int rightPriorityValue = |
1235 |
2103 |
rightPriority != null ? rightPriority.value() : MandatoryDocumentInitializer.DEFAULT_PRIORITY; |
1236 |
|
|
1237 |
|
|
1238 |
2103 |
return leftPriorityValue - rightPriorityValue; |
1239 |
|
} |
1240 |
|
}); |
1241 |
|
|
1242 |
92 |
for (MandatoryDocumentInitializer initializer : initializers) { |
1243 |
2107 |
initializeMandatoryDocument(initializer, context); |
1244 |
|
} |
1245 |
|
} |
1246 |
|
} |
1247 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
1248 |
0 |
private void initializeMandatoryDocument(String wiki, MandatoryDocumentInitializer initializer,... |
1249 |
|
XWikiContext context) |
1250 |
|
{ |
1251 |
0 |
String currentWiki = context.getWikiId(); |
1252 |
|
|
1253 |
0 |
try { |
1254 |
0 |
context.setWikiId(wiki); |
1255 |
|
|
1256 |
0 |
initializeMandatoryDocument(initializer, context); |
1257 |
|
} finally { |
1258 |
0 |
context.setWikiId(currentWiki); |
1259 |
|
} |
1260 |
|
} |
1261 |
|
|
|
|
| 90.9% |
Uncovered Elements: 1 (11) |
Complexity: 4 |
Complexity Density: 0.57 |
|
1262 |
2107 |
private void initializeMandatoryDocument(MandatoryDocumentInitializer initializer, XWikiContext context)... |
1263 |
|
{ |
1264 |
2107 |
try { |
1265 |
2107 |
DocumentReference documentReference = |
1266 |
|
getCurrentReferenceDocumentReferenceResolver().resolve(initializer.getDocumentReference()); |
1267 |
|
|
1268 |
2107 |
if (documentReference.getWikiReference().getName().equals(context.getWikiId())) { |
1269 |
2095 |
XWikiDocument document = context.getWiki().getDocument(documentReference, context); |
1270 |
|
|
1271 |
2095 |
if (initializer.updateDocument(document)) { |
1272 |
914 |
saveDocument(document, |
1273 |
|
localizePlainOrKey("core.model.xclass.mandatoryUpdateProperty.versionSummary"), context); |
1274 |
|
} |
1275 |
|
} |
1276 |
|
} catch (XWikiException e) { |
1277 |
0 |
LOGGER.error("Failed to initialize mandatory document", e); |
1278 |
|
} |
1279 |
|
} |
1280 |
|
|
|
|
| 83.3% |
Uncovered Elements: 1 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
1281 |
12 |
public XWikiStoreInterface getNotCacheStore()... |
1282 |
|
{ |
1283 |
12 |
XWikiStoreInterface store = getStore(); |
1284 |
12 |
if (store instanceof XWikiCacheStoreInterface) { |
1285 |
12 |
store = ((XWikiCacheStoreInterface) store).getStore(); |
1286 |
|
} |
1287 |
12 |
return store; |
1288 |
|
} |
1289 |
|
|
|
|
| 60% |
Uncovered Elements: 6 (15) |
Complexity: 4 |
Complexity Density: 0.44 |
|
1290 |
11297 |
public XWikiHibernateStore getHibernateStore()... |
1291 |
|
{ |
1292 |
11296 |
XWikiStoreInterface store = getStore(); |
1293 |
11298 |
if (store instanceof XWikiHibernateStore) { |
1294 |
0 |
return (XWikiHibernateStore) store; |
1295 |
11294 |
} else if (store instanceof XWikiCacheStoreInterface) { |
1296 |
11295 |
store = ((XWikiCacheStoreInterface) store).getStore(); |
1297 |
11295 |
if (store instanceof XWikiHibernateStore) { |
1298 |
11293 |
return (XWikiHibernateStore) store; |
1299 |
|
} else { |
1300 |
0 |
return null; |
1301 |
|
} |
1302 |
|
} else { |
1303 |
0 |
return null; |
1304 |
|
} |
1305 |
|
} |
1306 |
|
|
1307 |
|
|
1308 |
|
@param |
1309 |
|
@param@link |
1310 |
|
@deprecated@link |
1311 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1312 |
0 |
@Deprecated... |
1313 |
|
public void updateDatabase(String wikiId, XWikiContext context) throws HibernateException, XWikiException |
1314 |
|
{ |
1315 |
0 |
updateDatabase(wikiId, false, context); |
1316 |
|
} |
1317 |
|
|
1318 |
|
|
1319 |
|
@param |
1320 |
|
@param@link |
1321 |
|
@deprecated@link |
1322 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1323 |
0 |
@Deprecated... |
1324 |
|
public void updateDatabase(String wikiId, boolean force, XWikiContext context) |
1325 |
|
throws HibernateException, XWikiException |
1326 |
|
{ |
1327 |
0 |
updateDatabase(wikiId, force, true, context); |
1328 |
|
} |
1329 |
|
|
1330 |
|
|
1331 |
|
@param |
1332 |
|
@param |
1333 |
|
@param |
1334 |
|
@param@link |
1335 |
|
@deprecated@link |
1336 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1337 |
0 |
@Deprecated... |
1338 |
|
public void updateDatabase(String wikiId, boolean force, boolean initDocuments, XWikiContext context) |
1339 |
|
throws HibernateException, XWikiException |
1340 |
|
{ |
1341 |
0 |
initializeWiki(wikiId, true, context); |
1342 |
|
} |
1343 |
|
|
1344 |
|
|
1345 |
|
@return |
1346 |
|
@link |
1347 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1348 |
0 |
@Deprecated... |
1349 |
|
public List<String> getVirtualWikiList() |
1350 |
|
{ |
1351 |
0 |
return new ArrayList<>(this.initializedWikis.keySet()); |
1352 |
|
} |
1353 |
|
|
1354 |
|
|
1355 |
|
@param@link |
1356 |
|
@return |
1357 |
|
|
1358 |
|
|
1359 |
|
|
1360 |
|
|
1361 |
|
|
1362 |
|
|
1363 |
|
|
1364 |
|
|
1365 |
|
@deprecated@link |
1366 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
1367 |
93 |
@Deprecated... |
1368 |
|
public List<String> getVirtualWikisDatabaseNames(XWikiContext context) throws XWikiException |
1369 |
|
{ |
1370 |
93 |
WikiDescriptorManager descriptorManager = Utils.getComponent(WikiDescriptorManager.class); |
1371 |
|
|
1372 |
93 |
try { |
1373 |
93 |
return new ArrayList<String>(descriptorManager.getAllIds()); |
1374 |
|
} catch (WikiManagerException e) { |
1375 |
0 |
throw new XWikiException(XWikiException.MODULE_XWIKI, XWikiException.ERROR_XWIKI_UNKNOWN, |
1376 |
|
"Failed to get the list of wikis", e); |
1377 |
|
} |
1378 |
|
} |
1379 |
|
|
1380 |
|
|
1381 |
|
@return |
1382 |
|
@since |
1383 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1384 |
0 |
@Deprecated... |
1385 |
|
public Cache<DocumentReference> getVirtualWikiCache() |
1386 |
|
{ |
1387 |
0 |
return null; |
1388 |
|
} |
1389 |
|
|
1390 |
|
|
1391 |
|
|
1392 |
|
|
1393 |
|
@param |
1394 |
|
@param@link |
1395 |
|
@return |
1396 |
|
@throws |
1397 |
|
|
|
|
| 71.4% |
Uncovered Elements: 6 (21) |
Complexity: 4 |
Complexity Density: 0.27 |
|
1398 |
582 |
public String getWikiOwner(String wikiName, XWikiContext context) throws XWikiException... |
1399 |
|
{ |
1400 |
582 |
String wikiOwner; |
1401 |
|
|
1402 |
582 |
String currentdatabase = context.getWikiId(); |
1403 |
582 |
try { |
1404 |
582 |
context.setWikiId(context.getMainXWiki()); |
1405 |
|
|
1406 |
582 |
String serverwikipage = getServerWikiPage(wikiName); |
1407 |
582 |
XWikiDocument doc = getDocument(serverwikipage, context); |
1408 |
|
|
1409 |
582 |
if (doc.isNew()) { |
1410 |
0 |
if (!context.isMainWiki(wikiName)) { |
1411 |
0 |
throw new XWikiException(XWikiException.MODULE_XWIKI, XWikiException.ERROR_XWIKI_DOES_NOT_EXIST, |
1412 |
|
"The wiki " + wikiName + " does not exist"); |
1413 |
|
} else { |
1414 |
0 |
wikiOwner = null; |
1415 |
|
} |
1416 |
|
} else { |
1417 |
582 |
wikiOwner = doc.getStringValue(VIRTUAL_WIKI_DEFINITION_CLASS_REFERENCE, "owner"); |
1418 |
580 |
if (wikiOwner.indexOf(':') == -1) { |
1419 |
580 |
wikiOwner = context.getMainXWiki() + ":" + wikiOwner; |
1420 |
|
} |
1421 |
|
} |
1422 |
|
} finally { |
1423 |
582 |
context.setWikiId(currentdatabase); |
1424 |
|
} |
1425 |
|
|
1426 |
582 |
return wikiOwner; |
1427 |
|
} |
1428 |
|
|
1429 |
|
|
1430 |
|
@param@link |
1431 |
|
|
|
|
| 46.2% |
Uncovered Elements: 7 (13) |
Complexity: 3 |
Complexity Density: 0.27 |
|
1432 |
87 |
protected Object createClassFromConfig(String param, String defClass, XWikiContext context) throws XWikiException... |
1433 |
|
{ |
1434 |
87 |
String storeclass = getConfiguration().getProperty(param, defClass); |
1435 |
87 |
try { |
1436 |
87 |
Class<?>[] classes = new Class<?>[] { XWikiContext.class }; |
1437 |
87 |
Object[] args = new Object[] { context }; |
1438 |
87 |
Object result = Class.forName(storeclass).getConstructor(classes).newInstance(args); |
1439 |
87 |
return result; |
1440 |
|
} catch (Exception e) { |
1441 |
0 |
Throwable ecause = e; |
1442 |
0 |
if (e instanceof InvocationTargetException) { |
1443 |
0 |
ecause = ((InvocationTargetException) e).getTargetException(); |
1444 |
|
} |
1445 |
0 |
Object[] args = { param, storeclass }; |
1446 |
0 |
throw new XWikiException(XWikiException.MODULE_XWIKI_STORE, |
1447 |
|
XWikiException.ERROR_XWIKI_STORE_CLASSINVOCATIONERROR, "Cannot load class {1} from param {0}", ecause, |
1448 |
|
args); |
1449 |
|
} |
1450 |
|
} |
1451 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
1452 |
87 |
private void preparePlugins(XWikiContext context)... |
1453 |
|
{ |
1454 |
87 |
setPluginManager(new XWikiPluginManager(getXWikiPreference("plugins", context), context)); |
1455 |
87 |
String plugins = getConfiguration().getProperty("xwiki.plugins", ""); |
1456 |
87 |
if (!plugins.equals("")) { |
1457 |
32 |
getPluginManager().addPlugins(StringUtils.split(plugins, " ,"), context); |
1458 |
|
} |
1459 |
|
} |
1460 |
|
|
1461 |
|
|
1462 |
|
@return@link |
1463 |
|
|
|
|
| 83.3% |
Uncovered Elements: 2 (12) |
Complexity: 3 |
Complexity Density: 0.3 |
|
1464 |
2772 |
@SuppressWarnings("deprecation")... |
1465 |
|
public String getVersion() |
1466 |
|
{ |
1467 |
2772 |
if (this.version == null) { |
1468 |
30 |
try { |
1469 |
30 |
InputStream is = getResourceAsStream(VERSION_FILE); |
1470 |
30 |
try { |
1471 |
30 |
XWikiConfig properties = new XWikiConfig(is); |
1472 |
30 |
this.version = properties.getProperty(VERSION_FILE_PROPERTY); |
1473 |
|
} finally { |
1474 |
30 |
IOUtils.closeQuietly(is); |
1475 |
|
} |
1476 |
|
} catch (Exception e) { |
1477 |
|
|
1478 |
0 |
LOGGER.warn("Failed to retrieve XWiki's version from [" + VERSION_FILE + "], using the [" |
1479 |
|
+ VERSION_FILE_PROPERTY + "] property.", e); |
1480 |
0 |
this.version = "Unknown version"; |
1481 |
|
} |
1482 |
|
} |
1483 |
2768 |
return this.version; |
1484 |
|
} |
1485 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1486 |
30972 |
public URL getResource(String s) throws MalformedURLException... |
1487 |
|
{ |
1488 |
30972 |
return getEngineContext().getResource(s); |
1489 |
|
} |
1490 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
1491 |
9551 |
public InputStream getResourceAsStream(String s) throws MalformedURLException... |
1492 |
|
{ |
1493 |
9550 |
InputStream is = getEngineContext().getResourceAsStream(s); |
1494 |
9558 |
if (is == null) { |
1495 |
8387 |
is = getEngineContext().getResourceAsStream("/" + s); |
1496 |
|
} |
1497 |
9558 |
return is; |
1498 |
|
} |
1499 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 4 |
Complexity Density: 0.44 |
|
1500 |
0 |
public String getResourceContent(String name) throws IOException... |
1501 |
|
{ |
1502 |
0 |
InputStream is = null; |
1503 |
0 |
if (getEngineContext() != null) { |
1504 |
|
|
1505 |
0 |
try { |
1506 |
0 |
is = getResourceAsStream(name); |
1507 |
|
} catch (Exception e) { |
1508 |
|
} |
1509 |
|
} |
1510 |
|
|
1511 |
0 |
if (is == null) { |
1512 |
|
|
1513 |
0 |
return FileUtils.readFileToString(new File(name), DEFAULT_ENCODING); |
1514 |
|
} |
1515 |
|
|
1516 |
0 |
try { |
1517 |
0 |
return IOUtils.toString(is, DEFAULT_ENCODING); |
1518 |
|
} finally { |
1519 |
0 |
IOUtils.closeQuietly(is); |
1520 |
|
} |
1521 |
|
} |
1522 |
|
|
|
|
| 57.1% |
Uncovered Elements: 3 (7) |
Complexity: 3 |
Complexity Density: 0.6 |
|
1523 |
318 |
public Date getResourceLastModificationDate(String name)... |
1524 |
|
{ |
1525 |
318 |
try { |
1526 |
318 |
if (getEngineContext() != null) { |
1527 |
318 |
return Util.getFileLastModificationDate(getEngineContext().getRealPath(name)); |
1528 |
|
} |
1529 |
|
} catch (Exception ex) { |
1530 |
|
|
1531 |
0 |
LOGGER.info("Failed to get file modification date: " + ex.getMessage()); |
1532 |
|
} |
1533 |
0 |
return new Date(); |
1534 |
|
} |
1535 |
|
|
|
|
| 92.3% |
Uncovered Elements: 1 (13) |
Complexity: 4 |
Complexity Density: 0.44 |
|
1536 |
9494 |
public byte[] getResourceContentAsBytes(String name) throws IOException... |
1537 |
|
{ |
1538 |
9494 |
InputStream is = null; |
1539 |
9484 |
if (getEngineContext() != null) { |
1540 |
|
|
1541 |
9487 |
try { |
1542 |
9486 |
is = getResourceAsStream(name); |
1543 |
|
} catch (Exception e) { |
1544 |
|
} |
1545 |
|
} |
1546 |
|
|
1547 |
9500 |
if (is == null) { |
1548 |
8387 |
return FileUtils.readFileToByteArray(new File(name)); |
1549 |
|
} |
1550 |
|
|
1551 |
1113 |
try { |
1552 |
1113 |
return IOUtils.toByteArray(is); |
1553 |
|
} finally { |
1554 |
1112 |
IOUtils.closeQuietly(is); |
1555 |
|
} |
1556 |
|
} |
1557 |
|
|
|
|
| 83.3% |
Uncovered Elements: 2 (12) |
Complexity: 5 |
Complexity Density: 0.62 |
|
1558 |
30973 |
public boolean resourceExists(String name)... |
1559 |
|
{ |
1560 |
30971 |
if (getEngineContext() != null) { |
1561 |
30972 |
try { |
1562 |
30973 |
if (getResource(name) != null) { |
1563 |
30972 |
return true; |
1564 |
|
} |
1565 |
|
} catch (IOException e) { |
1566 |
|
} |
1567 |
|
} |
1568 |
1 |
try { |
1569 |
1 |
File file = new File(name); |
1570 |
1 |
return file.exists(); |
1571 |
|
} catch (Exception e) { |
1572 |
|
|
1573 |
|
} |
1574 |
0 |
return false; |
1575 |
|
} |
1576 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1577 |
0 |
public String getRealPath(String path)... |
1578 |
|
{ |
1579 |
0 |
return getEngineContext().getRealPath(path); |
1580 |
|
} |
1581 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
1582 |
0 |
public String ParamAsRealPath(String key)... |
1583 |
|
{ |
1584 |
0 |
String param = getConfiguration().getProperty(key); |
1585 |
0 |
try { |
1586 |
0 |
return getRealPath(param); |
1587 |
|
} catch (Exception e) { |
1588 |
0 |
return param; |
1589 |
|
} |
1590 |
|
} |
1591 |
|
|
1592 |
|
|
1593 |
|
@param@link |
1594 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1595 |
0 |
public String ParamAsRealPath(String key, XWikiContext context)... |
1596 |
|
{ |
1597 |
0 |
return ParamAsRealPath(key); |
1598 |
|
} |
1599 |
|
|
|
|
| 0% |
Uncovered Elements: 23 (23) |
Complexity: 5 |
Complexity Density: 0.33 |
|
1600 |
0 |
public String ParamAsRealPathVerified(String param)... |
1601 |
|
{ |
1602 |
0 |
String path; |
1603 |
0 |
File fpath; |
1604 |
|
|
1605 |
0 |
path = getConfiguration().getProperty(param); |
1606 |
0 |
if (path == null) { |
1607 |
0 |
return null; |
1608 |
|
} |
1609 |
|
|
1610 |
0 |
fpath = new File(path); |
1611 |
0 |
if (fpath.exists()) { |
1612 |
0 |
return path; |
1613 |
|
} |
1614 |
|
|
1615 |
0 |
path = getRealPath(path); |
1616 |
0 |
if (path == null) { |
1617 |
0 |
return null; |
1618 |
|
} |
1619 |
|
|
1620 |
0 |
fpath = new File(path); |
1621 |
0 |
if (fpath.exists()) { |
1622 |
0 |
return path; |
1623 |
|
} else { |
1624 |
|
} |
1625 |
0 |
return null; |
1626 |
|
} |
1627 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1628 |
985334 |
public XWikiStoreInterface getStore()... |
1629 |
|
{ |
1630 |
985319 |
return this.store; |
1631 |
|
} |
1632 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1633 |
726 |
public XWikiAttachmentStoreInterface getAttachmentStore()... |
1634 |
|
{ |
1635 |
726 |
return this.attachmentStore; |
1636 |
|
} |
1637 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1638 |
903 |
public AttachmentVersioningStore getAttachmentVersioningStore()... |
1639 |
|
{ |
1640 |
903 |
return this.attachmentVersioningStore; |
1641 |
|
} |
1642 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1643 |
11133 |
public XWikiVersioningStoreInterface getVersioningStore()... |
1644 |
|
{ |
1645 |
11133 |
return this.versioningStore; |
1646 |
|
} |
1647 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1648 |
467 |
public XWikiRecycleBinStoreInterface getRecycleBinStore()... |
1649 |
|
{ |
1650 |
468 |
return this.recycleBinStore; |
1651 |
|
} |
1652 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1653 |
5 |
public AttachmentRecycleBinStore getAttachmentRecycleBinStore()... |
1654 |
|
{ |
1655 |
5 |
return this.attachmentRecycleBinStore; |
1656 |
|
} |
1657 |
|
|
1658 |
|
|
1659 |
|
@param |
1660 |
|
@param@link |
1661 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1662 |
387 |
public void saveDocument(XWikiDocument doc, XWikiContext context) throws XWikiException... |
1663 |
|
{ |
1664 |
|
|
1665 |
387 |
saveDocument(doc, "", context); |
1666 |
|
} |
1667 |
|
|
1668 |
|
|
1669 |
|
@param |
1670 |
|
@param |
1671 |
|
@param@link |
1672 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1673 |
3564 |
public void saveDocument(XWikiDocument doc, String comment, XWikiContext context) throws XWikiException... |
1674 |
|
{ |
1675 |
3564 |
saveDocument(doc, comment, false, context); |
1676 |
|
} |
1677 |
|
|
1678 |
|
|
1679 |
|
@param |
1680 |
|
@param |
1681 |
|
@param |
1682 |
|
@param@link |
1683 |
|
|
|
|
| 87.8% |
Uncovered Elements: 6 (49) |
Complexity: 10 |
Complexity Density: 0.3 |
|
1684 |
3900 |
public void saveDocument(XWikiDocument document, String comment, boolean isMinorEdit, XWikiContext context)... |
1685 |
|
throws XWikiException |
1686 |
|
{ |
1687 |
3900 |
String currentWiki = context.getWikiId(); |
1688 |
|
|
1689 |
3900 |
try { |
1690 |
|
|
1691 |
3900 |
context.setWikiId(document.getDocumentReference().getWikiReference().getName()); |
1692 |
|
|
1693 |
|
|
1694 |
3900 |
document.setComment(StringUtils.defaultString(comment)); |
1695 |
3900 |
document.setMinorEdit(isMinorEdit); |
1696 |
|
|
1697 |
|
|
1698 |
|
|
1699 |
3900 |
XWikiDocument originalDocument = document.getOriginalDocument(); |
1700 |
|
|
1701 |
|
|
1702 |
|
|
1703 |
|
|
1704 |
|
|
1705 |
3900 |
if (originalDocument == null) { |
1706 |
2190 |
originalDocument = |
1707 |
|
getDocument(new DocumentReference(document.getDocumentReference(), document.getLocale()), context); |
1708 |
2190 |
document.setOriginalDocument(originalDocument); |
1709 |
|
} |
1710 |
|
|
1711 |
3900 |
ObservationManager om = getObservationManager(); |
1712 |
|
|
1713 |
|
|
1714 |
|
|
1715 |
|
|
1716 |
|
|
1717 |
|
|
1718 |
3900 |
if (om != null) { |
1719 |
3900 |
CancelableEvent documentEvent; |
1720 |
3900 |
if (originalDocument.isNew()) { |
1721 |
3472 |
documentEvent = new DocumentCreatingEvent(document.getDocumentReference()); |
1722 |
|
} else { |
1723 |
428 |
documentEvent = new DocumentUpdatingEvent(document.getDocumentReference()); |
1724 |
|
} |
1725 |
3900 |
om.notify(documentEvent, document, context); |
1726 |
|
|
1727 |
|
|
1728 |
3900 |
if (documentEvent.isCanceled()) { |
1729 |
0 |
throw new XWikiException(XWikiException.MODULE_XWIKI_STORE, |
1730 |
|
XWikiException.ERROR_XWIKI_STORE_HIBERNATE_SAVING_DOC, |
1731 |
|
String.format("An Event Listener has cancelled the document save for [%s]. Reason: [%s]", |
1732 |
|
document.getDocumentReference(), documentEvent.getReason())); |
1733 |
|
} |
1734 |
|
} |
1735 |
|
|
1736 |
|
|
1737 |
3900 |
if (hasAttachmentRecycleBin(context)) { |
1738 |
3897 |
for (XWikiAttachmentToRemove attachment : document.getAttachmentsToRemove()) { |
1739 |
5 |
if (attachment.isToRecycleBin()) { |
1740 |
5 |
getAttachmentRecycleBinStore().saveToRecycleBin(attachment.getAttachment(), context.getUser(), |
1741 |
|
new Date(), context, true); |
1742 |
|
} |
1743 |
|
} |
1744 |
|
} |
1745 |
|
|
1746 |
|
|
1747 |
3900 |
getStore().saveXWikiDoc(document, context); |
1748 |
|
|
1749 |
|
|
1750 |
|
|
1751 |
3900 |
XWikiDocument newOriginal = document.getOriginalDocument(); |
1752 |
|
|
1753 |
3900 |
try { |
1754 |
3900 |
document.setOriginalDocument(originalDocument); |
1755 |
|
|
1756 |
|
|
1757 |
|
|
1758 |
|
|
1759 |
|
|
1760 |
|
|
1761 |
|
|
1762 |
|
|
1763 |
|
|
1764 |
|
|
1765 |
3900 |
if (om != null) { |
1766 |
3900 |
if (originalDocument.isNew()) { |
1767 |
3472 |
om.notify(new DocumentCreatedEvent(document.getDocumentReference()), document, context); |
1768 |
|
} else { |
1769 |
428 |
om.notify(new DocumentUpdatedEvent(document.getDocumentReference()), document, context); |
1770 |
|
} |
1771 |
|
} |
1772 |
|
} catch (Exception ex) { |
1773 |
0 |
LOGGER.error("Failed to send document save notification for document [" |
1774 |
|
+ getDefaultEntityReferenceSerializer().serialize(document.getDocumentReference()) + "]", ex); |
1775 |
|
} finally { |
1776 |
3900 |
document.setOriginalDocument(newOriginal); |
1777 |
|
} |
1778 |
|
} finally { |
1779 |
3900 |
context.setWikiId(currentWiki); |
1780 |
|
} |
1781 |
|
} |
1782 |
|
|
1783 |
|
|
1784 |
|
|
1785 |
|
|
1786 |
|
|
1787 |
|
|
1788 |
|
|
1789 |
|
|
1790 |
|
|
1791 |
|
|
1792 |
|
@param |
1793 |
|
@param@link |
1794 |
|
@since |
1795 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1796 |
601 |
public XWikiDocument getDocument(EntityReference reference, XWikiContext context) throws XWikiException... |
1797 |
|
{ |
1798 |
601 |
return getDocument(getCurrentGetDocumentResolver().resolve(reference), context); |
1799 |
|
} |
1800 |
|
|
1801 |
|
|
1802 |
|
@param |
1803 |
|
@param@link |
1804 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
1805 |
586150 |
public XWikiDocument getDocument(XWikiDocument doc, XWikiContext context) throws XWikiException... |
1806 |
|
{ |
1807 |
586136 |
String currentWiki = context.getWikiId(); |
1808 |
586103 |
try { |
1809 |
586122 |
context.setWikiId(doc.getDocumentReference().getWikiReference().getName()); |
1810 |
|
|
1811 |
586148 |
return getStore().loadXWikiDoc(doc, context); |
1812 |
|
} finally { |
1813 |
586156 |
context.setWikiId(currentWiki); |
1814 |
|
} |
1815 |
|
} |
1816 |
|
|
1817 |
|
|
1818 |
|
@param |
1819 |
|
@param |
1820 |
|
@param@link |
1821 |
|
|
|
|
| 78.3% |
Uncovered Elements: 5 (23) |
Complexity: 8 |
Complexity Density: 0.53 |
|
1822 |
46 |
public XWikiDocument getDocument(XWikiDocument doc, String revision, XWikiContext context) throws XWikiException... |
1823 |
|
{ |
1824 |
46 |
XWikiDocument newdoc; |
1825 |
|
|
1826 |
46 |
String database = context.getWikiId(); |
1827 |
46 |
try { |
1828 |
46 |
if (doc.getDocumentReference().getWikiReference().getName() != null) { |
1829 |
46 |
context.setWikiId(doc.getDocumentReference().getWikiReference().getName()); |
1830 |
|
} |
1831 |
|
|
1832 |
46 |
if ((revision == null) || revision.equals("")) { |
1833 |
0 |
newdoc = new XWikiDocument(doc.getDocumentReference()); |
1834 |
46 |
} else if (revision.equals(doc.getVersion())) { |
1835 |
16 |
newdoc = doc; |
1836 |
|
} else { |
1837 |
30 |
newdoc = getVersioningStore().loadXWikiDoc(doc, revision, context); |
1838 |
|
} |
1839 |
|
} catch (XWikiException e) { |
1840 |
2 |
if (revision.equals("1.1") || revision.equals("1.0")) { |
1841 |
2 |
newdoc = new XWikiDocument(doc.getDocumentReference()); |
1842 |
|
} else { |
1843 |
0 |
throw e; |
1844 |
|
} |
1845 |
|
} finally { |
1846 |
46 |
context.setWikiId(database); |
1847 |
|
} |
1848 |
|
|
1849 |
46 |
return newdoc; |
1850 |
|
} |
1851 |
|
|
1852 |
|
|
1853 |
|
@param |
1854 |
|
@param@link |
1855 |
|
@since |
1856 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
1857 |
566495 |
public XWikiDocument getDocument(DocumentReference reference, XWikiContext context) throws XWikiException... |
1858 |
|
{ |
1859 |
566476 |
XWikiDocument doc = new XWikiDocument( |
1860 |
566425 |
reference.getLocale() != null ? new DocumentReference(reference, null) : reference, reference.getLocale()); |
1861 |
|
|
1862 |
566458 |
doc.setContentDirty(true); |
1863 |
|
|
1864 |
566450 |
return getDocument(doc, context); |
1865 |
|
} |
1866 |
|
|
1867 |
|
|
1868 |
|
@param |
1869 |
|
@param@link |
1870 |
|
@deprecated@link |
1871 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
1872 |
19682 |
@Deprecated... |
1873 |
|
public XWikiDocument getDocument(String fullname, XWikiContext context) throws XWikiException |
1874 |
|
{ |
1875 |
19677 |
XWikiDocument doc = new XWikiDocument(); |
1876 |
19679 |
doc.setFullName(fullname, context); |
1877 |
19683 |
return getDocument(doc, context); |
1878 |
|
} |
1879 |
|
|
1880 |
|
|
1881 |
|
@param |
1882 |
|
@param |
1883 |
|
@param@link |
1884 |
|
@deprecated@link |
1885 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 3 |
Complexity Density: 0.38 |
|
1886 |
0 |
@Deprecated... |
1887 |
|
public XWikiDocument getDocument(String spaces, String fullname, XWikiContext context) throws XWikiException |
1888 |
|
{ |
1889 |
0 |
int dotPosition = fullname.lastIndexOf('.'); |
1890 |
0 |
if (dotPosition != -1) { |
1891 |
0 |
String spaceFromFullname = fullname.substring(0, dotPosition); |
1892 |
0 |
String name = fullname.substring(dotPosition + 1); |
1893 |
0 |
if (name.equals("")) { |
1894 |
0 |
name = getDefaultPage(context); |
1895 |
|
} |
1896 |
0 |
return getDocument(spaceFromFullname + "." + name, context); |
1897 |
|
} else { |
1898 |
0 |
return getDocument(spaces + "." + fullname, context); |
1899 |
|
} |
1900 |
|
} |
1901 |
|
|
1902 |
|
|
1903 |
|
@see |
1904 |
|
|
|
|
| 71.4% |
Uncovered Elements: 2 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
1905 |
304 |
public XWikiDeletedDocument[] getDeletedDocuments(String fullname, String locale, XWikiContext context)... |
1906 |
|
throws XWikiException |
1907 |
|
{ |
1908 |
303 |
if (hasRecycleBin(context)) { |
1909 |
303 |
XWikiDocument doc = new XWikiDocument(getCurrentMixedDocumentReferenceResolver().resolve(fullname)); |
1910 |
304 |
doc.setLanguage(locale); |
1911 |
304 |
return getRecycleBinStore().getAllDeletedDocuments(doc, context, true); |
1912 |
|
} else { |
1913 |
0 |
return null; |
1914 |
|
} |
1915 |
|
} |
1916 |
|
|
1917 |
|
|
1918 |
|
@see |
1919 |
|
|
|
|
| 71.4% |
Uncovered Elements: 2 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
1920 |
2 |
public XWikiDeletedDocument getDeletedDocument(String fullname, String locale, int index, XWikiContext context)... |
1921 |
|
throws XWikiException |
1922 |
|
{ |
1923 |
2 |
if (hasRecycleBin(context)) { |
1924 |
2 |
XWikiDocument doc = new XWikiDocument(getCurrentMixedDocumentReferenceResolver().resolve(fullname)); |
1925 |
2 |
doc.setLanguage(locale); |
1926 |
2 |
return getRecycleBinStore().getDeletedDocument(doc, index, context, true); |
1927 |
|
} else { |
1928 |
0 |
return null; |
1929 |
|
} |
1930 |
|
} |
1931 |
|
|
1932 |
|
|
1933 |
|
|
1934 |
|
|
1935 |
|
|
1936 |
|
|
1937 |
|
|
1938 |
|
@param@link |
1939 |
|
@param@link |
1940 |
|
@return |
1941 |
|
|
1942 |
|
@throws |
1943 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
1944 |
0 |
public List<DeletedAttachment> getDeletedAttachments(String docName, XWikiContext context) throws XWikiException... |
1945 |
|
{ |
1946 |
0 |
if (hasAttachmentRecycleBin(context)) { |
1947 |
0 |
XWikiDocument doc = new XWikiDocument(getCurrentMixedDocumentReferenceResolver().resolve(docName)); |
1948 |
0 |
return getAttachmentRecycleBinStore().getAllDeletedAttachments(doc, context, true); |
1949 |
|
} |
1950 |
0 |
return null; |
1951 |
|
} |
1952 |
|
|
1953 |
|
|
1954 |
|
|
1955 |
|
|
1956 |
|
|
1957 |
|
|
1958 |
|
|
1959 |
|
|
1960 |
|
@param@link |
1961 |
|
@param@link |
1962 |
|
@param@link |
1963 |
|
@return |
1964 |
|
|
1965 |
|
@throws |
1966 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
1967 |
0 |
public List<DeletedAttachment> getDeletedAttachments(String docName, String filename, XWikiContext context)... |
1968 |
|
throws XWikiException |
1969 |
|
{ |
1970 |
0 |
if (hasAttachmentRecycleBin(context)) { |
1971 |
0 |
XWikiDocument doc = new XWikiDocument(getCurrentMixedDocumentReferenceResolver().resolve(docName)); |
1972 |
0 |
XWikiAttachment attachment = new XWikiAttachment(doc, filename); |
1973 |
0 |
return getAttachmentRecycleBinStore().getAllDeletedAttachments(attachment, context, true); |
1974 |
|
} |
1975 |
0 |
return null; |
1976 |
|
} |
1977 |
|
|
1978 |
|
|
1979 |
|
|
1980 |
|
|
1981 |
|
@param |
1982 |
|
@param |
1983 |
|
@return |
1984 |
|
@throws |
1985 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
1986 |
0 |
public DeletedAttachment getDeletedAttachment(String id, XWikiContext context) throws XWikiException... |
1987 |
|
{ |
1988 |
0 |
if (hasAttachmentRecycleBin(context)) { |
1989 |
0 |
return getAttachmentRecycleBinStore().getDeletedAttachment(NumberUtils.toLong(id), context, true); |
1990 |
|
} |
1991 |
0 |
return null; |
1992 |
|
} |
1993 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
1994 |
188 |
public MetaClass getMetaclass()... |
1995 |
|
{ |
1996 |
188 |
if (this.metaclass == null) { |
1997 |
2 |
this.metaclass = MetaClass.getMetaClass(); |
1998 |
|
} |
1999 |
188 |
return this.metaclass; |
2000 |
|
} |
2001 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
2002 |
0 |
public void setMetaclass(MetaClass metaclass)... |
2003 |
|
{ |
2004 |
0 |
this.metaclass = metaclass; |
2005 |
|
} |
2006 |
|
|
2007 |
|
|
2008 |
|
@param@link |
2009 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
2010 |
28 |
public List<String> getClassList(XWikiContext context) throws XWikiException... |
2011 |
|
{ |
2012 |
28 |
List<String> result = getStore().getClassList(context); |
2013 |
28 |
Collections.sort(result); |
2014 |
28 |
return result; |
2015 |
|
} |
2016 |
|
|
2017 |
|
|
2018 |
|
@param |
2019 |
|
@param@link |
2020 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
2021 |
0 |
public <T> List<T> search(String sql, XWikiContext context) throws XWikiException... |
2022 |
|
{ |
2023 |
0 |
return getStore().search(sql, 0, 0, context); |
2024 |
|
} |
2025 |
|
|
2026 |
|
|
2027 |
|
@param |
2028 |
|
@param |
2029 |
|
@param |
2030 |
|
@param@link |
2031 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
2032 |
0 |
public <T> List<T> search(String sql, int nb, int start, XWikiContext context) throws XWikiException... |
2033 |
|
{ |
2034 |
0 |
return getStore().search(sql, nb, start, context); |
2035 |
|
} |
2036 |
|
|
2037 |
|
|
2038 |
|
@param |
2039 |
|
@param@link |
2040 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
2041 |
1 |
public <T> List<T> search(String sql, Object[][] whereParams, XWikiContext context) throws XWikiException... |
2042 |
|
{ |
2043 |
1 |
return getStore().search(sql, 0, 0, whereParams, context); |
2044 |
|
} |
2045 |
|
|
2046 |
|
|
2047 |
|
@param |
2048 |
|
@param |
2049 |
|
@param |
2050 |
|
@param@link |
2051 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
2052 |
0 |
public <T> List<T> search(String sql, int nb, int start, Object[][] whereParams, XWikiContext context)... |
2053 |
|
throws XWikiException |
2054 |
|
{ |
2055 |
0 |
return getStore().search(sql, nb, start, whereParams, context); |
2056 |
|
} |
2057 |
|
|
2058 |
|
|
2059 |
|
@param |
2060 |
|
@param@link |
2061 |
|
@deprecated |
2062 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
2063 |
46 |
@Deprecated... |
2064 |
|
public String parseContent(String content, XWikiContext context) |
2065 |
|
{ |
2066 |
46 |
return getOldRendering().parseContent(content, context); |
2067 |
|
} |
2068 |
|
|
2069 |
|
|
2070 |
|
@param |
2071 |
|
@param@link |
2072 |
|
@deprecated@link |
2073 |
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
|
2074 |
71467 |
@Deprecated... |
2075 |
|
public String parseTemplate(String template, XWikiContext context) |
2076 |
|
{ |
2077 |
71467 |
String result = ""; |
2078 |
|
|
2079 |
71459 |
try { |
2080 |
71463 |
result = evaluateTemplate(template, context); |
2081 |
|
} catch (Exception e) { |
2082 |
0 |
LOGGER.debug("Exception while parsing template [{}] from /templates/", template, e); |
2083 |
|
} |
2084 |
|
|
2085 |
71460 |
return result; |
2086 |
|
} |
2087 |
|
|
2088 |
|
|
2089 |
|
|
2090 |
|
|
2091 |
|
@param |
2092 |
|
@param@link |
2093 |
|
@return |
2094 |
|
@throws |
2095 |
|
@since |
2096 |
|
@deprecated@link |
2097 |
|
|
|
|
| 33.3% |
Uncovered Elements: 4 (6) |
Complexity: 2 |
Complexity Density: 0.33 |
|
2098 |
78475 |
@Deprecated... |
2099 |
|
public String evaluateTemplate(String template, XWikiContext context) throws IOException |
2100 |
|
{ |
2101 |
78473 |
try { |
2102 |
78471 |
return getTemplateManager().render(template); |
2103 |
|
} catch (Exception e) { |
2104 |
0 |
LOGGER.error("Error while evaluating velocity template [{}]", template, e); |
2105 |
|
|
2106 |
0 |
Object[] args = { template }; |
2107 |
0 |
XWikiException xe = new XWikiException(XWikiException.MODULE_XWIKI_RENDERING, |
2108 |
|
XWikiException.ERROR_XWIKI_RENDERING_VELOCITY_EXCEPTION, "Error while evaluating velocity template {0}", |
2109 |
|
e, args); |
2110 |
|
|
2111 |
0 |
return Util.getHTMLExceptionMessage(xe, context); |
2112 |
|
} |
2113 |
|
} |
2114 |
|
|
2115 |
|
|
2116 |
|
@param |
2117 |
|
@param |
2118 |
|
@param@link |
2119 |
|
@deprecated@link |
2120 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 2 |
Complexity Density: 0.18 |
|
2121 |
0 |
@Deprecated... |
2122 |
|
public String parseTemplate(String template, String skinId, XWikiContext context) |
2123 |
|
{ |
2124 |
0 |
MutableRenderingContext mutableRenderingContext = getMutableRenderingContext(); |
2125 |
|
|
2126 |
0 |
Syntax currentTargetSyntax = mutableRenderingContext.getTargetSyntax(); |
2127 |
0 |
try { |
2128 |
|
|
2129 |
0 |
mutableRenderingContext.setTargetSyntax(Syntax.XHTML_1_0); |
2130 |
|
|
2131 |
0 |
Skin skin = getInternalSkinManager().getSkin(skinId); |
2132 |
0 |
return getTemplateManager().renderFromSkin(template, skin); |
2133 |
|
} catch (Exception e) { |
2134 |
0 |
LOGGER.error("Error while evaluating velocity template [{}] skin [{}]", template, skinId, e); |
2135 |
|
|
2136 |
0 |
Object[] args = { template, skinId }; |
2137 |
0 |
XWikiException xe = new XWikiException(XWikiException.MODULE_XWIKI_RENDERING, |
2138 |
|
XWikiException.ERROR_XWIKI_RENDERING_VELOCITY_EXCEPTION, |
2139 |
|
"Error while evaluating velocity template [{0}] from skin [{1}]", e, args); |
2140 |
|
|
2141 |
0 |
return Util.getHTMLExceptionMessage(xe, context); |
2142 |
|
} finally { |
2143 |
0 |
mutableRenderingContext.setTargetSyntax(currentTargetSyntax); |
2144 |
|
} |
2145 |
|
} |
2146 |
|
|
2147 |
|
|
2148 |
|
@param |
2149 |
|
@param |
2150 |
|
@param@link |
2151 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
2152 |
0 |
public String renderTemplate(String template, String skin, XWikiContext context)... |
2153 |
|
{ |
2154 |
0 |
try { |
2155 |
0 |
return getOldRendering().renderTemplate(template, skin, context); |
2156 |
|
} catch (Exception ex) { |
2157 |
0 |
LOGGER.error("Failed to render template [" + template + "] for skin [" + skin + "]", ex); |
2158 |
0 |
return parseTemplate(template, skin, context); |
2159 |
|
} |
2160 |
|
} |
2161 |
|
|
2162 |
|
|
2163 |
|
@param |
2164 |
|
@param@link |
2165 |
|
|
|
|
| 50% |
Uncovered Elements: 2 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
2166 |
8 |
public String renderTemplate(String template, XWikiContext context)... |
2167 |
|
{ |
2168 |
8 |
try { |
2169 |
8 |
return getOldRendering().renderTemplate(template, context); |
2170 |
|
} catch (Exception ex) { |
2171 |
0 |
LOGGER.error("Failed to render template [" + template + "]", ex); |
2172 |
0 |
return parseTemplate(template, context); |
2173 |
|
} |
2174 |
|
} |
2175 |
|
|
2176 |
|
|
2177 |
|
|
2178 |
|
|
2179 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.33 |
|
2180 |
0 |
public String invokeServletAndReturnAsString(String url, XWikiContext xwikiContext)... |
2181 |
|
{ |
2182 |
|
|
2183 |
0 |
HttpServletRequest servletRequest = xwikiContext.getRequest(); |
2184 |
0 |
HttpServletResponse servletResponse = xwikiContext.getResponse(); |
2185 |
|
|
2186 |
0 |
try { |
2187 |
0 |
return IncludeServletAsString.invokeServletAndReturnAsString(url, servletRequest, servletResponse); |
2188 |
|
} catch (Exception e) { |
2189 |
0 |
LOGGER.warn("Exception including url: " + url, e); |
2190 |
0 |
return "Exception including \"" + url + "\", see logs for details."; |
2191 |
|
} |
2192 |
|
|
2193 |
|
} |
2194 |
|
|
2195 |
|
|
2196 |
|
@param |
2197 |
|
|
2198 |
|
@param@link |
2199 |
|
@return |
2200 |
|
@since |
2201 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
2202 |
19 |
public String getIconURL(String iconName, XWikiContext context)... |
2203 |
|
{ |
2204 |
|
|
2205 |
|
|
2206 |
19 |
return getSkinFile("icons/silk/" + iconName + ".png", context); |
2207 |
|
} |
2208 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
2209 |
14444 |
public String getSkinFile(String filename, XWikiContext context)... |
2210 |
|
{ |
2211 |
14444 |
return getSkinFile(filename, false, context); |
2212 |
|
} |
2213 |
|
|
|
|
| 55.6% |
Uncovered Elements: 16 (36) |
Complexity: 9 |
Complexity Density: 0.41 |
|
2214 |
36364 |
public String getSkinFile(String filename, boolean forceSkinAction, XWikiContext context)... |
2215 |
|
{ |
2216 |
36362 |
XWikiURLFactory urlf = context.getURLFactory(); |
2217 |
|
|
2218 |
36360 |
try { |
2219 |
|
|
2220 |
36361 |
Skin skin = getInternalSkinManager().getCurrentSkin(true); |
2221 |
36367 |
if (skin != null) { |
2222 |
36367 |
Resource<?> resource = skin.getResource(filename); |
2223 |
36367 |
if (resource != null) { |
2224 |
5394 |
return resource.getURL(forceSkinAction); |
2225 |
|
} |
2226 |
|
} else { |
2227 |
|
|
2228 |
0 |
Skin parentSkin = getInternalSkinManager().getCurrentParentSkin(true); |
2229 |
0 |
if (parentSkin != null) { |
2230 |
0 |
Resource<?> resource = parentSkin.getResource(filename); |
2231 |
0 |
if (resource != null) { |
2232 |
0 |
return resource.getURL(forceSkinAction); |
2233 |
|
} |
2234 |
|
} |
2235 |
|
} |
2236 |
|
|
2237 |
|
|
2238 |
30973 |
if (resourceExists("/resources/" + filename)) { |
2239 |
30972 |
URL url = urlf.createResourceURL(filename, forceSkinAction, context); |
2240 |
30971 |
return urlf.getURL(url, context); |
2241 |
|
} |
2242 |
|
} catch (Exception e) { |
2243 |
0 |
if (LOGGER.isDebugEnabled()) { |
2244 |
0 |
LOGGER.debug("Exception while getting skin file [" + filename + "]", e); |
2245 |
|
} |
2246 |
|
} |
2247 |
|
|
2248 |
|
|
2249 |
1 |
URL url; |
2250 |
1 |
if (forceSkinAction) { |
2251 |
1 |
url = urlf.createSkinURL(filename, "skins", getDefaultBaseSkin(context), context); |
2252 |
|
} else { |
2253 |
0 |
url = urlf.createSkinURL(filename, getDefaultBaseSkin(context), context); |
2254 |
|
} |
2255 |
1 |
return urlf.getURL(url, context); |
2256 |
|
} |
2257 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
2258 |
0 |
public String getSkinFile(String filename, String skin, XWikiContext context)... |
2259 |
|
{ |
2260 |
0 |
return getSkinFile(filename, skin, false, context); |
2261 |
|
} |
2262 |
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 5 |
Complexity Density: 0.42 |
|
2263 |
0 |
public String getSkinFile(String filename, String skinId, boolean forceSkinAction, XWikiContext context)... |
2264 |
|
{ |
2265 |
0 |
try { |
2266 |
0 |
Skin skin = getInternalSkinManager().getSkin(skinId); |
2267 |
|
|
2268 |
0 |
Resource<?> resource = skin.getLocalResource(filename); |
2269 |
|
|
2270 |
0 |
if (resource != null) { |
2271 |
0 |
return resource.getURL(forceSkinAction); |
2272 |
|
} |
2273 |
|
|
2274 |
|
|
2275 |
0 |
if (resourceExists("/resources/" + filename)) { |
2276 |
0 |
XWikiURLFactory urlf = context.getURLFactory(); |
2277 |
|
|
2278 |
0 |
URL url = urlf.createResourceURL(filename, forceSkinAction, context); |
2279 |
0 |
return urlf.getURL(url, context); |
2280 |
|
} |
2281 |
|
} catch (Exception e) { |
2282 |
0 |
if (LOGGER.isDebugEnabled()) { |
2283 |
0 |
LOGGER.debug("Exception while getting skin file [{}] from skin [{}]", filename, skinId, e); |
2284 |
|
} |
2285 |
|
} |
2286 |
|
|
2287 |
0 |
return null; |
2288 |
|
} |
2289 |
|
|
2290 |
|
|
2291 |
|
@deprecated@link |
2292 |
|
|
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.33 |
|
2293 |
11169 |
@Deprecated... |
2294 |
|
public String getSkin(XWikiContext context) |
2295 |
|
{ |
2296 |
11168 |
String skin; |
2297 |
|
|
2298 |
11168 |
try { |
2299 |
11167 |
skin = getInternalSkinManager().getCurrentSkinId(true); |
2300 |
|
} catch (Exception e) { |
2301 |
0 |
LOGGER.debug("Exception while determining current skin", e); |
2302 |
0 |
skin = getDefaultBaseSkin(context); |
2303 |
|
} |
2304 |
|
|
2305 |
11167 |
return skin; |
2306 |
|
} |
2307 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
2308 |
0 |
public String getSkinPreference(String prefname, XWikiContext context)... |
2309 |
|
{ |
2310 |
0 |
return getSkinPreference(prefname, "", context); |
2311 |
|
} |
2312 |
|
|
|
|
| 50% |
Uncovered Elements: 6 (12) |
Complexity: 5 |
Complexity Density: 0.83 |
|
2313 |
1063 |
public String getSkinPreference(String prefname, String defaultValue, XWikiContext context)... |
2314 |
|
{ |
2315 |
3189 |
for (Skin skin = getInternalSkinManager().getCurrentSkin(true); skin != null; skin = skin.getParent()) { |
2316 |
2126 |
if (skin instanceof WikiSkin) { |
2317 |
0 |
String value = getWikiSkinUtils().getSkinProperty(skin.getId(), prefname); |
2318 |
|
|
2319 |
|
|
2320 |
0 |
if (!StringUtils.isEmpty(value) && !NO_VALUE.equals(value)) { |
2321 |
0 |
return value; |
2322 |
|
} |
2323 |
|
} |
2324 |
|
} |
2325 |
|
|
2326 |
1062 |
return defaultValue; |
2327 |
|
} |
2328 |
|
|
2329 |
|
|
2330 |
|
@deprecated@link |
2331 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
2332 |
1115 |
@Deprecated... |
2333 |
|
public String getDefaultBaseSkin(XWikiContext context) |
2334 |
|
{ |
2335 |
1115 |
return getInternalSkinManager().getDefaultParentSkinId(); |
2336 |
|
} |
2337 |
|
|
2338 |
|
|
2339 |
|
@deprecated |
2340 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
2341 |
0 |
@Deprecated... |
2342 |
|
public String getBaseSkin(XWikiContext context) |
2343 |
|
{ |
2344 |
0 |
return getBaseSkin(context, false); |
2345 |
|
} |
2346 |
|
|
2347 |
|
|
2348 |
|
@deprecated |
2349 |
|
|
|
|
| 50% |
Uncovered Elements: 3 (6) |
Complexity: 2 |
Complexity Density: 0.33 |
|
2350 |
1113 |
@Deprecated... |
2351 |
|
public String getBaseSkin(XWikiContext context, boolean fromRenderSkin) |
2352 |
|
{ |
2353 |
1113 |
String baseskin = ""; |
2354 |
1107 |
try { |
2355 |
1110 |
return getInternalSkinManager().getCurrentParentSkinId(false); |
2356 |
|
} catch (Exception e) { |
2357 |
0 |
baseskin = getDefaultBaseSkin(context); |
2358 |
|
|
2359 |
0 |
LOGGER.debug("Exception while determining base skin", e); |
2360 |
|
} |
2361 |
|
|
2362 |
0 |
return baseskin; |
2363 |
|
} |
2364 |
|
|
2365 |
|
|
2366 |
|
@param |
2367 |
|
@param@link |
2368 |
|
@return |
2369 |
|
@since |
2370 |
|
@since |
2371 |
|
@deprecated@link@link |
2372 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
2373 |
0 |
@Deprecated... |
2374 |
|
public String getBaseSkin(String skin, XWikiContext context) |
2375 |
|
{ |
2376 |
0 |
String baseSkin = getInternalSkinManager().getParentSkin(skin); |
2377 |
|
|
2378 |
0 |
return baseSkin != null ? baseSkin : ""; |
2379 |
|
} |
2380 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
2381 |
6824 |
public String getSpaceCopyright(XWikiContext context)... |
2382 |
|
{ |
2383 |
6827 |
return getSpacePreference("webcopyright", "", context); |
2384 |
|
} |
2385 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
2386 |
44330 |
public String getXWikiPreference(String prefname, XWikiContext context)... |
2387 |
|
{ |
2388 |
44329 |
return getXWikiPreference(prefname, "", context); |
2389 |
|
} |
2390 |
|
|
2391 |
|
|
2392 |
|
|
2393 |
|
|
2394 |
|
|
2395 |
|
|
2396 |
|
@param |
2397 |
|
|
2398 |
|
@param |
2399 |
|
|
2400 |
|
@param |
2401 |
|
|
2402 |
|
|
|
|
| 87.5% |
Uncovered Elements: 1 (8) |
Complexity: 3 |
Complexity Density: 0.75 |
|
2403 |
467122 |
public String getXWikiPreference(String prefname, String fallbackParam, String defaultValue, XWikiContext context)... |
2404 |
|
{ |
2405 |
467107 |
String result = getWikiConfiguration().getProperty(prefname, String.class); |
2406 |
|
|
2407 |
467141 |
if (StringUtils.isEmpty(result)) { |
2408 |
467104 |
result = getConfiguration().getProperty(fallbackParam, defaultValue); |
2409 |
|
} |
2410 |
|
|
2411 |
467182 |
return result != null ? result : ""; |
2412 |
|
} |
2413 |
|
|
2414 |
|
|
2415 |
|
|
2416 |
|
|
2417 |
|
|
2418 |
|
|
2419 |
|
@param |
2420 |
|
|
2421 |
|
@param |
2422 |
|
@param |
2423 |
|
|
2424 |
|
@param |
2425 |
|
|
2426 |
|
@since |
2427 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
2428 |
0 |
public String getXWikiPreference(String prefname, String wiki, String fallbackParam, String defaultValue,... |
2429 |
|
XWikiContext xcontext) |
2430 |
|
{ |
2431 |
0 |
String currentWiki = xcontext.getWikiId(); |
2432 |
|
|
2433 |
0 |
try { |
2434 |
0 |
xcontext.setWikiId(wiki); |
2435 |
|
|
2436 |
0 |
return getXWikiPreference(prefname, fallbackParam, defaultValue, xcontext); |
2437 |
|
} finally { |
2438 |
0 |
xcontext.setWikiId(currentWiki); |
2439 |
|
} |
2440 |
|
} |
2441 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
2442 |
401603 |
public String getXWikiPreference(String prefname, String defaultValue, XWikiContext context)... |
2443 |
|
{ |
2444 |
401590 |
return getXWikiPreference(prefname, "", defaultValue, context); |
2445 |
|
} |
2446 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
2447 |
53345 |
public String getSpacePreference(String preference, XWikiContext context)... |
2448 |
|
{ |
2449 |
53345 |
return getSpacePreference(preference, "", context); |
2450 |
|
} |
2451 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
2452 |
66593 |
public String getSpacePreference(String preference, String defaultValue, XWikiContext context)... |
2453 |
|
{ |
2454 |
66590 |
return getSpacePreference(preference, (SpaceReference) null, defaultValue, context); |
2455 |
|
} |
2456 |
|
|
2457 |
|
|
2458 |
|
@deprecated@link |
2459 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
2460 |
0 |
@Deprecated... |
2461 |
|
public String getSpacePreference(String preference, String space, String defaultValue, XWikiContext context) |
2462 |
|
{ |
2463 |
0 |
return getSpacePreference(preference, new SpaceReference(space, context.getWikiReference()), defaultValue, |
2464 |
|
context); |
2465 |
|
} |
2466 |
|
|
2467 |
|
|
2468 |
|
|
2469 |
|
|
2470 |
|
|
2471 |
|
|
2472 |
|
@param |
2473 |
|
@param |
2474 |
|
@param@link |
2475 |
|
@return |
2476 |
|
@since |
2477 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
2478 |
10 |
public String getSpacePreference(String preferenceKey, SpaceReference spaceReference, XWikiContext context)... |
2479 |
|
{ |
2480 |
10 |
return getSpacePreference(preferenceKey, spaceReference, "", context); |
2481 |
|
} |
2482 |
|
|
2483 |
|
|
2484 |
|
|
2485 |
|
|
2486 |
|
|
2487 |
|
|
2488 |
|
@param |
2489 |
|
@param |
2490 |
|
@param |
2491 |
|
@param@link |
2492 |
|
@return |
2493 |
|
@since |
2494 |
|
|
|
|
| 93.3% |
Uncovered Elements: 2 (30) |
Complexity: 8 |
Complexity Density: 0.5 |
|
2495 |
76023 |
public String getSpacePreference(String preferenceKey, SpaceReference spaceReference, String defaultValue,... |
2496 |
|
XWikiContext context) |
2497 |
|
{ |
2498 |
76024 |
XWikiDocument currentDocument = context.getDoc(); |
2499 |
|
|
2500 |
76036 |
try { |
2501 |
76029 |
if (spaceReference != null) { |
2502 |
9436 |
context.setDoc(new XWikiDocument(new DocumentReference("WebPreferences", spaceReference))); |
2503 |
66596 |
} else if (currentDocument != null) { |
2504 |
65496 |
spaceReference = currentDocument.getDocumentReference().getLastSpaceReference(); |
2505 |
|
} |
2506 |
|
|
2507 |
76030 |
String result = getSpaceConfiguration().getProperty(preferenceKey, String.class); |
2508 |
|
|
2509 |
76030 |
if (StringUtils.isEmpty(result)) { |
2510 |
75961 |
if (spaceReference == null) { |
2511 |
1094 |
result = getXWikiPreference(preferenceKey, defaultValue, context); |
2512 |
74869 |
} else if (spaceReference.getParent() instanceof SpaceReference) { |
2513 |
9420 |
result = getSpacePreference(preferenceKey, (SpaceReference) spaceReference.getParent(), |
2514 |
|
defaultValue, context); |
2515 |
65448 |
} else if (spaceReference.getParent() instanceof WikiReference) { |
2516 |
65449 |
result = |
2517 |
|
getXWikiPreference(preferenceKey, spaceReference.getParent().getName(), defaultValue, context); |
2518 |
|
} |
2519 |
|
} |
2520 |
|
|
2521 |
76034 |
return result != null ? result : defaultValue; |
2522 |
|
} finally { |
2523 |
76033 |
context.setDoc(currentDocument); |
2524 |
|
} |
2525 |
|
} |
2526 |
|
|
|
|
| 87.5% |
Uncovered Elements: 1 (8) |
Complexity: 3 |
Complexity Density: 0.75 |
|
2527 |
7929 |
public String getUserPreference(String prefname, XWikiContext context)... |
2528 |
|
{ |
2529 |
7928 |
String result = getUserConfiguration().getProperty(prefname, String.class); |
2530 |
|
|
2531 |
7931 |
if (StringUtils.isEmpty(result)) { |
2532 |
7925 |
result = getSpacePreference(prefname, context); |
2533 |
|
} |
2534 |
|
|
2535 |
7931 |
return result != null ? result : ""; |
2536 |
|
} |
2537 |
|
|
|
|
| 29.4% |
Uncovered Elements: 12 (17) |
Complexity: 4 |
Complexity Density: 0.36 |
|
2538 |
1 |
public String getUserPreferenceFromCookie(String prefname, XWikiContext context)... |
2539 |
|
{ |
2540 |
1 |
Cookie[] cookies = context.getRequest().getCookies(); |
2541 |
1 |
if (cookies == null) { |
2542 |
0 |
return null; |
2543 |
|
} |
2544 |
1 |
for (Cookie cookie : cookies) { |
2545 |
0 |
String name = cookie.getName(); |
2546 |
0 |
if (name.equals(prefname)) { |
2547 |
0 |
String value = cookie.getValue(); |
2548 |
0 |
if (!value.trim().equals("")) { |
2549 |
0 |
return value; |
2550 |
|
} else { |
2551 |
0 |
break; |
2552 |
|
} |
2553 |
|
} |
2554 |
|
} |
2555 |
1 |
return null; |
2556 |
|
} |
2557 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
2558 |
0 |
public String getUserPreference(String prefname, boolean useCookie, XWikiContext context)... |
2559 |
|
{ |
2560 |
|
|
2561 |
0 |
if (useCookie) { |
2562 |
0 |
String result = Util.normalizeLanguage(getUserPreferenceFromCookie(prefname, context)); |
2563 |
0 |
if (result != null) { |
2564 |
0 |
return result; |
2565 |
|
} |
2566 |
|
} |
2567 |
0 |
return getUserPreference(prefname, context); |
2568 |
|
} |
2569 |
|
|
2570 |
|
|
2571 |
|
|
2572 |
|
|
2573 |
|
|
2574 |
|
|
2575 |
|
|
2576 |
|
|
2577 |
|
@return |
2578 |
|
@since |
2579 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
2580 |
11331 |
public Locale getLocalePreference(XWikiContext context)... |
2581 |
|
{ |
2582 |
11335 |
String language = getLanguagePreference(context); |
2583 |
|
|
2584 |
11333 |
return LocaleUtils.toLocale(language); |
2585 |
|
} |
2586 |
|
|
2587 |
|
|
2588 |
|
|
2589 |
|
|
2590 |
|
|
2591 |
|
|
2592 |
|
|
2593 |
|
|
2594 |
|
@return |
2595 |
|
@deprecated@link |
2596 |
|
|
|
|
| 55.8% |
Uncovered Elements: 34 (77) |
Complexity: 20 |
Complexity Density: 0.38 |
|
2597 |
157386 |
@Deprecated... |
2598 |
|
|
2599 |
|
public String getLanguagePreference(XWikiContext context) |
2600 |
|
{ |
2601 |
|
|
2602 |
|
|
2603 |
157401 |
String language = context.getLanguage(); |
2604 |
157384 |
if (language != null) { |
2605 |
144054 |
return language; |
2606 |
|
} |
2607 |
|
|
2608 |
13333 |
String defaultLanguage = getDefaultLanguage(context); |
2609 |
|
|
2610 |
|
|
2611 |
13373 |
if (!context.getWiki().isMultiLingual(context)) { |
2612 |
13368 |
language = defaultLanguage; |
2613 |
13368 |
context.setLanguage(language); |
2614 |
13364 |
return language; |
2615 |
|
} |
2616 |
|
|
2617 |
|
|
2618 |
|
|
2619 |
|
|
2620 |
|
|
2621 |
1 |
try { |
2622 |
1 |
language = Util.normalizeLanguage(context.getRequest().getParameter("language")); |
2623 |
1 |
if ((language != null) && (!language.equals(""))) { |
2624 |
0 |
if (language.equals("default")) { |
2625 |
|
|
2626 |
0 |
Cookie cookie = new Cookie("language", ""); |
2627 |
0 |
cookie.setMaxAge(0); |
2628 |
0 |
cookie.setPath("/"); |
2629 |
0 |
context.getResponse().addCookie(cookie); |
2630 |
0 |
language = defaultLanguage; |
2631 |
|
} else { |
2632 |
|
|
2633 |
0 |
Cookie cookie = new Cookie("language", language); |
2634 |
0 |
cookie.setMaxAge(60 * 60 * 24 * 365 * 10); |
2635 |
0 |
cookie.setPath("/"); |
2636 |
0 |
context.getResponse().addCookie(cookie); |
2637 |
|
} |
2638 |
0 |
context.setLanguage(language); |
2639 |
0 |
return language; |
2640 |
|
} |
2641 |
|
} catch (Exception e) { |
2642 |
|
} |
2643 |
|
|
2644 |
|
|
2645 |
|
|
2646 |
1 |
try { |
2647 |
|
|
2648 |
1 |
language = Util.normalizeLanguage(getUserPreferenceFromCookie("language", context)); |
2649 |
1 |
if ((language != null) && (!language.equals(""))) { |
2650 |
0 |
context.setLanguage(language); |
2651 |
0 |
return language; |
2652 |
|
} |
2653 |
|
} catch (Exception e) { |
2654 |
|
} |
2655 |
|
|
2656 |
|
|
2657 |
1 |
try { |
2658 |
1 |
String user = context.getUser(); |
2659 |
1 |
XWikiDocument userdoc = null; |
2660 |
1 |
userdoc = getDocument(user, context); |
2661 |
1 |
if (userdoc != null) { |
2662 |
1 |
language = Util.normalizeLanguage(userdoc.getStringValue("XWiki.XWikiUsers", "default_language")); |
2663 |
1 |
if (!language.equals("")) { |
2664 |
0 |
context.setLanguage(language); |
2665 |
0 |
return language; |
2666 |
|
} |
2667 |
|
} |
2668 |
|
} catch (XWikiException e) { |
2669 |
|
} |
2670 |
|
|
2671 |
|
|
2672 |
|
|
2673 |
1 |
if (getConfiguration().getProperty("xwiki.language.preferDefault", "0").equals("1") |
2674 |
|
|| getSpacePreference("preferDefaultLanguage", "0", context).equals("1")) { |
2675 |
0 |
language = defaultLanguage; |
2676 |
0 |
context.setLanguage(language); |
2677 |
0 |
return language; |
2678 |
|
} |
2679 |
|
|
2680 |
|
|
2681 |
1 |
if (context.getRequest() != null) { |
2682 |
1 |
String acceptHeader = context.getRequest().getHeader("Accept-Language"); |
2683 |
|
|
2684 |
1 |
if ((acceptHeader != null) && (!acceptHeader.equals(""))) { |
2685 |
1 |
List<String> acceptedLanguages = getAcceptedLanguages(context.getRequest()); |
2686 |
|
|
2687 |
1 |
if (getConfiguration().getProperty("xwiki.language.forceSupported", "0").equals("1")) { |
2688 |
0 |
List<String> available = Arrays.asList(getXWikiPreference("languages", context).split("[, |]")); |
2689 |
|
|
2690 |
0 |
acceptedLanguages.retainAll(available); |
2691 |
|
} |
2692 |
1 |
if (acceptedLanguages.size() > 0) { |
2693 |
|
|
2694 |
1 |
context.setLanguage(acceptedLanguages.get(0)); |
2695 |
1 |
return acceptedLanguages.get(0); |
2696 |
|
} |
2697 |
|
|
2698 |
|
|
2699 |
|
} |
2700 |
|
} |
2701 |
|
|
2702 |
|
|
2703 |
0 |
context.setLanguage(defaultLanguage); |
2704 |
0 |
return defaultLanguage; |
2705 |
|
} |
2706 |
|
|
2707 |
|
|
2708 |
|
|
2709 |
|
|
2710 |
|
|
2711 |
|
|
2712 |
|
@param |
2713 |
|
@return |
2714 |
|
|
2715 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
2716 |
1 |
private List<String> getAcceptedLanguages(XWikiRequest request)... |
2717 |
|
{ |
2718 |
1 |
List<String> result = new ArrayList<String>(); |
2719 |
1 |
Enumeration<Locale> e = request.getLocales(); |
2720 |
5 |
while (e.hasMoreElements()) { |
2721 |
4 |
String language = e.nextElement().getLanguage().toLowerCase(); |
2722 |
|
|
2723 |
4 |
if (StringUtils.isAlpha(language)) { |
2724 |
2 |
result.add(language); |
2725 |
|
} |
2726 |
|
} |
2727 |
1 |
return result; |
2728 |
|
} |
2729 |
|
|
2730 |
|
|
2731 |
|
@deprecated@link |
2732 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
2733 |
13338 |
@Deprecated... |
2734 |
|
public String getDefaultLanguage(XWikiContext xcontext) |
2735 |
|
{ |
2736 |
13327 |
return getDefaultLocale(xcontext).toString(); |
2737 |
|
} |
2738 |
|
|
2739 |
|
|
2740 |
|
|
2741 |
|
|
2742 |
|
@param |
2743 |
|
@return |
2744 |
|
@since |
2745 |
|
|
|
|
| 54.5% |
Uncovered Elements: 5 (11) |
Complexity: 3 |
Complexity Density: 0.33 |
|
2746 |
17558 |
public Locale getDefaultLocale(XWikiContext xcontext)... |
2747 |
|
{ |
2748 |
|
|
2749 |
17570 |
String defaultLanguage = xcontext.getWiki().getXWikiPreference("default_language", "", xcontext); |
2750 |
|
|
2751 |
17641 |
Locale defaultLocale; |
2752 |
|
|
2753 |
17624 |
if (StringUtils.isBlank(defaultLanguage)) { |
2754 |
17619 |
defaultLocale = Locale.ENGLISH; |
2755 |
|
} else { |
2756 |
0 |
try { |
2757 |
0 |
defaultLocale = LocaleUtils.toLocale(Util.normalizeLanguage(defaultLanguage)); |
2758 |
|
} catch (Exception e) { |
2759 |
0 |
LOGGER.warn("Invalid locale [{}] set as default locale in the preferences", defaultLanguage); |
2760 |
0 |
defaultLocale = Locale.ENGLISH; |
2761 |
|
} |
2762 |
|
} |
2763 |
|
|
2764 |
17629 |
return defaultLocale; |
2765 |
|
} |
2766 |
|
|
2767 |
|
|
2768 |
|
|
2769 |
|
|
2770 |
|
@param |
2771 |
|
@return |
2772 |
|
@since |
2773 |
|
|
|
|
| 53.3% |
Uncovered Elements: 7 (15) |
Complexity: 4 |
Complexity Density: 0.36 |
|
2774 |
4158 |
public List<Locale> getAvailableLocales(XWikiContext xcontext)... |
2775 |
|
{ |
2776 |
4158 |
String[] languages = StringUtils.split(xcontext.getWiki().getXWikiPreference("languages", xcontext), ", |"); |
2777 |
|
|
2778 |
4158 |
List<Locale> locales = new ArrayList<Locale>(languages.length); |
2779 |
|
|
2780 |
4158 |
for (String language : languages) { |
2781 |
0 |
if (StringUtils.isNotBlank(language)) { |
2782 |
0 |
try { |
2783 |
0 |
locales.add(LocaleUtils.toLocale(language)); |
2784 |
|
} catch (Exception e) { |
2785 |
0 |
LOGGER.warn("Invalid locale [{}] listed as available in the preferences", language); |
2786 |
|
} |
2787 |
|
} |
2788 |
|
} |
2789 |
|
|
2790 |
|
|
2791 |
4158 |
Locale defaultocale = getDefaultLocale(xcontext); |
2792 |
4158 |
if (!locales.contains(defaultocale)) { |
2793 |
4158 |
locales.add(defaultocale); |
2794 |
|
} |
2795 |
|
|
2796 |
4158 |
return locales; |
2797 |
|
} |
2798 |
|
|
2799 |
|
|
2800 |
|
@since |
2801 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
2802 |
0 |
public Locale getDocLocalePreferenceNew(XWikiContext context)... |
2803 |
|
{ |
2804 |
0 |
String language = getDocLanguagePreferenceNew(context); |
2805 |
|
|
2806 |
0 |
return LocaleUtils.toLocale(language); |
2807 |
|
} |
2808 |
|
|
2809 |
|
|
2810 |
|
@deprecated@link |
2811 |
|
|
|
|
| 0% |
Uncovered Elements: 72 (72) |
Complexity: 19 |
Complexity Density: 0.4 |
|
2812 |
0 |
@Deprecated... |
2813 |
|
|
2814 |
|
public String getDocLanguagePreferenceNew(XWikiContext context) |
2815 |
|
{ |
2816 |
|
|
2817 |
0 |
String contextLanguage = context.getLanguage(); |
2818 |
|
|
2819 |
0 |
if (contextLanguage != null && contextLanguage != "") { |
2820 |
0 |
return contextLanguage; |
2821 |
|
} |
2822 |
|
|
2823 |
0 |
String language = "", requestLanguage = "", userPreferenceLanguage = "", navigatorLanguage = "", |
2824 |
|
cookieLanguage = ""; |
2825 |
0 |
boolean setCookie = false; |
2826 |
|
|
2827 |
0 |
if (!context.getWiki().isMultiLingual(context)) { |
2828 |
0 |
language = context.getWiki().getXWikiPreference("default_language", "", context); |
2829 |
0 |
context.setLanguage(language); |
2830 |
0 |
return language; |
2831 |
|
} |
2832 |
|
|
2833 |
|
|
2834 |
0 |
try { |
2835 |
0 |
requestLanguage = Util.normalizeLanguage(context.getRequest().getParameter("language")); |
2836 |
|
} catch (Exception ex) { |
2837 |
|
} |
2838 |
|
|
2839 |
|
|
2840 |
0 |
try { |
2841 |
0 |
String user = context.getUser(); |
2842 |
0 |
XWikiDocument userdoc = getDocument(user, context); |
2843 |
0 |
if (userdoc != null) { |
2844 |
0 |
userPreferenceLanguage = userdoc.getStringValue("XWiki.XWikiUsers", "default_language"); |
2845 |
|
} |
2846 |
|
} catch (XWikiException e) { |
2847 |
|
} |
2848 |
|
|
2849 |
|
|
2850 |
0 |
if (context.getRequest() != null) { |
2851 |
0 |
String accept = context.getRequest().getHeader("Accept-Language"); |
2852 |
0 |
if ((accept != null) && (!accept.equals(""))) { |
2853 |
0 |
String[] alist = StringUtils.split(accept, ",;-"); |
2854 |
0 |
if ((alist != null) && !(alist.length == 0)) { |
2855 |
0 |
context.setLanguage(alist[0]); |
2856 |
0 |
navigatorLanguage = alist[0]; |
2857 |
|
} |
2858 |
|
} |
2859 |
|
} |
2860 |
|
|
2861 |
|
|
2862 |
0 |
try { |
2863 |
0 |
cookieLanguage = Util.normalizeLanguage(getUserPreferenceFromCookie("language", context)); |
2864 |
|
} catch (Exception e) { |
2865 |
|
} |
2866 |
|
|
2867 |
|
|
2868 |
|
|
2869 |
0 |
if (StringUtils.isNotEmpty(requestLanguage)) { |
2870 |
0 |
if (requestLanguage.equals("default")) { |
2871 |
0 |
setCookie = true; |
2872 |
|
} else { |
2873 |
0 |
language = requestLanguage; |
2874 |
0 |
context.setLanguage(language); |
2875 |
0 |
Cookie cookie = new Cookie("language", language); |
2876 |
0 |
cookie.setMaxAge(60 * 60 * 24 * 365 * 10); |
2877 |
0 |
cookie.setPath("/"); |
2878 |
0 |
context.getResponse().addCookie(cookie); |
2879 |
0 |
return language; |
2880 |
|
} |
2881 |
|
} |
2882 |
|
|
2883 |
0 |
if (StringUtils.isNotEmpty(cookieLanguage)) { |
2884 |
0 |
language = cookieLanguage; |
2885 |
|
} |
2886 |
|
|
2887 |
0 |
else if (StringUtils.isNotEmpty(userPreferenceLanguage)) { |
2888 |
0 |
language = userPreferenceLanguage; |
2889 |
|
} |
2890 |
|
|
2891 |
0 |
else if (StringUtils.isNotEmpty(navigatorLanguage)) { |
2892 |
0 |
language = navigatorLanguage; |
2893 |
|
} |
2894 |
0 |
context.setLanguage(language); |
2895 |
0 |
if (setCookie) { |
2896 |
0 |
Cookie cookie = new Cookie("language", language); |
2897 |
0 |
cookie.setMaxAge(60 * 60 * 24 * 365 * 10); |
2898 |
0 |
cookie.setPath("/"); |
2899 |
0 |
context.getResponse().addCookie(cookie); |
2900 |
|
} |
2901 |
0 |
return language; |
2902 |
|
} |
2903 |
|
|
2904 |
|
|
2905 |
|
@since |
2906 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
2907 |
0 |
public Locale getInterfaceLocalePreference(XWikiContext context)... |
2908 |
|
{ |
2909 |
0 |
String language = getInterfaceLanguagePreference(context); |
2910 |
|
|
2911 |
0 |
return LocaleUtils.toLocale(language); |
2912 |
|
} |
2913 |
|
|
2914 |
|
|
2915 |
|
@deprecated@link |
2916 |
|
|
|
|
| 0% |
Uncovered Elements: 73 (73) |
Complexity: 20 |
Complexity Density: 0.41 |
|
2917 |
0 |
@Deprecated... |
2918 |
|
|
2919 |
|
public String getInterfaceLanguagePreference(XWikiContext context) |
2920 |
|
{ |
2921 |
0 |
String language = "", requestLanguage = "", userPreferenceLanguage = "", navigatorLanguage = "", |
2922 |
|
cookieLanguage = "", contextLanguage = ""; |
2923 |
0 |
boolean setCookie = false; |
2924 |
|
|
2925 |
0 |
if (!context.getWiki().isMultiLingual(context)) { |
2926 |
0 |
language = Util.normalizeLanguage(context.getWiki().getXWikiPreference("default_language", "", context)); |
2927 |
0 |
context.setInterfaceLanguage(language); |
2928 |
0 |
return language; |
2929 |
|
} |
2930 |
|
|
2931 |
|
|
2932 |
0 |
try { |
2933 |
0 |
requestLanguage = Util.normalizeLanguage(context.getRequest().getParameter("interfacelanguage")); |
2934 |
|
} catch (Exception ex) { |
2935 |
|
} |
2936 |
|
|
2937 |
|
|
2938 |
0 |
contextLanguage = context.getInterfaceLanguage(); |
2939 |
|
|
2940 |
|
|
2941 |
0 |
try { |
2942 |
0 |
String user = context.getUser(); |
2943 |
0 |
XWikiDocument userdoc = null; |
2944 |
0 |
userdoc = getDocument(user, context); |
2945 |
0 |
if (userdoc != null) { |
2946 |
0 |
userPreferenceLanguage = userdoc.getStringValue("XWiki.XWikiUsers", "default_interface_language"); |
2947 |
|
} |
2948 |
|
} catch (XWikiException e) { |
2949 |
|
} |
2950 |
|
|
2951 |
|
|
2952 |
0 |
if (context.getRequest() != null) { |
2953 |
0 |
String accept = context.getRequest().getHeader("Accept-Language"); |
2954 |
0 |
if ((accept != null) && (!accept.equals(""))) { |
2955 |
0 |
String[] alist = StringUtils.split(accept, ",;-"); |
2956 |
0 |
if ((alist != null) && !(alist.length == 0)) { |
2957 |
0 |
context.setLanguage(alist[0]); |
2958 |
0 |
navigatorLanguage = alist[0]; |
2959 |
|
} |
2960 |
|
} |
2961 |
|
} |
2962 |
|
|
2963 |
|
|
2964 |
0 |
try { |
2965 |
0 |
cookieLanguage = Util.normalizeLanguage(getUserPreferenceFromCookie("interfacelanguage", context)); |
2966 |
|
} catch (Exception e) { |
2967 |
|
} |
2968 |
|
|
2969 |
|
|
2970 |
|
|
2971 |
0 |
if ((requestLanguage != null) && (!requestLanguage.equals(""))) { |
2972 |
0 |
if (requestLanguage.equals("default")) { |
2973 |
0 |
setCookie = true; |
2974 |
|
} else { |
2975 |
0 |
language = requestLanguage; |
2976 |
0 |
context.setLanguage(language); |
2977 |
0 |
Cookie cookie = new Cookie("interfacelanguage", language); |
2978 |
0 |
cookie.setMaxAge(60 * 60 * 24 * 365 * 10); |
2979 |
0 |
cookie.setPath("/"); |
2980 |
0 |
context.getResponse().addCookie(cookie); |
2981 |
0 |
return language; |
2982 |
|
} |
2983 |
|
} |
2984 |
|
|
2985 |
0 |
if (contextLanguage != null && contextLanguage != "") { |
2986 |
0 |
language = contextLanguage; |
2987 |
|
} |
2988 |
|
|
2989 |
0 |
else if (StringUtils.isNotEmpty(cookieLanguage)) { |
2990 |
0 |
language = cookieLanguage; |
2991 |
|
} |
2992 |
|
|
2993 |
0 |
else if (StringUtils.isNotEmpty(userPreferenceLanguage)) { |
2994 |
0 |
language = userPreferenceLanguage; |
2995 |
|
} |
2996 |
|
|
2997 |
0 |
else if (StringUtils.isNotEmpty(navigatorLanguage)) { |
2998 |
0 |
language = navigatorLanguage; |
2999 |
|
} |
3000 |
0 |
context.setLanguage(language); |
3001 |
0 |
if (setCookie) { |
3002 |
0 |
Cookie cookie = new Cookie("interfacelanguage", language); |
3003 |
0 |
cookie.setMaxAge(60 * 60 * 24 * 365 * 10); |
3004 |
0 |
cookie.setPath("/"); |
3005 |
0 |
context.getResponse().addCookie(cookie); |
3006 |
|
} |
3007 |
0 |
return language; |
3008 |
|
} |
3009 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3010 |
0 |
public long getXWikiPreferenceAsLong(String preference, XWikiContext context)... |
3011 |
|
{ |
3012 |
0 |
return Long.parseLong(getXWikiPreference(preference, context)); |
3013 |
|
} |
3014 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3015 |
0 |
public long getSpacePreferenceAsLong(String preference, XWikiContext context)... |
3016 |
|
{ |
3017 |
0 |
return Long.parseLong(getSpacePreference(preference, context)); |
3018 |
|
} |
3019 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3020 |
20677 |
public long getXWikiPreferenceAsLong(String preference, long defaultValue, XWikiContext context)... |
3021 |
|
{ |
3022 |
20677 |
return NumberUtils.toLong((getXWikiPreference(preference, context)), defaultValue); |
3023 |
|
} |
3024 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3025 |
0 |
public long getXWikiPreferenceAsLong(String preference, String fallbackParameter, long defaultValue,... |
3026 |
|
XWikiContext context) |
3027 |
|
{ |
3028 |
0 |
return NumberUtils.toLong(getXWikiPreference(preference, fallbackParameter, "", context), defaultValue); |
3029 |
|
} |
3030 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3031 |
20 |
public long getSpacePreferenceAsLong(String preference, long defaultValue, XWikiContext context)... |
3032 |
|
{ |
3033 |
20 |
return NumberUtils.toLong(getSpacePreference(preference, context), defaultValue); |
3034 |
|
} |
3035 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3036 |
0 |
public long getUserPreferenceAsLong(String preference, XWikiContext context)... |
3037 |
|
{ |
3038 |
0 |
return Long.parseLong(getUserPreference(preference, context)); |
3039 |
|
} |
3040 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3041 |
0 |
public int getXWikiPreferenceAsInt(String preference, XWikiContext context)... |
3042 |
|
{ |
3043 |
0 |
return Integer.parseInt(getXWikiPreference(preference, context)); |
3044 |
|
} |
3045 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3046 |
0 |
public int getSpacePreferenceAsInt(String preference, XWikiContext context)... |
3047 |
|
{ |
3048 |
0 |
return Integer.parseInt(getSpacePreference(preference, context)); |
3049 |
|
} |
3050 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3051 |
1119 |
public int getXWikiPreferenceAsInt(String preference, int defaultValue, XWikiContext context)... |
3052 |
|
{ |
3053 |
1119 |
return NumberUtils.toInt(getXWikiPreference(preference, context), defaultValue); |
3054 |
|
} |
3055 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3056 |
0 |
public int getXWikiPreferenceAsInt(String preference, String fallbackParameter, int defaultValue,... |
3057 |
|
XWikiContext context) |
3058 |
|
{ |
3059 |
0 |
return NumberUtils.toInt(getXWikiPreference(preference, fallbackParameter, "", context), defaultValue); |
3060 |
|
} |
3061 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3062 |
572 |
public int getSpacePreferenceAsInt(String preference, int defaultValue, XWikiContext context)... |
3063 |
|
{ |
3064 |
572 |
return NumberUtils.toInt(getSpacePreference(preference, context), defaultValue); |
3065 |
|
} |
3066 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3067 |
0 |
public int getUserPreferenceAsInt(String prefname, XWikiContext context)... |
3068 |
|
{ |
3069 |
0 |
return Integer.parseInt(getUserPreference(prefname, context)); |
3070 |
|
} |
3071 |
|
|
|
|
| 0% |
Uncovered Elements: 25 (25) |
Complexity: 8 |
Complexity Density: 0.47 |
|
3072 |
0 |
public void flushCache(XWikiContext context)... |
3073 |
|
{ |
3074 |
|
|
3075 |
0 |
this.initializedWikis = new ConcurrentHashMap<>(); |
3076 |
|
|
3077 |
|
|
3078 |
0 |
if (this.groupService != null) { |
3079 |
0 |
this.groupService.flushCache(); |
3080 |
|
} |
3081 |
|
|
3082 |
|
|
3083 |
0 |
XWikiStoreInterface store = getStore(); |
3084 |
0 |
if ((store != null) && (store instanceof XWikiCacheStoreInterface)) { |
3085 |
0 |
((XWikiCacheStoreInterface) getStore()).flushCache(); |
3086 |
|
} |
3087 |
|
|
3088 |
0 |
getOldRendering().flushCache(); |
3089 |
0 |
getParseGroovyFromString().flushCache(); |
3090 |
|
|
3091 |
0 |
XWikiPluginManager pmanager = getPluginManager(); |
3092 |
0 |
if (pmanager != null) { |
3093 |
0 |
pmanager.flushCache(context); |
3094 |
|
} |
3095 |
|
|
3096 |
|
|
3097 |
0 |
try { |
3098 |
0 |
List<String> classes = getClassList(context); |
3099 |
0 |
for (int i = 0; i < classes.size(); i++) { |
3100 |
0 |
String className = classes.get(i); |
3101 |
0 |
try { |
3102 |
0 |
getClass(className, context).flushCache(); |
3103 |
|
} catch (Exception e) { |
3104 |
|
} |
3105 |
|
} |
3106 |
|
} catch (Exception e) { |
3107 |
|
} |
3108 |
|
|
3109 |
|
} |
3110 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3111 |
99443 |
public XWikiPluginManager getPluginManager()... |
3112 |
|
{ |
3113 |
99432 |
return this.pluginManager; |
3114 |
|
} |
3115 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3116 |
87 |
public void setPluginManager(XWikiPluginManager pluginManager)... |
3117 |
|
{ |
3118 |
87 |
this.pluginManager = pluginManager; |
3119 |
|
} |
3120 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3121 |
138 |
public void setStore(XWikiStoreInterface store)... |
3122 |
|
{ |
3123 |
138 |
this.store = store; |
3124 |
|
} |
3125 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3126 |
87 |
public void setAttachmentStore(XWikiAttachmentStoreInterface attachmentStore)... |
3127 |
|
{ |
3128 |
87 |
this.attachmentStore = attachmentStore; |
3129 |
|
} |
3130 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3131 |
89 |
public void setAttachmentVersioningStore(AttachmentVersioningStore avStore)... |
3132 |
|
{ |
3133 |
89 |
this.attachmentVersioningStore = avStore; |
3134 |
|
} |
3135 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3136 |
135 |
public void setVersioningStore(XWikiVersioningStoreInterface versioningStore)... |
3137 |
|
{ |
3138 |
135 |
this.versioningStore = versioningStore; |
3139 |
|
} |
3140 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3141 |
95 |
public void setRecycleBinStore(XWikiRecycleBinStoreInterface recycleBinStore)... |
3142 |
|
{ |
3143 |
95 |
this.recycleBinStore = recycleBinStore; |
3144 |
|
} |
3145 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3146 |
88 |
public void setAttachmentRecycleBinStore(AttachmentRecycleBinStore attachmentRecycleBinStore)... |
3147 |
|
{ |
3148 |
88 |
this.attachmentRecycleBinStore = attachmentRecycleBinStore; |
3149 |
|
} |
3150 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3151 |
87 |
public void setCriteriaService(XWikiCriteriaService criteriaService)... |
3152 |
|
{ |
3153 |
87 |
this.criteriaService = criteriaService; |
3154 |
|
} |
3155 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3156 |
0 |
public void setVersion(String version)... |
3157 |
|
{ |
3158 |
0 |
this.version = version; |
3159 |
|
} |
3160 |
|
|
3161 |
|
|
3162 |
|
|
3163 |
|
|
3164 |
|
|
3165 |
|
@param@link |
3166 |
|
@param |
3167 |
|
@return |
3168 |
|
@throws |
3169 |
|
|
|
|
| 90% |
Uncovered Elements: 1 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
3170 |
102 |
private BaseClass getMandatoryClass(XWikiContext context, DocumentReference classReference) throws XWikiException... |
3171 |
|
{ |
3172 |
102 |
XWikiDocument document = getDocument(classReference, context); |
3173 |
|
|
3174 |
102 |
if (context.get("initdone") == null) { |
3175 |
102 |
@SuppressWarnings("deprecation") |
3176 |
|
MandatoryDocumentInitializer initializer = |
3177 |
|
Utils.getComponent(MandatoryDocumentInitializer.class, document.getFullName()); |
3178 |
|
|
3179 |
102 |
if (initializer.updateDocument(document)) { |
3180 |
4 |
saveDocument(document, localizePlainOrKey("core.model.xclass.mandatoryUpdateProperty.versionSummary"), |
3181 |
|
context); |
3182 |
|
} |
3183 |
|
} |
3184 |
|
|
3185 |
102 |
return document.getXClass(); |
3186 |
|
} |
3187 |
|
|
3188 |
|
|
3189 |
|
|
3190 |
|
|
3191 |
|
|
3192 |
|
|
3193 |
|
@param@link |
3194 |
|
@return |
3195 |
|
@throws |
3196 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3197 |
0 |
public BaseClass getTagClass(XWikiContext context) throws XWikiException... |
3198 |
|
{ |
3199 |
0 |
return getMandatoryClass(context, new DocumentReference(context.getWikiId(), SYSTEM_SPACE, "TagClass")); |
3200 |
|
} |
3201 |
|
|
3202 |
|
|
3203 |
|
|
3204 |
|
|
3205 |
|
|
3206 |
|
|
3207 |
|
|
3208 |
|
|
3209 |
|
@param@link |
3210 |
|
@return |
3211 |
|
@throws |
3212 |
|
@deprecated |
3213 |
|
@see |
3214 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3215 |
0 |
@Deprecated... |
3216 |
|
public BaseClass getSheetClass(XWikiContext context) throws XWikiException |
3217 |
|
{ |
3218 |
0 |
return getMandatoryClass(context, new DocumentReference(context.getWikiId(), SYSTEM_SPACE, "SheetClass")); |
3219 |
|
} |
3220 |
|
|
3221 |
|
|
3222 |
|
|
3223 |
|
|
3224 |
|
|
3225 |
|
|
3226 |
|
|
3227 |
|
|
3228 |
|
@link |
3229 |
|
|
3230 |
|
@param@link |
3231 |
|
@return |
3232 |
|
@throws |
3233 |
|
@since |
3234 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3235 |
0 |
public BaseClass getEditModeClass(XWikiContext context) throws XWikiException... |
3236 |
|
{ |
3237 |
0 |
return getMandatoryClass(context, new DocumentReference( |
3238 |
|
new LocalDocumentReference(XWikiConstant.EDIT_MODE_CLASS), new WikiReference(context.getWikiId()))); |
3239 |
|
} |
3240 |
|
|
3241 |
|
|
3242 |
|
|
3243 |
|
|
3244 |
|
|
3245 |
|
|
3246 |
|
@param@link |
3247 |
|
@return |
3248 |
|
@throws |
3249 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3250 |
33 |
public BaseClass getUserClass(XWikiContext context) throws XWikiException... |
3251 |
|
{ |
3252 |
33 |
return getMandatoryClass(context, new DocumentReference(context.getWikiId(), SYSTEM_SPACE, "XWikiUsers")); |
3253 |
|
} |
3254 |
|
|
3255 |
|
|
3256 |
|
|
3257 |
|
|
3258 |
|
|
3259 |
|
|
3260 |
|
@param@link |
3261 |
|
@return |
3262 |
|
@throws |
3263 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3264 |
0 |
public BaseClass getRedirectClass(XWikiContext context) throws XWikiException... |
3265 |
|
{ |
3266 |
0 |
return getMandatoryClass(context, new DocumentReference(context.getWikiId(), SYSTEM_SPACE, "GlobalRedirect")); |
3267 |
|
} |
3268 |
|
|
3269 |
|
|
3270 |
|
|
3271 |
|
|
3272 |
|
|
3273 |
|
|
3274 |
|
@param@link |
3275 |
|
@return |
3276 |
|
@throws |
3277 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3278 |
2 |
public BaseClass getPrefsClass(XWikiContext context) throws XWikiException... |
3279 |
|
{ |
3280 |
2 |
return getMandatoryClass(context, getPreferencesDocumentReference(context)); |
3281 |
|
} |
3282 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3283 |
26 |
public BaseClass getGroupClass(XWikiContext context) throws XWikiException... |
3284 |
|
{ |
3285 |
26 |
return getMandatoryClass(context, new DocumentReference(context.getWikiId(), SYSTEM_SPACE, "XWikiGroups")); |
3286 |
|
} |
3287 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3288 |
32 |
public BaseClass getRightsClass(String pagename, XWikiContext context) throws XWikiException... |
3289 |
|
{ |
3290 |
32 |
return getMandatoryClass(context, new DocumentReference(context.getWikiId(), SYSTEM_SPACE, pagename)); |
3291 |
|
} |
3292 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3293 |
32 |
public BaseClass getRightsClass(XWikiContext context) throws XWikiException... |
3294 |
|
{ |
3295 |
32 |
return getRightsClass("XWikiRights", context); |
3296 |
|
} |
3297 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3298 |
0 |
public BaseClass getGlobalRightsClass(XWikiContext context) throws XWikiException... |
3299 |
|
{ |
3300 |
0 |
return getRightsClass("XWikiGlobalRights", context); |
3301 |
|
} |
3302 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3303 |
9 |
public BaseClass getCommentsClass(XWikiContext context) throws XWikiException... |
3304 |
|
{ |
3305 |
9 |
return getMandatoryClass(context, new DocumentReference(context.getWikiId(), SYSTEM_SPACE, "XWikiComments")); |
3306 |
|
} |
3307 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3308 |
0 |
public BaseClass getSkinClass(XWikiContext context) throws XWikiException... |
3309 |
|
{ |
3310 |
0 |
return getMandatoryClass(context, new DocumentReference(context.getWikiId(), SYSTEM_SPACE, "XWikiSkins")); |
3311 |
|
} |
3312 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3313 |
29 |
public int createUser(XWikiContext context) throws XWikiException... |
3314 |
|
{ |
3315 |
29 |
return createUser(false, "edit", context); |
3316 |
|
} |
3317 |
|
|
|
|
| 74.2% |
Uncovered Elements: 8 (31) |
Complexity: 7 |
Complexity Density: 0.3 |
|
3318 |
4 |
public int validateUser(boolean withConfirmEmail, XWikiContext context) throws XWikiException... |
3319 |
|
{ |
3320 |
4 |
try { |
3321 |
4 |
XWikiRequest request = context.getRequest(); |
3322 |
|
|
3323 |
4 |
String username = convertUsername(request.getParameter("xwikiname"), context); |
3324 |
4 |
if (username.indexOf('.') == -1) { |
3325 |
4 |
username = "XWiki." + username; |
3326 |
|
} |
3327 |
4 |
XWikiDocument userDocument = getDocument(username, context); |
3328 |
|
|
3329 |
|
|
3330 |
4 |
BaseObject userObject = userDocument.getObject("XWiki.XWikiUsers", 0); |
3331 |
4 |
String storedKey = userObject.getStringValue("validkey"); |
3332 |
|
|
3333 |
|
|
3334 |
4 |
String validationKey = request.getParameter("validkey"); |
3335 |
4 |
PropertyInterface validationKeyClass = getClass("XWiki.XWikiUsers", context).get("validkey"); |
3336 |
4 |
if (validationKeyClass instanceof PasswordClass) { |
3337 |
4 |
validationKey = ((PasswordClass) validationKeyClass).getEquivalentPassword(storedKey, validationKey); |
3338 |
|
} |
3339 |
|
|
3340 |
|
|
3341 |
4 |
if ((!storedKey.equals("") && (storedKey.equals(validationKey)))) { |
3342 |
2 |
userObject.setIntValue("active", 1); |
3343 |
2 |
saveDocument(userDocument, context); |
3344 |
|
|
3345 |
2 |
if (withConfirmEmail) { |
3346 |
0 |
String email = userObject.getStringValue("email"); |
3347 |
0 |
String password = userObject.getStringValue("password"); |
3348 |
0 |
sendValidationEmail(username, password, email, request.getParameter("validkey"), |
3349 |
|
"confirmation_email_content", context); |
3350 |
|
} |
3351 |
|
|
3352 |
2 |
return 0; |
3353 |
|
} else { |
3354 |
2 |
return -1; |
3355 |
|
} |
3356 |
|
} catch (Exception e) { |
3357 |
0 |
LOGGER.error(e.getMessage(), e); |
3358 |
|
|
3359 |
0 |
throw new XWikiException(XWikiException.MODULE_XWIKI_APP, XWikiException.ERROR_XWIKI_APP_VALIDATE_USER, |
3360 |
|
"Exception while validating user", e, null); |
3361 |
|
} |
3362 |
|
} |
3363 |
|
|
|
|
| 51.7% |
Uncovered Elements: 29 (60) |
Complexity: 17 |
Complexity Density: 0.4 |
|
3364 |
29 |
public int createUser(boolean withValidation, String userRights, XWikiContext context) throws XWikiException... |
3365 |
|
{ |
3366 |
29 |
try { |
3367 |
29 |
XWikiRequest request = context.getRequest(); |
3368 |
29 |
Map<String, String[]> map = Util.getObject(request, "register"); |
3369 |
|
|
3370 |
29 |
String content = ""; |
3371 |
29 |
Syntax syntax = getDefaultDocumentSyntaxInternal(); |
3372 |
|
|
3373 |
|
|
3374 |
29 |
String xwikiname = request.getParameter("xwikiname"); |
3375 |
29 |
String password2 = request.getParameter("register2_password"); |
3376 |
29 |
String password = (map.get("password"))[0]; |
3377 |
29 |
String email = (map.get("email"))[0]; |
3378 |
29 |
String template = request.getParameter("template"); |
3379 |
29 |
String parent = request.getParameter("parent"); |
3380 |
29 |
String validkey = null; |
3381 |
|
|
3382 |
|
|
3383 |
29 |
if (XWikiRightService.SUPERADMIN_USER.equalsIgnoreCase(xwikiname)) { |
3384 |
0 |
return -8; |
3385 |
|
} |
3386 |
29 |
try { |
3387 |
29 |
if (!context.getUtil().match(getConfiguration().getProperty("xwiki.validusername", "/^[a-zA-Z0-9_]+$/"), |
3388 |
|
xwikiname)) { |
3389 |
0 |
return -4; |
3390 |
|
} |
3391 |
|
} catch (RuntimeException ex) { |
3392 |
0 |
LOGGER.warn("Invalid regular expression for xwiki.validusername", ex); |
3393 |
0 |
if (!context.getUtil().match("/^[a-zA-Z0-9_]+$/", xwikiname)) { |
3394 |
0 |
return -4; |
3395 |
|
} |
3396 |
|
} |
3397 |
|
|
3398 |
29 |
if ((!password.equals(password2)) || (password.trim().equals(""))) { |
3399 |
|
|
3400 |
0 |
return -2; |
3401 |
|
} |
3402 |
|
|
3403 |
29 |
if ((template != null) && (!template.equals(""))) { |
3404 |
0 |
XWikiDocument tdoc = getDocument(template, context); |
3405 |
0 |
if ((!tdoc.isNew())) { |
3406 |
|
|
3407 |
0 |
content = tdoc.getContent(); |
3408 |
0 |
syntax = tdoc.getSyntax(); |
3409 |
|
} |
3410 |
|
} |
3411 |
|
|
3412 |
29 |
if ((parent == null) || (parent.equals(""))) { |
3413 |
29 |
parent = "XWiki.XWikiUsers"; |
3414 |
|
} |
3415 |
|
|
3416 |
|
|
3417 |
29 |
if (withValidation) { |
3418 |
0 |
map.put("active", new String[] { "0" }); |
3419 |
0 |
validkey = generateValidationKey(16); |
3420 |
0 |
map.put("validkey", new String[] { validkey }); |
3421 |
|
|
3422 |
|
} else { |
3423 |
|
|
3424 |
29 |
map.put("active", new String[] { "1" }); |
3425 |
|
} |
3426 |
|
|
3427 |
|
|
3428 |
29 |
int result = |
3429 |
|
createUser(xwikiname, map, getRelativeEntityReferenceResolver().resolve(parent, EntityType.DOCUMENT), |
3430 |
|
content, syntax, userRights, context); |
3431 |
|
|
3432 |
|
|
3433 |
29 |
if ((result > 0) && (withValidation)) { |
3434 |
|
|
3435 |
0 |
sendValidationEmail(xwikiname, password, email, validkey, "validation_email_content", context); |
3436 |
|
} |
3437 |
|
|
3438 |
29 |
return result; |
3439 |
|
} catch (XWikiException e) { |
3440 |
0 |
LOGGER.error(e.getMessage(), e); |
3441 |
|
|
3442 |
0 |
throw e; |
3443 |
|
} catch (Exception e) { |
3444 |
0 |
LOGGER.error(e.getMessage(), e); |
3445 |
|
|
3446 |
0 |
throw new XWikiException(XWikiException.MODULE_XWIKI_APP, XWikiException.ERROR_XWIKI_APP_CREATE_USER, |
3447 |
|
"Exception while creating user", e, null); |
3448 |
|
} |
3449 |
|
} |
3450 |
|
|
3451 |
|
|
3452 |
|
|
3453 |
|
|
3454 |
|
|
3455 |
|
@param |
3456 |
|
@param |
3457 |
|
@param@link |
3458 |
|
@return |
3459 |
|
@throws |
3460 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
3461 |
0 |
public boolean createEmptyUser(String xwikiname, String userRights, XWikiContext context) throws XWikiException... |
3462 |
|
{ |
3463 |
0 |
Map<String, String> map = new HashMap<String, String>(); |
3464 |
0 |
map.put("active", "1"); |
3465 |
0 |
map.put("first_name", xwikiname); |
3466 |
|
|
3467 |
0 |
if (createUser(xwikiname, map, userRights, context) == 1) { |
3468 |
0 |
return true; |
3469 |
|
} else { |
3470 |
0 |
return false; |
3471 |
|
} |
3472 |
|
} |
3473 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3474 |
0 |
public void sendConfirmationEmail(String xwikiname, String password, String email, String message,... |
3475 |
|
String contentfield, XWikiContext context) throws XWikiException |
3476 |
|
{ |
3477 |
0 |
sendValidationEmail(xwikiname, password, email, "message", message, contentfield, context); |
3478 |
|
} |
3479 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3480 |
0 |
public void sendValidationEmail(String xwikiname, String password, String email, String validkey,... |
3481 |
|
String contentfield, XWikiContext context) throws XWikiException |
3482 |
|
{ |
3483 |
0 |
sendValidationEmail(xwikiname, password, email, "validkey", validkey, contentfield, context); |
3484 |
|
} |
3485 |
|
|
|
|
| 0% |
Uncovered Elements: 42 (42) |
Complexity: 7 |
Complexity Density: 0.19 |
|
3486 |
0 |
public void sendValidationEmail(String xwikiname, String password, String email, String addfieldname,... |
3487 |
|
String addfieldvalue, String contentfield, XWikiContext context) throws XWikiException |
3488 |
|
{ |
3489 |
0 |
MailSenderConfiguration configuration = Utils.getComponent(MailSenderConfiguration.class); |
3490 |
|
|
3491 |
0 |
String sender; |
3492 |
0 |
String content; |
3493 |
0 |
try { |
3494 |
0 |
sender = configuration.getFromAddress(); |
3495 |
0 |
if (StringUtils.isBlank(sender)) { |
3496 |
0 |
String server = context.getRequest().getServerName(); |
3497 |
0 |
if (server.matches("\\[.*\\]|(\\d{1,3}+\\.){3}+\\d{1,3}+")) { |
3498 |
0 |
sender = "noreply@domain.net"; |
3499 |
|
} else { |
3500 |
0 |
sender = "noreply@" + server; |
3501 |
|
} |
3502 |
|
} |
3503 |
0 |
content = getXWikiPreference(contentfield, context); |
3504 |
|
} catch (Exception e) { |
3505 |
0 |
throw new XWikiException(XWikiException.MODULE_XWIKI_EMAIL, |
3506 |
|
XWikiException.ERROR_XWIKI_EMAIL_CANNOT_GET_VALIDATION_CONFIG, |
3507 |
|
"Exception while reading the validation email config", e, null); |
3508 |
|
|
3509 |
|
} |
3510 |
|
|
3511 |
0 |
try { |
3512 |
0 |
VelocityContext vcontext = (VelocityContext) context.get("vcontext"); |
3513 |
0 |
vcontext.put(addfieldname, addfieldvalue); |
3514 |
0 |
vcontext.put("email", email); |
3515 |
0 |
vcontext.put("password", password); |
3516 |
0 |
vcontext.put("sender", sender); |
3517 |
0 |
vcontext.put("xwikiname", xwikiname); |
3518 |
0 |
content = parseContent(content, context); |
3519 |
|
} catch (Exception e) { |
3520 |
0 |
throw new XWikiException(XWikiException.MODULE_XWIKI_EMAIL, |
3521 |
|
XWikiException.ERROR_XWIKI_EMAIL_CANNOT_PREPARE_VALIDATION_EMAIL, |
3522 |
|
"Exception while preparing the validation email", e, null); |
3523 |
|
|
3524 |
|
} |
3525 |
|
|
3526 |
|
|
3527 |
0 |
try { |
3528 |
0 |
Session session = |
3529 |
|
Session.getInstance(configuration.getAllProperties(), new XWikiAuthenticator(configuration)); |
3530 |
0 |
InputStream is = new ByteArrayInputStream(content.getBytes()); |
3531 |
0 |
MimeMessage message = new MimeMessage(session, is); |
3532 |
0 |
message.setFrom(new InternetAddress(sender)); |
3533 |
0 |
message.setRecipients(Message.RecipientType.TO, email); |
3534 |
0 |
message.setHeader("X-MailType", "Account Validation"); |
3535 |
0 |
MailSender mailSender = Utils.getComponent(MailSender.class); |
3536 |
0 |
MailListener mailListener = Utils.getComponent(MailListener.class, "database"); |
3537 |
0 |
mailSender.sendAsynchronously(Arrays.asList(message), session, mailListener); |
3538 |
0 |
mailListener.getMailStatusResult().waitTillProcessed(Long.MAX_VALUE); |
3539 |
0 |
String errorMessage = MailStatusResultSerializer.serializeErrors(mailListener.getMailStatusResult()); |
3540 |
0 |
if (errorMessage != null) { |
3541 |
0 |
throw new XWikiException(XWikiException.MODULE_XWIKI_EMAIL, |
3542 |
|
XWikiException.ERROR_XWIKI_EMAIL_ERROR_SENDING_EMAIL, |
3543 |
|
String.format("Error while sending the validation email. %s", errorMessage)); |
3544 |
|
} |
3545 |
|
} catch (Exception e) { |
3546 |
0 |
throw new XWikiException(XWikiException.MODULE_XWIKI_EMAIL, |
3547 |
|
XWikiException.ERROR_XWIKI_EMAIL_ERROR_SENDING_EMAIL, "Error while sending the validation email", e); |
3548 |
|
} |
3549 |
|
} |
3550 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3551 |
87 |
public String generateRandomString(int size)... |
3552 |
|
{ |
3553 |
87 |
return RandomStringUtils.randomAlphanumeric(size); |
3554 |
|
} |
3555 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3556 |
0 |
public String generateValidationKey(int size)... |
3557 |
|
{ |
3558 |
0 |
return generateRandomString(size); |
3559 |
|
} |
3560 |
|
|
3561 |
|
|
3562 |
|
|
3563 |
|
|
3564 |
|
@param |
3565 |
|
@param |
3566 |
|
@param@link |
3567 |
|
@return |
3568 |
|
|
3569 |
|
|
3570 |
|
|
3571 |
|
|
3572 |
|
@throws |
3573 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3574 |
0 |
public int createUser(String userName, Map<String, ?> map, XWikiContext context) throws XWikiException... |
3575 |
|
{ |
3576 |
0 |
return createUser(userName, map, "edit", context); |
3577 |
|
} |
3578 |
|
|
3579 |
|
|
3580 |
|
|
3581 |
|
|
3582 |
|
@param |
3583 |
|
@param |
3584 |
|
@param |
3585 |
|
@param@link |
3586 |
|
@return |
3587 |
|
|
3588 |
|
|
3589 |
|
|
3590 |
|
|
3591 |
|
@throws |
3592 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
3593 |
0 |
public int createUser(String userName, Map<String, ?> map, String userRights, XWikiContext context)... |
3594 |
|
throws XWikiException |
3595 |
|
{ |
3596 |
0 |
BaseClass userClass = getUserClass(context); |
3597 |
|
|
3598 |
0 |
String content = ""; |
3599 |
0 |
Syntax syntax = getDefaultDocumentSyntaxInternal(); |
3600 |
|
|
3601 |
0 |
return createUser(userName, map, |
3602 |
|
new EntityReference(userClass.getDocumentReference().getName(), EntityType.DOCUMENT), content, syntax, |
3603 |
|
userRights, context); |
3604 |
|
} |
3605 |
|
|
3606 |
|
|
3607 |
|
@deprecated |
3608 |
|
@link |
3609 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
|
3610 |
0 |
@Deprecated... |
3611 |
|
public int createUser(String userName, Map<String, ?> map, String parent, String content, String syntaxId, |
3612 |
|
String userRights, XWikiContext context) throws XWikiException |
3613 |
|
{ |
3614 |
0 |
Syntax syntax; |
3615 |
|
|
3616 |
0 |
try { |
3617 |
0 |
syntax = getSyntaxFactory().createSyntaxFromIdString(syntaxId); |
3618 |
|
} catch (ParseException e) { |
3619 |
0 |
syntax = getDefaultDocumentSyntaxInternal(); |
3620 |
|
} |
3621 |
|
|
3622 |
0 |
return createUser(userName, map, getRelativeEntityReferenceResolver().resolve(parent, EntityType.DOCUMENT), |
3623 |
|
content, syntax, userRights, context); |
3624 |
|
} |
3625 |
|
|
3626 |
|
|
3627 |
|
|
3628 |
|
|
3629 |
|
@param |
3630 |
|
@param |
3631 |
|
@param |
3632 |
|
@param |
3633 |
|
@param |
3634 |
|
@param |
3635 |
|
@param@link |
3636 |
|
@return |
3637 |
|
|
3638 |
|
|
3639 |
|
|
3640 |
|
|
3641 |
|
@throws |
3642 |
|
|
|
|
| 90.9% |
Uncovered Elements: 2 (22) |
Complexity: 3 |
Complexity Density: 0.15 |
|
3643 |
29 |
public int createUser(String userName, Map<String, ?> map, EntityReference parentReference, String content,... |
3644 |
|
Syntax syntax, String userRights, XWikiContext context) throws XWikiException |
3645 |
|
{ |
3646 |
29 |
BaseClass userClass = getUserClass(context); |
3647 |
|
|
3648 |
29 |
try { |
3649 |
|
|
3650 |
29 |
XWikiDocument doc = getDocument(new DocumentReference(context.getWikiId(), "XWiki", userName), context); |
3651 |
|
|
3652 |
29 |
if (!doc.isNew()) { |
3653 |
|
|
3654 |
3 |
return -3; |
3655 |
|
} |
3656 |
|
|
3657 |
26 |
DocumentReference userClassReference = userClass.getDocumentReference(); |
3658 |
26 |
BaseObject userObject = |
3659 |
|
doc.newXObject(userClassReference.removeParent(userClassReference.getWikiReference()), context); |
3660 |
26 |
userClass.fromMap(map, userObject); |
3661 |
|
|
3662 |
26 |
doc.setParentReference(parentReference); |
3663 |
26 |
doc.setContent(content); |
3664 |
26 |
doc.setSyntax(syntax); |
3665 |
26 |
doc.setCreatorReference(doc.getDocumentReference()); |
3666 |
26 |
doc.setAuthorReference(doc.getDocumentReference()); |
3667 |
|
|
3668 |
|
|
3669 |
|
|
3670 |
|
|
3671 |
|
|
3672 |
26 |
doc.setDefaultLocale(context.getLocale()); |
3673 |
|
|
3674 |
26 |
protectUserPage(doc.getFullName(), userRights, doc, context); |
3675 |
|
|
3676 |
26 |
saveDocument(doc, localizePlainOrKey("core.comment.createdUser"), context); |
3677 |
|
|
3678 |
|
|
3679 |
26 |
setUserDefaultGroup(doc.getFullName(), context); |
3680 |
|
|
3681 |
26 |
return 1; |
3682 |
|
} catch (Exception e) { |
3683 |
0 |
Object[] args = { "XWiki." + userName }; |
3684 |
0 |
throw new XWikiException(XWikiException.MODULE_XWIKI_USER, XWikiException.ERROR_XWIKI_USER_CREATE, |
3685 |
|
"Cannot create user {0}", e, args); |
3686 |
|
} |
3687 |
|
} |
3688 |
|
|
3689 |
|
|
3690 |
|
@deprecated |
3691 |
|
@link |
3692 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3693 |
0 |
@Deprecated... |
3694 |
|
public int createUser(String xwikiname, Map<String, ?> map, String parent, String content, String userRights, |
3695 |
|
XWikiContext context) throws XWikiException |
3696 |
|
{ |
3697 |
0 |
return createUser(xwikiname, map, parent, content, Syntax.XWIKI_1_0.toIdString(), userRights, context); |
3698 |
|
} |
3699 |
|
|
|
|
| 80% |
Uncovered Elements: 2 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
3700 |
29 |
public void setUserDefaultGroup(String fullwikiname, XWikiContext context) throws XWikiException... |
3701 |
|
{ |
3702 |
29 |
String groupsPreference = getConfiguration().getProperty("xwiki.users.initialGroups", "XWiki.XWikiAllGroup"); |
3703 |
|
|
3704 |
29 |
if (groupsPreference != null) { |
3705 |
29 |
String[] groups = groupsPreference.split(","); |
3706 |
29 |
for (String groupName : groups) { |
3707 |
29 |
if (StringUtils.isNotBlank(groupName)) { |
3708 |
29 |
addUserToGroup(fullwikiname, groupName.trim(), context); |
3709 |
|
} |
3710 |
|
} |
3711 |
|
} |
3712 |
|
} |
3713 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
3714 |
29 |
protected void addUserToGroup(String userName, String groupName, XWikiContext context) throws XWikiException... |
3715 |
|
{ |
3716 |
29 |
XWikiDocument groupDoc = getDocument(groupName, context); |
3717 |
|
|
3718 |
29 |
DocumentReference groupClassReference = getGroupClass(context).getDocumentReference(); |
3719 |
29 |
BaseObject memberObject = |
3720 |
|
groupDoc.newXObject(groupClassReference.removeParent(groupClassReference.getWikiReference()), context); |
3721 |
|
|
3722 |
29 |
memberObject.setStringValue("member", userName); |
3723 |
|
|
3724 |
29 |
this.saveDocument(groupDoc, localizePlainOrKey("core.comment.addedUserToGroup"), context); |
3725 |
|
} |
3726 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
3727 |
29 |
public void protectUserPage(String userName, String userRights, XWikiDocument doc, XWikiContext context)... |
3728 |
|
throws XWikiException |
3729 |
|
{ |
3730 |
29 |
DocumentReference rightClassReference = getRightsClass(context).getDocumentReference(); |
3731 |
|
|
3732 |
29 |
EntityReference relativeRightClassReference = |
3733 |
|
rightClassReference.removeParent(rightClassReference.getWikiReference()); |
3734 |
|
|
3735 |
|
|
3736 |
29 |
BaseObject newuserrightsobject = doc.newXObject(relativeRightClassReference, context); |
3737 |
29 |
newuserrightsobject.setLargeStringValue("users", userName); |
3738 |
29 |
newuserrightsobject.setStringValue("levels", userRights); |
3739 |
29 |
newuserrightsobject.setIntValue("allow", 1); |
3740 |
|
} |
3741 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
3742 |
3 |
public User getUser(XWikiContext context)... |
3743 |
|
{ |
3744 |
3 |
XWikiUser xwikiUser = context.getXWikiUser(); |
3745 |
3 |
User user = new User(xwikiUser, context); |
3746 |
3 |
return user; |
3747 |
|
} |
3748 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
3749 |
0 |
public User getUser(String username, XWikiContext context)... |
3750 |
|
{ |
3751 |
0 |
XWikiUser xwikiUser = new XWikiUser(username); |
3752 |
0 |
User user = new User(xwikiUser, context); |
3753 |
0 |
return user; |
3754 |
|
} |
3755 |
|
|
3756 |
|
|
3757 |
|
|
3758 |
|
|
3759 |
|
@param@link |
3760 |
|
|
|
|
| 90.9% |
Uncovered Elements: 1 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
3761 |
11353 |
public void prepareResources(XWikiContext context)... |
3762 |
|
{ |
3763 |
11348 |
if (context.get("msg") == null) { |
3764 |
11303 |
Locale locale = getLocalePreference(context); |
3765 |
11344 |
context.setLocale(locale); |
3766 |
11342 |
if (context.getResponse() != null) { |
3767 |
11342 |
context.getResponse().setLocale(locale); |
3768 |
|
} |
3769 |
11331 |
XWikiMessageTool msg = new XWikiMessageTool(Utils.getComponent(ContextualLocalizationManager.class)); |
3770 |
11328 |
context.put("msg", msg); |
3771 |
|
} |
3772 |
|
} |
3773 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3774 |
13008 |
public XWikiUser checkAuth(XWikiContext context) throws XWikiException... |
3775 |
|
{ |
3776 |
13018 |
return getAuthService().checkAuth(context); |
3777 |
|
} |
3778 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 4 |
Complexity Density: 0.57 |
|
3779 |
11672 |
public boolean checkAccess(String action, XWikiDocument doc, XWikiContext context) throws XWikiException... |
3780 |
|
{ |
3781 |
|
|
3782 |
11674 |
String firstSpaceName = doc.getDocumentReference().getSpaceReferences().get(0).getName(); |
3783 |
11672 |
if (action.equals("skin") && SKIN_RESOURCE_SPACE_NAMES.contains(firstSpaceName)) { |
3784 |
|
|
3785 |
1112 |
XWikiUser user = checkAuth(context); |
3786 |
1109 |
if (user != null) { |
3787 |
851 |
context.setUser(user.getUser()); |
3788 |
|
} |
3789 |
|
|
3790 |
|
|
3791 |
1114 |
return true; |
3792 |
|
} |
3793 |
|
|
3794 |
10560 |
return getRightService().checkAccess(action, doc, context); |
3795 |
|
} |
3796 |
|
|
|
|
| 72.9% |
Uncovered Elements: 26 (96) |
Complexity: 20 |
Complexity Density: 0.3 |
|
3797 |
150 |
public String include(String topic, boolean isForm, XWikiContext context) throws XWikiException... |
3798 |
|
{ |
3799 |
150 |
String database = null, incdatabase = null; |
3800 |
150 |
String prefixedTopic, localTopic; |
3801 |
|
|
3802 |
|
|
3803 |
150 |
Document currentAPIdoc = null, currentAPIcdoc = null, currentAPItdoc = null; |
3804 |
150 |
ScriptContextManager scritContextManager = Utils.getComponent(ScriptContextManager.class); |
3805 |
150 |
ScriptContext scontext = scritContextManager.getScriptContext(); |
3806 |
150 |
String currentDocName = context.getWikiId() + ":" + context.getDoc().getFullName(); |
3807 |
150 |
if (scontext != null) { |
3808 |
150 |
currentAPIdoc = (Document) scontext.getAttribute("doc"); |
3809 |
150 |
currentAPIcdoc = (Document) scontext.getAttribute("cdoc"); |
3810 |
150 |
currentAPItdoc = (Document) scontext.getAttribute("tdoc"); |
3811 |
|
} |
3812 |
|
|
3813 |
150 |
try { |
3814 |
150 |
int i0 = topic.indexOf(':'); |
3815 |
150 |
if (i0 != -1) { |
3816 |
0 |
incdatabase = topic.substring(0, i0); |
3817 |
0 |
database = context.getWikiId(); |
3818 |
0 |
context.setWikiId(incdatabase); |
3819 |
0 |
prefixedTopic = topic; |
3820 |
0 |
localTopic = topic.substring(i0 + 1); |
3821 |
|
} else { |
3822 |
150 |
prefixedTopic = context.getWikiId() + ":" + topic; |
3823 |
150 |
localTopic = topic; |
3824 |
|
} |
3825 |
|
|
3826 |
150 |
XWikiDocument doc = null; |
3827 |
150 |
try { |
3828 |
150 |
LOGGER.debug("Including Topic " + topic); |
3829 |
150 |
try { |
3830 |
150 |
@SuppressWarnings("unchecked") |
3831 |
|
Set<String> includedDocs = (Set<String>) context.get("included_docs"); |
3832 |
150 |
if (includedDocs == null) { |
3833 |
150 |
includedDocs = new HashSet<String>(); |
3834 |
150 |
context.put("included_docs", includedDocs); |
3835 |
|
} |
3836 |
|
|
3837 |
150 |
if (includedDocs.contains(prefixedTopic) || currentDocName.equals(prefixedTopic)) { |
3838 |
0 |
LOGGER.warn("Error on too many recursive includes for topic " + topic); |
3839 |
0 |
return "Cannot make recursive include"; |
3840 |
|
} |
3841 |
150 |
includedDocs.add(prefixedTopic); |
3842 |
|
} catch (Exception e) { |
3843 |
|
} |
3844 |
|
|
3845 |
|
|
3846 |
150 |
DocumentReference targetDocumentReference = |
3847 |
|
getCurrentMixedDocumentReferenceResolver().resolve(localTopic); |
3848 |
150 |
doc = getDocument(targetDocumentReference, context); |
3849 |
|
|
3850 |
150 |
if (checkAccess("view", doc, context) == false) { |
3851 |
0 |
throw new XWikiException(XWikiException.MODULE_XWIKI_ACCESS, |
3852 |
|
XWikiException.ERROR_XWIKI_ACCESS_DENIED, "Access to this document is denied: " + doc); |
3853 |
|
} |
3854 |
|
} catch (XWikiException e) { |
3855 |
0 |
LOGGER.warn("Exception Including Topic " + topic, e); |
3856 |
0 |
return "Topic " + topic + " does not exist"; |
3857 |
|
} |
3858 |
|
|
3859 |
150 |
XWikiDocument contentdoc = doc.getTranslatedDocument(context); |
3860 |
|
|
3861 |
150 |
String result; |
3862 |
150 |
if (isForm) { |
3863 |
|
|
3864 |
72 |
if (database != null) { |
3865 |
0 |
context.setWikiId(database); |
3866 |
|
} |
3867 |
|
|
3868 |
|
|
3869 |
|
|
3870 |
72 |
result = getRenderedContent(contentdoc, (XWikiDocument) context.get("doc"), context); |
3871 |
|
} else { |
3872 |
|
|
3873 |
|
|
3874 |
|
|
3875 |
|
|
3876 |
78 |
XWikiDocument originalDoc = null; |
3877 |
78 |
try { |
3878 |
78 |
originalDoc = context.getDoc(); |
3879 |
78 |
context.put("doc", doc); |
3880 |
78 |
result = getRenderedContent(contentdoc, doc, context); |
3881 |
|
} finally { |
3882 |
78 |
context.put("doc", originalDoc); |
3883 |
|
} |
3884 |
|
} |
3885 |
150 |
try { |
3886 |
150 |
@SuppressWarnings("unchecked") |
3887 |
|
Set<String> includedDocs = (Set<String>) context.get("included_docs"); |
3888 |
150 |
if (includedDocs != null) { |
3889 |
150 |
includedDocs.remove(prefixedTopic); |
3890 |
|
} |
3891 |
|
} catch (Exception e) { |
3892 |
|
} |
3893 |
150 |
return result; |
3894 |
|
} finally { |
3895 |
150 |
if (database != null) { |
3896 |
0 |
context.setWikiId(database); |
3897 |
|
} |
3898 |
|
|
3899 |
150 |
if (currentAPIdoc != null) { |
3900 |
150 |
if (scontext != null) { |
3901 |
150 |
scontext.setAttribute("doc", currentAPIdoc, ScriptContext.ENGINE_SCOPE); |
3902 |
|
} |
3903 |
|
} |
3904 |
150 |
if (currentAPIcdoc != null) { |
3905 |
150 |
if (scontext != null) { |
3906 |
150 |
scontext.setAttribute("cdoc", currentAPIcdoc, ScriptContext.ENGINE_SCOPE); |
3907 |
|
} |
3908 |
|
} |
3909 |
150 |
if (currentAPItdoc != null) { |
3910 |
150 |
if (scontext != null) { |
3911 |
150 |
scontext.setAttribute("tdoc", currentAPItdoc, ScriptContext.ENGINE_SCOPE); |
3912 |
|
} |
3913 |
|
} |
3914 |
|
} |
3915 |
|
} |
3916 |
|
|
3917 |
|
|
3918 |
|
|
3919 |
|
|
3920 |
|
|
3921 |
|
@since |
3922 |
|
|
|
|
| 88.9% |
Uncovered Elements: 2 (18) |
Complexity: 3 |
Complexity Density: 0.21 |
|
3923 |
150 |
private String getRenderedContent(XWikiDocument includedDoc, XWikiDocument includingDoc, XWikiContext context)... |
3924 |
|
throws XWikiException |
3925 |
|
{ |
3926 |
150 |
String result; |
3927 |
150 |
XWikiDocument idoc = (XWikiDocument) context.get("idoc"); |
3928 |
150 |
XWikiDocument sdoc = (XWikiDocument) context.get("sdoc"); |
3929 |
|
|
3930 |
150 |
context.put("idoc", includingDoc); |
3931 |
150 |
context.put("sdoc", includedDoc); |
3932 |
150 |
try { |
3933 |
150 |
result = includedDoc.getRenderedContent(Utils.getComponent(RenderingContext.class).getTargetSyntax(), false, |
3934 |
|
context); |
3935 |
|
} finally { |
3936 |
|
|
3937 |
150 |
if (idoc == null) { |
3938 |
150 |
context.remove("idoc"); |
3939 |
|
} else { |
3940 |
0 |
context.put("idoc", idoc); |
3941 |
|
} |
3942 |
|
|
3943 |
|
|
3944 |
150 |
if (sdoc == null) { |
3945 |
1 |
context.remove("sdoc"); |
3946 |
|
} else { |
3947 |
149 |
context.put("sdoc", sdoc); |
3948 |
|
} |
3949 |
|
} |
3950 |
|
|
3951 |
150 |
return result; |
3952 |
|
} |
3953 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
3954 |
129 |
public void deleteDocument(XWikiDocument doc, XWikiContext context) throws XWikiException... |
3955 |
|
{ |
3956 |
129 |
deleteDocument(doc, true, context); |
3957 |
|
} |
3958 |
|
|
|
|
| 88% |
Uncovered Elements: 3 (25) |
Complexity: 6 |
Complexity Density: 0.32 |
|
3959 |
156 |
public void deleteDocument(XWikiDocument doc, boolean totrash, XWikiContext context) throws XWikiException... |
3960 |
|
{ |
3961 |
156 |
String currentWiki = null; |
3962 |
|
|
3963 |
156 |
currentWiki = context.getWikiId(); |
3964 |
156 |
try { |
3965 |
156 |
context.setWikiId(doc.getDocumentReference().getWikiReference().getName()); |
3966 |
|
|
3967 |
|
|
3968 |
|
|
3969 |
|
|
3970 |
156 |
XWikiDocument blankDoc = new XWikiDocument(doc.getDocumentReference()); |
3971 |
|
|
3972 |
|
|
3973 |
156 |
blankDoc.setOriginalDocument(doc.getOriginalDocument()); |
3974 |
156 |
blankDoc.setAuthorReference(context.getUserReference()); |
3975 |
156 |
blankDoc.setContentAuthorReference(context.getUserReference()); |
3976 |
|
|
3977 |
156 |
ObservationManager om = getObservationManager(); |
3978 |
|
|
3979 |
|
|
3980 |
|
|
3981 |
|
|
3982 |
156 |
if (om != null) { |
3983 |
156 |
om.notify(new DocumentDeletingEvent(doc.getDocumentReference()), blankDoc, context); |
3984 |
|
} |
3985 |
|
|
3986 |
156 |
if (hasRecycleBin(context) && totrash) { |
3987 |
153 |
getRecycleBinStore().saveToRecycleBin(doc, context.getUser(), new Date(), context, true); |
3988 |
|
} |
3989 |
|
|
3990 |
156 |
getStore().deleteXWikiDoc(doc, context); |
3991 |
|
|
3992 |
156 |
try { |
3993 |
|
|
3994 |
|
|
3995 |
|
|
3996 |
156 |
if (om != null) { |
3997 |
156 |
om.notify(new DocumentDeletedEvent(doc.getDocumentReference()), blankDoc, context); |
3998 |
|
} |
3999 |
|
} catch (Exception ex) { |
4000 |
0 |
LOGGER.error("Failed to send document delete notifications for document [{}]", |
4001 |
|
doc.getDocumentReference(), ex); |
4002 |
|
} |
4003 |
|
} finally { |
4004 |
156 |
context.setWikiId(currentWiki); |
4005 |
|
} |
4006 |
|
} |
4007 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
4008 |
4 |
public String getDatabase()... |
4009 |
|
{ |
4010 |
4 |
return this.database; |
4011 |
|
} |
4012 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
4013 |
87 |
public void setDatabase(String database)... |
4014 |
|
{ |
4015 |
87 |
this.database = database; |
4016 |
|
} |
4017 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
4018 |
0 |
public void gc()... |
4019 |
|
{ |
4020 |
0 |
System.gc(); |
4021 |
|
} |
4022 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
4023 |
0 |
public long freeMemory()... |
4024 |
|
{ |
4025 |
0 |
return Runtime.getRuntime().freeMemory(); |
4026 |
|
} |
4027 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
4028 |
0 |
public long totalMemory()... |
4029 |
|
{ |
4030 |
0 |
return Runtime.getRuntime().totalMemory(); |
4031 |
|
} |
4032 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
4033 |
0 |
public long maxMemory()... |
4034 |
|
{ |
4035 |
0 |
return Runtime.getRuntime().maxMemory(); |
4036 |
|
} |
4037 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
4038 |
0 |
public String[] split(String str, String sep)... |
4039 |
|
{ |
4040 |
0 |
return StringUtils.split(str, sep); |
4041 |
|
} |
4042 |
|
|
4043 |
|
|
4044 |
|
@deprecated@link |
4045 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
4046 |
0 |
@Deprecated... |
4047 |
|
public String printStrackTrace(Throwable e) |
4048 |
|
{ |
4049 |
0 |
StringWriter strwriter = new StringWriter(); |
4050 |
0 |
PrintWriter writer = new PrintWriter(strwriter); |
4051 |
0 |
e.printStackTrace(writer); |
4052 |
|
|
4053 |
0 |
return strwriter.toString(); |
4054 |
|
} |
4055 |
|
|
4056 |
|
|
4057 |
|
@since |
4058 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
4059 |
4 |
public boolean copyDocument(DocumentReference sourceDocumentReference, DocumentReference targetDocumentReference,... |
4060 |
|
XWikiContext context) throws XWikiException |
4061 |
|
{ |
4062 |
4 |
return copyDocument(sourceDocumentReference, targetDocumentReference, null, true, context); |
4063 |
|
} |
4064 |
|
|
4065 |
|
|
4066 |
|
@since |
4067 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
4068 |
3 |
public boolean copyDocument(DocumentReference sourceDocumentReference, DocumentReference targetDocumentReference,... |
4069 |
|
boolean reset, XWikiContext context) throws XWikiException |
4070 |
|
{ |
4071 |
3 |
return copyDocument(sourceDocumentReference, targetDocumentReference, null, reset, context); |
4072 |
|
} |
4073 |
|
|
4074 |
|
|
4075 |
|
@since |
4076 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
4077 |
0 |
public boolean copyDocument(DocumentReference sourceDocumentReference, DocumentReference targetDocumentReference,... |
4078 |
|
boolean reset, boolean force, boolean resetCreationData, XWikiContext context) throws XWikiException |
4079 |
|
{ |
4080 |
0 |
return copyDocument(sourceDocumentReference, targetDocumentReference, null, reset, force, resetCreationData, |
4081 |
|
context); |
4082 |
|
} |
4083 |
|
|
4084 |
|
|
4085 |
|
@since |
4086 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
4087 |
0 |
public boolean copyDocument(DocumentReference sourceDocumentReference, DocumentReference targetDocumentReference,... |
4088 |
|
String wikilocale, XWikiContext context) throws XWikiException |
4089 |
|
{ |
4090 |
0 |
return copyDocument(sourceDocumentReference, targetDocumentReference, wikilocale, true, context); |
4091 |
|
} |
4092 |
|
|
4093 |
|
|
4094 |
|
@since |
4095 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
4096 |
7 |
public boolean copyDocument(DocumentReference sourceDocumentReference, DocumentReference targetDocumentReference,... |
4097 |
|
String wikilocale, boolean reset, XWikiContext context) throws XWikiException |
4098 |
|
{ |
4099 |
7 |
return copyDocument(sourceDocumentReference, targetDocumentReference, wikilocale, reset, false, context); |
4100 |
|
} |
4101 |
|
|
4102 |
|
|
4103 |
|
@since |
4104 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
4105 |
81 |
public boolean copyDocument(DocumentReference sourceDocumentReference, DocumentReference targetDocumentReference,... |
4106 |
|
String wikilocale, boolean reset, boolean force, XWikiContext context) throws XWikiException |
4107 |
|
{ |
4108 |
81 |
return copyDocument(sourceDocumentReference, targetDocumentReference, wikilocale, reset, force, false, context); |
4109 |
|
} |
4110 |
|
|
4111 |
|
|
4112 |
|
@since |
4113 |
|
|
|
|
| 58.5% |
Uncovered Elements: 54 (130) |
Complexity: 17 |
Complexity Density: 0.17 |
|
4114 |
87 |
public boolean copyDocument(DocumentReference sourceDocumentReference, DocumentReference targetDocumentReference,... |
4115 |
|
String wikilocale, boolean reset, boolean force, boolean resetCreationData, XWikiContext context) |
4116 |
|
throws XWikiException |
4117 |
|
{ |
4118 |
87 |
String db = context.getWikiId(); |
4119 |
87 |
String sourceWiki = sourceDocumentReference.getWikiReference().getName(); |
4120 |
87 |
String targetWiki = targetDocumentReference.getWikiReference().getName(); |
4121 |
|
|
4122 |
87 |
String sourceStringReference = getDefaultEntityReferenceSerializer().serialize(sourceDocumentReference); |
4123 |
|
|
4124 |
87 |
try { |
4125 |
87 |
context.setWikiId(sourceWiki); |
4126 |
87 |
XWikiDocument sdoc = getDocument(sourceDocumentReference, context); |
4127 |
87 |
if (!sdoc.isNew()) { |
4128 |
87 |
if (LOGGER.isInfoEnabled()) { |
4129 |
0 |
LOGGER.info( |
4130 |
|
"Copying document [" + sourceDocumentReference + "] to [" + targetDocumentReference + "]"); |
4131 |
|
} |
4132 |
|
|
4133 |
|
|
4134 |
87 |
context.setWikiId(targetWiki); |
4135 |
87 |
XWikiDocument tdoc = getDocument(targetDocumentReference, context); |
4136 |
|
|
4137 |
87 |
if (!tdoc.isNew()) { |
4138 |
52 |
if (force) { |
4139 |
|
|
4140 |
52 |
deleteDocument(tdoc, context); |
4141 |
|
} else { |
4142 |
0 |
return false; |
4143 |
|
} |
4144 |
|
} |
4145 |
|
|
4146 |
|
|
4147 |
87 |
context.setWikiId(sourceWiki); |
4148 |
|
|
4149 |
87 |
if (wikilocale == null) { |
4150 |
87 |
tdoc = sdoc.copyDocument(targetDocumentReference, context); |
4151 |
|
|
4152 |
|
|
4153 |
|
|
4154 |
|
|
4155 |
87 |
tdoc.setNew(true); |
4156 |
|
|
4157 |
|
|
4158 |
87 |
if (reset) { |
4159 |
78 |
tdoc.setVersion("1.1"); |
4160 |
|
} |
4161 |
87 |
if (resetCreationData) { |
4162 |
6 |
Date now = new Date(); |
4163 |
6 |
tdoc.setCreationDate(now); |
4164 |
6 |
tdoc.setContentUpdateDate(now); |
4165 |
6 |
tdoc.setDate(now); |
4166 |
6 |
tdoc.setCreatorReference(context.getUserReference()); |
4167 |
6 |
tdoc.setAuthorReference(context.getUserReference()); |
4168 |
|
} |
4169 |
|
|
4170 |
|
|
4171 |
87 |
tdoc.setMetaDataDirty(false); |
4172 |
87 |
tdoc.setContentDirty(false); |
4173 |
|
|
4174 |
87 |
saveDocument(tdoc, "Copied from " + sourceStringReference, context); |
4175 |
|
|
4176 |
87 |
if (!reset) { |
4177 |
9 |
context.setWikiId(sourceWiki); |
4178 |
9 |
XWikiDocumentArchive txda = getVersioningStore().getXWikiDocumentArchive(sdoc, context); |
4179 |
9 |
context.setWikiId(targetWiki); |
4180 |
9 |
txda = txda.clone(tdoc.getId(), context); |
4181 |
9 |
getVersioningStore().saveXWikiDocArchive(txda, true, context); |
4182 |
|
} else { |
4183 |
78 |
context.setWikiId(targetWiki); |
4184 |
78 |
getVersioningStore().resetRCSArchive(tdoc, true, context); |
4185 |
|
} |
4186 |
|
|
4187 |
|
|
4188 |
87 |
context.setWikiId(sourceWiki); |
4189 |
87 |
List<String> tlist = sdoc.getTranslationList(context); |
4190 |
87 |
for (String clanguage : tlist) { |
4191 |
30 |
XWikiDocument stdoc = sdoc.getTranslatedDocument(clanguage, context); |
4192 |
30 |
if (LOGGER.isInfoEnabled()) { |
4193 |
0 |
LOGGER.info("Copying document [" + sourceWiki + "], language [" + clanguage + "] to [" |
4194 |
|
+ targetDocumentReference + "]"); |
4195 |
|
} |
4196 |
|
|
4197 |
30 |
context.setWikiId(targetWiki); |
4198 |
30 |
XWikiDocument ttdoc = tdoc.getTranslatedDocument(clanguage, context); |
4199 |
|
|
4200 |
|
|
4201 |
30 |
if (ttdoc != tdoc) { |
4202 |
0 |
return false; |
4203 |
|
} |
4204 |
|
|
4205 |
|
|
4206 |
30 |
context.setWikiId(sourceWiki); |
4207 |
|
|
4208 |
30 |
ttdoc = stdoc.copyDocument(targetDocumentReference, context); |
4209 |
|
|
4210 |
|
|
4211 |
30 |
if (reset) { |
4212 |
30 |
ttdoc.setNew(true); |
4213 |
30 |
ttdoc.setVersion("1.1"); |
4214 |
|
} |
4215 |
30 |
if (resetCreationData) { |
4216 |
0 |
Date now = new Date(); |
4217 |
0 |
ttdoc.setCreationDate(now); |
4218 |
0 |
ttdoc.setContentUpdateDate(now); |
4219 |
0 |
ttdoc.setDate(now); |
4220 |
0 |
ttdoc.setCreatorReference(context.getUserReference()); |
4221 |
0 |
ttdoc.setAuthorReference(context.getUserReference()); |
4222 |
|
} |
4223 |
|
|
4224 |
|
|
4225 |
|
|
4226 |
30 |
tdoc.setMetaDataDirty(false); |
4227 |
30 |
tdoc.setContentDirty(false); |
4228 |
|
|
4229 |
30 |
saveDocument(ttdoc, "Copied from " + sourceStringReference, context); |
4230 |
|
|
4231 |
30 |
if (!reset) { |
4232 |
0 |
context.setWikiId(sourceWiki); |
4233 |
0 |
XWikiDocumentArchive txda = getVersioningStore().getXWikiDocumentArchive(sdoc, context); |
4234 |
0 |
context.setWikiId(targetWiki); |
4235 |
0 |
txda = txda.clone(tdoc.getId(), context); |
4236 |
0 |
getVersioningStore().saveXWikiDocArchive(txda, true, context); |
4237 |
|
} else { |
4238 |
30 |
getVersioningStore().resetRCSArchive(tdoc, true, context); |
4239 |
|
} |
4240 |
|
} |
4241 |
|
} else { |
4242 |
|
|
4243 |
0 |
XWikiDocument stdoc = sdoc.getTranslatedDocument(wikilocale, context); |
4244 |
|
|
4245 |
0 |
tdoc = stdoc.copyDocument(targetDocumentReference, context); |
4246 |
|
|
4247 |
|
|
4248 |
|
|
4249 |
|
|
4250 |
0 |
tdoc.setNew(true); |
4251 |
|
|
4252 |
|
|
4253 |
0 |
tdoc.setDefaultLanguage(wikilocale); |
4254 |
0 |
tdoc.setLanguage(""); |
4255 |
|
|
4256 |
0 |
if (reset) { |
4257 |
0 |
tdoc.setVersion("1.1"); |
4258 |
|
} |
4259 |
0 |
if (resetCreationData) { |
4260 |
0 |
Date now = new Date(); |
4261 |
0 |
tdoc.setCreationDate(now); |
4262 |
0 |
tdoc.setContentUpdateDate(now); |
4263 |
0 |
tdoc.setDate(now); |
4264 |
0 |
tdoc.setCreatorReference(context.getUserReference()); |
4265 |
0 |
tdoc.setAuthorReference(context.getUserReference()); |
4266 |
|
} |
4267 |
|
|
4268 |
|
|
4269 |
|
|
4270 |
0 |
tdoc.setMetaDataDirty(false); |
4271 |
0 |
tdoc.setContentDirty(false); |
4272 |
|
|
4273 |
0 |
saveDocument(tdoc, "Copied from " + sourceStringReference, context); |
4274 |
|
|
4275 |
0 |
if (!reset) { |
4276 |
0 |
context.setWikiId(sourceWiki); |
4277 |
0 |
XWikiDocumentArchive txda = getVersioningStore().getXWikiDocumentArchive(sdoc, context); |
4278 |
0 |
context.setWikiId(targetWiki); |
4279 |
0 |
txda = txda.clone(tdoc.getId(), context); |
4280 |
0 |
getVersioningStore().saveXWikiDocArchive(txda, true, context); |
4281 |
|
} else { |
4282 |
0 |
getVersioningStore().resetRCSArchive(tdoc, true, context); |
4283 |
|
} |
4284 |
|
} |
4285 |
|
} |
4286 |
87 |
return true; |
4287 |
|
} finally { |
4288 |
87 |
context.setWikiId(db); |
4289 |
|
} |
4290 |
|
} |
4291 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
4292 |
0 |
public int copySpaceBetweenWikis(String space, String sourceWiki, String targetWiki, String locale,... |
4293 |
|
XWikiContext context) throws XWikiException |
4294 |
|
{ |
4295 |
0 |
return copySpaceBetweenWikis(space, sourceWiki, targetWiki, locale, false, context); |
4296 |
|
} |
4297 |
|
|
|
|
| 0% |
Uncovered Elements: 40 (40) |
Complexity: 5 |
Complexity Density: 0.16 |
|
4298 |
0 |
public int copySpaceBetweenWikis(String space, String sourceWiki, String targetWiki, String locale, boolean clean,... |
4299 |
|
XWikiContext context) throws XWikiException |
4300 |
|
{ |
4301 |
0 |
String db = context.getWikiId(); |
4302 |
0 |
int nb = 0; |
4303 |
|
|
4304 |
|
|
4305 |
|
|
4306 |
0 |
String sql = "select distinct doc.fullName from XWikiDocument as doc"; |
4307 |
0 |
List<String> parameters = new ArrayList<String>(); |
4308 |
0 |
if (space != null) { |
4309 |
0 |
sql += " where doc.space = ?"; |
4310 |
0 |
parameters.add(space); |
4311 |
|
} |
4312 |
|
|
4313 |
0 |
if (clean) { |
4314 |
0 |
try { |
4315 |
0 |
context.setWikiId(targetWiki); |
4316 |
0 |
List<String> list = getStore().search(sql, 0, 0, parameters, context); |
4317 |
0 |
if (LOGGER.isInfoEnabled()) { |
4318 |
0 |
LOGGER.info("Deleting " + list.size() + " documents from wiki " + targetWiki); |
4319 |
|
} |
4320 |
|
|
4321 |
0 |
for (String docname : list) { |
4322 |
0 |
XWikiDocument doc = getDocument(docname, context); |
4323 |
0 |
deleteDocument(doc, context); |
4324 |
|
} |
4325 |
|
} finally { |
4326 |
0 |
context.setWikiId(db); |
4327 |
|
} |
4328 |
|
} |
4329 |
|
|
4330 |
0 |
try { |
4331 |
0 |
context.setWikiId(sourceWiki); |
4332 |
0 |
List<String> list = getStore().search(sql, 0, 0, parameters, context); |
4333 |
0 |
if (LOGGER.isInfoEnabled()) { |
4334 |
0 |
LOGGER.info("Copying " + list.size() + " documents from wiki " + sourceWiki + " to wiki " + targetWiki); |
4335 |
|
} |
4336 |
|
|
4337 |
0 |
WikiReference sourceWikiReference = new WikiReference(sourceWiki); |
4338 |
0 |
WikiReference targetWikiReference = new WikiReference(targetWiki); |
4339 |
0 |
for (String docname : list) { |
4340 |
0 |
DocumentReference sourceDocumentReference = getCurrentMixedDocumentReferenceResolver().resolve(docname); |
4341 |
0 |
sourceDocumentReference = sourceDocumentReference |
4342 |
|
.replaceParent(sourceDocumentReference.getWikiReference(), sourceWikiReference); |
4343 |
0 |
DocumentReference targetDocumentReference = |
4344 |
|
sourceDocumentReference.replaceParent(sourceWikiReference, targetWikiReference); |
4345 |
0 |
copyDocument(sourceDocumentReference, targetDocumentReference, locale, context); |
4346 |
0 |
nb++; |
4347 |
|
} |
4348 |
0 |
return nb; |
4349 |
|
} finally { |
4350 |
0 |
context.setWikiId(db); |
4351 |
|
} |
4352 |
|
} |
4353 |
|
|
4354 |
|
|
4355 |
|
|
4356 |
|
|
4357 |
|
|
4358 |
|
|
4359 |
|
@param |
4360 |
|
@param |
4361 |
|
@param |
4362 |
|
@param@link |
4363 |
|
@return |
4364 |
|
@throws |
4365 |
|
@deprecated@link |
4366 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
4367 |
0 |
@Deprecated... |
4368 |
|
public int copyWiki(String sourceWiki, String targetWiki, String locale, XWikiContext context) throws XWikiException |
4369 |
|
{ |
4370 |
0 |
return copyWiki(sourceWiki, targetWiki, locale, false, context); |
4371 |
|
} |
4372 |
|
|
4373 |
|
|
4374 |
|
|
4375 |
|
|
4376 |
|
@param |
4377 |
|
@param |
4378 |
|
@param |
4379 |
|
@param |
4380 |
|
@param@link |
4381 |
|
@return |
4382 |
|
@throws |
4383 |
|
@deprecated@link |
4384 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
4385 |
0 |
@Deprecated... |
4386 |
|
public int copyWiki(String sourceWiki, String targetWiki, String locale, boolean clean, XWikiContext context) |
4387 |
|
throws XWikiException |
4388 |
|
{ |
4389 |
0 |
int documents = copySpaceBetweenWikis(null, sourceWiki, targetWiki, locale, clean, context); |
4390 |
|
|
4391 |
0 |
ObservationManager om = getObservationManager(); |
4392 |
|
|
4393 |
0 |
if (om != null) { |
4394 |
0 |
om.notify(new WikiCopiedEvent(sourceWiki, targetWiki), sourceWiki, context); |
4395 |
|
} |
4396 |
|
|
4397 |
0 |
return documents; |
4398 |
|
} |
4399 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
4400 |
28124 |
public String getEncoding()... |
4401 |
|
{ |
4402 |
28124 |
return getConfiguration().getProperty("xwiki.encoding", "UTF-8"); |
4403 |
|
} |
4404 |
|
|
|
|
| 77.8% |
Uncovered Elements: 10 (45) |
Complexity: 12 |
Complexity Density: 0.44 |
|
4405 |
9600 |
public URL getServerURL(String database, XWikiContext context) throws MalformedURLException... |
4406 |
|
{ |
4407 |
9600 |
String serverurl = null; |
4408 |
|
|
4409 |
|
|
4410 |
9600 |
if ("1".equals(getConfiguration().getProperty("xwiki.virtual.usepath", "1"))) { |
4411 |
9596 |
return null; |
4412 |
|
} |
4413 |
|
|
4414 |
4 |
if (database != null) { |
4415 |
4 |
String db = context.getWikiId(); |
4416 |
4 |
try { |
4417 |
4 |
context.setWikiId(getDatabase()); |
4418 |
4 |
XWikiDocument doc = getDocument("XWiki.XWikiServer" + StringUtils.capitalize(database), context); |
4419 |
4 |
BaseObject serverobject = doc.getXObject(VIRTUAL_WIKI_DEFINITION_CLASS_REFERENCE); |
4420 |
4 |
if (serverobject != null) { |
4421 |
4 |
String server = serverobject.getStringValue("server"); |
4422 |
4 |
if (server != null) { |
4423 |
4 |
String protocol = getConfiguration().getProperty("xwiki.url.protocol", null); |
4424 |
4 |
if (protocol == null) { |
4425 |
4 |
int iSecure = serverobject.getIntValue("secure", -1); |
4426 |
|
|
4427 |
4 |
boolean secure = iSecure == 1 || (iSecure < 0 && context.getRequest().isSecure()); |
4428 |
4 |
protocol = secure ? "https" : "http"; |
4429 |
|
} |
4430 |
4 |
long port = context.getURL().getPort(); |
4431 |
4 |
if (port == 80 || port == 443) { |
4432 |
0 |
port = -1; |
4433 |
|
} |
4434 |
4 |
if (port != -1) { |
4435 |
0 |
serverurl = protocol + "://" + server + ":" + port + "/"; |
4436 |
|
} else { |
4437 |
4 |
serverurl = protocol + "://" + server + "/"; |
4438 |
|
} |
4439 |
|
} |
4440 |
|
} |
4441 |
|
} catch (Exception ex) { |
4442 |
|
} finally { |
4443 |
4 |
context.setWikiId(db); |
4444 |
|
} |
4445 |
|
} |
4446 |
|
|
4447 |
4 |
if (serverurl != null) { |
4448 |
4 |
return new URL(serverurl); |
4449 |
|
} else { |
4450 |
0 |
return null; |
4451 |
|
} |
4452 |
|
} |
4453 |
|
|
|
|
| 89.7% |
Uncovered Elements: 3 (29) |
Complexity: 9 |
Complexity Density: 0.47 |
|
4454 |
112287 |
public String getServletPath(String wikiName, XWikiContext context)... |
4455 |
|
{ |
4456 |
|
|
4457 |
112283 |
if (!context.getMainXWiki().equalsIgnoreCase(wikiName) |
4458 |
|
&& "1".equals(getConfiguration().getProperty("xwiki.virtual.usepath", "1"))) { |
4459 |
10048 |
String database = context.getWikiId(); |
4460 |
10048 |
try { |
4461 |
10048 |
context.setWikiId(context.getMainXWiki()); |
4462 |
10049 |
XWikiDocument doc = getDocument(getServerWikiPage(wikiName), context); |
4463 |
10049 |
BaseObject serverobject = doc.getXObject(VIRTUAL_WIKI_DEFINITION_CLASS_REFERENCE); |
4464 |
10049 |
if (serverobject != null) { |
4465 |
10025 |
String server = serverobject.getStringValue("server"); |
4466 |
10025 |
return "wiki/" + server + "/"; |
4467 |
|
} |
4468 |
|
} catch (Exception e) { |
4469 |
0 |
LOGGER.error("Failed to get URL for provided wiki [" + wikiName + "]", e); |
4470 |
|
} finally { |
4471 |
10049 |
context.setWikiId(database); |
4472 |
|
} |
4473 |
|
} |
4474 |
|
|
4475 |
102261 |
String servletPath = getConfiguration().getProperty("xwiki.servletpath", ""); |
4476 |
|
|
4477 |
102260 |
if (context.getRequest() != null) { |
4478 |
102260 |
if (StringUtils.isEmpty(servletPath)) { |
4479 |
102260 |
String currentServletpath = context.getRequest().getServletPath(); |
4480 |
102258 |
if (currentServletpath != null && currentServletpath.startsWith("/bin")) { |
4481 |
100826 |
servletPath = "bin/"; |
4482 |
|
} else { |
4483 |
1432 |
servletPath = getConfiguration().getProperty("xwiki.defaultservletpath", "bin/"); |
4484 |
|
} |
4485 |
|
} |
4486 |
|
} |
4487 |
|
|
4488 |
102258 |
return servletPath; |
4489 |
|
} |
4490 |
|
|
|
|
| 86.7% |
Uncovered Elements: 2 (15) |
Complexity: 4 |
Complexity Density: 0.44 |
|
4491 |
14047 |
public String getWebAppPath(XWikiContext context)... |
4492 |
|
{ |
4493 |
14046 |
String contextPath = getConfiguration().getProperty("xwiki.webapppath"); |
4494 |
14048 |
if (contextPath == null) { |
4495 |
|
|
4496 |
|
|
4497 |
|
|
4498 |
|
|
4499 |
14048 |
XWikiRequest request = context.getRequest(); |
4500 |
14046 |
if (request != null) { |
4501 |
14046 |
contextPath = request.getContextPath(); |
4502 |
|
} |
4503 |
14047 |
if (contextPath == null) { |
4504 |
|
|
4505 |
123 |
contextPath = StringUtils.substringBefore(StringUtils.stripStart(context.getURL().getPath(), "/"), "/"); |
4506 |
|
} |
4507 |
|
} |
4508 |
|
|
4509 |
|
|
4510 |
14043 |
contextPath = StringUtils.strip(contextPath, "/"); |
4511 |
|
|
4512 |
|
|
4513 |
|
|
4514 |
14023 |
return contextPath + "/"; |
4515 |
|
} |
4516 |
|
|
4517 |
|
|
4518 |
|
@since |
4519 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
4520 |
2452 |
public String getURL(EntityReference entityReference, String action, String queryString, String anchor,... |
4521 |
|
XWikiContext context) |
4522 |
|
{ |
4523 |
|
|
4524 |
|
|
4525 |
|
|
4526 |
2451 |
if (EntityType.ATTACHMENT.equals(entityReference.getType())) { |
4527 |
|
|
4528 |
1 |
AttachmentReference attachmentReference = getCurrentAttachmentResolver().resolve(entityReference); |
4529 |
1 |
return getAttachmentURL(attachmentReference, action, queryString, context); |
4530 |
|
} |
4531 |
|
|
4532 |
|
|
4533 |
2450 |
DocumentReference documentReference = getCurrentGetDocumentResolver().resolve(entityReference); |
4534 |
2451 |
return getURL(documentReference, action, queryString, anchor, context); |
4535 |
|
} |
4536 |
|
|
4537 |
|
|
4538 |
|
@since |
4539 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
4540 |
2424 |
public String getURL(EntityReference reference, String action, XWikiContext context)... |
4541 |
|
{ |
4542 |
2424 |
return getURL(reference, action, null, null, context); |
4543 |
|
} |
4544 |
|
|
4545 |
|
|
4546 |
|
@since |
4547 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
4548 |
2425 |
public String getURL(EntityReference reference, XWikiContext context)... |
4549 |
|
{ |
4550 |
2425 |
String action = "view"; |
4551 |
2425 |
if (reference.getType() == EntityType.ATTACHMENT) { |
4552 |
1 |
action = "download"; |
4553 |
|
} |
4554 |
2425 |
return getURL(reference, action, context); |
4555 |
|
} |
4556 |
|
|
4557 |
|
|
4558 |
|
@since |
4559 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 4 |
Complexity Density: 0.4 |
|
4560 |
43998 |
public String getURL(DocumentReference documentReference, String action, String queryString, String anchor,... |
4561 |
|
XWikiContext context) |
4562 |
|
{ |
4563 |
|
|
4564 |
43996 |
String spaces = getLocalStringEntityReferenceSerializer().serialize(documentReference.getLastSpaceReference()); |
4565 |
|
|
4566 |
|
|
4567 |
43997 |
Locale documentLocale = documentReference.getLocale(); |
4568 |
43998 |
String actualQueryString = queryString; |
4569 |
43996 |
if (documentLocale != null && documentLocale != Locale.ROOT) { |
4570 |
91 |
String localeQueryString = "language=" + documentLocale; |
4571 |
91 |
if (StringUtils.isEmpty(queryString)) { |
4572 |
90 |
actualQueryString = localeQueryString; |
4573 |
|
} else { |
4574 |
|
|
4575 |
|
|
4576 |
1 |
actualQueryString += '&' + localeQueryString; |
4577 |
|
} |
4578 |
|
} |
4579 |
|
|
4580 |
43998 |
URL url = context.getURLFactory().createURL(spaces, documentReference.getName(), action, actualQueryString, |
4581 |
|
anchor, documentReference.getWikiReference().getName(), context); |
4582 |
|
|
4583 |
43998 |
return context.getURLFactory().getURL(url, context); |
4584 |
|
} |
4585 |
|
|
4586 |
|
|
4587 |
|
@deprecated@link |
4588 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
4589 |
9977 |
@Deprecated... |
4590 |
|
public String getURL(String fullname, String action, String queryString, String anchor, XWikiContext context) |
4591 |
|
{ |
4592 |
9977 |
return getURL(getCurrentMixedDocumentReferenceResolver().resolve(fullname), action, queryString, anchor, |
4593 |
|
context); |
4594 |
|
} |
4595 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
4596 |
5546 |
public String getURL(String fullname, String action, String querystring, XWikiContext context)... |
4597 |
|
{ |
4598 |
5547 |
return getURL(fullname, action, querystring, null, context); |
4599 |
|
} |
4600 |
|
|
4601 |
|
|
4602 |
|
@since |
4603 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
4604 |
12250 |
public String getURL(DocumentReference reference, String action, XWikiContext context)... |
4605 |
|
{ |
4606 |
12248 |
return getURL(reference, action, null, null, context); |
4607 |
|
} |
4608 |
|
|
4609 |
|
|
4610 |
|
@deprecated@link |
4611 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
4612 |
4430 |
@Deprecated... |
4613 |
|
public String getURL(String fullname, String action, XWikiContext context) |
4614 |
|
{ |
4615 |
4430 |
return getURL(fullname, action, null, null, context); |
4616 |
|
} |
4617 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
4618 |
0 |
public String getExternalURL(String fullname, String action, XWikiContext context) throws XWikiException... |
4619 |
|
{ |
4620 |
0 |
XWikiDocument doc = new XWikiDocument(getCurrentMixedDocumentReferenceResolver().resolve(fullname)); |
4621 |
|
|
4622 |
0 |
URL url = context.getURLFactory().createExternalURL(doc.getSpace(), doc.getName(), action, null, null, |
4623 |
|
doc.getDatabase(), context); |
4624 |
0 |
return url.toString(); |
4625 |
|
} |
4626 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
4627 |
0 |
public String getExternalURL(String fullname, String action, String querystring, XWikiContext context)... |
4628 |
|
throws XWikiException |
4629 |
|
{ |
4630 |
0 |
XWikiDocument doc = new XWikiDocument(getCurrentMixedDocumentReferenceResolver().resolve(fullname)); |
4631 |
|
|
4632 |
0 |
URL url = context.getURLFactory().createExternalURL(doc.getSpace(), doc.getName(), action, querystring, null, |
4633 |
|
doc.getDatabase(), context); |
4634 |
0 |
return url.toString(); |
4635 |
|
} |
4636 |
|
|
4637 |
|
|
4638 |
|
@since |
4639 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
4640 |
317 |
public String getAttachmentURL(AttachmentReference attachmentReference, String action, String queryString,... |
4641 |
|
XWikiContext context) |
4642 |
|
{ |
4643 |
317 |
DocumentReference documentReference = attachmentReference.getDocumentReference(); |
4644 |
317 |
SpaceReference spaceReference = documentReference.getLastSpaceReference(); |
4645 |
317 |
WikiReference wikiReference = spaceReference.getWikiReference(); |
4646 |
|
|
4647 |
|
|
4648 |
|
|
4649 |
317 |
String serializedSpace = getLocalStringEntityReferenceSerializer().serialize(spaceReference); |
4650 |
|
|
4651 |
317 |
URL url = context.getURLFactory().createAttachmentURL(attachmentReference.getName(), serializedSpace, |
4652 |
|
documentReference.getName(), action, queryString, wikiReference.getName(), context); |
4653 |
|
|
4654 |
317 |
return context.getURLFactory().getURL(url, context); |
4655 |
|
} |
4656 |
|
|
4657 |
|
|
4658 |
|
@since |
4659 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
4660 |
280 |
public String getAttachmentURL(AttachmentReference attachmentReference, String queryString, XWikiContext context)... |
4661 |
|
{ |
4662 |
280 |
return getAttachmentURL(attachmentReference, "download", queryString, context); |
4663 |
|
} |
4664 |
|
|
4665 |
|
|
4666 |
|
@since |
4667 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
4668 |
0 |
public String getAttachmentRevisionURL(AttachmentReference attachmentReference, String revision, String queryString,... |
4669 |
|
XWikiContext context) |
4670 |
|
{ |
4671 |
0 |
DocumentReference documentReference = attachmentReference.getDocumentReference(); |
4672 |
0 |
SpaceReference spaceReference = documentReference.getLastSpaceReference(); |
4673 |
0 |
WikiReference wikiReference = spaceReference.getWikiReference(); |
4674 |
|
|
4675 |
|
|
4676 |
|
|
4677 |
0 |
String serializedSpace = getLocalStringEntityReferenceSerializer().serialize(spaceReference); |
4678 |
|
|
4679 |
0 |
URL url = context.getURLFactory().createAttachmentRevisionURL(attachmentReference.getName(), serializedSpace, |
4680 |
|
documentReference.getName(), revision, queryString, wikiReference.getName(), context); |
4681 |
|
|
4682 |
0 |
return context.getURLFactory().getURL(url, context); |
4683 |
|
} |
4684 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
4685 |
4 |
public String getAttachmentURL(String fullname, String filename, XWikiContext context) throws XWikiException... |
4686 |
|
{ |
4687 |
4 |
return getAttachmentURL(fullname, filename, null, context); |
4688 |
|
} |
4689 |
|
|
4690 |
|
|
4691 |
|
@since |
4692 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
4693 |
280 |
public String getAttachmentURL(String fullname, String filename, String queryString, XWikiContext context)... |
4694 |
|
throws XWikiException |
4695 |
|
{ |
4696 |
280 |
AttachmentReference attachmentReference = |
4697 |
|
new AttachmentReference(filename, getCurrentMixedDocumentReferenceResolver().resolve(fullname)); |
4698 |
|
|
4699 |
280 |
return getAttachmentURL(attachmentReference, queryString, context); |
4700 |
|
} |
4701 |
|
|
4702 |
|
|
4703 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
4704 |
0 |
public int getTimeDelta(long time)... |
4705 |
|
{ |
4706 |
0 |
Date ctime = new Date(); |
4707 |
0 |
return (int) (ctime.getTime() - time); |
4708 |
|
} |
4709 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
4710 |
22590 |
public boolean isMultiLingual(XWikiContext context)... |
4711 |
|
{ |
4712 |
22568 |
return "1".equals(getXWikiPreference("multilingual", "0", context)); |
4713 |
|
} |
4714 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
4715 |
32 |
public boolean isLDAP()... |
4716 |
|
{ |
4717 |
32 |
return "1".equals(getConfiguration().getProperty("xwiki.authentication.ldap")); |
4718 |
|
} |
4719 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
4720 |
9499 |
public int checkActive(XWikiContext context) throws XWikiException... |
4721 |
|
{ |
4722 |
9502 |
return checkActive(context.getUser(), context); |
4723 |
|
} |
4724 |
|
|
|
|
| 75% |
Uncovered Elements: 3 (12) |
Complexity: 4 |
Complexity Density: 0.5 |
|
4725 |
9504 |
public int checkActive(String user, XWikiContext context) throws XWikiException... |
4726 |
|
{ |
4727 |
9505 |
int active = 1; |
4728 |
|
|
4729 |
|
|
4730 |
9508 |
if (user.equals(XWikiRightService.GUEST_USER_FULLNAME) |
4731 |
|
|| (user.equals(XWikiRightService.SUPERADMIN_USER_FULLNAME))) { |
4732 |
6195 |
return active; |
4733 |
|
} |
4734 |
|
|
4735 |
3311 |
String checkactivefield = getXWikiPreference("auth_active_check", context); |
4736 |
3311 |
if (checkactivefield.equals("1")) { |
4737 |
0 |
XWikiDocument userdoc = getDocument(user, context); |
4738 |
0 |
active = userdoc.getIntValue("XWiki.XWikiUsers", "active"); |
4739 |
|
} |
4740 |
|
|
4741 |
3311 |
return active; |
4742 |
|
} |
4743 |
|
|
4744 |
|
|
4745 |
|
@since |
4746 |
|
|
|
|
| 53.8% |
Uncovered Elements: 12 (26) |
Complexity: 8 |
Complexity Density: 0.5 |
|
4747 |
10252 |
public DocumentReference getDocumentReference(XWikiRequest request, XWikiContext context)... |
4748 |
|
{ |
4749 |
10252 |
DocumentReference reference; |
4750 |
10243 |
if (context.getMode() == XWikiContext.MODE_PORTLET) { |
4751 |
0 |
if (request.getParameter("topic") != null) { |
4752 |
0 |
reference = getCurrentMixedDocumentReferenceResolver().resolve(request.getParameter("topic")); |
4753 |
|
} else { |
4754 |
|
|
4755 |
0 |
reference = getDefaultDocumentReference().setWikiReference(new WikiReference(context.getWikiId())); |
4756 |
|
} |
4757 |
10237 |
} else if (context.getMode() == XWikiContext.MODE_XMLRPC) { |
4758 |
0 |
reference = new DocumentReference(context.getWikiId(), |
4759 |
|
context.getDoc().getDocumentReference().getLastSpaceReference().getName(), |
4760 |
|
context.getDoc().getDocumentReference().getName()); |
4761 |
|
} else { |
4762 |
10226 |
ResourceReference resourceReference = getResourceReferenceManager().getResourceReference(); |
4763 |
10240 |
if (resourceReference instanceof EntityResourceReference) { |
4764 |
10236 |
EntityResourceReference entityResource = (EntityResourceReference) resourceReference; |
4765 |
10223 |
String action = entityResource.getAction().getActionName(); |
4766 |
10242 |
if ((request.getParameter("topic") != null) && (action.equals("edit") || action.equals("inline"))) { |
4767 |
0 |
reference = getCurrentMixedDocumentReferenceResolver().resolve(request.getParameter("topic")); |
4768 |
|
} else { |
4769 |
10235 |
reference = new DocumentReference( |
4770 |
|
entityResource.getEntityReference().extractReference(EntityType.DOCUMENT)); |
4771 |
|
} |
4772 |
|
} else { |
4773 |
|
|
4774 |
|
|
4775 |
0 |
throw new RuntimeException( |
4776 |
|
String.format("Resource Reference [%s] isn't an Entity Resource Reference!", resourceReference)); |
4777 |
|
} |
4778 |
|
} |
4779 |
|
|
4780 |
10240 |
return reference; |
4781 |
|
} |
4782 |
|
|
4783 |
|
|
4784 |
|
|
4785 |
|
|
4786 |
|
|
4787 |
|
|
4788 |
|
|
4789 |
|
@param |
4790 |
|
@param |
4791 |
|
@return |
4792 |
|
|
|
|
| 46.7% |
Uncovered Elements: 8 (15) |
Complexity: 5 |
Complexity Density: 0.56 |
|
4793 |
118 |
public static String stripSegmentFromPath(String path, String segment)... |
4794 |
|
{ |
4795 |
118 |
if (!path.startsWith(segment)) { |
4796 |
|
|
4797 |
0 |
try { |
4798 |
0 |
segment = URIUtil.encodePath(segment); |
4799 |
|
} catch (URIException e) { |
4800 |
0 |
LOGGER.warn("Invalid path: [" + segment + "]"); |
4801 |
|
} |
4802 |
|
} |
4803 |
118 |
if (!path.startsWith(segment)) { |
4804 |
|
|
4805 |
0 |
segment = segment.replaceAll("-", "%2D"); |
4806 |
|
} |
4807 |
118 |
if (!path.startsWith(segment)) { |
4808 |
|
|
4809 |
0 |
return path.substring(path.indexOf('/', 1)); |
4810 |
|
} |
4811 |
118 |
return path.substring(segment.length()); |
4812 |
|
} |
4813 |
|
|
|
|
| 42.9% |
Uncovered Elements: 40 (70) |
Complexity: 24 |
Complexity Density: 0.5 |
|
4814 |
9516 |
public boolean prepareDocuments(XWikiRequest request, XWikiContext context, VelocityContext vcontext)... |
4815 |
|
throws XWikiException |
4816 |
|
{ |
4817 |
9516 |
XWikiDocument doc; |
4818 |
9514 |
context.getWiki().prepareResources(context); |
4819 |
9513 |
DocumentReference reference = getDocumentReference(request, context); |
4820 |
9503 |
if (context.getAction().equals("register")) { |
4821 |
163 |
setPhonyDocument(reference, context, vcontext); |
4822 |
163 |
doc = context.getDoc(); |
4823 |
|
} else { |
4824 |
9342 |
try { |
4825 |
9321 |
doc = getDocument(reference, context); |
4826 |
|
} catch (XWikiException e) { |
4827 |
0 |
doc = context.getDoc(); |
4828 |
0 |
if (context.getAction().equals("delete")) { |
4829 |
0 |
if (doc == null) { |
4830 |
0 |
setPhonyDocument(reference, context, vcontext); |
4831 |
0 |
doc = context.getDoc(); |
4832 |
|
} |
4833 |
0 |
if (!checkAccess("admin", doc, context)) { |
4834 |
0 |
throw e; |
4835 |
|
} |
4836 |
|
} else { |
4837 |
0 |
throw e; |
4838 |
|
} |
4839 |
|
} |
4840 |
|
} |
4841 |
|
|
4842 |
|
|
4843 |
|
|
4844 |
9509 |
if (checkAccess(context.getAction(), doc, context) == false) { |
4845 |
5 |
Object[] args = { doc.getFullName(), context.getUser() }; |
4846 |
5 |
setPhonyDocument(reference, context, vcontext); |
4847 |
5 |
throw new XWikiException(XWikiException.MODULE_XWIKI_ACCESS, XWikiException.ERROR_XWIKI_ACCESS_DENIED, |
4848 |
|
"Access to document {0} has been denied to user {1}", null, args); |
4849 |
9507 |
} else if (checkActive(context) == 0) { |
4850 |
0 |
boolean allow = false; |
4851 |
0 |
String action = context.getAction(); |
4852 |
|
|
4853 |
|
|
4854 |
|
|
4855 |
|
|
4856 |
|
|
4857 |
0 |
if ((action.equals("skin") && (doc.getSpace().equals("skins") || doc.getSpace().equals("resources"))) |
4858 |
|
|| ((action.equals("skin") || action.equals("download") || action.equals("ssx") || action.equals("jsx")) |
4859 |
|
&& getRightService().hasAccessLevel("view", XWikiRightService.GUEST_USER_FULLNAME, |
4860 |
|
doc.getPrefixedFullName(), context)) |
4861 |
|
|| ((action.equals("view") && doc.getFullName().equals("XWiki.AccountValidation")))) { |
4862 |
0 |
allow = true; |
4863 |
|
} else { |
4864 |
0 |
String allowed = getConfiguration().getProperty("xwiki.inactiveuser.allowedpages", ""); |
4865 |
0 |
if (context.getAction().equals("view") && !allowed.equals("")) { |
4866 |
0 |
String[] allowedList = StringUtils.split(allowed, " ,"); |
4867 |
0 |
for (String element : allowedList) { |
4868 |
0 |
if (element.equals(doc.getFullName())) { |
4869 |
0 |
allow = true; |
4870 |
0 |
break; |
4871 |
|
} |
4872 |
|
} |
4873 |
|
} |
4874 |
|
} |
4875 |
0 |
if (!allow) { |
4876 |
0 |
Object[] args = { context.getUser() }; |
4877 |
0 |
setPhonyDocument(reference, context, vcontext); |
4878 |
0 |
throw new XWikiException(XWikiException.MODULE_XWIKI_USER, XWikiException.ERROR_XWIKI_USER_INACTIVE, |
4879 |
|
"User {0} account is inactive", null, args); |
4880 |
|
} |
4881 |
|
} |
4882 |
|
|
4883 |
9509 |
context.put("doc", doc); |
4884 |
9506 |
context.put("cdoc", doc); |
4885 |
9510 |
vcontext.put("doc", doc.newDocument(context)); |
4886 |
9498 |
vcontext.put("cdoc", vcontext.get("doc")); |
4887 |
9503 |
XWikiDocument tdoc = doc.getTranslatedDocument(context); |
4888 |
9508 |
try { |
4889 |
9510 |
String rev = (String) context.get("rev"); |
4890 |
9501 |
if (StringUtils.isNotEmpty(rev)) { |
4891 |
0 |
tdoc = getDocument(tdoc, rev, context); |
4892 |
|
} |
4893 |
|
} catch (Exception ex) { |
4894 |
|
|
4895 |
|
} |
4896 |
9501 |
context.put("tdoc", tdoc); |
4897 |
9508 |
vcontext.put("tdoc", tdoc.newDocument(context)); |
4898 |
|
|
4899 |
9510 |
return true; |
4900 |
|
} |
4901 |
|
|
4902 |
|
|
4903 |
|
@since |
4904 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
4905 |
168 |
public void setPhonyDocument(DocumentReference reference, XWikiContext context)... |
4906 |
|
{ |
4907 |
168 |
XWikiDocument doc = new XWikiDocument(reference); |
4908 |
168 |
doc.setElements(XWikiDocument.HAS_ATTACHMENTS | XWikiDocument.HAS_OBJECTS); |
4909 |
168 |
doc.setStore(getStore()); |
4910 |
168 |
context.put("doc", doc); |
4911 |
|
} |
4912 |
|
|
4913 |
|
|
4914 |
|
@since |
4915 |
|
@deprecated@link |
4916 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
4917 |
168 |
@Deprecated... |
4918 |
|
public void setPhonyDocument(DocumentReference reference, XWikiContext context, VelocityContext vcontext) |
4919 |
|
{ |
4920 |
168 |
setPhonyDocument(reference, context); |
4921 |
|
|
4922 |
168 |
vcontext.put("doc", context.getDoc().newDocument(context)); |
4923 |
168 |
vcontext.put("cdoc", vcontext.get("doc")); |
4924 |
168 |
vcontext.put("tdoc", vcontext.get("doc")); |
4925 |
|
} |
4926 |
|
|
4927 |
|
|
4928 |
|
@deprecated@link |
4929 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
4930 |
0 |
@Deprecated... |
4931 |
|
public void setPhonyDocument(String docName, XWikiContext context, VelocityContext vcontext) |
4932 |
|
{ |
4933 |
0 |
setPhonyDocument(getCurrentMixedDocumentReferenceResolver().resolve(docName), context, vcontext); |
4934 |
|
} |
4935 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
4936 |
89991 |
public XWikiEngineContext getEngineContext()... |
4937 |
|
{ |
4938 |
89994 |
return this.engine_context; |
4939 |
|
} |
4940 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
4941 |
87 |
public void setEngineContext(XWikiEngineContext engine_context)... |
4942 |
|
{ |
4943 |
87 |
this.engine_context = engine_context; |
4944 |
|
} |
4945 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
4946 |
1 |
public void setAuthService(XWikiAuthService authService)... |
4947 |
|
{ |
4948 |
1 |
this.authService = authService; |
4949 |
|
} |
4950 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
4951 |
20 |
public void setRightService(XWikiRightService rightService)... |
4952 |
|
{ |
4953 |
20 |
this.rightService = rightService; |
4954 |
|
} |
4955 |
|
|
|
|
| 81.8% |
Uncovered Elements: 2 (11) |
Complexity: 3 |
Complexity Density: 0.33 |
|
4956 |
230 |
public XWikiGroupService getGroupService(XWikiContext context) throws XWikiException... |
4957 |
|
{ |
4958 |
230 |
synchronized (this.GROUP_SERVICE_LOCK) { |
4959 |
230 |
if (this.groupService == null) { |
4960 |
50 |
String groupClass = getConfiguration().getProperty("xwiki.authentication.groupclass", |
4961 |
|
"com.xpn.xwiki.user.impl.xwiki.XWikiGroupServiceImpl"); |
4962 |
|
|
4963 |
50 |
try { |
4964 |
50 |
this.groupService = (XWikiGroupService) Class.forName(groupClass).newInstance(); |
4965 |
|
} catch (Exception e) { |
4966 |
0 |
LOGGER.error("Failed to instantiate custom group service class: " + e.getMessage(), e); |
4967 |
0 |
this.groupService = new XWikiGroupServiceImpl(); |
4968 |
|
} |
4969 |
50 |
this.groupService.init(this, context); |
4970 |
|
} |
4971 |
|
|
4972 |
230 |
return this.groupService; |
4973 |
|
} |
4974 |
|
} |
4975 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
4976 |
0 |
public void setGroupService(XWikiGroupService groupService)... |
4977 |
|
{ |
4978 |
0 |
this.groupService = groupService; |
4979 |
|
} |
4980 |
|
|
4981 |
|
|
|
|
| 57.1% |
Uncovered Elements: 18 (42) |
Complexity: 10 |
Complexity Density: 0.38 |
|
4982 |
21823 |
public XWikiAuthService getAuthService()... |
4983 |
|
{ |
4984 |
21826 |
synchronized (this.AUTH_SERVICE_LOCK) { |
4985 |
21834 |
if (this.authService == null) { |
4986 |
|
|
4987 |
32 |
LOGGER.info("Initializing AuthService..."); |
4988 |
|
|
4989 |
32 |
String authClass = getConfiguration().getProperty("xwiki.authentication.authclass"); |
4990 |
32 |
if (StringUtils.isNotEmpty(authClass)) { |
4991 |
0 |
if (LOGGER.isDebugEnabled()) { |
4992 |
0 |
LOGGER.debug("Using custom AuthClass " + authClass + "."); |
4993 |
|
} |
4994 |
|
} else { |
4995 |
32 |
if (isLDAP()) { |
4996 |
0 |
authClass = "com.xpn.xwiki.user.impl.LDAP.XWikiLDAPAuthServiceImpl"; |
4997 |
|
} else { |
4998 |
32 |
authClass = "com.xpn.xwiki.user.impl.xwiki.XWikiAuthServiceImpl"; |
4999 |
|
} |
5000 |
|
|
5001 |
32 |
if (LOGGER.isDebugEnabled()) { |
5002 |
0 |
LOGGER.debug("Using default AuthClass " + authClass + "."); |
5003 |
|
} |
5004 |
|
} |
5005 |
|
|
5006 |
32 |
try { |
5007 |
|
|
5008 |
32 |
@SuppressWarnings("deprecation") |
5009 |
|
ClassLoaderManager clManager = Utils.getComponent(ClassLoaderManager.class); |
5010 |
32 |
ClassLoader classloader = null; |
5011 |
32 |
if (clManager != null) { |
5012 |
32 |
classloader = clManager.getURLClassLoader("wiki:xwiki", false); |
5013 |
|
} |
5014 |
|
|
5015 |
|
|
5016 |
32 |
if (classloader != null) { |
5017 |
32 |
this.authService = (XWikiAuthService) Class.forName(authClass, true, classloader).newInstance(); |
5018 |
|
} else { |
5019 |
0 |
this.authService = (XWikiAuthService) Class.forName(authClass).newInstance(); |
5020 |
|
} |
5021 |
|
|
5022 |
32 |
LOGGER.debug("Initialized AuthService using Relfection."); |
5023 |
|
} catch (Exception e) { |
5024 |
0 |
LOGGER.warn("Failed to initialize AuthService " + authClass |
5025 |
|
+ " using Reflection, trying default implementations using 'new'.", e); |
5026 |
|
|
5027 |
0 |
this.authService = new XWikiAuthServiceImpl(); |
5028 |
|
|
5029 |
0 |
if (LOGGER.isDebugEnabled()) { |
5030 |
0 |
LOGGER.debug( |
5031 |
|
"Initialized AuthService " + this.authService.getClass().getName() + " using 'new'."); |
5032 |
|
} |
5033 |
|
} |
5034 |
|
} |
5035 |
|
|
5036 |
21834 |
return this.authService; |
5037 |
|
} |
5038 |
|
} |
5039 |
|
|
5040 |
|
private static final String DEFAULT_RIGHT_SERVICE_CLASS = |
5041 |
|
"org.xwiki.security.authorization.internal.XWikiCachingRightService"; |
5042 |
|
|
|
|
| 36.6% |
Uncovered Elements: 26 (41) |
Complexity: 11 |
Complexity Density: 0.41 |
|
5043 |
67854 |
public XWikiRightService getRightService()... |
5044 |
|
{ |
5045 |
67851 |
synchronized (this.RIGHT_SERVICE_LOCK) { |
5046 |
67858 |
if (this.rightService == null) { |
5047 |
59 |
LOGGER.info("Initializing RightService..."); |
5048 |
|
|
5049 |
59 |
String rightsClass = getConfiguration().getProperty("xwiki.authentication.rightsclass"); |
5050 |
59 |
if (rightsClass != null && !rightsClass.equals(DEFAULT_RIGHT_SERVICE_CLASS)) { |
5051 |
0 |
if (LOGGER.isDebugEnabled()) { |
5052 |
0 |
LOGGER.warn("Using custom Right Service [{}].", rightsClass); |
5053 |
|
} |
5054 |
|
} else { |
5055 |
59 |
rightsClass = DEFAULT_RIGHT_SERVICE_CLASS; |
5056 |
59 |
if (LOGGER.isDebugEnabled()) { |
5057 |
0 |
LOGGER.debug("Using default Right Service [{}].", rightsClass); |
5058 |
|
} |
5059 |
|
} |
5060 |
|
|
5061 |
59 |
try { |
5062 |
59 |
this.rightService = (XWikiRightService) Class.forName(rightsClass).newInstance(); |
5063 |
59 |
LOGGER.debug("Initialized RightService using Reflection."); |
5064 |
|
} catch (Exception e) { |
5065 |
0 |
Exception lastException = e; |
5066 |
|
|
5067 |
0 |
if (!rightsClass.equals(DEFAULT_RIGHT_SERVICE_CLASS)) { |
5068 |
0 |
LOGGER.warn(String.format( |
5069 |
|
"Failed to initialize custom RightService [%s]" |
5070 |
|
+ " by Reflection, using default implementation [%s].", |
5071 |
|
rightsClass, DEFAULT_RIGHT_SERVICE_CLASS), e); |
5072 |
0 |
rightsClass = DEFAULT_RIGHT_SERVICE_CLASS; |
5073 |
0 |
try { |
5074 |
0 |
this.rightService = (XWikiRightService) Class.forName(rightsClass).newInstance(); |
5075 |
0 |
LOGGER.debug("Initialized default RightService using Reflection."); |
5076 |
|
} catch (Exception e1) { |
5077 |
0 |
lastException = e1; |
5078 |
|
} |
5079 |
|
} |
5080 |
|
|
5081 |
0 |
if (this.rightService == null) { |
5082 |
0 |
LOGGER.warn(String.format( |
5083 |
|
"Failed to initialize RightService [%s]" |
5084 |
|
+ " by Reflection, using OLD implementation [%s] with 'new'.", |
5085 |
|
rightsClass, XWikiRightServiceImpl.class.getCanonicalName()), lastException); |
5086 |
|
|
5087 |
0 |
this.rightService = new XWikiRightServiceImpl(); |
5088 |
|
|
5089 |
0 |
if (LOGGER.isDebugEnabled()) { |
5090 |
0 |
LOGGER.debug("Initialized old RightService implementation " |
5091 |
|
+ this.rightService.getClass().getName() + " using 'new'."); |
5092 |
|
} |
5093 |
|
} |
5094 |
|
} |
5095 |
|
} |
5096 |
67858 |
return this.rightService; |
5097 |
|
} |
5098 |
|
} |
5099 |
|
|
|
|
| 71.4% |
Uncovered Elements: 4 (14) |
Complexity: 4 |
Complexity Density: 0.4 |
|
5100 |
60 |
public XWikiStatsService getStatsService(XWikiContext context)... |
5101 |
|
{ |
5102 |
60 |
synchronized (this.STATS_SERVICE_LOCK) { |
5103 |
60 |
if (this.statsService == null) { |
5104 |
60 |
if ("1".equals(getConfiguration().getProperty("xwiki.stats", "1"))) { |
5105 |
60 |
String storeClass = getConfiguration().getProperty("xwiki.stats.class", |
5106 |
|
"com.xpn.xwiki.stats.impl.XWikiStatsServiceImpl"); |
5107 |
60 |
try { |
5108 |
60 |
this.statsService = (XWikiStatsService) Class.forName(storeClass).newInstance(); |
5109 |
|
} catch (Exception e) { |
5110 |
0 |
LOGGER.error(e.getMessage(), e); |
5111 |
|
|
5112 |
0 |
this.statsService = new XWikiStatsServiceImpl(); |
5113 |
|
} |
5114 |
|
|
5115 |
60 |
this.statsService.init(context); |
5116 |
|
} |
5117 |
|
} |
5118 |
|
|
5119 |
60 |
return this.statsService; |
5120 |
|
} |
5121 |
|
} |
5122 |
|
|
|
|
| 58.1% |
Uncovered Elements: 13 (31) |
Complexity: 8 |
Complexity Density: 0.42 |
|
5123 |
11610 |
public XWikiURLFactoryService getURLFactoryService()... |
5124 |
|
{ |
5125 |
11600 |
if (this.urlFactoryService == null) { |
5126 |
87 |
synchronized (this.URLFACTORY_SERVICE_LOCK) { |
5127 |
87 |
if (this.urlFactoryService == null) { |
5128 |
87 |
LOGGER.info("Initializing URLFactory Service..."); |
5129 |
|
|
5130 |
87 |
XWikiURLFactoryService factoryService = null; |
5131 |
|
|
5132 |
87 |
String urlFactoryServiceClass = getConfiguration().getProperty("xwiki.urlfactory.serviceclass"); |
5133 |
87 |
if (urlFactoryServiceClass != null) { |
5134 |
0 |
try { |
5135 |
0 |
if (LOGGER.isDebugEnabled()) { |
5136 |
0 |
LOGGER.debug("Using custom URLFactory Service Class [" + urlFactoryServiceClass + "]"); |
5137 |
|
} |
5138 |
0 |
factoryService = (XWikiURLFactoryService) Class.forName(urlFactoryServiceClass) |
5139 |
|
.getConstructor(new Class<?>[] { XWiki.class }).newInstance(new Object[] { this }); |
5140 |
|
} catch (Exception e) { |
5141 |
0 |
factoryService = null; |
5142 |
0 |
LOGGER.warn("Failed to initialize URLFactory Service [" + urlFactoryServiceClass + "]", e); |
5143 |
|
} |
5144 |
|
} |
5145 |
87 |
if (factoryService == null) { |
5146 |
87 |
if (LOGGER.isDebugEnabled()) { |
5147 |
0 |
LOGGER.debug("Using default URLFactory Service Class [" + urlFactoryServiceClass + "]"); |
5148 |
|
} |
5149 |
87 |
factoryService = new XWikiURLFactoryServiceImpl(this); |
5150 |
|
} |
5151 |
|
|
5152 |
|
|
5153 |
|
|
5154 |
|
|
5155 |
87 |
this.urlFactoryService = factoryService; |
5156 |
|
} |
5157 |
|
} |
5158 |
|
} |
5159 |
|
|
5160 |
11610 |
return this.urlFactoryService; |
5161 |
|
} |
5162 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
5163 |
14 |
public XWikiCriteriaService getCriteriaService(XWikiContext context)... |
5164 |
|
{ |
5165 |
14 |
return this.criteriaService; |
5166 |
|
} |
5167 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
5168 |
0 |
public ZipOutputStream getZipOutputStream(XWikiContext context) throws IOException... |
5169 |
|
{ |
5170 |
0 |
return new ZipOutputStream(context.getResponse().getOutputStream()); |
5171 |
|
} |
5172 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
5173 |
0 |
private Map<String, SearchEngineRule> getSearchEngineRules(XWikiContext context)... |
5174 |
|
{ |
5175 |
|
|
5176 |
|
|
5177 |
0 |
Map<String, SearchEngineRule> map = new HashMap<String, SearchEngineRule>(); |
5178 |
0 |
map.put("Google", new SearchEngineRule("google.", "s/(^|.*&)q=(.*?)(&.*|$)/$2/")); |
5179 |
0 |
map.put("MSN", new SearchEngineRule("search.msn.", "s/(^|.*&)q=(.*?)(&.*|$)/$2/")); |
5180 |
0 |
map.put("Yahoo", new SearchEngineRule("search.yahoo.", "s/(^|.*&)p=(.*?)(&.*|$)/$2/")); |
5181 |
0 |
map.put("Voila", new SearchEngineRule("voila.fr", "s/(^|.*&)kw=(.*?)(&.*|$)/$2/")); |
5182 |
|
|
5183 |
0 |
return map; |
5184 |
|
} |
5185 |
|
|
|
|
| 0% |
Uncovered Elements: 23 (23) |
Complexity: 7 |
Complexity Density: 0.47 |
|
5186 |
0 |
public String getRefererText(String referer, XWikiContext context)... |
5187 |
|
{ |
5188 |
0 |
try { |
5189 |
0 |
URL url = new URL(referer); |
5190 |
0 |
Map<String, SearchEngineRule> searchengines = getSearchEngineRules(context); |
5191 |
0 |
if (searchengines != null) { |
5192 |
0 |
for (SearchEngineRule senginerule : searchengines.values()) { |
5193 |
0 |
String host = url.getHost(); |
5194 |
0 |
int i1 = host.indexOf(senginerule.getHost()); |
5195 |
0 |
if (i1 != -1) { |
5196 |
0 |
String query = context.getUtil().substitute(senginerule.getRegEx(), url.getQuery()); |
5197 |
0 |
if ((query != null) && (!query.equals(""))) { |
5198 |
|
|
5199 |
0 |
return host.substring(i1) + ":" + query; |
5200 |
|
} |
5201 |
|
} |
5202 |
|
} |
5203 |
|
} |
5204 |
|
} catch (Exception e) { |
5205 |
|
} |
5206 |
|
|
5207 |
0 |
String result = referer.substring(referer.indexOf("://") + 3); |
5208 |
0 |
if (result.endsWith("/")) { |
5209 |
0 |
return result.substring(0, result.length() - 1); |
5210 |
|
} else { |
5211 |
0 |
return result; |
5212 |
|
} |
5213 |
|
} |
5214 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
5215 |
0 |
public boolean isMySQL()... |
5216 |
|
{ |
5217 |
0 |
if (getHibernateStore() == null) { |
5218 |
0 |
return false; |
5219 |
|
} |
5220 |
|
|
5221 |
0 |
Object dialect = getHibernateStore().getConfiguration().getProperties().get("dialect"); |
5222 |
0 |
return "org.hibernate.dialect.MySQLDialect".equals(dialect) |
5223 |
|
|| "net.sf.hibernate.dialect.MySQLDialect".equals(dialect); |
5224 |
|
} |
5225 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
5226 |
0 |
public String getFullNameSQL()... |
5227 |
|
{ |
5228 |
0 |
return getFullNameSQL(true); |
5229 |
|
} |
5230 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 4 |
Complexity Density: 0.57 |
|
5231 |
0 |
public String getFullNameSQL(boolean newFullName)... |
5232 |
|
{ |
5233 |
0 |
if (newFullName) { |
5234 |
0 |
return "doc.fullName"; |
5235 |
|
} |
5236 |
|
|
5237 |
0 |
if (this.fullNameSQL == null) { |
5238 |
0 |
if (isMySQL()) { |
5239 |
0 |
this.fullNameSQL = "CONCAT(doc.space,'.',doc.name)"; |
5240 |
|
} else { |
5241 |
0 |
this.fullNameSQL = "doc.space||'.'||doc.name"; |
5242 |
|
} |
5243 |
|
} |
5244 |
|
|
5245 |
0 |
return this.fullNameSQL; |
5246 |
|
} |
5247 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
5248 |
0 |
public String getUserName(String user, XWikiContext context)... |
5249 |
|
{ |
5250 |
0 |
return getUserName(user, null, true, context); |
5251 |
|
} |
5252 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
5253 |
1157 |
public String getUserName(String user, String format, XWikiContext context)... |
5254 |
|
{ |
5255 |
1157 |
return getUserName(user, format, true, context); |
5256 |
|
} |
5257 |
|
|
5258 |
|
|
5259 |
|
@return |
5260 |
|
|
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
5261 |
5443 |
public String getUserName(String user, String format, boolean link, XWikiContext context)... |
5262 |
|
{ |
5263 |
5441 |
if (StringUtils.isBlank(user)) { |
5264 |
0 |
return localizePlainOrKey("core.users.unknownUser"); |
5265 |
|
} |
5266 |
|
|
5267 |
5442 |
DocumentReference userReference = getCurrentMixedDocumentReferenceResolver().resolve(user); |
5268 |
|
|
5269 |
5443 |
return getUserName(userReference, format, link, true, context); |
5270 |
|
} |
5271 |
|
|
5272 |
|
|
5273 |
|
|
5274 |
|
|
5275 |
|
@param |
5276 |
|
@param |
5277 |
|
@param |
5278 |
|
@param |
5279 |
|
@param@link |
5280 |
|
@return |
5281 |
|
@since |
5282 |
|
|
|
|
| 75% |
Uncovered Elements: 13 (52) |
Complexity: 15 |
Complexity Density: 0.5 |
|
5283 |
7615 |
public String getUserName(DocumentReference userReference, String format, boolean link, boolean escapeXML,... |
5284 |
|
XWikiContext context) |
5285 |
|
{ |
5286 |
7616 |
if (userReference == null) { |
5287 |
94 |
return localizePlainOrKey("core.users.unknownUser"); |
5288 |
|
} |
5289 |
|
|
5290 |
7520 |
XWikiDocument userdoc = null; |
5291 |
7521 |
try { |
5292 |
7522 |
userdoc = getDocument(userReference, context); |
5293 |
7522 |
if (userdoc == null) { |
5294 |
0 |
return escapeXML ? XMLUtils.escape(userReference.getName()) : userReference.getName(); |
5295 |
|
} |
5296 |
|
|
5297 |
7522 |
BaseObject userobj = userdoc.getObject("XWiki.XWikiUsers"); |
5298 |
7522 |
if (userobj == null) { |
5299 |
6167 |
return escapeXML ? XMLUtils.escape(userdoc.getDocumentReference().getName()) |
5300 |
|
: userdoc.getDocumentReference().getName(); |
5301 |
|
} |
5302 |
|
|
5303 |
1355 |
String text; |
5304 |
|
|
5305 |
1355 |
if (format == null) { |
5306 |
1355 |
text = userobj.getStringValue("first_name"); |
5307 |
1355 |
String lastName = userobj.getStringValue("last_name"); |
5308 |
1355 |
if (!text.isEmpty() && !lastName.isEmpty()) { |
5309 |
239 |
text += ' '; |
5310 |
|
} |
5311 |
1355 |
text += userobj.getStringValue("last_name"); |
5312 |
1355 |
if (StringUtils.isBlank(text)) { |
5313 |
1114 |
text = userdoc.getDocumentReference().getName(); |
5314 |
|
} |
5315 |
|
} else { |
5316 |
0 |
VelocityContext vcontext = new VelocityContext(); |
5317 |
0 |
for (String propname : userobj.getPropertyList()) { |
5318 |
0 |
vcontext.put(propname, userobj.getStringValue(propname)); |
5319 |
|
} |
5320 |
0 |
text = evaluateVelocity(format, |
5321 |
|
"<username formatting code in " + context.getDoc().getDocumentReference() + ">", vcontext); |
5322 |
|
} |
5323 |
|
|
5324 |
1355 |
if (escapeXML || link) { |
5325 |
1274 |
text = XMLUtils.escape(text.trim()); |
5326 |
|
} |
5327 |
|
|
5328 |
1355 |
if (link) { |
5329 |
275 |
text = "<span class=\"wikilink\"><a href=\"" + userdoc.getURL("view", context) + "\">" + text |
5330 |
|
+ "</a></span>"; |
5331 |
|
} |
5332 |
1355 |
return text; |
5333 |
|
} catch (Exception e) { |
5334 |
0 |
LOGGER.warn("Failed to display the user name of [{}]. Root cause is [{}]. Falling back on the user id.", |
5335 |
|
userReference, ExceptionUtils.getRootCauseMessage(e)); |
5336 |
|
|
5337 |
0 |
return escapeXML ? XMLUtils.escape(userReference.getName()) : userReference.getName(); |
5338 |
|
} |
5339 |
|
} |
5340 |
|
|
5341 |
|
|
5342 |
|
@param |
5343 |
|
@param |
5344 |
|
@param |
5345 |
|
|
5346 |
|
@return |
5347 |
|
@since |
5348 |
|
|
|
|
| 69.6% |
Uncovered Elements: 7 (23) |
Complexity: 6 |
Complexity Density: 0.35 |
|
5349 |
997 |
public String evaluateVelocity(String content, String namespace, VelocityContext vcontext)... |
5350 |
|
{ |
5351 |
998 |
StringWriter writer = new StringWriter(); |
5352 |
|
|
5353 |
993 |
boolean renderingContextPushed = false; |
5354 |
992 |
try { |
5355 |
|
|
5356 |
994 |
String currentNamespace = getRenderingContext().getTransformationId(); |
5357 |
996 |
if (namespace != null && !StringUtils.equals(namespace, currentNamespace)) { |
5358 |
994 |
if (getRenderingContext() instanceof MutableRenderingContext) { |
5359 |
|
|
5360 |
993 |
((MutableRenderingContext) getRenderingContext()).push(getRenderingContext().getTransformation(), |
5361 |
|
getRenderingContext().getXDOM(), getRenderingContext().getDefaultSyntax(), namespace, |
5362 |
|
getRenderingContext().isRestricted(), getRenderingContext().getTargetSyntax()); |
5363 |
|
|
5364 |
1001 |
renderingContextPushed = true; |
5365 |
|
} |
5366 |
|
} |
5367 |
|
|
5368 |
999 |
VelocityManager velocityManager = Utils.getComponent(VelocityManager.class); |
5369 |
1000 |
velocityManager.getVelocityEngine().evaluate(vcontext, writer, namespace, content); |
5370 |
|
|
5371 |
1001 |
return writer.toString(); |
5372 |
|
} catch (Exception e) { |
5373 |
0 |
LOGGER.error("Error while parsing velocity template namespace [{}] with content:\n[{}]", namespace, content, |
5374 |
|
e); |
5375 |
0 |
Object[] args = { namespace }; |
5376 |
0 |
XWikiException xe = new XWikiException(XWikiException.MODULE_XWIKI_RENDERING, |
5377 |
|
XWikiException.ERROR_XWIKI_RENDERING_VELOCITY_EXCEPTION, "Error while parsing velocity page {0}", e, |
5378 |
|
args); |
5379 |
0 |
return Util.getHTMLExceptionMessage(xe, null); |
5380 |
|
} finally { |
5381 |
|
|
5382 |
1001 |
if (renderingContextPushed) { |
5383 |
1001 |
((MutableRenderingContext) this.renderingContext).pop(); |
5384 |
|
} |
5385 |
|
} |
5386 |
|
} |
5387 |
|
|
5388 |
|
|
5389 |
|
@param |
5390 |
|
@param |
5391 |
|
@return |
5392 |
|
@since |
5393 |
|
|
|
|
| 50% |
Uncovered Elements: 4 (8) |
Complexity: 2 |
Complexity Density: 0.25 |
|
5394 |
1001 |
public String evaluateVelocity(String content, String name)... |
5395 |
|
{ |
5396 |
1001 |
try { |
5397 |
999 |
VelocityManager velocityManager = Utils.getComponent(VelocityManager.class); |
5398 |
1000 |
VelocityContext velocityContext = velocityManager.getVelocityContext(); |
5399 |
996 |
return evaluateVelocity(content, name, velocityContext); |
5400 |
|
} catch (Exception e) { |
5401 |
0 |
LOGGER.error("Error while parsing velocity template namespace [{}] with content:\n[{}]", name, content, e); |
5402 |
0 |
Object[] args = { name }; |
5403 |
0 |
XWikiException xe = new XWikiException(XWikiException.MODULE_XWIKI_RENDERING, |
5404 |
|
XWikiException.ERROR_XWIKI_RENDERING_VELOCITY_EXCEPTION, "Error while parsing velocity page {0}", e, |
5405 |
|
args); |
5406 |
0 |
return Util.getHTMLExceptionMessage(xe, null); |
5407 |
|
} |
5408 |
|
} |
5409 |
|
|
5410 |
|
|
5411 |
|
|
5412 |
|
|
5413 |
|
@param |
5414 |
|
@param@link |
5415 |
|
@return |
5416 |
|
@since |
5417 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
5418 |
2173 |
public String getPlainUserName(DocumentReference userReference, XWikiContext context)... |
5419 |
|
{ |
5420 |
2173 |
return getUserName(userReference, null, false, false, context); |
5421 |
|
} |
5422 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
5423 |
0 |
public boolean hasCentralizedAuthentication(XWikiContext context)... |
5424 |
|
{ |
5425 |
0 |
String bl = getXWikiPreference("authentication_centralized", "", context); |
5426 |
0 |
if ("1".equals(bl)) { |
5427 |
0 |
return true; |
5428 |
|
} |
5429 |
|
|
5430 |
0 |
if ("0".equals(bl)) { |
5431 |
0 |
return false; |
5432 |
|
} |
5433 |
|
|
5434 |
0 |
return "1".equals(getConfiguration().getProperty("xwiki.authentication.centralized", "0")); |
5435 |
|
} |
5436 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
5437 |
0 |
public String getLocalUserName(String user, XWikiContext context)... |
5438 |
|
{ |
5439 |
0 |
if (hasCentralizedAuthentication(context)) { |
5440 |
0 |
return getUserName(user, null, true, context); |
5441 |
|
} else { |
5442 |
0 |
return getUserName(user.substring(user.indexOf(':') + 1), null, true, context); |
5443 |
|
} |
5444 |
|
} |
5445 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
5446 |
0 |
public String getLocalUserName(String user, String format, XWikiContext context)... |
5447 |
|
{ |
5448 |
0 |
if (hasCentralizedAuthentication(context)) { |
5449 |
0 |
return getUserName(user, format, true, context); |
5450 |
|
} else { |
5451 |
0 |
return getUserName(user.substring(user.indexOf(':') + 1), format, true, context); |
5452 |
|
} |
5453 |
|
} |
5454 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
5455 |
0 |
public String getLocalUserName(String user, String format, boolean link, XWikiContext context)... |
5456 |
|
{ |
5457 |
0 |
if (hasCentralizedAuthentication(context)) { |
5458 |
0 |
return getUserName(user, format, link, context); |
5459 |
|
} else { |
5460 |
0 |
return getUserName(user.substring(user.indexOf(':') + 1), format, link, context); |
5461 |
|
} |
5462 |
|
} |
5463 |
|
|
|
|
| 51.3% |
Uncovered Elements: 19 (39) |
Complexity: 11 |
Complexity Density: 0.41 |
|
5464 |
1218 |
public String formatDate(Date date, String format, XWikiContext context)... |
5465 |
|
{ |
5466 |
1218 |
if (date == null) { |
5467 |
0 |
return ""; |
5468 |
|
} |
5469 |
1218 |
String xformat = format; |
5470 |
1218 |
String defaultFormat = "yyyy/MM/dd HH:mm"; |
5471 |
|
|
5472 |
1218 |
if (format == null) { |
5473 |
1042 |
xformat = getXWikiPreference("dateformat", defaultFormat, context); |
5474 |
|
} |
5475 |
|
|
5476 |
1218 |
try { |
5477 |
1218 |
DateFormatSymbols formatSymbols = null; |
5478 |
1218 |
try { |
5479 |
1218 |
String language = getLanguagePreference(context); |
5480 |
1218 |
formatSymbols = new DateFormatSymbols(new Locale(language)); |
5481 |
|
} catch (Exception e2) { |
5482 |
0 |
String language = getXWikiPreference("default_language", context); |
5483 |
0 |
if ((language != null) && (!language.equals(""))) { |
5484 |
0 |
formatSymbols = new DateFormatSymbols(new Locale(language)); |
5485 |
|
} |
5486 |
|
} |
5487 |
|
|
5488 |
1218 |
SimpleDateFormat sdf; |
5489 |
1218 |
if (formatSymbols != null) { |
5490 |
1218 |
sdf = new SimpleDateFormat(xformat, formatSymbols); |
5491 |
|
} else { |
5492 |
0 |
sdf = new SimpleDateFormat(xformat); |
5493 |
|
} |
5494 |
|
|
5495 |
1218 |
try { |
5496 |
1218 |
sdf.setTimeZone(TimeZone.getTimeZone(getUserTimeZone(context))); |
5497 |
|
} catch (Exception e) { |
5498 |
|
} |
5499 |
|
|
5500 |
1218 |
return sdf.format(date); |
5501 |
|
} catch (Exception e) { |
5502 |
0 |
LOGGER.info("Failed to format date [" + date + "] with pattern [" + xformat + "]: " + e.getMessage()); |
5503 |
0 |
if (format == null) { |
5504 |
0 |
if (xformat.equals(defaultFormat)) { |
5505 |
0 |
return date.toString(); |
5506 |
|
} else { |
5507 |
0 |
return formatDate(date, defaultFormat, context); |
5508 |
|
} |
5509 |
|
} else { |
5510 |
0 |
return formatDate(date, null, context); |
5511 |
|
} |
5512 |
|
} |
5513 |
|
} |
5514 |
|
|
5515 |
|
|
5516 |
|
|
5517 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
5518 |
1218 |
public String getUserTimeZone(XWikiContext context)... |
5519 |
|
{ |
5520 |
1218 |
String tz = getUserPreference("timezone", context); |
5521 |
|
|
5522 |
|
|
5523 |
1218 |
if (!ArrayUtils.contains(TimeZone.getAvailableIDs(), tz)) { |
5524 |
1212 |
String defaultTz = TimeZone.getDefault().getID(); |
5525 |
1212 |
return getConfiguration().getProperty("xwiki.timezone", defaultTz); |
5526 |
|
} else { |
5527 |
6 |
return tz; |
5528 |
|
} |
5529 |
|
} |
5530 |
|
|
5531 |
|
|
5532 |
|
@deprecated@link |
5533 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
5534 |
37367 |
@Deprecated... |
5535 |
|
public boolean exists(String fullname, XWikiContext context) |
5536 |
|
{ |
5537 |
37367 |
return exists(getCurrentMixedDocumentReferenceResolver().resolve(fullname), context); |
5538 |
|
} |
5539 |
|
|
|
|
| 85.7% |
Uncovered Elements: 1 (7) |
Complexity: 2 |
Complexity Density: 0.29 |
|
5540 |
54724 |
public boolean exists(DocumentReference documentReference, XWikiContext context)... |
5541 |
|
{ |
5542 |
54723 |
String currentWiki = context.getWikiId(); |
5543 |
|
|
5544 |
54722 |
try { |
5545 |
54723 |
XWikiDocument doc = new XWikiDocument(documentReference, documentReference.getLocale()); |
5546 |
|
|
5547 |
54724 |
context.setWikiId(documentReference.getWikiReference().getName()); |
5548 |
|
|
5549 |
54725 |
return getStore().exists(doc, context); |
5550 |
|
} catch (XWikiException e) { |
5551 |
0 |
return false; |
5552 |
|
} finally { |
5553 |
54725 |
context.setWikiId(currentWiki); |
5554 |
|
} |
5555 |
|
} |
5556 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
5557 |
0 |
public String getAdType(XWikiContext context)... |
5558 |
|
{ |
5559 |
0 |
String adtype = ""; |
5560 |
0 |
XWikiDocument wikiServer = context.getWikiServer(); |
5561 |
0 |
if (wikiServer != null) { |
5562 |
0 |
adtype = wikiServer.getStringValue(VIRTUAL_WIKI_DEFINITION_CLASS_REFERENCE, "adtype"); |
5563 |
|
} |
5564 |
|
|
5565 |
0 |
if (adtype.equals("")) { |
5566 |
0 |
adtype = getConfiguration().getProperty("xwiki.ad.type", ""); |
5567 |
|
} |
5568 |
|
|
5569 |
0 |
return adtype; |
5570 |
|
} |
5571 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.4 |
|
5572 |
0 |
public String getAdClientId(XWikiContext context)... |
5573 |
|
{ |
5574 |
0 |
final String defaultadclientid = "pub-2778691407285481"; |
5575 |
0 |
String adclientid = ""; |
5576 |
0 |
XWikiDocument wikiServer = context.getWikiServer(); |
5577 |
0 |
if (wikiServer != null) { |
5578 |
0 |
adclientid = wikiServer.getStringValue(VIRTUAL_WIKI_DEFINITION_CLASS_REFERENCE, "adclientid"); |
5579 |
|
} |
5580 |
|
|
5581 |
0 |
if (adclientid.equals("")) { |
5582 |
0 |
adclientid = getConfiguration().getProperty("xwiki.ad.clientid", ""); |
5583 |
|
} |
5584 |
|
|
5585 |
0 |
if (adclientid.equals("")) { |
5586 |
0 |
adclientid = defaultadclientid; |
5587 |
|
} |
5588 |
|
|
5589 |
0 |
return adclientid; |
5590 |
|
} |
5591 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
5592 |
85418 |
@Deprecated... |
5593 |
|
public XWikiPluginInterface getPlugin(String name, XWikiContext context) |
5594 |
|
{ |
5595 |
85405 |
XWikiPluginManager plugins = getPluginManager(); |
5596 |
85381 |
Vector<String> pluginlist = plugins.getPlugins(); |
5597 |
78475 |
for (String pluginname : pluginlist) { |
5598 |
247758 |
if (pluginname.equals(name)) { |
5599 |
21955 |
return plugins.getPlugin(pluginname); |
5600 |
|
} |
5601 |
|
} |
5602 |
|
|
5603 |
56539 |
return null; |
5604 |
|
} |
5605 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
5606 |
23875 |
@Deprecated... |
5607 |
|
public Api getPluginApi(String name, XWikiContext context) |
5608 |
|
{ |
5609 |
23875 |
XWikiPluginInterface plugin = getPlugin(name, context); |
5610 |
23875 |
if (plugin != null) { |
5611 |
21953 |
return plugin.getPluginApi(plugin, context); |
5612 |
|
} |
5613 |
|
|
5614 |
1922 |
return null; |
5615 |
|
} |
5616 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
5617 |
0 |
public int getHttpTimeout(XWikiContext context)... |
5618 |
|
{ |
5619 |
0 |
return getConfiguration().getProperty("xwiki.http.timeout", 60000); |
5620 |
|
} |
5621 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
5622 |
0 |
public String getHttpUserAgent(XWikiContext context)... |
5623 |
|
{ |
5624 |
0 |
return getConfiguration().getProperty("xwiki.http.useragent", "XWikiBot/1.0"); |
5625 |
|
} |
5626 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
5627 |
0 |
public String getURLContent(String surl, XWikiContext context) throws IOException... |
5628 |
|
{ |
5629 |
0 |
return getURLContent(surl, getHttpTimeout(context), getHttpUserAgent(context)); |
5630 |
|
} |
5631 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
5632 |
0 |
public String getURLContent(String surl, int timeout, String userAgent) throws IOException... |
5633 |
|
{ |
5634 |
0 |
String content; |
5635 |
0 |
HttpClient client = getHttpClient(timeout, userAgent); |
5636 |
0 |
GetMethod get = new GetMethod(surl); |
5637 |
|
|
5638 |
0 |
try { |
5639 |
0 |
client.executeMethod(get); |
5640 |
0 |
content = get.getResponseBodyAsString(); |
5641 |
|
} finally { |
5642 |
|
|
5643 |
0 |
get.releaseConnection(); |
5644 |
|
} |
5645 |
|
|
5646 |
0 |
return content; |
5647 |
|
} |
5648 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
5649 |
0 |
public String getURLContent(String surl, String username, String password, XWikiContext context) throws IOException... |
5650 |
|
{ |
5651 |
0 |
return getURLContent(surl, username, password, getHttpTimeout(context), getHttpUserAgent(context)); |
5652 |
|
} |
5653 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
5654 |
0 |
public String getURLContent(String surl, String username, String password, int timeout, String userAgent)... |
5655 |
|
throws IOException |
5656 |
|
{ |
5657 |
0 |
HttpClient client = getHttpClient(timeout, userAgent); |
5658 |
|
|
5659 |
|
|
5660 |
|
|
5661 |
|
|
5662 |
0 |
client.getState().setCredentials(new AuthScope(null, -1, null), |
5663 |
|
new UsernamePasswordCredentials(username, password)); |
5664 |
|
|
5665 |
|
|
5666 |
|
|
5667 |
0 |
GetMethod get = new GetMethod(surl); |
5668 |
|
|
5669 |
0 |
try { |
5670 |
|
|
5671 |
|
|
5672 |
|
|
5673 |
|
|
5674 |
|
|
5675 |
0 |
get.setDoAuthentication(true); |
5676 |
|
|
5677 |
|
|
5678 |
0 |
client.executeMethod(get); |
5679 |
|
|
5680 |
|
|
5681 |
0 |
return get.getResponseBodyAsString(); |
5682 |
|
} finally { |
5683 |
|
|
5684 |
0 |
get.releaseConnection(); |
5685 |
|
} |
5686 |
|
} |
5687 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
5688 |
0 |
public byte[] getURLContentAsBytes(String surl, XWikiContext context) throws IOException... |
5689 |
|
{ |
5690 |
0 |
return getURLContentAsBytes(surl, getHttpTimeout(context), getHttpUserAgent(context)); |
5691 |
|
} |
5692 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
5693 |
0 |
public byte[] getURLContentAsBytes(String surl, int timeout, String userAgent) throws IOException... |
5694 |
|
{ |
5695 |
0 |
HttpClient client = getHttpClient(timeout, userAgent); |
5696 |
|
|
5697 |
|
|
5698 |
|
|
5699 |
0 |
GetMethod get = new GetMethod(surl); |
5700 |
|
|
5701 |
0 |
try { |
5702 |
|
|
5703 |
0 |
client.executeMethod(get); |
5704 |
|
|
5705 |
|
|
5706 |
0 |
return get.getResponseBody(); |
5707 |
|
} finally { |
5708 |
|
|
5709 |
0 |
get.releaseConnection(); |
5710 |
|
} |
5711 |
|
} |
5712 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
5713 |
0 |
public byte[] getURLContentAsBytes(String surl, String username, String password, XWikiContext context)... |
5714 |
|
throws IOException |
5715 |
|
{ |
5716 |
0 |
return getURLContentAsBytes(surl, username, password, getHttpTimeout(context), getHttpUserAgent(context)); |
5717 |
|
} |
5718 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
5719 |
0 |
public byte[] getURLContentAsBytes(String surl, String username, String password, int timeout, String userAgent)... |
5720 |
|
throws IOException |
5721 |
|
{ |
5722 |
0 |
HttpClient client = getHttpClient(timeout, userAgent); |
5723 |
|
|
5724 |
|
|
5725 |
|
|
5726 |
|
|
5727 |
0 |
client.getState().setCredentials(new AuthScope(null, -1, null), |
5728 |
|
new UsernamePasswordCredentials(username, password)); |
5729 |
|
|
5730 |
|
|
5731 |
|
|
5732 |
0 |
GetMethod get = new GetMethod(surl); |
5733 |
|
|
5734 |
0 |
try { |
5735 |
|
|
5736 |
|
|
5737 |
|
|
5738 |
|
|
5739 |
|
|
5740 |
0 |
get.setDoAuthentication(true); |
5741 |
|
|
5742 |
|
|
5743 |
0 |
client.executeMethod(get); |
5744 |
|
|
5745 |
|
|
5746 |
0 |
return get.getResponseBody(); |
5747 |
|
} finally { |
5748 |
|
|
5749 |
0 |
get.releaseConnection(); |
5750 |
|
} |
5751 |
|
} |
5752 |
|
|
5753 |
|
|
5754 |
|
|
5755 |
|
|
5756 |
|
|
5757 |
|
|
5758 |
|
@return |
5759 |
|
|
5760 |
|
@throws |
5761 |
|
@deprecated |
5762 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
5763 |
32 |
@Deprecated... |
5764 |
|
public List<String> getSpaces(XWikiContext context) throws XWikiException |
5765 |
|
{ |
5766 |
32 |
try { |
5767 |
32 |
return getStore().getQueryManager().getNamedQuery("getSpaces") |
5768 |
|
.addFilter(Utils.<QueryFilter>getComponent(QueryFilter.class, "hidden")).execute(); |
5769 |
|
} catch (QueryException ex) { |
5770 |
0 |
throw new XWikiException(0, 0, ex.getMessage(), ex); |
5771 |
|
} |
5772 |
|
} |
5773 |
|
|
5774 |
|
|
5775 |
|
|
5776 |
|
|
5777 |
|
@param |
5778 |
|
@return |
5779 |
|
|
5780 |
|
@throws |
5781 |
|
@deprecated |
5782 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
5783 |
0 |
@Deprecated... |
5784 |
|
public List<String> getSpaceDocsName(String spaceReference, XWikiContext context) throws XWikiException |
5785 |
|
{ |
5786 |
0 |
try { |
5787 |
0 |
return getStore().getQueryManager().getNamedQuery("getSpaceDocsName") |
5788 |
|
.addFilter(Utils.<QueryFilter>getComponent(QueryFilter.class, "hidden")) |
5789 |
|
.bindValue("space", spaceReference).execute(); |
5790 |
|
} catch (QueryException ex) { |
5791 |
0 |
throw new XWikiException(0, 0, ex.getMessage(), ex); |
5792 |
|
} |
5793 |
|
} |
5794 |
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 4 |
Complexity Density: 0.36 |
|
5795 |
0 |
public List<String> getIncludedMacros(String defaultSpace, String content, XWikiContext context)... |
5796 |
|
{ |
5797 |
0 |
List<String> list; |
5798 |
|
|
5799 |
0 |
try { |
5800 |
0 |
String pattern = "#includeMacros[ ]*\\([ ]*([\"'])(.*?)\\1[ ]*\\)"; |
5801 |
0 |
list = context.getUtil().getUniqueMatches(content, pattern, 2); |
5802 |
0 |
for (int i = 0; i < list.size(); i++) { |
5803 |
0 |
String name = list.get(i); |
5804 |
0 |
if (name.indexOf('.') == -1) { |
5805 |
0 |
list.set(i, defaultSpace + "." + name); |
5806 |
|
} |
5807 |
|
} |
5808 |
|
} catch (Exception e) { |
5809 |
|
|
5810 |
0 |
LOGGER.error("Failed to extract #includeMacros targets from provided content [" + content + "]", e); |
5811 |
|
|
5812 |
0 |
list = Collections.emptyList(); |
5813 |
|
} |
5814 |
|
|
5815 |
0 |
return list; |
5816 |
|
} |
5817 |
|
|
5818 |
|
|
5819 |
|
|
5820 |
|
|
5821 |
|
@see |
5822 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
5823 |
24046 |
public boolean isReadOnly()... |
5824 |
|
{ |
5825 |
24046 |
return this.isReadOnly; |
5826 |
|
} |
5827 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
5828 |
0 |
public void setReadOnly(boolean readOnly)... |
5829 |
|
{ |
5830 |
0 |
this.isReadOnly = readOnly; |
5831 |
|
} |
5832 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
5833 |
25 |
public void deleteAllDocuments(XWikiDocument doc, XWikiContext context) throws XWikiException... |
5834 |
|
{ |
5835 |
25 |
deleteAllDocuments(doc, true, context); |
5836 |
|
} |
5837 |
|
|
|
|
| 50% |
Uncovered Elements: 2 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
5838 |
26 |
public void deleteAllDocuments(XWikiDocument doc, boolean toTrash, XWikiContext context) throws XWikiException... |
5839 |
|
{ |
5840 |
|
|
5841 |
26 |
for (Locale locale : doc.getTranslationLocales(context)) { |
5842 |
0 |
XWikiDocument tdoc = doc.getTranslatedDocument(locale, context); |
5843 |
0 |
deleteDocument(tdoc, toTrash, context); |
5844 |
|
} |
5845 |
|
|
5846 |
|
|
5847 |
26 |
deleteDocument(doc, toTrash, context); |
5848 |
|
} |
5849 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 3 |
Complexity Density: 0.5 |
|
5850 |
0 |
public void refreshLinks(XWikiContext context) throws XWikiException... |
5851 |
|
{ |
5852 |
0 |
try { |
5853 |
|
|
5854 |
0 |
@SuppressWarnings("deprecation") |
5855 |
|
List<String> docs = getStore().getQueryManager().getNamedQuery("getAllDocuments") |
5856 |
|
.addFilter(Utils.<QueryFilter>getComponent(QueryFilter.class, "hidden")).execute(); |
5857 |
0 |
for (int i = 0; i < docs.size(); i++) { |
5858 |
0 |
XWikiDocument myDoc = this.getDocument(docs.get(i), context); |
5859 |
0 |
myDoc.getStore().saveLinks(myDoc, context, true); |
5860 |
|
} |
5861 |
|
} catch (QueryException ex) { |
5862 |
0 |
throw new XWikiException(0, 0, ex.getMessage(), ex); |
5863 |
|
} |
5864 |
|
} |
5865 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
5866 |
3958 |
public boolean hasBacklinks(XWikiContext context)... |
5867 |
|
{ |
5868 |
3958 |
if (this.hasBacklinks == null) { |
5869 |
60 |
this.hasBacklinks = "1".equals(getXWikiPreference("backlinks", "xwiki.backlinks", "0", context)); |
5870 |
|
} |
5871 |
3958 |
return this.hasBacklinks; |
5872 |
|
} |
5873 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
5874 |
0 |
public boolean hasTags(XWikiContext context)... |
5875 |
|
{ |
5876 |
0 |
return "1".equals(getXWikiPreference("tags", "xwiki.tags", "0", context)); |
5877 |
|
} |
5878 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
5879 |
330 |
public boolean hasCustomMappings()... |
5880 |
|
{ |
5881 |
330 |
return "1".equals(getConfiguration().getProperty("xwiki.store.hibernate.custommapping", "1")); |
5882 |
|
} |
5883 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
5884 |
15031 |
public boolean hasDynamicCustomMappings()... |
5885 |
|
{ |
5886 |
15032 |
return "1".equals(getConfiguration().getProperty("xwiki.store.hibernate.custommapping.dynamic", "0")); |
5887 |
|
} |
5888 |
|
|
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
5889 |
36 |
public String getDefaultSpace(XWikiContext context)... |
5890 |
|
{ |
5891 |
36 |
String defaultSpace = getXWikiPreference("defaultweb", "", context); |
5892 |
36 |
if (StringUtils.isEmpty(defaultSpace)) { |
5893 |
36 |
return getConfiguration().getProperty("xwiki.defaultweb", DEFAULT_HOME_SPACE); |
5894 |
|
} |
5895 |
0 |
return defaultSpace; |
5896 |
|
} |
5897 |
|
|
|
|
| 60% |
Uncovered Elements: 4 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
5898 |
111220 |
public boolean showViewAction(XWikiContext context)... |
5899 |
|
{ |
5900 |
111221 |
String bl = getXWikiPreference("showviewaction", "", context); |
5901 |
111221 |
if ("1".equals(bl)) { |
5902 |
0 |
return true; |
5903 |
111221 |
} else if ("0".equals(bl)) { |
5904 |
0 |
return false; |
5905 |
|
} |
5906 |
|
|
5907 |
111221 |
return "1".equals(getConfiguration().getProperty("xwiki.showviewaction", "1")); |
5908 |
|
} |
5909 |
|
|
|
|
| 60% |
Uncovered Elements: 4 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
5910 |
97961 |
public boolean useDefaultAction(XWikiContext context)... |
5911 |
|
{ |
5912 |
97964 |
String bl = getXWikiPreference("usedefaultaction", "", context); |
5913 |
97968 |
if ("1".equals(bl)) { |
5914 |
0 |
return true; |
5915 |
|
} |
5916 |
|
|
5917 |
97968 |
if ("0".equals(bl)) { |
5918 |
0 |
return false; |
5919 |
|
} |
5920 |
|
|
5921 |
97968 |
return "1".equals(getConfiguration().getProperty("xwiki.usedefaultaction", "0")); |
5922 |
|
} |
5923 |
|
|
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
5924 |
98002 |
public String getDefaultPage(XWikiContext context)... |
5925 |
|
{ |
5926 |
98002 |
String defaultPage = getXWikiPreference("defaultpage", "", context); |
5927 |
98003 |
if (StringUtils.isEmpty(defaultPage)) { |
5928 |
98002 |
return getConfiguration().getProperty("xwiki.defaultpage", DEFAULT_SPACE_HOMEPAGE); |
5929 |
|
} |
5930 |
0 |
return defaultPage; |
5931 |
|
} |
5932 |
|
|
|
|
| 60% |
Uncovered Elements: 4 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
5933 |
118 |
public boolean hasEditComment(XWikiContext context)... |
5934 |
|
{ |
5935 |
118 |
String bl = getXWikiPreference("editcomment", "", context); |
5936 |
118 |
if ("1".equals(bl)) { |
5937 |
0 |
return true; |
5938 |
|
} |
5939 |
|
|
5940 |
118 |
if ("0".equals(bl)) { |
5941 |
0 |
return false; |
5942 |
|
} |
5943 |
|
|
5944 |
118 |
return "1".equals(getConfiguration().getProperty("xwiki.editcomment", "0")); |
5945 |
|
} |
5946 |
|
|
|
|
| 60% |
Uncovered Elements: 4 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
5947 |
100 |
public boolean isEditCommentFieldHidden(XWikiContext context)... |
5948 |
|
{ |
5949 |
100 |
String bl = getXWikiPreference("editcomment_hidden", "", context); |
5950 |
100 |
if ("1".equals(bl)) { |
5951 |
0 |
return true; |
5952 |
|
} |
5953 |
|
|
5954 |
100 |
if ("0".equals(bl)) { |
5955 |
0 |
return false; |
5956 |
|
} |
5957 |
|
|
5958 |
100 |
return "1".equals(getConfiguration().getProperty("xwiki.editcomment.hidden", "0")); |
5959 |
|
} |
5960 |
|
|
|
|
| 60% |
Uncovered Elements: 4 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
5961 |
34 |
public boolean isEditCommentSuggested(XWikiContext context)... |
5962 |
|
{ |
5963 |
34 |
String bl = getXWikiPreference("editcomment_suggested", "", context); |
5964 |
34 |
if ("1".equals(bl)) { |
5965 |
0 |
return true; |
5966 |
|
} |
5967 |
|
|
5968 |
34 |
if ("0".equals(bl)) { |
5969 |
0 |
return false; |
5970 |
|
} |
5971 |
|
|
5972 |
34 |
return "1".equals(getConfiguration().getProperty("xwiki.editcomment.suggested", "0")); |
5973 |
|
} |
5974 |
|
|
|
|
| 60% |
Uncovered Elements: 4 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
5975 |
68 |
public boolean isEditCommentMandatory(XWikiContext context)... |
5976 |
|
{ |
5977 |
68 |
String bl = getXWikiPreference("editcomment_mandatory", "", context); |
5978 |
68 |
if ("1".equals(bl)) { |
5979 |
0 |
return true; |
5980 |
|
} |
5981 |
|
|
5982 |
68 |
if ("0".equals(bl)) { |
5983 |
0 |
return false; |
5984 |
|
} |
5985 |
|
|
5986 |
68 |
return "1".equals(getConfiguration().getProperty("xwiki.editcomment.mandatory", "0")); |
5987 |
|
} |
5988 |
|
|
5989 |
|
|
5990 |
|
@see |
5991 |
|
|
|
|
| 60% |
Uncovered Elements: 4 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
5992 |
59 |
public boolean hasMinorEdit(XWikiContext context)... |
5993 |
|
{ |
5994 |
59 |
String bl = getXWikiPreference("minoredit", "", context); |
5995 |
59 |
if ("1".equals(bl)) { |
5996 |
0 |
return true; |
5997 |
|
} |
5998 |
|
|
5999 |
59 |
if ("0".equals(bl)) { |
6000 |
0 |
return false; |
6001 |
|
} |
6002 |
|
|
6003 |
59 |
return "1".equals(getConfiguration().getProperty("xwiki.minoredit", "1")); |
6004 |
|
} |
6005 |
|
|
6006 |
|
|
6007 |
|
@see |
6008 |
|
@param@link |
6009 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
6010 |
569 |
public boolean hasRecycleBin(XWikiContext context)... |
6011 |
|
{ |
6012 |
570 |
return "1".equals(getConfiguration().getProperty("xwiki.recyclebin", "1")); |
6013 |
|
} |
6014 |
|
|
6015 |
|
|
6016 |
|
|
6017 |
|
|
6018 |
|
|
6019 |
|
@param@link |
6020 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
6021 |
3987 |
public boolean hasAttachmentRecycleBin(XWikiContext context)... |
6022 |
|
{ |
6023 |
3987 |
return "1".equals(getConfiguration().getProperty("storage.attachment.recyclebin", "1")); |
6024 |
|
} |
6025 |
|
|
6026 |
|
|
6027 |
|
@deprecated@link |
6028 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
6029 |
0 |
@Deprecated... |
6030 |
|
public XWikiDocument renamePage(XWikiDocument doc, String newFullName, XWikiContext context) throws XWikiException |
6031 |
|
{ |
6032 |
0 |
if (context.getWiki().exists(newFullName, context)) { |
6033 |
0 |
XWikiDocument delDoc = context.getWiki().getDocument(newFullName, context); |
6034 |
0 |
context.getWiki().deleteDocument(delDoc, context); |
6035 |
|
} |
6036 |
|
|
6037 |
0 |
XWikiDocument renamedDoc = doc.copyDocument(newFullName, context); |
6038 |
0 |
saveDocument(renamedDoc, context); |
6039 |
0 |
renamedDoc.saveAllAttachments(context); |
6040 |
0 |
deleteDocument(doc, context); |
6041 |
|
|
6042 |
0 |
return renamedDoc; |
6043 |
|
} |
6044 |
|
|
6045 |
|
|
6046 |
|
@deprecated@link |
6047 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
6048 |
0 |
@Deprecated... |
6049 |
|
public XWikiDocument renamePage(XWikiDocument doc, XWikiContext context, String newFullName) throws XWikiException |
6050 |
|
{ |
6051 |
0 |
return renamePage(doc, newFullName, context); |
6052 |
|
} |
6053 |
|
|
6054 |
|
|
6055 |
|
@since |
6056 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
6057 |
45895 |
public BaseClass getXClass(DocumentReference documentReference, XWikiContext context) throws XWikiException... |
6058 |
|
{ |
6059 |
|
|
6060 |
45895 |
BaseClass bclass = context.getBaseClass(documentReference); |
6061 |
45885 |
if (bclass != null) { |
6062 |
5005 |
return bclass; |
6063 |
|
} |
6064 |
|
|
6065 |
40880 |
return getDocument(documentReference, context).getXClass(); |
6066 |
|
} |
6067 |
|
|
6068 |
|
|
6069 |
|
@deprecated@link |
6070 |
|
|
|
|
| 83.3% |
Uncovered Elements: 1 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
6071 |
275 |
@Deprecated... |
6072 |
|
public BaseClass getClass(String fullName, XWikiContext context) throws XWikiException |
6073 |
|
{ |
6074 |
275 |
DocumentReference reference = null; |
6075 |
275 |
if (StringUtils.isNotEmpty(fullName)) { |
6076 |
275 |
reference = getCurrentMixedDocumentReferenceResolver().resolve(fullName); |
6077 |
|
} |
6078 |
275 |
return getXClass(reference, context); |
6079 |
|
} |
6080 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
6081 |
92 |
public String getEditorPreference(XWikiContext context)... |
6082 |
|
{ |
6083 |
92 |
String defaultSyntaxContentEditor = getEditConfiguration().getDefaultEditor(SyntaxContent.class); |
6084 |
|
|
6085 |
92 |
return defaultSyntaxContentEditor == null ? "" : defaultSyntaxContentEditor.toLowerCase(); |
6086 |
|
} |
6087 |
|
|
6088 |
|
|
6089 |
|
|
6090 |
|
|
6091 |
|
|
6092 |
|
@param |
6093 |
|
@return |
6094 |
|
@throws |
6095 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
6096 |
0 |
public Object parseGroovyFromString(String script, XWikiContext xcontext) throws XWikiException... |
6097 |
|
{ |
6098 |
0 |
return getParseGroovyFromString().parseGroovyFromString(script, xcontext); |
6099 |
|
} |
6100 |
|
|
6101 |
|
|
6102 |
|
|
6103 |
|
|
6104 |
|
|
6105 |
|
@param |
6106 |
|
@return |
6107 |
|
@throws |
6108 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
6109 |
0 |
public Object parseGroovyFromString(String script, String jarWikiPage, XWikiContext xcontext) throws XWikiException... |
6110 |
|
{ |
6111 |
0 |
XWikiPageClassLoader pcl = new XWikiPageClassLoader(jarWikiPage, xcontext); |
6112 |
0 |
Object prevParentClassLoader = xcontext.get("parentclassloader"); |
6113 |
0 |
try { |
6114 |
0 |
xcontext.put("parentclassloader", pcl); |
6115 |
|
|
6116 |
0 |
return parseGroovyFromString(script, xcontext); |
6117 |
|
} finally { |
6118 |
0 |
if (prevParentClassLoader == null) { |
6119 |
0 |
xcontext.remove("parentclassloader"); |
6120 |
|
} else { |
6121 |
0 |
xcontext.put("parentclassloader", prevParentClassLoader); |
6122 |
|
} |
6123 |
|
} |
6124 |
|
} |
6125 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
6126 |
0 |
public Object parseGroovyFromPage(String fullname, XWikiContext context) throws XWikiException... |
6127 |
|
{ |
6128 |
0 |
return parseGroovyFromString(context.getWiki().getDocument(fullname, context).getContent(), context); |
6129 |
|
} |
6130 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
6131 |
0 |
public Object parseGroovyFromPage(String fullName, String jarWikiPage, XWikiContext context) throws XWikiException... |
6132 |
|
{ |
6133 |
0 |
return parseGroovyFromString(context.getWiki().getDocument(fullName, context).getContent(), jarWikiPage, |
6134 |
|
context); |
6135 |
|
} |
6136 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.33 |
|
6137 |
0 |
public String getMacroList(XWikiContext context)... |
6138 |
|
{ |
6139 |
0 |
String macrosmapping = ""; |
6140 |
0 |
XWiki xwiki = context.getWiki(); |
6141 |
|
|
6142 |
0 |
try { |
6143 |
0 |
macrosmapping = getResourceContent(MACROS_FILE); |
6144 |
|
} catch (IOException e) { |
6145 |
|
} |
6146 |
|
|
6147 |
0 |
macrosmapping += "\r\n" + xwiki.getXWikiPreference("macros_mapping", "", context); |
6148 |
|
|
6149 |
0 |
return macrosmapping; |
6150 |
|
} |
6151 |
|
|
6152 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
6153 |
0 |
public BaseObject getObjectFromRequest(String className, XWikiContext context) throws XWikiException... |
6154 |
|
{ |
6155 |
0 |
Map<String, String[]> map = Util.getObject(context.getRequest(), className); |
6156 |
0 |
BaseClass bclass = context.getWiki().getClass(className, context); |
6157 |
0 |
BaseObject newobject = (BaseObject) bclass.fromMap(map, context); |
6158 |
|
|
6159 |
0 |
return newobject; |
6160 |
|
} |
6161 |
|
|
|
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
6162 |
12742 |
public String getConvertingUserNameType(XWikiContext context)... |
6163 |
|
{ |
6164 |
12742 |
if (StringUtils.isNotBlank(context.getWiki().getXWikiPreference("convertmail", context))) { |
6165 |
0 |
return context.getWiki().getXWikiPreference("convertmail", "0", context); |
6166 |
|
} |
6167 |
|
|
6168 |
12742 |
return getConfiguration().getProperty("xwiki.authentication.convertemail", "0"); |
6169 |
|
} |
6170 |
|
|
|
|
| 45% |
Uncovered Elements: 11 (20) |
Complexity: 6 |
Complexity Density: 0.5 |
|
6171 |
8795 |
public String convertUsername(String username, XWikiContext context)... |
6172 |
|
{ |
6173 |
8792 |
if (username == null) { |
6174 |
2424 |
return null; |
6175 |
|
} |
6176 |
|
|
6177 |
6371 |
if (getConvertingUserNameType(context).equals("1") && (username.indexOf('@') != -1)) { |
6178 |
0 |
String id = "" + username.hashCode(); |
6179 |
0 |
id = id.replace("-", ""); |
6180 |
0 |
if (username.length() > 1) { |
6181 |
0 |
int i1 = username.indexOf('@'); |
6182 |
0 |
id = "" + username.charAt(0) + username.substring(i1 + 1, i1 + 2) |
6183 |
|
+ username.charAt(username.length() - 1) + id; |
6184 |
|
} |
6185 |
|
|
6186 |
0 |
return id; |
6187 |
6371 |
} else if (getConvertingUserNameType(context).equals("2")) { |
6188 |
0 |
return username.replaceAll("[\\.\\@]", "_"); |
6189 |
|
} else { |
6190 |
6371 |
return username; |
6191 |
|
} |
6192 |
|
} |
6193 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
6194 |
176 |
public boolean hasSectionEdit(XWikiContext context)... |
6195 |
|
{ |
6196 |
176 |
return getConfiguration().getProperty("xwiki.section.edit", 0) == 1; |
6197 |
|
} |
6198 |
|
|
6199 |
|
|
6200 |
|
@return |
6201 |
|
|
6202 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
6203 |
47 |
public long getSectionEditingDepth()... |
6204 |
|
{ |
6205 |
47 |
return getConfiguration().getProperty("xwiki.section.depth", 2L); |
6206 |
|
} |
6207 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
6208 |
0 |
public String getWysiwygToolbars(XWikiContext context)... |
6209 |
|
{ |
6210 |
0 |
return getConfiguration().getProperty("xwiki.wysiwyg.toolbars", ""); |
6211 |
|
} |
6212 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
6213 |
36 |
public String clearName(String name, XWikiContext context)... |
6214 |
|
{ |
6215 |
36 |
return clearName(name, true, true, context); |
6216 |
|
} |
6217 |
|
|
|
|
| 96.8% |
Uncovered Elements: 2 (63) |
Complexity: 4 |
Complexity Density: 0.07 |
|
6218 |
40 |
public String clearName(String name, boolean stripDots, boolean ascii, XWikiContext context)... |
6219 |
|
{ |
6220 |
40 |
String temp = name; |
6221 |
40 |
temp = temp.replaceAll( |
6222 |
|
"[\u00c0\u00c1\u00c2\u00c3\u00c4\u00c5\u0100\u0102\u0104\u01cd\u01de\u01e0\u01fa\u0200\u0202\u0226]", "A"); |
6223 |
40 |
temp = temp.replaceAll( |
6224 |
|
"[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5\u0101\u0103\u0105\u01ce\u01df\u01e1\u01fb\u0201\u0203\u0227]", "a"); |
6225 |
40 |
temp = temp.replaceAll("[\u00c6\u01e2\u01fc]", "AE"); |
6226 |
40 |
temp = temp.replaceAll("[\u00e6\u01e3\u01fd]", "ae"); |
6227 |
40 |
temp = temp.replaceAll("[\u008c\u0152]", "OE"); |
6228 |
40 |
temp = temp.replaceAll("[\u009c\u0153]", "oe"); |
6229 |
40 |
temp = temp.replaceAll("[\u00c7\u0106\u0108\u010a\u010c]", "C"); |
6230 |
40 |
temp = temp.replaceAll("[\u00e7\u0107\u0109\u010b\u010d]", "c"); |
6231 |
40 |
temp = temp.replaceAll("[\u00d0\u010e\u0110]", "D"); |
6232 |
40 |
temp = temp.replaceAll("[\u00f0\u010f\u0111]", "d"); |
6233 |
40 |
temp = temp.replaceAll("[\u00c8\u00c9\u00ca\u00cb\u0112\u0114\u0116\u0118\u011a\u0204\u0206\u0228]", "E"); |
6234 |
40 |
temp = temp.replaceAll("[\u00e8\u00e9\u00ea\u00eb\u0113\u0115\u0117\u0119\u011b\u01dd\u0205\u0207\u0229]", "e"); |
6235 |
40 |
temp = temp.replaceAll("[\u011c\u011e\u0120\u0122\u01e4\u01e6\u01f4]", "G"); |
6236 |
40 |
temp = temp.replaceAll("[\u011d\u011f\u0121\u0123\u01e5\u01e7\u01f5]", "g"); |
6237 |
40 |
temp = temp.replaceAll("[\u0124\u0126\u021e]", "H"); |
6238 |
40 |
temp = temp.replaceAll("[\u0125\u0127\u021f]", "h"); |
6239 |
40 |
temp = temp.replaceAll("[\u00cc\u00cd\u00ce\u00cf\u0128\u012a\u012c\u012e\u0130\u01cf\u0208\u020a]", "I"); |
6240 |
40 |
temp = temp.replaceAll("[\u00ec\u00ed\u00ee\u00ef\u0129\u012b\u012d\u012f\u0131\u01d0\u0209\u020b]", "i"); |
6241 |
40 |
temp = temp.replaceAll("[\u0132]", "IJ"); |
6242 |
40 |
temp = temp.replaceAll("[\u0133]", "ij"); |
6243 |
40 |
temp = temp.replaceAll("[\u0134]", "J"); |
6244 |
40 |
temp = temp.replaceAll("[\u0135]", "j"); |
6245 |
40 |
temp = temp.replaceAll("[\u0136\u01e8]", "K"); |
6246 |
40 |
temp = temp.replaceAll("[\u0137\u0138\u01e9]", "k"); |
6247 |
40 |
temp = temp.replaceAll("[\u0139\u013b\u013d\u013f\u0141]", "L"); |
6248 |
40 |
temp = temp.replaceAll("[\u013a\u013c\u013e\u0140\u0142\u0234]", "l"); |
6249 |
40 |
temp = temp.replaceAll("[\u00d1\u0143\u0145\u0147\u014a\u01f8]", "N"); |
6250 |
40 |
temp = temp.replaceAll("[\u00f1\u0144\u0146\u0148\u0149\u014b\u01f9\u0235]", "n"); |
6251 |
40 |
temp = temp.replaceAll( |
6252 |
|
"[\u00d2\u00d3\u00d4\u00d5\u00d6\u00d8\u014c\u014e\u0150\u01d1\u01ea\u01ec\u01fe\u020c\u020e\u022a\u022c" |
6253 |
|
+ "\u022e\u0230]", |
6254 |
|
"O"); |
6255 |
40 |
temp = temp.replaceAll( |
6256 |
|
"[\u00f2\u00f3\u00f4\u00f5\u00f6\u00f8\u014d\u014f\u0151\u01d2\u01eb\u01ed\u01ff\u020d\u020f\u022b\u022d" |
6257 |
|
+ "\u022f\u0231]", |
6258 |
|
"o"); |
6259 |
40 |
temp = temp.replaceAll("[\u0156\u0158\u0210\u0212]", "R"); |
6260 |
40 |
temp = temp.replaceAll("[\u0157\u0159\u0211\u0213]", "r"); |
6261 |
40 |
temp = temp.replaceAll("[\u015a\u015c\u015e\u0160\u0218]", "S"); |
6262 |
40 |
temp = temp.replaceAll("[\u015b\u015d\u015f\u0161\u0219]", "s"); |
6263 |
40 |
temp = temp.replaceAll("[\u00de\u0162\u0164\u0166\u021a]", "T"); |
6264 |
40 |
temp = temp.replaceAll("[\u00fe\u0163\u0165\u0167\u021b\u0236]", "t"); |
6265 |
40 |
temp = temp.replaceAll( |
6266 |
|
"[\u00d9\u00da\u00db\u00dc\u0168\u016a\u016c\u016e\u0170\u0172\u01d3\u01d5\u01d7\u01d9\u01db\u0214\u0216]", |
6267 |
|
"U"); |
6268 |
40 |
temp = temp.replaceAll( |
6269 |
|
"[\u00f9\u00fa\u00fb\u00fc\u0169\u016b\u016d\u016f\u0171\u0173\u01d4\u01d6\u01d8\u01da\u01dc\u0215\u0217]", |
6270 |
|
"u"); |
6271 |
40 |
temp = temp.replaceAll("[\u0174]", "W"); |
6272 |
40 |
temp = temp.replaceAll("[\u0175]", "w"); |
6273 |
40 |
temp = temp.replaceAll("[\u00dd\u0176\u0178\u0232]", "Y"); |
6274 |
40 |
temp = temp.replaceAll("[\u00fd\u00ff\u0177\u0233]", "y"); |
6275 |
40 |
temp = temp.replaceAll("[\u0179\u017b\u017d]", "Z"); |
6276 |
40 |
temp = temp.replaceAll("[\u017a\u017c\u017e]", "z"); |
6277 |
40 |
temp = temp.replaceAll("[\u00df]", "SS"); |
6278 |
40 |
temp = temp.replaceAll("[_':,;\\\\/]", " "); |
6279 |
40 |
name = temp; |
6280 |
40 |
name = name.replaceAll("\\s+", ""); |
6281 |
40 |
name = name.replaceAll("[\\(\\)]", " "); |
6282 |
|
|
6283 |
40 |
if (stripDots) { |
6284 |
38 |
name = name.replaceAll("[\\.]", ""); |
6285 |
|
} |
6286 |
|
|
6287 |
40 |
if (ascii) { |
6288 |
38 |
name = name.replaceAll("[^a-zA-Z0-9\\-_\\.]", ""); |
6289 |
|
} |
6290 |
|
|
6291 |
40 |
if (name.length() > 250) { |
6292 |
0 |
name = name.substring(0, 250); |
6293 |
|
} |
6294 |
|
|
6295 |
40 |
return name; |
6296 |
|
|
6297 |
|
} |
6298 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
6299 |
36 |
public String getUniquePageName(String space, XWikiContext context)... |
6300 |
|
{ |
6301 |
36 |
String pageName = generateRandomString(16); |
6302 |
|
|
6303 |
36 |
return getUniquePageName(space, pageName, context); |
6304 |
|
} |
6305 |
|
|
|
|
| 36.4% |
Uncovered Elements: 7 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
6306 |
36 |
public String getUniquePageName(String space, String name, XWikiContext context)... |
6307 |
|
{ |
6308 |
36 |
String pageName = clearName(name, context); |
6309 |
36 |
if (exists(space + "." + pageName, context)) { |
6310 |
0 |
int i = 0; |
6311 |
0 |
while (exists(space + "." + pageName + "_" + i, context)) { |
6312 |
0 |
i++; |
6313 |
|
} |
6314 |
|
|
6315 |
0 |
return pageName + "_" + i; |
6316 |
|
} |
6317 |
|
|
6318 |
36 |
return pageName; |
6319 |
|
} |
6320 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.38 |
|
6321 |
0 |
public PropertyClass getPropertyClassFromName(String propPath, XWikiContext context)... |
6322 |
|
{ |
6323 |
0 |
int i1 = propPath.indexOf('_'); |
6324 |
0 |
if (i1 == -1) { |
6325 |
0 |
return null; |
6326 |
|
} else { |
6327 |
0 |
String className = propPath.substring(0, i1); |
6328 |
0 |
String propName = propPath.substring(i1 + 1); |
6329 |
0 |
try { |
6330 |
0 |
return (PropertyClass) getDocument(className, context).getXClass().get(propName); |
6331 |
|
} catch (XWikiException e) { |
6332 |
0 |
return null; |
6333 |
|
} |
6334 |
|
} |
6335 |
|
} |
6336 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
6337 |
0 |
public boolean validateDocument(XWikiDocument doc, XWikiContext context) throws XWikiException... |
6338 |
|
{ |
6339 |
0 |
return doc.validate(context); |
6340 |
|
} |
6341 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
|
6342 |
0 |
public String addTooltip(String html, String message, String params, XWikiContext context)... |
6343 |
|
{ |
6344 |
0 |
StringBuilder buffer = new StringBuilder(); |
6345 |
0 |
buffer.append("<span class=\"tooltip_span\" onmouseover=\""); |
6346 |
0 |
buffer.append(params); |
6347 |
0 |
buffer.append("; return escape('"); |
6348 |
0 |
buffer.append(message.replaceAll("'", "\\'")); |
6349 |
0 |
buffer.append("');\">"); |
6350 |
0 |
buffer.append(html); |
6351 |
0 |
buffer.append("</span>"); |
6352 |
|
|
6353 |
0 |
return buffer.toString(); |
6354 |
|
} |
6355 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
6356 |
0 |
public String addTooltipJS(XWikiContext context)... |
6357 |
|
{ |
6358 |
0 |
StringBuilder buffer = new StringBuilder(); |
6359 |
0 |
buffer.append("<script type=\"text/javascript\" src=\""); |
6360 |
0 |
buffer.append(getSkinFile("ajax/wzToolTip.js", context)); |
6361 |
0 |
buffer.append("\"></script>"); |
6362 |
|
|
6363 |
|
|
6364 |
0 |
return buffer.toString(); |
6365 |
|
} |
6366 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
6367 |
0 |
public String addTooltip(String html, String message, XWikiContext context)... |
6368 |
|
{ |
6369 |
0 |
return addTooltip(html, message, "this.WIDTH='300'", context); |
6370 |
|
} |
6371 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
6372 |
0 |
public void renamePage(String fullName, String newFullName, XWikiContext context) throws XWikiException... |
6373 |
|
{ |
6374 |
0 |
renamePage(context.getWiki().getDocument(fullName, context), newFullName, context); |
6375 |
|
} |
6376 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
6377 |
0 |
public String addMandatory(XWikiContext context)... |
6378 |
|
{ |
6379 |
0 |
String star = |
6380 |
|
"<span class=\"mandatoryParenthesis\"> (</span><span class=\"mandatoryDot\">∗</span><span class=\"mandatoryParenthesis\">) </span>"; |
6381 |
0 |
return context.getWiki().getXWikiPreference("mandatory_display", star, context); |
6382 |
|
} |
6383 |
|
|
6384 |
|
|
6385 |
|
@since |
6386 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
6387 |
5783 |
public boolean hasVersioning(XWikiContext context)... |
6388 |
|
{ |
6389 |
5783 |
return ("1".equals(getConfiguration().getProperty("xwiki.store.versioning", "1"))); |
6390 |
|
} |
6391 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
6392 |
87 |
public boolean hasAttachmentVersioning(XWikiContext context)... |
6393 |
|
{ |
6394 |
87 |
return ("1".equals(getConfiguration().getProperty("xwiki.store.attachment.versioning", "1"))); |
6395 |
|
} |
6396 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
6397 |
0 |
public String getExternalAttachmentURL(String fullName, String filename, XWikiContext context)... |
6398 |
|
{ |
6399 |
0 |
XWikiDocument doc = new XWikiDocument(); |
6400 |
0 |
doc.setFullName(fullName, context); |
6401 |
|
|
6402 |
0 |
return doc.getExternalAttachmentURL(filename, "download", context); |
6403 |
|
} |
6404 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
6405 |
0 |
public int getMaxRecursiveSpaceChecks(XWikiContext context)... |
6406 |
|
{ |
6407 |
0 |
int max = getXWikiPreferenceAsInt("rights_maxrecursivespacechecks", -1, context); |
6408 |
0 |
if (max == -1) { |
6409 |
0 |
return getConfiguration().getProperty("xwiki.rights.maxrecursivespacechecks", 0); |
6410 |
|
} else { |
6411 |
0 |
return max; |
6412 |
|
} |
6413 |
|
} |
6414 |
|
|
6415 |
|
|
6416 |
|
|
6417 |
|
|
6418 |
|
@param |
6419 |
|
@param |
6420 |
|
@param@link |
6421 |
|
@throws |
6422 |
|
@since |
6423 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
6424 |
0 |
public void restoreFromRecycleBin(final XWikiDocument doc, String comment, XWikiContext context)... |
6425 |
|
throws XWikiException |
6426 |
|
{ |
6427 |
0 |
XWikiDeletedDocument[] deletedDocuments = getRecycleBinStore().getAllDeletedDocuments(doc, context, true); |
6428 |
0 |
if (deletedDocuments != null && deletedDocuments.length > 0) { |
6429 |
0 |
long index = deletedDocuments[0].getId(); |
6430 |
0 |
restoreFromRecycleBin(doc, index, comment, context); |
6431 |
|
} |
6432 |
|
} |
6433 |
|
|
6434 |
|
|
6435 |
|
|
6436 |
|
|
6437 |
|
@param |
6438 |
|
@param |
6439 |
|
@param |
6440 |
|
@param@link |
6441 |
|
@throws |
6442 |
|
@since |
6443 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
6444 |
2 |
public void restoreFromRecycleBin(final XWikiDocument doc, long index, String comment, XWikiContext context)... |
6445 |
|
throws XWikiException |
6446 |
|
{ |
6447 |
2 |
XWikiDocument newdoc = getRecycleBinStore().restoreFromRecycleBin(doc, index, context, true); |
6448 |
2 |
saveDocument(newdoc, comment, context); |
6449 |
2 |
getRecycleBinStore().deleteFromRecycleBin(doc, index, context, true); |
6450 |
|
} |
6451 |
|
|
|
|
| 22.1% |
Uncovered Elements: 81 (104) |
Complexity: 15 |
Complexity Density: 0.19 |
|
6452 |
2 |
public XWikiDocument rollback(final XWikiDocument tdoc, String rev, XWikiContext context) throws XWikiException... |
6453 |
|
{ |
6454 |
2 |
LOGGER.debug("Rolling back [" + tdoc + "] to version " + rev); |
6455 |
|
|
6456 |
2 |
XWikiDocument rolledbackDoc = getDocument(tdoc, rev, context).clone(); |
6457 |
|
|
6458 |
2 |
if ("1".equals(getConfiguration().getProperty("xwiki.store.rollbackattachmentwithdocuments", "1"))) { |
6459 |
|
|
6460 |
|
|
6461 |
|
|
6462 |
|
|
6463 |
|
|
6464 |
|
|
6465 |
|
|
6466 |
|
|
6467 |
|
|
6468 |
|
|
6469 |
|
|
6470 |
|
|
6471 |
|
|
6472 |
|
|
6473 |
|
|
6474 |
|
|
6475 |
|
|
6476 |
0 |
List<XWikiAttachment> oldAttachments = rolledbackDoc.getAttachmentList(); |
6477 |
0 |
List<XWikiAttachment> currentAttachments = tdoc.getAttachmentList(); |
6478 |
0 |
List<XWikiAttachment> toRestore = new ArrayList<XWikiAttachment>(); |
6479 |
0 |
List<XWikiAttachment> toRevert = new ArrayList<XWikiAttachment>(); |
6480 |
|
|
6481 |
|
|
6482 |
0 |
LOGGER.debug("Checking attachments"); |
6483 |
|
|
6484 |
0 |
for (XWikiAttachment oldAttachment : oldAttachments) { |
6485 |
0 |
String filename = oldAttachment.getFilename(); |
6486 |
0 |
XWikiAttachment equivalentAttachment = tdoc.getAttachment(filename); |
6487 |
0 |
if (equivalentAttachment == null) { |
6488 |
|
|
6489 |
0 |
LOGGER.debug("Deleted attachment: " + filename); |
6490 |
0 |
toRestore.add(oldAttachment); |
6491 |
0 |
continue; |
6492 |
|
} |
6493 |
0 |
XWikiAttachment equivalentAttachmentRevision = |
6494 |
|
equivalentAttachment.getAttachmentRevision(oldAttachment.getVersion(), context); |
6495 |
|
|
6496 |
|
|
6497 |
|
|
6498 |
|
|
6499 |
0 |
if (equivalentAttachmentRevision == null |
6500 |
|
|| equivalentAttachmentRevision.getDate().getTime() != oldAttachment.getDate().getTime()) { |
6501 |
|
|
6502 |
0 |
LOGGER.debug("Recreated attachment: " + filename); |
6503 |
|
|
6504 |
0 |
if (getAttachmentRecycleBinStore() != null) { |
6505 |
0 |
getAttachmentRecycleBinStore().saveToRecycleBin(equivalentAttachment, context.getUser(), |
6506 |
|
new Date(), context, true); |
6507 |
0 |
toRestore.add(oldAttachment); |
6508 |
|
} |
6509 |
0 |
continue; |
6510 |
|
} |
6511 |
0 |
if (!StringUtils.equals(oldAttachment.getVersion(), equivalentAttachment.getVersion())) { |
6512 |
|
|
6513 |
0 |
LOGGER.debug("Updated attachment: " + filename); |
6514 |
0 |
toRevert.add(equivalentAttachment); |
6515 |
|
} |
6516 |
|
} |
6517 |
0 |
for (XWikiAttachment attachment : currentAttachments) { |
6518 |
0 |
if (rolledbackDoc.getAttachment(attachment.getFilename()) == null) { |
6519 |
0 |
LOGGER.debug("New attachment: " + attachment.getFilename()); |
6520 |
|
|
6521 |
0 |
rolledbackDoc.getAttachmentsToRemove().add(new XWikiAttachmentToRemove(attachment, true)); |
6522 |
|
} |
6523 |
|
} |
6524 |
|
|
6525 |
|
|
6526 |
|
|
6527 |
|
|
6528 |
0 |
for (XWikiAttachment attachmentToRevert : toRevert) { |
6529 |
0 |
String oldAttachmentVersion = |
6530 |
|
rolledbackDoc.getAttachment(attachmentToRevert.getFilename()).getVersion(); |
6531 |
0 |
XWikiAttachment oldAttachmentRevision = |
6532 |
|
attachmentToRevert.getAttachmentRevision(oldAttachmentVersion, context); |
6533 |
0 |
if (oldAttachmentRevision == null) { |
6534 |
|
|
6535 |
0 |
replaceAttachmentInPlace(rolledbackDoc, attachmentToRevert); |
6536 |
0 |
continue; |
6537 |
|
} |
6538 |
|
|
6539 |
|
|
6540 |
|
|
6541 |
|
|
6542 |
|
|
6543 |
0 |
oldAttachmentRevision.setVersion(attachmentToRevert.getVersion()); |
6544 |
0 |
oldAttachmentRevision.setMetaDataDirty(true); |
6545 |
0 |
oldAttachmentRevision.getAttachment_content().setContentDirty(true); |
6546 |
0 |
replaceAttachmentInPlace(rolledbackDoc, oldAttachmentRevision); |
6547 |
|
} |
6548 |
|
|
6549 |
|
|
6550 |
0 |
if (getAttachmentRecycleBinStore() != null) { |
6551 |
0 |
for (XWikiAttachment attachmentToRestore : toRestore) { |
6552 |
|
|
6553 |
0 |
List<DeletedAttachment> deletedVariants = |
6554 |
|
getAttachmentRecycleBinStore().getAllDeletedAttachments(attachmentToRestore, context, true); |
6555 |
0 |
DeletedAttachment correctVariant = null; |
6556 |
0 |
for (DeletedAttachment variant : deletedVariants) { |
6557 |
0 |
if (variant.getDate().before(rolledbackDoc.getDate())) { |
6558 |
0 |
break; |
6559 |
|
} |
6560 |
0 |
correctVariant = variant; |
6561 |
|
} |
6562 |
0 |
if (correctVariant == null) { |
6563 |
|
|
6564 |
0 |
continue; |
6565 |
|
} |
6566 |
0 |
XWikiAttachment restoredAttachment = correctVariant.restoreAttachment(null, context); |
6567 |
0 |
XWikiAttachment restoredAttachmentRevision = |
6568 |
|
restoredAttachment.getAttachmentRevision(attachmentToRestore.getVersion(), context); |
6569 |
|
|
6570 |
0 |
if (restoredAttachmentRevision != null) { |
6571 |
0 |
restoredAttachmentRevision.setAttachment_archive(restoredAttachment.getAttachment_archive()); |
6572 |
0 |
restoredAttachmentRevision.getAttachment_archive().setAttachment(restoredAttachmentRevision); |
6573 |
0 |
restoredAttachmentRevision.setVersion(restoredAttachment.getVersion()); |
6574 |
0 |
restoredAttachmentRevision.setMetaDataDirty(true); |
6575 |
0 |
restoredAttachmentRevision.getAttachment_content().setContentDirty(true); |
6576 |
0 |
replaceAttachmentInPlace(rolledbackDoc, restoredAttachmentRevision); |
6577 |
|
} else { |
6578 |
|
|
6579 |
0 |
replaceAttachmentInPlace(rolledbackDoc, restoredAttachment); |
6580 |
|
} |
6581 |
|
} |
6582 |
|
} else { |
6583 |
|
|
6584 |
0 |
for (XWikiAttachment attachmentToRestore : toRestore) { |
6585 |
0 |
rolledbackDoc.getAttachmentList().remove(attachmentToRestore); |
6586 |
|
} |
6587 |
|
} |
6588 |
|
} |
6589 |
|
|
6590 |
|
|
6591 |
2 |
rolledbackDoc.addXObjectsToRemoveFromVersion(tdoc); |
6592 |
|
|
6593 |
|
|
6594 |
2 |
rolledbackDoc.setOriginalDocument(tdoc); |
6595 |
2 |
rolledbackDoc.setAuthorReference(context.getUserReference()); |
6596 |
2 |
rolledbackDoc.setRCSVersion(tdoc.getRCSVersion()); |
6597 |
2 |
rolledbackDoc.setVersion(tdoc.getVersion()); |
6598 |
2 |
rolledbackDoc.setContentDirty(true); |
6599 |
|
|
6600 |
2 |
ObservationManager om = getObservationManager(); |
6601 |
2 |
if (om != null) { |
6602 |
|
|
6603 |
|
|
6604 |
|
|
6605 |
2 |
om.notify(new DocumentRollingBackEvent(rolledbackDoc.getDocumentReference(), rev), rolledbackDoc, context); |
6606 |
|
} |
6607 |
|
|
6608 |
2 |
saveDocument(rolledbackDoc, localizePlainOrKey("core.comment.rollback", rev), context); |
6609 |
|
|
6610 |
|
|
6611 |
2 |
XWikiDocument newOriginalDocument = rolledbackDoc.getOriginalDocument(); |
6612 |
2 |
rolledbackDoc.setOriginalDocument(tdoc); |
6613 |
|
|
6614 |
2 |
try { |
6615 |
2 |
if (om != null) { |
6616 |
|
|
6617 |
|
|
6618 |
|
|
6619 |
2 |
om.notify(new DocumentRolledBackEvent(rolledbackDoc.getDocumentReference(), rev), rolledbackDoc, |
6620 |
|
context); |
6621 |
|
} |
6622 |
|
} finally { |
6623 |
2 |
rolledbackDoc.setOriginalDocument(newOriginalDocument); |
6624 |
|
} |
6625 |
|
|
6626 |
2 |
return rolledbackDoc; |
6627 |
|
} |
6628 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
6629 |
0 |
private void replaceAttachmentInPlace(XWikiDocument doc, XWikiAttachment attachment)... |
6630 |
|
{ |
6631 |
0 |
for (ListIterator<XWikiAttachment> it = doc.getAttachmentList().listIterator(); it.hasNext();) { |
6632 |
0 |
if (StringUtils.equals(it.next().getFilename(), attachment.getFilename())) { |
6633 |
0 |
it.remove(); |
6634 |
0 |
it.add(attachment); |
6635 |
0 |
break; |
6636 |
|
} |
6637 |
|
} |
6638 |
|
} |
6639 |
|
|
6640 |
|
|
6641 |
|
@return |
6642 |
|
|
6643 |
|
@deprecated |
6644 |
|
|
6645 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
6646 |
0 |
@Deprecated... |
6647 |
|
public List<String> getConfiguredSyntaxes() |
6648 |
|
{ |
6649 |
0 |
return this.configuredSyntaxes; |
6650 |
|
} |
6651 |
|
|
6652 |
|
|
6653 |
|
@return |
6654 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
6655 |
0 |
public String getDefaultDocumentSyntax()... |
6656 |
|
{ |
6657 |
|
|
6658 |
0 |
return getDefaultDocumentSyntaxInternal().toIdString(); |
6659 |
|
} |
6660 |
|
|
6661 |
|
|
6662 |
|
@return |
6663 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
6664 |
29 |
private Syntax getDefaultDocumentSyntaxInternal()... |
6665 |
|
{ |
6666 |
29 |
return Utils.getComponent(CoreConfiguration.class).getDefaultDocumentSyntax(); |
6667 |
|
} |
6668 |
|
|
6669 |
|
|
6670 |
|
|
6671 |
|
|
6672 |
|
|
6673 |
|
|
6674 |
|
@link |
6675 |
|
|
6676 |
|
|
6677 |
|
|
6678 |
|
@link |
6679 |
|
|
6680 |
|
@param |
6681 |
|
@return |
6682 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
6683 |
1923 |
public String getCurrentContentSyntaxId(String defaultSyntaxId, XWikiContext context)... |
6684 |
|
{ |
6685 |
1923 |
String syntaxId = getCurrentContentSyntaxIdInternal(context); |
6686 |
|
|
6687 |
1923 |
if (syntaxId == null) { |
6688 |
2 |
syntaxId = defaultSyntaxId; |
6689 |
|
} |
6690 |
|
|
6691 |
1923 |
return syntaxId; |
6692 |
|
} |
6693 |
|
|
6694 |
|
|
6695 |
|
|
6696 |
|
|
6697 |
|
|
6698 |
|
|
6699 |
|
@link |
6700 |
|
|
6701 |
|
|
6702 |
|
|
6703 |
|
@link |
6704 |
|
|
6705 |
|
@return |
6706 |
|
|
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
6707 |
182 |
public String getCurrentContentSyntaxId(XWikiContext context)... |
6708 |
|
{ |
6709 |
182 |
String syntaxId = getCurrentContentSyntaxIdInternal(context); |
6710 |
|
|
6711 |
182 |
if (syntaxId == null) { |
6712 |
0 |
throw new RuntimeException("Cannot get the current syntax since there's no current document set"); |
6713 |
|
} |
6714 |
|
|
6715 |
182 |
return syntaxId; |
6716 |
|
} |
6717 |
|
|
6718 |
|
|
6719 |
|
|
6720 |
|
|
6721 |
|
|
6722 |
|
|
6723 |
|
@link |
6724 |
|
|
6725 |
|
|
6726 |
|
|
6727 |
|
@link |
6728 |
|
|
6729 |
|
@return |
6730 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
6731 |
2105 |
private String getCurrentContentSyntaxIdInternal(XWikiContext context)... |
6732 |
|
{ |
6733 |
2105 |
Syntax syntax = getCurrentContentSyntaxInternal(context); |
6734 |
|
|
6735 |
2105 |
return syntax != null ? syntax.toIdString() : null; |
6736 |
|
} |
6737 |
|
|
6738 |
|
|
6739 |
|
|
6740 |
|
|
6741 |
|
|
6742 |
|
|
6743 |
|
@link |
6744 |
|
|
6745 |
|
|
6746 |
|
|
6747 |
|
@link |
6748 |
|
|
6749 |
|
@return |
6750 |
|
|
|
|
| 90.9% |
Uncovered Elements: 2 (22) |
Complexity: 6 |
Complexity Density: 0.5 |
|
6751 |
2105 |
private Syntax getCurrentContentSyntaxInternal(XWikiContext context)... |
6752 |
|
{ |
6753 |
2105 |
Syntax syntax = null; |
6754 |
|
|
6755 |
|
|
6756 |
2105 |
if (getRenderingContext() != null) { |
6757 |
2105 |
Block curentBlock = getRenderingContext().getCurrentBlock(); |
6758 |
|
|
6759 |
2105 |
if (curentBlock != null) { |
6760 |
1240 |
MetaDataBlock metaDataBlock = |
6761 |
|
curentBlock.getFirstBlock(new MetadataBlockMatcher(MetaData.SYNTAX), Axes.ANCESTOR_OR_SELF); |
6762 |
|
|
6763 |
1240 |
if (metaDataBlock != null) { |
6764 |
1240 |
return (Syntax) metaDataBlock.getMetaData().getMetaData(MetaData.SYNTAX); |
6765 |
|
} |
6766 |
|
} |
6767 |
|
} |
6768 |
|
|
6769 |
|
|
6770 |
865 |
if (context.get("sdoc") != null) { |
6771 |
|
|
6772 |
858 |
syntax = ((XWikiDocument) context.get("sdoc")).getSyntax(); |
6773 |
7 |
} else if (context.getDoc() != null) { |
6774 |
|
|
6775 |
5 |
syntax = context.getDoc().getSyntax(); |
6776 |
|
} |
6777 |
|
|
6778 |
865 |
return syntax; |
6779 |
|
} |
6780 |
|
|
6781 |
|
|
6782 |
|
@return |
6783 |
|
|
6784 |
|
|
6785 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
6786 |
212 |
public boolean isTitleInCompatibilityMode()... |
6787 |
|
{ |
6788 |
212 |
return "1".equals(getConfiguration().getProperty("xwiki.title.compatibility", "0")); |
6789 |
|
} |
6790 |
|
|
|
|
| 15.8% |
Uncovered Elements: 16 (19) |
Complexity: 5 |
Complexity Density: 0.45 |
|
6791 |
3 |
@Override... |
6792 |
|
public void onEvent(Event event, Object source, Object data) |
6793 |
|
{ |
6794 |
3 |
if (event instanceof WikiDeletedEvent) { |
6795 |
|
|
6796 |
3 |
onWikiDeletedEvent((WikiDeletedEvent) event); |
6797 |
0 |
} else if (event instanceof ComponentDescriptorAddedEvent) { |
6798 |
|
|
6799 |
0 |
onMandatoryDocumentInitializerAdded((ComponentDescriptorAddedEvent) event, (ComponentManager) source); |
6800 |
|
} else { |
6801 |
|
|
6802 |
|
|
6803 |
0 |
XWikiDocument doc = (XWikiDocument) source; |
6804 |
0 |
XWikiContext context = (XWikiContext) data; |
6805 |
|
|
6806 |
0 |
if (event instanceof XObjectPropertyEvent) { |
6807 |
0 |
EntityReference reference = ((XObjectPropertyEvent) event).getReference(); |
6808 |
0 |
String modifiedProperty = reference.getName(); |
6809 |
0 |
if ("backlinks".equals(modifiedProperty)) { |
6810 |
0 |
this.hasBacklinks = doc.getXObject((ObjectReference) reference.getParent()).getIntValue("backlinks", |
6811 |
|
getConfiguration().getProperty("xwiki.backlinks", 0)) == 1; |
6812 |
|
} |
6813 |
|
} |
6814 |
|
} |
6815 |
|
} |
6816 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
6817 |
3 |
private void onWikiDeletedEvent(WikiDeletedEvent event)... |
6818 |
|
{ |
6819 |
3 |
this.initializedWikis.remove(event.getWikiId()); |
6820 |
|
} |
6821 |
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 5 |
Complexity Density: 0.36 |
|
6822 |
0 |
private void onMandatoryDocumentInitializerAdded(ComponentDescriptorAddedEvent event,... |
6823 |
|
ComponentManager componentManager) |
6824 |
|
{ |
6825 |
0 |
String namespace; |
6826 |
0 |
if (componentManager instanceof NamespacedComponentManager) { |
6827 |
0 |
namespace = ((NamespacedComponentManager) componentManager).getNamespace(); |
6828 |
|
} else { |
6829 |
0 |
namespace = null; |
6830 |
|
} |
6831 |
|
|
6832 |
0 |
MandatoryDocumentInitializer initializer; |
6833 |
0 |
try { |
6834 |
0 |
initializer = componentManager.getInstance(MandatoryDocumentInitializer.class, event.getRoleHint()); |
6835 |
|
|
6836 |
0 |
XWikiContext context = getXWikiContext(); |
6837 |
0 |
if (namespace == null) { |
6838 |
|
|
6839 |
0 |
for (String wiki : this.initializedWikis.keySet()) { |
6840 |
0 |
initializeMandatoryDocument(wiki, initializer, context); |
6841 |
|
} |
6842 |
0 |
} else if (namespace.startsWith("wiki:")) { |
6843 |
|
|
6844 |
0 |
initializeMandatoryDocument(namespace.substring("wiki:".length()), initializer, context); |
6845 |
|
} |
6846 |
|
} catch (ComponentLookupException e) { |
6847 |
0 |
LOGGER.error("Failed to lookup mandatory document initializer", e); |
6848 |
|
} |
6849 |
|
} |
6850 |
|
|
6851 |
|
|
6852 |
|
|
6853 |
|
|
6854 |
|
private static final RegexEntityReference XWIKIPREFERENCE_PROPERTY_REFERENCE = |
6855 |
|
new RegexEntityReference(Pattern.compile("backlinks"), EntityType.OBJECT_PROPERTY, |
6856 |
|
new RegexEntityReference(Pattern.compile(".*:XWiki.XWikiPreferences\\[\\d*\\]"), EntityType.OBJECT)); |
6857 |
|
|
6858 |
|
private static final List<Event> LISTENER_EVENTS = |
6859 |
|
Arrays.<Event>asList(new XObjectPropertyAddedEvent(XWIKIPREFERENCE_PROPERTY_REFERENCE), |
6860 |
|
new XObjectPropertyDeletedEvent(XWIKIPREFERENCE_PROPERTY_REFERENCE), |
6861 |
|
new XObjectPropertyUpdatedEvent(XWIKIPREFERENCE_PROPERTY_REFERENCE), new WikiDeletedEvent(), |
6862 |
|
new ComponentDescriptorAddedEvent(MandatoryDocumentInitializer.class)); |
6863 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
6864 |
87 |
@Override... |
6865 |
|
public List<Event> getEvents() |
6866 |
|
{ |
6867 |
87 |
return LISTENER_EVENTS; |
6868 |
|
} |
6869 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
6870 |
1017 |
@Override... |
6871 |
|
public String getName() |
6872 |
|
{ |
6873 |
1017 |
return "xwiki-core"; |
6874 |
|
} |
6875 |
|
|
6876 |
|
|
6877 |
|
|
6878 |
|
|
6879 |
|
@param@link |
6880 |
|
@since |
6881 |
|
|
|
|
| 75% |
Uncovered Elements: 2 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
6882 |
2 |
private DocumentReference getPreferencesDocumentReference(XWikiContext context)... |
6883 |
|
{ |
6884 |
2 |
String database = context.getWikiId(); |
6885 |
2 |
EntityReference spaceReference; |
6886 |
2 |
if (database != null) { |
6887 |
2 |
spaceReference = new EntityReference(SYSTEM_SPACE, EntityType.SPACE, new WikiReference(database)); |
6888 |
|
} else { |
6889 |
0 |
spaceReference = getCurrentMixedEntityReferenceResolver().resolve(SYSTEM_SPACE, EntityType.SPACE); |
6890 |
|
} |
6891 |
2 |
return new DocumentReference("XWikiPreferences", new SpaceReference(spaceReference)); |
6892 |
|
} |
6893 |
|
|
6894 |
|
|
6895 |
|
|
6896 |
|
|
6897 |
|
|
6898 |
|
@param |
6899 |
|
|
6900 |
|
@param |
6901 |
|
@param |
6902 |
|
@param |
6903 |
|
@param@link |
6904 |
|
@param@link |
6905 |
|
@return@link |
6906 |
|
@throws |
6907 |
|
@see |
6908 |
|
@since |
6909 |
|
|
|
|
| 83.9% |
Uncovered Elements: 5 (31) |
Complexity: 6 |
Complexity Density: 0.29 |
|
6910 |
2 |
public List<XWikiAttachment> searchAttachments(String parametrizedSqlClause, boolean checkRight, int nb, int start,... |
6911 |
|
List<?> parameterValues, XWikiContext context) throws XWikiException |
6912 |
|
{ |
6913 |
2 |
parametrizedSqlClause = parametrizedSqlClause.trim().replaceFirst("^and ", "").replaceFirst("^where ", ""); |
6914 |
|
|
6915 |
|
|
6916 |
2 |
List<java.lang.Object[]> results = this.getStore().search( |
6917 |
|
"select attach.filename, doc.fullName from XWikiAttachment attach, XWikiDocument doc where doc.id = attach.docId and " |
6918 |
|
+ parametrizedSqlClause, |
6919 |
|
nb, start, parameterValues, context); |
6920 |
|
|
6921 |
2 |
HashMap<String, List<String>> filenamesByDocFullName = new HashMap<String, List<String>>(); |
6922 |
|
|
6923 |
|
|
6924 |
5 |
for (int i = 0; i < results.size(); i++) { |
6925 |
3 |
String filename = (String) results.get(i)[0]; |
6926 |
3 |
String docFullName = (String) results.get(i)[1]; |
6927 |
3 |
if (!filenamesByDocFullName.containsKey(docFullName)) { |
6928 |
3 |
filenamesByDocFullName.put(docFullName, new ArrayList<String>()); |
6929 |
|
} |
6930 |
3 |
filenamesByDocFullName.get(docFullName).add(filename); |
6931 |
|
} |
6932 |
|
|
6933 |
2 |
List<XWikiAttachment> out = new ArrayList<XWikiAttachment>(); |
6934 |
|
|
6935 |
|
|
6936 |
2 |
for (Map.Entry<String, List<String>> entry : filenamesByDocFullName.entrySet()) { |
6937 |
3 |
String fullName = entry.getKey(); |
6938 |
|
|
6939 |
3 |
XWikiDocument doc = getDocument(fullName, context); |
6940 |
3 |
if (checkRight) { |
6941 |
3 |
if (!context.getWiki().getRightService().hasAccessLevel("view", context.getUser(), doc.getFullName(), |
6942 |
|
context)) { |
6943 |
0 |
continue; |
6944 |
|
} |
6945 |
|
} |
6946 |
3 |
List<String> returnedAttachmentNames = entry.getValue(); |
6947 |
3 |
for (XWikiAttachment attach : doc.getAttachmentList()) { |
6948 |
3 |
if (returnedAttachmentNames.contains(attach.getFilename())) { |
6949 |
3 |
out.add(attach); |
6950 |
|
} |
6951 |
|
} |
6952 |
|
} |
6953 |
|
|
6954 |
2 |
return out; |
6955 |
|
} |
6956 |
|
|
6957 |
|
|
6958 |
|
|
6959 |
|
|
6960 |
|
@param |
6961 |
|
@param@link |
6962 |
|
@param@link |
6963 |
|
@return |
6964 |
|
@throws |
6965 |
|
@see |
6966 |
|
@since |
6967 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
6968 |
2 |
public int countAttachments(String parametrizedSqlClause, List<?> parameterValues, XWikiContext context)... |
6969 |
|
throws XWikiException |
6970 |
|
{ |
6971 |
2 |
parametrizedSqlClause = parametrizedSqlClause.trim().replaceFirst("^and ", "").replaceFirst("^where ", ""); |
6972 |
|
|
6973 |
2 |
List l = getStore().search("select count(attach) from XWikiAttachment attach, XWikiDocument doc where " |
6974 |
|
+ "attach.docId=doc.id and " + parametrizedSqlClause, 0, 0, parameterValues, context); |
6975 |
2 |
return ((Number) l.get(0)).intValue(); |
6976 |
|
} |
6977 |
|
|
6978 |
|
|
6979 |
|
|
6980 |
|
|
6981 |
|
@deprecated@link |
6982 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
6983 |
0 |
@Deprecated... |
6984 |
|
public static String getConfigPath() throws NamingException |
6985 |
|
{ |
6986 |
0 |
return XWikiCfgConfigurationSource.getConfigPath(); |
6987 |
|
} |
6988 |
|
|
6989 |
|
|
6990 |
|
@deprecated@link |
6991 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
6992 |
27 |
@Deprecated... |
6993 |
|
public XWiki(XWikiConfig config, XWikiContext context) throws XWikiException |
6994 |
|
{ |
6995 |
27 |
this(config, context, null, false); |
6996 |
|
} |
6997 |
|
|
6998 |
|
|
6999 |
|
@deprecated@link |
7000 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
7001 |
55 |
@Deprecated... |
7002 |
|
public XWiki(XWikiConfig config, XWikiContext context, XWikiEngineContext engine_context, boolean noupdate) |
7003 |
|
throws XWikiException |
7004 |
|
{ |
7005 |
55 |
initXWiki(config, context, engine_context, noupdate); |
7006 |
|
} |
7007 |
|
|
7008 |
|
|
7009 |
|
@deprecated@link |
7010 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
7011 |
0 |
@Deprecated... |
7012 |
|
public XWiki(String xwikicfgpath, XWikiContext context) throws XWikiException |
7013 |
|
{ |
7014 |
0 |
this(xwikicfgpath, context, null, false); |
7015 |
|
} |
7016 |
|
|
7017 |
|
|
7018 |
|
@deprecated@link |
7019 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
7020 |
0 |
@Deprecated... |
7021 |
|
public XWiki(String xwikicfgpath, XWikiContext context, XWikiEngineContext engine_context, boolean noupdate) |
7022 |
|
throws XWikiException |
7023 |
|
{ |
7024 |
0 |
try { |
7025 |
0 |
initXWiki(new XWikiConfig(new FileInputStream(xwikicfgpath)), context, engine_context, noupdate); |
7026 |
|
} catch (FileNotFoundException e) { |
7027 |
0 |
Object[] args = { xwikicfgpath }; |
7028 |
0 |
throw new XWikiException(XWikiException.MODULE_XWIKI_CONFIG, XWikiException.ERROR_XWIKI_CONFIG_FILENOTFOUND, |
7029 |
|
"Configuration file {0} not found", e, args); |
7030 |
|
} |
7031 |
|
} |
7032 |
|
|
7033 |
|
|
7034 |
|
@deprecated@link |
7035 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
7036 |
0 |
@Deprecated... |
7037 |
|
public XWiki(InputStream is, XWikiContext context, XWikiEngineContext engine_context) throws XWikiException |
7038 |
|
{ |
7039 |
0 |
initXWiki(new XWikiConfig(is), context, engine_context, true); |
7040 |
|
} |
7041 |
|
|
7042 |
|
|
7043 |
|
@deprecated@link |
7044 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
7045 |
17272 |
@Deprecated... |
7046 |
|
public XWikiConfig getConfig() |
7047 |
|
{ |
7048 |
17272 |
return new XWikiConfigDelegate(getConfiguration()); |
7049 |
|
} |
7050 |
|
|
7051 |
|
|
7052 |
|
@deprecated |
7053 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
7054 |
66 |
@Deprecated... |
7055 |
|
public void setConfig(XWikiConfig config) |
7056 |
|
{ |
7057 |
66 |
ConfigurationSource configuration = getConfiguration(); |
7058 |
|
|
7059 |
66 |
if (configuration instanceof XWikiCfgConfigurationSource) { |
7060 |
28 |
((XWikiCfgConfigurationSource) configuration).set(config); |
7061 |
|
} |
7062 |
|
} |
7063 |
|
|
7064 |
|
|
7065 |
|
@deprecated@link |
7066 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
7067 |
71360 |
@Deprecated... |
7068 |
|
public String Param(String key) |
7069 |
|
{ |
7070 |
71356 |
return Param(key, null); |
7071 |
|
} |
7072 |
|
|
7073 |
|
|
7074 |
|
@deprecated@link |
7075 |
|
|
|
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
7076 |
137559 |
@Deprecated... |
7077 |
|
public String Param(String key, String default_value) |
7078 |
|
{ |
7079 |
137586 |
if (getConfiguration() != null) { |
7080 |
137580 |
return getConfiguration().getProperty(key, default_value); |
7081 |
|
} |
7082 |
|
|
7083 |
0 |
return default_value; |
7084 |
|
} |
7085 |
|
|
7086 |
|
|
7087 |
|
@deprecated@link |
7088 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
7089 |
0 |
@Deprecated... |
7090 |
|
public long ParamAsLong(String key) |
7091 |
|
{ |
7092 |
0 |
return getConfiguration().getProperty(key, long.class); |
7093 |
|
} |
7094 |
|
|
7095 |
|
|
7096 |
|
@deprecated@link |
7097 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
7098 |
11625 |
@Deprecated... |
7099 |
|
public long ParamAsLong(String key, long default_value) |
7100 |
|
{ |
7101 |
11625 |
return getConfiguration().getProperty(key, default_value); |
7102 |
|
} |
7103 |
|
} |