1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package com.xpn.xwiki.plugin.webdav.utils

File XWikiDavContext.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart7.png
64% of files have more coverage

Code metrics

32
151
35
1
662
359
70
0.46
4.31
35
2

Classes

Class Line # Actions
XWikiDavContext 68 151 0% 70 65
0.7018348670.2%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
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    * Holds context information about a webdav request.
63    * <p>
64    * TODO: Get rid of this class (Move to components).
65    *
66    * @version $Id: 198ad22c450440f920c6ad8035d51a89bee114bb $
67    */
 
68    public class XWikiDavContext
69    {
70    /**
71    * Logger instance.
72    */
73    private static final Logger LOGGER = LoggerFactory.getLogger(XWikiDavContext.class);
74   
75    /**
76    * Global per-user based storage.
77    */
78    private static Cache<XWikiDavUserStorage> davCache;
79   
80    /**
81    * Dav request.
82    */
83    private DavServletRequest request;
84   
85    /**
86    * XWiki context.
87    */
88    private XWikiContext xwikiContext;
89   
90    /**
91    * DAV resource factory.
92    */
93    private DavResourceFactory resourceFactory;
94   
95    /**
96    * DAV session.
97    */
98    private DavSession davSession;
99   
100    /**
101    * Lock manager.
102    */
103    private LockManager lockManager;
104   
105    /**
106    * Creates a new xwiki webdav context.
107    *
108    * @param request dav request.
109    * @param response dav response.
110    * @param servletContext servlet context.
111    * @param resourceFactory dav resource factory.
112    * @param davSession dav session.
113    * @param lockManager lock manager.
114    * @throws DavException if an error occurs while initializing the xwiki context.
115    */
 
116  84 toggle 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    // Initialize XWikiContext.
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    // Initialize the cache.
161  84 if (null == davCache) {
162  1 initCache();
163    }
164    }
165   
166    /**
167    * Initializes global webdav cache.
168    *
169    * @throws DavException if an error occurs while initializing the cache.
170    */
 
171  1 toggle 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    * Returns the session storage allocated for the current user.
187    *
188    * @return Session storage.
189    */
 
190  1062 toggle 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    * Returns if the user (in the context) has the given access level on the document in question.
201    *
202    * @param right Access level.
203    * @param fullDocName Name of the document.
204    * @return True if the user has the given access level for the document in question, false otherwise.
205    */
 
206  31 toggle 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    * Validates if the user (in the context) has the given access level on the document in question, if not, throws a
225    * {@link DavException}.
226    *
227    * @param right Access level.
228    * @param fullDocName Name of the document.
229    * @throws DavException If the user doesn't have enough access rights on the given document or if the access
230    * verification code fails.
231    */
 
232  22 toggle 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    * Returns the mime type of the given attachment.
241    *
242    * @param attachment xwiki attachment.
243    * @return a mime type string.
244    */
 
245  3 toggle public String getMimeType(XWikiAttachment attachment)
246    {
247  3 return attachment.getMimeType(xwikiContext);
248    }
249   
250    /**
251    * Returns the content of the attachment.
252    *
253    * @param attachment xwiki attachment.
254    * @return attachment content as a byte array.
255    * @throws DavException if an error occurs while reading the attachment.
256    */
 
257  1 toggle 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    * Utility method for reading a given input stream into a byte array.
268    *
269    * @param in input stream.
270    * @return a byte array holding data from the given stream.
271    * @throws DavException if an error occurs while reading the input stream.
272    */
 
273  5 toggle 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    * Adds an attachment to the {@link XWikiDocument} represented by this resource.
284    *
285    * @param attachmentName Name of this attachment.
286    * @param data Data to be put into the attachment (file content).
287    * @param doc The document to which the attachment is made.
288    * @throws DavException Indicates an internal error.
289    */
 
290  1 toggle 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    // Add the attachment to the document
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    * Moves the given attachment under the target document.
325    *
326    * @param attachment xwiki attachment.
327    * @param destinationDoc target document.
328    * @param newAttachmentName new attachment name.
329    * @throws DavException if an error occurs while accessing the wiki.
330    */
 
331  0 toggle public void moveAttachment(XWikiAttachment attachment, XWikiDocument destinationDoc, String newAttachmentName)
332    throws DavException
333    {
334  0 try {
335    // Delete the current attachment
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    // Rename the (in memory) attachment.
343  0 attachment.setFilename(newAttachmentName);
344    // Add the attachment to destination doc.
345  0 destinationDoc.getAttachmentList().add(attachment);
346  0 attachment.setDoc(destinationDoc);
347    // Save the attachment.
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    * Deletes the given attachment from it's document.
357    *
358    * @param attachment xwiki attachment.
359    * @throws DavException if an error occurs while accessing the wiki.
360    */
 
361  1 toggle 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    * Checks whether the specified xwiki document exists or not.
376    *
377    * @param fullDocName name of the document.
378    * @return true if the documents exists.
379    */
 
380  14 toggle public boolean exists(String fullDocName)
381    {
382  14 return xwikiContext.getWiki().exists(fullDocName, xwikiContext);
383    }
384   
385    /**
386    * Finds the xwiki document matching the given document name.
387    *
388    * @param fullDocName name of the xwiki document.
389    * @return xwiki document matching the given document name.
390    * @throws DavException if an error occurs while accessing the wiki.
391    */
 
392  41 toggle 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    * Converts the given xwiki document into an xml representation.
403    *
404    * @param document xwiki document.
405    * @return the xml representation of the document.
406    * @throws DavException if an error occurs while accessing the wiki.
407    */
 
408  6 toggle 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    * Renames the given xwiki document into the new document name provided.
419    *
420    * @param document xwiki document to be renamed.
421    * @param newDocumentName new document name.
422    * @throws DavException if an error occurs while accessing the wiki.
423    */
 
424  1 toggle 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    * A shortcut to {@link com.xpn.xwiki.store.XWikiStoreInterface#searchDocumentsNames(String, int, int, XWikiContext)}, returns all the
439    * results found.
440    *
441    * @param sql the HQL query string.
442    * @return document names matching the given criterion.
443    * @throws DavException if an error occurs while accessing the wiki.
444    */
 
445  14 toggle 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    * A shortcut to {@link com.xpn.xwiki.store.XWikiStoreInterface#searchDocumentsNames(String, int, int, XWikiContext)}.
456    *
457    * @param sql the HQL where clause.
458    * @param nb number of results expected.
459    * @param start offset.
460    * @return document names matching the given criterion.
461    * @throws DavException if an error occurs while accessing the wiki.
462    */
 
463  0 toggle 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    * A shortcut to {@link com.xpn.xwiki.store.XWikiStoreInterface#search(String, int, int, XWikiContext)}.
474    *
475    * @param sql the HQL query.
476    * @return search results.
477    * @throws DavException if an error occurs while accessing the wiki.
478    */
 
479  0 toggle 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    * Saves the given xwiki document into current xwiki.
490    *
491    * @param document xwiki document to be saved.
492    * @throws DavException if an error occurs while accessing the wiki.
493    */
 
494  11 toggle 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    * Deletes the specified xwiki document from the current xwiki.
505    *
506    * @param document the xwiki document.
507    * @throws DavException if an error occurs while accessing the wiki.
508    */
 
509  10 toggle 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 a list of spaces available in the current xwiki.
524    * @throws DavException if an error occurs while accessing the wiki.
525    */
 
526  32 toggle 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 true if the current webdav request is trying to create a collection resource (DAV_MKCOL).
537    */
 
538  24 toggle public boolean isCreateCollectionRequest()
539    {
540  24 return DavMethods.isCreateCollectionRequest(request);
541    }
542   
543    /**
544    * @return true if the current webdav request is trying to create a file resource (DAV_PUT or DAV_POST).
545    */
 
546  29 toggle 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 true if the current webdav request is trying to create a resource.
554    */
 
555  7 toggle public boolean isCreateResourceRequest()
556    {
557  7 return isCreateCollectionRequest() || isCreateFileRequest();
558    }
559   
560    /**
561    * @return true if the current webdav request is trying to move (rename) a resource.
562    */
 
563  19 toggle public boolean isMoveResourceRequest()
564    {
565  19 int methodCode = DavMethods.getMethodCode(getMethod());
566  19 return methodCode == DavMethods.DAV_MOVE;
567    }
568   
569    /**
570    * @return true if the current webdav request is trying to create or move (rename) a resource.
571    */
 
572  19 toggle public boolean isCreateOrMoveRequest()
573    {
574  19 return isMoveResourceRequest() || isCreateResourceRequest();
575    }
576   
577    /**
578    * Utility method for checking whether the current webdav request is trying to move / rename an attachment.
579    *
580    * @param doc the xwiki document to which the attachment belongs to.
581    * @return true if the current webdav request is about moving (or renaming) an attachment from the given xwiki
582    * document.
583    */
 
584  1 toggle 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 true if the current webdav request is a DAV_DELETE request.
598    */
 
599  0 toggle public boolean isDeleteResourceRequest()
600    {
601  0 int methodCode = DavMethods.getMethodCode(getMethod());
602  0 return methodCode == DavMethods.DAV_DELETE;
603    }
604   
605    /**
606    * @return name of the webdav method executed by the current request.
607    */
 
608  85 toggle public String getMethod()
609    {
610  85 return request.getMethod();
611    }
612   
613    /**
614    * @return current xwiki user name.
615    */
 
616  65 toggle public String getUser()
617    {
618  65 return xwikiContext.getUser();
619    }
620   
621    /**
622    * @return dav resource factory.
623    */
 
624  0 toggle public DavResourceFactory getResourceFactory()
625    {
626  0 return resourceFactory;
627    }
628   
629    /**
630    * @return the dav session.
631    */
 
632  0 toggle public DavSession getDavSession()
633    {
634  0 return davSession;
635    }
636   
637    /**
638    * @return global lock manager.
639    */
 
640  264 toggle public LockManager getLockManager()
641    {
642  264 return lockManager;
643    }
644   
645    /**
646    * @return the internal xwiki context.
647    */
 
648  0 toggle public XWikiContext getXwikiContext()
649    {
650  0 return xwikiContext;
651    }
652   
653    /**
654    * Release any resources acquired.
655    */
 
656  65 toggle public void cleanUp()
657    {
658  65 if ((xwikiContext != null) && (xwikiContext.getWiki() != null)) {
659  65 xwikiContext.getWiki().getStore().cleanUp(xwikiContext);
660    }
661    }
662    }