LibreOffice Module ucb (master)  1
neon/DAVResourceAccess.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * Copyright 2000, 2010 Oracle and/or its affiliates.
7  *
8  * OpenOffice.org - a multi-platform office productivity suite
9  *
10  * This file is part of OpenOffice.org.
11  *
12  * OpenOffice.org is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU Lesser General Public License version 3
14  * only, as published by the Free Software Foundation.
15  *
16  * OpenOffice.org is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Lesser General Public License version 3 for more details
20  * (a copy is included in the LICENSE file that accompanied this code).
21  *
22  * You should have received a copy of the GNU Lesser General Public License
23  * version 3 along with OpenOffice.org. If not, see
24  * <http://www.openoffice.org/license.html>
25  * for a copy of the LGPLv3 License.
26  *
27  ************************************************************************/
28 
29 #pragma once
30 
31 #include <config_lgpl.h>
32 #include <vector>
33 #include <rtl/ustring.hxx>
34 #include <rtl/ref.hxx>
35 #include <osl/mutex.hxx>
36 #include <com/sun/star/io/XInputStream.hpp>
37 #include <com/sun/star/io/XOutputStream.hpp>
38 #include <com/sun/star/beans/NamedValue.hpp>
39 #include <com/sun/star/ucb/Lock.hpp>
40 #include <com/sun/star/ucb/WebDAVHTTPMethod.hpp>
41 #include <com/sun/star/ucb/XCommandEnvironment.hpp>
42 #include "DAVAuthListener.hxx"
43 #include "DAVException.hxx"
44 #include "DAVSession.hxx"
45 #include "DAVResource.hxx"
46 #include "DAVTypes.hxx"
47 #include "NeonUri.hxx"
48 
49 namespace webdav_ucp
50 {
51 
52 class DAVSessionFactory;
53 
55 {
56  osl::Mutex m_aMutex;
57  OUString m_aURL;
58  OUString m_aPath;
59  css::uno::Sequence< css::beans::NamedValue > m_aFlags;
62  css::uno::Reference< css::uno::XComponentContext > m_xContext;
63  std::vector< NeonUri > m_aRedirectURIs;
64 
65 public:
66  DAVResourceAccess( const css::uno::Reference< css::uno::XComponentContext > & rxContext,
67  rtl::Reference< DAVSessionFactory > const & rSessionFactory,
68  const OUString & rURL );
69  DAVResourceAccess( const DAVResourceAccess & rOther );
70 
71  DAVResourceAccess & operator=( const DAVResourceAccess & rOther );
72 
74  void setFlags( const css::uno::Sequence< css::beans::NamedValue >& rFlags );
75 
77  void setURL( const OUString & rNewURL );
78 
79  void resetUri();
80 
81  const OUString & getURL() const { return m_aURL; }
82 
84  { return m_xSessionFactory; }
85 
86  // DAV methods
87 
89  void
90  OPTIONS( DAVOptions & rOptions,
91  const css::uno::Reference<
92  css::ucb::XCommandEnvironment > & xEnv );
93 
94  // allprop & named
96  void
97  PROPFIND( const Depth nDepth,
98  const std::vector< OUString > & rPropertyNames,
99  std::vector< DAVResource > & rResources,
100  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
101 
102  // propnames
104  void
105  PROPFIND( const Depth nDepth,
106  std::vector< DAVResourceInfo > & rResInfo,
107  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
108 
110  void
111  PROPPATCH( const std::vector< ProppatchValue > & rValues,
112  const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
113 
115  void
116  HEAD( const std::vector< OUString > & rHeaderNames, // empty == 'all'
117  DAVResource & rResource,
118  const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
119 
121  css::uno::Reference< css::io::XInputStream >
122  GET( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
123 
125  void
126  GET( css::uno::Reference< css::io::XOutputStream > & rStream,
127  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
128 
131  css::uno::Reference< css::io::XInputStream >
132  GET( const std::vector< OUString > & rHeaderNames, // empty == 'all'
133  DAVResource & rResource,
134  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
135 
136  // used as HEAD substitute when HEAD is not implemented on server
138  void
139  GET0( DAVRequestHeaders & rRequestHeaders,
140  const std::vector< OUString > & rHeaderNames, // empty == 'all'
141  DAVResource & rResource,
142  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
143 
145  void
146  GET( css::uno::Reference< css::io::XOutputStream > & rStream,
147  const std::vector< OUString > & rHeaderNames, // empty == 'all'
148  DAVResource & rResource,
149  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
150 
153  void
154  PUT( const css::uno::Reference< css::io::XInputStream > & rStream,
155  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
156 
159  css::uno::Reference< css::io::XInputStream >
160  POST( const OUString & rContentType,
161  const OUString & rReferer,
162  const css::uno::Reference< css::io::XInputStream > & rInputStream,
163  const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
164 
167  void
168  POST( const OUString & rContentType,
169  const OUString & rReferer,
170  const css::uno::Reference< css::io::XInputStream > & rInputStream,
171  css::uno::Reference< css::io::XOutputStream > & rOutputStream,
172  const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
173 
175  void
176  MKCOL( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
177 
179  void
180  COPY( const OUString & rSourcePath,
181  const OUString & rDestinationURI,
182  bool bOverwrite,
183  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
184 
186  void
187  MOVE( const OUString & rSourcePath,
188  const OUString & rDestinationURI,
189  bool bOverwrite,
190  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
191 
193  void
194  DESTROY( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
195 
196  // set new lock.
198  void
199  LOCK( css::ucb::Lock & inLock,
200  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
201 
203  void
204  UNLOCK( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
205 
207  void
208  abort();
209 
210  // helper
211  static void
213  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv,
214  const OUString & rURI,
215  css::ucb::WebDAVHTTPMethod eMethod,
216  DAVRequestHeaders & rRequestHeaders );
217 
219  bool handleException( const DAVException & e, int errorCount );
220 
221 private:
222  const OUString & getRequestURI() const;
224  bool detectRedirectCycle( const OUString& rRedirectURL );
226  void initialize();
227 };
228 
229 } // namespace webdav_ucp
230 
231 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const OUString & getRequestURI() const
void UNLOCK(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
rtl::Reference< DAVSessionFactory > m_xSessionFactory
DAVResourceAccess(const css::uno::Reference< css::uno::XComponentContext > &rxContext, rtl::Reference< DAVSessionFactory > const &rSessionFactory, const OUString &rURL)
std::vector< DAVRequestHeader > DAVRequestHeaders
void MKCOL(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
rtl::Reference< DAVSession > m_xSession
void PROPPATCH(const std::vector< ProppatchValue > &rValues, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void PROPFIND(const Depth nDepth, const std::vector< OUString > &rPropertyNames, std::vector< DAVResource > &rResources, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void setFlags(const css::uno::Sequence< css::beans::NamedValue > &rFlags)
css::uno::Reference< css::uno::XComponentContext > m_xContext
void LOCK(css::ucb::Lock &inLock, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void MOVE(const OUString &rSourcePath, const OUString &rDestinationURI, bool bOverwrite, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void COPY(const OUString &rSourcePath, const OUString &rDestinationURI, bool bOverwrite, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
const rtl::Reference< DAVSessionFactory > & getSessionFactory() const
void PUT(const css::uno::Reference< css::io::XInputStream > &rStream, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
DAVResourceAccess & operator=(const DAVResourceAccess &rOther)
void DESTROY(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
const OUString & getURL() const
static void getUserRequestHeaders(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv, const OUString &rURI, css::ucb::WebDAVHTTPMethod eMethod, DAVRequestHeaders &rRequestHeaders)
css::uno::Sequence< css::beans::NamedValue > m_aFlags
void OPTIONS(DAVOptions &rOptions, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
css::uno::Reference< css::io::XInputStream > POST(const OUString &rContentType, const OUString &rReferer, const css::uno::Reference< css::io::XInputStream > &rInputStream, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void GET0(DAVRequestHeaders &rRequestHeaders, const std::vector< OUString > &rHeaderNames, DAVResource &rResource, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
std::vector< NeonUri > m_aRedirectURIs
void HEAD(const std::vector< OUString > &rHeaderNames, DAVResource &rResource, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void setURL(const OUString &rNewURL)
bool detectRedirectCycle(const OUString &rRedirectURL)
css::uno::Reference< css::io::XInputStream > GET(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
bool handleException(const DAVException &e, int errorCount)