View Javadoc

1   //========================================================================
2   //Copyright 2008 Mort Bay Consulting Pty. Ltd.
3   //------------------------------------------------------------------------
4   //Licensed under the Apache License, Version 2.0 (the "License");
5   //you may not use this file except in compliance with the License.
6   //You may obtain a copy of the License at
7   //http://www.apache.org/licenses/LICENSE-2.0
8   //Unless required by applicable law or agreed to in writing, software
9   //distributed under the License is distributed on an "AS IS" BASIS,
10  //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11  //See the License for the specific language governing permissions and
12  //limitations under the License.
13  //========================================================================
14  
15  package org.mortbay.jetty.client.webdav;
16  
17  import java.io.IOException;
18  
19  import org.mortbay.io.Buffer;
20  import org.mortbay.jetty.client.HttpExchange;
21  import org.mortbay.log.Log;
22  
23  
24  public class WebdavSupportedExchange extends HttpExchange
25  {
26      private boolean _webdavSupported = false;
27      private boolean _isComplete = false;
28  
29      protected void onResponseHeader(Buffer name, Buffer value) throws IOException
30      {
31          if (Log.isDebugEnabled())
32              Log.debug("WebdavSupportedExchange:Header:" + name.toString() + " / " + value.toString() );
33          if ( "DAV".equals( name.toString() ) )
34          {
35              if ( value.toString().indexOf( "1" ) >= 0 || value.toString().indexOf( "2" ) >= 0 )
36              {
37                  _webdavSupported = true;
38              }
39          }
40  
41          super.onResponseHeader(name, value);
42      }
43  
44      public void waitTilCompletion() throws InterruptedException
45      {
46          synchronized (this)
47          {
48              while ( !_isComplete)
49              {
50                  this.wait();
51              }
52          }
53      }
54  
55      protected void onResponseComplete() throws IOException
56      {
57          _isComplete = true;
58  
59          super.onResponseComplete();
60      }
61  
62      public boolean isWebdavSupported()
63      {
64          return _webdavSupported;
65      }
66  }