Class | Line # | Actions | |||||
---|---|---|---|---|---|---|---|
ZipExplorerPluginAPI | 43 | 5 | 0% | 5 | 10 |
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.plugin.zipexplorer; | |
21 | ||
22 | import java.util.List; | |
23 | ||
24 | import com.xpn.xwiki.XWikiContext; | |
25 | import com.xpn.xwiki.api.Document; | |
26 | import com.xpn.xwiki.doc.XWikiAttachment; | |
27 | import com.xpn.xwiki.objects.classes.ListItem; | |
28 | import com.xpn.xwiki.plugin.PluginApi; | |
29 | ||
30 | /** | |
31 | * ZIP-related APIs to list content of a ZIP attachments and to intercept XWiki download requests so that it's possible | |
32 | * to display contents found inside ZIP files. This plugin accepts specially formatted URLs pointing to files inside ZIP | |
33 | * files by using the following syntax: | |
34 | * <code>http://[...]/download/Document/zipfile.zip/SomeDirectory/SomeFile.txt</code>. In this example, the URL points | |
35 | * to the <code>SomeFile.txt</code> file located in a directory named <code>SomeDirectory</code> inside a ZIP file named | |
36 | * <code>zipfile.zip</code> and attached to the document named <code>Document</code>. | |
37 | * | |
38 | * @version $Id: 8bb7259b921a644b005f31f23ce248a1a651e7e3 $ | |
39 | * @see com.xpn.xwiki.plugin.zipexplorer.ZipExplorerPlugin | |
40 | * @deprecated the plugin technology is deprecated, consider rewriting as components | |
41 | */ | |
42 | @Deprecated | |
43 | public class ZipExplorerPluginAPI extends PluginApi<ZipExplorerPlugin> | |
44 | { | |
45 | /** | |
46 | * @param plugin the ZIP Explorer plugin that this class is hiding. | |
47 | * @param context the XWiki context instance containing the last user request | |
48 | */ | |
49 | 0 | ![]() |
50 | { | |
51 | 0 | super(plugin, context); |
52 | } | |
53 | ||
54 | /** | |
55 | * For ZIP URLs of the format <code>http://[...]/zipfile.zip/SomeDirectory/SomeFile.txt</code> return a new | |
56 | * attachment containing the file pointed to inside the ZIP. If the original attachment does not point to a ZIP file | |
57 | * or if it doesn't specify a location inside the ZIP then do nothing and return the original attachment. | |
58 | * | |
59 | * @param attachment the original attachment | |
60 | * @return a new attachment pointing to the file pointed to by the URL inside the ZIP or the original attachment if | |
61 | * the requested URL doesn't specify a file inside a ZIP | |
62 | * @see com.xpn.xwiki.plugin.XWikiDefaultPlugin#downloadAttachment | |
63 | */ | |
64 | 0 | ![]() |
65 | { | |
66 | 0 | return getProtectedPlugin().downloadAttachment(attachment, getXWikiContext()); |
67 | } | |
68 | ||
69 | /** | |
70 | * @param document the document containing the ZIP file as an attachment | |
71 | * @param attachmentName the name under which the ZIP file is attached in the document | |
72 | * @return the list of file entries in the ZIP file attached under the passed attachment name inside the passed | |
73 | * document | |
74 | */ | |
75 | 0 | ![]() |
76 | { | |
77 | 0 | return getProtectedPlugin().getFileList(document, attachmentName, getXWikiContext()); |
78 | } | |
79 | ||
80 | /** | |
81 | * Finds the ZIP attachment with passed name from the passed document matching and parse the ZIP to generate a list | |
82 | * of {@link com.xpn.xwiki.objects.classes.ListItem} elements representing a tree view of all directories and files | |
83 | * in the ZIP. For example the following zip: | |
84 | * | |
85 | * <pre> | |
86 | * zipfile.zip: | |
87 | * Directory/File.txt | |
88 | * File2.txt | |
89 | * </pre> | |
90 | * | |
91 | * generates the following ListItem list: | |
92 | * | |
93 | * <pre> | |
94 | * | |
95 | * { id = "Directory/", value = "Directory", parent = ""} | |
96 | * { id = "Directory/File.txt", value = "File.txt", parent = "Directory/"} | |
97 | * { id = "File2.txt", value = "File2.txt", parent = ""} | |
98 | * | |
99 | * </pre> | |
100 | * | |
101 | * @param document the document containing the ZIP file as an attachment | |
102 | * @param attachmentName the name under which the ZIP file is attached in the document | |
103 | * @return a tree view list of {@link com.xpn.xwiki.objects.classes.ListItem} elements representing the content of | |
104 | * the ZIP file | |
105 | */ | |
106 | 0 | ![]() |
107 | { | |
108 | 0 | return getProtectedPlugin().getFileTreeList(document, attachmentName, getXWikiContext()); |
109 | } | |
110 | ||
111 | /** | |
112 | * @param document the document containing the ZIP file as an attachment | |
113 | * @param attachmentName the name under which the ZIP file is attached in the document | |
114 | * @param fileName the filename to concatenate at the end of the attachment URL | |
115 | * @return the attachment URL of the passed attachment located in the passed document to which the passed filename | |
116 | * has been suffixed. | |
117 | */ | |
118 | 0 | ![]() |
119 | { | |
120 | 0 | return getProtectedPlugin().getFileLink(document, attachmentName, fileName, getXWikiContext()); |
121 | } | |
122 | } |