source:
trunk/docx4j/etc/commons-vfs.patch
@
449
| Revision 449, 16.4 KB checked in by jharrop, 4 years ago (diff) |
|---|
-
C:/Users/jojada/workspace/Eclipse3.3/Jason/Commons-VFS/core/src/main/java/org/apache/commons/vfs/provider/http/ThreadLocalHttpConnectionManager.java
19 19 import org.apache.commons.httpclient.HostConfiguration; 20 20 import org.apache.commons.httpclient.HttpConnection; 21 21 import org.apache.commons.httpclient.HttpConnectionManager; 22 import org.apache.commons.httpclient.params.HttpConnectionManagerParams; 22 23 23 24 import java.io.IOException; 24 25 import java.io.InputStream; … … 40 41 */ 41 42 public class ThreadLocalHttpConnectionManager implements HttpConnectionManager 42 43 { 43 private static class ConnectionParameters 44 { 45 private boolean staleCheck; 44 45 /* 46 * Revision 209275 was compatible with HttpClient 3.0.1 47 * Revision 209411 reverted back to HttpClient 2.0.2 48 * on the basis that HttpClient 3.0-rc3 and WebDavLib were not compatible, 49 * which was the case at the time (July 2005), but ceased being the case 50 * in Dec 2006 - see https://issues.apache.org/bugzilla/show_bug.cgi?id=35213 51 * 52 * This version effectively applies the patch which takes you 53 * from 209411 to 209275. 54 * 55 */ 56 57 58 // private static class ConnectionParameters 59 // { 60 // private boolean staleCheck; 61 // 62 // public boolean isStaleCheckingEnabled() 63 // { 64 // return staleCheck; 65 // } 66 // 67 // public void setStaleCheckingEnabled(boolean b) 68 // { 69 // staleCheck = b; 70 // } 71 // 72 // public void populateParameters(HttpConnection connection) 73 // { 74 // connection.setStaleCheckingEnabled(staleCheck); 75 // } 76 // } 46 77 47 public boolean isStaleCheckingEnabled()48 {49 return staleCheck;50 }51 52 public void setStaleCheckingEnabled(boolean b)53 {54 staleCheck = b;55 }56 57 public void populateParameters(HttpConnection connection)58 {59 connection.setStaleCheckingEnabled(staleCheck);60 }61 }62 63 78 /** 64 79 * Since the same connection is about to be reused, make sure the 65 80 * previous request was completely processed, and if not … … 99 114 /** 100 115 * Collection of parameters associated with this connection manager. 101 116 */ 102 private ConnectionParameters params = new ConnectionParameters(); 117 //private ConnectionParameters params = new ConnectionParameters(); 118 private HttpConnectionManagerParams params = new HttpConnectionManagerParams(); 103 119 104 120 /** 105 121 * release the connection of the current thread … … 181 197 } 182 198 183 199 /** 184 * @see HttpConnectionManager#getConnection (HostConfiguration, long)200 * @see HttpConnectionManager#getConnectionWithTimeout(HostConfiguration, long) 185 201 * @since 3.0 186 202 */ 187 203 public HttpConnection getConnectionWithTimeout( … … 194 210 httpConnection = new HttpConnection(hostConfiguration); 195 211 setLocalHttpConnection(httpConnection); 196 212 httpConnection.setHttpConnectionManager(this); 197 this.params.populateParameters(httpConnection); 213 // this.params.populateParameters(httpConnection); 214 httpConnection.getParams().setDefaults(this.params); 215 198 216 } 199 217 else 200 218 { … … 257 275 } 258 276 259 277 /** 278 * Returns {@link HttpConnectionManagerParams parameters} associated 279 * with this connection manager. 280 * 281 * @see HttpConnectionManagerParams 282 * @since 2.1 283 */ 284 public HttpConnectionManagerParams getParams() 285 { 286 return this.params; 287 } 288 289 /** 290 * Assigns {@link HttpConnectionManagerParams parameters} for this 291 * connection manager. 292 * 293 * @see HttpConnectionManagerParams 294 * @since 2.1 295 */ 296 public void setParams(final HttpConnectionManagerParams params) 297 { 298 if (params == null) 299 { 300 throw new IllegalArgumentException("Parameters may not be null"); 301 } 302 this.params = params; 303 } 304 305 /** 260 306 * @since 3.0 261 307 */ 262 308 public void closeIdleConnections(long idleTimeout) -
C:/Users/jojada/workspace/Eclipse3.3/Jason/Commons-VFS/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileObject.java
1342 1342 } 1343 1343 catch (Exception exc) 1344 1344 { 1345 exc.printStackTrace(); 1345 1346 throw new FileSystemException("vfs.provider/get-type.error", new Object[]{name}, exc); 1346 1347 } 1347 1348 -
C:/Users/jojada/workspace/Eclipse3.3/Jason/Commons-VFS/core/pom.xml
74 74 <dependency> 75 75 <groupId>commons-httpclient</groupId> 76 76 <artifactId>commons-httpclient</artifactId> 77 <version> 2.0.2</version>77 <version>3.0.1</version> 78 78 <optional>true</optional> 79 79 </dependency> 80 80 <dependency> -
C:/Users/jojada/workspace/Eclipse3.3/Jason/Commons-VFS/pom.xml
142 142 </repository> 143 143 </repositories> 144 144 145 <dependencies> 146 <dependency> 147 <groupId>commons-logging</groupId> 148 <artifactId>commons-logging</artifactId> 149 <version>1.0.4</version> 150 </dependency> 151 <dependency> 152 <groupId>ant</groupId> 153 <artifactId>ant</artifactId> 154 <version>1.6.2</version> 155 <optional>true</optional> 156 </dependency> 157 <dependency> 158 <groupId>commons-net</groupId> 159 <artifactId>commons-net</artifactId> 160 <version>1.4.1</version> 161 <optional>true</optional> 162 </dependency> 163 <!--TODO:Revert to [compress] if/when released 164 <dependency> 165 <groupId>commons-compress</groupId> 166 <artifactId>commons-compress</artifactId> 167 <version>SNAPSHOT</version> 168 <optional>true</optional> 169 </dependency--> 170 <dependency> 171 <groupId>commons-collections</groupId> 172 <artifactId>commons-collections</artifactId> 173 <version>3.1</version> 174 <optional>true</optional> 175 </dependency> 176 <dependency> 177 <groupId>jdom</groupId> 178 <artifactId>jdom</artifactId> 179 <version>1.0</version> 180 <optional>true</optional> 181 </dependency> 182 <!-- 183 <dependency> 184 <groupId>commons-httpclient</groupId> 185 <artifactId>commons-httpclient</artifactId> 186 <version>3.0.1</version> 187 <optional>true</optional> 188 </dependency> --> 189 <!-- 190 <version>2.0.2</version> 191 --> 192 <dependency> 193 <groupId>com.jcraft</groupId> 194 <artifactId>jsch</artifactId> 195 <version>0.1.31</version> 196 <optional>true</optional> 197 </dependency> 198 <dependency> 199 <groupId>xml-apis</groupId> 200 <artifactId>xml-apis</artifactId> 201 <version>1.0.b2</version> 202 <optional>true</optional> 203 </dependency> 204 <dependency> 205 <groupId>oro</groupId> 206 <artifactId>oro</artifactId> 207 <version>2.0.8</version> 208 <optional>true</optional> 209 </dependency> 210 <dependency> 211 <groupId>junit</groupId> 212 <artifactId>junit</artifactId> 213 <version>3.8.1</version> 214 <scope>test</scope> 215 </dependency> 216 <!-- sandbox --> 217 <dependency> 218 <groupId>jcifs</groupId> 219 <artifactId>jcifs</artifactId> 220 <version>0.8.3</version> 221 <optional>true</optional> 222 </dependency> 223 <dependency> 224 <groupId>javax.mail</groupId> 225 <artifactId>mail</artifactId> 226 <version>1.4</version> 227 <optional>true</optional> 228 </dependency> 229 </dependencies> 230 145 231 <distributionManagement> 146 232 <repository> 147 233 <id>apache.releases</id> -
C:/Users/jojada/workspace/Eclipse3.3/Jason/Commons-VFS/sandbox/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java
16 16 */ 17 17 package org.apache.commons.vfs.provider.webdav; 18 18 19 import java.io.DataInputStream; 20 import java.io.FilterInputStream; 21 import java.io.IOException; 22 import java.io.InputStream; 23 import java.io.OutputStream; 24 import java.net.HttpURLConnection; 25 import java.util.ArrayList; 26 import java.util.Enumeration; 27 import java.util.HashMap; 28 import java.util.List; 29 import java.util.Map; 30 import java.util.Set; 31 import java.util.TreeSet; 32 19 33 import org.apache.commons.httpclient.HttpException; 20 34 import org.apache.commons.httpclient.HttpMethodBase; 21 35 import org.apache.commons.httpclient.HttpStatus; … … 26 40 import org.apache.commons.vfs.NameScope; 27 41 import org.apache.commons.vfs.RandomAccessContent; 28 42 import org.apache.commons.vfs.provider.AbstractFileObject; 29 import org.apache.commons.vfs.provider.AbstractRandomAccess Content;43 import org.apache.commons.vfs.provider.AbstractRandomAccessStreamContent; 30 44 import org.apache.commons.vfs.provider.GenericFileName; 31 45 import org.apache.commons.vfs.provider.URLFileName; 32 import org.apache.commons.vfs.provider.AbstractRandomAccessStreamContent;33 46 import org.apache.commons.vfs.util.FileObjectUtils; 34 47 import org.apache.commons.vfs.util.MonitorOutputStream; 35 48 import org.apache.commons.vfs.util.RandomAccessMode; … … 37 50 import org.apache.webdav.lib.WebdavResource; 38 51 import org.apache.webdav.lib.methods.DepthSupport; 39 52 import org.apache.webdav.lib.methods.OptionsMethod; 53 import org.apache.webdav.lib.methods.PropFindMethod; 40 54 import org.apache.webdav.lib.methods.XMLResponseMethodBase; 41 55 import org.apache.webdav.lib.properties.ResourceTypeProperty; 42 56 43 import java.io.DataInputStream;44 import java.io.FilterInputStream;45 import java.io.IOException;46 import java.io.InputStream;47 import java.io.OutputStream;48 import java.net.HttpURLConnection;49 import java.util.ArrayList;50 import java.util.Enumeration;51 import java.util.HashMap;52 import java.util.List;53 import java.util.Map;54 import java.util.Set;55 import java.util.TreeSet;56 57 57 /** 58 58 * A WebDAV file. 59 59 * … … 114 114 */ 115 115 private void setDavResource(WebdavResource resource) throws Exception 116 116 { 117 117 118 redirectionResolved = false; 118 119 119 120 final URLFileName name = (URLFileName) getName(); … … 136 137 { 137 138 /* now fill the dav properties */ 138 139 String pathEncoded = name.getPathQueryEncoded(urlCharset); 139 final OptionsMethod optionsMethod = new OptionsMethod(pathEncoded); 140 141 // We only execute the options method in order to 142 // setAllowedMethods. Haven't looked to see how important doing that is. 143 144 // Existence is determined separately (see existsTest). 145 146 147 final OptionsMethod optionsMethod = new OptionsMethod(pathEncoded); 140 148 configureMethod(optionsMethod); 141 149 try 142 150 { … … 160 168 } 161 169 // handle the (maybe) redirected url 162 170 redirectionResolved = true; 163 resource.getHttpURL().setEscapedPath(optionsMethod.getURI().getPath()); 171 System.out.println(optionsMethod.getURI().getPath()); 172 // resource.getHttpURL().setEscapedPath(optionsMethod.getURI().getPath()); 173 resource.getHttpURL().setEscapedPath(optionsMethod.getURI().getEscapedPath()); 164 174 165 175 setAllowedMethods(optionsMethod.getAllowedMethods()); 166 boolean exists = false; 167 for (Enumeration enumeration = optionsMethod.getAllowedMethods(); enumeration.hasMoreElements();) 168 { 169 final String method = (String) enumeration.nextElement(); 170 // IIS allows GET even if the file is non existend - so changed to COPY 171 // if (method.equals("GET")) 172 if (method.equals("COPY")) 173 { 174 exists = true; 175 break; 176 } 177 } 176 177 boolean exists = existsTest(pathEncoded); 178 178 if (!exists) 179 179 { 180 180 injectType(FileType.IMAGINARY); 181 181 return; 182 182 } 183 183 184 184 try 185 185 { 186 186 resource.setProperties(WebdavResource.DEFAULT, 1); 187 187 } 188 188 catch (IOException e) 189 189 { 190 e.printStackTrace(); 191 190 192 throw new FileSystemException(e); 191 193 } 192 194 } 193 195 finally 194 196 { 195 optionsMethod.releaseConnection();197 optionsMethod.releaseConnection(); 196 198 } 197 199 } 198 200 199 201 ResourceTypeProperty resourceType = resource.getResourceType(); 200 if (resourceType.isCollection()) 202 if (resourceType == null) { 203 //This should not happen because resource has been checked for its existence 204 //and DAV:resourcetype property MUST be defined on all DAV compliant resources. 205 //However there may be a non-compliant server. 206 injectType(FileType.FILE_OR_FOLDER); 207 208 } else if (resourceType.isCollection()) 201 209 { 202 210 injectType(FileType.FOLDER); 203 211 } … … 206 214 injectType(FileType.FILE); 207 215 } 208 216 } 217 218 private boolean existsTest(String pathEncoded) throws IOException { 219 220 final PropFindMethod propFindMethod = new PropFindMethod(pathEncoded); 221 configureMethod(propFindMethod); 222 try 223 { 224 propFindMethod.setFollowRedirects(true); 225 final int status = fileSystem.getClient().executeMethod(propFindMethod); 226 if (status < 200 || status > 299) 227 { 228 //injectType(FileType.IMAGINARY); 229 return false; 230 } else { 231 return true; 232 } 233 } 234 finally 235 { 236 propFindMethod.releaseConnection(); 237 } 238 } 209 239 210 240 protected void configureMethod(HttpMethodBase httpMethod) 211 241 { … … 468 498 // final boolean ok = resource.putMethod(outstr.toByteArray()); 469 499 try 470 500 { 501 System.out.println("In onClose"); 471 502 final boolean ok = resource.putMethod(webdavTmp.getContent().getInputStream()); 472 503 if (!ok) 473 504 { … … 485 516 486 517 protected void handleCreate(final FileType newType) throws Exception 487 518 { 519 System.out.println("In handleCreate"); 488 520 // imario@apache.org: this is to reread the webdav internal state 489 521 // Ill treat this as workaround 490 522 reattach(); -
C:/Users/jojada/workspace/Eclipse3.3/Jason/Commons-VFS/sandbox/pom.xml
50 50 <dependency> 51 51 <groupId>slide</groupId> 52 52 <artifactId>jakarta-slide-webdavlib</artifactId> 53 <!-- FIXME: this snapshot is too old; you need one from Dec 06 or later --> 53 54 <version>20050629.161100</version> 54 55 <optional>true</optional> 55 56 </dependency> … … 62 63 <dependency> 63 64 <groupId>commons-httpclient</groupId> 64 65 <artifactId>commons-httpclient</artifactId> 65 <version> 2.0.2</version>66 <version>3.0.1</version> 66 67 <optional>true</optional> 67 68 </dependency> 68 69 <dependency>
Note: See TracBrowser
for help on using the repository browser.
