xref: /trunk/main/ucb/source/ucp/webdav/DAVResourceAccess.hxx (revision 6df1ea1f75e32b7bdb9b43f28f6c06e1fbd0c5ce)
1*6df1ea1fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*6df1ea1fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*6df1ea1fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*6df1ea1fSAndrew Rist  * distributed with this work for additional information
6*6df1ea1fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*6df1ea1fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*6df1ea1fSAndrew Rist  * "License"); you may not use this file except in compliance
9*6df1ea1fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*6df1ea1fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*6df1ea1fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*6df1ea1fSAndrew Rist  * software distributed under the License is distributed on an
15*6df1ea1fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*6df1ea1fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*6df1ea1fSAndrew Rist  * specific language governing permissions and limitations
18*6df1ea1fSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*6df1ea1fSAndrew Rist  *************************************************************/
21*6df1ea1fSAndrew Rist 
22*6df1ea1fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _DAVRESOURCEACCESS_HXX_
25cdf0e10cSrcweir #define _DAVRESOURCEACCESS_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <vector>
28cdf0e10cSrcweir #include <rtl/ustring.hxx>
29cdf0e10cSrcweir #include <rtl/ref.hxx>
30cdf0e10cSrcweir #include <osl/mutex.hxx>
31cdf0e10cSrcweir #include <com/sun/star/io/XInputStream.hpp>
32cdf0e10cSrcweir #include <com/sun/star/io/XOutputStream.hpp>
33cdf0e10cSrcweir #include <com/sun/star/ucb/Lock.hpp>
34cdf0e10cSrcweir #include <com/sun/star/ucb/XCommandEnvironment.hpp>
35cdf0e10cSrcweir #include "DAVAuthListener.hxx"
36cdf0e10cSrcweir #include "DAVException.hxx"
37cdf0e10cSrcweir #include "DAVSession.hxx"
38cdf0e10cSrcweir #include "DAVResource.hxx"
39cdf0e10cSrcweir #include "DAVTypes.hxx"
40cdf0e10cSrcweir #include "NeonUri.hxx"
41cdf0e10cSrcweir 
42cdf0e10cSrcweir namespace webdav_ucp
43cdf0e10cSrcweir {
44cdf0e10cSrcweir 
45cdf0e10cSrcweir class DAVSessionFactory;
46cdf0e10cSrcweir 
47cdf0e10cSrcweir class DAVResourceAccess
48cdf0e10cSrcweir {
49cdf0e10cSrcweir     osl::Mutex    m_aMutex;
50cdf0e10cSrcweir     rtl::OUString m_aURL;
51cdf0e10cSrcweir     rtl::OUString m_aPath;
52cdf0e10cSrcweir     rtl::Reference< DAVSession > m_xSession;
53cdf0e10cSrcweir     rtl::Reference< DAVSessionFactory > m_xSessionFactory;
54cdf0e10cSrcweir     com::sun::star::uno::Reference<
55cdf0e10cSrcweir         com::sun::star::lang::XMultiServiceFactory > m_xSMgr;
56cdf0e10cSrcweir     std::vector< NeonUri > m_aRedirectURIs;
57cdf0e10cSrcweir 
58cdf0e10cSrcweir public:
59cdf0e10cSrcweir     DAVResourceAccess() : m_xSessionFactory( 0 ) {}
60cdf0e10cSrcweir     DAVResourceAccess( const com::sun::star::uno::Reference<
61cdf0e10cSrcweir                            com::sun::star::lang::XMultiServiceFactory > & rSMgr,
62cdf0e10cSrcweir                        rtl::Reference<
63cdf0e10cSrcweir                        DAVSessionFactory > const & rSessionFactory,
64cdf0e10cSrcweir                        const rtl::OUString & rURL );
65cdf0e10cSrcweir     DAVResourceAccess( const DAVResourceAccess & rOther );
66cdf0e10cSrcweir 
67cdf0e10cSrcweir     DAVResourceAccess & operator=( const DAVResourceAccess & rOther );
68cdf0e10cSrcweir 
69cdf0e10cSrcweir     void setURL( const rtl::OUString & rNewURL )
70cdf0e10cSrcweir         throw ( DAVException );
71cdf0e10cSrcweir 
72cdf0e10cSrcweir     void resetUri();
73cdf0e10cSrcweir 
74cdf0e10cSrcweir     const rtl::OUString & getURL() const { return m_aURL; }
75cdf0e10cSrcweir 
76cdf0e10cSrcweir     rtl::Reference< DAVSessionFactory > getSessionFactory() const
77cdf0e10cSrcweir     { return m_xSessionFactory; }
78cdf0e10cSrcweir 
79cdf0e10cSrcweir     // DAV methods
80cdf0e10cSrcweir     //
81cdf0e10cSrcweir 
82cdf0e10cSrcweir #if 0 // currently not used, but please don't remove code
83cdf0e10cSrcweir     void
84cdf0e10cSrcweir     OPTIONS(  DAVCapabilities & rCapabilities,
85cdf0e10cSrcweir               const com::sun::star::uno::Reference<
86cdf0e10cSrcweir                   com::sun::star::ucb::XCommandEnvironment > & xEnv )
87cdf0e10cSrcweir         throw ( DAVException );
88cdf0e10cSrcweir #endif
89cdf0e10cSrcweir 
90cdf0e10cSrcweir     // allprop & named
91cdf0e10cSrcweir     void
92cdf0e10cSrcweir     PROPFIND( const Depth nDepth,
93cdf0e10cSrcweir               const std::vector< rtl::OUString > & rPropertyNames,
94cdf0e10cSrcweir               std::vector< DAVResource > & rResources,
95cdf0e10cSrcweir               const com::sun::star::uno::Reference<
96cdf0e10cSrcweir                   com::sun::star::ucb::XCommandEnvironment > & xEnv )
97cdf0e10cSrcweir         throw ( DAVException );
98cdf0e10cSrcweir 
99cdf0e10cSrcweir     // propnames
100cdf0e10cSrcweir     void
101cdf0e10cSrcweir     PROPFIND( const Depth nDepth,
102cdf0e10cSrcweir               std::vector< DAVResourceInfo > & rResInfo,
103cdf0e10cSrcweir               const com::sun::star::uno::Reference<
104cdf0e10cSrcweir                   com::sun::star::ucb::XCommandEnvironment > & xEnv )
105cdf0e10cSrcweir         throw ( DAVException );
106cdf0e10cSrcweir 
107cdf0e10cSrcweir     void
108cdf0e10cSrcweir     PROPPATCH( const std::vector< ProppatchValue > & rValues,
109cdf0e10cSrcweir                const com::sun::star::uno::Reference<
110cdf0e10cSrcweir                    com::sun::star::ucb::XCommandEnvironment >& xEnv )
111cdf0e10cSrcweir         throw ( DAVException );
112cdf0e10cSrcweir 
113cdf0e10cSrcweir     void
114cdf0e10cSrcweir     HEAD( const std::vector< rtl::OUString > & rHeaderNames, // empty == 'all'
115cdf0e10cSrcweir           DAVResource & rResource,
116cdf0e10cSrcweir           const com::sun::star::uno::Reference<
117cdf0e10cSrcweir               com::sun::star::ucb::XCommandEnvironment >& xEnv )
118cdf0e10cSrcweir         throw ( DAVException );
119cdf0e10cSrcweir 
120cdf0e10cSrcweir     com::sun::star::uno::Reference< com::sun::star::io::XInputStream >
121cdf0e10cSrcweir     GET( const com::sun::star::uno::Reference<
122cdf0e10cSrcweir              com::sun::star::ucb::XCommandEnvironment > & xEnv )
123cdf0e10cSrcweir         throw ( DAVException );
124cdf0e10cSrcweir 
125cdf0e10cSrcweir     void
126cdf0e10cSrcweir     GET( com::sun::star::uno::Reference<
127cdf0e10cSrcweir              com::sun::star::io::XOutputStream > & rStream,
128cdf0e10cSrcweir          const com::sun::star::uno::Reference<
129cdf0e10cSrcweir              com::sun::star::ucb::XCommandEnvironment > & xEnv )
130cdf0e10cSrcweir         throw ( DAVException );
131cdf0e10cSrcweir 
132cdf0e10cSrcweir     com::sun::star::uno::Reference< com::sun::star::io::XInputStream >
133cdf0e10cSrcweir     GET( const std::vector< rtl::OUString > & rHeaderNames, // empty == 'all'
134cdf0e10cSrcweir          DAVResource & rResource,
135cdf0e10cSrcweir          const com::sun::star::uno::Reference<
136cdf0e10cSrcweir              com::sun::star::ucb::XCommandEnvironment > & xEnv )
137cdf0e10cSrcweir         throw ( DAVException );
138cdf0e10cSrcweir 
139cdf0e10cSrcweir     void
140cdf0e10cSrcweir     GET( com::sun::star::uno::Reference<
141cdf0e10cSrcweir              com::sun::star::io::XOutputStream > & rStream,
142cdf0e10cSrcweir          const std::vector< rtl::OUString > & rHeaderNames, // empty == 'all'
143cdf0e10cSrcweir          DAVResource & rResource,
144cdf0e10cSrcweir          const com::sun::star::uno::Reference<
145cdf0e10cSrcweir              com::sun::star::ucb::XCommandEnvironment > & xEnv )
146cdf0e10cSrcweir         throw ( DAVException );
147cdf0e10cSrcweir 
148cdf0e10cSrcweir     void
149cdf0e10cSrcweir     PUT( const com::sun::star::uno::Reference<
150cdf0e10cSrcweir              com::sun::star::io::XInputStream > & rStream,
151cdf0e10cSrcweir          const com::sun::star::uno::Reference<
152cdf0e10cSrcweir              com::sun::star::ucb::XCommandEnvironment > & xEnv )
153cdf0e10cSrcweir         throw ( DAVException );
154cdf0e10cSrcweir 
155cdf0e10cSrcweir     com::sun::star::uno::Reference< com::sun::star::io::XInputStream >
156cdf0e10cSrcweir     POST( const rtl::OUString & rContentType,
157cdf0e10cSrcweir           const rtl::OUString & rReferer,
158cdf0e10cSrcweir           const com::sun::star::uno::Reference<
159cdf0e10cSrcweir               com::sun::star::io::XInputStream > & rInputStream,
160cdf0e10cSrcweir           const com::sun::star::uno::Reference<
161cdf0e10cSrcweir           com::sun::star::ucb::XCommandEnvironment >& xEnv )
162cdf0e10cSrcweir         throw ( DAVException );
163cdf0e10cSrcweir 
164cdf0e10cSrcweir     void
165cdf0e10cSrcweir     POST( const rtl::OUString & rContentType,
166cdf0e10cSrcweir           const rtl::OUString & rReferer,
167cdf0e10cSrcweir           const com::sun::star::uno::Reference<
168cdf0e10cSrcweir               com::sun::star::io::XInputStream > & rInputStream,
169cdf0e10cSrcweir           com::sun::star::uno::Reference<
170cdf0e10cSrcweir               com::sun::star::io::XOutputStream > & rOutputStream,
171cdf0e10cSrcweir           const com::sun::star::uno::Reference<
172cdf0e10cSrcweir               com::sun::star::ucb::XCommandEnvironment >& xEnv )
173cdf0e10cSrcweir         throw ( DAVException );
174cdf0e10cSrcweir 
175cdf0e10cSrcweir     void
176cdf0e10cSrcweir     MKCOL( const com::sun::star::uno::Reference<
177cdf0e10cSrcweir                com::sun::star::ucb::XCommandEnvironment > & xEnv )
178cdf0e10cSrcweir         throw ( DAVException );
179cdf0e10cSrcweir 
180cdf0e10cSrcweir     void
181cdf0e10cSrcweir     COPY( const ::rtl::OUString & rSourcePath,
182cdf0e10cSrcweir           const ::rtl::OUString & rDestinationURI,
183cdf0e10cSrcweir           sal_Bool bOverwrite,
184cdf0e10cSrcweir           const com::sun::star::uno::Reference<
185cdf0e10cSrcweir               com::sun::star::ucb::XCommandEnvironment > & xEnv )
186cdf0e10cSrcweir         throw ( DAVException );
187cdf0e10cSrcweir 
188cdf0e10cSrcweir     void
189cdf0e10cSrcweir     MOVE( const ::rtl::OUString & rSourcePath,
190cdf0e10cSrcweir           const ::rtl::OUString & rDestinationURI,
191cdf0e10cSrcweir           sal_Bool bOverwrite,
192cdf0e10cSrcweir           const com::sun::star::uno::Reference<
193cdf0e10cSrcweir               com::sun::star::ucb::XCommandEnvironment > & xEnv )
194cdf0e10cSrcweir         throw ( DAVException );
195cdf0e10cSrcweir 
196cdf0e10cSrcweir     void
197cdf0e10cSrcweir     DESTROY( const com::sun::star::uno::Reference<
198cdf0e10cSrcweir                  com::sun::star::ucb::XCommandEnvironment > & xEnv )
199cdf0e10cSrcweir         throw ( DAVException );
200cdf0e10cSrcweir 
201cdf0e10cSrcweir     // set new lock.
202cdf0e10cSrcweir     void
203cdf0e10cSrcweir     LOCK( com::sun::star::ucb::Lock & inLock,
204cdf0e10cSrcweir           const com::sun::star::uno::Reference<
205cdf0e10cSrcweir               com::sun::star::ucb::XCommandEnvironment > & xEnv )
206cdf0e10cSrcweir         throw( DAVException );
207cdf0e10cSrcweir 
208cdf0e10cSrcweir #if 0 // currently not used, but please don't remove code
209cdf0e10cSrcweir     // refresh existing lock.
210cdf0e10cSrcweir     sal_Int64
211cdf0e10cSrcweir     LOCK( sal_Int64 nTimeout,
212cdf0e10cSrcweir           const com::sun::star::uno::Reference<
213cdf0e10cSrcweir               com::sun::star::ucb::XCommandEnvironment > & xEnv )
214cdf0e10cSrcweir         throw ( DAVException );
215cdf0e10cSrcweir #endif
216cdf0e10cSrcweir 
217cdf0e10cSrcweir     void
218cdf0e10cSrcweir     UNLOCK( const com::sun::star::uno::Reference<
219cdf0e10cSrcweir                 com::sun::star::ucb::XCommandEnvironment > & xEnv )
220cdf0e10cSrcweir         throw ( DAVException );
221cdf0e10cSrcweir 
222cdf0e10cSrcweir     void
223cdf0e10cSrcweir     abort()
224cdf0e10cSrcweir         throw ( DAVException );
225cdf0e10cSrcweir 
226cdf0e10cSrcweir     // helper
227cdf0e10cSrcweir     static void
228cdf0e10cSrcweir     getUserRequestHeaders(
229cdf0e10cSrcweir         const com::sun::star::uno::Reference<
230cdf0e10cSrcweir             com::sun::star::ucb::XCommandEnvironment > & xEnv,
231cdf0e10cSrcweir         const rtl::OUString & rURI,
232cdf0e10cSrcweir         const rtl::OUString & rMethod,
233cdf0e10cSrcweir         DAVRequestHeaders & rRequestHeaders );
234cdf0e10cSrcweir 
235cdf0e10cSrcweir private:
236cdf0e10cSrcweir     const rtl::OUString & getRequestURI() const;
237cdf0e10cSrcweir     sal_Bool detectRedirectCycle( const rtl::OUString& rRedirectURL )
238cdf0e10cSrcweir         throw ( DAVException );
239cdf0e10cSrcweir     sal_Bool handleException( DAVException & e, int errorCount )
240cdf0e10cSrcweir         throw ( DAVException );
241cdf0e10cSrcweir     void initialize()
242cdf0e10cSrcweir         throw ( DAVException );
243cdf0e10cSrcweir };
244cdf0e10cSrcweir 
245cdf0e10cSrcweir } // namespace webdav_ucp
246cdf0e10cSrcweir 
247cdf0e10cSrcweir #endif // _DAVRESOURCEACCESS_HXX_
248