View Javadoc

1   // ========================================================================
2   // Copyright (c) 2008-2009 Mort Bay Consulting Pty. Ltd.
3   // ------------------------------------------------------------------------
4   // All rights reserved. This program and the accompanying materials
5   // are made available under the terms of the Eclipse Public License v1.0
6   // and Apache License v2.0 which accompanies this distribution.
7   // The Eclipse Public License is available at 
8   // http://www.eclipse.org/legal/epl-v10.html
9   // The Apache License v2.0 is available at
10  // http://www.opensource.org/licenses/apache2.0.php
11  // You may elect to redistribute this code under either of these licenses. 
12  // ========================================================================
13  
14  package org.eclipse.jetty.client.webdav;
15  
16  import java.io.IOException;
17  
18  import org.eclipse.jetty.client.HttpExchange;
19  import org.eclipse.jetty.io.Buffer;
20  import org.eclipse.jetty.util.log.Log;
21  
22  
23  public class WebdavSupportedExchange extends HttpExchange
24  {
25      private boolean _webdavSupported = false;
26      private boolean _isComplete = false;
27  
28      protected void onResponseHeader(Buffer name, Buffer value) throws IOException
29      {
30          if (Log.isDebugEnabled())
31              Log.debug("WebdavSupportedExchange:Header:" + name.toString() + " / " + value.toString() );
32          if ( "DAV".equals( name.toString() ) )
33          {
34              if ( value.toString().indexOf( "1" ) >= 0 || value.toString().indexOf( "2" ) >= 0 )
35              {
36                  _webdavSupported = true;
37              }
38          }
39  
40          super.onResponseHeader(name, value);
41      }
42  
43      public void waitTilCompletion() throws InterruptedException
44      {
45          synchronized (this)
46          {
47              while ( !_isComplete)
48              {
49                  this.wait();
50              }
51          }
52      }
53  
54      protected void onResponseComplete() throws IOException
55      {
56          _isComplete = true;
57  
58          super.onResponseComplete();
59      }
60  
61      public boolean isWebdavSupported()
62      {
63          return _webdavSupported;
64      }
65  }