xref: /trunk/main/ucb/source/ucp/webdav/webdavcontent.hxx (revision 59ddfc10bd384e83978dcd8c83c4a7ba8f8fdec1)
16df1ea1fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
36df1ea1fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
46df1ea1fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
56df1ea1fSAndrew Rist  * distributed with this work for additional information
66df1ea1fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
76df1ea1fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
86df1ea1fSAndrew Rist  * "License"); you may not use this file except in compliance
96df1ea1fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
116df1ea1fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
136df1ea1fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
146df1ea1fSAndrew Rist  * software distributed under the License is distributed on an
156df1ea1fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
166df1ea1fSAndrew Rist  * KIND, either express or implied.  See the License for the
176df1ea1fSAndrew Rist  * specific language governing permissions and limitations
186df1ea1fSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
206df1ea1fSAndrew Rist  *************************************************************/
216df1ea1fSAndrew Rist 
226df1ea1fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _WEBDAV_UCP_CONTENT_HXX
25cdf0e10cSrcweir #define _WEBDAV_UCP_CONTENT_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <memory>
28cdf0e10cSrcweir #include <list>
29cdf0e10cSrcweir #include <rtl/ref.hxx>
30cdf0e10cSrcweir #include <com/sun/star/ucb/ContentCreationException.hpp>
31cdf0e10cSrcweir #include <com/sun/star/ucb/XContentCreator.hpp>
32cdf0e10cSrcweir #include <ucbhelper/contenthelper.hxx>
33cdf0e10cSrcweir #include "DAVResourceAccess.hxx"
34cdf0e10cSrcweir #include "PropertyMap.hxx"
35cdf0e10cSrcweir 
36cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace beans {
37cdf0e10cSrcweir     struct Property;
38cdf0e10cSrcweir     struct PropertyValue;
39cdf0e10cSrcweir } } } }
40cdf0e10cSrcweir 
41cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace io {
42cdf0e10cSrcweir     class XInputStream;
43cdf0e10cSrcweir } } } }
44cdf0e10cSrcweir 
45cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace sdbc {
46cdf0e10cSrcweir     class XRow;
47cdf0e10cSrcweir } } } }
48cdf0e10cSrcweir 
49cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace ucb {
50cdf0e10cSrcweir     struct OpenCommandArgument2;
51cdf0e10cSrcweir     struct PostCommandArgument2;
52cdf0e10cSrcweir     struct TransferInfo;
53cdf0e10cSrcweir } } } }
54cdf0e10cSrcweir 
55*59ddfc10SAndre Fischer namespace http_dav_ucp
56cdf0e10cSrcweir {
57cdf0e10cSrcweir 
58cdf0e10cSrcweir //=========================================================================
59cdf0e10cSrcweir 
60cdf0e10cSrcweir // UNO service name for the content.
61cdf0e10cSrcweir #define WEBDAV_CONTENT_SERVICE_NAME "com.sun.star.ucb.WebDAVContent"
62cdf0e10cSrcweir 
63cdf0e10cSrcweir //=========================================================================
64cdf0e10cSrcweir 
65cdf0e10cSrcweir class ContentProvider;
66cdf0e10cSrcweir class ContentProperties;
67cdf0e10cSrcweir class CachableContentProperties;
68cdf0e10cSrcweir 
69cdf0e10cSrcweir class Content : public ::ucbhelper::ContentImplHelper,
70cdf0e10cSrcweir                 public com::sun::star::ucb::XContentCreator
71cdf0e10cSrcweir {
72cdf0e10cSrcweir     enum ResourceType
73cdf0e10cSrcweir     {
74cdf0e10cSrcweir         UNKNOWN,
75cdf0e10cSrcweir         NON_DAV,
76cdf0e10cSrcweir         DAV
77cdf0e10cSrcweir     };
78cdf0e10cSrcweir 
79cdf0e10cSrcweir     std::auto_ptr< DAVResourceAccess > m_xResAccess;
80cdf0e10cSrcweir     std::auto_ptr< CachableContentProperties >
81cdf0e10cSrcweir                       m_xCachedProps; // locally cached props
82cdf0e10cSrcweir     rtl::OUString     m_aEscapedTitle;
83cdf0e10cSrcweir     ResourceType      m_eResourceType;
84cdf0e10cSrcweir     ContentProvider*  m_pProvider; // No need for a ref, base class holds object
85cdf0e10cSrcweir     bool              m_bTransient;
86cdf0e10cSrcweir     bool              m_bCollection;
87cdf0e10cSrcweir     bool              m_bDidGetOrHead;
88cdf0e10cSrcweir     std::vector< rtl::OUString > m_aFailedPropNames;
89cdf0e10cSrcweir 
90cdf0e10cSrcweir private:
91cdf0e10cSrcweir     virtual com::sun::star::uno::Sequence< com::sun::star::beans::Property >
92cdf0e10cSrcweir     getProperties( const com::sun::star::uno::Reference<
93cdf0e10cSrcweir                        com::sun::star::ucb::XCommandEnvironment > & xEnv );
94cdf0e10cSrcweir     virtual com::sun::star::uno::Sequence< com::sun::star::ucb::CommandInfo >
95cdf0e10cSrcweir     getCommands( const com::sun::star::uno::Reference<
96cdf0e10cSrcweir                      com::sun::star::ucb::XCommandEnvironment > & xEnv );
97cdf0e10cSrcweir     virtual ::rtl::OUString getParentURL();
98cdf0e10cSrcweir 
99cdf0e10cSrcweir     sal_Bool isFolder( const ::com::sun::star::uno::Reference<
100cdf0e10cSrcweir                            ::com::sun::star::ucb::XCommandEnvironment >& xEnv )
101cdf0e10cSrcweir         throw ( ::com::sun::star::uno::Exception );
102cdf0e10cSrcweir 
103cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
104cdf0e10cSrcweir     getPropertyValues( const ::com::sun::star::uno::Sequence<
105cdf0e10cSrcweir                            ::com::sun::star::beans::Property >& rProperties,
106cdf0e10cSrcweir                        const ::com::sun::star::uno::Reference<
107cdf0e10cSrcweir                            ::com::sun::star::ucb::XCommandEnvironment >& xEnv )
108cdf0e10cSrcweir         throw ( ::com::sun::star::uno::Exception );
109cdf0e10cSrcweir 
110cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
111cdf0e10cSrcweir     setPropertyValues( const ::com::sun::star::uno::Sequence<
112cdf0e10cSrcweir                            ::com::sun::star::beans::PropertyValue >& rValues,
113cdf0e10cSrcweir                        const ::com::sun::star::uno::Reference<
114cdf0e10cSrcweir                            ::com::sun::star::ucb::XCommandEnvironment >& xEnv )
115cdf0e10cSrcweir         throw ( ::com::sun::star::uno::Exception );
116cdf0e10cSrcweir 
117cdf0e10cSrcweir     typedef rtl::Reference< Content > ContentRef;
118cdf0e10cSrcweir     typedef std::list< ContentRef > ContentRefList;
119cdf0e10cSrcweir     void queryChildren( ContentRefList& rChildren);
120cdf0e10cSrcweir 
121cdf0e10cSrcweir     sal_Bool
122cdf0e10cSrcweir     exchangeIdentity( const ::com::sun::star::uno::Reference<
123cdf0e10cSrcweir                           ::com::sun::star::ucb::XContentIdentifier >& xNewId );
124cdf0e10cSrcweir 
125cdf0e10cSrcweir     const rtl::OUString
126cdf0e10cSrcweir     getBaseURI( const std::auto_ptr< DAVResourceAccess > & rResAccess );
127cdf0e10cSrcweir 
128cdf0e10cSrcweir     const ResourceType &
129cdf0e10cSrcweir     getResourceType( const ::com::sun::star::uno::Reference<
130cdf0e10cSrcweir                          ::com::sun::star::ucb::XCommandEnvironment >& xEnv )
131cdf0e10cSrcweir         throw ( ::com::sun::star::uno::Exception );
132cdf0e10cSrcweir 
133cdf0e10cSrcweir     const ResourceType &
134cdf0e10cSrcweir     getResourceType( const ::com::sun::star::uno::Reference<
135cdf0e10cSrcweir                           ::com::sun::star::ucb::XCommandEnvironment >& xEnv,
136cdf0e10cSrcweir                      const std::auto_ptr< DAVResourceAccess > & rResAccess )
137cdf0e10cSrcweir         throw ( ::com::sun::star::uno::Exception );
138cdf0e10cSrcweir 
139cdf0e10cSrcweir     // Command "open"
140cdf0e10cSrcweir     com::sun::star::uno::Any open(
141cdf0e10cSrcweir                 const com::sun::star::ucb::OpenCommandArgument2 & rArg,
142cdf0e10cSrcweir                 const com::sun::star::uno::Reference<
143cdf0e10cSrcweir                     com::sun::star::ucb::XCommandEnvironment > & xEnv )
144cdf0e10cSrcweir         throw( ::com::sun::star::uno::Exception );
145cdf0e10cSrcweir 
146cdf0e10cSrcweir     // Command "post"
147cdf0e10cSrcweir     void post( const com::sun::star::ucb::PostCommandArgument2 & rArg,
148cdf0e10cSrcweir                const com::sun::star::uno::Reference<
149cdf0e10cSrcweir                     com::sun::star::ucb::XCommandEnvironment > & xEnv )
150cdf0e10cSrcweir         throw( ::com::sun::star::uno::Exception );
151cdf0e10cSrcweir 
152cdf0e10cSrcweir     // Command "insert"
153cdf0e10cSrcweir     void insert( const ::com::sun::star::uno::Reference<
154cdf0e10cSrcweir                      ::com::sun::star::io::XInputStream > & xInputStream,
155cdf0e10cSrcweir                  sal_Bool bReplaceExisting,
156cdf0e10cSrcweir                  const com::sun::star::uno::Reference<
157cdf0e10cSrcweir                      com::sun::star::ucb::XCommandEnvironment >& Environment )
158cdf0e10cSrcweir         throw( ::com::sun::star::uno::Exception );
159cdf0e10cSrcweir 
160cdf0e10cSrcweir     // Command "transfer"
161cdf0e10cSrcweir     void transfer( const ::com::sun::star::ucb::TransferInfo & rArgs,
162cdf0e10cSrcweir                    const com::sun::star::uno::Reference<
163cdf0e10cSrcweir                        com::sun::star::ucb::XCommandEnvironment >& Environment )
164cdf0e10cSrcweir         throw( ::com::sun::star::uno::Exception );
165cdf0e10cSrcweir 
166cdf0e10cSrcweir     // Command "delete"
167cdf0e10cSrcweir     void destroy( sal_Bool bDeletePhysical )
168cdf0e10cSrcweir         throw( ::com::sun::star::uno::Exception );
169cdf0e10cSrcweir 
170cdf0e10cSrcweir     // Command "lock"
171cdf0e10cSrcweir     void lock( const com::sun::star::uno::Reference<
172cdf0e10cSrcweir                   com::sun::star::ucb::XCommandEnvironment >& Environment )
173cdf0e10cSrcweir         throw( ::com::sun::star::uno::Exception );
174cdf0e10cSrcweir 
175cdf0e10cSrcweir     // Command "unlock"
176cdf0e10cSrcweir     void unlock( const com::sun::star::uno::Reference<
177cdf0e10cSrcweir                   com::sun::star::ucb::XCommandEnvironment >& Environment )
178cdf0e10cSrcweir         throw( ::com::sun::star::uno::Exception );
179cdf0e10cSrcweir 
180cdf0e10cSrcweir     ::com::sun::star::uno::Any MapDAVException( const DAVException & e,
181cdf0e10cSrcweir                                                 sal_Bool bWrite );
182cdf0e10cSrcweir     void cancelCommandExecution(
183cdf0e10cSrcweir                     const DAVException & e,
184cdf0e10cSrcweir                     const ::com::sun::star::uno::Reference<
185cdf0e10cSrcweir                         com::sun::star::ucb::XCommandEnvironment > & xEnv,
186cdf0e10cSrcweir                     sal_Bool bWrite = sal_False )
187cdf0e10cSrcweir         throw( ::com::sun::star::uno::Exception );
188cdf0e10cSrcweir 
189cdf0e10cSrcweir     static bool shouldAccessNetworkAfterException( const DAVException & e );
190cdf0e10cSrcweir 
191cdf0e10cSrcweir     bool supportsExclusiveWriteLock(
192cdf0e10cSrcweir         const com::sun::star::uno::Reference<
193cdf0e10cSrcweir             com::sun::star::ucb::XCommandEnvironment >& Environment );
194cdf0e10cSrcweir 
195cdf0e10cSrcweir public:
196cdf0e10cSrcweir     Content( const ::com::sun::star::uno::Reference<
197cdf0e10cSrcweir                  ::com::sun::star::lang::XMultiServiceFactory >& rxSMgr,
198cdf0e10cSrcweir              ContentProvider* pProvider,
199cdf0e10cSrcweir              const ::com::sun::star::uno::Reference<
200cdf0e10cSrcweir                  ::com::sun::star::ucb::XContentIdentifier >& Identifier,
201cdf0e10cSrcweir              rtl::Reference< DAVSessionFactory > const & rSessionFactory )
202cdf0e10cSrcweir         throw ( ::com::sun::star::ucb::ContentCreationException );
203cdf0e10cSrcweir     Content( const ::com::sun::star::uno::Reference<
204cdf0e10cSrcweir                  ::com::sun::star::lang::XMultiServiceFactory >& rxSMgr,
205cdf0e10cSrcweir              ContentProvider* pProvider,
206cdf0e10cSrcweir              const ::com::sun::star::uno::Reference<
207cdf0e10cSrcweir                  ::com::sun::star::ucb::XContentIdentifier >& Identifier,
208cdf0e10cSrcweir              rtl::Reference< DAVSessionFactory > const & rSessionFactory,
209cdf0e10cSrcweir              sal_Bool isCollection )
210cdf0e10cSrcweir         throw ( ::com::sun::star::ucb::ContentCreationException );
211cdf0e10cSrcweir     virtual ~Content();
212cdf0e10cSrcweir 
213cdf0e10cSrcweir     // XInterface
214cdf0e10cSrcweir     XINTERFACE_DECL()
215cdf0e10cSrcweir 
216cdf0e10cSrcweir     // XTypeProvider
217cdf0e10cSrcweir     XTYPEPROVIDER_DECL()
218cdf0e10cSrcweir 
219cdf0e10cSrcweir     // XServiceInfo
220cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL
221cdf0e10cSrcweir     getImplementationName()
222cdf0e10cSrcweir         throw( ::com::sun::star::uno::RuntimeException );
223cdf0e10cSrcweir 
224cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
225cdf0e10cSrcweir     getSupportedServiceNames()
226cdf0e10cSrcweir         throw( ::com::sun::star::uno::RuntimeException );
227cdf0e10cSrcweir 
228cdf0e10cSrcweir     // XContent
229cdf0e10cSrcweir     virtual rtl::OUString SAL_CALL
230cdf0e10cSrcweir     getContentType()
231cdf0e10cSrcweir         throw( com::sun::star::uno::RuntimeException );
232cdf0e10cSrcweir 
233cdf0e10cSrcweir     // XCommandProcessor
234cdf0e10cSrcweir     virtual com::sun::star::uno::Any SAL_CALL
235cdf0e10cSrcweir     execute( const com::sun::star::ucb::Command& aCommand,
236cdf0e10cSrcweir              sal_Int32 CommandId,
237cdf0e10cSrcweir              const com::sun::star::uno::Reference<
238cdf0e10cSrcweir                  com::sun::star::ucb::XCommandEnvironment >& Environment )
239cdf0e10cSrcweir         throw( com::sun::star::uno::Exception,
240cdf0e10cSrcweir                com::sun::star::ucb::CommandAbortedException,
241cdf0e10cSrcweir                com::sun::star::uno::RuntimeException );
242cdf0e10cSrcweir     virtual void SAL_CALL
243cdf0e10cSrcweir     abort( sal_Int32 CommandId )
244cdf0e10cSrcweir         throw( com::sun::star::uno::RuntimeException );
245cdf0e10cSrcweir 
246cdf0e10cSrcweir     // XPropertyContainer
247cdf0e10cSrcweir     virtual void SAL_CALL
248cdf0e10cSrcweir     addProperty( const rtl::OUString& Name,
249cdf0e10cSrcweir                  sal_Int16 Attributes,
250cdf0e10cSrcweir                  const com::sun::star::uno::Any& DefaultValue )
251cdf0e10cSrcweir         throw( com::sun::star::beans::PropertyExistException,
252cdf0e10cSrcweir                com::sun::star::beans::IllegalTypeException,
253cdf0e10cSrcweir                com::sun::star::lang::IllegalArgumentException,
254cdf0e10cSrcweir                com::sun::star::uno::RuntimeException );
255cdf0e10cSrcweir 
256cdf0e10cSrcweir     virtual void SAL_CALL
257cdf0e10cSrcweir     removeProperty( const rtl::OUString& Name )
258cdf0e10cSrcweir         throw( com::sun::star::beans::UnknownPropertyException,
259cdf0e10cSrcweir                com::sun::star::beans::NotRemoveableException,
260cdf0e10cSrcweir                com::sun::star::uno::RuntimeException );
261cdf0e10cSrcweir 
262cdf0e10cSrcweir     //////////////////////////////////////////////////////////////////////
263cdf0e10cSrcweir     // Additional interfaces
264cdf0e10cSrcweir     //////////////////////////////////////////////////////////////////////
265cdf0e10cSrcweir 
266cdf0e10cSrcweir     // XContentCreator
267cdf0e10cSrcweir     virtual com::sun::star::uno::Sequence<
268cdf0e10cSrcweir         com::sun::star::ucb::ContentInfo > SAL_CALL
269cdf0e10cSrcweir    queryCreatableContentsInfo()
270cdf0e10cSrcweir         throw( com::sun::star::uno::RuntimeException );
271cdf0e10cSrcweir     virtual com::sun::star::uno::Reference<
272cdf0e10cSrcweir         com::sun::star::ucb::XContent > SAL_CALL
273cdf0e10cSrcweir     createNewContent( const com::sun::star::ucb::ContentInfo& Info )
274cdf0e10cSrcweir         throw( com::sun::star::uno::RuntimeException );
275cdf0e10cSrcweir 
276cdf0e10cSrcweir     //////////////////////////////////////////////////////////////////////
277cdf0e10cSrcweir     // Non-interface methods.
278cdf0e10cSrcweir     //////////////////////////////////////////////////////////////////////
279cdf0e10cSrcweir 
280cdf0e10cSrcweir     DAVResourceAccess & getResourceAccess() { return *m_xResAccess; }
281cdf0e10cSrcweir 
282cdf0e10cSrcweir     // Called from resultset data supplier.
283cdf0e10cSrcweir     static ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
284cdf0e10cSrcweir     getPropertyValues( const ::com::sun::star::uno::Reference<
285cdf0e10cSrcweir                            ::com::sun::star::lang::XMultiServiceFactory >& rSMgr,
286cdf0e10cSrcweir                        const ::com::sun::star::uno::Sequence<
287cdf0e10cSrcweir                            ::com::sun::star::beans::Property >& rProperties,
288cdf0e10cSrcweir                        const ContentProperties& rData,
289cdf0e10cSrcweir                        const rtl::Reference<
290cdf0e10cSrcweir                            ::ucbhelper::ContentProviderImplHelper >& rProvider,
291cdf0e10cSrcweir                        const ::rtl::OUString& rContentId );
292cdf0e10cSrcweir };
293cdf0e10cSrcweir 
294cdf0e10cSrcweir }
295cdf0e10cSrcweir 
296cdf0e10cSrcweir #endif
297