source: trunk/docx4j/etc/commons-vfs.patch @ 449

Revision 449, 16.4 KB checked in by jharrop, 4 years ago (diff)

Moved stuff that doesn't need to go into the jar out of src/main/resources.

  • C:/Users/jojada/workspace/Eclipse3.3/Jason/Commons-VFS/core/src/main/java/org/apache/commons/vfs/provider/http/ThreadLocalHttpConnectionManager.java

     
    1919import org.apache.commons.httpclient.HostConfiguration; 
    2020import org.apache.commons.httpclient.HttpConnection; 
    2121import org.apache.commons.httpclient.HttpConnectionManager; 
     22import org.apache.commons.httpclient.params.HttpConnectionManagerParams; 
    2223 
    2324import java.io.IOException; 
    2425import java.io.InputStream; 
     
    4041 */ 
    4142public class ThreadLocalHttpConnectionManager implements HttpConnectionManager 
    4243{ 
    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//    } 
    4677 
    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  
    6378    /** 
    6479     * Since the same connection is about to be reused, make sure the 
    6580     * previous request was completely processed, and if not 
     
    99114    /** 
    100115     * Collection of parameters associated with this connection manager. 
    101116     */ 
    102     private ConnectionParameters params = new ConnectionParameters(); 
     117    //private ConnectionParameters params = new ConnectionParameters(); 
     118    private HttpConnectionManagerParams params = new HttpConnectionManagerParams(); 
    103119 
    104120    /** 
    105121     * release the connection of the current thread 
     
    181197    } 
    182198 
    183199    /** 
    184      * @see HttpConnectionManager#getConnection(HostConfiguration, long) 
     200     * @see HttpConnectionManager#getConnectionWithTimeout(HostConfiguration, long) 
    185201     * @since 3.0 
    186202     */ 
    187203    public HttpConnection getConnectionWithTimeout( 
     
    194210            httpConnection = new HttpConnection(hostConfiguration); 
    195211            setLocalHttpConnection(httpConnection); 
    196212            httpConnection.setHttpConnectionManager(this); 
    197             this.params.populateParameters(httpConnection); 
     213//            this.params.populateParameters(httpConnection); 
     214            httpConnection.getParams().setDefaults(this.params); 
     215             
    198216        } 
    199217        else 
    200218        { 
     
    257275    } 
    258276 
    259277    /** 
     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    /** 
    260306     * @since 3.0 
    261307     */ 
    262308    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

     
    13421342            } 
    13431343            catch (Exception exc) 
    13441344            { 
     1345                exc.printStackTrace(); 
    13451346                throw new FileSystemException("vfs.provider/get-type.error", new Object[]{name}, exc); 
    13461347            } 
    13471348 
  • C:/Users/jojada/workspace/Eclipse3.3/Jason/Commons-VFS/core/pom.xml

     
    7474                <dependency> 
    7575                        <groupId>commons-httpclient</groupId> 
    7676                        <artifactId>commons-httpclient</artifactId> 
    77                         <version>2.0.2</version> 
     77                        <version>3.0.1</version> 
    7878                        <optional>true</optional> 
    7979                </dependency> 
    8080                <dependency> 
  • C:/Users/jojada/workspace/Eclipse3.3/Jason/Commons-VFS/pom.xml

     
    142142    </repository> 
    143143  </repositories> 
    144144 
     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                 
    145231  <distributionManagement> 
    146232    <repository> 
    147233      <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

     
    1616 */ 
    1717package org.apache.commons.vfs.provider.webdav; 
    1818 
     19import java.io.DataInputStream; 
     20import java.io.FilterInputStream; 
     21import java.io.IOException; 
     22import java.io.InputStream; 
     23import java.io.OutputStream; 
     24import java.net.HttpURLConnection; 
     25import java.util.ArrayList; 
     26import java.util.Enumeration; 
     27import java.util.HashMap; 
     28import java.util.List; 
     29import java.util.Map; 
     30import java.util.Set; 
     31import java.util.TreeSet; 
     32 
    1933import org.apache.commons.httpclient.HttpException; 
    2034import org.apache.commons.httpclient.HttpMethodBase; 
    2135import org.apache.commons.httpclient.HttpStatus; 
     
    2640import org.apache.commons.vfs.NameScope; 
    2741import org.apache.commons.vfs.RandomAccessContent; 
    2842import org.apache.commons.vfs.provider.AbstractFileObject; 
    29 import org.apache.commons.vfs.provider.AbstractRandomAccessContent; 
     43import org.apache.commons.vfs.provider.AbstractRandomAccessStreamContent; 
    3044import org.apache.commons.vfs.provider.GenericFileName; 
    3145import org.apache.commons.vfs.provider.URLFileName; 
    32 import org.apache.commons.vfs.provider.AbstractRandomAccessStreamContent; 
    3346import org.apache.commons.vfs.util.FileObjectUtils; 
    3447import org.apache.commons.vfs.util.MonitorOutputStream; 
    3548import org.apache.commons.vfs.util.RandomAccessMode; 
     
    3750import org.apache.webdav.lib.WebdavResource; 
    3851import org.apache.webdav.lib.methods.DepthSupport; 
    3952import org.apache.webdav.lib.methods.OptionsMethod; 
     53import org.apache.webdav.lib.methods.PropFindMethod; 
    4054import org.apache.webdav.lib.methods.XMLResponseMethodBase; 
    4155import org.apache.webdav.lib.properties.ResourceTypeProperty; 
    4256 
    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  
    5757/** 
    5858 * A WebDAV file. 
    5959 * 
     
    114114     */ 
    115115    private void setDavResource(WebdavResource resource) throws Exception 
    116116    { 
     117         
    117118        redirectionResolved = false; 
    118119 
    119120        final URLFileName name = (URLFileName) getName(); 
     
    136137        { 
    137138            /* now fill the dav properties */ 
    138139            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); 
    140148            configureMethod(optionsMethod); 
    141149            try 
    142150            { 
     
    160168                } 
    161169                // handle the (maybe) redirected url 
    162170                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()); 
    164174 
    165175                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); 
    178178                if (!exists) 
    179179                { 
    180180                    injectType(FileType.IMAGINARY); 
    181181                    return; 
    182182                } 
    183  
     183                 
    184184                try 
    185185                { 
    186186                    resource.setProperties(WebdavResource.DEFAULT, 1); 
    187187                } 
    188188                catch (IOException e) 
    189189                { 
     190                        e.printStackTrace(); 
     191                         
    190192                    throw new FileSystemException(e); 
    191193                } 
    192194            } 
    193195            finally 
    194196            { 
    195                 optionsMethod.releaseConnection(); 
     197                optionsMethod.releaseConnection(); 
    196198            } 
    197199        } 
    198200 
    199201        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()) 
    201209        { 
    202210            injectType(FileType.FOLDER); 
    203211        } 
     
    206214            injectType(FileType.FILE); 
    207215        } 
    208216    } 
     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    } 
    209239 
    210240    protected void configureMethod(HttpMethodBase httpMethod) 
    211241    { 
     
    468498            // final boolean ok = resource.putMethod(outstr.toByteArray()); 
    469499            try 
    470500            { 
     501                System.out.println("In onClose"); 
    471502                final boolean ok = resource.putMethod(webdavTmp.getContent().getInputStream()); 
    472503                if (!ok) 
    473504                { 
     
    485516 
    486517    protected void handleCreate(final FileType newType) throws Exception 
    487518    { 
     519        System.out.println("In handleCreate"); 
    488520        // imario@apache.org: this is to reread the webdav internal state 
    489521        // Ill treat this as workaround 
    490522        reattach(); 
  • C:/Users/jojada/workspace/Eclipse3.3/Jason/Commons-VFS/sandbox/pom.xml

     
    5050                <dependency> 
    5151                        <groupId>slide</groupId> 
    5252                        <artifactId>jakarta-slide-webdavlib</artifactId> 
     53                        <!-- FIXME: this snapshot is too old; you need one from Dec 06 or later -->  
    5354                        <version>20050629.161100</version> 
    5455                        <optional>true</optional> 
    5556                </dependency> 
     
    6263                <dependency> 
    6364                        <groupId>commons-httpclient</groupId> 
    6465                        <artifactId>commons-httpclient</artifactId> 
    65                         <version>2.0.2</version> 
     66                        <version>3.0.1</version> 
    6667                        <optional>true</optional> 
    6768                </dependency> 
    6869                <dependency> 
Note: See TracBrowser for help on using the repository browser.