KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > servlets > webdav > AbstractPath


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  * Free SoftwareFoundation, Inc.
23  * 59 Temple Place, Suite 330
24  * Boston, MA 02111-1307 USA
25  *
26  * @author Scott Ferguson
27  */

28
29 package com.caucho.servlets.webdav;
30
31 import com.caucho.log.Log;
32 import com.caucho.util.NullIterator;
33
34 import javax.servlet.ServletContext JavaDoc;
35 import javax.servlet.http.HttpServletRequest JavaDoc;
36 import java.io.IOException JavaDoc;
37 import java.io.InputStream JavaDoc;
38 import java.io.OutputStream JavaDoc;
39 import java.util.Iterator JavaDoc;
40 import java.util.logging.Logger JavaDoc;
41
42 /**
43  * Represents a virtual filesystem.
44  */

45 public abstract class AbstractPath {
46   protected static final Logger JavaDoc log = Log.open(AbstractPath.class);
47
48   /**
49    * Returns true if the named file is a file.
50    *
51    * @param path the requested relative path
52    * @param request the servlet request
53    * @param app the servlet context
54    */

55   public abstract boolean isFile(String JavaDoc path,
56                                  HttpServletRequest JavaDoc request,
57                                  ServletContext JavaDoc app)
58     throws IOException JavaDoc;
59
60   /**
61    * Returns true if the named file is a directory.
62    *
63    * @param path the requested relative path
64    * @param request the servlet request
65    * @param app the servlet context
66    */

67   public abstract boolean isDirectory(String JavaDoc path,
68                                       HttpServletRequest JavaDoc request,
69                                       ServletContext JavaDoc app)
70     throws IOException JavaDoc;
71   
72   /**
73    * Returns true if the file can be read.
74    *
75    * @param path the requested relative path
76    * @param request the servlet request
77    * @param app the servlet context
78    */

79   public abstract boolean canRead(String JavaDoc path,
80                                   HttpServletRequest JavaDoc request,
81                                   ServletContext JavaDoc app)
82     throws IOException JavaDoc;
83   
84   /**
85    * Returns true if the file exists.
86    *
87    * @param path the requested relative path
88    * @param request the servlet request
89    * @param app the servlet context
90    */

91   public abstract boolean exists(String JavaDoc path,
92                                  HttpServletRequest JavaDoc request,
93                                  ServletContext JavaDoc app)
94     throws IOException JavaDoc;
95   
96   /**
97    * Returns the length of the named file.
98    *
99    * @param path the requested relative path
100    * @param request the servlet request
101    * @param app the servlet context
102    */

103   public abstract long getLength(String JavaDoc path,
104                                  HttpServletRequest JavaDoc request,
105                                  ServletContext JavaDoc app)
106     throws IOException JavaDoc;
107   
108   /**
109    * Returns the last modified time of the named file.
110    *
111    * @param path the requested relative path
112    * @param request the servlet request
113    * @param app the servlet context
114    */

115   public abstract long getLastModified(String JavaDoc path,
116                                        HttpServletRequest JavaDoc request,
117                                        ServletContext JavaDoc app)
118     throws IOException JavaDoc;
119   
120   /**
121    * Returns an iterator over the attribute names.
122    * Each attribute name is of the type AttributeName.
123    *
124    * @param path the requested relative path
125    * @param request the servlet request
126    * @param app the servlet context
127    */

128   public Iterator getAttributeNames(String JavaDoc path,
129                                     HttpServletRequest JavaDoc request,
130                                     ServletContext JavaDoc app)
131     throws IOException JavaDoc
132   {
133     return NullIterator.create();
134   }
135   
136   /**
137    * Returns an attribute value.
138    *
139    * @param name the attribute name
140    * @param path the requested relative path
141    * @param request the servlet request
142    * @param app the servlet context
143    */

144   public String JavaDoc getAttribute(AttributeName name,
145                              String JavaDoc path,
146                              HttpServletRequest JavaDoc request,
147                              ServletContext JavaDoc app)
148     throws IOException JavaDoc
149   {
150     return null;
151   }
152   
153   /**
154    * Sets an attribute value.
155    *
156    * @param name the attribute name
157    * @param value the attribute value
158    * @param path the requested relative path
159    * @param request the servlet request
160    * @param app the servlet context
161    *
162    * @return true if the setting was successful
163    */

164   public boolean setAttribute(AttributeName name, String JavaDoc value,
165                               String JavaDoc path,
166                               HttpServletRequest JavaDoc request,
167                               ServletContext JavaDoc app)
168     throws IOException JavaDoc
169   {
170     return false;
171   }
172   
173   /**
174    * Removes an attribute value.
175    *
176    * @param name the attribute name
177    * @param path the requested relative path
178    * @param request the servlet request
179    * @param app the servlet context
180    */

181   public boolean removeAttribute(AttributeName name,
182                                  String JavaDoc path,
183                                  HttpServletRequest JavaDoc request,
184                                  ServletContext JavaDoc app)
185     throws IOException JavaDoc
186   {
187     return false;
188   }
189   
190   /**
191    * Returns a list of the files in the directory.
192    *
193    * @param path the requested relative path
194    * @param request the servlet request
195    * @param app the servlet context
196    */

197   public abstract String JavaDoc []list(String JavaDoc path,
198                                 HttpServletRequest JavaDoc request,
199                                 ServletContext JavaDoc app)
200     throws IOException JavaDoc;
201   
202   /**
203    * Creates the named directory.
204    *
205    * @param path the requested relative path
206    * @param request the servlet request
207    * @param app the servlet context
208    *
209    * @return true if the creation succeeded.
210    */

211   public abstract boolean mkdir(String JavaDoc path,
212                                 HttpServletRequest JavaDoc request,
213                                 ServletContext JavaDoc app)
214     throws IOException JavaDoc;
215   
216   /**
217    * Removes the named directory.
218    *
219    * @param path the requested relative path
220    * @param request the servlet request
221    * @param app the servlet context
222    *
223    * @return true if the remove succeeded.
224    */

225   public abstract boolean rmdir(String JavaDoc path,
226                                 HttpServletRequest JavaDoc request,
227                                 ServletContext JavaDoc app)
228     throws IOException JavaDoc;
229   
230   /**
231    * Renames the file without forcing a copy. If rename returns true,
232    * use copy instead.
233    *
234    * @param path the requested relative path
235    * @param destination the new name
236    * @param request the servlet request
237    * @param app the servlet context
238    *
239    * @return true if the remove succeeded.
240    */

241   public boolean rename(String JavaDoc path,
242             String JavaDoc destination,
243             HttpServletRequest JavaDoc request,
244             ServletContext JavaDoc app)
245     throws IOException JavaDoc
246   {
247     return false;
248   }
249   
250   /**
251    * Deletes the file
252    *
253    * @param path the requested relative path
254    * @param request the servlet request
255    * @param app the servlet context
256    *
257    * @return true if the remove succeeded.
258    */

259   public abstract boolean remove(String JavaDoc path,
260                                  HttpServletRequest JavaDoc request,
261                                  ServletContext JavaDoc app)
262     throws IOException JavaDoc;
263   
264   /**
265    * Opens an OutputStream for writing.
266    *
267    * @param path the requested relative path
268    * @param request the servlet request
269    * @param app the servlet context
270    *
271    * @return the output stream to the resource.
272    */

273   public abstract OutputStream JavaDoc openWrite(String JavaDoc path,
274                                          HttpServletRequest JavaDoc request,
275                                          ServletContext JavaDoc app)
276     throws IOException JavaDoc;
277   
278   /**
279    * Opens an InputStream for reading
280    *
281    * @param path the requested relative path
282    * @param request the servlet request
283    * @param app the servlet context
284    *
285    * @return the input stream to the resource.
286    */

287   public abstract InputStream JavaDoc openRead(String JavaDoc path,
288                                        HttpServletRequest JavaDoc request,
289                                        ServletContext JavaDoc app)
290     throws IOException JavaDoc;
291
292   /**
293    * Cleans up when no longer needed.
294    */

295   public void destroy()
296   {
297   }
298 }
299
Popular Tags