Re: Fixes for bugs in WebdavResource putMethod and getMethod

Antoine Levy-Lambert <[email protected]> Sun, 11 Feb 2007 22:20:33 -0500
Newsgroups gmane.comp.jakarta.slide.devel
Message-ID <[email protected]>
Hello Michael,

I have just committed this fix too.

Best regards,

Antoine Levy-Lambert

On Feb 8, 2007, at 5:46 PM, Michael Christoff wrote:

> FileInputStream fis = null;
>  5:        try {
>  6:            setClient();
>  7:            PutMethod method = new PutMethod 
> (URIUtil.encodePathQuery(path));
>  8:            generateIfHeader(method);
>  9:            if (getGetContentType() != null && !getGetContentType 
> ().equals(""))
> 10:                method.setRequestHeader("Content-Type",  
> getGetContentType());
> 11:            long fileLength = file.length();
> 12:            method.setRequestContentLength(fileLength <=  
> Integer.MAX_VALUE
> 13:                                           ? (int) fileLength
> 14:                                           :  
> PutMethod.CONTENT_LENGTH_CHUNKED);
> 15:            fis = new FileInputStream(file);
> 16:            method.setRequestBody(fis);
> 17:            generateTransactionHeader(method);
> 18:            int statusCode = client.executeMethod(method);
> 19:
> 20:            setStatusCode(statusCode);
> 21:            return (statusCode >= 200 && statusCode < 300) ?  
> true : false;
> 22:
> 23:        } finally {
> 24:            if(fis != null)
> 25:                fis.close();
> 26:        }