1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
22 #ifndef INCLUDED_UCB_SOURCE_UCP_WEBDAV_WEBDAVCONTENT_HXX
23 #define INCLUDED_UCB_SOURCE_UCP_WEBDAV_WEBDAVCONTENT_HXX
27 #include <boost/scoped_ptr.hpp>
28 #include <rtl/ref.hxx>
29 #include <com/sun/star/ucb/ContentCreationException.hpp>
30 #include <com/sun/star/ucb/XContentCreator.hpp>
31 #include <ucbhelper/contenthelper.hxx>
32 #include "DAVResourceAccess.hxx"
33 #include "PropertyMap.hxx"
35 namespace com
{ namespace sun
{ namespace star
{ namespace beans
{
40 namespace com
{ namespace sun
{ namespace star
{ namespace io
{
44 namespace com
{ namespace sun
{ namespace star
{ namespace sdbc
{
48 namespace com
{ namespace sun
{ namespace star
{ namespace ucb
{
49 struct OpenCommandArgument2
;
50 struct PropertyCommandArgument
;
51 struct PostCommandArgument2
;
55 namespace http_dav_ucp
60 // UNO service name for the content.
61 #define WEBDAV_CONTENT_SERVICE_NAME "com.sun.star.ucb.WebDAVContent"
65 class ContentProvider
;
66 class ContentProperties
;
67 class CachableContentProperties
;
69 class Content
: public ::ucbhelper::ContentImplHelper
,
70 public com::sun::star::ucb::XContentCreator
79 boost::scoped_ptr
< DAVResourceAccess
> m_xResAccess
;
80 boost::scoped_ptr
< CachableContentProperties
> m_xCachedProps
; // locally cached props
81 OUString m_aEscapedTitle
;
82 ResourceType m_eResourceType
;
83 ContentProvider
* m_pProvider
; // No need for a ref, base class holds object
88 std::vector
< OUString
> m_aFailedPropNames
;
91 virtual com::sun::star::uno::Sequence
< com::sun::star::beans::Property
>
92 getProperties( const com::sun::star::uno::Reference
<
93 com::sun::star::ucb::XCommandEnvironment
> & xEnv
) SAL_OVERRIDE
;
94 virtual com::sun::star::uno::Sequence
< com::sun::star::ucb::CommandInfo
>
95 getCommands( const com::sun::star::uno::Reference
<
96 com::sun::star::ucb::XCommandEnvironment
> & xEnv
) SAL_OVERRIDE
;
97 virtual OUString
getParentURL() SAL_OVERRIDE
;
99 bool isFolder( const ::com::sun::star::uno::Reference
<
100 ::com::sun::star::ucb::XCommandEnvironment
>& xEnv
)
101 throw ( ::com::sun::star::uno::Exception
);
103 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XRow
>
104 getPropertyValues( const ::com::sun::star::uno::Sequence
<
105 ::com::sun::star::beans::Property
>& rProperties
,
106 const ::com::sun::star::uno::Reference
<
107 ::com::sun::star::ucb::XCommandEnvironment
>& xEnv
)
108 throw ( ::com::sun::star::uno::Exception
);
110 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>
111 setPropertyValues( const ::com::sun::star::uno::Sequence
<
112 ::com::sun::star::beans::PropertyValue
>& rValues
,
113 const ::com::sun::star::uno::Reference
<
114 ::com::sun::star::ucb::XCommandEnvironment
>& xEnv
)
115 throw ( ::com::sun::star::uno::Exception
);
117 typedef rtl::Reference
< Content
> ContentRef
;
118 typedef std::list
< ContentRef
> ContentRefList
;
119 void queryChildren( ContentRefList
& rChildren
);
122 exchangeIdentity( const ::com::sun::star::uno::Reference
<
123 ::com::sun::star::ucb::XContentIdentifier
>& xNewId
);
126 getBaseURI( const boost::scoped_ptr
< DAVResourceAccess
> & rResAccess
);
129 getResourceType( const ::com::sun::star::uno::Reference
<
130 ::com::sun::star::ucb::XCommandEnvironment
>& xEnv
)
131 throw ( ::com::sun::star::uno::Exception
);
134 getResourceType( const ::com::sun::star::uno::Reference
<
135 ::com::sun::star::ucb::XCommandEnvironment
>& xEnv
,
136 const boost::scoped_ptr
< DAVResourceAccess
> & rResAccess
,
137 bool * networkAccessAllowed
= 0 )
138 throw ( ::com::sun::star::uno::Exception
);
141 com::sun::star::uno::Any
open(
142 const com::sun::star::ucb::OpenCommandArgument2
& rArg
,
143 const com::sun::star::uno::Reference
<
144 com::sun::star::ucb::XCommandEnvironment
> & xEnv
)
145 throw( ::com::sun::star::uno::Exception
);
148 void post( const com::sun::star::ucb::PostCommandArgument2
& rArg
,
149 const com::sun::star::uno::Reference
<
150 com::sun::star::ucb::XCommandEnvironment
> & xEnv
)
151 throw( ::com::sun::star::uno::Exception
);
154 void insert( const ::com::sun::star::uno::Reference
<
155 ::com::sun::star::io::XInputStream
> & xInputStream
,
156 bool bReplaceExisting
,
157 const com::sun::star::uno::Reference
<
158 com::sun::star::ucb::XCommandEnvironment
>& Environment
)
159 throw( ::com::sun::star::uno::Exception
);
161 // Command "transfer"
162 void transfer( const ::com::sun::star::ucb::TransferInfo
& rArgs
,
163 const com::sun::star::uno::Reference
<
164 com::sun::star::ucb::XCommandEnvironment
>& Environment
)
165 throw( ::com::sun::star::uno::Exception
);
168 void destroy( bool bDeletePhysical
)
169 throw( ::com::sun::star::uno::Exception
);
172 void lock( const com::sun::star::uno::Reference
<
173 com::sun::star::ucb::XCommandEnvironment
>& Environment
)
174 throw( ::com::sun::star::uno::Exception
);
177 void unlock( const com::sun::star::uno::Reference
<
178 com::sun::star::ucb::XCommandEnvironment
>& Environment
)
179 throw( ::com::sun::star::uno::Exception
);
181 ::com::sun::star::uno::Any
MapDAVException( const DAVException
& e
,
183 void cancelCommandExecution(
184 const DAVException
& e
,
185 const ::com::sun::star::uno::Reference
<
186 com::sun::star::ucb::XCommandEnvironment
> & xEnv
,
187 bool bWrite
= false )
188 throw( ::com::sun::star::uno::Exception
);
190 static bool shouldAccessNetworkAfterException( const DAVException
& e
);
192 bool supportsExclusiveWriteLock(
193 const com::sun::star::uno::Reference
<
194 com::sun::star::ucb::XCommandEnvironment
>& Environment
);
196 // XPropertyContainer replacement
197 void addProperty( const com::sun::star::ucb::PropertyCommandArgument
&aCmdArg
,
198 const com::sun::star::uno::Reference
<
199 com::sun::star::ucb::XCommandEnvironment
>& Environment
)
200 throw( com::sun::star::beans::PropertyExistException
,
201 com::sun::star::beans::IllegalTypeException
,
202 com::sun::star::lang::IllegalArgumentException
,
203 com::sun::star::uno::RuntimeException
);
205 void removeProperty( const rtl::OUString
& Name
,
206 const com::sun::star::uno::Reference
<
207 com::sun::star::ucb::XCommandEnvironment
>& Environment
)
208 throw( com::sun::star::beans::UnknownPropertyException
,
209 com::sun::star::beans::NotRemoveableException
,
210 com::sun::star::uno::RuntimeException
);
212 Content( const ::com::sun::star::uno::Reference
<
213 ::com::sun::star::uno::XComponentContext
>& rxContext
,
214 ContentProvider
* pProvider
,
215 const ::com::sun::star::uno::Reference
<
216 ::com::sun::star::ucb::XContentIdentifier
>& Identifier
,
217 rtl::Reference
< DAVSessionFactory
> const & rSessionFactory
)
218 throw ( ::com::sun::star::ucb::ContentCreationException
);
219 Content( const ::com::sun::star::uno::Reference
<
220 ::com::sun::star::uno::XComponentContext
>& rxContext
,
221 ContentProvider
* pProvider
,
222 const ::com::sun::star::uno::Reference
<
223 ::com::sun::star::ucb::XContentIdentifier
>& Identifier
,
224 rtl::Reference
< DAVSessionFactory
> const & rSessionFactory
,
226 throw ( ::com::sun::star::ucb::ContentCreationException
);
230 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
)
231 throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
232 virtual void SAL_CALL
acquire()
233 throw() SAL_OVERRIDE
;
234 virtual void SAL_CALL
release()
235 throw() SAL_OVERRIDE
;
238 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId()
239 throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
240 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes()
241 throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
244 virtual OUString SAL_CALL
245 getImplementationName()
246 throw( ::com::sun::star::uno::RuntimeException
) SAL_OVERRIDE
;
248 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
249 getSupportedServiceNames()
250 throw( ::com::sun::star::uno::RuntimeException
) SAL_OVERRIDE
;
253 virtual OUString SAL_CALL
255 throw( com::sun::star::uno::RuntimeException
) SAL_OVERRIDE
;
258 virtual com::sun::star::uno::Any SAL_CALL
259 execute( const com::sun::star::ucb::Command
& aCommand
,
261 const com::sun::star::uno::Reference
<
262 com::sun::star::ucb::XCommandEnvironment
>& Environment
)
263 throw( com::sun::star::uno::Exception
,
264 com::sun::star::ucb::CommandAbortedException
,
265 com::sun::star::uno::RuntimeException
) SAL_OVERRIDE
;
266 virtual void SAL_CALL
267 abort( sal_Int32 CommandId
)
268 throw( com::sun::star::uno::RuntimeException
) SAL_OVERRIDE
;
270 // XPropertyContainer
271 virtual void SAL_CALL
272 addProperty( const OUString
& Name
,
273 sal_Int16 Attributes
,
274 const com::sun::star::uno::Any
& DefaultValue
)
275 throw( com::sun::star::beans::PropertyExistException
,
276 com::sun::star::beans::IllegalTypeException
,
277 com::sun::star::lang::IllegalArgumentException
,
278 com::sun::star::uno::RuntimeException
) SAL_OVERRIDE
;
280 virtual void SAL_CALL
281 removeProperty( const OUString
& Name
)
282 throw( com::sun::star::beans::UnknownPropertyException
,
283 com::sun::star::beans::NotRemoveableException
,
284 com::sun::star::uno::RuntimeException
) SAL_OVERRIDE
;
287 // Additional interfaces
291 virtual com::sun::star::uno::Sequence
<
292 com::sun::star::ucb::ContentInfo
> SAL_CALL
293 queryCreatableContentsInfo()
294 throw( com::sun::star::uno::RuntimeException
) SAL_OVERRIDE
;
295 virtual com::sun::star::uno::Reference
<
296 com::sun::star::ucb::XContent
> SAL_CALL
297 createNewContent( const com::sun::star::ucb::ContentInfo
& Info
)
298 throw( com::sun::star::uno::RuntimeException
) SAL_OVERRIDE
;
301 // Non-interface methods.
304 DAVResourceAccess
& getResourceAccess() { return *m_xResAccess
; }
306 // Called from resultset data supplier.
307 static ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XRow
>
308 getPropertyValues( const ::com::sun::star::uno::Reference
<
309 ::com::sun::star::uno::XComponentContext
>& rContext
,
310 const ::com::sun::star::uno::Sequence
<
311 ::com::sun::star::beans::Property
>& rProperties
,
312 const ContentProperties
& rData
,
313 const rtl::Reference
<
314 ::ucbhelper::ContentProviderImplHelper
>& rProvider
,
315 const OUString
& rContentId
);
322 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */