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

File AttachmentRecycleBinStore.java

 

Code metrics

0
0
0
1
122
24
0
-
-
0
-

Classes

Class Line # Actions
AttachmentRecycleBinStore 43 0 - 0 0
-1.0 -
 

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    import java.util.List;
24   
25    import org.xwiki.component.annotation.Role;
26   
27    import com.xpn.xwiki.XWikiContext;
28    import com.xpn.xwiki.XWikiException;
29    import com.xpn.xwiki.doc.DeletedAttachment;
30    import com.xpn.xwiki.doc.XWikiAttachment;
31    import com.xpn.xwiki.doc.XWikiDocument;
32   
33    /**
34    * Interface for AttachmentRecycleBin feature (XWIKI-2254) store system. Attachments can be placed in the recycle bin
35    * using {@link #saveToRecycleBin(XWikiAttachment, String, Date, XWikiContext, boolean)}, restored using
36    * {@link #restoreFromRecycleBin(XWikiAttachment, long, XWikiContext, boolean)}, and permanently removed from the
37    * recycle bin using {@link #deleteFromRecycleBin(long, XWikiContext, boolean)}.
38    *
39    * @version $Id: e0392a10570ec1aa20f1b369a285d707b8266bfd $
40    * @since 1.4M1
41    */
42    @Role
 
43    public interface AttachmentRecycleBinStore
44    {
45    /**
46    * Save attachment to recycle bin, with full history.
47    *
48    * @param attachment The attachment to save.
49    * @param deleter The user which deleted the attachment.
50    * @param date Date of delete action.
51    * @param context The current context.
52    * @param bTransaction Should use old transaction (false) or create new (true).
53    * @throws XWikiException If an exception occurs during the attachment export or attachment persistence.
54    */
55    void saveToRecycleBin(XWikiAttachment attachment, String deleter, Date date, XWikiContext context,
56    boolean bTransaction) throws XWikiException;
57   
58    /**
59    * Restore an attachment from the recycle bin (with full history).
60    *
61    * @return Restored attachment, or <code>null</code> if an entry with the requested ID does not exist.
62    * @param attachment Optional attachment to restore. If a non-null value is passed, then this object will be changed
63    * to reflect the contents/history of the deleted attachment.
64    * @param index What deleted attachment to restore. See {@link DeletedAttachment#getId()}.
65    * @param context The current context.
66    * @param bTransaction Should use old transaction (false) or create new (true).
67    * @throws XWikiException If an error occurs while loading or restoring the attachment.
68    * @see #getDeletedAttachment(long, XWikiContext, boolean)
69    */
70    XWikiAttachment restoreFromRecycleBin(XWikiAttachment attachment, long index, XWikiContext context,
71    boolean bTransaction) throws XWikiException;
72   
73    /**
74    * Returns a {@link DeletedAttachment handler} for a deleted attachment.
75    *
76    * @return Specified deleted document from recycle bin. <code>null</code> if not found.
77    * @param index What deleted attachment to restore. See {@link DeletedAttachment#getId()}
78    * @param context The current context.
79    * @param bTransaction Should use old transaction (false) or create new (true).
80    * @throws XWikiException If an error occurs while loading or restoring the attachment.
81    * @see #restoreFromRecycleBin(XWikiAttachment, long, XWikiContext, boolean)
82    */
83    DeletedAttachment getDeletedAttachment(long index, XWikiContext context, boolean bTransaction)
84    throws XWikiException;
85   
86    /**
87    * Get all the deleted attachments from the database matching an attachment template (document name and filename).
88    * The results are ordered by the deletion date, descending (most recently deleted first).
89    *
90    * @param attachment Optional attachment template. If <code>null</code>, return information about all deleted
91    * attachments from the database. Otherwise, filter by the document and filename provided in the passed
92    * attachment.
93    * @param context The current context.
94    * @param bTransaction Should use old transaction (false) or create new (true).
95    * @return Infos about all matching deleted attachments, sorted by date.
96    * @throws XWikiException If an error occurs while loading or restoring the attachments.
97    */
98    List<DeletedAttachment> getAllDeletedAttachments(XWikiAttachment attachment, XWikiContext context,
99    boolean bTransaction) throws XWikiException;
100   
101    /**
102    * Get all the deleted attachments for a given document.
103    *
104    * @return Infos about all deleted attachments of specific document, sorted by date.
105    * @param doc The document for which to retrieve deleted attachments.
106    * @param context The current context.
107    * @param bTransaction Should use old transaction (false) or create new (true).
108    * @throws XWikiException If an error occurs while loading or restoring the attachments.
109    */
110    List<DeletedAttachment> getAllDeletedAttachments(XWikiDocument doc, XWikiContext context, boolean bTransaction)
111    throws XWikiException;
112   
113    /**
114    * Permanently delete attachment from recycle bin.
115    *
116    * @param index Which instance to delete from the recycle bin.
117    * @param context The current context.
118    * @param bTransaction Should use old transaction (false) or create new (true).
119    * @throws XWikiException If an error occurs while executing the query.
120    */
121    void deleteFromRecycleBin(long index, XWikiContext context, boolean bTransaction) throws XWikiException;
122    }