Class | Line # | Actions | |||||
---|---|---|---|---|---|---|---|
AttachmentOfficeDocumentView | 38 | 7 | 0% | 4 | 5 |
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.office.viewer.internal; | |
21 | ||
22 | import java.io.File; | |
23 | import java.util.Set; | |
24 | ||
25 | import org.xwiki.cache.DisposableCacheValue; | |
26 | import org.xwiki.model.reference.AttachmentReference; | |
27 | import org.xwiki.rendering.block.XDOM; | |
28 | import org.xwiki.rendering.listener.reference.ResourceReference; | |
29 | ||
30 | /** | |
31 | * Holds all the information belonging to an office attachment view. Instances of this class are mainly used for caching | |
32 | * office attachment views. | |
33 | * | |
34 | * @since 5.4.6 | |
35 | * @since 6.2.2 | |
36 | * @version $Id: 23eadbb5ab82298765ec8fec510b27a8a69e073c $ | |
37 | */ | |
38 | public class AttachmentOfficeDocumentView extends OfficeDocumentView implements DisposableCacheValue | |
39 | { | |
40 | /** | |
41 | * Reference to the office attachment to which this view belongs. | |
42 | */ | |
43 | private final AttachmentReference attachmentReference; | |
44 | ||
45 | /** | |
46 | * Specific version of the attachment to which this view corresponds. | |
47 | */ | |
48 | private final String version; | |
49 | ||
50 | /** | |
51 | * Creates a new {@link AttachmentOfficeDocumentView} instance. | |
52 | * | |
53 | * @param reference the reference to the office file to which this view belongs | |
54 | * @param attachmentReference reference to the office attachment to which this view belongs | |
55 | * @param version version of the attachment to which this view corresponds | |
56 | * @param xdom {@link XDOM} representation of the office document | |
57 | * @param temporaryFiles temporary files used by this view | |
58 | */ | |
59 | 5 | public AttachmentOfficeDocumentView(ResourceReference reference, AttachmentReference attachmentReference, |
60 | String version, XDOM xdom, Set<File> temporaryFiles) | |
61 | { | |
62 | 5 | super(reference, xdom, temporaryFiles); |
63 | ||
64 | 5 | this.attachmentReference = attachmentReference; |
65 | 5 | this.version = version; |
66 | } | |
67 | ||
68 | /** | |
69 | * @return a reference to the office attachment that is the source of this view | |
70 | */ | |
71 | 0 | public AttachmentReference getAttachmentReference() |
72 | { | |
73 | 0 | return this.attachmentReference; |
74 | } | |
75 | ||
76 | /** | |
77 | * @return the version of the attachment that is the source of this view | |
78 | */ | |
79 | 2 | public String getVersion() |
80 | { | |
81 | 2 | return this.version; |
82 | } | |
83 | ||
84 | 0 | @Override |
85 | public void dispose() throws Exception | |
86 | { | |
87 | // Cleanup all the temporary files. | |
88 | 0 | for (File file : getTemporaryFiles()) { |
89 | 0 | file.delete(); |
90 | } | |
91 | } | |
92 | } |