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