1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package com.xpn.xwiki.store

File XWikiRecycleBinStoreInterface.java

 

Coverage histogram

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

Code metrics

0
8
8
1
235
61
8
1
1
8
1

Classes

Class Line # Actions
XWikiRecycleBinStoreInterface 38 8 0% 8 16
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 com.xpn.xwiki.store;
21   
22    import java.util.Date;
23   
24    import org.xwiki.component.annotation.Role;
25   
26    import com.xpn.xwiki.XWikiContext;
27    import com.xpn.xwiki.XWikiException;
28    import com.xpn.xwiki.doc.XWikiDeletedDocument;
29    import com.xpn.xwiki.doc.XWikiDocument;
30   
31    /**
32    * Interface for RecycleBin feature (XWIKI-543) store system.
33    *
34    * @version $Id: eae53a1cff08dd2c1b34bd597870fb7c0cf5685b $
35    * @since 1.2M1
36    */
37    @Role
 
38    public interface XWikiRecycleBinStoreInterface
39    {
40    /**
41    * Save document to recycle bin.
42    *
43    * @param doc - document to save
44    * @param deleter - the user which delete document
45    * @param date - date of delete action
46    * @param bTransaction - should use old transaction(false) or create new (true)
47    * @param context - used while saving
48    * @throws XWikiException if error in saving
49    */
50    void saveToRecycleBin(XWikiDocument doc, String deleter, Date date, XWikiContext context, boolean bTransaction)
51    throws XWikiException;
52   
53    /**
54    * Save document to recycle bin.
55    *
56    * @param doc - document to save
57    * @param deleter - the user which delete document
58    * @param date - date of delete action
59    * @param batchId - id of the operation that deleted multiple documents at the same time, useful when trying to
60    * revert the operation. {@code null} or empty values are ignored
61    * @param bTransaction - should use old transaction(false) or create new (true)
62    * @param context - used while saving
63    * @throws XWikiException if error in saving
64    * @since 9.4RC1
65    */
 
66  0 toggle default void saveToRecycleBin(XWikiDocument doc, String deleter, Date date, String batchId, XWikiContext context,
67    boolean bTransaction) throws XWikiException
68    {
69    // XXX: The current signature does not return the saved document index so we have no way of setting the batchId
70    // to the save document. This means we can`t completely respect the method`s contract, but at least the most
71    // important part of the work is done and the document can be individually restored.
72  0 saveToRecycleBin(doc, deleter, date, context, bTransaction);
73    }
74   
75    /**
76    * @return restored document from recycle bin
77    * @param doc - document to restore
78    * @param index - what deleted document to restore. see {@link XWikiDeletedDocument#getId()}
79    * @param context - used while loading
80    * @param bTransaction - should use old transaction(false) or create new (true)
81    * @throws XWikiException if error while loading
82    * @deprecated since 9.4RC1. The document parameter is useless and gets in the way. Use
83    * {@link #restoreFromRecycleBin(long, XWikiContext, boolean)} instead.
84    */
85    @Deprecated
86    XWikiDocument restoreFromRecycleBin(XWikiDocument doc, long index, XWikiContext context, boolean bTransaction)
87    throws XWikiException;
88   
89    /**
90    * @param index - what deleted document to restore. see {@link XWikiDeletedDocument#getId()}
91    * @param context - used while loading
92    * @param bTransaction - should use old transaction(false) or create new (true)
93    * @return the restored document from recycle bin
94    * @throws XWikiException if error while loading
95    * @since 9.4RC1
96    */
 
97  0 toggle default XWikiDocument restoreFromRecycleBin(long index, XWikiContext context, boolean bTransaction)
98    throws XWikiException
99    {
100    // XXX: Depending on how an older implementation handled the XWikiDocument argument, it's relatively safer to
101    // pass an empty document than null. However, if the document's reference is actually used, the result might be
102    // unpredictable.
103  0 return restoreFromRecycleBin(new XWikiDocument(), index, context, bTransaction);
104    }
105   
106    /**
107    * @return specified deleted document from recycle bin. null if not found.
108    * @param doc - deleted document
109    * @param index - what deleted document to restore. see {@link XWikiDeletedDocument#getId()}
110    * @param context - used while loading
111    * @param bTransaction - should use old transaction(false) or create new (true)
112    * @throws XWikiException if error while loading
113    * @deprecated since 9.4RC1. The document parameter is useless and gets in the way. Use
114    * {@link #getDeletedDocument(long, XWikiContext, boolean)} instead.
115    */
116    @Deprecated
117    XWikiDeletedDocument getDeletedDocument(XWikiDocument doc, long index, XWikiContext context, boolean bTransaction)
118    throws XWikiException;
119   
120    /**
121    * @param index - what deleted document to restore. See {@link XWikiDeletedDocument#getId()}
122    * @param context - used while loading
123    * @param bTransaction - should use old transaction(false) or create new (true)
124    * @return specified deleted document from recycle bin or {@code null} if not found.
125    * @throws XWikiException if error while loading
126    * @since 9.4RC1
127    */
 
128  0 toggle default XWikiDeletedDocument getDeletedDocument(long index, XWikiContext context, boolean bTransaction)
129    throws XWikiException
130    {
131    // XXX: Depending on how an older implementation handled the XWikiDocument argument, it's relatively safer to
132    // pass an empty document than null. However, if the document's reference is actually used, the result might be
133    // unpredictable.
134  0 return getDeletedDocument(new XWikiDocument(), index, context, bTransaction);
135    }
136   
137    /**
138    * @return info about all delete actions of specific document. sorted by date.
139    * @param doc - the deleted document
140    * @param context - used to load
141    * @param bTransaction - should use old transaction(false) or create new (true)
142    * @throws XWikiException - if error in loading
143    */
144    XWikiDeletedDocument[] getAllDeletedDocuments(XWikiDocument doc, XWikiContext context, boolean bTransaction)
145    throws XWikiException;
146   
147    /**
148    * Get all the deleted documents ID or a specified number. Sorted by date.
149    * @param context - used to load the deleted documents id.
150    * @param limit - if > 0 then all deleted documents id are returned. Else the specified number.
151    * @return an array of IDs of deleted documents.
152    * @throws XWikiException - if error in loading
153    * @since 10.10RC1
154    */
 
155  0 toggle default Long[] getAllDeletedDocumentsIds(XWikiContext context, int limit) throws XWikiException
156    {
157  0 return new Long[0];
158    }
159   
160    /**
161    * @param context - used to realize the query.
162    * @return the number of deleted documents in the recycle bin.
163    * @throws XWikiException - if error in loading.
164    * @since 10.10RC1
165    */
 
166  0 toggle default Long getNumberOfDeletedDocuments(XWikiContext context) throws XWikiException
167    {
168  0 return -1L;
169    }
170   
171    /**
172    * @return info about all documents that were deleted in the same batch, as part of the same operation
173    * @param batchId - id of the operation that deleted multiple documents at the same time; useful when trying to
174    * revert the operation
175    * @param context - used to load
176    * @param bTransaction - should use old transaction(false) or create new (true)
177    * @throws XWikiException - if error in loading
178    * @since 9.4RC1
179    */
 
180  0 toggle default XWikiDeletedDocument[] getAllDeletedDocuments(String batchId, XWikiContext context, boolean bTransaction)
181    throws XWikiException
182    {
183    // Return no results as default implementation.
184  0 return new XWikiDeletedDocument[0];
185    }
186   
187    /**
188    * @param batchId - id of the operation that deleted multiple documents at the same time; useful when trying to
189    * revert the operation
190    * @param withContent - {@code true} if the deleted document's content should also be loaded; {@code false} if
191    * @param context - used to load
192    * @param bTransaction - should use old transaction(false) or create new (true)
193    * @return info about all documents that were deleted in the same batch, as part of the same operation
194    * @throws XWikiException - if error in loading
195    * @since 9.4RC1
196    */
 
197  0 toggle default XWikiDeletedDocument[] getAllDeletedDocuments(String batchId, boolean withContent, XWikiContext context,
198    boolean bTransaction) throws XWikiException
199    {
200    // Return no results as default implementation.
201  0 return new XWikiDeletedDocument[0];
202    }
203   
204    /**
205    * Permanently delete document from recycle bin.
206    *
207    * @param doc - document to delete
208    * @param index - which instance document in recycle bin to delete
209    * @param context - used for environment
210    * @param bTransaction - should use old transaction(false) or create new (true)
211    * @throws XWikiException if any error
212    * @deprecated since 9.4RC1. The document parameter is useless and gets in the way. Use
213    * {@link #deleteFromRecycleBin(long, XWikiContext, boolean)} instead.
214    */
215    @Deprecated
216    void deleteFromRecycleBin(XWikiDocument doc, long index, XWikiContext context, boolean bTransaction)
217    throws XWikiException;
218   
219    /**
220    * Permanently delete document from recycle bin.
221    *
222    * @param index - which instance document in recycle bin to delete
223    * @param context - used for environment
224    * @param bTransaction - should use old transaction(false) or create new (true)
225    * @throws XWikiException if any error
226    * @since 9.4RC1
227    */
 
228  0 toggle default void deleteFromRecycleBin(long index, XWikiContext context, boolean bTransaction) throws XWikiException
229    {
230    // XXX: Depending on how an older implementation handled the XWikiDocument argument, it's relatively safer to
231    // pass an empty document than null. However, if the document's reference is actually used, the result might be
232    // unpredictable.
233  0 deleteFromRecycleBin(new XWikiDocument(), index, context, bTransaction);
234    }
235    }