1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package com.xpn.xwiki.plugin.webdav.utils; |
21 |
|
|
22 |
|
import java.io.IOException; |
23 |
|
import java.io.InputStream; |
24 |
|
import java.util.List; |
25 |
|
|
26 |
|
import javax.servlet.ServletContext; |
27 |
|
|
28 |
|
import org.apache.commons.io.IOUtils; |
29 |
|
import org.apache.jackrabbit.webdav.DavException; |
30 |
|
import org.apache.jackrabbit.webdav.DavMethods; |
31 |
|
import org.apache.jackrabbit.webdav.DavResourceFactory; |
32 |
|
import org.apache.jackrabbit.webdav.DavServletRequest; |
33 |
|
import org.apache.jackrabbit.webdav.DavServletResponse; |
34 |
|
import org.apache.jackrabbit.webdav.DavSession; |
35 |
|
import org.apache.jackrabbit.webdav.lock.LockManager; |
36 |
|
import org.slf4j.Logger; |
37 |
|
import org.slf4j.LoggerFactory; |
38 |
|
import org.xwiki.cache.Cache; |
39 |
|
import org.xwiki.cache.CacheException; |
40 |
|
import org.xwiki.cache.CacheManager; |
41 |
|
import org.xwiki.cache.config.CacheConfiguration; |
42 |
|
import org.xwiki.cache.eviction.LRUEvictionConfiguration; |
43 |
|
import org.xwiki.container.servlet.ServletContainerException; |
44 |
|
import org.xwiki.container.servlet.ServletContainerInitializer; |
45 |
|
|
46 |
|
import com.xpn.xwiki.XWiki; |
47 |
|
import com.xpn.xwiki.XWikiContext; |
48 |
|
import com.xpn.xwiki.XWikiException; |
49 |
|
import com.xpn.xwiki.doc.XWikiAttachment; |
50 |
|
import com.xpn.xwiki.doc.XWikiDocument; |
51 |
|
import com.xpn.xwiki.user.api.XWikiUser; |
52 |
|
import com.xpn.xwiki.web.Utils; |
53 |
|
import com.xpn.xwiki.web.XWikiEngineContext; |
54 |
|
import com.xpn.xwiki.web.XWikiRequest; |
55 |
|
import com.xpn.xwiki.web.XWikiResponse; |
56 |
|
import com.xpn.xwiki.web.XWikiServletContext; |
57 |
|
import com.xpn.xwiki.web.XWikiServletRequest; |
58 |
|
import com.xpn.xwiki.web.XWikiURLFactory; |
59 |
|
import com.xpn.xwiki.web.XWikiServletResponse; |
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
@version |
67 |
|
|
|
|
| 70.2% |
Uncovered Elements: 65 (218) |
Complexity: 70 |
Complexity Density: 0.46 |
|
68 |
|
public class XWikiDavContext |
69 |
|
{ |
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
private static final Logger LOGGER = LoggerFactory.getLogger(XWikiDavContext.class); |
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
|
78 |
|
private static Cache<XWikiDavUserStorage> davCache; |
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
private DavServletRequest request; |
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
|
88 |
|
private XWikiContext xwikiContext; |
89 |
|
|
90 |
|
|
91 |
|
|
92 |
|
|
93 |
|
private DavResourceFactory resourceFactory; |
94 |
|
|
95 |
|
|
96 |
|
|
97 |
|
|
98 |
|
private DavSession davSession; |
99 |
|
|
100 |
|
|
101 |
|
|
102 |
|
|
103 |
|
private LockManager lockManager; |
104 |
|
|
105 |
|
|
106 |
|
|
107 |
|
|
108 |
|
@param |
109 |
|
@param |
110 |
|
@param |
111 |
|
@param |
112 |
|
@param |
113 |
|
@param |
114 |
|
@throws |
115 |
|
|
|
|
| 89.5% |
Uncovered Elements: 4 (38) |
Complexity: 6 |
Complexity Density: 0.19 |
|
116 |
84 |
public XWikiDavContext(DavServletRequest request, DavServletResponse response, ServletContext servletContext,... |
117 |
|
DavResourceFactory resourceFactory, DavSession davSession, LockManager lockManager) throws DavException |
118 |
|
{ |
119 |
84 |
this.request = request; |
120 |
84 |
this.resourceFactory = resourceFactory; |
121 |
84 |
this.davSession = davSession; |
122 |
84 |
this.lockManager = lockManager; |
123 |
|
|
124 |
84 |
try { |
125 |
84 |
XWikiEngineContext xwikiEngine = new XWikiServletContext(servletContext); |
126 |
84 |
XWikiRequest xwikiRequest = new XWikiServletRequest(request); |
127 |
84 |
XWikiResponse xwikiResponse = new XWikiServletResponse(response); |
128 |
|
|
129 |
84 |
xwikiContext = Utils.prepareContext("", xwikiRequest, xwikiResponse, xwikiEngine); |
130 |
84 |
xwikiContext.setMode(XWikiContext.MODE_SERVLET); |
131 |
84 |
xwikiContext.setWikiId("xwiki"); |
132 |
|
|
133 |
84 |
ServletContainerInitializer containerInitializer = Utils.getComponent(ServletContainerInitializer.class); |
134 |
84 |
containerInitializer.initializeRequest(xwikiContext.getRequest().getHttpServletRequest(), xwikiContext); |
135 |
84 |
containerInitializer.initializeResponse(xwikiContext.getResponse()); |
136 |
84 |
containerInitializer.initializeSession(xwikiContext.getRequest().getHttpServletRequest()); |
137 |
84 |
containerInitializer.initializeApplicationContext(servletContext); |
138 |
|
|
139 |
84 |
XWiki xwiki = XWiki.getXWiki(xwikiContext); |
140 |
84 |
XWikiURLFactory urlf = xwiki.getURLFactoryService().createURLFactory(xwikiContext.getMode(), xwikiContext); |
141 |
84 |
xwikiContext.setURLFactory(urlf); |
142 |
84 |
xwiki.prepareResources(xwikiContext); |
143 |
|
|
144 |
84 |
String username = "XWiki.XWikiGuest"; |
145 |
84 |
XWikiUser user = xwikiContext.getWiki().checkAuth(xwikiContext); |
146 |
84 |
if (user != null) { |
147 |
84 |
username = user.getUser(); |
148 |
|
} |
149 |
84 |
xwikiContext.setUser(username); |
150 |
|
|
151 |
84 |
if (xwikiContext.getDoc() == null) { |
152 |
84 |
xwikiContext.setDoc(new XWikiDocument("Fake", "Document")); |
153 |
|
} |
154 |
84 |
xwikiContext.put("ajax", Boolean.TRUE); |
155 |
|
} catch (XWikiException ex) { |
156 |
0 |
throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, ex); |
157 |
|
} catch (ServletContainerException ex) { |
158 |
0 |
throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, ex); |
159 |
|
} |
160 |
|
|
161 |
84 |
if (null == davCache) { |
162 |
1 |
initCache(); |
163 |
|
} |
164 |
|
} |
165 |
|
|
166 |
|
|
167 |
|
|
168 |
|
|
169 |
|
@throws |
170 |
|
|
|
|
| 87.5% |
Uncovered Elements: 1 (8) |
Complexity: 2 |
Complexity Density: 0.25 |
|
171 |
1 |
private static void initCache() throws DavException... |
172 |
|
{ |
173 |
1 |
try { |
174 |
1 |
CacheManager cacheManager = Utils.getComponent(CacheManager.class, "default"); |
175 |
1 |
CacheConfiguration conf = new CacheConfiguration(); |
176 |
1 |
LRUEvictionConfiguration lec = new LRUEvictionConfiguration(); |
177 |
1 |
lec.setMaxIdle(300); |
178 |
1 |
conf.put(LRUEvictionConfiguration.CONFIGURATIONID, lec); |
179 |
1 |
davCache = cacheManager.createNewCache(conf); |
180 |
|
} catch (CacheException ex) { |
181 |
0 |
throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, ex); |
182 |
|
} |
183 |
|
} |
184 |
|
|
185 |
|
|
186 |
|
|
187 |
|
|
188 |
|
@return |
189 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
190 |
1062 |
public XWikiDavUserStorage getUserStorage()... |
191 |
|
{ |
192 |
1062 |
String user = xwikiContext.getUser(); |
193 |
1062 |
if (null == davCache.get(user)) { |
194 |
1 |
davCache.set(user, new XWikiDavUserStorage()); |
195 |
|
} |
196 |
1062 |
return davCache.get(user); |
197 |
|
} |
198 |
|
|
199 |
|
|
200 |
|
|
201 |
|
|
202 |
|
@param |
203 |
|
@param |
204 |
|
@return |
205 |
|
|
|
|
| 80% |
Uncovered Elements: 3 (15) |
Complexity: 5 |
Complexity Density: 0.56 |
|
206 |
31 |
public boolean hasAccess(String right, String fullDocName)... |
207 |
|
{ |
208 |
31 |
boolean hasAccess = false; |
209 |
31 |
try { |
210 |
31 |
if (right.equals("overwrite")) { |
211 |
1 |
String overwriteAccess = exists(fullDocName) ? "delete" : "edit"; |
212 |
1 |
hasAccess = hasAccess(overwriteAccess, fullDocName); |
213 |
30 |
} else if (xwikiContext.getWiki().getRightService() |
214 |
|
.hasAccessLevel(right, xwikiContext.getUser(), fullDocName, xwikiContext)) { |
215 |
30 |
hasAccess = true; |
216 |
|
} |
217 |
|
} catch (XWikiException ex) { |
218 |
0 |
LOGGER.error("Error while validating access level.", ex); |
219 |
|
} |
220 |
31 |
return hasAccess; |
221 |
|
} |
222 |
|
|
223 |
|
|
224 |
|
|
225 |
|
@link |
226 |
|
|
227 |
|
@param |
228 |
|
@param |
229 |
|
@throws |
230 |
|
|
231 |
|
|
|
|
| 50% |
Uncovered Elements: 2 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
232 |
22 |
public void checkAccess(String right, String fullDocName) throws DavException... |
233 |
|
{ |
234 |
22 |
if (!hasAccess(right, fullDocName)) { |
235 |
0 |
throw new DavException(DavServletResponse.SC_FORBIDDEN); |
236 |
|
} |
237 |
|
} |
238 |
|
|
239 |
|
|
240 |
|
|
241 |
|
|
242 |
|
@param |
243 |
|
@return |
244 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
245 |
3 |
public String getMimeType(XWikiAttachment attachment)... |
246 |
|
{ |
247 |
3 |
return attachment.getMimeType(xwikiContext); |
248 |
|
} |
249 |
|
|
250 |
|
|
251 |
|
|
252 |
|
|
253 |
|
@param |
254 |
|
@return |
255 |
|
@throws |
256 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
257 |
1 |
public byte[] getContent(XWikiAttachment attachment) throws DavException... |
258 |
|
{ |
259 |
1 |
try { |
260 |
1 |
return attachment.getContent(xwikiContext); |
261 |
|
} catch (XWikiException ex) { |
262 |
0 |
throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, ex); |
263 |
|
} |
264 |
|
} |
265 |
|
|
266 |
|
|
267 |
|
|
268 |
|
|
269 |
|
@param |
270 |
|
@return |
271 |
|
@throws |
272 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
273 |
5 |
public byte[] getFileContentAsBytes(InputStream in) throws DavException... |
274 |
|
{ |
275 |
5 |
try { |
276 |
5 |
return IOUtils.toByteArray(in); |
277 |
|
} catch (IOException ex) { |
278 |
0 |
throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, ex); |
279 |
|
} |
280 |
|
} |
281 |
|
|
282 |
|
|
283 |
|
@link |
284 |
|
|
285 |
|
@param |
286 |
|
@param |
287 |
|
@param |
288 |
|
@throws |
289 |
|
|
|
|
| 79.2% |
Uncovered Elements: 5 (24) |
Complexity: 5 |
Complexity Density: 0.28 |
|
290 |
1 |
public void addAttachment(XWikiDocument doc, byte[] data, String attachmentName) throws DavException... |
291 |
|
{ |
292 |
1 |
int i = attachmentName.indexOf("\\"); |
293 |
1 |
if (i == -1) { |
294 |
1 |
i = attachmentName.indexOf(XWikiDavUtils.URL_SEPARATOR); |
295 |
|
} |
296 |
1 |
String filename = attachmentName.substring(i + 1); |
297 |
|
|
298 |
1 |
XWikiAttachment attachment = doc.getAttachment(filename); |
299 |
1 |
if (attachment == null) { |
300 |
1 |
attachment = new XWikiAttachment(); |
301 |
1 |
doc.getAttachmentList().add(attachment); |
302 |
|
} |
303 |
|
|
304 |
1 |
attachment.setContent(data); |
305 |
1 |
attachment.setFilename(filename); |
306 |
1 |
attachment.setAuthor(xwikiContext.getUser()); |
307 |
|
|
308 |
|
|
309 |
1 |
attachment.setDoc(doc); |
310 |
|
|
311 |
1 |
doc.setAuthor(xwikiContext.getUser()); |
312 |
1 |
if (doc.isNew()) { |
313 |
0 |
doc.setCreator(xwikiContext.getUser()); |
314 |
|
} |
315 |
|
|
316 |
1 |
try { |
317 |
1 |
xwikiContext.getWiki().saveDocument(doc, "[WEBDAV] Attachment " + filename + " added.", xwikiContext); |
318 |
|
} catch (XWikiException ex) { |
319 |
0 |
throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, ex); |
320 |
|
} |
321 |
|
} |
322 |
|
|
323 |
|
|
324 |
|
|
325 |
|
|
326 |
|
@param |
327 |
|
@param |
328 |
|
@param |
329 |
|
@throws |
330 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 2 |
Complexity Density: 0.2 |
|
331 |
0 |
public void moveAttachment(XWikiAttachment attachment, XWikiDocument destinationDoc, String newAttachmentName)... |
332 |
|
throws DavException |
333 |
|
{ |
334 |
0 |
try { |
335 |
|
|
336 |
0 |
XWikiDocument document = attachment.getDoc(); |
337 |
0 |
document.removeAttachment(attachment); |
338 |
0 |
this.xwikiContext.getWiki().saveDocument( |
339 |
|
document, |
340 |
|
"Move attachment [" + attachment.getFilename() + "] to document [" |
341 |
|
+ destinationDoc.getDocumentReference() + "]", this.xwikiContext); |
342 |
|
|
343 |
0 |
attachment.setFilename(newAttachmentName); |
344 |
|
|
345 |
0 |
destinationDoc.getAttachmentList().add(attachment); |
346 |
0 |
attachment.setDoc(destinationDoc); |
347 |
|
|
348 |
0 |
destinationDoc.saveAttachmentContent(attachment, xwikiContext); |
349 |
0 |
xwikiContext.getWiki().saveDocument(destinationDoc, "[WEBDAV] Attachment moved / renamed.", xwikiContext); |
350 |
|
} catch (XWikiException ex) { |
351 |
0 |
throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, ex); |
352 |
|
} |
353 |
|
} |
354 |
|
|
355 |
|
|
356 |
|
|
357 |
|
|
358 |
|
@param |
359 |
|
@throws |
360 |
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
|
361 |
1 |
public void deleteAttachment(XWikiAttachment attachment) throws DavException... |
362 |
|
{ |
363 |
1 |
try { |
364 |
1 |
XWikiDocument document = attachment.getDoc(); |
365 |
|
|
366 |
1 |
document.removeAttachment(attachment); |
367 |
1 |
this.xwikiContext.getWiki().saveDocument(document, "Deleted attachment [" + attachment.getFilename() + "]", |
368 |
|
this.xwikiContext); |
369 |
|
} catch (XWikiException ex) { |
370 |
0 |
throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, ex); |
371 |
|
} |
372 |
|
} |
373 |
|
|
374 |
|
|
375 |
|
|
376 |
|
|
377 |
|
@param |
378 |
|
@return |
379 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
380 |
14 |
public boolean exists(String fullDocName)... |
381 |
|
{ |
382 |
14 |
return xwikiContext.getWiki().exists(fullDocName, xwikiContext); |
383 |
|
} |
384 |
|
|
385 |
|
|
386 |
|
|
387 |
|
|
388 |
|
@param |
389 |
|
@return |
390 |
|
@throws |
391 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
392 |
41 |
public XWikiDocument getDocument(String fullDocName) throws DavException... |
393 |
|
{ |
394 |
41 |
try { |
395 |
41 |
return xwikiContext.getWiki().getDocument(fullDocName, xwikiContext); |
396 |
|
} catch (XWikiException ex) { |
397 |
0 |
throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, ex); |
398 |
|
} |
399 |
|
} |
400 |
|
|
401 |
|
|
402 |
|
|
403 |
|
|
404 |
|
@param |
405 |
|
@return |
406 |
|
@throws |
407 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
408 |
6 |
public String toXML(XWikiDocument document) throws DavException... |
409 |
|
{ |
410 |
6 |
try { |
411 |
6 |
return document.toXML(xwikiContext); |
412 |
|
} catch (XWikiException ex) { |
413 |
0 |
throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, ex); |
414 |
|
} |
415 |
|
} |
416 |
|
|
417 |
|
|
418 |
|
|
419 |
|
|
420 |
|
@param |
421 |
|
@param |
422 |
|
@throws |
423 |
|
|
|
|
| 57.1% |
Uncovered Elements: 3 (7) |
Complexity: 3 |
Complexity Density: 0.6 |
|
424 |
1 |
public void renameDocument(XWikiDocument document, String newDocumentName) throws DavException... |
425 |
|
{ |
426 |
1 |
if (document.isCurrentUserPage(xwikiContext)) { |
427 |
0 |
throw new DavException(DavServletResponse.SC_METHOD_NOT_ALLOWED); |
428 |
|
} else { |
429 |
1 |
try { |
430 |
1 |
document.rename(newDocumentName, xwikiContext); |
431 |
|
} catch (XWikiException ex) { |
432 |
0 |
throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, ex); |
433 |
|
} |
434 |
|
} |
435 |
|
} |
436 |
|
|
437 |
|
|
438 |
|
@link |
439 |
|
|
440 |
|
|
441 |
|
@param |
442 |
|
@return |
443 |
|
@throws |
444 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
445 |
14 |
public List<String> searchDocumentsNames(String sql) throws DavException... |
446 |
|
{ |
447 |
14 |
try { |
448 |
14 |
return xwikiContext.getWiki().getStore().searchDocumentsNames(sql, 0, 0, xwikiContext); |
449 |
|
} catch (XWikiException ex) { |
450 |
0 |
throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, ex); |
451 |
|
} |
452 |
|
} |
453 |
|
|
454 |
|
|
455 |
|
@link |
456 |
|
|
457 |
|
@param |
458 |
|
@param |
459 |
|
@param |
460 |
|
@return |
461 |
|
@throws |
462 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
463 |
0 |
public List<String> searchDocumentsNames(String sql, int nb, int start) throws DavException... |
464 |
|
{ |
465 |
0 |
try { |
466 |
0 |
return xwikiContext.getWiki().getStore().searchDocumentsNames(sql, nb, start, xwikiContext); |
467 |
|
} catch (XWikiException ex) { |
468 |
0 |
throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, ex); |
469 |
|
} |
470 |
|
} |
471 |
|
|
472 |
|
|
473 |
|
@link |
474 |
|
|
475 |
|
@param |
476 |
|
@return |
477 |
|
@throws |
478 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
479 |
0 |
public List<Object> search(String sql) throws DavException... |
480 |
|
{ |
481 |
0 |
try { |
482 |
0 |
return xwikiContext.getWiki().getStore().search(sql, 0, 0, xwikiContext); |
483 |
|
} catch (XWikiException ex) { |
484 |
0 |
throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, ex); |
485 |
|
} |
486 |
|
} |
487 |
|
|
488 |
|
|
489 |
|
|
490 |
|
|
491 |
|
@param |
492 |
|
@throws |
493 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
494 |
11 |
public void saveDocument(XWikiDocument document) throws DavException... |
495 |
|
{ |
496 |
11 |
try { |
497 |
11 |
xwikiContext.getWiki().saveDocument(document, "[WEBDAV] Modified.", xwikiContext); |
498 |
|
} catch (XWikiException ex) { |
499 |
0 |
throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, ex); |
500 |
|
} |
501 |
|
} |
502 |
|
|
503 |
|
|
504 |
|
|
505 |
|
|
506 |
|
@param |
507 |
|
@throws |
508 |
|
|
|
|
| 57.1% |
Uncovered Elements: 3 (7) |
Complexity: 3 |
Complexity Density: 0.6 |
|
509 |
10 |
public void deleteDocument(XWikiDocument document) throws DavException... |
510 |
|
{ |
511 |
10 |
if (document.isCurrentUserPage(xwikiContext)) { |
512 |
0 |
throw new DavException(DavServletResponse.SC_METHOD_NOT_ALLOWED); |
513 |
|
} else { |
514 |
10 |
try { |
515 |
10 |
xwikiContext.getWiki().deleteDocument(document, xwikiContext); |
516 |
|
} catch (XWikiException ex) { |
517 |
0 |
throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, ex); |
518 |
|
} |
519 |
|
} |
520 |
|
} |
521 |
|
|
522 |
|
|
523 |
|
@return |
524 |
|
@throws |
525 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
526 |
32 |
public List<String> getSpaces() throws DavException... |
527 |
|
{ |
528 |
32 |
try { |
529 |
32 |
return xwikiContext.getWiki().getSpaces(xwikiContext); |
530 |
|
} catch (XWikiException ex) { |
531 |
0 |
throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, ex); |
532 |
|
} |
533 |
|
} |
534 |
|
|
535 |
|
|
536 |
|
@return |
537 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
538 |
24 |
public boolean isCreateCollectionRequest()... |
539 |
|
{ |
540 |
24 |
return DavMethods.isCreateCollectionRequest(request); |
541 |
|
} |
542 |
|
|
543 |
|
|
544 |
|
@return |
545 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
546 |
29 |
public boolean isCreateFileRequest()... |
547 |
|
{ |
548 |
29 |
int methodCode = DavMethods.getMethodCode(getMethod()); |
549 |
29 |
return methodCode == DavMethods.DAV_PUT || methodCode == DavMethods.DAV_POST; |
550 |
|
} |
551 |
|
|
552 |
|
|
553 |
|
@return |
554 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
555 |
7 |
public boolean isCreateResourceRequest()... |
556 |
|
{ |
557 |
7 |
return isCreateCollectionRequest() || isCreateFileRequest(); |
558 |
|
} |
559 |
|
|
560 |
|
|
561 |
|
@return |
562 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
563 |
19 |
public boolean isMoveResourceRequest()... |
564 |
|
{ |
565 |
19 |
int methodCode = DavMethods.getMethodCode(getMethod()); |
566 |
19 |
return methodCode == DavMethods.DAV_MOVE; |
567 |
|
} |
568 |
|
|
569 |
|
|
570 |
|
@return |
571 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
572 |
19 |
public boolean isCreateOrMoveRequest()... |
573 |
|
{ |
574 |
19 |
return isMoveResourceRequest() || isCreateResourceRequest(); |
575 |
|
} |
576 |
|
|
577 |
|
|
578 |
|
|
579 |
|
|
580 |
|
@param |
581 |
|
@return |
582 |
|
|
583 |
|
|
|
|
| 36.4% |
Uncovered Elements: 7 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
584 |
1 |
public boolean isMoveAttachmentRequest(XWikiDocument doc)... |
585 |
|
{ |
586 |
1 |
int methodCode = DavMethods.getMethodCode(getMethod()); |
587 |
1 |
if (methodCode == DavMethods.DAV_MOVE) { |
588 |
0 |
String rPath = request.getRequestLocator().getResourcePath(); |
589 |
0 |
rPath = (rPath.endsWith(XWikiDavUtils.URL_SEPARATOR)) ? rPath.substring(0, rPath.length() - 1) : rPath; |
590 |
0 |
String resourceName = rPath.substring(rPath.lastIndexOf(XWikiDavUtils.URL_SEPARATOR) + 1); |
591 |
0 |
return doc.getAttachment(resourceName) != null; |
592 |
|
} |
593 |
1 |
return false; |
594 |
|
} |
595 |
|
|
596 |
|
|
597 |
|
@return |
598 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
599 |
0 |
public boolean isDeleteResourceRequest()... |
600 |
|
{ |
601 |
0 |
int methodCode = DavMethods.getMethodCode(getMethod()); |
602 |
0 |
return methodCode == DavMethods.DAV_DELETE; |
603 |
|
} |
604 |
|
|
605 |
|
|
606 |
|
@return |
607 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
608 |
85 |
public String getMethod()... |
609 |
|
{ |
610 |
85 |
return request.getMethod(); |
611 |
|
} |
612 |
|
|
613 |
|
|
614 |
|
@return |
615 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
616 |
65 |
public String getUser()... |
617 |
|
{ |
618 |
65 |
return xwikiContext.getUser(); |
619 |
|
} |
620 |
|
|
621 |
|
|
622 |
|
@return |
623 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
624 |
0 |
public DavResourceFactory getResourceFactory()... |
625 |
|
{ |
626 |
0 |
return resourceFactory; |
627 |
|
} |
628 |
|
|
629 |
|
|
630 |
|
@return |
631 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
632 |
0 |
public DavSession getDavSession()... |
633 |
|
{ |
634 |
0 |
return davSession; |
635 |
|
} |
636 |
|
|
637 |
|
|
638 |
|
@return |
639 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
640 |
264 |
public LockManager getLockManager()... |
641 |
|
{ |
642 |
264 |
return lockManager; |
643 |
|
} |
644 |
|
|
645 |
|
|
646 |
|
@return |
647 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
648 |
0 |
public XWikiContext getXwikiContext()... |
649 |
|
{ |
650 |
0 |
return xwikiContext; |
651 |
|
} |
652 |
|
|
653 |
|
|
654 |
|
|
655 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 3 |
Complexity Density: 1.5 |
|
656 |
65 |
public void cleanUp()... |
657 |
|
{ |
658 |
65 |
if ((xwikiContext != null) && (xwikiContext.getWiki() != null)) { |
659 |
65 |
xwikiContext.getWiki().getStore().cleanUp(xwikiContext); |
660 |
|
} |
661 |
|
} |
662 |
|
} |