KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > core > DownloadContent


1 package com.sslexplorer.core;
2
3 import javax.servlet.http.HttpServletRequest JavaDoc;
4 import javax.servlet.http.HttpServletResponse JavaDoc;
5
6 import org.apache.struts.action.ActionForward;
7
8 import com.sslexplorer.security.SessionInfo;
9
10 /**
11  * Core to the feature that allows files to be download for
12  * various functions such as a private key downloads or VFS downloads, implementations
13  * of this interface are responsible for provided the content to be downloaded.
14  * <p>
15  * For example, one implementation may get the downloadable content from a
16  * local file, whilst another zips lots of resources to a single archive
17  * and provides that for download.
18  * <p>
19  * Implementations must also provide some message resources that will
20  * be displayed when at the time of file download.
21  *
22  * @author Brett Smith <a HREF="mailto: brett@3sp.com">&lt;brett@3sp.com&gt;</a>
23  */

24 public interface DownloadContent {
25
26     /**
27      * Constant name for hook to delete temporary download
28      * files when session is invalidated
29      */

30     public final String JavaDoc FILES_DOWNLOAD_CLEANUP_SESSION_HOOK = "fileDownloadCleanupSessionHook";
31     
32     /**
33      * Do the actual download. At this point the filename and content type
34      * will already have been set on the response so all this method does
35      * is get the downloadable input stream from somewhere and write it
36      * to the {@link HttpServletResponse} objects output stream.
37      *
38      * @param response response that contains output stream to write to
39      * @param request request
40      * @throws Exception on any error
41      */

42     public void sendDownload(HttpServletResponse JavaDoc response, HttpServletRequest JavaDoc request)
43             throws Exception JavaDoc;
44
45     /**
46      * Each download must have a unique id, this method returns it.
47      *
48      * @return download id
49      */

50     public int getId();
51
52     /**
53      * Each download must have a unique id, this method sets it.
54      *
55      * @param id download id
56      */

57     public void setId(int id);
58
59     /**
60      * Invoked when the download is complete, any clean up should be done
61      * here.
62      * @param session
63      */

64     public void completeDownload(SessionInfo session);
65     
66     /**
67      * Get the forward to direct to when the download is complete.
68      *
69      * @return forward
70      */

71     public ActionForward getForward();
72     
73     /**
74      * Get the message key for the resources to display to user on the
75      * file download page.
76      *
77      * @return message key
78      */

79     public String JavaDoc getMessageKey();
80
81     /**
82      * Get the resource bundle id from which to get the resources to display
83      * to user on the file download page
84      *
85      * @return message resources bundle id
86      */

87     public String JavaDoc getMessageResourcesKey();
88     
89     /**
90      * Get the first argument to pass to the message to display to user on
91      * the file dfownload page.
92      *
93      * @return first argument
94      */

95     public String JavaDoc getMessageArg0();
96
97     /**
98      * Get the second argument to pass to the message to display to user on
99      * the file download page.
100      *
101      * @return second argument
102      */

103     public String JavaDoc getMessageArg1();
104
105     /**
106      * Get the third argument to pass to the message to display to user on
107      * the file download page.
108      *
109      * @return third argument
110      */

111     public String JavaDoc getMessageArg2();
112
113     /**
114      * Get the fourth argument to pass to the message to display to user on
115      * the file download page.
116      *
117      * @return fourth argument
118      */

119     public String JavaDoc getMessageArg3();
120
121     /**
122      * Get the fifth argument to pass to the message to display to user on
123      * the file download page.
124      *
125      * @return fifth argument
126      */

127     public String JavaDoc getMessageArg4();
128     
129     /**
130      * Get the mime type to return to the browser when downloaded. This will
131      * affect the actions that are presented to the user (e.g. open with
132      * application or save to disk etc).
133      *
134      * @return mime type
135      */

136     public String JavaDoc getMimeType();
137     
138     /**
139      * Get the filename to return to the browser when downloaded.
140      *
141      * @return filename
142      */

143     public String JavaDoc getFilename();
144     
145     /**
146      * Get the forward to use to show the download message
147      *
148      * @return forward
149      */

150     public ActionForward getMessageForward();
151
152     /**
153      * Get the number of times this piece of content has been downloaded.
154      *
155      * @return download count
156      */

157     public int getDownloadCount();
158
159 }
Popular Tags