1 28 29 package com.caucho.servlets.webdav; 30 31 import com.caucho.server.webapp.Application; 32 import com.caucho.util.NullIterator; 33 import com.caucho.vfs.Path; 34 35 import javax.servlet.ServletContext ; 36 import javax.servlet.http.HttpServletRequest ; 37 import java.io.IOException ; 38 import java.io.InputStream ; 39 import java.io.OutputStream ; 40 import java.util.Iterator ; 41 42 45 public class ApplicationPath extends AbstractPath { 46 51 public boolean isFile(String path, 52 HttpServletRequest request, 53 ServletContext app) 54 throws IOException 55 { 56 return getPath(path, request, app).isFile(); 57 } 58 59 64 public boolean isDirectory(String path, 65 HttpServletRequest request, 66 ServletContext app) 67 throws IOException 68 { 69 return getPath(path, request, app).isDirectory(); 70 } 71 72 77 public boolean canRead(String path, 78 HttpServletRequest request, 79 ServletContext app) 80 throws IOException 81 { 82 return getPath(path, request, app).canRead(); 83 } 84 85 90 public boolean exists(String path, 91 HttpServletRequest request, 92 ServletContext app) 93 throws IOException 94 { 95 return getPath(path, request, app).exists(); 96 } 97 98 103 public long getLength(String path, 104 HttpServletRequest request, 105 ServletContext app) 106 throws IOException 107 { 108 return getPath(path, request, app).getLength(); 109 } 110 111 116 public long getLastModified(String path, 117 HttpServletRequest request, 118 ServletContext app) 119 throws IOException 120 { 121 return getPath(path, request, app).getLastModified(); 122 } 123 124 132 public Iterator getAttributeNames(String path, 133 HttpServletRequest request, 134 ServletContext app) 135 throws IOException 136 { 137 return NullIterator.create(); 138 } 139 140 148 public String getAttribute(AttributeName name, 149 String path, 150 HttpServletRequest request, 151 ServletContext app) 152 throws IOException 153 { 154 return null; 155 } 156 157 168 public boolean setAttribute(AttributeName name, String value, 169 String path, 170 HttpServletRequest request, 171 ServletContext app) 172 throws IOException 173 { 174 return false; 175 } 176 177 185 public void removeAttribute(String name, 186 String path, 187 HttpServletRequest request, 188 ServletContext app) 189 throws IOException 190 { 191 } 192 193 198 public String []list(String path, 199 HttpServletRequest request, 200 ServletContext app) 201 throws IOException 202 { 203 return getPath(path, request, app).list(); 204 } 205 206 213 public boolean mkdir(String path, 214 HttpServletRequest request, 215 ServletContext app) 216 throws IOException 217 { 218 return getPath(path, request, app).mkdir(); 219 } 220 221 228 public boolean rmdir(String path, 229 HttpServletRequest request, 230 ServletContext app) 231 throws IOException 232 { 233 return getPath(path, request, app).remove(); 234 } 235 236 243 public boolean remove(String path, 244 HttpServletRequest request, 245 ServletContext app) 246 throws IOException 247 { 248 return getPath(path, request, app).remove(); 249 } 250 251 258 public OutputStream openWrite(String path, 259 HttpServletRequest request, 260 ServletContext app) 261 throws IOException 262 { 263 return getPath(path, request, app).openWrite(); 264 } 265 266 273 public InputStream openRead(String path, 274 HttpServletRequest request, 275 ServletContext app) 276 throws IOException 277 { 278 return getPath(path, request, app).openRead(); 279 } 280 281 284 protected Path getPath(String path, 285 HttpServletRequest request, 286 ServletContext app) 287 throws IOException 288 { 289 Path appDir = ((Application) app).getAppDir(); 290 291 return appDir.lookup("./" + path); 292 } 293 } 294 | Popular Tags |