1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.store.legacy.doc.internal; |
21 |
|
|
22 |
|
import java.util.Date; |
23 |
|
|
24 |
|
import com.xpn.xwiki.XWikiContext; |
25 |
|
import com.xpn.xwiki.XWikiException; |
26 |
|
import com.xpn.xwiki.doc.DeletedAttachment; |
27 |
|
import com.xpn.xwiki.doc.XWikiAttachment; |
28 |
|
import com.xpn.xwiki.doc.XWikiAttachmentArchive; |
29 |
|
import com.xpn.xwiki.doc.XWikiAttachmentContent; |
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
@link |
34 |
|
|
35 |
|
@version |
36 |
|
@since |
37 |
|
|
|
|
| 0% |
Uncovered Elements: 44 (44) |
Complexity: 15 |
Complexity Density: 0.62 |
|
38 |
|
public class DeletedFilesystemAttachment extends DeletedAttachment |
39 |
|
{ |
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
private XWikiAttachment attachment; |
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
48 |
0 |
protected DeletedFilesystemAttachment()... |
49 |
|
{ |
50 |
|
} |
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
@param |
56 |
|
@param |
57 |
|
@param |
58 |
|
@throws |
59 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
60 |
0 |
public DeletedFilesystemAttachment(final XWikiAttachment attachment, final String deleter, final Date deleteDate)... |
61 |
|
throws XWikiException |
62 |
|
{ |
63 |
0 |
super(attachment, deleter, deleteDate, null); |
64 |
|
} |
65 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
66 |
0 |
@Override... |
67 |
|
public long getDocId() |
68 |
|
{ |
69 |
|
|
70 |
0 |
if (this.attachment != null && this.attachment.getDoc() != null) { |
71 |
0 |
return this.attachment.getDocId(); |
72 |
|
} |
73 |
0 |
return 0; |
74 |
|
} |
75 |
|
|
76 |
|
|
77 |
|
@inheritDoc |
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
@see |
83 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
84 |
0 |
@Override... |
85 |
|
protected void setAttachment(final XWikiAttachment attachment, final XWikiContext context) |
86 |
|
{ |
87 |
0 |
this.attachment = (XWikiAttachment) attachment.clone(); |
88 |
0 |
if (this.getDate() != null) { |
89 |
0 |
this.setId(generateId(this.attachment, this.getDate())); |
90 |
|
} |
91 |
|
} |
92 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
93 |
0 |
@Override... |
94 |
|
public void setDate(Date date) |
95 |
|
{ |
96 |
0 |
super.setDate(date); |
97 |
0 |
if (this.getAttachment() != null) { |
98 |
0 |
this.setId(generateId(this.getAttachment(), date)); |
99 |
|
} |
100 |
|
} |
101 |
|
|
102 |
|
|
103 |
|
@link |
104 |
|
|
105 |
|
|
106 |
|
@return |
107 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
108 |
0 |
public XWikiAttachment getAttachment()... |
109 |
|
{ |
110 |
0 |
return this.attachment; |
111 |
|
} |
112 |
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 4 |
Complexity Density: 0.33 |
|
113 |
0 |
@Override... |
114 |
|
public XWikiAttachment restoreAttachment(final XWikiAttachment attachment, final XWikiContext context) |
115 |
|
throws XWikiException |
116 |
|
{ |
117 |
0 |
XWikiAttachment result = attachment; |
118 |
0 |
if (result != null) { |
119 |
|
|
120 |
|
|
121 |
0 |
result.fromXML(this.attachment.toXML(context)); |
122 |
0 |
if (this.attachment.getAttachment_content() != null) { |
123 |
0 |
attachment.setAttachment_content((XWikiAttachmentContent) this.attachment.getAttachment_content() |
124 |
|
.clone()); |
125 |
0 |
attachment.getAttachment_content().setAttachment(attachment); |
126 |
|
} |
127 |
0 |
if (this.attachment.getAttachment_archive() != null) { |
128 |
0 |
result.setAttachment_archive((XWikiAttachmentArchive) this.attachment.getAttachment_archive().clone()); |
129 |
0 |
result.getAttachment_archive().setAttachment(result); |
130 |
|
} |
131 |
|
} else { |
132 |
0 |
result = (XWikiAttachment) this.attachment.clone(); |
133 |
|
} |
134 |
|
|
135 |
0 |
result.setDoc(context.getWiki().getDocument(this.attachment.getReference().getDocumentReference(), context)); |
136 |
0 |
return result; |
137 |
|
} |
138 |
|
|
139 |
|
|
140 |
|
@link |
141 |
|
|
142 |
|
|
143 |
|
|
144 |
|
|
145 |
|
@param |
146 |
|
@param |
147 |
|
@return |
148 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
149 |
0 |
private static long generateId(final XWikiAttachment attachment, final Date deleteDate)... |
150 |
|
{ |
151 |
0 |
return (attachment.getId() << 32) ^ ((deleteDate.getTime() / 1000) & 0x00000000FFFFFFFFL); |
152 |
|
} |
153 |
|
} |