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 #ifndef INCLUDED_UCB_SOURCE_UCP_WEBDAV_WEBDAVCONTENT_HXX
22 #define INCLUDED_UCB_SOURCE_UCP_WEBDAV_WEBDAVCONTENT_HXX
23 
24 #include <memory>
25 #include <list>
26 #include <rtl/ref.hxx>
27 #include <com/sun/star/ucb/ContentCreationException.hpp>
28 #include <com/sun/star/ucb/XContentCreator.hpp>
30 #include "DAVResourceAccess.hxx"
31 #include "PropertyMap.hxx"
32 
33 namespace com { namespace sun { namespace star { namespace beans {
34  struct Property;
35  struct PropertyValue;
36 } } } }
37 
38 namespace com { namespace sun { namespace star { namespace io {
39  class XInputStream;
40 } } } }
41 
42 namespace com { namespace sun { namespace star { namespace sdbc {
43  class XRow;
44 } } } }
45 
46 namespace com { namespace sun { namespace star { namespace ucb {
47  struct OpenCommandArgument2;
48  struct PropertyCommandArgument;
49  struct PostCommandArgument2;
50  struct TransferInfo;
51 } } } }
52 
53 namespace http_dav_ucp
54 {
55 
56 
57 // UNO service name for the content.
58 #define WEBDAV_CONTENT_SERVICE_NAME "com.sun.star.ucb.WebDAVContent"
59 
60 
61 class ContentProvider;
62 class ContentProperties;
63 class CachableContentProperties;
64 
66  public css::ucb::XContentCreator
67 {
69  {
73  };
74 
75  std::unique_ptr< DAVResourceAccess > m_xResAccess;
76  std::unique_ptr< CachableContentProperties > m_xCachedProps; // locally cached props
77  OUString m_aEscapedTitle;
79  ContentProvider* m_pProvider; // No need for a ref, base class holds object
81  bool m_bLocked;
84  std::vector< OUString > m_aFailedPropNames;
85 
86 private:
87  virtual css::uno::Sequence< css::beans::Property >
88  getProperties( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv ) override;
89  virtual css::uno::Sequence< css::ucb::CommandInfo >
90  getCommands( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv ) override;
91  virtual OUString getParentURL() override;
92 
94  bool isFolder( const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
95 
97  css::uno::Reference< css::sdbc::XRow >
98  getPropertyValues( const css::uno::Sequence< css::beans::Property >& rProperties,
99  const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
100 
102  css::uno::Sequence< css::uno::Any >
103  setPropertyValues( const css::uno::Sequence< css::beans::PropertyValue >& rValues,
104  const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
105 
107  typedef std::vector< ContentRef > ContentRefList;
108  void queryChildren( ContentRefList& rChildren);
109 
110  bool
111  exchangeIdentity( const css::uno::Reference< css::ucb::XContentIdentifier >& xNewId );
112 
113  const OUString
114  getBaseURI( const std::unique_ptr< DAVResourceAccess > & rResAccess );
115 
118  getResourceType( const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
119 
122  getResourceType( const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv,
123  const std::unique_ptr< DAVResourceAccess > & rResAccess,
124  bool * networkAccessAllowed = nullptr );
125 
126  // Command "open"
128  css::uno::Any open(
129  const css::ucb::OpenCommandArgument2 & rArg,
130  const css::uno::Reference<
131  css::ucb::XCommandEnvironment > & xEnv );
132 
133  // Command "post"
135  void post( const css::ucb::PostCommandArgument2 & rArg,
136  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
137 
138  // Command "insert"
140  void insert( const css::uno::Reference< css::io::XInputStream > & xInputStream,
141  bool bReplaceExisting,
142  const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment );
143 
144  // Command "transfer"
146  void transfer( const css::ucb::TransferInfo & rArgs,
147  const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment );
148 
149  // Command "delete"
151  void destroy( bool bDeletePhysical );
152 
153  // Command "lock"
155  void lock( const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment );
156 
157  // Command "unlock"
159  void unlock( const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment );
160 
161  css::uno::Any MapDAVException( const DAVException & e,
162  bool bWrite );
165  const DAVException & e,
166  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv,
167  bool bWrite = false );
168 
169  static bool shouldAccessNetworkAfterException( const DAVException & e );
170 
172  const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment );
173 
174  // XPropertyContainer replacement
179  void addProperty( const css::ucb::PropertyCommandArgument &aCmdArg,
180  const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment );
181 
185  void removeProperty( const OUString& Name,
186  const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment );
187 public:
189  Content( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
190  ContentProvider* pProvider,
191  const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier,
192  rtl::Reference< DAVSessionFactory > const & rSessionFactory );
194  Content( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
195  ContentProvider* pProvider,
196  const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier,
197  rtl::Reference< DAVSessionFactory > const & rSessionFactory,
198  bool isCollection );
199  virtual ~Content() override;
200 
201  // XInterface
202  virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
203  virtual void SAL_CALL acquire()
204  throw() override;
205  virtual void SAL_CALL release()
206  throw() override;
207 
208  // XTypeProvider
209  virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
210  virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
211 
212  // XServiceInfo
213  virtual OUString SAL_CALL
214  getImplementationName() override;
215 
216  virtual css::uno::Sequence< OUString > SAL_CALL
217  getSupportedServiceNames() override;
218 
219  // XContent
220  virtual OUString SAL_CALL
221  getContentType() override;
222 
223  // XCommandProcessor
224  virtual css::uno::Any SAL_CALL
225  execute( const css::ucb::Command& aCommand,
226  sal_Int32 CommandId,
227  const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment ) override;
228  virtual void SAL_CALL
229  abort( sal_Int32 CommandId ) override;
230 
231  // XPropertyContainer
232  virtual void SAL_CALL
233  addProperty( const OUString& Name,
234  sal_Int16 Attributes,
235  const css::uno::Any& DefaultValue ) override;
236 
237  virtual void SAL_CALL
238  removeProperty( const OUString& Name ) override;
239 
240 
241  // Additional interfaces
242 
243 
244  // XContentCreator
245  virtual css::uno::Sequence< css::ucb::ContentInfo > SAL_CALL
246  queryCreatableContentsInfo() override;
247  virtual css::uno::Reference< css::ucb::XContent > SAL_CALL
248  createNewContent( const css::ucb::ContentInfo& Info ) override;
249 
250 
251  // Non-interface methods.
252 
253 
255 
256  // Called from resultset data supplier.
257  static css::uno::Reference< css::sdbc::XRow >
258  getPropertyValues( const css::uno::Reference< css::uno::XComponentContext >& rContext,
259  const css::uno::Sequence< css::beans::Property >& rProperties,
260  const ContentProperties& rData,
262  const OUString& rContentId );
263 };
264 
265 }
266 
267 #endif
268 
269 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< CachableContentProperties > m_xCachedProps
ContentProvider * m_pProvider
Type
virtual ~Content() override
virtual OUString SAL_CALL getImplementationName() override
bool supportsExclusiveWriteLock(const css::uno::Reference< css::ucb::XCommandEnvironment > &Environment)
rtl::Reference< Content > ContentRef
void destroy(bool bDeletePhysical)
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() 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)
virtual css::uno::Any SAL_CALL execute(const css::ucb::Command &aCommand, sal_Int32 CommandId, const css::uno::Reference< css::ucb::XCommandEnvironment > &Environment) override
css::uno::Any open(const css::ucb::OpenCommandArgument2 &rArg, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
virtual void SAL_CALL acquire() override
signed char sal_Int8
void addProperty(const css::ucb::PropertyCommandArgument &aCmdArg, const css::uno::Reference< css::ucb::XCommandEnvironment > &Environment)
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
DAVResourceAccess & getResourceAccess()
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void SAL_CALL release() override
virtual OUString SAL_CALL getContentType() override
ResourceType m_eResourceType
css::uno::Any MapDAVException(const DAVException &e, bool bWrite)
virtual css::uno::Reference< css::ucb::XContent > SAL_CALL createNewContent(const css::ucb::ContentInfo &Info) override
bool isFolder(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
virtual css::uno::Sequence< css::beans::Property > getProperties(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv) override
ResourceType getResourceType(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void cancelCommandExecution(const DAVException &e, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv, bool bWrite=false)
void queryChildren(ContentRefList &rChildren)
void unlock(const css::uno::Reference< css::ucb::XCommandEnvironment > &Environment)
void transfer(const css::ucb::TransferInfo &rArgs, const css::uno::Reference< css::ucb::XCommandEnvironment > &Environment)
virtual css::uno::Sequence< css::ucb::CommandInfo > getCommands(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv) override
bool exchangeIdentity(const css::uno::Reference< css::ucb::XContentIdentifier > &xNewId)
void post(const css::ucb::PostCommandArgument2 &rArg, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
css::uno::Sequence< css::uno::Any > setPropertyValues(const css::uno::Sequence< css::beans::PropertyValue > &rValues, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
static bool shouldAccessNetworkAfterException(const DAVException &e)
std::vector< ContentRef > ContentRefList
void insert(const css::uno::Reference< css::io::XInputStream > &xInputStream, bool bReplaceExisting, const css::uno::Reference< css::ucb::XCommandEnvironment > &Environment)
std::vector< OUString > m_aFailedPropNames
css::uno::Reference< css::sdbc::XRow > getPropertyValues(const css::uno::Sequence< css::beans::Property > &rProperties, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void lock(const css::uno::Reference< css::ucb::XCommandEnvironment > &Environment)
virtual OUString getParentURL() override
virtual void SAL_CALL abort(sal_Int32 CommandId) override
const OUString getBaseURI(const std::unique_ptr< DAVResourceAccess > &rResAccess)
void removeProperty(const OUString &Name, const css::uno::Reference< css::ucb::XCommandEnvironment > &Environment)
std::unique_ptr< DAVResourceAccess > m_xResAccess
virtual css::uno::Sequence< css::ucb::ContentInfo > SAL_CALL queryCreatableContentsInfo() override