1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.bridge

File DocumentAccessBridge.java

 

Coverage histogram

../../../img/srcFileCovDistChart0.png
83% of files have more coverage

Code metrics

0
1
1
1
681
108
1
1
1
1
1

Classes

Class Line # Actions
DocumentAccessBridge 40 1 0% 1 2
0.00%
 

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 org.xwiki.bridge;
21   
22    import java.io.InputStream;
23    import java.util.List;
24    import java.util.Map;
25   
26    import org.xwiki.component.annotation.Role;
27    import org.xwiki.model.reference.AttachmentReference;
28    import org.xwiki.model.reference.DocumentReference;
29    import org.xwiki.model.reference.ObjectPropertyReference;
30    import org.xwiki.model.reference.ObjectReference;
31   
32    /**
33    * Exposes methods for accessing Document data. This is temporary until we remodel the Model classes and the Document
34    * services.
35    *
36    * @version $Id: afbb5e3d18beb9f28aa3d007c3f8c7573428fc60 $
37    * @since 1.6M1
38    */
39    @Role
 
40    public interface DocumentAccessBridge
41    {
42    /**
43    * Get the document object associated with the passed document name.
44    *
45    * @param documentReference the String reference of the document to find
46    * @return the document object matching the passed document name
47    * @throws Exception when the storage cannot be accessed
48    * @deprecated use {@link #getDocument(org.xwiki.model.reference.DocumentReference)} instead
49    */
50    @Deprecated
51    DocumentModelBridge getDocument(String documentReference) throws Exception;
52   
53    /**
54    * Get the document object associated with the passed document name.
55    *
56    * @param documentReference the name of the document to find
57    * @return the document object matching the passed document name
58    * @throws Exception when the storage cannot be accessed
59    * @since 2.2M1
60    */
61    DocumentModelBridge getDocument(DocumentReference documentReference) throws Exception;
62   
63    /**
64    * Get the reference to the current document (found in the Context).
65    *
66    * @return the reference to the current document
67    * @since 2.2M1
68    */
69    DocumentReference getCurrentDocumentReference();
70   
71    /**
72    * Check if a document exists or not in the wiki.
73    *
74    * @param documentReference The reference of the document to check.
75    * @return <code>true</code> if the document already exists, <code>false</code> otherwise.
76    * @since 2.2.1
77    */
78    boolean exists(DocumentReference documentReference);
79   
80    /**
81    * Check if a document exists or not in the wiki.
82    *
83    * @param documentReference The reference of the document to check.
84    * @return <code>true</code> if the document already exists, <code>false</code> otherwise.
85    * @deprecated replaced by {@link #exists(DocumentReference)} since 2.2.1
86    */
87    @Deprecated
88    boolean exists(String documentReference);
89   
90    /**
91    * Updates the target document with the new content provided. If the target document does not exists, a new one will
92    * be created.
93    *
94    * @param documentReference the reference to the target document
95    * @param content Content to be set.
96    * @param editComment Comment describing this particular change.
97    * @param isMinorEdit Flag indicating if this change is a minor one.
98    * @throws Exception if the storage cannot be accessed.
99    * @since 2.2.1
100    */
101    void setDocumentContent(DocumentReference documentReference, String content, String editComment,
102    boolean isMinorEdit) throws Exception;
103   
104    /**
105    * Updates the target document with the new content provided. If the target document does not exists, a new one will
106    * be created.
107    *
108    * @param documentReference the reference to the target document
109    * @param content Content to be set.
110    * @param editComment Comment describing this particular change.
111    * @param isMinorEdit Flag indicating if this change is a minor one.
112    * @throws Exception if the storage cannot be accessed.
113    * @deprecated replaced by {@link #setDocumentContent(DocumentReference, String, String, boolean)} since 2.2.1
114    */
115    @Deprecated
116    void setDocumentContent(String documentReference, String content, String editComment, boolean isMinorEdit)
117    throws Exception;
118   
119    /**
120    * Retrieves the textual content of the document, in the current language.
121    *
122    * @param documentReference the reference of the document to access
123    * @return The document's content.
124    * @throws Exception If the document cannot be accessed.
125    * @deprecated replaced by {@link #getDocument(DocumentReference)} and {@link DocumentModelBridge#getContent()}
126    * since 2.2.1
127    */
128    @Deprecated
129    String getDocumentContent(String documentReference) throws Exception;
130   
131    /**
132    * Get the syntax Id of the target document. If the target document does not exists, the default syntax of a new
133    * document is returned.
134    *
135    * @param documentReference the reference of the target document
136    * @return the syntax id.
137    * @throws Exception If the storage cannot be accessed.
138    * @deprecated replaced by {@link #getDocument(DocumentReference)} and {@link DocumentModelBridge#getSyntaxId()}
139    * since 2.2.1
140    */
141    @Deprecated
142    String getDocumentSyntaxId(String documentReference) throws Exception;
143   
144    /**
145    * Changes the syntax Id of the target document to the given syntaxId. If the target document does not exists, a new
146    * one will be created.
147    *
148    * @param documentReference the reference of the target document
149    * @param syntaxId New syntax Id.
150    * @throws Exception If the storage cannot be accessed.
151    * @since 2.2.1
152    */
153    void setDocumentSyntaxId(DocumentReference documentReference, String syntaxId) throws Exception;
154   
155    /**
156    * Changes the syntax Id of the target document to the given syntaxId. If the target document does not exists, a new
157    * one will be created.
158    *
159    * @param documentReference the reference of the target document
160    * @param syntaxId New syntax Id.
161    * @throws Exception If the storage cannot be accessed.
162    * @deprecated replaced by {@link #setDocumentSyntaxId(DocumentReference, String)} since 2.2.1
163    */
164    @Deprecated
165    void setDocumentSyntaxId(String documentReference, String syntaxId) throws Exception;
166   
167    /**
168    * Sets the parent document name attribute for this document.
169    *
170    * @param documentReference the reference of the target document
171    * @param parentReference name of the parent document.
172    * @throws Exception If the storage cannot be accessed.
173    * @since 2.2
174    */
175    void setDocumentParentReference(DocumentReference documentReference, DocumentReference parentReference)
176    throws Exception;
177   
178    /**
179    * Sets the title of this document.
180    *
181    * @param documentReference the reference of the target document
182    * @param title the title to be set.
183    * @throws Exception If the storage cannot be accessed.
184    * @since 2.2
185    */
186    void setDocumentTitle(DocumentReference documentReference, String title) throws Exception;
187   
188    /**
189    * Retrieves the textual content of the document, in the document's default language.
190    * <p>
191    * Note: you should always use {@link #getDocumentContent(String)} unless you really need specifically the
192    * document's content for default language of the document.
193    *
194    * @param documentReference the reference of the document to access
195    * @return The document's content.
196    * @throws Exception If the document cannot be accessed.
197    * @since 2.2.1
198    */
199    String getDocumentContentForDefaultLanguage(DocumentReference documentReference) throws Exception;
200   
201    /**
202    * Retrieves the textual content of the document, in the document's default language.
203    * <p>
204    * Note: you should always use {@link #getDocumentContent(String)} unless you really need specifically the
205    * document's content for default language of the document.
206    *
207    * @param documentReference the reference of the document to access
208    * @return The document's content.
209    * @throws Exception If the document cannot be accessed.
210    * @deprecated replaced by {@link #getDocumentContentForDefaultLanguage(DocumentReference)} since 2.2.1
211    */
212    @Deprecated
213    String getDocumentContentForDefaultLanguage(String documentReference) throws Exception;
214   
215    /**
216    * Retrieves the textual content of the document, in the given language.
217    *
218    * @param documentReference the referenc of the document to access
219    * @param language The desired translation of the document.
220    * @return The document's content.
221    * @throws Exception If the document cannot be accessed.
222    * @since 2.2.1
223    */
224    String getDocumentContent(DocumentReference documentReference, String language) throws Exception;
225   
226    /**
227    * Retrieves the textual content of the document, in the given language.
228    *
229    * @param documentReference the referenc of the document to access
230    * @param language The desired translation of the document.
231    * @return The document's content.
232    * @throws Exception If the document cannot be accessed.
233    * @deprecated replaced by {@link #getDocumentContent(DocumentReference, String)} since 2.2.1
234    */
235    @Deprecated
236    String getDocumentContent(String documentReference, String language) throws Exception;
237   
238    /**
239    * Get the number of the first object that has a property that match the expectation.
240    *
241    * @param documentReference the reference of the document to look for objects into
242    * @param classReference the reference of the class to look objects of
243    * @param parameterName the name of the parameter to check the value for
244    * @param valueToMatch the value to match for this parameter
245    * @return the number of the first matching object, or -1 if none found
246    */
247    int getObjectNumber(DocumentReference documentReference, DocumentReference classReference,
248    String parameterName, String valueToMatch);
249   
250    /**
251    * Retrieves the value for an object property.
252    *
253    * @param documentReference the reference of the document to access
254    * @param className The name of the class.
255    * @param objectNumber The number of the object from the given class.
256    * @param propertyName The name of the property to retrieve.
257    * @return the property value or null if it doesn't exist or an error occurred while looking for the property (the
258    * document doesn't exist for example)
259    */
260    Object getProperty(String documentReference, String className, int objectNumber, String propertyName);
261   
262    /**
263    * Retrieves the value for an object property, from the first object of the given class.
264    *
265    * @param documentReference the reference of the document to access
266    * @param className The name of the class.
267    * @param propertyName The name of the property to retrieve.
268    * @return the property value or null if it doesn't exist or an error occurred while looking for the property (the
269    * document doesn't exist for example)
270    * @deprecated since 2.2M1 use {@link #getProperty(DocumentReference, DocumentReference, String)} instead
271    */
272    @Deprecated
273    Object getProperty(String documentReference, String className, String propertyName);
274   
275    /**
276    * Retrieves the value for an object property.
277    *
278    * @param objectReference the reference of the object to access
279    * @param propertyName The name of the property to retrieve.
280    * @return the property value or null if it doesn't exist or an error occurred while looking for the property (the
281    * document doesn't exist for example)
282    * @since 3.2M3
283    */
284    Object getProperty(ObjectReference objectReference, String propertyName);
285   
286    /**
287    * Retrieves the value for an object property.
288    *
289    * @param objectPropertyReference the reference of the property to access
290    * @return the property value or null if it doesn't exist or an error occurred while looking for the property (the
291    * document doesn't exist for example)
292    * @since 3.2M3
293    */
294    Object getProperty(ObjectPropertyReference objectPropertyReference);
295   
296    /**
297    * Retrieves the value for an object property, from the first object of the given class.
298    *
299    * @param documentReference the reference of the document to access
300    * @param classReference the reference to the XWiki Class
301    * @param propertyName The name of the property to retrieve.
302    * @return the property value or null if it doesn't exist or an error occurred while looking for the property (the
303    * document doesn't exist for example)
304    * @since 2.2M1
305    */
306    Object getProperty(DocumentReference documentReference, DocumentReference classReference, String propertyName);
307   
308    /**
309    * Retrieves the value for an object property, from the Nth object of the given class.
310    *
311    * @param documentReference the reference of the document to access
312    * @param classReference the reference to the XWiki Class
313    * @param objectNumber the number of the object to get the property for
314    * @param propertyName The name of the property to retrieve.
315    * @return the property value or null if it doesn't exist or an error occurred while looking for the property (the
316    * document doesn't exist for example)
317    * @since 3.2M3
318    */
319    Object getProperty(DocumentReference documentReference, DocumentReference classReference, int objectNumber,
320    String propertyName);
321   
322    /**
323    * Retrieves the value for an object property, from the first object of any class that has a property with that
324    * name.
325    *
326    * @param documentReference the reference of the document to access
327    * @param propertyName The name of the property to retrieve.
328    * @return the property value or null if it doesn't exist or an error occurred while looking for the property (the
329    * document doesn't exist for example)
330    */
331    Object getProperty(String documentReference, String propertyName);
332   
333    /**
334    * @param documentReference the reference of the document to access
335    * @param className the name of the class in the passed document from which to get the properties
336    * @return the list of properties available in the passed document and class names
337    */
338    List<Object> getProperties(String documentReference, String className);
339   
340    /**
341    * @param className The name of the class.
342    * @param propertyName The name of the property.
343    * @return class name of the property object or null if property is not found. For example StringProperty,
344    * IntegerProperty.
345    * @throws Exception if class cannot be accessed
346    */
347    String getPropertyType(String className, String propertyName) throws Exception;
348   
349    /**
350    * @param className The name of the class.
351    * @param propertyName The name of the property of the class.
352    * @return is the property stored in a special custom mapped class.
353    * @throws Exception if class cannot be accessed
354    */
355    boolean isPropertyCustomMapped(String className, String propertyName) throws Exception;
356   
357    /**
358    * Sets the given property of the first object (of the given class) attached to the document. If no such object
359    * exists, this method will create a new object of the given class, attach it to the document and set the property.
360    *
361    * @param documentReference the reference of the document to access
362    * @param className name of the class.
363    * @param propertyName name of the property to set.
364    * @param propertyValue value of the property to set.
365    * @throws Exception if the document cannot be accessed.
366    * @deprecated use {@link DocumentAccessBridge#setProperty(DocumentReference, DocumentReference, String, Object)}
367    */
368    @Deprecated
369    void setProperty(String documentReference, String className, String propertyName, Object propertyValue)
370    throws Exception;
371   
372    /**
373    * Sets the given property of the first object (of the given class) attached to the document. If no such object
374    * exists, this method will create a new object of the given class, attach it to the document and set the property.
375    *
376    * @param documentReference the reference of the document to access
377    * @param classReference the reference of the class.
378    * @param propertyName name of the property to set.
379    * @param propertyValue value of the property to set.
380    * @throws Exception if the document cannot be accessed.
381    */
382    void setProperty(DocumentReference documentReference, DocumentReference classReference, String propertyName,
383    Object propertyValue) throws Exception;
384   
385    /**
386    * Returns the content of a document attachment.
387    *
388    * @param documentReference the reference of the document to access
389    * @param attachmentName The filename of the attachment to access.
390    * @return The content of the attachment, as an array of <code>byte</code>s, which is empty if the attachment does
391    * not exist.
392    * @throws Exception If the document cannot be accessed.
393    * @deprecated use {@link #getAttachmentContent(org.xwiki.model.reference.AttachmentReference)} instead
394    */
395    @Deprecated
396    byte[] getAttachmentContent(String documentReference, String attachmentName) throws Exception;
397   
398    /**
399    * Returns the content of a document attachment.
400    *
401    * @param attachmentReference the name of the attachment to access
402    * @return The content of the attachment, as an array of <code>byte</code>s, which is empty if the attachment does
403    * not exist
404    * @throws Exception If the document cannot be accessed.
405    * @since 2.2M1
406    */
407    InputStream getAttachmentContent(AttachmentReference attachmentReference) throws Exception;
408   
409    /**
410    * Sets the content of a document attachment. If the document or the attachment does not exist, both will be created
411    * newly.
412    *
413    * @param attachmentReference the name of the attachment to access
414    * @param attachmentData Attachment content.
415    * @throws Exception If the storage cannot be accessed.
416    * @since 2.2.1
417    */
418    void setAttachmentContent(AttachmentReference attachmentReference, byte[] attachmentData) throws Exception;
419   
420    /**
421    * Sets the content of a document attachment. If the document or the attachment does not exist, both will be created
422    * newly.
423    *
424    * @param documentReference the reference to the target document name
425    * @param attachmentFilename the name of the attachment
426    * @param attachmentData Attachment content.
427    * @throws Exception If the storage cannot be accessed.
428    * @deprecated replaced by {@link #getAttachmentContent(AttachmentReference)} since 2.2.1
429    */
430    @Deprecated
431    void setAttachmentContent(String documentReference, String attachmentFilename, byte[] attachmentData)
432    throws Exception;
433   
434    /**
435    * Returns the current version of a document attachment.
436    *
437    * @param attachmentReference identifies the attachment to access
438    * @return the current version of the specified attachment, {@code null} if the attachment does not exist
439    * @throws Exception if the document cannot be accessed
440    * @since 2.5M2
441    */
442    String getAttachmentVersion(AttachmentReference attachmentReference) throws Exception;
443   
444    /**
445    * Retrieves the internal (without the hostname) URL that can be used to access a document, using a specific action.
446    *
447    * @param documentReference the reference of the document to access
448    * @param action The "mode" in which the document is accessed, for example <code>view</code> to view the document,
449    * <code>edit</code> to open the document for modifications, etc.
450    * @param queryString An optional query string to append to the URL, use <code>null</code> or an empty string to
451    * skip.
452    * @param anchor An optional URL fragment to append to the URL, use <code>null</code> or an empty string to skip.
453    * @return A <code>String</code> representation of the URL, starting with the path segment of the URL (without
454    * protocol, host and port), for example <code>/xwiki/bin/save/Main/WebHome?content=abc</code>.
455    * @since 2.2.1
456    */
457    String getDocumentURL(DocumentReference documentReference, String action, String queryString, String anchor);
458   
459    /**
460    * Retrieves the relitive (without the hostname) or absolute (with the hostname) URL that can be used to access
461    * a document, using a specific action.
462    *
463    * @param documentReference the reference of the document to access
464    * @param action The "mode" in which the document is accessed, for example <code>view</code> to view the document,
465    * <code>edit</code> to open the document for modifications, etc.
466    * @param queryString An optional query string to append to the URL, use <code>null</code> or an empty string to
467    * skip.
468    * @param anchor An optional URL fragment to append to the URL, use <code>null</code> or an empty string to skip.
469    * @param isFullURL if true then the URL will be an absolute URL which contains the host name, and protocol.
470    * @return A <code>String</code> representation of the URL, starting with the path segment of the URL (without
471    * protocol, host and port), for example <code>/xwiki/bin/save/Main/WebHome?content=abc</code>.
472    * @since 2.5M1
473    */
474    String getDocumentURL(DocumentReference documentReference,
475    String action,
476    String queryString,
477    String anchor,
478    boolean isFullURL);
479   
480    /**
481    * Retrieves the internal (without the hostname) URL that can be used to access a document, using a specific action.
482    *
483    * @param documentReference the reference of the document to access
484    * @param action The "mode" in which the document is accessed, for example <code>view</code> to view the document,
485    * <code>edit</code> to open the document for modifications, etc.
486    * @param queryString An optional query string to append to the URL, use <code>null</code> or an empty string to
487    * skip.
488    * @param anchor An optional URL fragment to append to the URL, use <code>null</code> or an empty string to skip.
489    * @return A <code>String</code> representation of the URL, starting with the path segment of the URL (without
490    * protocol, host and port), for example <code>/xwiki/bin/save/Main/WebHome?content=abc</code>.
491    * @deprecated replaced by {@link #getDocumentURL(DocumentReference, String, String, String)} since 2.2.1
492    */
493    @Deprecated
494    String getURL(String documentReference, String action, String queryString, String anchor);
495   
496    /**
497    * Retrieves all attachments in the passed document.
498    *
499    * @param documentReference the reference to the document for which to retrieve all attachment references
500    * @return the list of attachment names in the passed document
501    * @throws Exception in case of a storage issue finding all attachments for the document matching the passed name
502    * @since 2.2M1
503    */
504    List<AttachmentReference> getAttachmentReferences(DocumentReference documentReference) throws Exception;
505   
506    /**
507    * Retrieves the relative URL (ie the path without the hostname and port) that can be used to access an attachment.
508    *
509    * @param documentReference the reference to the document containing the attachment (eg "wiki:Space.Page")
510    * @param attachmentFilename the attachment name (eg "my.png")
511    * @return the attachment URL
512    * @deprecated use {@link #getAttachmentURL(org.xwiki.model.reference.AttachmentReference , boolean)} instead
513    */
514    @Deprecated
515    String getAttachmentURL(String documentReference, String attachmentFilename);
516   
517    /**
518    * Retrieves the URL (either relative ie the path without the hostname and port, or the full URL) that can be used
519    * to access an attachment.
520    *
521    * @param attachmentReference the attachment name for which to find the URL
522    * @param isFullURL whether the returned URL will a relative URL or the full URL
523    * @return the attachment URL
524    * @since 2.2M1
525    */
526    String getAttachmentURL(AttachmentReference attachmentReference, boolean isFullURL);
527   
528    /**
529    * Retrieves the URL (either relative ie the path without the hostname and port, or the full URL) that can be used
530    * to access an attachment.
531    *
532    * @param attachmentReference the attachment name for which to find the URL
533    * @param queryString An optional query string to append to the URL, use <code>null</code> or an empty string to
534    * skip.
535    * @param isFullURL whether the returned URL will a relative URL or the full URL
536    * @return the attachment URL
537    * @since 2.5RC1
538    */
539    String getAttachmentURL(AttachmentReference attachmentReference, String queryString, boolean isFullURL);
540   
541    /**
542    * @param documentReference the document for which to retrieve all attachment URLs
543    * @param isFullURL whether the returned URL will a relative URL or the full URL
544    * @return the list of attachment URLs (either relative ie the path without the hostname and port, or the full URL)
545    * for all attachments in the passed document
546    * @throws Exception in case of a storage issue finding all attachments for the document matching the passed name
547    * @deprecated use {@link #getAttachmentReferences(org.xwiki.model.reference.DocumentReference)} instead
548    * @since 2.2M1
549    */
550    @Deprecated
551    List<String> getAttachmentURLs(DocumentReference documentReference, boolean isFullURL) throws Exception;
552   
553    /**
554    * @param documentReference the reference of the document to access
555    * @return true if current user can view provided document.
556    * @since 2.2.1
557    * @deprecated since 6.1, use
558    * {@link org.xwiki.security.authorization.ContextualAuthorizationManager#checkAccess(org.xwiki.security.authorization.Right, org.xwiki.model.reference.EntityReference)}
559    * with {@link org.xwiki.security.authorization.Right#VIEW} instead
560    */
561    @Deprecated
562    boolean isDocumentViewable(DocumentReference documentReference);
563   
564    /**
565    * @param documentReference the reference of the document to access
566    * @return true if current user can view provided document.
567    * @deprecated use {@link #isDocumentViewable(org.xwiki.model.reference.DocumentReference)} instead
568    */
569    @Deprecated
570    boolean isDocumentViewable(String documentReference);
571   
572    /**
573    * @param documentReference the reference of the document to be edited
574    * @return True if current user has 'edit' access on the target document.
575    * @deprecated use {@link #isDocumentEditable(org.xwiki.model.reference.DocumentReference)} instead
576    */
577    @Deprecated
578    boolean isDocumentEditable(String documentReference);
579   
580    /**
581    * @param documentReference the name of the document to be edited.
582    * @return True if current user has 'edit' access on the target document.
583    * @since 2.2M1
584    * @deprecated since 6.1, use
585    * {@link org.xwiki.security.authorization.ContextualAuthorizationManager#checkAccess(org.xwiki.security.authorization.Right, org.xwiki.model.reference.EntityReference)}
586    * with {@link org.xwiki.security.authorization.Right#EDIT} instead
587    */
588    @Deprecated
589    boolean isDocumentEditable(DocumentReference documentReference);
590   
591    /**
592    * @return true if the current document's author has programming rights.
593    * @deprecated since 6.1RC1, use
594    * {@link org.xwiki.security.authorization.ContextualAuthorizationManager#hasAccess(org.xwiki.security.authorization.Right)}
595    * instead
596    */
597    @Deprecated
598    boolean hasProgrammingRights();
599   
600    /**
601    * Utility method to retrieve the current user.
602    *
603    * @return the current user full reference.
604    * @deprecated replaced by {@link org.xwiki.bridge.DocumentAccessBridge#getCurrentUserReference()} since 4.0RC1
605    */
606    @Deprecated
607    String getCurrentUser();
608   
609    /**
610    * Utility method to retrieve the current user document reference.
611    *
612    * @return the current user document reference.
613    * @since 4.0RC1
614    */
615    DocumentReference getCurrentUserReference();
616   
617    /**
618    * Utility method to set the current user.
619    *
620    * @param userName the current user
621    * @since 2.4M2
622    */
623    void setCurrentUser(String userName);
624   
625    /**
626    * @return The default encoding for the current wiki.
627    */
628    String getDefaultEncoding();
629   
630    /**
631    * Sets the passed document as the current document in the XWiki Context and saves current values related to the
632    * current document into a backup object.
633    *
634    * @param backupObjects the object in which to some context properties will be saved
635    * @param documentReference the reference to the document to set as the current document
636    * @throws Exception in case of an error like a problem loading the document from the database
637    * @deprecated use {@link #pushDocumentInContext(Map, DocumentReference)} instead
638    */
639    @Deprecated
640    void pushDocumentInContext(Map<String, Object> backupObjects, String documentReference) throws Exception;
641   
642    /**
643    * Sets the passed document as the current document in the XWiki Context and saves current values related to the
644    * current document into a backup object.
645    *
646    * @param backupObjects the object in which to some context properties will be saved
647    * @param documentReference the reference to the document to set as the current document
648    * @throws Exception in case of an error like a problem loading the document from the database
649    * @since 2.2.1
650    */
651    void pushDocumentInContext(Map<String, Object> backupObjects, DocumentReference documentReference) throws Exception;
652   
653    /**
654    * Sets the passed document as the current document in the XWiki Context and saves current values related to the
655    * current document into a backup object.
656    *
657    * @param backupObjects the object in which to some context properties will be saved
658    * @param document the document to set as the current document
659    * @throws Exception in case of an error like a problem loading the document from the database
660    * @since 8.4M1
661    */
 
662  0 toggle default void pushDocumentInContext(Map<String, Object> backupObjects, DocumentModelBridge document) throws Exception
663    {
664  0 pushDocumentInContext(backupObjects, document.getDocumentReference());
665    }
666   
667    /**
668    * Restore values saved in a backup object in the XWiki Context and restore the current document with the same value
669    * before {@link #pushDocumentInContext(Map, String)} was called.
670    *
671    * @param backupObjects the object containing the backed-up context properties to restore
672    */
673    void popDocumentFromContext(Map<String, Object> backupObjects);
674   
675    /**
676    * @return the current wiki
677    * @deprecated replaced by {@link org.xwiki.model.ModelContext#getCurrentEntityReference()} since 2.2M1
678    */
679    @Deprecated
680    String getCurrentWiki();
681    }