1
17 package org.apache.catalina.webresources;
18
19 import java.io.File;
20 import java.io.IOException;
21 import java.io.InputStream;
22 import java.net.URL;
23 import java.security.cert.Certificate;
24 import java.util.jar.Manifest;
25
26 import org.apache.catalina.WebResource;
27 import org.apache.catalina.WebResourceRoot;
28
29 public class EmptyResource implements WebResource {
30
31 private final WebResourceRoot root;
32 private final String webAppPath;
33 private final File file;
34
35 public EmptyResource(WebResourceRoot root, String webAppPath) {
36 this(root, webAppPath, null);
37 }
38
39 public EmptyResource(WebResourceRoot root, String webAppPath, File file) {
40 this.root = root;
41 this.webAppPath = webAppPath;
42 this.file = file;
43 }
44
45 @Override
46 public long getLastModified() {
47 return 0;
48 }
49
50 @Override
51 public String getLastModifiedHttp() {
52 return null;
53 }
54
55 @Override
56 public boolean exists() {
57 return false;
58 }
59
60 @Override
61 public boolean isVirtual() {
62 return false;
63 }
64
65 @Override
66 public boolean isDirectory() {
67 return false;
68 }
69
70 @Override
71 public boolean isFile() {
72 return false;
73 }
74
75 @Override
76 public boolean delete() {
77 return false;
78 }
79
80 @Override
81 public String getName() {
82 int index = webAppPath.lastIndexOf('/');
83 if (index == -1) {
84 return webAppPath;
85 } else {
86 return webAppPath.substring(index + 1);
87 }
88 }
89
90 @Override
91 public long getContentLength() {
92 return -1;
93 }
94
95 @Override
96 public String getCanonicalPath() {
97 if (file == null) {
98 return null;
99 } else {
100 try {
101 return file.getCanonicalPath();
102 } catch (IOException e) {
103 return null;
104 }
105 }
106 }
107
108 @Override
109 public boolean canRead() {
110 return false;
111 }
112
113 @Override
114 public String getWebappPath() {
115 return webAppPath;
116 }
117
118 @Override
119 public String getETag() {
120 return null;
121 }
122
123 @Override
124 public void setMimeType(String mimeType) {
125
126 }
127
128 @Override
129 public String getMimeType() {
130 return null;
131 }
132
133 @Override
134 public InputStream getInputStream() {
135 return null;
136 }
137
138 @Override
139 public byte[] getContent() {
140 return null;
141 }
142
143 @Override
144 public long getCreation() {
145 return 0;
146 }
147
148 @Override
149 public URL getURL() {
150 return null;
151 }
152
153 @Override
154 public URL getCodeBase() {
155 return null;
156 }
157
158 @Override
159 public Certificate[] getCertificates() {
160 return null;
161 }
162
163 @Override
164 public Manifest getManifest() {
165 return null;
166 }
167
168 @Override
169 public WebResourceRoot getWebResourceRoot() {
170 return root;
171 }
172 }
173