1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package com.xpn.xwiki.doc; |
21 |
|
|
22 |
|
import java.util.Date; |
23 |
|
|
24 |
|
import com.xpn.xwiki.XWikiContext; |
25 |
|
import com.xpn.xwiki.XWikiException; |
26 |
|
import com.xpn.xwiki.util.AbstractSimpleClass; |
27 |
|
|
28 |
|
|
29 |
|
@link |
30 |
|
|
31 |
|
|
32 |
|
@version |
33 |
|
@since |
34 |
|
|
|
|
| 56% |
Uncovered Elements: 22 (50) |
Complexity: 21 |
Complexity Density: 0.75 |
|
35 |
|
public class DeletedAttachment extends AbstractSimpleClass |
36 |
|
{ |
37 |
|
|
38 |
|
private long id; |
39 |
|
|
40 |
|
|
41 |
|
private long docId; |
42 |
|
|
43 |
|
|
44 |
|
private String docName; |
45 |
|
|
46 |
|
|
47 |
|
private String filename; |
48 |
|
|
49 |
|
|
50 |
|
private Date date; |
51 |
|
|
52 |
|
|
53 |
|
private String deleter; |
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
@see |
59 |
|
|
60 |
|
private String xml; |
61 |
|
|
62 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
63 |
60 |
protected DeletedAttachment()... |
64 |
|
{ |
65 |
|
} |
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
@param |
71 |
|
@param |
72 |
|
@param |
73 |
|
@param |
74 |
|
@throws |
75 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
76 |
5 |
public DeletedAttachment(XWikiAttachment attachment, String deleter, Date deleteDate, XWikiContext context)... |
77 |
|
throws XWikiException |
78 |
|
{ |
79 |
5 |
this.docId = attachment.getDocId(); |
80 |
5 |
this.docName = attachment.getDoc().getFullName(); |
81 |
5 |
this.filename = attachment.getFilename(); |
82 |
5 |
this.deleter = deleter; |
83 |
5 |
this.date = deleteDate; |
84 |
5 |
setAttachment(attachment, context); |
85 |
|
} |
86 |
|
|
87 |
|
|
88 |
|
@link |
89 |
|
|
90 |
|
@return |
91 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
92 |
65 |
public long getId()... |
93 |
|
{ |
94 |
65 |
return this.id; |
95 |
|
} |
96 |
|
|
97 |
|
|
98 |
|
@link |
99 |
|
|
100 |
|
@param |
101 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
102 |
5 |
protected void setId(long id)... |
103 |
|
{ |
104 |
5 |
this.id = id; |
105 |
|
} |
106 |
|
|
107 |
|
|
108 |
|
@link |
109 |
|
|
110 |
|
@return |
111 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
112 |
10 |
public long getDocId()... |
113 |
|
{ |
114 |
10 |
return this.docId; |
115 |
|
} |
116 |
|
|
117 |
|
|
118 |
|
@link |
119 |
|
|
120 |
|
@param |
121 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
122 |
0 |
protected void setDocId(long docId)... |
123 |
|
{ |
124 |
0 |
this.docId = docId; |
125 |
|
} |
126 |
|
|
127 |
|
|
128 |
|
@link |
129 |
|
|
130 |
|
@return |
131 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
132 |
10 |
public String getDocName()... |
133 |
|
{ |
134 |
10 |
return this.docName; |
135 |
|
} |
136 |
|
|
137 |
|
|
138 |
|
@link |
139 |
|
|
140 |
|
@param |
141 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
142 |
0 |
protected void setDocName(String docName)... |
143 |
|
{ |
144 |
0 |
this.docName = docName; |
145 |
|
} |
146 |
|
|
147 |
|
|
148 |
|
@link |
149 |
|
|
150 |
|
@return |
151 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
152 |
10 |
public String getFilename()... |
153 |
|
{ |
154 |
10 |
return this.filename; |
155 |
|
} |
156 |
|
|
157 |
|
|
158 |
|
@link |
159 |
|
|
160 |
|
@param |
161 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
162 |
0 |
protected void setFilename(String filename)... |
163 |
|
{ |
164 |
0 |
this.filename = filename; |
165 |
|
} |
166 |
|
|
167 |
|
|
168 |
|
@link |
169 |
|
|
170 |
|
@return |
171 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
172 |
10 |
public Date getDate()... |
173 |
|
{ |
174 |
10 |
return this.date; |
175 |
|
} |
176 |
|
|
177 |
|
|
178 |
|
@link |
179 |
|
|
180 |
|
@param |
181 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
182 |
0 |
protected void setDate(Date date)... |
183 |
|
{ |
184 |
0 |
this.date = date; |
185 |
|
} |
186 |
|
|
187 |
|
|
188 |
|
@link |
189 |
|
|
190 |
|
@return |
191 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
192 |
10 |
public String getDeleter()... |
193 |
|
{ |
194 |
10 |
return this.deleter; |
195 |
|
} |
196 |
|
|
197 |
|
|
198 |
|
@link |
199 |
|
|
200 |
|
@param |
201 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
202 |
0 |
protected void setDeleter(String deleter)... |
203 |
|
{ |
204 |
0 |
this.deleter = deleter; |
205 |
|
} |
206 |
|
|
207 |
|
|
208 |
|
@link |
209 |
|
|
210 |
|
@return@link |
211 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
212 |
10 |
public String getXml()... |
213 |
|
{ |
214 |
10 |
return this.xml; |
215 |
|
} |
216 |
|
|
217 |
|
|
218 |
|
@link |
219 |
|
|
220 |
|
@param@link |
221 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
222 |
5 |
protected void setXml(String xml)... |
223 |
|
{ |
224 |
5 |
this.xml = xml; |
225 |
|
} |
226 |
|
|
227 |
|
|
228 |
|
@link@link |
229 |
|
|
230 |
|
@param |
231 |
|
@param |
232 |
|
@throws |
233 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
234 |
5 |
protected void setAttachment(XWikiAttachment attachment, XWikiContext context) throws XWikiException... |
235 |
|
{ |
236 |
5 |
setXml(attachment.toStringXML(true, true, context)); |
237 |
|
} |
238 |
|
|
239 |
|
|
240 |
|
@link@link |
241 |
|
@link |
242 |
|
|
243 |
|
|
244 |
|
@return |
245 |
|
@param |
246 |
|
@param@link |
247 |
|
@throws |
248 |
|
@link |
249 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 4 |
Complexity Density: 0.57 |
|
250 |
0 |
public XWikiAttachment restoreAttachment(XWikiAttachment attachment, XWikiContext context) throws XWikiException... |
251 |
|
{ |
252 |
0 |
XWikiAttachment result = attachment; |
253 |
0 |
if (result == null) { |
254 |
0 |
result = new XWikiAttachment(); |
255 |
|
} |
256 |
0 |
result.fromXML(getXml()); |
257 |
0 |
if (result.getDoc() == null || !(this.getDocName().equals(result.getDoc().getFullName()))) { |
258 |
0 |
result.setDoc(context.getWiki().getDocument(this.getDocName(), context)); |
259 |
|
} |
260 |
0 |
return result; |
261 |
|
} |
262 |
|
} |