LibreOffice Module ucb (master) 1
webdavcontent.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20
21#pragma once
22
23#include <memory>
24#include <list>
25#include <rtl/ref.hxx>
26#include <com/sun/star/ucb/ContentCreationException.hpp>
27#include <com/sun/star/ucb/XContentCreator.hpp>
29#include "DAVResourceAccess.hxx"
30#include "PropertyMap.hxx"
31
32namespace com::sun::star::beans {
33 struct Property;
34 struct PropertyValue;
35}
36
37namespace com::sun::star::io {
38 class XInputStream;
39}
40
41namespace com::sun::star::sdbc {
42 class XRow;
43}
44
45namespace com::sun::star::ucb {
46 struct OpenCommandArgument3;
47 struct PropertyCommandArgument;
48 struct PostCommandArgument2;
49 struct TransferInfo;
50}
51
52namespace http_dav_ucp
53{
54
55
56// UNO service name for the content.
57inline constexpr OUStringLiteral WEBDAV_CONTENT_SERVICE_NAME = u"com.sun.star.ucb.WebDAVContent";
58
59
60class ContentProvider;
63
65 public css::ucb::XContentCreator
66{
68 {
69 UNKNOWN, // the type of the Web resource is unknown
70 NOT_FOUND, // the Web resource does not exists
71 NON_DAV, // the Web resource exists but it's not DAV
72 DAV, // the type of the Web resource is DAV with lock/unlock available
73 DAV_NOLOCK // the type of the Web resource is DAV with no lock/unlock available
74 };
75
76 std::unique_ptr< DAVResourceAccess > m_xResAccess;
77 std::unique_ptr< CachableContentProperties > m_xCachedProps; // locally cached props
79 // resource type for general DAV methods
81 // resource type for general LOCK method only
83 ContentProvider* m_pProvider; // No need for a ref, base class holds object
85 bool const m_bCollection;
87 std::vector< OUString > m_aFailedPropNames;
88 // Options Cache lifetime
89 // for web site implementing OPTIONS, but not dav
91 // for WebDAV site where OPTIONS is mandatory
93 // same as above, but when the resource is locked by us
95// For web site not implementing OPTIONS
96 // during this time we assume the site doesn't turn to WebDAV
97 // but remains a simple Web
99 // When resource is not found
100 // may be the resource is unavailable only briefly?
101 // so better have this small
103
105
106private:
107 virtual css::uno::Sequence< css::beans::Property >
108 getProperties( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv ) override;
109 virtual css::uno::Sequence< css::ucb::CommandInfo >
110 getCommands( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv ) override;
111 virtual OUString getParentURL() override;
112
114 bool isFolder( const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
115
117 css::uno::Reference< css::sdbc::XRow >
118 getPropertyValues( const css::uno::Sequence< css::beans::Property >& rProperties,
119 const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
120
122 css::uno::Sequence< css::uno::Any >
123 setPropertyValues( const css::uno::Sequence< css::beans::PropertyValue >& rValues,
124 const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
125
127 typedef std::vector< ContentRef > ContentRefList;
128 void queryChildren( ContentRefList& rChildren);
129
130 bool
131 exchangeIdentity( const css::uno::Reference< css::ucb::XContentIdentifier >& xNewId );
132
133 OUString
134 getBaseURI( const std::unique_ptr< DAVResourceAccess > & rResAccess );
135
138 getResourceType( const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
139
142 getResourceType( const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv,
143 const std::unique_ptr< DAVResourceAccess > & rResAccess,
144 bool * networkAccessAllowed = nullptr );
145
146 // Command "open"
148 css::uno::Any open(
149 const css::ucb::OpenCommandArgument3 & rArg,
150 const css::uno::Reference<
151 css::ucb::XCommandEnvironment > & xEnv );
152
153 // Command "post"
155 void post( const css::ucb::PostCommandArgument2 & rArg,
156 const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
157
158 // Command "insert"
160 void insert( const css::uno::Reference< css::io::XInputStream > & xInputStream,
161 bool bReplaceExisting,
162 const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment );
163
164 // Command "transfer"
166 void transfer( const css::ucb::TransferInfo & rArgs,
167 const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment );
168
169 // Command "delete"
171 void destroy( bool bDeletePhysical );
172
173 // Command "lock"
175 void lock( const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment );
176
177 // Command "unlock"
179 void unlock( const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment );
180
181 css::uno::Any MapDAVException( const DAVException & e,
182 bool bWrite );
185 const DAVException & e,
186 const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv,
187 bool bWrite = false );
188
189 static bool shouldAccessNetworkAfterException( const DAVException & e );
190
192 const css::uno::Reference< css::ucb::XCommandEnvironment >& rEnvironment,
193 const std::unique_ptr< DAVResourceAccess > & rResAccess );
194
196 const css::uno::Reference< css::ucb::XCommandEnvironment >& rEnvironment );
197
198 // XPropertyContainer replacement
203 void addProperty( const css::ucb::PropertyCommandArgument &aCmdArg,
204 const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment );
205
209 void removeProperty( const OUString& Name,
210 const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment );
211public:
213 Content( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
214 ContentProvider* pProvider,
215 const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier,
216 rtl::Reference< DAVSessionFactory > const & rSessionFactory );
218 Content( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
219 ContentProvider* pProvider,
220 const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier,
221 rtl::Reference< DAVSessionFactory > const & rSessionFactory,
222 bool isCollection );
223 virtual ~Content() override;
224
225 // XInterface
226 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
227 virtual void SAL_CALL acquire()
228 noexcept override;
229 virtual void SAL_CALL release()
230 noexcept override;
231
232 // XTypeProvider
233 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
234 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
235
236 // XServiceInfo
237 virtual OUString SAL_CALL
238 getImplementationName() override;
239
240 virtual css::uno::Sequence< OUString > SAL_CALL
241 getSupportedServiceNames() override;
242
243 // XContent
244 virtual OUString SAL_CALL
245 getContentType() override;
246
247 // XCommandProcessor
248 virtual css::uno::Any SAL_CALL
249 execute( const css::ucb::Command& aCommand,
250 sal_Int32 CommandId,
251 const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment ) override;
252 virtual void SAL_CALL
253 abort( sal_Int32 CommandId ) override;
254
255 // XPropertyContainer
256 virtual void SAL_CALL
257 addProperty( const OUString& Name,
258 sal_Int16 Attributes,
259 const css::uno::Any& DefaultValue ) override;
260
261 virtual void SAL_CALL
262 removeProperty( const OUString& Name ) override;
263
264
265 // Additional interfaces
266
267
268 // XContentCreator
269 virtual css::uno::Sequence< css::ucb::ContentInfo > SAL_CALL
271 virtual css::uno::Reference< css::ucb::XContent > SAL_CALL
272 createNewContent( const css::ucb::ContentInfo& Info ) override;
273
274
275 // Non-interface methods.
276
277
279
280 // Called from resultset data supplier.
281 static css::uno::Reference< css::sdbc::XRow >
282 getPropertyValues( const css::uno::Reference< css::uno::XComponentContext >& rContext,
283 const css::uno::Sequence< css::beans::Property >& rProperties,
284 const ContentProperties& rData,
286 const OUString& rContentId );
287
290 void getResourceOptions( const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv,
291 DAVOptions& rDAVOptions,
292 const std::unique_ptr< DAVResourceAccess > & rResAccess,
293 bool * networkAccessAllowed = nullptr);
294
295 static bool isResourceAvailable( const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv,
296 const std::unique_ptr< DAVResourceAccess > & rResAccess,
297 DAVOptions& rDAVOptions );
298
299 static void removeCachedPropertyNames( const OUString & rURL );
300
301};
302
303}
304
305/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool isFolder(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
OUString getBaseURI(const std::unique_ptr< DAVResourceAccess > &rResAccess)
virtual css::uno::Sequence< css::ucb::CommandInfo > getCommands(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv) override
static css::uno::Reference< css::sdbc::XRow > getPropertyValues(const css::uno::Reference< css::uno::XComponentContext > &rContext, const css::uno::Sequence< css::beans::Property > &rProperties, const ContentProperties &rData, const rtl::Reference< ::ucbhelper::ContentProviderImplHelper > &rProvider, const OUString &rContentId)
ResourceType m_eResourceTypeForLocks
void cancelCommandExecution(const DAVException &e, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv, bool bWrite=false)
static void removeCachedPropertyNames(const OUString &rURL)
static bool isResourceAvailable(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv, const std::unique_ptr< DAVResourceAccess > &rResAccess, DAVOptions &rDAVOptions)
sal_uInt32 m_nOptsCacheLifeDAVLocked
virtual css::uno::Reference< css::ucb::XContent > SAL_CALL createNewContent(const css::ucb::ContentInfo &Info) override
ResourceType getResourceType(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv, const std::unique_ptr< DAVResourceAccess > &rResAccess, bool *networkAccessAllowed=nullptr)
sal_uInt32 m_nOptsCacheLifeImplWeb
rtl::Reference< Content > ContentRef
virtual css::uno::Sequence< css::ucb::ContentInfo > SAL_CALL queryCreatableContentsInfo() override
sal_uInt32 m_nOptsCacheLifeNotImpl
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
static bool shouldAccessNetworkAfterException(const DAVException &e)
sal_uInt32 m_nOptsCacheLifeDAV
css::uno::Reference< css::sdbc::XRow > getPropertyValues(const css::uno::Sequence< css::beans::Property > &rProperties, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
std::vector< ContentRef > ContentRefList
ResourceType resourceTypeForLocks(const css::uno::Reference< css::ucb::XCommandEnvironment > &rEnvironment)
virtual css::uno::Sequence< css::beans::Property > getProperties(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv) override
Content(const css::uno::Reference< css::uno::XComponentContext > &rxContext, ContentProvider *pProvider, const css::uno::Reference< css::ucb::XContentIdentifier > &Identifier, rtl::Reference< DAVSessionFactory > const &rSessionFactory)
bool exchangeIdentity(const css::uno::Reference< css::ucb::XContentIdentifier > &xNewId)
void getResourceOptions(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv, DAVOptions &rDAVOptions, const std::unique_ptr< DAVResourceAccess > &rResAccess, bool *networkAccessAllowed=nullptr)
Use OPTIONS method to retrieve the type of the Web resource.
void lock(const css::uno::Reference< css::ucb::XCommandEnvironment > &Environment)
void unlock(const css::uno::Reference< css::ucb::XCommandEnvironment > &Environment)
void removeProperty(const OUString &Name, const css::uno::Reference< css::ucb::XCommandEnvironment > &Environment)
css::uno::Sequence< css::uno::Any > setPropertyValues(const css::uno::Sequence< css::beans::PropertyValue > &rValues, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void insert(const css::uno::Reference< css::io::XInputStream > &xInputStream, bool bReplaceExisting, const css::uno::Reference< css::ucb::XCommandEnvironment > &Environment)
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
DAVResourceAccess & getResourceAccess()
virtual css::uno::Any SAL_CALL execute(const css::ucb::Command &aCommand, sal_Int32 CommandId, const css::uno::Reference< css::ucb::XCommandEnvironment > &Environment) override
std::vector< OUString > m_aFailedPropNames
virtual OUString SAL_CALL getImplementationName() override
ResourceType m_eResourceType
virtual void SAL_CALL acquire() noexcept override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void SAL_CALL release() noexcept override
ResourceType resourceTypeForLocks(const css::uno::Reference< css::ucb::XCommandEnvironment > &rEnvironment, const std::unique_ptr< DAVResourceAccess > &rResAccess)
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
void transfer(const css::ucb::TransferInfo &rArgs, const css::uno::Reference< css::ucb::XCommandEnvironment > &Environment)
css::uno::Any open(const css::ucb::OpenCommandArgument3 &rArg, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
sal_uInt32 m_nOptsCacheLifeNotFound
void queryChildren(ContentRefList &rChildren)
std::unique_ptr< DAVResourceAccess > m_xResAccess
virtual OUString SAL_CALL getContentType() override
virtual void SAL_CALL abort(sal_Int32 CommandId) override
virtual OUString getParentURL() override
void addProperty(const css::ucb::PropertyCommandArgument &aCmdArg, const css::uno::Reference< css::ucb::XCommandEnvironment > &Environment)
ResourceType getResourceType(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
std::unique_ptr< CachableContentProperties > m_xCachedProps
css::uno::Any MapDAVException(const DAVException &e, bool bWrite)
void destroy(bool bDeletePhysical)
ContentProvider * m_pProvider
virtual ~Content() override
Content(const css::uno::Reference< css::uno::XComponentContext > &rxContext, ContentProvider *pProvider, const css::uno::Reference< css::ucb::XContentIdentifier > &Identifier, rtl::Reference< DAVSessionFactory > const &rSessionFactory, bool isCollection)
void post(const css::ucb::PostCommandArgument2 &rArg, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
float u
Type
constexpr OUStringLiteral WEBDAV_CONTENT_SERVICE_NAME
signed char sal_Int8