Line data Source code
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 : #ifndef _WEBDAV_UCP_CONTENT_HXX
30 : #define _WEBDAV_UCP_CONTENT_HXX
31 :
32 : #include <memory>
33 : #include <list>
34 : #include <rtl/ref.hxx>
35 : #include <com/sun/star/ucb/ContentCreationException.hpp>
36 : #include <com/sun/star/ucb/XContentCreator.hpp>
37 : #include <ucbhelper/contenthelper.hxx>
38 : #include "DAVResourceAccess.hxx"
39 : #include "PropertyMap.hxx"
40 :
41 : namespace com { namespace sun { namespace star { namespace beans {
42 : struct Property;
43 : struct PropertyValue;
44 : } } } }
45 :
46 : namespace com { namespace sun { namespace star { namespace io {
47 : class XInputStream;
48 : } } } }
49 :
50 : namespace com { namespace sun { namespace star { namespace sdbc {
51 : class XRow;
52 : } } } }
53 :
54 : namespace com { namespace sun { namespace star { namespace ucb {
55 : struct OpenCommandArgument3;
56 : struct PostCommandArgument2;
57 : struct TransferInfo;
58 : } } } }
59 :
60 : namespace webdav_ucp
61 : {
62 :
63 : //=========================================================================
64 :
65 : // UNO service name for the content.
66 : #define WEBDAV_CONTENT_SERVICE_NAME "com.sun.star.ucb.WebDAVContent"
67 :
68 : //=========================================================================
69 :
70 : class ContentProvider;
71 : class ContentProperties;
72 : class CachableContentProperties;
73 :
74 : class Content : public ::ucbhelper::ContentImplHelper,
75 : public com::sun::star::ucb::XContentCreator
76 : {
77 : enum ResourceType
78 : {
79 : UNKNOWN,
80 : FTP,
81 : NON_DAV,
82 : DAV
83 : };
84 :
85 : std::auto_ptr< DAVResourceAccess > m_xResAccess;
86 : std::auto_ptr< CachableContentProperties >
87 : m_xCachedProps; // locally cached props
88 : rtl::OUString m_aEscapedTitle;
89 : ResourceType m_eResourceType;
90 : ContentProvider* m_pProvider; // No need for a ref, base class holds object
91 : bool m_bTransient;
92 : bool m_bCollection;
93 : bool m_bDidGetOrHead;
94 : std::vector< rtl::OUString > m_aFailedPropNames;
95 :
96 : private:
97 : virtual com::sun::star::uno::Sequence< com::sun::star::beans::Property >
98 : getProperties( const com::sun::star::uno::Reference<
99 : com::sun::star::ucb::XCommandEnvironment > & xEnv );
100 : virtual com::sun::star::uno::Sequence< com::sun::star::ucb::CommandInfo >
101 : getCommands( const com::sun::star::uno::Reference<
102 : com::sun::star::ucb::XCommandEnvironment > & xEnv );
103 : virtual ::rtl::OUString getParentURL();
104 :
105 : sal_Bool isFolder( const ::com::sun::star::uno::Reference<
106 : ::com::sun::star::ucb::XCommandEnvironment >& xEnv )
107 : throw ( ::com::sun::star::uno::Exception );
108 :
109 : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
110 : getPropertyValues( const ::com::sun::star::uno::Sequence<
111 : ::com::sun::star::beans::Property >& rProperties,
112 : const ::com::sun::star::uno::Reference<
113 : ::com::sun::star::ucb::XCommandEnvironment >& xEnv )
114 : throw ( ::com::sun::star::uno::Exception );
115 :
116 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
117 : setPropertyValues( const ::com::sun::star::uno::Sequence<
118 : ::com::sun::star::beans::PropertyValue >& rValues,
119 : const ::com::sun::star::uno::Reference<
120 : ::com::sun::star::ucb::XCommandEnvironment >& xEnv )
121 : throw ( ::com::sun::star::uno::Exception );
122 :
123 : typedef rtl::Reference< Content > ContentRef;
124 : typedef std::list< ContentRef > ContentRefList;
125 : void queryChildren( ContentRefList& rChildren);
126 :
127 : sal_Bool
128 : exchangeIdentity( const ::com::sun::star::uno::Reference<
129 : ::com::sun::star::ucb::XContentIdentifier >& xNewId );
130 :
131 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
132 : const rtl::OUString
133 : getBaseURI( const std::auto_ptr< DAVResourceAccess > & rResAccess );
134 : SAL_WNODEPRECATED_DECLARATIONS_POP
135 :
136 : const ResourceType &
137 : getResourceType( const ::com::sun::star::uno::Reference<
138 : ::com::sun::star::ucb::XCommandEnvironment >& xEnv )
139 : throw ( ::com::sun::star::uno::Exception );
140 :
141 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
142 : const ResourceType &
143 : getResourceType( const ::com::sun::star::uno::Reference<
144 : ::com::sun::star::ucb::XCommandEnvironment >& xEnv,
145 : const std::auto_ptr< DAVResourceAccess > & rResAccess )
146 : throw ( ::com::sun::star::uno::Exception );
147 : SAL_WNODEPRECATED_DECLARATIONS_POP
148 :
149 : // Command "open"
150 : com::sun::star::uno::Any open(
151 : const com::sun::star::ucb::OpenCommandArgument3 & rArg,
152 : const com::sun::star::uno::Reference<
153 : com::sun::star::ucb::XCommandEnvironment > & xEnv )
154 : throw( ::com::sun::star::uno::Exception );
155 :
156 : // Command "post"
157 : void post( const com::sun::star::ucb::PostCommandArgument2 & rArg,
158 : const com::sun::star::uno::Reference<
159 : com::sun::star::ucb::XCommandEnvironment > & xEnv )
160 : throw( ::com::sun::star::uno::Exception );
161 :
162 : // Command "insert"
163 : void insert( const ::com::sun::star::uno::Reference<
164 : ::com::sun::star::io::XInputStream > & xInputStream,
165 : sal_Bool bReplaceExisting,
166 : const com::sun::star::uno::Reference<
167 : com::sun::star::ucb::XCommandEnvironment >& Environment )
168 : throw( ::com::sun::star::uno::Exception );
169 :
170 : // Command "transfer"
171 : void transfer( const ::com::sun::star::ucb::TransferInfo & rArgs,
172 : const com::sun::star::uno::Reference<
173 : com::sun::star::ucb::XCommandEnvironment >& Environment )
174 : throw( ::com::sun::star::uno::Exception );
175 :
176 : // Command "delete"
177 : void destroy( sal_Bool bDeletePhysical )
178 : throw( ::com::sun::star::uno::Exception );
179 :
180 : // Command "lock"
181 : void lock( const com::sun::star::uno::Reference<
182 : com::sun::star::ucb::XCommandEnvironment >& Environment )
183 : throw( ::com::sun::star::uno::Exception );
184 :
185 : // Command "unlock"
186 : void unlock( const com::sun::star::uno::Reference<
187 : com::sun::star::ucb::XCommandEnvironment >& Environment )
188 : throw( ::com::sun::star::uno::Exception );
189 :
190 : ::com::sun::star::uno::Any MapDAVException( const DAVException & e,
191 : sal_Bool bWrite );
192 : void cancelCommandExecution(
193 : const DAVException & e,
194 : const ::com::sun::star::uno::Reference<
195 : com::sun::star::ucb::XCommandEnvironment > & xEnv,
196 : sal_Bool bWrite = sal_False )
197 : throw( ::com::sun::star::uno::Exception );
198 :
199 : static bool shouldAccessNetworkAfterException( const DAVException & e );
200 :
201 : bool supportsExclusiveWriteLock(
202 : const com::sun::star::uno::Reference<
203 : com::sun::star::ucb::XCommandEnvironment >& Environment );
204 :
205 : public:
206 : Content( const ::com::sun::star::uno::Reference<
207 : ::com::sun::star::uno::XComponentContext >& rxContext,
208 : ContentProvider* pProvider,
209 : const ::com::sun::star::uno::Reference<
210 : ::com::sun::star::ucb::XContentIdentifier >& Identifier,
211 : rtl::Reference< DAVSessionFactory > const & rSessionFactory )
212 : throw ( ::com::sun::star::ucb::ContentCreationException );
213 : Content( const ::com::sun::star::uno::Reference<
214 : ::com::sun::star::uno::XComponentContext >& rxContext,
215 : ContentProvider* pProvider,
216 : const ::com::sun::star::uno::Reference<
217 : ::com::sun::star::ucb::XContentIdentifier >& Identifier,
218 : rtl::Reference< DAVSessionFactory > const & rSessionFactory,
219 : sal_Bool isCollection )
220 : throw ( ::com::sun::star::ucb::ContentCreationException );
221 : virtual ~Content();
222 :
223 : // XInterface
224 : XINTERFACE_DECL()
225 :
226 : // XTypeProvider
227 : XTYPEPROVIDER_DECL()
228 :
229 : // XServiceInfo
230 : virtual ::rtl::OUString SAL_CALL
231 : getImplementationName()
232 : throw( ::com::sun::star::uno::RuntimeException );
233 :
234 : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
235 : getSupportedServiceNames()
236 : throw( ::com::sun::star::uno::RuntimeException );
237 :
238 : // XContent
239 : virtual rtl::OUString SAL_CALL
240 : getContentType()
241 : throw( com::sun::star::uno::RuntimeException );
242 :
243 : // XCommandProcessor
244 : virtual com::sun::star::uno::Any SAL_CALL
245 : execute( const com::sun::star::ucb::Command& aCommand,
246 : sal_Int32 CommandId,
247 : const com::sun::star::uno::Reference<
248 : com::sun::star::ucb::XCommandEnvironment >& Environment )
249 : throw( com::sun::star::uno::Exception,
250 : com::sun::star::ucb::CommandAbortedException,
251 : com::sun::star::uno::RuntimeException );
252 : virtual void SAL_CALL
253 : abort( sal_Int32 CommandId )
254 : throw( com::sun::star::uno::RuntimeException );
255 :
256 : // XPropertyContainer
257 : virtual void SAL_CALL
258 : addProperty( const rtl::OUString& Name,
259 : sal_Int16 Attributes,
260 : const com::sun::star::uno::Any& DefaultValue )
261 : throw( com::sun::star::beans::PropertyExistException,
262 : com::sun::star::beans::IllegalTypeException,
263 : com::sun::star::lang::IllegalArgumentException,
264 : com::sun::star::uno::RuntimeException );
265 :
266 : virtual void SAL_CALL
267 : removeProperty( const rtl::OUString& Name )
268 : throw( com::sun::star::beans::UnknownPropertyException,
269 : com::sun::star::beans::NotRemoveableException,
270 : com::sun::star::uno::RuntimeException );
271 :
272 : //////////////////////////////////////////////////////////////////////
273 : // Additional interfaces
274 : //////////////////////////////////////////////////////////////////////
275 :
276 : // XContentCreator
277 : virtual com::sun::star::uno::Sequence<
278 : com::sun::star::ucb::ContentInfo > SAL_CALL
279 : queryCreatableContentsInfo()
280 : throw( com::sun::star::uno::RuntimeException );
281 : virtual com::sun::star::uno::Reference<
282 : com::sun::star::ucb::XContent > SAL_CALL
283 : createNewContent( const com::sun::star::ucb::ContentInfo& Info )
284 : throw( com::sun::star::uno::RuntimeException );
285 :
286 : //////////////////////////////////////////////////////////////////////
287 : // Non-interface methods.
288 : //////////////////////////////////////////////////////////////////////
289 :
290 0 : DAVResourceAccess & getResourceAccess() { return *m_xResAccess; }
291 :
292 : // Called from resultset data supplier.
293 : static ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
294 : getPropertyValues( const ::com::sun::star::uno::Reference<
295 : ::com::sun::star::uno::XComponentContext >& rxContext,
296 : const ::com::sun::star::uno::Sequence<
297 : ::com::sun::star::beans::Property >& rProperties,
298 : const ContentProperties& rData,
299 : const rtl::Reference<
300 : ::ucbhelper::ContentProviderImplHelper >& rProvider,
301 : const ::rtl::OUString& rContentId );
302 : };
303 :
304 : }
305 :
306 : #endif
307 :
308 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|