103928aee4356845252ac6b662d5c72c29903813eJake Slack//
203928aee4356845252ac6b662d5c72c29903813eJake Slack//  ========================================================================
303928aee4356845252ac6b662d5c72c29903813eJake Slack//  Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
403928aee4356845252ac6b662d5c72c29903813eJake Slack//  ------------------------------------------------------------------------
503928aee4356845252ac6b662d5c72c29903813eJake Slack//  All rights reserved. This program and the accompanying materials
603928aee4356845252ac6b662d5c72c29903813eJake Slack//  are made available under the terms of the Eclipse Public License v1.0
703928aee4356845252ac6b662d5c72c29903813eJake Slack//  and Apache License v2.0 which accompanies this distribution.
803928aee4356845252ac6b662d5c72c29903813eJake Slack//
903928aee4356845252ac6b662d5c72c29903813eJake Slack//      The Eclipse Public License is available at
1003928aee4356845252ac6b662d5c72c29903813eJake Slack//      http://www.eclipse.org/legal/epl-v10.html
1103928aee4356845252ac6b662d5c72c29903813eJake Slack//
1203928aee4356845252ac6b662d5c72c29903813eJake Slack//      The Apache License v2.0 is available at
1303928aee4356845252ac6b662d5c72c29903813eJake Slack//      http://www.opensource.org/licenses/apache2.0.php
1403928aee4356845252ac6b662d5c72c29903813eJake Slack//
1503928aee4356845252ac6b662d5c72c29903813eJake Slack//  You may elect to redistribute this code under either of these licenses.
1603928aee4356845252ac6b662d5c72c29903813eJake Slack//  ========================================================================
1703928aee4356845252ac6b662d5c72c29903813eJake Slack//
1803928aee4356845252ac6b662d5c72c29903813eJake Slack
1903928aee4356845252ac6b662d5c72c29903813eJake Slackpackage org.eclipse.jetty.client.webdav;
2003928aee4356845252ac6b662d5c72c29903813eJake Slack
2103928aee4356845252ac6b662d5c72c29903813eJake Slackimport java.io.IOException;
2203928aee4356845252ac6b662d5c72c29903813eJake Slack
2303928aee4356845252ac6b662d5c72c29903813eJake Slackimport org.eclipse.jetty.client.HttpExchange;
2403928aee4356845252ac6b662d5c72c29903813eJake Slackimport org.eclipse.jetty.http.HttpStatus;
2503928aee4356845252ac6b662d5c72c29903813eJake Slackimport org.eclipse.jetty.io.Buffer;
2603928aee4356845252ac6b662d5c72c29903813eJake Slackimport org.eclipse.jetty.util.log.Log;
2703928aee4356845252ac6b662d5c72c29903813eJake Slackimport org.eclipse.jetty.util.log.Logger;
2803928aee4356845252ac6b662d5c72c29903813eJake Slack
2903928aee4356845252ac6b662d5c72c29903813eJake Slack
3003928aee4356845252ac6b662d5c72c29903813eJake Slackpublic class PropfindExchange extends HttpExchange
3103928aee4356845252ac6b662d5c72c29903813eJake Slack{
3203928aee4356845252ac6b662d5c72c29903813eJake Slack    private static final Logger LOG = Log.getLogger(PropfindExchange.class);
3303928aee4356845252ac6b662d5c72c29903813eJake Slack
3403928aee4356845252ac6b662d5c72c29903813eJake Slack    boolean _propertyExists = false;
3503928aee4356845252ac6b662d5c72c29903813eJake Slack
3603928aee4356845252ac6b662d5c72c29903813eJake Slack    /* ------------------------------------------------------------ */
3703928aee4356845252ac6b662d5c72c29903813eJake Slack    @Override
3803928aee4356845252ac6b662d5c72c29903813eJake Slack    protected void onResponseStatus(Buffer version, int status, Buffer reason) throws IOException
3903928aee4356845252ac6b662d5c72c29903813eJake Slack    {
4003928aee4356845252ac6b662d5c72c29903813eJake Slack        if ( status == HttpStatus.OK_200 )
4103928aee4356845252ac6b662d5c72c29903813eJake Slack        {
4203928aee4356845252ac6b662d5c72c29903813eJake Slack            LOG.debug( "PropfindExchange:Status: Exists" );
4303928aee4356845252ac6b662d5c72c29903813eJake Slack            _propertyExists = true;
4403928aee4356845252ac6b662d5c72c29903813eJake Slack        }
4503928aee4356845252ac6b662d5c72c29903813eJake Slack        else
4603928aee4356845252ac6b662d5c72c29903813eJake Slack        {
4703928aee4356845252ac6b662d5c72c29903813eJake Slack            LOG.debug( "PropfindExchange:Status: Not Exists" );
4803928aee4356845252ac6b662d5c72c29903813eJake Slack        }
4903928aee4356845252ac6b662d5c72c29903813eJake Slack
5003928aee4356845252ac6b662d5c72c29903813eJake Slack        super.onResponseStatus(version, status, reason);
5103928aee4356845252ac6b662d5c72c29903813eJake Slack    }
5203928aee4356845252ac6b662d5c72c29903813eJake Slack
5303928aee4356845252ac6b662d5c72c29903813eJake Slack    public boolean exists()
5403928aee4356845252ac6b662d5c72c29903813eJake Slack    {
5503928aee4356845252ac6b662d5c72c29903813eJake Slack        return _propertyExists;
5603928aee4356845252ac6b662d5c72c29903813eJake Slack    }
5703928aee4356845252ac6b662d5c72c29903813eJake Slack}
58