12f86921cSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 32f86921cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 42f86921cSAndrew Rist * or more contributor license agreements. See the NOTICE file 52f86921cSAndrew Rist * distributed with this work for additional information 62f86921cSAndrew Rist * regarding copyright ownership. The ASF licenses this file 72f86921cSAndrew Rist * to you under the Apache License, Version 2.0 (the 82f86921cSAndrew Rist * "License"); you may not use this file except in compliance 92f86921cSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 112f86921cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 132f86921cSAndrew Rist * Unless required by applicable law or agreed to in writing, 142f86921cSAndrew Rist * software distributed under the License is distributed on an 152f86921cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 162f86921cSAndrew Rist * KIND, either express or implied. See the License for the 172f86921cSAndrew Rist * specific language governing permissions and limitations 182f86921cSAndrew Rist * under the License. 19cdf0e10cSrcweir * 202f86921cSAndrew Rist *************************************************************/ 212f86921cSAndrew Rist 222f86921cSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_ucb.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir /************************************************************************** 28cdf0e10cSrcweir TODO 29cdf0e10cSrcweir ************************************************************************** 30cdf0e10cSrcweir 31cdf0e10cSrcweir *************************************************************************/ 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include <osl/diagnose.h> 34cdf0e10cSrcweir #include "osl/doublecheckedlocking.h" 35cdf0e10cSrcweir #include <rtl/uri.hxx> 36cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 37cdf0e10cSrcweir #include <ucbhelper/contentidentifier.hxx> 38cdf0e10cSrcweir #include <ucbhelper/propertyvalueset.hxx> 39cdf0e10cSrcweir #include <ucbhelper/simpleinteractionrequest.hxx> 40cdf0e10cSrcweir #include <ucbhelper/cancelcommandexecution.hxx> 41cdf0e10cSrcweir 42cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp> 43cdf0e10cSrcweir #include <com/sun/star/beans/PropertySetInfoChange.hpp> 44cdf0e10cSrcweir #include <com/sun/star/beans/PropertySetInfoChangeEvent.hpp> 45cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp> 46cdf0e10cSrcweir #include <com/sun/star/io/XActiveDataSink.hpp> 47cdf0e10cSrcweir #include <com/sun/star/io/XOutputStream.hpp> 48cdf0e10cSrcweir #include <com/sun/star/lang/IllegalAccessException.hpp> 49cdf0e10cSrcweir #include <com/sun/star/task/PasswordContainerInteractionHandler.hpp> 50cdf0e10cSrcweir #include <com/sun/star/ucb/CommandEnvironment.hpp> 51cdf0e10cSrcweir #include <com/sun/star/ucb/CommandFailedException.hpp> 52cdf0e10cSrcweir #include <com/sun/star/ucb/ContentInfoAttribute.hpp> 53cdf0e10cSrcweir #include <com/sun/star/ucb/InsertCommandArgument.hpp> 54cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveBadTransferURLException.hpp> 55cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp> 56cdf0e10cSrcweir #include "com/sun/star/ucb/InteractiveLockingLockedException.hpp" 57cdf0e10cSrcweir #include "com/sun/star/ucb/InteractiveLockingLockExpiredException.hpp" 58cdf0e10cSrcweir #include "com/sun/star/ucb/InteractiveLockingNotLockedException.hpp" 59cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveNetworkConnectException.hpp> 60cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveNetworkGeneralException.hpp> 61cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveNetworkReadException.hpp> 62cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveNetworkResolveNameException.hpp> 63cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveNetworkWriteException.hpp> 64cdf0e10cSrcweir #include <com/sun/star/ucb/MissingInputStreamException.hpp> 65cdf0e10cSrcweir #include <com/sun/star/ucb/MissingPropertiesException.hpp> 66cdf0e10cSrcweir #include <com/sun/star/ucb/NameClash.hpp> 67cdf0e10cSrcweir #include <com/sun/star/ucb/NameClashException.hpp> 68cdf0e10cSrcweir #include <com/sun/star/ucb/OpenCommandArgument2.hpp> 69cdf0e10cSrcweir #include <com/sun/star/ucb/OpenMode.hpp> 70cdf0e10cSrcweir #include <com/sun/star/ucb/PostCommandArgument2.hpp> 71cdf0e10cSrcweir #include <com/sun/star/ucb/TransferInfo.hpp> 72cdf0e10cSrcweir #include <com/sun/star/ucb/UnsupportedCommandException.hpp> 73cdf0e10cSrcweir #include <com/sun/star/ucb/UnsupportedDataSinkException.hpp> 74cdf0e10cSrcweir #include <com/sun/star/ucb/UnsupportedNameClashException.hpp> 75cdf0e10cSrcweir #include <com/sun/star/ucb/UnsupportedOpenModeException.hpp> 76cdf0e10cSrcweir #include <com/sun/star/ucb/XCommandInfo.hpp> 77cdf0e10cSrcweir #include <com/sun/star/ucb/XPersistentPropertySet.hpp> 78cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp> 79cdf0e10cSrcweir 80cdf0e10cSrcweir #include "webdavcontent.hxx" 81cdf0e10cSrcweir #include "webdavprovider.hxx" 82cdf0e10cSrcweir #include "webdavresultset.hxx" 83cdf0e10cSrcweir #include "ContentProperties.hxx" 84*59ddfc10SAndre Fischer #include "SerfUri.hxx" 85cdf0e10cSrcweir #include "UCBDeadPropertyValue.hxx" 86cdf0e10cSrcweir 87cdf0e10cSrcweir using namespace com::sun::star; 88*59ddfc10SAndre Fischer using namespace http_dav_ucp; 89cdf0e10cSrcweir 90cdf0e10cSrcweir //========================================================================= 91cdf0e10cSrcweir //========================================================================= 92cdf0e10cSrcweir // 93cdf0e10cSrcweir // Content Implementation. 94cdf0e10cSrcweir // 95cdf0e10cSrcweir //========================================================================= 96cdf0e10cSrcweir //========================================================================= 97cdf0e10cSrcweir 98cdf0e10cSrcweir //========================================================================= 99cdf0e10cSrcweir // ctr for content on an existing webdav resource 100cdf0e10cSrcweir Content::Content( 101cdf0e10cSrcweir const uno::Reference< lang::XMultiServiceFactory >& rxSMgr, 102cdf0e10cSrcweir ContentProvider* pProvider, 103cdf0e10cSrcweir const uno::Reference< ucb::XContentIdentifier >& Identifier, 104cdf0e10cSrcweir rtl::Reference< DAVSessionFactory > const & rSessionFactory ) 105cdf0e10cSrcweir throw ( ucb::ContentCreationException ) 106cdf0e10cSrcweir : ContentImplHelper( rxSMgr, pProvider, Identifier ), 107cdf0e10cSrcweir m_eResourceType( UNKNOWN ), 108cdf0e10cSrcweir m_pProvider( pProvider ), 109cdf0e10cSrcweir m_bTransient( false ), 110cdf0e10cSrcweir m_bCollection( false ), 111cdf0e10cSrcweir m_bDidGetOrHead( false ) 112cdf0e10cSrcweir { 113cdf0e10cSrcweir try 114cdf0e10cSrcweir { 115cdf0e10cSrcweir m_xResAccess.reset( new DAVResourceAccess( 116cdf0e10cSrcweir rxSMgr, 117cdf0e10cSrcweir rSessionFactory, 118cdf0e10cSrcweir Identifier->getContentIdentifier() ) ); 119cdf0e10cSrcweir 120*59ddfc10SAndre Fischer SerfUri aURI( Identifier->getContentIdentifier() ); 121cdf0e10cSrcweir m_aEscapedTitle = aURI.GetPathBaseName(); 122cdf0e10cSrcweir } 123cdf0e10cSrcweir catch ( DAVException const & ) 124cdf0e10cSrcweir { 125cdf0e10cSrcweir throw ucb::ContentCreationException(); 126cdf0e10cSrcweir } 127cdf0e10cSrcweir } 128cdf0e10cSrcweir 129cdf0e10cSrcweir //========================================================================= 130cdf0e10cSrcweir // ctr for content on an non-existing webdav resource 131cdf0e10cSrcweir Content::Content( 132cdf0e10cSrcweir const uno::Reference< lang::XMultiServiceFactory >& rxSMgr, 133cdf0e10cSrcweir ContentProvider* pProvider, 134cdf0e10cSrcweir const uno::Reference< ucb::XContentIdentifier >& Identifier, 135cdf0e10cSrcweir rtl::Reference< DAVSessionFactory > const & rSessionFactory, 136cdf0e10cSrcweir sal_Bool isCollection ) 137cdf0e10cSrcweir throw ( ucb::ContentCreationException ) 138cdf0e10cSrcweir : ContentImplHelper( rxSMgr, pProvider, Identifier ), 139cdf0e10cSrcweir m_eResourceType( UNKNOWN ), 140cdf0e10cSrcweir m_pProvider( pProvider ), 141cdf0e10cSrcweir m_bTransient( true ), 142cdf0e10cSrcweir m_bCollection( isCollection ), 143cdf0e10cSrcweir m_bDidGetOrHead( false ) 144cdf0e10cSrcweir { 145cdf0e10cSrcweir try 146cdf0e10cSrcweir { 147cdf0e10cSrcweir m_xResAccess.reset( new DAVResourceAccess( 148cdf0e10cSrcweir rxSMgr, rSessionFactory, Identifier->getContentIdentifier() ) ); 149cdf0e10cSrcweir } 150cdf0e10cSrcweir catch ( DAVException const & ) 151cdf0e10cSrcweir { 152cdf0e10cSrcweir throw ucb::ContentCreationException(); 153cdf0e10cSrcweir } 154cdf0e10cSrcweir 155cdf0e10cSrcweir // Do not set m_aEscapedTitle here! Content::insert relays on this!!! 156cdf0e10cSrcweir } 157cdf0e10cSrcweir 158cdf0e10cSrcweir //========================================================================= 159cdf0e10cSrcweir // virtual 160cdf0e10cSrcweir Content::~Content() 161cdf0e10cSrcweir { 162cdf0e10cSrcweir } 163cdf0e10cSrcweir 164cdf0e10cSrcweir //========================================================================= 165cdf0e10cSrcweir // 166cdf0e10cSrcweir // XInterface methods. 167cdf0e10cSrcweir // 168cdf0e10cSrcweir //========================================================================= 169cdf0e10cSrcweir 170cdf0e10cSrcweir // virtual 171cdf0e10cSrcweir void SAL_CALL Content::acquire() 172cdf0e10cSrcweir throw( ) 173cdf0e10cSrcweir { 174cdf0e10cSrcweir ContentImplHelper::acquire(); 175cdf0e10cSrcweir } 176cdf0e10cSrcweir 177cdf0e10cSrcweir //========================================================================= 178cdf0e10cSrcweir // virtual 179cdf0e10cSrcweir void SAL_CALL Content::release() 180cdf0e10cSrcweir throw( ) 181cdf0e10cSrcweir { 182cdf0e10cSrcweir ContentImplHelper::release(); 183cdf0e10cSrcweir } 184cdf0e10cSrcweir 185cdf0e10cSrcweir //========================================================================= 186cdf0e10cSrcweir // virtual 187cdf0e10cSrcweir uno::Any SAL_CALL Content::queryInterface( const uno::Type & rType ) 188cdf0e10cSrcweir throw ( uno::RuntimeException ) 189cdf0e10cSrcweir { 190cdf0e10cSrcweir // Note: isFolder may require network activities! So call it only 191cdf0e10cSrcweir // if it is really necessary!!! 192cdf0e10cSrcweir uno::Any aRet = cppu::queryInterface( 193cdf0e10cSrcweir rType, 194cdf0e10cSrcweir static_cast< ucb::XContentCreator * >( this ) ); 195cdf0e10cSrcweir if ( aRet.hasValue() ) 196cdf0e10cSrcweir { 197cdf0e10cSrcweir try 198cdf0e10cSrcweir { 199cdf0e10cSrcweir uno::Reference< beans::XPropertySet > const xProps( 200cdf0e10cSrcweir m_xSMgr, uno::UNO_QUERY_THROW ); 201cdf0e10cSrcweir uno::Reference< uno::XComponentContext > xCtx; 202cdf0e10cSrcweir xCtx.set( xProps->getPropertyValue( 203cdf0e10cSrcweir rtl::OUString( 204cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ), 205cdf0e10cSrcweir uno::UNO_QUERY_THROW ); 206cdf0e10cSrcweir 207cdf0e10cSrcweir uno::Reference< task::XInteractionHandler > xIH( 208cdf0e10cSrcweir task::PasswordContainerInteractionHandler::create( xCtx ) ); 209cdf0e10cSrcweir 210cdf0e10cSrcweir // Supply a command env to isFolder() that contains an interaction 211cdf0e10cSrcweir // handler that uses the password container service to obtain 212cdf0e10cSrcweir // credentials without displaying a password gui. 213cdf0e10cSrcweir 214cdf0e10cSrcweir uno::Reference< ucb::XCommandEnvironment > xCmdEnv( 215cdf0e10cSrcweir ucb::CommandEnvironment::create( 216cdf0e10cSrcweir xCtx, 217cdf0e10cSrcweir xIH, 218cdf0e10cSrcweir uno::Reference< ucb::XProgressHandler >() ) ); 219cdf0e10cSrcweir 220cdf0e10cSrcweir return isFolder( xCmdEnv ) ? aRet : uno::Any(); 221cdf0e10cSrcweir } 222cdf0e10cSrcweir catch ( uno::RuntimeException const & ) 223cdf0e10cSrcweir { 224cdf0e10cSrcweir throw; 225cdf0e10cSrcweir } 226cdf0e10cSrcweir catch ( uno::Exception const & ) 227cdf0e10cSrcweir { 228cdf0e10cSrcweir return uno::Any(); 229cdf0e10cSrcweir } 230cdf0e10cSrcweir } 231cdf0e10cSrcweir return aRet.hasValue() ? aRet : ContentImplHelper::queryInterface( rType ); 232cdf0e10cSrcweir } 233cdf0e10cSrcweir 234cdf0e10cSrcweir //========================================================================= 235cdf0e10cSrcweir // 236cdf0e10cSrcweir // XTypeProvider methods. 237cdf0e10cSrcweir // 238cdf0e10cSrcweir //========================================================================= 239cdf0e10cSrcweir 240cdf0e10cSrcweir XTYPEPROVIDER_COMMON_IMPL( Content ); 241cdf0e10cSrcweir 242cdf0e10cSrcweir //========================================================================= 243cdf0e10cSrcweir // virtual 244cdf0e10cSrcweir uno::Sequence< uno::Type > SAL_CALL Content::getTypes() 245cdf0e10cSrcweir throw( uno::RuntimeException ) 246cdf0e10cSrcweir { 247cdf0e10cSrcweir sal_Bool bFolder = sal_False; 248cdf0e10cSrcweir try 249cdf0e10cSrcweir { 250cdf0e10cSrcweir bFolder 251cdf0e10cSrcweir = isFolder( uno::Reference< ucb::XCommandEnvironment >() ); 252cdf0e10cSrcweir } 253cdf0e10cSrcweir catch ( uno::RuntimeException const & ) 254cdf0e10cSrcweir { 255cdf0e10cSrcweir throw; 256cdf0e10cSrcweir } 257cdf0e10cSrcweir catch ( uno::Exception const & ) 258cdf0e10cSrcweir { 259cdf0e10cSrcweir } 260cdf0e10cSrcweir 261cdf0e10cSrcweir cppu::OTypeCollection * pCollection = 0; 262cdf0e10cSrcweir 263cdf0e10cSrcweir if ( bFolder ) 264cdf0e10cSrcweir { 265cdf0e10cSrcweir static cppu::OTypeCollection* pFolderTypes = 0; 266cdf0e10cSrcweir 267cdf0e10cSrcweir pCollection = pFolderTypes; 268cdf0e10cSrcweir if ( !pCollection ) 269cdf0e10cSrcweir { 270cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); 271cdf0e10cSrcweir 272cdf0e10cSrcweir pCollection = pFolderTypes; 273cdf0e10cSrcweir if ( !pCollection ) 274cdf0e10cSrcweir { 275cdf0e10cSrcweir static cppu::OTypeCollection aCollection( 276cdf0e10cSrcweir CPPU_TYPE_REF( lang::XTypeProvider ), 277cdf0e10cSrcweir CPPU_TYPE_REF( lang::XServiceInfo ), 278cdf0e10cSrcweir CPPU_TYPE_REF( lang::XComponent ), 279cdf0e10cSrcweir CPPU_TYPE_REF( ucb::XContent ), 280cdf0e10cSrcweir CPPU_TYPE_REF( ucb::XCommandProcessor ), 281cdf0e10cSrcweir CPPU_TYPE_REF( beans::XPropertiesChangeNotifier ), 282cdf0e10cSrcweir CPPU_TYPE_REF( ucb::XCommandInfoChangeNotifier ), 283cdf0e10cSrcweir CPPU_TYPE_REF( beans::XPropertyContainer ), 284cdf0e10cSrcweir CPPU_TYPE_REF( beans::XPropertySetInfoChangeNotifier ), 285cdf0e10cSrcweir CPPU_TYPE_REF( container::XChild ), 286cdf0e10cSrcweir CPPU_TYPE_REF( ucb::XContentCreator ) ); // !! 287cdf0e10cSrcweir pCollection = &aCollection; 288cdf0e10cSrcweir OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); 289cdf0e10cSrcweir pFolderTypes = pCollection; 290cdf0e10cSrcweir } 291cdf0e10cSrcweir } 292cdf0e10cSrcweir else { 293cdf0e10cSrcweir OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); 294cdf0e10cSrcweir } 295cdf0e10cSrcweir } 296cdf0e10cSrcweir else 297cdf0e10cSrcweir { 298cdf0e10cSrcweir static cppu::OTypeCollection* pDocumentTypes = 0; 299cdf0e10cSrcweir 300cdf0e10cSrcweir pCollection = pDocumentTypes; 301cdf0e10cSrcweir if ( !pCollection ) 302cdf0e10cSrcweir { 303cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); 304cdf0e10cSrcweir 305cdf0e10cSrcweir pCollection = pDocumentTypes; 306cdf0e10cSrcweir if ( !pCollection ) 307cdf0e10cSrcweir { 308cdf0e10cSrcweir static cppu::OTypeCollection aCollection( 309cdf0e10cSrcweir CPPU_TYPE_REF( lang::XTypeProvider ), 310cdf0e10cSrcweir CPPU_TYPE_REF( lang::XServiceInfo ), 311cdf0e10cSrcweir CPPU_TYPE_REF( lang::XComponent ), 312cdf0e10cSrcweir CPPU_TYPE_REF( ucb::XContent ), 313cdf0e10cSrcweir CPPU_TYPE_REF( ucb::XCommandProcessor ), 314cdf0e10cSrcweir CPPU_TYPE_REF( beans::XPropertiesChangeNotifier ), 315cdf0e10cSrcweir CPPU_TYPE_REF( ucb::XCommandInfoChangeNotifier ), 316cdf0e10cSrcweir CPPU_TYPE_REF( beans::XPropertyContainer ), 317cdf0e10cSrcweir CPPU_TYPE_REF( beans::XPropertySetInfoChangeNotifier ), 318cdf0e10cSrcweir CPPU_TYPE_REF( container::XChild ) ); 319cdf0e10cSrcweir pCollection = &aCollection; 320cdf0e10cSrcweir OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); 321cdf0e10cSrcweir pDocumentTypes = pCollection; 322cdf0e10cSrcweir } 323cdf0e10cSrcweir } 324cdf0e10cSrcweir else { 325cdf0e10cSrcweir OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); 326cdf0e10cSrcweir } 327cdf0e10cSrcweir } 328cdf0e10cSrcweir 329cdf0e10cSrcweir return (*pCollection).getTypes(); 330cdf0e10cSrcweir } 331cdf0e10cSrcweir 332cdf0e10cSrcweir //========================================================================= 333cdf0e10cSrcweir // 334cdf0e10cSrcweir // XServiceInfo methods. 335cdf0e10cSrcweir // 336cdf0e10cSrcweir //========================================================================= 337cdf0e10cSrcweir 338cdf0e10cSrcweir // virtual 339cdf0e10cSrcweir rtl::OUString SAL_CALL Content::getImplementationName() 340cdf0e10cSrcweir throw( uno::RuntimeException ) 341cdf0e10cSrcweir { 342cdf0e10cSrcweir return rtl::OUString::createFromAscii( 343cdf0e10cSrcweir "com.sun.star.comp.ucb.WebDAVContent" ); 344cdf0e10cSrcweir } 345cdf0e10cSrcweir 346cdf0e10cSrcweir //========================================================================= 347cdf0e10cSrcweir // virtual 348cdf0e10cSrcweir uno::Sequence< rtl::OUString > SAL_CALL Content::getSupportedServiceNames() 349cdf0e10cSrcweir throw( uno::RuntimeException ) 350cdf0e10cSrcweir { 351cdf0e10cSrcweir uno::Sequence< rtl::OUString > aSNS( 1 ); 352cdf0e10cSrcweir aSNS.getArray()[ 0 ] 353cdf0e10cSrcweir = rtl::OUString::createFromAscii( WEBDAV_CONTENT_SERVICE_NAME ); 354cdf0e10cSrcweir return aSNS; 355cdf0e10cSrcweir } 356cdf0e10cSrcweir 357cdf0e10cSrcweir //========================================================================= 358cdf0e10cSrcweir // 359cdf0e10cSrcweir // XContent methods. 360cdf0e10cSrcweir // 361cdf0e10cSrcweir //========================================================================= 362cdf0e10cSrcweir 363cdf0e10cSrcweir // virtual 364cdf0e10cSrcweir rtl::OUString SAL_CALL Content::getContentType() 365cdf0e10cSrcweir throw( uno::RuntimeException ) 366cdf0e10cSrcweir { 367cdf0e10cSrcweir sal_Bool bFolder = sal_False; 368cdf0e10cSrcweir try 369cdf0e10cSrcweir { 370cdf0e10cSrcweir bFolder 371cdf0e10cSrcweir = isFolder( uno::Reference< ucb::XCommandEnvironment >() ); 372cdf0e10cSrcweir } 373cdf0e10cSrcweir catch ( uno::RuntimeException const & ) 374cdf0e10cSrcweir { 375cdf0e10cSrcweir throw; 376cdf0e10cSrcweir } 377cdf0e10cSrcweir catch ( uno::Exception const & ) 378cdf0e10cSrcweir { 379cdf0e10cSrcweir } 380cdf0e10cSrcweir 381cdf0e10cSrcweir if ( bFolder ) 382cdf0e10cSrcweir return rtl::OUString::createFromAscii( WEBDAV_COLLECTION_TYPE ); 383cdf0e10cSrcweir 384cdf0e10cSrcweir return rtl::OUString::createFromAscii( WEBDAV_CONTENT_TYPE ); 385cdf0e10cSrcweir } 386cdf0e10cSrcweir 387cdf0e10cSrcweir //========================================================================= 388cdf0e10cSrcweir // 389cdf0e10cSrcweir // XCommandProcessor methods. 390cdf0e10cSrcweir // 391cdf0e10cSrcweir //========================================================================= 392cdf0e10cSrcweir 393cdf0e10cSrcweir // virtual 394cdf0e10cSrcweir uno::Any SAL_CALL Content::execute( 395cdf0e10cSrcweir const ucb::Command& aCommand, 396cdf0e10cSrcweir sal_Int32 /*CommandId*/, 397cdf0e10cSrcweir const uno::Reference< ucb::XCommandEnvironment >& Environment ) 398cdf0e10cSrcweir throw( uno::Exception, 399cdf0e10cSrcweir ucb::CommandAbortedException, 400cdf0e10cSrcweir uno::RuntimeException ) 401cdf0e10cSrcweir { 402cdf0e10cSrcweir OSL_TRACE( ">>>>> Content::execute: start: command: %s, env: %s", 403cdf0e10cSrcweir rtl::OUStringToOString( aCommand.Name, 404cdf0e10cSrcweir RTL_TEXTENCODING_UTF8 ).getStr(), 405cdf0e10cSrcweir Environment.is() ? "present" : "missing" ); 406cdf0e10cSrcweir 407cdf0e10cSrcweir uno::Any aRet; 408cdf0e10cSrcweir 409cdf0e10cSrcweir if ( aCommand.Name.equalsAsciiL( 410cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "getPropertyValues" ) ) ) 411cdf0e10cSrcweir { 412cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 413cdf0e10cSrcweir // getPropertyValues 414cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 415cdf0e10cSrcweir 416cdf0e10cSrcweir uno::Sequence< beans::Property > Properties; 417cdf0e10cSrcweir if ( !( aCommand.Argument >>= Properties ) ) 418cdf0e10cSrcweir { 419cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 420cdf0e10cSrcweir uno::makeAny( lang::IllegalArgumentException( 421cdf0e10cSrcweir rtl::OUString::createFromAscii( 422cdf0e10cSrcweir "Wrong argument type!" ), 423cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 424cdf0e10cSrcweir -1 ) ), 425cdf0e10cSrcweir Environment ); 426cdf0e10cSrcweir // Unreachable 427cdf0e10cSrcweir } 428cdf0e10cSrcweir 429cdf0e10cSrcweir aRet <<= getPropertyValues( Properties, Environment ); 430cdf0e10cSrcweir } 431cdf0e10cSrcweir else if ( aCommand.Name.equalsAsciiL( 432cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "setPropertyValues" ) ) ) 433cdf0e10cSrcweir { 434cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 435cdf0e10cSrcweir // setPropertyValues 436cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 437cdf0e10cSrcweir 438cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aProperties; 439cdf0e10cSrcweir if ( !( aCommand.Argument >>= aProperties ) ) 440cdf0e10cSrcweir { 441cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 442cdf0e10cSrcweir uno::makeAny( lang::IllegalArgumentException( 443cdf0e10cSrcweir rtl::OUString::createFromAscii( 444cdf0e10cSrcweir "Wrong argument type!" ), 445cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 446cdf0e10cSrcweir -1 ) ), 447cdf0e10cSrcweir Environment ); 448cdf0e10cSrcweir // Unreachable 449cdf0e10cSrcweir } 450cdf0e10cSrcweir 451cdf0e10cSrcweir if ( !aProperties.getLength() ) 452cdf0e10cSrcweir { 453cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 454cdf0e10cSrcweir uno::makeAny( lang::IllegalArgumentException( 455cdf0e10cSrcweir rtl::OUString::createFromAscii( 456cdf0e10cSrcweir "No properties!" ), 457cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 458cdf0e10cSrcweir -1 ) ), 459cdf0e10cSrcweir Environment ); 460cdf0e10cSrcweir // Unreachable 461cdf0e10cSrcweir } 462cdf0e10cSrcweir 463cdf0e10cSrcweir aRet <<= setPropertyValues( aProperties, Environment ); 464cdf0e10cSrcweir } 465cdf0e10cSrcweir else if ( aCommand.Name.equalsAsciiL( 466cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "getPropertySetInfo" ) ) ) 467cdf0e10cSrcweir { 468cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 469cdf0e10cSrcweir // getPropertySetInfo 470cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 471cdf0e10cSrcweir 472cdf0e10cSrcweir // Note: Implemented by base class. 473cdf0e10cSrcweir aRet <<= getPropertySetInfo( Environment, 474cdf0e10cSrcweir sal_False /* don't cache data */ ); 475cdf0e10cSrcweir } 476cdf0e10cSrcweir else if ( aCommand.Name.equalsAsciiL( 477cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "getCommandInfo" ) ) ) 478cdf0e10cSrcweir { 479cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 480cdf0e10cSrcweir // getCommandInfo 481cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 482cdf0e10cSrcweir 483cdf0e10cSrcweir // Note: Implemented by base class. 484cdf0e10cSrcweir aRet <<= getCommandInfo( Environment, sal_False ); 485cdf0e10cSrcweir } 486cdf0e10cSrcweir else if ( aCommand.Name.equalsAsciiL( 487cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "open" ) ) ) 488cdf0e10cSrcweir { 489cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 490cdf0e10cSrcweir // open 491cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 492cdf0e10cSrcweir 493cdf0e10cSrcweir ucb::OpenCommandArgument2 aOpenCommand; 494cdf0e10cSrcweir if ( !( aCommand.Argument >>= aOpenCommand ) ) 495cdf0e10cSrcweir { 496cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 497cdf0e10cSrcweir uno::makeAny( lang::IllegalArgumentException( 498cdf0e10cSrcweir rtl::OUString::createFromAscii( 499cdf0e10cSrcweir "Wrong argument type!" ), 500cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 501cdf0e10cSrcweir -1 ) ), 502cdf0e10cSrcweir Environment ); 503cdf0e10cSrcweir // Unreachable 504cdf0e10cSrcweir } 505cdf0e10cSrcweir 506cdf0e10cSrcweir aRet = open( aOpenCommand, Environment ); 507cdf0e10cSrcweir } 508cdf0e10cSrcweir else if ( aCommand.Name.equalsAsciiL( 509cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "insert" ) ) ) 510cdf0e10cSrcweir { 511cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 512cdf0e10cSrcweir // insert 513cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 514cdf0e10cSrcweir 515cdf0e10cSrcweir ucb::InsertCommandArgument arg; 516cdf0e10cSrcweir if ( !( aCommand.Argument >>= arg ) ) 517cdf0e10cSrcweir { 518cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 519cdf0e10cSrcweir uno::makeAny( lang::IllegalArgumentException( 520cdf0e10cSrcweir rtl::OUString::createFromAscii( 521cdf0e10cSrcweir "Wrong argument type!" ), 522cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 523cdf0e10cSrcweir -1 ) ), 524cdf0e10cSrcweir Environment ); 525cdf0e10cSrcweir // Unreachable 526cdf0e10cSrcweir } 527cdf0e10cSrcweir 528cdf0e10cSrcweir insert( arg.Data, arg.ReplaceExisting, Environment ); 529cdf0e10cSrcweir } 530cdf0e10cSrcweir else if ( aCommand.Name.equalsAsciiL( 531cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "delete" ) ) ) 532cdf0e10cSrcweir { 533cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 534cdf0e10cSrcweir // delete 535cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 536cdf0e10cSrcweir 537cdf0e10cSrcweir sal_Bool bDeletePhysical = sal_False; 538cdf0e10cSrcweir aCommand.Argument >>= bDeletePhysical; 539cdf0e10cSrcweir 540cdf0e10cSrcweir // KSO: Ignore parameter and destroy the content, if you don't support 541cdf0e10cSrcweir // putting objects into trashcan. ( Since we do not have a trash can 542cdf0e10cSrcweir // service yet (src603), you actually have no other choice. ) 543cdf0e10cSrcweir // if ( bDeletePhysical ) 544cdf0e10cSrcweir // { 545cdf0e10cSrcweir try 546cdf0e10cSrcweir { 547cdf0e10cSrcweir std::auto_ptr< DAVResourceAccess > xResAccess; 548cdf0e10cSrcweir { 549cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 550cdf0e10cSrcweir xResAccess.reset( new DAVResourceAccess( *m_xResAccess.get() ) ); 551cdf0e10cSrcweir } 552cdf0e10cSrcweir xResAccess->DESTROY( Environment ); 553cdf0e10cSrcweir { 554cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 555cdf0e10cSrcweir m_xResAccess.reset( new DAVResourceAccess( *xResAccess.get() ) ); 556cdf0e10cSrcweir } 557cdf0e10cSrcweir } 558cdf0e10cSrcweir catch ( DAVException const & e ) 559cdf0e10cSrcweir { 560cdf0e10cSrcweir cancelCommandExecution( e, Environment, sal_True ); 561cdf0e10cSrcweir // Unreachable 562cdf0e10cSrcweir } 563cdf0e10cSrcweir // } 564cdf0e10cSrcweir 565cdf0e10cSrcweir // Propagate destruction. 566cdf0e10cSrcweir destroy( bDeletePhysical ); 567cdf0e10cSrcweir 568cdf0e10cSrcweir // Remove own and all children's Additional Core Properties. 569cdf0e10cSrcweir removeAdditionalPropertySet( sal_True ); 570cdf0e10cSrcweir } 571cdf0e10cSrcweir else if ( aCommand.Name.equalsAsciiL( 572cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "transfer" ) ) 573cdf0e10cSrcweir && isFolder( Environment ) ) 574cdf0e10cSrcweir { 575cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 576cdf0e10cSrcweir // transfer 577cdf0e10cSrcweir // ( Not available at documents ) 578cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 579cdf0e10cSrcweir 580cdf0e10cSrcweir ucb::TransferInfo transferArgs; 581cdf0e10cSrcweir if ( !( aCommand.Argument >>= transferArgs ) ) 582cdf0e10cSrcweir { 583cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 584cdf0e10cSrcweir uno::makeAny( lang::IllegalArgumentException( 585cdf0e10cSrcweir rtl::OUString::createFromAscii( 586cdf0e10cSrcweir "Wrong argument type!" ), 587cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 588cdf0e10cSrcweir -1 ) ), 589cdf0e10cSrcweir Environment ); 590cdf0e10cSrcweir // Unreachable 591cdf0e10cSrcweir } 592cdf0e10cSrcweir 593cdf0e10cSrcweir transfer( transferArgs, Environment ); 594cdf0e10cSrcweir } 595cdf0e10cSrcweir else if ( aCommand.Name.equalsAsciiL( 596cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "post" ) ) ) 597cdf0e10cSrcweir { 598cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 599cdf0e10cSrcweir // post 600cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 601cdf0e10cSrcweir 602cdf0e10cSrcweir ucb::PostCommandArgument2 aArg; 603cdf0e10cSrcweir if ( !( aCommand.Argument >>= aArg ) ) 604cdf0e10cSrcweir { 605cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 606cdf0e10cSrcweir uno::makeAny( lang::IllegalArgumentException( 607cdf0e10cSrcweir rtl::OUString::createFromAscii( 608cdf0e10cSrcweir "Wrong argument type!" ), 609cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 610cdf0e10cSrcweir -1 ) ), 611cdf0e10cSrcweir Environment ); 612cdf0e10cSrcweir // Unreachable 613cdf0e10cSrcweir } 614cdf0e10cSrcweir 615cdf0e10cSrcweir post( aArg, Environment ); 616cdf0e10cSrcweir } 617cdf0e10cSrcweir else if ( aCommand.Name.equalsAsciiL( 618cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "lock" ) ) && 619cdf0e10cSrcweir supportsExclusiveWriteLock( Environment ) ) 620cdf0e10cSrcweir { 621cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 622cdf0e10cSrcweir // lock 623cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 624cdf0e10cSrcweir 625cdf0e10cSrcweir lock( Environment ); 626cdf0e10cSrcweir } 627cdf0e10cSrcweir else if ( aCommand.Name.equalsAsciiL( 628cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "unlock" ) ) && 629cdf0e10cSrcweir supportsExclusiveWriteLock( Environment ) ) 630cdf0e10cSrcweir { 631cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 632cdf0e10cSrcweir // unlock 633cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 634cdf0e10cSrcweir 635cdf0e10cSrcweir unlock( Environment ); 636cdf0e10cSrcweir } 637cdf0e10cSrcweir else if ( aCommand.Name.equalsAsciiL( 638cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "createNewContent" ) ) && 639cdf0e10cSrcweir isFolder( Environment ) ) 640cdf0e10cSrcweir { 641cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 642cdf0e10cSrcweir // createNewContent 643cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 644cdf0e10cSrcweir 645cdf0e10cSrcweir ucb::ContentInfo aArg; 646cdf0e10cSrcweir if ( !( aCommand.Argument >>= aArg ) ) 647cdf0e10cSrcweir { 648cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 649cdf0e10cSrcweir uno::makeAny( lang::IllegalArgumentException( 650cdf0e10cSrcweir rtl::OUString::createFromAscii( 651cdf0e10cSrcweir "Wrong argument type!" ), 652cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 653cdf0e10cSrcweir -1 ) ), 654cdf0e10cSrcweir Environment ); 655cdf0e10cSrcweir // Unreachable 656cdf0e10cSrcweir } 657cdf0e10cSrcweir 658cdf0e10cSrcweir aRet = uno::makeAny( createNewContent( aArg ) ); 659cdf0e10cSrcweir } 660cdf0e10cSrcweir else 661cdf0e10cSrcweir { 662cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 663cdf0e10cSrcweir // Unsupported command 664cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 665cdf0e10cSrcweir 666cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 667cdf0e10cSrcweir uno::makeAny( ucb::UnsupportedCommandException( 668cdf0e10cSrcweir aCommand.Name, 669cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ) ), 670cdf0e10cSrcweir Environment ); 671cdf0e10cSrcweir // Unreachable 672cdf0e10cSrcweir } 673cdf0e10cSrcweir 674cdf0e10cSrcweir OSL_TRACE( "<<<<< Content::execute: end: command: %s", 675cdf0e10cSrcweir rtl::OUStringToOString( aCommand.Name, 676cdf0e10cSrcweir RTL_TEXTENCODING_UTF8 ).getStr() ); 677cdf0e10cSrcweir 678cdf0e10cSrcweir return aRet; 679cdf0e10cSrcweir } 680cdf0e10cSrcweir 681cdf0e10cSrcweir //========================================================================= 682cdf0e10cSrcweir // virtual 683cdf0e10cSrcweir void SAL_CALL Content::abort( sal_Int32 /*CommandId*/ ) 684cdf0e10cSrcweir throw( uno::RuntimeException ) 685cdf0e10cSrcweir { 686cdf0e10cSrcweir try 687cdf0e10cSrcweir { 688cdf0e10cSrcweir std::auto_ptr< DAVResourceAccess > xResAccess; 689cdf0e10cSrcweir { 690cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 691cdf0e10cSrcweir xResAccess.reset( new DAVResourceAccess( *m_xResAccess.get() ) ); 692cdf0e10cSrcweir } 693cdf0e10cSrcweir xResAccess->abort(); 694cdf0e10cSrcweir { 695cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 696cdf0e10cSrcweir m_xResAccess.reset( new DAVResourceAccess( *xResAccess.get() ) ); 697cdf0e10cSrcweir } 698cdf0e10cSrcweir } 699cdf0e10cSrcweir catch ( DAVException const & ) 700cdf0e10cSrcweir { 701cdf0e10cSrcweir // abort failed! 702cdf0e10cSrcweir } 703cdf0e10cSrcweir } 704cdf0e10cSrcweir 705cdf0e10cSrcweir //========================================================================= 706cdf0e10cSrcweir // 707cdf0e10cSrcweir // XPropertyContainer methods. 708cdf0e10cSrcweir // 709cdf0e10cSrcweir //========================================================================= 710cdf0e10cSrcweir 711cdf0e10cSrcweir // virtual 712cdf0e10cSrcweir void SAL_CALL Content::addProperty( const rtl::OUString& Name, 713cdf0e10cSrcweir sal_Int16 Attributes, 714cdf0e10cSrcweir const uno::Any& DefaultValue ) 715cdf0e10cSrcweir throw( beans::PropertyExistException, 716cdf0e10cSrcweir beans::IllegalTypeException, 717cdf0e10cSrcweir lang::IllegalArgumentException, 718cdf0e10cSrcweir uno::RuntimeException ) 719cdf0e10cSrcweir { 720cdf0e10cSrcweir // if ( m_bTransient ) 721cdf0e10cSrcweir // @@@ ??? 722cdf0e10cSrcweir 723cdf0e10cSrcweir if ( !Name.getLength() ) 724cdf0e10cSrcweir throw lang::IllegalArgumentException(); 725cdf0e10cSrcweir 726cdf0e10cSrcweir // Check property type. 727cdf0e10cSrcweir if ( !UCBDeadPropertyValue::supportsType( DefaultValue.getValueType() ) ) 728cdf0e10cSrcweir { 729cdf0e10cSrcweir OSL_ENSURE( sal_False, 730cdf0e10cSrcweir "Content::addProperty - Unsupported property type!" ); 731cdf0e10cSrcweir throw beans::IllegalTypeException(); 732cdf0e10cSrcweir } 733cdf0e10cSrcweir 734cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 735cdf0e10cSrcweir // Make sure a property with the requested name does not already 736cdf0e10cSrcweir // exist in dynamic and static(!) properties. 737cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 738cdf0e10cSrcweir 739cdf0e10cSrcweir // @@@ Need real command environment here, but where to get it from? 740cdf0e10cSrcweir // XPropertyContainer interface should be replaced by 741cdf0e10cSrcweir // XCommandProcessor commands! 742cdf0e10cSrcweir uno::Reference< ucb::XCommandEnvironment > xEnv; 743cdf0e10cSrcweir 744cdf0e10cSrcweir // Note: This requires network access! 745cdf0e10cSrcweir if ( getPropertySetInfo( xEnv, sal_False /* don't cache data */ ) 746cdf0e10cSrcweir ->hasPropertyByName( Name ) ) 747cdf0e10cSrcweir { 748cdf0e10cSrcweir // Property does already exist. 749cdf0e10cSrcweir throw beans::PropertyExistException(); 750cdf0e10cSrcweir } 751cdf0e10cSrcweir 752cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 753cdf0e10cSrcweir // Add a new dynamic property. 754cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 755cdf0e10cSrcweir 756cdf0e10cSrcweir ProppatchValue aValue( PROPSET, Name, DefaultValue ); 757cdf0e10cSrcweir 758cdf0e10cSrcweir std::vector< ProppatchValue > aProppatchValues; 759cdf0e10cSrcweir aProppatchValues.push_back( aValue ); 760cdf0e10cSrcweir 761cdf0e10cSrcweir try 762cdf0e10cSrcweir { 763cdf0e10cSrcweir // Set property value at server. 764cdf0e10cSrcweir std::auto_ptr< DAVResourceAccess > xResAccess; 765cdf0e10cSrcweir { 766cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 767cdf0e10cSrcweir xResAccess.reset( new DAVResourceAccess( *m_xResAccess.get() ) ); 768cdf0e10cSrcweir } 769cdf0e10cSrcweir xResAccess->PROPPATCH( aProppatchValues, xEnv ); 770cdf0e10cSrcweir { 771cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 772cdf0e10cSrcweir m_xResAccess.reset( new DAVResourceAccess( *xResAccess.get() ) ); 773cdf0e10cSrcweir } 774cdf0e10cSrcweir 775cdf0e10cSrcweir // Notify propertyset info change listeners. 776cdf0e10cSrcweir beans::PropertySetInfoChangeEvent evt( 777cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 778cdf0e10cSrcweir Name, 779cdf0e10cSrcweir -1, // No handle available 780cdf0e10cSrcweir beans::PropertySetInfoChange::PROPERTY_INSERTED ); 781cdf0e10cSrcweir notifyPropertySetInfoChange( evt ); 782cdf0e10cSrcweir } 783cdf0e10cSrcweir catch ( DAVException const & e ) 784cdf0e10cSrcweir { 785cdf0e10cSrcweir if ( e.getStatus() == SC_FORBIDDEN ) 786cdf0e10cSrcweir { 787cdf0e10cSrcweir // Support for setting arbitrary dead properties is optional! 788cdf0e10cSrcweir 789cdf0e10cSrcweir // Store property locally. 790cdf0e10cSrcweir ContentImplHelper::addProperty( 791cdf0e10cSrcweir Name, Attributes, DefaultValue ); 792cdf0e10cSrcweir } 793cdf0e10cSrcweir else 794cdf0e10cSrcweir { 795cdf0e10cSrcweir if ( shouldAccessNetworkAfterException( e ) ) 796cdf0e10cSrcweir { 797cdf0e10cSrcweir try 798cdf0e10cSrcweir { 799cdf0e10cSrcweir const ResourceType & rType = getResourceType( xEnv ); 800cdf0e10cSrcweir switch ( rType ) 801cdf0e10cSrcweir { 802cdf0e10cSrcweir case UNKNOWN: 803cdf0e10cSrcweir case DAV: 804cdf0e10cSrcweir throw lang::IllegalArgumentException(); 805cdf0e10cSrcweir 806cdf0e10cSrcweir case NON_DAV: 807cdf0e10cSrcweir // Store property locally. 808cdf0e10cSrcweir ContentImplHelper::addProperty( Name, 809cdf0e10cSrcweir Attributes, 810cdf0e10cSrcweir DefaultValue ); 811cdf0e10cSrcweir break; 812cdf0e10cSrcweir 813cdf0e10cSrcweir default: 814cdf0e10cSrcweir OSL_ENSURE( sal_False, 815cdf0e10cSrcweir "Content::addProperty - " 816cdf0e10cSrcweir "Unsupported resource type!" ); 817cdf0e10cSrcweir break; 818cdf0e10cSrcweir } 819cdf0e10cSrcweir } 820cdf0e10cSrcweir catch ( uno::Exception const & ) 821cdf0e10cSrcweir { 822cdf0e10cSrcweir OSL_ENSURE( sal_False, 823cdf0e10cSrcweir "Content::addProperty - " 824cdf0e10cSrcweir "Unable to determine resource type!" ); 825cdf0e10cSrcweir } 826cdf0e10cSrcweir } 827cdf0e10cSrcweir else 828cdf0e10cSrcweir { 829cdf0e10cSrcweir OSL_ENSURE( sal_False, 830cdf0e10cSrcweir "Content::addProperty - " 831cdf0e10cSrcweir "Unable to determine resource type!" ); 832cdf0e10cSrcweir } 833cdf0e10cSrcweir } 834cdf0e10cSrcweir } 835cdf0e10cSrcweir } 836cdf0e10cSrcweir 837cdf0e10cSrcweir //========================================================================= 838cdf0e10cSrcweir // virtual 839cdf0e10cSrcweir void SAL_CALL Content::removeProperty( const rtl::OUString& Name ) 840cdf0e10cSrcweir throw( beans::UnknownPropertyException, 841cdf0e10cSrcweir beans::NotRemoveableException, 842cdf0e10cSrcweir uno::RuntimeException ) 843cdf0e10cSrcweir { 844cdf0e10cSrcweir // @@@ Need real command environment here, but where to get it from? 845cdf0e10cSrcweir // XPropertyContainer interface should be replaced by 846cdf0e10cSrcweir // XCommandProcessor commands! 847cdf0e10cSrcweir uno::Reference< ucb::XCommandEnvironment > xEnv; 848cdf0e10cSrcweir 849cdf0e10cSrcweir #if 0 850cdf0e10cSrcweir // @@@ REMOVEABLE z.Z. nicht richtig an der PropSetInfo gesetzt!!! 851cdf0e10cSrcweir try 852cdf0e10cSrcweir { 853cdf0e10cSrcweir beans::Property aProp 854cdf0e10cSrcweir = getPropertySetInfo( xEnv, sal_False /* don't cache data */ ) 855cdf0e10cSrcweir ->getPropertyByName( Name ); 856cdf0e10cSrcweir 857cdf0e10cSrcweir if ( !( aProp.Attributes & beans::PropertyAttribute::REMOVEABLE ) ) 858cdf0e10cSrcweir { 859cdf0e10cSrcweir // Not removeable! 860cdf0e10cSrcweir throw beans::NotRemoveableException(); 861cdf0e10cSrcweir } 862cdf0e10cSrcweir } 863cdf0e10cSrcweir catch ( beans::UnknownPropertyException const & ) 864cdf0e10cSrcweir { 865cdf0e10cSrcweir //OSL_ENSURE( sal_False, "removeProperty - Unknown property!" ); 866cdf0e10cSrcweir throw; 867cdf0e10cSrcweir } 868cdf0e10cSrcweir #endif 869cdf0e10cSrcweir 870cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 871cdf0e10cSrcweir // Try to remove property from server. 872cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 873cdf0e10cSrcweir 874cdf0e10cSrcweir try 875cdf0e10cSrcweir { 876cdf0e10cSrcweir std::vector< ProppatchValue > aProppatchValues; 877cdf0e10cSrcweir ProppatchValue aValue( PROPREMOVE, Name, uno::Any() ); 878cdf0e10cSrcweir aProppatchValues.push_back( aValue ); 879cdf0e10cSrcweir 880cdf0e10cSrcweir // Remove property value from server. 881cdf0e10cSrcweir std::auto_ptr< DAVResourceAccess > xResAccess; 882cdf0e10cSrcweir { 883cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 884cdf0e10cSrcweir xResAccess.reset( new DAVResourceAccess( *m_xResAccess.get() ) ); 885cdf0e10cSrcweir } 886cdf0e10cSrcweir xResAccess->PROPPATCH( aProppatchValues, xEnv ); 887cdf0e10cSrcweir { 888cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 889cdf0e10cSrcweir m_xResAccess.reset( new DAVResourceAccess( *xResAccess.get() ) ); 890cdf0e10cSrcweir } 891cdf0e10cSrcweir 892cdf0e10cSrcweir // Notify propertyset info change listeners. 893cdf0e10cSrcweir beans::PropertySetInfoChangeEvent evt( 894cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 895cdf0e10cSrcweir Name, 896cdf0e10cSrcweir -1, // No handle available 897cdf0e10cSrcweir beans::PropertySetInfoChange::PROPERTY_REMOVED ); 898cdf0e10cSrcweir notifyPropertySetInfoChange( evt ); 899cdf0e10cSrcweir } 900cdf0e10cSrcweir catch ( DAVException const & e ) 901cdf0e10cSrcweir { 902cdf0e10cSrcweir if ( e.getStatus() == SC_FORBIDDEN ) 903cdf0e10cSrcweir { 904cdf0e10cSrcweir // Support for setting arbitrary dead properties is optional! 905cdf0e10cSrcweir 906cdf0e10cSrcweir // Try to remove property from local store. 907cdf0e10cSrcweir ContentImplHelper::removeProperty( Name ); 908cdf0e10cSrcweir } 909cdf0e10cSrcweir else 910cdf0e10cSrcweir { 911cdf0e10cSrcweir if ( shouldAccessNetworkAfterException( e ) ) 912cdf0e10cSrcweir { 913cdf0e10cSrcweir try 914cdf0e10cSrcweir { 915cdf0e10cSrcweir const ResourceType & rType = getResourceType( xEnv ); 916cdf0e10cSrcweir switch ( rType ) 917cdf0e10cSrcweir { 918cdf0e10cSrcweir case UNKNOWN: 919cdf0e10cSrcweir case DAV: 920cdf0e10cSrcweir throw beans::UnknownPropertyException(); 921cdf0e10cSrcweir 922cdf0e10cSrcweir case NON_DAV: 923cdf0e10cSrcweir // Try to remove property from local store. 924cdf0e10cSrcweir ContentImplHelper::removeProperty( Name ); 925cdf0e10cSrcweir break; 926cdf0e10cSrcweir 927cdf0e10cSrcweir default: 928cdf0e10cSrcweir OSL_ENSURE( sal_False, 929cdf0e10cSrcweir "Content::removeProperty - " 930cdf0e10cSrcweir "Unsupported resource type!" ); 931cdf0e10cSrcweir break; 932cdf0e10cSrcweir } 933cdf0e10cSrcweir } 934cdf0e10cSrcweir catch ( uno::Exception const & ) 935cdf0e10cSrcweir { 936cdf0e10cSrcweir OSL_ENSURE( sal_False, 937cdf0e10cSrcweir "Content::removeProperty - " 938cdf0e10cSrcweir "Unable to determine resource type!" ); 939cdf0e10cSrcweir } 940cdf0e10cSrcweir } 941cdf0e10cSrcweir else 942cdf0e10cSrcweir { 943cdf0e10cSrcweir OSL_ENSURE( sal_False, 944cdf0e10cSrcweir "Content::removeProperty - " 945cdf0e10cSrcweir "Unable to determine resource type!" ); 946cdf0e10cSrcweir // throw beans::UnknownPropertyException(); 947cdf0e10cSrcweir } 948cdf0e10cSrcweir } 949cdf0e10cSrcweir } 950cdf0e10cSrcweir } 951cdf0e10cSrcweir 952cdf0e10cSrcweir //========================================================================= 953cdf0e10cSrcweir // 954cdf0e10cSrcweir // XContentCreator methods. 955cdf0e10cSrcweir // 956cdf0e10cSrcweir //========================================================================= 957cdf0e10cSrcweir 958cdf0e10cSrcweir // virtual 959cdf0e10cSrcweir uno::Sequence< ucb::ContentInfo > SAL_CALL 960cdf0e10cSrcweir Content::queryCreatableContentsInfo() 961cdf0e10cSrcweir throw( uno::RuntimeException ) 962cdf0e10cSrcweir { 963cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 964cdf0e10cSrcweir 965cdf0e10cSrcweir uno::Sequence< ucb::ContentInfo > aSeq( 2 ); 966cdf0e10cSrcweir 967cdf0e10cSrcweir // document. 968cdf0e10cSrcweir aSeq.getArray()[ 0 ].Type 969cdf0e10cSrcweir = rtl::OUString::createFromAscii( WEBDAV_CONTENT_TYPE ); 970cdf0e10cSrcweir aSeq.getArray()[ 0 ].Attributes 971cdf0e10cSrcweir = ucb::ContentInfoAttribute::INSERT_WITH_INPUTSTREAM 972cdf0e10cSrcweir | ucb::ContentInfoAttribute::KIND_DOCUMENT; 973cdf0e10cSrcweir 974cdf0e10cSrcweir beans::Property aProp; 975cdf0e10cSrcweir m_pProvider->getProperty( 976cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ), aProp ); 977cdf0e10cSrcweir 978cdf0e10cSrcweir uno::Sequence< beans::Property > aDocProps( 1 ); 979cdf0e10cSrcweir aDocProps.getArray()[ 0 ] = aProp; 980cdf0e10cSrcweir aSeq.getArray()[ 0 ].Properties = aDocProps; 981cdf0e10cSrcweir 982cdf0e10cSrcweir // folder. 983cdf0e10cSrcweir aSeq.getArray()[ 1 ].Type 984cdf0e10cSrcweir = rtl::OUString::createFromAscii( WEBDAV_COLLECTION_TYPE ); 985cdf0e10cSrcweir aSeq.getArray()[ 1 ].Attributes 986cdf0e10cSrcweir = ucb::ContentInfoAttribute::KIND_FOLDER; 987cdf0e10cSrcweir 988cdf0e10cSrcweir uno::Sequence< beans::Property > aFolderProps( 1 ); 989cdf0e10cSrcweir aFolderProps.getArray()[ 0 ] = aProp; 990cdf0e10cSrcweir aSeq.getArray()[ 1 ].Properties = aFolderProps; 991cdf0e10cSrcweir return aSeq; 992cdf0e10cSrcweir } 993cdf0e10cSrcweir 994cdf0e10cSrcweir //========================================================================= 995cdf0e10cSrcweir // virtual 996cdf0e10cSrcweir uno::Reference< ucb::XContent > SAL_CALL 997cdf0e10cSrcweir Content::createNewContent( const ucb::ContentInfo& Info ) 998cdf0e10cSrcweir throw( uno::RuntimeException ) 999cdf0e10cSrcweir { 1000cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 1001cdf0e10cSrcweir 1002cdf0e10cSrcweir if ( !Info.Type.getLength() ) 1003cdf0e10cSrcweir return uno::Reference< ucb::XContent >(); 1004cdf0e10cSrcweir 1005cdf0e10cSrcweir if ( ( !Info.Type.equalsAsciiL( 1006cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( WEBDAV_COLLECTION_TYPE ) ) ) 1007cdf0e10cSrcweir && 1008cdf0e10cSrcweir ( !Info.Type.equalsAsciiL( 1009cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( WEBDAV_CONTENT_TYPE ) ) ) ) 1010cdf0e10cSrcweir return uno::Reference< ucb::XContent >(); 1011cdf0e10cSrcweir 1012cdf0e10cSrcweir rtl::OUString aURL = m_xIdentifier->getContentIdentifier(); 1013cdf0e10cSrcweir 1014cdf0e10cSrcweir OSL_ENSURE( aURL.getLength() > 0, 1015cdf0e10cSrcweir "WebdavContent::createNewContent - empty identifier!" ); 1016cdf0e10cSrcweir 1017cdf0e10cSrcweir if ( ( aURL.lastIndexOf( '/' ) + 1 ) != aURL.getLength() ) 1018cdf0e10cSrcweir aURL += rtl::OUString::createFromAscii( "/" ); 1019cdf0e10cSrcweir 1020cdf0e10cSrcweir sal_Bool isCollection; 1021cdf0e10cSrcweir if ( Info.Type.equalsAsciiL( 1022cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( WEBDAV_COLLECTION_TYPE ) ) ) 1023cdf0e10cSrcweir { 1024cdf0e10cSrcweir aURL += rtl::OUString::createFromAscii( "New_Collection" ); 1025cdf0e10cSrcweir isCollection = sal_True; 1026cdf0e10cSrcweir } 1027cdf0e10cSrcweir else 1028cdf0e10cSrcweir { 1029cdf0e10cSrcweir aURL += rtl::OUString::createFromAscii( "New_Content" ); 1030cdf0e10cSrcweir isCollection = sal_False; 1031cdf0e10cSrcweir } 1032cdf0e10cSrcweir 1033cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier > xId( 1034cdf0e10cSrcweir new ::ucbhelper::ContentIdentifier( m_xSMgr, aURL ) ); 1035cdf0e10cSrcweir 1036cdf0e10cSrcweir // create the local content 1037cdf0e10cSrcweir try 1038cdf0e10cSrcweir { 1039*59ddfc10SAndre Fischer return new ::http_dav_ucp::Content( m_xSMgr, 1040cdf0e10cSrcweir m_pProvider, 1041cdf0e10cSrcweir xId, 1042cdf0e10cSrcweir m_xResAccess->getSessionFactory(), 1043cdf0e10cSrcweir isCollection ); 1044cdf0e10cSrcweir } 1045cdf0e10cSrcweir catch ( ucb::ContentCreationException & ) 1046cdf0e10cSrcweir { 1047cdf0e10cSrcweir return uno::Reference< ucb::XContent >(); 1048cdf0e10cSrcweir } 1049cdf0e10cSrcweir } 1050cdf0e10cSrcweir 1051cdf0e10cSrcweir //========================================================================= 1052cdf0e10cSrcweir // virtual 1053cdf0e10cSrcweir rtl::OUString Content::getParentURL() 1054cdf0e10cSrcweir { 1055cdf0e10cSrcweir // <scheme>:// -> "" 1056cdf0e10cSrcweir // <scheme>://foo -> "" 1057cdf0e10cSrcweir // <scheme>://foo/ -> "" 1058cdf0e10cSrcweir // <scheme>://foo/bar -> <scheme>://foo/ 1059cdf0e10cSrcweir // <scheme>://foo/bar/ -> <scheme>://foo/ 1060cdf0e10cSrcweir // <scheme>://foo/bar/abc -> <scheme>://foo/bar/ 1061cdf0e10cSrcweir 1062cdf0e10cSrcweir rtl::OUString aURL = m_xIdentifier->getContentIdentifier(); 1063cdf0e10cSrcweir 1064cdf0e10cSrcweir sal_Int32 nPos = aURL.lastIndexOf( '/' ); 1065cdf0e10cSrcweir if ( nPos == ( aURL.getLength() - 1 ) ) 1066cdf0e10cSrcweir { 1067cdf0e10cSrcweir // Trailing slash found. Skip. 1068cdf0e10cSrcweir nPos = aURL.lastIndexOf( '/', nPos ); 1069cdf0e10cSrcweir } 1070cdf0e10cSrcweir 1071cdf0e10cSrcweir sal_Int32 nPos1 = aURL.lastIndexOf( '/', nPos ); 1072cdf0e10cSrcweir if ( nPos1 != -1 ) 1073cdf0e10cSrcweir nPos1 = aURL.lastIndexOf( '/', nPos1 ); 1074cdf0e10cSrcweir 1075cdf0e10cSrcweir if ( nPos1 == -1 ) 1076cdf0e10cSrcweir return rtl::OUString(); 1077cdf0e10cSrcweir 1078cdf0e10cSrcweir return rtl::OUString( aURL.copy( 0, nPos + 1 ) ); 1079cdf0e10cSrcweir } 1080cdf0e10cSrcweir 1081cdf0e10cSrcweir //========================================================================= 1082cdf0e10cSrcweir // 1083cdf0e10cSrcweir // Non-interface methods. 1084cdf0e10cSrcweir // 1085cdf0e10cSrcweir //========================================================================= 1086cdf0e10cSrcweir 1087cdf0e10cSrcweir // static 1088cdf0e10cSrcweir uno::Reference< sdbc::XRow > Content::getPropertyValues( 1089cdf0e10cSrcweir const uno::Reference< lang::XMultiServiceFactory >& rSMgr, 1090cdf0e10cSrcweir const uno::Sequence< beans::Property >& rProperties, 1091cdf0e10cSrcweir const ContentProperties& rData, 1092cdf0e10cSrcweir const rtl::Reference< ::ucbhelper::ContentProviderImplHelper >& rProvider, 1093cdf0e10cSrcweir const rtl::OUString& rContentId ) 1094cdf0e10cSrcweir { 1095cdf0e10cSrcweir // Note: Empty sequence means "get values of all supported properties". 1096cdf0e10cSrcweir 1097cdf0e10cSrcweir rtl::Reference< ::ucbhelper::PropertyValueSet > xRow 1098cdf0e10cSrcweir = new ::ucbhelper::PropertyValueSet( rSMgr ); 1099cdf0e10cSrcweir 1100cdf0e10cSrcweir sal_Int32 nCount = rProperties.getLength(); 1101cdf0e10cSrcweir if ( nCount ) 1102cdf0e10cSrcweir { 1103cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xAdditionalPropSet; 1104cdf0e10cSrcweir sal_Bool bTriedToGetAdditonalPropSet = sal_False; 1105cdf0e10cSrcweir 1106cdf0e10cSrcweir const beans::Property* pProps = rProperties.getConstArray(); 1107cdf0e10cSrcweir for ( sal_Int32 n = 0; n < nCount; ++n ) 1108cdf0e10cSrcweir { 1109cdf0e10cSrcweir const beans::Property& rProp = pProps[ n ]; 1110cdf0e10cSrcweir 1111cdf0e10cSrcweir // Process standard UCB, DAV and HTTP properties. 1112cdf0e10cSrcweir const uno::Any & rValue = rData.getValue( rProp.Name ); 1113cdf0e10cSrcweir if ( rValue.hasValue() ) 1114cdf0e10cSrcweir { 1115cdf0e10cSrcweir xRow->appendObject( rProp, rValue ); 1116cdf0e10cSrcweir } 1117cdf0e10cSrcweir else 1118cdf0e10cSrcweir { 1119cdf0e10cSrcweir // Process local Additional Properties. 1120cdf0e10cSrcweir if ( !bTriedToGetAdditonalPropSet && !xAdditionalPropSet.is() ) 1121cdf0e10cSrcweir { 1122cdf0e10cSrcweir xAdditionalPropSet 1123cdf0e10cSrcweir = uno::Reference< beans::XPropertySet >( 1124cdf0e10cSrcweir rProvider->getAdditionalPropertySet( rContentId, 1125cdf0e10cSrcweir sal_False ), 1126cdf0e10cSrcweir uno::UNO_QUERY ); 1127cdf0e10cSrcweir bTriedToGetAdditonalPropSet = sal_True; 1128cdf0e10cSrcweir } 1129cdf0e10cSrcweir 1130cdf0e10cSrcweir if ( !xAdditionalPropSet.is() || 1131cdf0e10cSrcweir !xRow->appendPropertySetValue( 1132cdf0e10cSrcweir xAdditionalPropSet, rProp ) ) 1133cdf0e10cSrcweir { 1134cdf0e10cSrcweir // Append empty entry. 1135cdf0e10cSrcweir xRow->appendVoid( rProp ); 1136cdf0e10cSrcweir } 1137cdf0e10cSrcweir } 1138cdf0e10cSrcweir } 1139cdf0e10cSrcweir } 1140cdf0e10cSrcweir else 1141cdf0e10cSrcweir { 1142cdf0e10cSrcweir // Append all standard UCB, DAV and HTTP properties. 1143cdf0e10cSrcweir 1144cdf0e10cSrcweir const std::auto_ptr< PropertyValueMap > & xProps = rData.getProperties(); 1145cdf0e10cSrcweir 1146cdf0e10cSrcweir PropertyValueMap::const_iterator it = xProps->begin(); 1147cdf0e10cSrcweir PropertyValueMap::const_iterator end = xProps->end(); 1148cdf0e10cSrcweir 1149cdf0e10cSrcweir ContentProvider * pProvider 1150cdf0e10cSrcweir = static_cast< ContentProvider * >( rProvider.get() ); 1151cdf0e10cSrcweir beans::Property aProp; 1152cdf0e10cSrcweir 1153cdf0e10cSrcweir while ( it != end ) 1154cdf0e10cSrcweir { 1155cdf0e10cSrcweir if ( pProvider->getProperty( (*it).first, aProp ) ) 1156cdf0e10cSrcweir xRow->appendObject( aProp, (*it).second.value() ); 1157cdf0e10cSrcweir 1158cdf0e10cSrcweir ++it; 1159cdf0e10cSrcweir } 1160cdf0e10cSrcweir 1161cdf0e10cSrcweir // Append all local Additional Properties. 1162cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xSet( 1163cdf0e10cSrcweir rProvider->getAdditionalPropertySet( rContentId, sal_False ), 1164cdf0e10cSrcweir uno::UNO_QUERY ); 1165cdf0e10cSrcweir xRow->appendPropertySet( xSet ); 1166cdf0e10cSrcweir } 1167cdf0e10cSrcweir 1168cdf0e10cSrcweir return uno::Reference< sdbc::XRow >( xRow.get() ); 1169cdf0e10cSrcweir } 1170cdf0e10cSrcweir 1171cdf0e10cSrcweir //========================================================================= 1172cdf0e10cSrcweir uno::Reference< sdbc::XRow > Content::getPropertyValues( 1173cdf0e10cSrcweir const uno::Sequence< beans::Property >& rProperties, 1174cdf0e10cSrcweir const uno::Reference< ucb::XCommandEnvironment >& xEnv ) 1175cdf0e10cSrcweir throw ( uno::Exception ) 1176cdf0e10cSrcweir { 1177cdf0e10cSrcweir std::auto_ptr< ContentProperties > xProps; 1178cdf0e10cSrcweir std::auto_ptr< ContentProperties > xCachedProps; 1179cdf0e10cSrcweir std::auto_ptr< DAVResourceAccess > xResAccess; 1180cdf0e10cSrcweir rtl::OUString aUnescapedTitle; 1181cdf0e10cSrcweir bool bHasAll = false; 1182cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xSMgr; 1183cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier > xIdentifier; 1184cdf0e10cSrcweir rtl::Reference< ::ucbhelper::ContentProviderImplHelper > xProvider; 1185cdf0e10cSrcweir 1186cdf0e10cSrcweir { 1187cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 1188cdf0e10cSrcweir 1189*59ddfc10SAndre Fischer aUnescapedTitle = SerfUri::unescape( m_aEscapedTitle ); 1190cdf0e10cSrcweir xSMgr.set( m_xSMgr ); 1191cdf0e10cSrcweir xIdentifier.set( m_xIdentifier ); 1192cdf0e10cSrcweir xProvider.set( m_xProvider.get() ); 1193cdf0e10cSrcweir xResAccess.reset( new DAVResourceAccess( *m_xResAccess.get() ) ); 1194cdf0e10cSrcweir 1195cdf0e10cSrcweir // First, ask cache... 1196cdf0e10cSrcweir if ( m_xCachedProps.get() ) 1197cdf0e10cSrcweir { 1198cdf0e10cSrcweir xCachedProps.reset( new ContentProperties( *m_xCachedProps.get() ) ); 1199cdf0e10cSrcweir 1200cdf0e10cSrcweir std::vector< rtl::OUString > aMissingProps; 1201cdf0e10cSrcweir if ( xCachedProps->containsAllNames( rProperties, aMissingProps ) ) 1202cdf0e10cSrcweir { 1203cdf0e10cSrcweir // All properties are already in cache! No server access needed. 1204cdf0e10cSrcweir bHasAll = true; 1205cdf0e10cSrcweir } 1206cdf0e10cSrcweir 1207cdf0e10cSrcweir // use the cached ContentProperties instance 1208cdf0e10cSrcweir xProps.reset( new ContentProperties( *xCachedProps.get() ) ); 1209cdf0e10cSrcweir } 1210cdf0e10cSrcweir } 1211cdf0e10cSrcweir 1212cdf0e10cSrcweir if ( !m_bTransient && !bHasAll ) 1213cdf0e10cSrcweir { 1214cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////// 1215cdf0e10cSrcweir // Obtain values from server... 1216cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////// 1217cdf0e10cSrcweir 1218cdf0e10cSrcweir // First, identify whether resource is DAV or not 1219cdf0e10cSrcweir const ResourceType & rType = getResourceType( xEnv, xResAccess ); 1220cdf0e10cSrcweir 1221cdf0e10cSrcweir bool bNetworkAccessAllowed = true; 1222cdf0e10cSrcweir 1223cdf0e10cSrcweir if ( DAV == rType ) 1224cdf0e10cSrcweir { 1225cdf0e10cSrcweir // cache lookup... getResourceType may fill the props cache via 1226cdf0e10cSrcweir // PROPFIND! 1227cdf0e10cSrcweir if ( m_xCachedProps.get() ) 1228cdf0e10cSrcweir { 1229cdf0e10cSrcweir xCachedProps.reset( 1230cdf0e10cSrcweir new ContentProperties( *m_xCachedProps.get() ) ); 1231cdf0e10cSrcweir 1232cdf0e10cSrcweir std::vector< rtl::OUString > aMissingProps; 1233cdf0e10cSrcweir if ( xCachedProps->containsAllNames( 1234cdf0e10cSrcweir rProperties, aMissingProps ) ) 1235cdf0e10cSrcweir { 1236cdf0e10cSrcweir // All properties are already in cache! No server access 1237cdf0e10cSrcweir // needed. 1238cdf0e10cSrcweir bHasAll = true; 1239cdf0e10cSrcweir } 1240cdf0e10cSrcweir 1241cdf0e10cSrcweir // use the cached ContentProperties instance 1242cdf0e10cSrcweir xProps.reset( new ContentProperties( *xCachedProps.get() ) ); 1243cdf0e10cSrcweir } 1244cdf0e10cSrcweir 1245cdf0e10cSrcweir if ( !bHasAll ) 1246cdf0e10cSrcweir { 1247cdf0e10cSrcweir // Only DAV resources support PROPFIND 1248cdf0e10cSrcweir std::vector< rtl::OUString > aPropNames; 1249cdf0e10cSrcweir 1250cdf0e10cSrcweir uno::Sequence< beans::Property > aProperties( 1251cdf0e10cSrcweir rProperties.getLength() ); 1252cdf0e10cSrcweir 1253cdf0e10cSrcweir if ( m_aFailedPropNames.size() > 0 ) 1254cdf0e10cSrcweir { 1255cdf0e10cSrcweir sal_Int32 nProps = 0; 1256cdf0e10cSrcweir sal_Int32 nCount = rProperties.getLength(); 1257cdf0e10cSrcweir for ( sal_Int32 n = 0; n < nCount; ++n ) 1258cdf0e10cSrcweir { 1259cdf0e10cSrcweir const rtl::OUString & rName = rProperties[ n ].Name; 1260cdf0e10cSrcweir 1261cdf0e10cSrcweir std::vector< rtl::OUString >::const_iterator it 1262cdf0e10cSrcweir = m_aFailedPropNames.begin(); 1263cdf0e10cSrcweir std::vector< rtl::OUString >::const_iterator end 1264cdf0e10cSrcweir = m_aFailedPropNames.end(); 1265cdf0e10cSrcweir 1266cdf0e10cSrcweir while ( it != end ) 1267cdf0e10cSrcweir { 1268cdf0e10cSrcweir if ( *it == rName ) 1269cdf0e10cSrcweir break; 1270cdf0e10cSrcweir 1271cdf0e10cSrcweir ++it; 1272cdf0e10cSrcweir } 1273cdf0e10cSrcweir 1274cdf0e10cSrcweir if ( it == end ) 1275cdf0e10cSrcweir { 1276cdf0e10cSrcweir aProperties[ nProps ] = rProperties[ n ]; 1277cdf0e10cSrcweir nProps++; 1278cdf0e10cSrcweir } 1279cdf0e10cSrcweir } 1280cdf0e10cSrcweir 1281cdf0e10cSrcweir aProperties.realloc( nProps ); 1282cdf0e10cSrcweir } 1283cdf0e10cSrcweir else 1284cdf0e10cSrcweir { 1285cdf0e10cSrcweir aProperties = rProperties; 1286cdf0e10cSrcweir } 1287cdf0e10cSrcweir 1288cdf0e10cSrcweir if ( aProperties.getLength() > 0 ) 1289cdf0e10cSrcweir ContentProperties::UCBNamesToDAVNames( 1290cdf0e10cSrcweir aProperties, aPropNames ); 1291cdf0e10cSrcweir 1292cdf0e10cSrcweir if ( aPropNames.size() > 0 ) 1293cdf0e10cSrcweir { 1294cdf0e10cSrcweir std::vector< DAVResource > resources; 1295cdf0e10cSrcweir try 1296cdf0e10cSrcweir { 1297cdf0e10cSrcweir xResAccess->PROPFIND( 1298cdf0e10cSrcweir DAVZERO, aPropNames, resources, xEnv ); 1299cdf0e10cSrcweir 1300cdf0e10cSrcweir if ( 1 == resources.size() ) 1301cdf0e10cSrcweir { 1302cdf0e10cSrcweir if ( xProps.get()) 1303cdf0e10cSrcweir xProps->addProperties( 1304cdf0e10cSrcweir aPropNames, 1305cdf0e10cSrcweir ContentProperties( resources[ 0 ] )); 1306cdf0e10cSrcweir else 1307cdf0e10cSrcweir xProps.reset( 1308cdf0e10cSrcweir new ContentProperties( resources[ 0 ] ) ); 1309cdf0e10cSrcweir } 1310cdf0e10cSrcweir } 1311cdf0e10cSrcweir catch ( DAVException const & e ) 1312cdf0e10cSrcweir { 1313cdf0e10cSrcweir bNetworkAccessAllowed 1314cdf0e10cSrcweir = shouldAccessNetworkAfterException( e ); 1315cdf0e10cSrcweir 1316cdf0e10cSrcweir if ( !bNetworkAccessAllowed ) 1317cdf0e10cSrcweir { 1318cdf0e10cSrcweir cancelCommandExecution( e, xEnv ); 1319cdf0e10cSrcweir // unreachable 1320cdf0e10cSrcweir } 1321cdf0e10cSrcweir } 1322cdf0e10cSrcweir } 1323cdf0e10cSrcweir } 1324cdf0e10cSrcweir } 1325cdf0e10cSrcweir 1326cdf0e10cSrcweir if ( bNetworkAccessAllowed ) 1327cdf0e10cSrcweir { 1328cdf0e10cSrcweir // All properties obtained already? 1329cdf0e10cSrcweir std::vector< rtl::OUString > aMissingProps; 1330cdf0e10cSrcweir if ( !( xProps.get() 1331cdf0e10cSrcweir && xProps->containsAllNames( 1332cdf0e10cSrcweir rProperties, aMissingProps ) ) 1333cdf0e10cSrcweir && !m_bDidGetOrHead ) 1334cdf0e10cSrcweir { 1335cdf0e10cSrcweir // Possibly the missing props can be obtained using a HEAD 1336cdf0e10cSrcweir // request. 1337cdf0e10cSrcweir 1338cdf0e10cSrcweir std::vector< rtl::OUString > aHeaderNames; 1339cdf0e10cSrcweir ContentProperties::UCBNamesToHTTPNames( 1340cdf0e10cSrcweir rProperties, 1341cdf0e10cSrcweir aHeaderNames, 1342cdf0e10cSrcweir true /* bIncludeUnmatched */ ); 1343cdf0e10cSrcweir 1344cdf0e10cSrcweir if ( aHeaderNames.size() > 0 ) 1345cdf0e10cSrcweir { 1346cdf0e10cSrcweir try 1347cdf0e10cSrcweir { 1348cdf0e10cSrcweir DAVResource resource; 1349cdf0e10cSrcweir xResAccess->HEAD( aHeaderNames, resource, xEnv ); 1350cdf0e10cSrcweir m_bDidGetOrHead = true; 1351cdf0e10cSrcweir 1352cdf0e10cSrcweir if ( xProps.get() ) 1353cdf0e10cSrcweir xProps->addProperties( 1354cdf0e10cSrcweir aMissingProps, 1355cdf0e10cSrcweir ContentProperties( resource ) ); 1356cdf0e10cSrcweir else 1357cdf0e10cSrcweir xProps.reset ( new ContentProperties( resource ) ); 1358cdf0e10cSrcweir 1359cdf0e10cSrcweir if ( m_eResourceType == NON_DAV ) 1360cdf0e10cSrcweir xProps->addProperties( aMissingProps, 1361cdf0e10cSrcweir ContentProperties( 1362cdf0e10cSrcweir aUnescapedTitle, 1363cdf0e10cSrcweir false ) ); 1364cdf0e10cSrcweir } 1365cdf0e10cSrcweir catch ( DAVException const & e ) 1366cdf0e10cSrcweir { 1367cdf0e10cSrcweir bNetworkAccessAllowed 1368cdf0e10cSrcweir = shouldAccessNetworkAfterException( e ); 1369cdf0e10cSrcweir 1370cdf0e10cSrcweir if ( !bNetworkAccessAllowed ) 1371cdf0e10cSrcweir { 1372cdf0e10cSrcweir cancelCommandExecution( e, xEnv ); 1373cdf0e10cSrcweir // unreachable 1374cdf0e10cSrcweir } 1375cdf0e10cSrcweir } 1376cdf0e10cSrcweir } 1377cdf0e10cSrcweir } 1378cdf0e10cSrcweir } 1379cdf0e10cSrcweir 1380cdf0e10cSrcweir // might trigger HTTP redirect. 1381cdf0e10cSrcweir // Therefore, title must be updated here. 1382*59ddfc10SAndre Fischer SerfUri aUri( xResAccess->getURL() ); 1383cdf0e10cSrcweir aUnescapedTitle = aUri.GetPathBaseNameUnescaped(); 1384cdf0e10cSrcweir 1385cdf0e10cSrcweir if ( rType == UNKNOWN ) 1386cdf0e10cSrcweir { 1387cdf0e10cSrcweir xProps.reset( new ContentProperties( aUnescapedTitle ) ); 1388cdf0e10cSrcweir } 1389cdf0e10cSrcweir 1390cdf0e10cSrcweir // For DAV resources we only know the Title, for non-DAV 1391cdf0e10cSrcweir // resources we additionally know that it is a document. 1392cdf0e10cSrcweir 1393cdf0e10cSrcweir if ( rType == DAV ) 1394cdf0e10cSrcweir { 1395cdf0e10cSrcweir //xProps.reset( 1396cdf0e10cSrcweir // new ContentProperties( aUnescapedTitle ) ); 1397cdf0e10cSrcweir xProps->addProperty( 1398cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ), 1399cdf0e10cSrcweir uno::makeAny( aUnescapedTitle ), 1400cdf0e10cSrcweir true ); 1401cdf0e10cSrcweir } 1402cdf0e10cSrcweir else 1403cdf0e10cSrcweir { 1404cdf0e10cSrcweir if ( !xProps.get() ) 1405cdf0e10cSrcweir xProps.reset( new ContentProperties( aUnescapedTitle, false ) ); 1406cdf0e10cSrcweir else 1407cdf0e10cSrcweir xProps->addProperty( 1408cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ), 1409cdf0e10cSrcweir uno::makeAny( aUnescapedTitle ), 1410cdf0e10cSrcweir true ); 1411cdf0e10cSrcweir 1412cdf0e10cSrcweir xProps->addProperty( 1413cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ), 1414cdf0e10cSrcweir uno::makeAny( false ), 1415cdf0e10cSrcweir true ); 1416cdf0e10cSrcweir xProps->addProperty( 1417cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsDocument" ) ), 1418cdf0e10cSrcweir uno::makeAny( true ), 1419cdf0e10cSrcweir true ); 1420cdf0e10cSrcweir } 1421cdf0e10cSrcweir } 1422cdf0e10cSrcweir else 1423cdf0e10cSrcweir { 1424cdf0e10cSrcweir // No server access for just created (not yet committed) objects. 1425cdf0e10cSrcweir // Only a minimal set of properties supported at this stage. 1426cdf0e10cSrcweir if (m_bTransient) 1427cdf0e10cSrcweir xProps.reset( new ContentProperties( aUnescapedTitle, 1428cdf0e10cSrcweir m_bCollection ) ); 1429cdf0e10cSrcweir } 1430cdf0e10cSrcweir 1431cdf0e10cSrcweir sal_Int32 nCount = rProperties.getLength(); 1432cdf0e10cSrcweir for ( sal_Int32 n = 0; n < nCount; ++n ) 1433cdf0e10cSrcweir { 1434cdf0e10cSrcweir const rtl::OUString rName = rProperties[ n ].Name; 1435cdf0e10cSrcweir if ( rName.equalsAsciiL( 1436cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "BaseURI" ) ) ) 1437cdf0e10cSrcweir { 1438cdf0e10cSrcweir // Add BaseURI property, if requested. 1439cdf0e10cSrcweir xProps->addProperty( 1440cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BaseURI" ) ), 1441cdf0e10cSrcweir uno::makeAny( getBaseURI( xResAccess ) ), 1442cdf0e10cSrcweir true ); 1443cdf0e10cSrcweir } 1444cdf0e10cSrcweir else if ( rName.equalsAsciiL( 1445cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "CreatableContentsInfo" ) ) ) 1446cdf0e10cSrcweir { 1447cdf0e10cSrcweir // Add CreatableContentsInfo property, if requested. 1448cdf0e10cSrcweir sal_Bool bFolder = sal_False; 1449cdf0e10cSrcweir xProps->getValue( 1450cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ) ) 1451cdf0e10cSrcweir >>= bFolder; 1452cdf0e10cSrcweir xProps->addProperty( 1453cdf0e10cSrcweir rtl::OUString( 1454cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( "CreatableContentsInfo" ) ), 1455cdf0e10cSrcweir uno::makeAny( bFolder 1456cdf0e10cSrcweir ? queryCreatableContentsInfo() 1457cdf0e10cSrcweir : uno::Sequence< ucb::ContentInfo >() ), 1458cdf0e10cSrcweir true ); 1459cdf0e10cSrcweir } 1460cdf0e10cSrcweir } 1461cdf0e10cSrcweir 1462cdf0e10cSrcweir uno::Reference< sdbc::XRow > xResultRow 1463cdf0e10cSrcweir = getPropertyValues( xSMgr, 1464cdf0e10cSrcweir rProperties, 1465cdf0e10cSrcweir *xProps, 1466cdf0e10cSrcweir xProvider, 1467cdf0e10cSrcweir xIdentifier->getContentIdentifier() ); 1468cdf0e10cSrcweir 1469cdf0e10cSrcweir { 1470cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 1471cdf0e10cSrcweir 1472cdf0e10cSrcweir if ( !m_xCachedProps.get() ) 1473cdf0e10cSrcweir m_xCachedProps.reset( new CachableContentProperties( *xProps.get() ) ); 1474cdf0e10cSrcweir else 1475cdf0e10cSrcweir m_xCachedProps->addProperties( *xProps.get() ); 1476cdf0e10cSrcweir 1477cdf0e10cSrcweir m_xResAccess.reset( new DAVResourceAccess( *xResAccess.get() ) ); 1478*59ddfc10SAndre Fischer m_aEscapedTitle = SerfUri::escapeSegment( aUnescapedTitle ); 1479cdf0e10cSrcweir } 1480cdf0e10cSrcweir 1481cdf0e10cSrcweir return xResultRow; 1482cdf0e10cSrcweir } 1483cdf0e10cSrcweir 1484cdf0e10cSrcweir //========================================================================= 1485cdf0e10cSrcweir uno::Sequence< uno::Any > Content::setPropertyValues( 1486cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue >& rValues, 1487cdf0e10cSrcweir const uno::Reference< ucb::XCommandEnvironment >& xEnv ) 1488cdf0e10cSrcweir throw ( uno::Exception ) 1489cdf0e10cSrcweir { 1490cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xSMgr; 1491cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier > xIdentifier; 1492cdf0e10cSrcweir rtl::Reference< ContentProvider > xProvider; 1493cdf0e10cSrcweir sal_Bool bTransient; 1494cdf0e10cSrcweir std::auto_ptr< DAVResourceAccess > xResAccess; 1495cdf0e10cSrcweir 1496cdf0e10cSrcweir { 1497cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 1498cdf0e10cSrcweir 1499cdf0e10cSrcweir xProvider.set( m_pProvider ); 1500cdf0e10cSrcweir xIdentifier.set( m_xIdentifier ); 1501cdf0e10cSrcweir bTransient = m_bTransient; 1502cdf0e10cSrcweir xResAccess.reset( new DAVResourceAccess( *m_xResAccess.get() ) ); 1503cdf0e10cSrcweir xSMgr.set( m_xSMgr ); 1504cdf0e10cSrcweir } 1505cdf0e10cSrcweir 1506cdf0e10cSrcweir uno::Sequence< uno::Any > aRet( rValues.getLength() ); 1507cdf0e10cSrcweir uno::Sequence< beans::PropertyChangeEvent > aChanges( rValues.getLength() ); 1508cdf0e10cSrcweir sal_Int32 nChanged = 0; 1509cdf0e10cSrcweir 1510cdf0e10cSrcweir beans::PropertyChangeEvent aEvent; 1511cdf0e10cSrcweir aEvent.Source = static_cast< cppu::OWeakObject * >( this ); 1512cdf0e10cSrcweir aEvent.Further = sal_False; 1513cdf0e10cSrcweir // aEvent.PropertyName = 1514cdf0e10cSrcweir aEvent.PropertyHandle = -1; 1515cdf0e10cSrcweir // aEvent.OldValue = 1516cdf0e10cSrcweir // aEvent.NewValue = 1517cdf0e10cSrcweir 1518cdf0e10cSrcweir std::vector< ProppatchValue > aProppatchValues; 1519cdf0e10cSrcweir std::vector< sal_Int32 > aProppatchPropsPositions; 1520cdf0e10cSrcweir 1521cdf0e10cSrcweir uno::Reference< ucb::XPersistentPropertySet > xAdditionalPropSet; 1522cdf0e10cSrcweir sal_Bool bTriedToGetAdditonalPropSet = sal_False; 1523cdf0e10cSrcweir 1524cdf0e10cSrcweir sal_Bool bExchange = sal_False; 1525cdf0e10cSrcweir rtl::OUString aNewTitle; 1526cdf0e10cSrcweir rtl::OUString aOldTitle; 1527cdf0e10cSrcweir sal_Int32 nTitlePos = -1; 1528cdf0e10cSrcweir 1529cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > xInfo; 1530cdf0e10cSrcweir 1531cdf0e10cSrcweir const beans::PropertyValue* pValues = rValues.getConstArray(); 1532cdf0e10cSrcweir sal_Int32 nCount = rValues.getLength(); 1533cdf0e10cSrcweir for ( sal_Int32 n = 0; n < nCount; ++n ) 1534cdf0e10cSrcweir { 1535cdf0e10cSrcweir const beans::PropertyValue& rValue = pValues[ n ]; 1536cdf0e10cSrcweir const rtl::OUString & rName = rValue.Name; 1537cdf0e10cSrcweir 1538cdf0e10cSrcweir beans::Property aTmpProp; 1539cdf0e10cSrcweir xProvider->getProperty( rName, aTmpProp ); 1540cdf0e10cSrcweir 1541cdf0e10cSrcweir if ( aTmpProp.Attributes & beans::PropertyAttribute::READONLY ) 1542cdf0e10cSrcweir { 1543cdf0e10cSrcweir // Read-only property! 1544cdf0e10cSrcweir aRet[ n ] <<= lang::IllegalAccessException( 1545cdf0e10cSrcweir rtl::OUString::createFromAscii( 1546cdf0e10cSrcweir "Property is read-only!" ), 1547cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 1548cdf0e10cSrcweir continue; 1549cdf0e10cSrcweir } 1550cdf0e10cSrcweir 1551cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 1552cdf0e10cSrcweir // Mandatory props. 1553cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 1554cdf0e10cSrcweir 1555cdf0e10cSrcweir if ( rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ContentType" ) ) ) 1556cdf0e10cSrcweir { 1557cdf0e10cSrcweir // Read-only property! 1558cdf0e10cSrcweir aRet[ n ] <<= lang::IllegalAccessException( 1559cdf0e10cSrcweir rtl::OUString::createFromAscii( 1560cdf0e10cSrcweir "Property is read-only!" ), 1561cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 1562cdf0e10cSrcweir } 1563cdf0e10cSrcweir else if ( rName.equalsAsciiL( 1564cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "IsDocument" ) ) ) 1565cdf0e10cSrcweir { 1566cdf0e10cSrcweir // Read-only property! 1567cdf0e10cSrcweir aRet[ n ] <<= lang::IllegalAccessException( 1568cdf0e10cSrcweir rtl::OUString::createFromAscii( 1569cdf0e10cSrcweir "Property is read-only!" ), 1570cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 1571cdf0e10cSrcweir } 1572cdf0e10cSrcweir else if ( rName.equalsAsciiL( 1573cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "IsFolder" ) ) ) 1574cdf0e10cSrcweir { 1575cdf0e10cSrcweir // Read-only property! 1576cdf0e10cSrcweir aRet[ n ] <<= lang::IllegalAccessException( 1577cdf0e10cSrcweir rtl::OUString::createFromAscii( 1578cdf0e10cSrcweir "Property is read-only!" ), 1579cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 1580cdf0e10cSrcweir } 1581cdf0e10cSrcweir else if ( rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Title" ) ) ) 1582cdf0e10cSrcweir { 1583cdf0e10cSrcweir rtl::OUString aNewValue; 1584cdf0e10cSrcweir if ( rValue.Value >>= aNewValue ) 1585cdf0e10cSrcweir { 1586cdf0e10cSrcweir // No empty titles! 1587cdf0e10cSrcweir if ( aNewValue.getLength() > 0 ) 1588cdf0e10cSrcweir { 1589cdf0e10cSrcweir try 1590cdf0e10cSrcweir { 1591*59ddfc10SAndre Fischer SerfUri aURI( xIdentifier->getContentIdentifier() ); 1592cdf0e10cSrcweir aOldTitle = aURI.GetPathBaseNameUnescaped(); 1593cdf0e10cSrcweir 1594cdf0e10cSrcweir if ( aNewValue != aOldTitle ) 1595cdf0e10cSrcweir { 1596cdf0e10cSrcweir // modified title -> modified URL -> exchange ! 1597cdf0e10cSrcweir if ( !bTransient ) 1598cdf0e10cSrcweir bExchange = sal_True; 1599cdf0e10cSrcweir 1600cdf0e10cSrcweir // new value will be set later... 1601cdf0e10cSrcweir aNewTitle = aNewValue; 1602cdf0e10cSrcweir 1603cdf0e10cSrcweir // remember position within sequence of values (for 1604cdf0e10cSrcweir // error handling). 1605cdf0e10cSrcweir nTitlePos = n; 1606cdf0e10cSrcweir } 1607cdf0e10cSrcweir } 1608cdf0e10cSrcweir catch ( DAVException const & ) 1609cdf0e10cSrcweir { 1610cdf0e10cSrcweir aRet[ n ] <<= lang::IllegalArgumentException( 1611cdf0e10cSrcweir rtl::OUString::createFromAscii( 1612cdf0e10cSrcweir "Invalid content identifier!" ), 1613cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 1614cdf0e10cSrcweir -1 ); 1615cdf0e10cSrcweir } 1616cdf0e10cSrcweir } 1617cdf0e10cSrcweir else 1618cdf0e10cSrcweir { 1619cdf0e10cSrcweir aRet[ n ] <<= lang::IllegalArgumentException( 1620cdf0e10cSrcweir rtl::OUString::createFromAscii( 1621cdf0e10cSrcweir "Empty title not allowed!" ), 1622cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 1623cdf0e10cSrcweir -1 ); 1624cdf0e10cSrcweir } 1625cdf0e10cSrcweir } 1626cdf0e10cSrcweir else 1627cdf0e10cSrcweir { 1628cdf0e10cSrcweir aRet[ n ] <<= beans::IllegalTypeException( 1629cdf0e10cSrcweir rtl::OUString::createFromAscii( 1630cdf0e10cSrcweir "Property value has wrong type!" ), 1631cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 1632cdf0e10cSrcweir } 1633cdf0e10cSrcweir } 1634cdf0e10cSrcweir else 1635cdf0e10cSrcweir { 1636cdf0e10cSrcweir ////////////////////////////////////////////////////////////// 1637cdf0e10cSrcweir // Optional props. 1638cdf0e10cSrcweir ////////////////////////////////////////////////////////////// 1639cdf0e10cSrcweir 1640cdf0e10cSrcweir if ( !xInfo.is() ) 1641cdf0e10cSrcweir xInfo = getPropertySetInfo( xEnv, 1642cdf0e10cSrcweir sal_False /* don't cache data */ ); 1643cdf0e10cSrcweir 1644cdf0e10cSrcweir if ( !xInfo->hasPropertyByName( rName ) ) 1645cdf0e10cSrcweir { 1646cdf0e10cSrcweir // Check, whether property exists. Skip otherwise. 1647cdf0e10cSrcweir // PROPPATCH::set would add the property automatically, which 1648cdf0e10cSrcweir // is not allowed for "setPropertyValues" command! 1649cdf0e10cSrcweir aRet[ n ] <<= beans::UnknownPropertyException( 1650cdf0e10cSrcweir rtl::OUString::createFromAscii( 1651cdf0e10cSrcweir "Property is unknown!" ), 1652cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 1653cdf0e10cSrcweir continue; 1654cdf0e10cSrcweir } 1655cdf0e10cSrcweir 1656cdf0e10cSrcweir if ( rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Size" ) ) ) 1657cdf0e10cSrcweir { 1658cdf0e10cSrcweir // Read-only property! 1659cdf0e10cSrcweir aRet[ n ] <<= lang::IllegalAccessException( 1660cdf0e10cSrcweir rtl::OUString::createFromAscii( 1661cdf0e10cSrcweir "Property is read-only!" ), 1662cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 1663cdf0e10cSrcweir } 1664cdf0e10cSrcweir else if ( rName.equalsAsciiL( 1665cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "DateCreated" ) ) ) 1666cdf0e10cSrcweir { 1667cdf0e10cSrcweir // Read-only property! 1668cdf0e10cSrcweir aRet[ n ] <<= lang::IllegalAccessException( 1669cdf0e10cSrcweir rtl::OUString::createFromAscii( 1670cdf0e10cSrcweir "Property is read-only!" ), 1671cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 1672cdf0e10cSrcweir } 1673cdf0e10cSrcweir else if ( rName.equalsAsciiL( 1674cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "DateModified" ) ) ) 1675cdf0e10cSrcweir { 1676cdf0e10cSrcweir // Read-only property! 1677cdf0e10cSrcweir aRet[ n ] <<= lang::IllegalAccessException( 1678cdf0e10cSrcweir rtl::OUString::createFromAscii( 1679cdf0e10cSrcweir "Property is read-only!" ), 1680cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 1681cdf0e10cSrcweir } 1682cdf0e10cSrcweir else if ( rName.equalsAsciiL( 1683cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "MediaType" ) ) ) 1684cdf0e10cSrcweir { 1685cdf0e10cSrcweir // Read-only property! 1686cdf0e10cSrcweir // (but could be writable, if 'getcontenttype' would be) 1687cdf0e10cSrcweir aRet[ n ] <<= lang::IllegalAccessException( 1688cdf0e10cSrcweir rtl::OUString::createFromAscii( 1689cdf0e10cSrcweir "Property is read-only!" ), 1690cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 1691cdf0e10cSrcweir } 1692cdf0e10cSrcweir if ( rName.equalsAsciiL( 1693cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "CreatableContentsInfo" ) ) ) 1694cdf0e10cSrcweir { 1695cdf0e10cSrcweir // Read-only property! 1696cdf0e10cSrcweir aRet[ n ] <<= lang::IllegalAccessException( 1697cdf0e10cSrcweir rtl::OUString::createFromAscii( 1698cdf0e10cSrcweir "Property is read-only!" ), 1699cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 1700cdf0e10cSrcweir } 1701cdf0e10cSrcweir else 1702cdf0e10cSrcweir { 1703cdf0e10cSrcweir if ( getResourceType( xEnv, xResAccess ) == DAV ) 1704cdf0e10cSrcweir { 1705cdf0e10cSrcweir // Property value will be set on server. 1706cdf0e10cSrcweir ProppatchValue aValue( PROPSET, rName, rValue.Value ); 1707cdf0e10cSrcweir aProppatchValues.push_back( aValue ); 1708cdf0e10cSrcweir 1709cdf0e10cSrcweir // remember position within sequence of values (for 1710cdf0e10cSrcweir // error handling). 1711cdf0e10cSrcweir aProppatchPropsPositions.push_back( n ); 1712cdf0e10cSrcweir } 1713cdf0e10cSrcweir else 1714cdf0e10cSrcweir { 1715cdf0e10cSrcweir // Property value will be stored in local property store. 1716cdf0e10cSrcweir if ( !bTriedToGetAdditonalPropSet && 1717cdf0e10cSrcweir !xAdditionalPropSet.is() ) 1718cdf0e10cSrcweir { 1719cdf0e10cSrcweir xAdditionalPropSet 1720cdf0e10cSrcweir = getAdditionalPropertySet( sal_False ); 1721cdf0e10cSrcweir bTriedToGetAdditonalPropSet = sal_True; 1722cdf0e10cSrcweir } 1723cdf0e10cSrcweir 1724cdf0e10cSrcweir if ( xAdditionalPropSet.is() ) 1725cdf0e10cSrcweir { 1726cdf0e10cSrcweir try 1727cdf0e10cSrcweir { 1728cdf0e10cSrcweir uno::Any aOldValue 1729cdf0e10cSrcweir = xAdditionalPropSet->getPropertyValue( rName ); 1730cdf0e10cSrcweir if ( aOldValue != rValue.Value ) 1731cdf0e10cSrcweir { 1732cdf0e10cSrcweir xAdditionalPropSet->setPropertyValue( 1733cdf0e10cSrcweir rName, rValue.Value ); 1734cdf0e10cSrcweir 1735cdf0e10cSrcweir aEvent.PropertyName = rName; 1736cdf0e10cSrcweir aEvent.OldValue = aOldValue; 1737cdf0e10cSrcweir aEvent.NewValue = rValue.Value; 1738cdf0e10cSrcweir 1739cdf0e10cSrcweir aChanges.getArray()[ nChanged ] = aEvent; 1740cdf0e10cSrcweir nChanged++; 1741cdf0e10cSrcweir } 1742cdf0e10cSrcweir } 1743cdf0e10cSrcweir catch ( beans::UnknownPropertyException const & e ) 1744cdf0e10cSrcweir { 1745cdf0e10cSrcweir aRet[ n ] <<= e; 1746cdf0e10cSrcweir } 1747cdf0e10cSrcweir catch ( lang::WrappedTargetException const & e ) 1748cdf0e10cSrcweir { 1749cdf0e10cSrcweir aRet[ n ] <<= e; 1750cdf0e10cSrcweir } 1751cdf0e10cSrcweir catch ( beans::PropertyVetoException const & e ) 1752cdf0e10cSrcweir { 1753cdf0e10cSrcweir aRet[ n ] <<= e; 1754cdf0e10cSrcweir } 1755cdf0e10cSrcweir catch ( lang::IllegalArgumentException const & e ) 1756cdf0e10cSrcweir { 1757cdf0e10cSrcweir aRet[ n ] <<= e; 1758cdf0e10cSrcweir } 1759cdf0e10cSrcweir } 1760cdf0e10cSrcweir else 1761cdf0e10cSrcweir { 1762cdf0e10cSrcweir aRet[ n ] <<= uno::Exception( 1763cdf0e10cSrcweir rtl::OUString::createFromAscii( 1764cdf0e10cSrcweir "No property set for storing the value!" ), 1765cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 1766cdf0e10cSrcweir } 1767cdf0e10cSrcweir } 1768cdf0e10cSrcweir } 1769cdf0e10cSrcweir } 1770cdf0e10cSrcweir } // for 1771cdf0e10cSrcweir 1772cdf0e10cSrcweir if ( !bTransient && aProppatchValues.size() ) 1773cdf0e10cSrcweir { 1774cdf0e10cSrcweir try 1775cdf0e10cSrcweir { 1776cdf0e10cSrcweir // Set property values at server. 1777cdf0e10cSrcweir xResAccess->PROPPATCH( aProppatchValues, xEnv ); 1778cdf0e10cSrcweir 1779cdf0e10cSrcweir std::vector< ProppatchValue >::const_iterator it 1780cdf0e10cSrcweir = aProppatchValues.begin(); 1781cdf0e10cSrcweir std::vector< ProppatchValue >::const_iterator end 1782cdf0e10cSrcweir = aProppatchValues.end(); 1783cdf0e10cSrcweir 1784cdf0e10cSrcweir while ( it != end ) 1785cdf0e10cSrcweir { 1786cdf0e10cSrcweir aEvent.PropertyName = (*it).name; 1787cdf0e10cSrcweir aEvent.OldValue = uno::Any(); // @@@ to expensive to obtain! 1788cdf0e10cSrcweir aEvent.NewValue = (*it).value; 1789cdf0e10cSrcweir 1790cdf0e10cSrcweir aChanges.getArray()[ nChanged ] = aEvent; 1791cdf0e10cSrcweir nChanged++; 1792cdf0e10cSrcweir 1793cdf0e10cSrcweir ++it; 1794cdf0e10cSrcweir } 1795cdf0e10cSrcweir } 1796cdf0e10cSrcweir catch ( DAVException const & e ) 1797cdf0e10cSrcweir { 1798cdf0e10cSrcweir // OSL_ENSURE( sal_False, 1799cdf0e10cSrcweir // "Content::setPropertyValues - PROPPATCH failed!" ); 1800cdf0e10cSrcweir 1801cdf0e10cSrcweir #if 1 1802cdf0e10cSrcweir cancelCommandExecution( e, xEnv ); 1803cdf0e10cSrcweir // unreachable 1804cdf0e10cSrcweir #else 1805cdf0e10cSrcweir // Note: PROPPATCH either sets ALL property values OR NOTHING. 1806cdf0e10cSrcweir 1807cdf0e10cSrcweir std::vector< sal_Int32 >::const_iterator it 1808cdf0e10cSrcweir = aProppatchPropsPositions.begin(); 1809cdf0e10cSrcweir std::vector< sal_Int32 >::const_iterator end 1810cdf0e10cSrcweir = aProppatchPropsPositions.end(); 1811cdf0e10cSrcweir 1812cdf0e10cSrcweir while ( it != end ) 1813cdf0e10cSrcweir { 1814cdf0e10cSrcweir // Set error. 1815cdf0e10cSrcweir aRet[ (*it) ] <<= MapDAVException( e, sal_True ); 1816cdf0e10cSrcweir ++it; 1817cdf0e10cSrcweir } 1818cdf0e10cSrcweir #endif 1819cdf0e10cSrcweir } 1820cdf0e10cSrcweir } 1821cdf0e10cSrcweir 1822cdf0e10cSrcweir if ( bExchange ) 1823cdf0e10cSrcweir { 1824cdf0e10cSrcweir // Assemble new content identifier... 1825cdf0e10cSrcweir 1826cdf0e10cSrcweir rtl::OUString aNewURL = getParentURL(); 1827cdf0e10cSrcweir if ( aNewURL.lastIndexOf( '/' ) != ( aNewURL.getLength() - 1 ) ) 1828cdf0e10cSrcweir aNewURL += rtl::OUString::createFromAscii( "/" ); 1829cdf0e10cSrcweir 1830*59ddfc10SAndre Fischer aNewURL += SerfUri::escapeSegment( aNewTitle ); 1831cdf0e10cSrcweir 1832cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier > xNewId 1833cdf0e10cSrcweir = new ::ucbhelper::ContentIdentifier( xSMgr, aNewURL ); 1834cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier > xOldId = xIdentifier; 1835cdf0e10cSrcweir 1836cdf0e10cSrcweir try 1837cdf0e10cSrcweir { 1838*59ddfc10SAndre Fischer SerfUri sourceURI( xOldId->getContentIdentifier() ); 1839*59ddfc10SAndre Fischer SerfUri targetURI( xNewId->getContentIdentifier() ); 1840cdf0e10cSrcweir targetURI.SetScheme( sourceURI.GetScheme() ); 1841cdf0e10cSrcweir 1842cdf0e10cSrcweir xResAccess->MOVE( 1843cdf0e10cSrcweir sourceURI.GetPath(), targetURI.GetURI(), sal_False, xEnv ); 1844cdf0e10cSrcweir // @@@ Should check for resources that could not be moved 1845cdf0e10cSrcweir // (due to source access or target overwrite) and send 1846cdf0e10cSrcweir // this information through the interaction handler. 1847cdf0e10cSrcweir 1848cdf0e10cSrcweir // @@@ Existing content should be checked to see if it needs 1849cdf0e10cSrcweir // to be deleted at the source 1850cdf0e10cSrcweir 1851cdf0e10cSrcweir // @@@ Existing content should be checked to see if it has 1852cdf0e10cSrcweir // been overwritten at the target 1853cdf0e10cSrcweir 1854cdf0e10cSrcweir if ( exchangeIdentity( xNewId ) ) 1855cdf0e10cSrcweir { 1856cdf0e10cSrcweir xResAccess->setURL( aNewURL ); 1857cdf0e10cSrcweir 1858cdf0e10cSrcweir // DAV resources store all additional props on server! 1859cdf0e10cSrcweir // // Adapt Additional Core Properties. 1860cdf0e10cSrcweir // renameAdditionalPropertySet( xOldId->getContentIdentifier(), 1861cdf0e10cSrcweir // xNewId->getContentIdentifier(), 1862cdf0e10cSrcweir // sal_True ); 1863cdf0e10cSrcweir } 1864cdf0e10cSrcweir else 1865cdf0e10cSrcweir { 1866cdf0e10cSrcweir // Do not set new title! 1867cdf0e10cSrcweir aNewTitle = rtl::OUString(); 1868cdf0e10cSrcweir 1869cdf0e10cSrcweir // Set error . 1870cdf0e10cSrcweir aRet[ nTitlePos ] <<= uno::Exception( 1871cdf0e10cSrcweir rtl::OUString::createFromAscii( "Exchange failed!" ), 1872cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 1873cdf0e10cSrcweir } 1874cdf0e10cSrcweir } 1875cdf0e10cSrcweir catch ( DAVException const & e ) 1876cdf0e10cSrcweir { 1877cdf0e10cSrcweir // Do not set new title! 1878cdf0e10cSrcweir aNewTitle = rtl::OUString(); 1879cdf0e10cSrcweir 1880cdf0e10cSrcweir // Set error . 1881cdf0e10cSrcweir aRet[ nTitlePos ] <<= MapDAVException( e, sal_True ); 1882cdf0e10cSrcweir } 1883cdf0e10cSrcweir } 1884cdf0e10cSrcweir 1885cdf0e10cSrcweir if ( aNewTitle.getLength() ) 1886cdf0e10cSrcweir { 1887cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 1888cdf0e10cSrcweir 1889cdf0e10cSrcweir aEvent.PropertyName = rtl::OUString::createFromAscii( "Title" ); 1890cdf0e10cSrcweir aEvent.OldValue = uno::makeAny( aOldTitle ); 1891cdf0e10cSrcweir aEvent.NewValue = uno::makeAny( aNewTitle ); 1892cdf0e10cSrcweir 1893*59ddfc10SAndre Fischer m_aEscapedTitle = SerfUri::escapeSegment( aNewTitle ); 1894cdf0e10cSrcweir 1895cdf0e10cSrcweir aChanges.getArray()[ nChanged ] = aEvent; 1896cdf0e10cSrcweir nChanged++; 1897cdf0e10cSrcweir } 1898cdf0e10cSrcweir 1899cdf0e10cSrcweir if ( nChanged > 0 ) 1900cdf0e10cSrcweir { 1901cdf0e10cSrcweir aChanges.realloc( nChanged ); 1902cdf0e10cSrcweir notifyPropertiesChange( aChanges ); 1903cdf0e10cSrcweir } 1904cdf0e10cSrcweir 1905cdf0e10cSrcweir { 1906cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 1907cdf0e10cSrcweir m_xResAccess.reset( new DAVResourceAccess( *xResAccess.get() ) ); 1908cdf0e10cSrcweir } 1909cdf0e10cSrcweir 1910cdf0e10cSrcweir return aRet; 1911cdf0e10cSrcweir } 1912cdf0e10cSrcweir 1913cdf0e10cSrcweir //========================================================================= 1914cdf0e10cSrcweir uno::Any Content::open( 1915cdf0e10cSrcweir const ucb::OpenCommandArgument2 & rArg, 1916cdf0e10cSrcweir const uno::Reference< ucb::XCommandEnvironment > & xEnv ) 1917cdf0e10cSrcweir throw( uno::Exception ) 1918cdf0e10cSrcweir { 1919cdf0e10cSrcweir uno::Any aRet; 1920cdf0e10cSrcweir 1921cdf0e10cSrcweir sal_Bool bOpenFolder = ( ( rArg.Mode == ucb::OpenMode::ALL ) || 1922cdf0e10cSrcweir ( rArg.Mode == ucb::OpenMode::FOLDERS ) || 1923cdf0e10cSrcweir ( rArg.Mode == ucb::OpenMode::DOCUMENTS ) ); 1924cdf0e10cSrcweir if ( bOpenFolder ) 1925cdf0e10cSrcweir { 1926cdf0e10cSrcweir if ( isFolder( xEnv ) ) 1927cdf0e10cSrcweir { 1928cdf0e10cSrcweir // Open collection. 1929cdf0e10cSrcweir 1930cdf0e10cSrcweir uno::Reference< ucb::XDynamicResultSet > xSet 1931cdf0e10cSrcweir = new DynamicResultSet( m_xSMgr, this, rArg, xEnv ); 1932cdf0e10cSrcweir aRet <<= xSet; 1933cdf0e10cSrcweir } 1934cdf0e10cSrcweir else 1935cdf0e10cSrcweir { 1936cdf0e10cSrcweir // Error: Not a folder! 1937cdf0e10cSrcweir 1938cdf0e10cSrcweir rtl::OUStringBuffer aMsg; 1939cdf0e10cSrcweir aMsg.appendAscii( "Non-folder resource cannot be " 1940cdf0e10cSrcweir "opened as folder! Wrong Open Mode!" ); 1941cdf0e10cSrcweir 1942cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 1943cdf0e10cSrcweir uno::makeAny( 1944cdf0e10cSrcweir lang::IllegalArgumentException( 1945cdf0e10cSrcweir aMsg.makeStringAndClear(), 1946cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 1947cdf0e10cSrcweir -1 ) ), 1948cdf0e10cSrcweir xEnv ); 1949cdf0e10cSrcweir // Unreachable 1950cdf0e10cSrcweir } 1951cdf0e10cSrcweir } 1952cdf0e10cSrcweir 1953cdf0e10cSrcweir if ( rArg.Sink.is() ) 1954cdf0e10cSrcweir { 1955cdf0e10cSrcweir // Open document. 1956cdf0e10cSrcweir 1957cdf0e10cSrcweir if ( ( rArg.Mode == ucb::OpenMode::DOCUMENT_SHARE_DENY_NONE ) || 1958cdf0e10cSrcweir ( rArg.Mode == ucb::OpenMode::DOCUMENT_SHARE_DENY_WRITE ) ) 1959cdf0e10cSrcweir { 1960cdf0e10cSrcweir // Currently(?) unsupported. 1961cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 1962cdf0e10cSrcweir uno::makeAny( 1963cdf0e10cSrcweir ucb::UnsupportedOpenModeException( 1964cdf0e10cSrcweir rtl::OUString(), 1965cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 1966cdf0e10cSrcweir sal_Int16( rArg.Mode ) ) ), 1967cdf0e10cSrcweir xEnv ); 1968cdf0e10cSrcweir // Unreachable 1969cdf0e10cSrcweir } 1970cdf0e10cSrcweir 1971cdf0e10cSrcweir rtl::OUString aURL = m_xIdentifier->getContentIdentifier(); 1972cdf0e10cSrcweir uno::Reference< io::XOutputStream > xOut 1973cdf0e10cSrcweir = uno::Reference< io::XOutputStream >( rArg.Sink, uno::UNO_QUERY ); 1974cdf0e10cSrcweir if ( xOut.is() ) 1975cdf0e10cSrcweir { 1976cdf0e10cSrcweir // PUSH: write data 1977cdf0e10cSrcweir try 1978cdf0e10cSrcweir { 1979cdf0e10cSrcweir std::auto_ptr< DAVResourceAccess > xResAccess; 1980cdf0e10cSrcweir 1981cdf0e10cSrcweir { 1982cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 1983cdf0e10cSrcweir 1984cdf0e10cSrcweir xResAccess.reset( 1985cdf0e10cSrcweir new DAVResourceAccess( *m_xResAccess.get() ) ); 1986cdf0e10cSrcweir } 1987cdf0e10cSrcweir 1988cdf0e10cSrcweir DAVResource aResource; 1989cdf0e10cSrcweir std::vector< rtl::OUString > aHeaders; 1990cdf0e10cSrcweir 1991cdf0e10cSrcweir xResAccess->GET( xOut, aHeaders, aResource, xEnv ); 1992cdf0e10cSrcweir m_bDidGetOrHead = true; 1993cdf0e10cSrcweir 1994cdf0e10cSrcweir { 1995cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 1996cdf0e10cSrcweir 1997cdf0e10cSrcweir // cache headers. 1998cdf0e10cSrcweir if ( !m_xCachedProps.get()) 1999cdf0e10cSrcweir m_xCachedProps.reset( 2000cdf0e10cSrcweir new CachableContentProperties( aResource ) ); 2001cdf0e10cSrcweir else 2002cdf0e10cSrcweir m_xCachedProps->addProperties( aResource ); 2003cdf0e10cSrcweir 2004cdf0e10cSrcweir m_xResAccess.reset( 2005cdf0e10cSrcweir new DAVResourceAccess( *xResAccess.get() ) ); 2006cdf0e10cSrcweir } 2007cdf0e10cSrcweir } 2008cdf0e10cSrcweir catch ( DAVException const & e ) 2009cdf0e10cSrcweir { 2010cdf0e10cSrcweir cancelCommandExecution( e, xEnv ); 2011cdf0e10cSrcweir // Unreachable 2012cdf0e10cSrcweir } 2013cdf0e10cSrcweir } 2014cdf0e10cSrcweir else 2015cdf0e10cSrcweir { 2016cdf0e10cSrcweir uno::Reference< io::XActiveDataSink > xDataSink 2017cdf0e10cSrcweir = uno::Reference< io::XActiveDataSink >( rArg.Sink, 2018cdf0e10cSrcweir uno::UNO_QUERY ); 2019cdf0e10cSrcweir if ( xDataSink.is() ) 2020cdf0e10cSrcweir { 2021cdf0e10cSrcweir // PULL: wait for client read 2022cdf0e10cSrcweir try 2023cdf0e10cSrcweir { 2024cdf0e10cSrcweir std::auto_ptr< DAVResourceAccess > xResAccess; 2025cdf0e10cSrcweir { 2026cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 2027cdf0e10cSrcweir 2028cdf0e10cSrcweir xResAccess.reset( 2029cdf0e10cSrcweir new DAVResourceAccess( *m_xResAccess.get() ) ); 2030cdf0e10cSrcweir } 2031cdf0e10cSrcweir 2032cdf0e10cSrcweir // fill inputsream sync; return if all data present 2033cdf0e10cSrcweir DAVResource aResource; 2034cdf0e10cSrcweir std::vector< rtl::OUString > aHeaders; 2035cdf0e10cSrcweir 2036cdf0e10cSrcweir uno::Reference< io::XInputStream > xIn 2037cdf0e10cSrcweir = xResAccess->GET( aHeaders, aResource, xEnv ); 2038cdf0e10cSrcweir m_bDidGetOrHead = true; 2039cdf0e10cSrcweir 2040cdf0e10cSrcweir { 2041cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 2042cdf0e10cSrcweir 2043cdf0e10cSrcweir // cache headers. 2044cdf0e10cSrcweir if ( !m_xCachedProps.get()) 2045cdf0e10cSrcweir m_xCachedProps.reset( 2046cdf0e10cSrcweir new CachableContentProperties( aResource ) ); 2047cdf0e10cSrcweir else 2048cdf0e10cSrcweir m_xCachedProps->addProperties( 2049cdf0e10cSrcweir aResource.properties ); 2050cdf0e10cSrcweir 2051cdf0e10cSrcweir m_xResAccess.reset( 2052cdf0e10cSrcweir new DAVResourceAccess( *xResAccess.get() ) ); 2053cdf0e10cSrcweir } 2054cdf0e10cSrcweir 2055cdf0e10cSrcweir xDataSink->setInputStream( xIn ); 2056cdf0e10cSrcweir } 2057cdf0e10cSrcweir catch ( DAVException const & e ) 2058cdf0e10cSrcweir { 2059cdf0e10cSrcweir cancelCommandExecution( e, xEnv ); 2060cdf0e10cSrcweir // Unreachable 2061cdf0e10cSrcweir } 2062cdf0e10cSrcweir } 2063cdf0e10cSrcweir else 2064cdf0e10cSrcweir { 2065cdf0e10cSrcweir // Note: aOpenCommand.Sink may contain an XStream 2066cdf0e10cSrcweir // implementation. Support for this type of 2067cdf0e10cSrcweir // sink is optional... 2068cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 2069cdf0e10cSrcweir uno::makeAny( 2070cdf0e10cSrcweir ucb::UnsupportedDataSinkException( 2071cdf0e10cSrcweir rtl::OUString(), 2072cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 2073cdf0e10cSrcweir rArg.Sink ) ), 2074cdf0e10cSrcweir xEnv ); 2075cdf0e10cSrcweir // Unreachable 2076cdf0e10cSrcweir } 2077cdf0e10cSrcweir } 2078cdf0e10cSrcweir } 2079cdf0e10cSrcweir 2080cdf0e10cSrcweir return aRet; 2081cdf0e10cSrcweir } 2082cdf0e10cSrcweir 2083cdf0e10cSrcweir //========================================================================= 2084cdf0e10cSrcweir void Content::post( 2085cdf0e10cSrcweir const ucb::PostCommandArgument2 & rArg, 2086cdf0e10cSrcweir const uno::Reference< ucb::XCommandEnvironment > & xEnv ) 2087cdf0e10cSrcweir throw( uno::Exception ) 2088cdf0e10cSrcweir { 2089cdf0e10cSrcweir uno::Reference< io::XActiveDataSink > xSink( rArg.Sink, uno::UNO_QUERY ); 2090cdf0e10cSrcweir if ( xSink.is() ) 2091cdf0e10cSrcweir { 2092cdf0e10cSrcweir try 2093cdf0e10cSrcweir { 2094cdf0e10cSrcweir std::auto_ptr< DAVResourceAccess > xResAccess; 2095cdf0e10cSrcweir { 2096cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 2097cdf0e10cSrcweir xResAccess.reset( 2098cdf0e10cSrcweir new DAVResourceAccess( *m_xResAccess.get() ) ); 2099cdf0e10cSrcweir } 2100cdf0e10cSrcweir 2101cdf0e10cSrcweir uno::Reference< io::XInputStream > xResult 2102cdf0e10cSrcweir = xResAccess->POST( rArg.MediaType, 2103cdf0e10cSrcweir rArg.Referer, 2104cdf0e10cSrcweir rArg.Source, 2105cdf0e10cSrcweir xEnv ); 2106cdf0e10cSrcweir 2107cdf0e10cSrcweir { 2108cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 2109cdf0e10cSrcweir m_xResAccess.reset( 2110cdf0e10cSrcweir new DAVResourceAccess( *xResAccess.get() ) ); 2111cdf0e10cSrcweir } 2112cdf0e10cSrcweir 2113cdf0e10cSrcweir xSink->setInputStream( xResult ); 2114cdf0e10cSrcweir } 2115cdf0e10cSrcweir catch ( DAVException const & e ) 2116cdf0e10cSrcweir { 2117cdf0e10cSrcweir cancelCommandExecution( e, xEnv, sal_True ); 2118cdf0e10cSrcweir // Unreachable 2119cdf0e10cSrcweir } 2120cdf0e10cSrcweir } 2121cdf0e10cSrcweir else 2122cdf0e10cSrcweir { 2123cdf0e10cSrcweir uno::Reference< io::XOutputStream > xResult( rArg.Sink, uno::UNO_QUERY ); 2124cdf0e10cSrcweir if ( xResult.is() ) 2125cdf0e10cSrcweir { 2126cdf0e10cSrcweir try 2127cdf0e10cSrcweir { 2128cdf0e10cSrcweir std::auto_ptr< DAVResourceAccess > xResAccess; 2129cdf0e10cSrcweir { 2130cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 2131cdf0e10cSrcweir xResAccess.reset( 2132cdf0e10cSrcweir new DAVResourceAccess( *m_xResAccess.get() ) ); 2133cdf0e10cSrcweir } 2134cdf0e10cSrcweir 2135cdf0e10cSrcweir xResAccess->POST( rArg.MediaType, 2136cdf0e10cSrcweir rArg.Referer, 2137cdf0e10cSrcweir rArg.Source, 2138cdf0e10cSrcweir xResult, 2139cdf0e10cSrcweir xEnv ); 2140cdf0e10cSrcweir 2141cdf0e10cSrcweir { 2142cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 2143cdf0e10cSrcweir m_xResAccess.reset( 2144cdf0e10cSrcweir new DAVResourceAccess( *xResAccess.get() ) ); 2145cdf0e10cSrcweir } 2146cdf0e10cSrcweir } 2147cdf0e10cSrcweir catch ( DAVException const & e ) 2148cdf0e10cSrcweir { 2149cdf0e10cSrcweir cancelCommandExecution( e, xEnv, sal_True ); 2150cdf0e10cSrcweir // Unreachable 2151cdf0e10cSrcweir } 2152cdf0e10cSrcweir } 2153cdf0e10cSrcweir else 2154cdf0e10cSrcweir { 2155cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 2156cdf0e10cSrcweir uno::makeAny( 2157cdf0e10cSrcweir ucb::UnsupportedDataSinkException( 2158cdf0e10cSrcweir rtl::OUString(), 2159cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 2160cdf0e10cSrcweir rArg.Sink ) ), 2161cdf0e10cSrcweir xEnv ); 2162cdf0e10cSrcweir // Unreachable 2163cdf0e10cSrcweir } 2164cdf0e10cSrcweir } 2165cdf0e10cSrcweir } 2166cdf0e10cSrcweir 2167cdf0e10cSrcweir //========================================================================= 2168cdf0e10cSrcweir void Content::queryChildren( ContentRefList& rChildren ) 2169cdf0e10cSrcweir { 2170cdf0e10cSrcweir // Obtain a list with a snapshot of all currently instanciated contents 2171cdf0e10cSrcweir // from provider and extract the contents which are direct children 2172cdf0e10cSrcweir // of this content. 2173cdf0e10cSrcweir 2174cdf0e10cSrcweir ::ucbhelper::ContentRefList aAllContents; 2175cdf0e10cSrcweir m_xProvider->queryExistingContents( aAllContents ); 2176cdf0e10cSrcweir 2177cdf0e10cSrcweir rtl::OUString aURL = m_xIdentifier->getContentIdentifier(); 2178cdf0e10cSrcweir sal_Int32 nURLPos = aURL.lastIndexOf( '/' ); 2179cdf0e10cSrcweir 2180cdf0e10cSrcweir if ( nURLPos != ( aURL.getLength() - 1 ) ) 2181cdf0e10cSrcweir { 2182cdf0e10cSrcweir // No trailing slash found. Append. 2183cdf0e10cSrcweir aURL += rtl::OUString::createFromAscii( "/" ); 2184cdf0e10cSrcweir } 2185cdf0e10cSrcweir 2186cdf0e10cSrcweir sal_Int32 nLen = aURL.getLength(); 2187cdf0e10cSrcweir 2188cdf0e10cSrcweir ::ucbhelper::ContentRefList::const_iterator it = aAllContents.begin(); 2189cdf0e10cSrcweir ::ucbhelper::ContentRefList::const_iterator end = aAllContents.end(); 2190cdf0e10cSrcweir 2191cdf0e10cSrcweir while ( it != end ) 2192cdf0e10cSrcweir { 2193cdf0e10cSrcweir ::ucbhelper::ContentImplHelperRef xChild = (*it); 2194cdf0e10cSrcweir rtl::OUString aChildURL 2195cdf0e10cSrcweir = xChild->getIdentifier()->getContentIdentifier(); 2196cdf0e10cSrcweir 2197cdf0e10cSrcweir // Is aURL a prefix of aChildURL? 2198cdf0e10cSrcweir if ( ( aChildURL.getLength() > nLen ) && 2199cdf0e10cSrcweir ( aChildURL.compareTo( aURL, nLen ) == 0 ) ) 2200cdf0e10cSrcweir { 2201cdf0e10cSrcweir sal_Int32 nPos = nLen; 2202cdf0e10cSrcweir nPos = aChildURL.indexOf( '/', nPos ); 2203cdf0e10cSrcweir 2204cdf0e10cSrcweir if ( ( nPos == -1 ) || 2205cdf0e10cSrcweir ( nPos == ( aChildURL.getLength() - 1 ) ) ) 2206cdf0e10cSrcweir { 2207cdf0e10cSrcweir // No further slashes / only a final slash. It's a child! 2208cdf0e10cSrcweir rChildren.push_back( 2209*59ddfc10SAndre Fischer ::http_dav_ucp::Content::ContentRef( 2210*59ddfc10SAndre Fischer static_cast< ::http_dav_ucp::Content * >( 2211cdf0e10cSrcweir xChild.get() ) ) ); 2212cdf0e10cSrcweir } 2213cdf0e10cSrcweir } 2214cdf0e10cSrcweir ++it; 2215cdf0e10cSrcweir } 2216cdf0e10cSrcweir } 2217cdf0e10cSrcweir 2218cdf0e10cSrcweir //========================================================================= 2219cdf0e10cSrcweir void Content::insert( 2220cdf0e10cSrcweir const uno::Reference< io::XInputStream > & xInputStream, 2221cdf0e10cSrcweir sal_Bool bReplaceExisting, 2222cdf0e10cSrcweir const uno::Reference< ucb::XCommandEnvironment >& Environment ) 2223cdf0e10cSrcweir throw( uno::Exception ) 2224cdf0e10cSrcweir { 2225cdf0e10cSrcweir sal_Bool bTransient, bCollection; 2226cdf0e10cSrcweir rtl::OUString aEscapedTitle; 2227cdf0e10cSrcweir std::auto_ptr< DAVResourceAccess > xResAccess; 2228cdf0e10cSrcweir 2229cdf0e10cSrcweir { 2230cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 2231cdf0e10cSrcweir 2232cdf0e10cSrcweir bTransient = m_bTransient; 2233cdf0e10cSrcweir bCollection = m_bCollection; 2234cdf0e10cSrcweir aEscapedTitle = m_aEscapedTitle; 2235cdf0e10cSrcweir xResAccess.reset( new DAVResourceAccess( *m_xResAccess.get() ) ); 2236cdf0e10cSrcweir } 2237cdf0e10cSrcweir 2238cdf0e10cSrcweir // Check, if all required properties are present. 2239cdf0e10cSrcweir 2240cdf0e10cSrcweir if ( aEscapedTitle.getLength() == 0 ) 2241cdf0e10cSrcweir { 2242cdf0e10cSrcweir OSL_ENSURE( sal_False, "Content::insert - Title missing!" ); 2243cdf0e10cSrcweir 2244cdf0e10cSrcweir uno::Sequence< rtl::OUString > aProps( 1 ); 2245cdf0e10cSrcweir aProps[ 0 ] = rtl::OUString::createFromAscii( "Title" ); 2246cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 2247cdf0e10cSrcweir uno::makeAny( ucb::MissingPropertiesException( 2248cdf0e10cSrcweir rtl::OUString(), 2249cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 2250cdf0e10cSrcweir aProps ) ), 2251cdf0e10cSrcweir Environment ); 2252cdf0e10cSrcweir // Unreachable 2253cdf0e10cSrcweir } 2254cdf0e10cSrcweir 2255cdf0e10cSrcweir if ( !bReplaceExisting ) 2256cdf0e10cSrcweir { 2257cdf0e10cSrcweir /* [RFC 2616] - HTTP 2258cdf0e10cSrcweir 2259cdf0e10cSrcweir The PUT method requests that the enclosed entity be stored under the 2260cdf0e10cSrcweir supplied Request-URI. If the Request-URI refers to an already 2261cdf0e10cSrcweir existing resource, the enclosed entity SHOULD be considered as a 2262cdf0e10cSrcweir modified version of the one residing on the origin server. 2263cdf0e10cSrcweir */ 2264cdf0e10cSrcweir 2265cdf0e10cSrcweir /* [RFC 2518] - WebDAV 2266cdf0e10cSrcweir 2267cdf0e10cSrcweir MKCOL creates a new collection resource at the location specified by 2268cdf0e10cSrcweir the Request-URI. If the resource identified by the Request-URI is 2269cdf0e10cSrcweir non-null then the MKCOL MUST fail. 2270cdf0e10cSrcweir */ 2271cdf0e10cSrcweir 2272cdf0e10cSrcweir // ==> Complain on PUT, continue on MKCOL. 2273cdf0e10cSrcweir if ( !bTransient || ( bTransient && !bCollection ) ) 2274cdf0e10cSrcweir { 2275*59ddfc10SAndre Fischer #undef ERROR 2276cdf0e10cSrcweir ucb::UnsupportedNameClashException aEx( 2277*59ddfc10SAndre Fischer rtl::OUString::createFromAscii( "Unable to write without overwrite!" ), 2278cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 2279cdf0e10cSrcweir ucb::NameClash::ERROR ); 2280cdf0e10cSrcweir 2281cdf0e10cSrcweir uno::Reference< task::XInteractionHandler > xIH; 2282cdf0e10cSrcweir 2283cdf0e10cSrcweir if ( Environment.is() ) 2284cdf0e10cSrcweir xIH = Environment->getInteractionHandler(); 2285cdf0e10cSrcweir 2286cdf0e10cSrcweir if ( xIH.is() ) 2287cdf0e10cSrcweir { 2288cdf0e10cSrcweir uno::Any aExAsAny( uno::makeAny( aEx ) ); 2289cdf0e10cSrcweir 2290cdf0e10cSrcweir rtl::Reference< ucbhelper::SimpleInteractionRequest > xRequest 2291cdf0e10cSrcweir = new ucbhelper::SimpleInteractionRequest( 2292cdf0e10cSrcweir aExAsAny, 2293cdf0e10cSrcweir ucbhelper::CONTINUATION_APPROVE 2294cdf0e10cSrcweir | ucbhelper::CONTINUATION_DISAPPROVE ); 2295cdf0e10cSrcweir xIH->handle( xRequest.get() ); 2296cdf0e10cSrcweir 2297cdf0e10cSrcweir const sal_Int32 nResp = xRequest->getResponse(); 2298cdf0e10cSrcweir 2299cdf0e10cSrcweir switch ( nResp ) 2300cdf0e10cSrcweir { 2301cdf0e10cSrcweir case ucbhelper::CONTINUATION_UNKNOWN: 2302cdf0e10cSrcweir // Not handled; throw. 2303cdf0e10cSrcweir throw aEx; 2304cdf0e10cSrcweir // break; 2305cdf0e10cSrcweir 2306cdf0e10cSrcweir case ucbhelper::CONTINUATION_APPROVE: 2307cdf0e10cSrcweir // Continue -> Overwrite. 2308cdf0e10cSrcweir bReplaceExisting = sal_True; 2309cdf0e10cSrcweir break; 2310cdf0e10cSrcweir 2311cdf0e10cSrcweir case ucbhelper::CONTINUATION_DISAPPROVE: 2312cdf0e10cSrcweir // Abort. 2313cdf0e10cSrcweir throw ucb::CommandFailedException( 2314cdf0e10cSrcweir rtl::OUString(), 2315cdf0e10cSrcweir uno::Reference< uno::XInterface >(), 2316cdf0e10cSrcweir aExAsAny ); 2317cdf0e10cSrcweir // break; 2318cdf0e10cSrcweir 2319cdf0e10cSrcweir default: 2320cdf0e10cSrcweir OSL_ENSURE( sal_False, 2321cdf0e10cSrcweir "Content::insert - " 2322cdf0e10cSrcweir "Unknown interaction selection!" ); 2323cdf0e10cSrcweir throw ucb::CommandFailedException( 2324cdf0e10cSrcweir rtl::OUString::createFromAscii( 2325cdf0e10cSrcweir "Unknown interaction selection!" ), 2326cdf0e10cSrcweir uno::Reference< uno::XInterface >(), 2327cdf0e10cSrcweir aExAsAny ); 2328cdf0e10cSrcweir // break; 2329cdf0e10cSrcweir } 2330cdf0e10cSrcweir } 2331cdf0e10cSrcweir else 2332cdf0e10cSrcweir { 2333cdf0e10cSrcweir // No IH; throw. 2334cdf0e10cSrcweir throw aEx; 2335cdf0e10cSrcweir } 2336cdf0e10cSrcweir } 2337cdf0e10cSrcweir } 2338cdf0e10cSrcweir 2339cdf0e10cSrcweir if ( bTransient ) 2340cdf0e10cSrcweir { 2341cdf0e10cSrcweir // Assemble new content identifier... 2342cdf0e10cSrcweir rtl::OUString aURL = getParentURL(); 2343cdf0e10cSrcweir if ( aURL.lastIndexOf( '/' ) != ( aURL.getLength() - 1 ) ) 2344cdf0e10cSrcweir aURL += rtl::OUString::createFromAscii( "/" ); 2345cdf0e10cSrcweir 2346cdf0e10cSrcweir aURL += aEscapedTitle; 2347cdf0e10cSrcweir 2348cdf0e10cSrcweir try 2349cdf0e10cSrcweir { 2350cdf0e10cSrcweir xResAccess->setURL( aURL ); 2351cdf0e10cSrcweir 2352cdf0e10cSrcweir if ( bCollection ) 2353cdf0e10cSrcweir xResAccess->MKCOL( Environment ); 2354cdf0e10cSrcweir else 2355cdf0e10cSrcweir xResAccess->PUT( xInputStream, Environment ); 2356cdf0e10cSrcweir } 2357cdf0e10cSrcweir catch ( DAVException const & except ) 2358cdf0e10cSrcweir { 2359cdf0e10cSrcweir if ( bCollection ) 2360cdf0e10cSrcweir { 2361cdf0e10cSrcweir if ( except.getStatus() == SC_METHOD_NOT_ALLOWED ) 2362cdf0e10cSrcweir { 2363cdf0e10cSrcweir // [RFC 2518] - WebDAV 2364cdf0e10cSrcweir // 405 (Method Not Allowed) - MKCOL can only be 2365cdf0e10cSrcweir // executed on a deleted/non-existent resource. 2366cdf0e10cSrcweir 2367cdf0e10cSrcweir if ( bReplaceExisting ) 2368cdf0e10cSrcweir { 2369cdf0e10cSrcweir // Destroy old resource. 2370cdf0e10cSrcweir try 2371cdf0e10cSrcweir { 2372cdf0e10cSrcweir xResAccess->DESTROY( Environment ); 2373cdf0e10cSrcweir } 2374cdf0e10cSrcweir catch ( DAVException const & e ) 2375cdf0e10cSrcweir { 2376cdf0e10cSrcweir cancelCommandExecution( e, Environment, sal_True ); 2377cdf0e10cSrcweir // Unreachable 2378cdf0e10cSrcweir } 2379cdf0e10cSrcweir 2380cdf0e10cSrcweir // Insert (recursion!). 2381cdf0e10cSrcweir insert( xInputStream, bReplaceExisting, Environment ); 2382cdf0e10cSrcweir 2383cdf0e10cSrcweir { 2384cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 2385cdf0e10cSrcweir m_xResAccess.reset( 2386cdf0e10cSrcweir new DAVResourceAccess( *xResAccess.get() ) ); 2387cdf0e10cSrcweir } 2388cdf0e10cSrcweir 2389cdf0e10cSrcweir // Success! 2390cdf0e10cSrcweir return; 2391cdf0e10cSrcweir } 2392cdf0e10cSrcweir else 2393cdf0e10cSrcweir { 2394cdf0e10cSrcweir rtl::OUString aTitle; 2395cdf0e10cSrcweir try 2396cdf0e10cSrcweir { 2397*59ddfc10SAndre Fischer SerfUri aURI( aURL ); 2398cdf0e10cSrcweir aTitle = aURI.GetPathBaseNameUnescaped(); 2399cdf0e10cSrcweir } 2400cdf0e10cSrcweir catch ( DAVException const & ) 2401cdf0e10cSrcweir { 2402cdf0e10cSrcweir } 2403cdf0e10cSrcweir 2404cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 2405cdf0e10cSrcweir uno::makeAny( 2406cdf0e10cSrcweir ucb::NameClashException( 2407cdf0e10cSrcweir rtl::OUString(), 2408cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 2409cdf0e10cSrcweir task::InteractionClassification_ERROR, 2410cdf0e10cSrcweir aTitle ) ), 2411cdf0e10cSrcweir Environment ); 2412cdf0e10cSrcweir // Unreachable 2413cdf0e10cSrcweir } 2414cdf0e10cSrcweir } 2415cdf0e10cSrcweir } 2416cdf0e10cSrcweir 2417cdf0e10cSrcweir cancelCommandExecution( except, Environment, sal_True ); 2418cdf0e10cSrcweir // Unreachable 2419cdf0e10cSrcweir } 2420cdf0e10cSrcweir 2421cdf0e10cSrcweir { 2422cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 2423cdf0e10cSrcweir m_xIdentifier 2424cdf0e10cSrcweir = new ::ucbhelper::ContentIdentifier( m_xSMgr, aURL ); 2425cdf0e10cSrcweir } 2426cdf0e10cSrcweir 2427cdf0e10cSrcweir inserted(); 2428cdf0e10cSrcweir 2429cdf0e10cSrcweir { 2430cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 2431cdf0e10cSrcweir m_bTransient = sal_False; 2432cdf0e10cSrcweir } 2433cdf0e10cSrcweir } 2434cdf0e10cSrcweir else 2435cdf0e10cSrcweir { 2436cdf0e10cSrcweir if ( !xInputStream.is() ) 2437cdf0e10cSrcweir { 2438cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 2439cdf0e10cSrcweir uno::makeAny( 2440cdf0e10cSrcweir ucb::MissingInputStreamException( 2441cdf0e10cSrcweir rtl::OUString(), 2442cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ) ), 2443cdf0e10cSrcweir Environment ); 2444cdf0e10cSrcweir // Unreachable 2445cdf0e10cSrcweir } 2446cdf0e10cSrcweir 2447cdf0e10cSrcweir try 2448cdf0e10cSrcweir { 2449cdf0e10cSrcweir xResAccess->PUT( xInputStream, Environment ); 2450cdf0e10cSrcweir } 2451cdf0e10cSrcweir catch ( DAVException const & e ) 2452cdf0e10cSrcweir { 2453cdf0e10cSrcweir cancelCommandExecution( e, Environment, sal_True ); 2454cdf0e10cSrcweir // Unreachable 2455cdf0e10cSrcweir } 2456cdf0e10cSrcweir } 2457cdf0e10cSrcweir 2458cdf0e10cSrcweir { 2459cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 2460cdf0e10cSrcweir m_xResAccess.reset( new DAVResourceAccess( *xResAccess.get() ) ); 2461cdf0e10cSrcweir } 2462cdf0e10cSrcweir } 2463cdf0e10cSrcweir 2464cdf0e10cSrcweir //========================================================================= 2465cdf0e10cSrcweir void Content::transfer( 2466cdf0e10cSrcweir const ucb::TransferInfo & rArgs, 2467cdf0e10cSrcweir const uno::Reference< ucb::XCommandEnvironment >& Environment ) 2468cdf0e10cSrcweir throw( uno::Exception ) 2469cdf0e10cSrcweir { 2470cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xSMgr; 2471cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier > xIdentifier; 2472cdf0e10cSrcweir uno::Reference< ucb::XContentProvider > xProvider; 2473cdf0e10cSrcweir std::auto_ptr< DAVResourceAccess > xResAccess; 2474cdf0e10cSrcweir 2475cdf0e10cSrcweir { 2476cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 2477cdf0e10cSrcweir 2478cdf0e10cSrcweir xSMgr.set( m_xSMgr ); 2479cdf0e10cSrcweir xIdentifier.set( m_xIdentifier ); 2480cdf0e10cSrcweir xProvider.set( m_xProvider.get() ); 2481cdf0e10cSrcweir xResAccess.reset( new DAVResourceAccess( *m_xResAccess.get() ) ); 2482cdf0e10cSrcweir } 2483cdf0e10cSrcweir 2484cdf0e10cSrcweir rtl::OUString aTargetURI; 2485cdf0e10cSrcweir try 2486cdf0e10cSrcweir { 2487*59ddfc10SAndre Fischer SerfUri sourceURI( rArgs.SourceURL ); 2488*59ddfc10SAndre Fischer SerfUri targetURI( xIdentifier->getContentIdentifier() ); 2489cdf0e10cSrcweir aTargetURI = targetURI.GetPathBaseNameUnescaped(); 2490cdf0e10cSrcweir 2491cdf0e10cSrcweir // Check source's and target's URL scheme 2492cdf0e10cSrcweir // 2493cdf0e10cSrcweir const rtl::OUString aScheme = sourceURI.GetScheme().toAsciiLowerCase(); 2494cdf0e10cSrcweir if ( aScheme.equalsAsciiL( 2495cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( WEBDAV_URL_SCHEME ) ) ) 2496cdf0e10cSrcweir { 2497cdf0e10cSrcweir sourceURI.SetScheme( 2498cdf0e10cSrcweir rtl::OUString::createFromAscii( HTTP_URL_SCHEME ) ); 2499cdf0e10cSrcweir } 2500cdf0e10cSrcweir else if ( aScheme.equalsAsciiL( 2501cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( DAV_URL_SCHEME ) ) ) 2502cdf0e10cSrcweir { 2503cdf0e10cSrcweir sourceURI.SetScheme( 2504cdf0e10cSrcweir rtl::OUString::createFromAscii( HTTP_URL_SCHEME ) ); 2505cdf0e10cSrcweir } 2506cdf0e10cSrcweir else if ( aScheme.equalsAsciiL( 2507cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( DAVS_URL_SCHEME ) ) ) 2508cdf0e10cSrcweir { 2509cdf0e10cSrcweir sourceURI.SetScheme( 2510cdf0e10cSrcweir rtl::OUString::createFromAscii( HTTPS_URL_SCHEME ) ); 2511cdf0e10cSrcweir } 2512cdf0e10cSrcweir else 2513cdf0e10cSrcweir { 2514cdf0e10cSrcweir if ( !aScheme.equalsAsciiL( 2515cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( HTTP_URL_SCHEME ) ) && 2516cdf0e10cSrcweir !aScheme.equalsAsciiL( 2517cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( HTTPS_URL_SCHEME ) ) ) 2518cdf0e10cSrcweir { 2519cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 2520cdf0e10cSrcweir uno::makeAny( 2521cdf0e10cSrcweir ucb::InteractiveBadTransferURLException( 2522cdf0e10cSrcweir rtl::OUString::createFromAscii( 2523cdf0e10cSrcweir "Unsupported URL scheme!" ), 2524cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ) ), 2525cdf0e10cSrcweir Environment ); 2526cdf0e10cSrcweir // Unreachable 2527cdf0e10cSrcweir } 2528cdf0e10cSrcweir } 2529cdf0e10cSrcweir 2530cdf0e10cSrcweir if ( targetURI.GetScheme().toAsciiLowerCase().equalsAsciiL( 2531cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( WEBDAV_URL_SCHEME ) ) ) 2532cdf0e10cSrcweir targetURI.SetScheme( 2533cdf0e10cSrcweir rtl::OUString::createFromAscii( HTTP_URL_SCHEME ) ); 2534cdf0e10cSrcweir else if ( targetURI.GetScheme().toAsciiLowerCase().equalsAsciiL( 2535cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( DAV_URL_SCHEME ) ) ) 2536cdf0e10cSrcweir targetURI.SetScheme( 2537cdf0e10cSrcweir rtl::OUString::createFromAscii( HTTP_URL_SCHEME ) ); 2538cdf0e10cSrcweir 2539cdf0e10cSrcweir // @@@ This implementation of 'transfer' only works 2540cdf0e10cSrcweir // if the source and target are located at same host. 2541cdf0e10cSrcweir // (Neon does not support cross-server copy/move) 2542cdf0e10cSrcweir 2543cdf0e10cSrcweir // Check for same host 2544cdf0e10cSrcweir // 2545cdf0e10cSrcweir if ( sourceURI.GetHost().getLength() && 2546cdf0e10cSrcweir ( sourceURI.GetHost() != targetURI.GetHost() ) ) 2547cdf0e10cSrcweir { 2548cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 2549cdf0e10cSrcweir uno::makeAny( ucb::InteractiveBadTransferURLException( 2550cdf0e10cSrcweir rtl::OUString::createFromAscii( 2551cdf0e10cSrcweir "Different hosts!" ), 2552cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ) ), 2553cdf0e10cSrcweir Environment ); 2554cdf0e10cSrcweir // Unreachable 2555cdf0e10cSrcweir } 2556cdf0e10cSrcweir 2557cdf0e10cSrcweir rtl::OUString aTitle = rArgs.NewTitle; 2558cdf0e10cSrcweir 2559cdf0e10cSrcweir if ( !aTitle.getLength() ) 2560cdf0e10cSrcweir aTitle = sourceURI.GetPathBaseNameUnescaped(); 2561cdf0e10cSrcweir 2562cdf0e10cSrcweir if ( aTitle.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "/" ) ) ) 2563cdf0e10cSrcweir { 2564cdf0e10cSrcweir // kso: ??? 2565cdf0e10cSrcweir aTitle = rtl::OUString(); 2566cdf0e10cSrcweir } 2567cdf0e10cSrcweir 2568cdf0e10cSrcweir targetURI.AppendPath( aTitle ); 2569cdf0e10cSrcweir 2570cdf0e10cSrcweir rtl::OUString aTargetURL = xIdentifier->getContentIdentifier(); 2571cdf0e10cSrcweir if ( ( aTargetURL.lastIndexOf( '/' ) + 1 ) 2572cdf0e10cSrcweir != aTargetURL.getLength() ) 2573cdf0e10cSrcweir aTargetURL += rtl::OUString::createFromAscii( "/" ); 2574cdf0e10cSrcweir 2575cdf0e10cSrcweir aTargetURL += aTitle; 2576cdf0e10cSrcweir 2577cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier > xTargetId 2578cdf0e10cSrcweir = new ::ucbhelper::ContentIdentifier( xSMgr, aTargetURL ); 2579cdf0e10cSrcweir 2580cdf0e10cSrcweir DAVResourceAccess aSourceAccess( xSMgr, 2581cdf0e10cSrcweir xResAccess->getSessionFactory(), 2582cdf0e10cSrcweir sourceURI.GetURI() ); 2583cdf0e10cSrcweir 2584cdf0e10cSrcweir if ( rArgs.MoveData == sal_True ) 2585cdf0e10cSrcweir { 2586cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier > xId 2587cdf0e10cSrcweir = new ::ucbhelper::ContentIdentifier( xSMgr, rArgs.SourceURL ); 2588cdf0e10cSrcweir 2589cdf0e10cSrcweir // Note: The static cast is okay here, because its sure that 2590cdf0e10cSrcweir // xProvider is always the WebDAVContentProvider. 2591cdf0e10cSrcweir rtl::Reference< Content > xSource 2592cdf0e10cSrcweir = static_cast< Content * >( 2593cdf0e10cSrcweir xProvider->queryContent( xId ).get() ); 2594cdf0e10cSrcweir 2595cdf0e10cSrcweir // [RFC 2518] - WebDAV 2596cdf0e10cSrcweir // If a resource exists at the destination and the Overwrite 2597cdf0e10cSrcweir // header is "T" then prior to performing the move the server 2598cdf0e10cSrcweir // MUST perform a DELETE with "Depth: infinity" on the 2599cdf0e10cSrcweir // destination resource. If the Overwrite header is set to 2600cdf0e10cSrcweir // "F" then the operation will fail. 2601cdf0e10cSrcweir 2602cdf0e10cSrcweir aSourceAccess.MOVE( sourceURI.GetPath(), 2603cdf0e10cSrcweir targetURI.GetURI(), 2604cdf0e10cSrcweir rArgs.NameClash 2605cdf0e10cSrcweir == ucb::NameClash::OVERWRITE, 2606cdf0e10cSrcweir Environment ); 2607cdf0e10cSrcweir 2608cdf0e10cSrcweir if ( xSource.is() ) 2609cdf0e10cSrcweir { 2610cdf0e10cSrcweir // Propagate destruction to listeners. 2611cdf0e10cSrcweir xSource->destroy( sal_True ); 2612cdf0e10cSrcweir } 2613cdf0e10cSrcweir 2614cdf0e10cSrcweir // DAV resources store all additional props on server! 2615cdf0e10cSrcweir // // Rename own and all children's Additional Core Properties. 2616cdf0e10cSrcweir // renameAdditionalPropertySet( xId->getContentIdentifier(), 2617cdf0e10cSrcweir // xTargetId->getContentIdentifier(), 2618cdf0e10cSrcweir // sal_True ); 2619cdf0e10cSrcweir } 2620cdf0e10cSrcweir else 2621cdf0e10cSrcweir { 2622cdf0e10cSrcweir // [RFC 2518] - WebDAV 2623cdf0e10cSrcweir // If a resource exists at the destination and the Overwrite 2624cdf0e10cSrcweir // header is "T" then prior to performing the copy the server 2625cdf0e10cSrcweir // MUST perform a DELETE with "Depth: infinity" on the 2626cdf0e10cSrcweir // destination resource. If the Overwrite header is set to 2627cdf0e10cSrcweir // "F" then the operation will fail. 2628cdf0e10cSrcweir 2629cdf0e10cSrcweir aSourceAccess.COPY( sourceURI.GetPath(), 2630cdf0e10cSrcweir targetURI.GetURI(), 2631cdf0e10cSrcweir rArgs.NameClash 2632cdf0e10cSrcweir == ucb::NameClash::OVERWRITE, 2633cdf0e10cSrcweir Environment ); 2634cdf0e10cSrcweir 2635cdf0e10cSrcweir // DAV resources store all additional props on server! 2636cdf0e10cSrcweir // // Copy own and all children's Additional Core Properties. 2637cdf0e10cSrcweir // copyAdditionalPropertySet( xId->getContentIdentifier(), 2638cdf0e10cSrcweir // xTargetId->getContentIdentifier(), 2639cdf0e10cSrcweir // sal_True ); 2640cdf0e10cSrcweir } 2641cdf0e10cSrcweir 2642cdf0e10cSrcweir // Note: The static cast is okay here, because its sure that 2643cdf0e10cSrcweir // xProvider is always the WebDAVContentProvider. 2644cdf0e10cSrcweir rtl::Reference< Content > xTarget 2645cdf0e10cSrcweir = static_cast< Content * >( 2646cdf0e10cSrcweir xProvider->queryContent( xTargetId ).get() ); 2647cdf0e10cSrcweir 2648cdf0e10cSrcweir // Announce transfered content in its new folder. 2649cdf0e10cSrcweir xTarget->inserted(); 2650cdf0e10cSrcweir } 2651cdf0e10cSrcweir catch ( ucb::IllegalIdentifierException const & ) 2652cdf0e10cSrcweir { 2653cdf0e10cSrcweir // queryContent 2654cdf0e10cSrcweir } 2655cdf0e10cSrcweir catch ( DAVException const & e ) 2656cdf0e10cSrcweir { 2657cdf0e10cSrcweir // [RFC 2518] - WebDAV 2658cdf0e10cSrcweir // 412 (Precondition Failed) - The server was unable to maintain 2659cdf0e10cSrcweir // the liveness of the properties listed in the propertybehavior 2660cdf0e10cSrcweir // XML element or the Overwrite header is "F" and the state of 2661cdf0e10cSrcweir // the destination resource is non-null. 2662cdf0e10cSrcweir 2663cdf0e10cSrcweir if ( e.getStatus() == SC_PRECONDITION_FAILED ) 2664cdf0e10cSrcweir { 2665cdf0e10cSrcweir switch ( rArgs.NameClash ) 2666cdf0e10cSrcweir { 2667*59ddfc10SAndre Fischer case 0/*ucb::NameClash::ERROR*/: 2668cdf0e10cSrcweir { 2669cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 2670cdf0e10cSrcweir uno::makeAny( 2671cdf0e10cSrcweir ucb::NameClashException( 2672cdf0e10cSrcweir rtl::OUString(), 2673cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 2674cdf0e10cSrcweir task::InteractionClassification_ERROR, 2675cdf0e10cSrcweir aTargetURI ) ), 2676cdf0e10cSrcweir Environment ); 2677cdf0e10cSrcweir // Unreachable 2678cdf0e10cSrcweir } 2679cdf0e10cSrcweir 2680cdf0e10cSrcweir case ucb::NameClash::OVERWRITE: 2681cdf0e10cSrcweir break; 2682cdf0e10cSrcweir 2683cdf0e10cSrcweir case ucb::NameClash::KEEP: // deprecated 2684cdf0e10cSrcweir case ucb::NameClash::RENAME: 2685cdf0e10cSrcweir case ucb::NameClash::ASK: 2686cdf0e10cSrcweir default: 2687cdf0e10cSrcweir { 2688cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 2689cdf0e10cSrcweir uno::makeAny( 2690cdf0e10cSrcweir ucb::UnsupportedNameClashException( 2691cdf0e10cSrcweir rtl::OUString(), 2692cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 2693cdf0e10cSrcweir rArgs.NameClash ) ), 2694cdf0e10cSrcweir Environment ); 2695cdf0e10cSrcweir // Unreachable 2696cdf0e10cSrcweir } 2697cdf0e10cSrcweir } 2698cdf0e10cSrcweir } 2699cdf0e10cSrcweir 2700cdf0e10cSrcweir cancelCommandExecution( e, Environment, sal_True ); 2701cdf0e10cSrcweir // Unreachable 2702cdf0e10cSrcweir } 2703cdf0e10cSrcweir 2704cdf0e10cSrcweir { 2705cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 2706cdf0e10cSrcweir m_xResAccess.reset( new DAVResourceAccess( *xResAccess.get() ) ); 2707cdf0e10cSrcweir } 2708cdf0e10cSrcweir } 2709cdf0e10cSrcweir 2710cdf0e10cSrcweir //========================================================================= 2711cdf0e10cSrcweir void Content::destroy( sal_Bool bDeletePhysical ) 2712cdf0e10cSrcweir throw( uno::Exception ) 2713cdf0e10cSrcweir { 2714cdf0e10cSrcweir // @@@ take care about bDeletePhysical -> trashcan support 2715cdf0e10cSrcweir rtl::OUString aURL = m_xIdentifier->getContentIdentifier(); 2716cdf0e10cSrcweir 2717cdf0e10cSrcweir uno::Reference< ucb::XContent > xThis = this; 2718cdf0e10cSrcweir 2719cdf0e10cSrcweir deleted(); 2720cdf0e10cSrcweir 2721cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 2722cdf0e10cSrcweir 2723cdf0e10cSrcweir // Process instanciated children... 2724cdf0e10cSrcweir 2725*59ddfc10SAndre Fischer ::http_dav_ucp::Content::ContentRefList aChildren; 2726cdf0e10cSrcweir queryChildren( aChildren ); 2727cdf0e10cSrcweir 2728cdf0e10cSrcweir ContentRefList::const_iterator it = aChildren.begin(); 2729cdf0e10cSrcweir ContentRefList::const_iterator end = aChildren.end(); 2730cdf0e10cSrcweir 2731cdf0e10cSrcweir while ( it != end ) 2732cdf0e10cSrcweir { 2733cdf0e10cSrcweir (*it)->destroy( bDeletePhysical ); 2734cdf0e10cSrcweir ++it; 2735cdf0e10cSrcweir } 2736cdf0e10cSrcweir } 2737cdf0e10cSrcweir 2738cdf0e10cSrcweir //========================================================================= 2739cdf0e10cSrcweir bool Content::supportsExclusiveWriteLock( 2740cdf0e10cSrcweir const uno::Reference< ucb::XCommandEnvironment >& Environment ) 2741cdf0e10cSrcweir { 2742cdf0e10cSrcweir if ( getResourceType( Environment ) == DAV ) 2743cdf0e10cSrcweir { 2744cdf0e10cSrcweir if ( m_xCachedProps.get() ) 2745cdf0e10cSrcweir { 2746cdf0e10cSrcweir uno::Sequence< ucb::LockEntry > aSupportedLocks; 2747cdf0e10cSrcweir if ( m_xCachedProps->getValue( DAVProperties::SUPPORTEDLOCK ) 2748cdf0e10cSrcweir >>= aSupportedLocks ) 2749cdf0e10cSrcweir { 2750cdf0e10cSrcweir for ( sal_Int32 n = 0; n < aSupportedLocks.getLength(); ++n ) 2751cdf0e10cSrcweir { 2752cdf0e10cSrcweir if ( aSupportedLocks[ n ].Scope 2753cdf0e10cSrcweir == ucb::LockScope_EXCLUSIVE && 2754cdf0e10cSrcweir aSupportedLocks[ n ].Type 2755cdf0e10cSrcweir == ucb::LockType_WRITE ) 2756cdf0e10cSrcweir return true; 2757cdf0e10cSrcweir } 2758cdf0e10cSrcweir } 2759cdf0e10cSrcweir } 2760cdf0e10cSrcweir } 2761cdf0e10cSrcweir return false; 2762cdf0e10cSrcweir } 2763cdf0e10cSrcweir 2764cdf0e10cSrcweir //========================================================================= 2765cdf0e10cSrcweir void Content::lock( 2766cdf0e10cSrcweir const uno::Reference< ucb::XCommandEnvironment >& Environment ) 2767cdf0e10cSrcweir throw( uno::Exception ) 2768cdf0e10cSrcweir { 2769cdf0e10cSrcweir try 2770cdf0e10cSrcweir { 2771cdf0e10cSrcweir std::auto_ptr< DAVResourceAccess > xResAccess; 2772cdf0e10cSrcweir { 2773cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 2774cdf0e10cSrcweir xResAccess.reset( new DAVResourceAccess( *m_xResAccess.get() ) ); 2775cdf0e10cSrcweir } 2776cdf0e10cSrcweir 2777cdf0e10cSrcweir uno::Any aOwnerAny; 2778cdf0e10cSrcweir aOwnerAny 2779cdf0e10cSrcweir <<= rtl::OUString::createFromAscii( "http://ucb.openoffice.org" ); 2780cdf0e10cSrcweir 2781cdf0e10cSrcweir ucb::Lock aLock( 2782cdf0e10cSrcweir ucb::LockScope_EXCLUSIVE, 2783cdf0e10cSrcweir ucb::LockType_WRITE, 2784cdf0e10cSrcweir ucb::LockDepth_ZERO, 2785cdf0e10cSrcweir aOwnerAny, 2786cdf0e10cSrcweir 180, // lock timeout in secs 2787cdf0e10cSrcweir //-1, // infinite lock 2788cdf0e10cSrcweir uno::Sequence< ::rtl::OUString >() ); 2789cdf0e10cSrcweir 2790cdf0e10cSrcweir xResAccess->LOCK( aLock, Environment ); 2791cdf0e10cSrcweir 2792cdf0e10cSrcweir { 2793cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 2794cdf0e10cSrcweir m_xResAccess.reset( new DAVResourceAccess( *xResAccess.get() ) ); 2795cdf0e10cSrcweir } 2796cdf0e10cSrcweir } 2797cdf0e10cSrcweir catch ( DAVException const & e ) 2798cdf0e10cSrcweir { 2799cdf0e10cSrcweir cancelCommandExecution( e, Environment, sal_False ); 2800cdf0e10cSrcweir // Unreachable 2801cdf0e10cSrcweir } 2802cdf0e10cSrcweir } 2803cdf0e10cSrcweir 2804cdf0e10cSrcweir //========================================================================= 2805cdf0e10cSrcweir void Content::unlock( 2806cdf0e10cSrcweir const uno::Reference< ucb::XCommandEnvironment >& Environment ) 2807cdf0e10cSrcweir throw( uno::Exception ) 2808cdf0e10cSrcweir { 2809cdf0e10cSrcweir try 2810cdf0e10cSrcweir { 2811cdf0e10cSrcweir std::auto_ptr< DAVResourceAccess > xResAccess; 2812cdf0e10cSrcweir { 2813cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 2814cdf0e10cSrcweir xResAccess.reset( new DAVResourceAccess( *m_xResAccess.get() ) ); 2815cdf0e10cSrcweir } 2816cdf0e10cSrcweir 2817cdf0e10cSrcweir xResAccess->UNLOCK( Environment ); 2818cdf0e10cSrcweir 2819cdf0e10cSrcweir { 2820cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 2821cdf0e10cSrcweir m_xResAccess.reset( new DAVResourceAccess( *xResAccess.get() ) ); 2822cdf0e10cSrcweir } 2823cdf0e10cSrcweir } 2824cdf0e10cSrcweir catch ( DAVException const & e ) 2825cdf0e10cSrcweir { 2826cdf0e10cSrcweir cancelCommandExecution( e, Environment, sal_False ); 2827cdf0e10cSrcweir // Unreachable 2828cdf0e10cSrcweir } 2829cdf0e10cSrcweir } 2830cdf0e10cSrcweir 2831cdf0e10cSrcweir //========================================================================= 2832cdf0e10cSrcweir sal_Bool Content::exchangeIdentity( 2833cdf0e10cSrcweir const uno::Reference< ucb::XContentIdentifier >& xNewId ) 2834cdf0e10cSrcweir { 2835cdf0e10cSrcweir if ( !xNewId.is() ) 2836cdf0e10cSrcweir return sal_False; 2837cdf0e10cSrcweir 2838cdf0e10cSrcweir osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex ); 2839cdf0e10cSrcweir 2840cdf0e10cSrcweir uno::Reference< ucb::XContent > xThis = this; 2841cdf0e10cSrcweir 2842cdf0e10cSrcweir // Already persistent? 2843cdf0e10cSrcweir if ( m_bTransient ) 2844cdf0e10cSrcweir { 2845cdf0e10cSrcweir OSL_ENSURE( sal_False, "Content::exchangeIdentity - Not persistent!" ); 2846cdf0e10cSrcweir return sal_False; 2847cdf0e10cSrcweir } 2848cdf0e10cSrcweir 2849cdf0e10cSrcweir // Exchange own identitity. 2850cdf0e10cSrcweir 2851cdf0e10cSrcweir // Fail, if a content with given id already exists. 2852cdf0e10cSrcweir // if ( !hasData( xNewId ) ) 2853cdf0e10cSrcweir { 2854cdf0e10cSrcweir rtl::OUString aOldURL = m_xIdentifier->getContentIdentifier(); 2855cdf0e10cSrcweir 2856cdf0e10cSrcweir aGuard.clear(); 2857cdf0e10cSrcweir if ( exchange( xNewId ) ) 2858cdf0e10cSrcweir { 2859cdf0e10cSrcweir // Process instanciated children... 2860cdf0e10cSrcweir 2861cdf0e10cSrcweir ContentRefList aChildren; 2862cdf0e10cSrcweir queryChildren( aChildren ); 2863cdf0e10cSrcweir 2864cdf0e10cSrcweir ContentRefList::const_iterator it = aChildren.begin(); 2865cdf0e10cSrcweir ContentRefList::const_iterator end = aChildren.end(); 2866cdf0e10cSrcweir 2867cdf0e10cSrcweir while ( it != end ) 2868cdf0e10cSrcweir { 2869cdf0e10cSrcweir ContentRef xChild = (*it); 2870cdf0e10cSrcweir 2871cdf0e10cSrcweir // Create new content identifier for the child... 2872cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier > 2873cdf0e10cSrcweir xOldChildId = xChild->getIdentifier(); 2874cdf0e10cSrcweir rtl::OUString aOldChildURL 2875cdf0e10cSrcweir = xOldChildId->getContentIdentifier(); 2876cdf0e10cSrcweir rtl::OUString aNewChildURL 2877cdf0e10cSrcweir = aOldChildURL.replaceAt( 2878cdf0e10cSrcweir 0, 2879cdf0e10cSrcweir aOldURL.getLength(), 2880cdf0e10cSrcweir xNewId->getContentIdentifier() ); 2881cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier > xNewChildId 2882cdf0e10cSrcweir = new ::ucbhelper::ContentIdentifier( 2883cdf0e10cSrcweir m_xSMgr, aNewChildURL ); 2884cdf0e10cSrcweir 2885cdf0e10cSrcweir if ( !xChild->exchangeIdentity( xNewChildId ) ) 2886cdf0e10cSrcweir return sal_False; 2887cdf0e10cSrcweir 2888cdf0e10cSrcweir ++it; 2889cdf0e10cSrcweir } 2890cdf0e10cSrcweir return sal_True; 2891cdf0e10cSrcweir } 2892cdf0e10cSrcweir } 2893cdf0e10cSrcweir 2894cdf0e10cSrcweir OSL_ENSURE( sal_False, 2895cdf0e10cSrcweir "Content::exchangeIdentity - " 2896cdf0e10cSrcweir "Panic! Cannot exchange identity!" ); 2897cdf0e10cSrcweir return sal_False; 2898cdf0e10cSrcweir } 2899cdf0e10cSrcweir 2900cdf0e10cSrcweir //========================================================================= 2901cdf0e10cSrcweir sal_Bool Content::isFolder( 2902cdf0e10cSrcweir const uno::Reference< ucb::XCommandEnvironment >& xEnv ) 2903cdf0e10cSrcweir throw( uno::Exception ) 2904cdf0e10cSrcweir { 2905cdf0e10cSrcweir { 2906cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 2907cdf0e10cSrcweir 2908cdf0e10cSrcweir if ( m_bTransient ) 2909cdf0e10cSrcweir return m_bCollection; 2910cdf0e10cSrcweir } 2911cdf0e10cSrcweir 2912cdf0e10cSrcweir uno::Sequence< beans::Property > aProperties( 1 ); 2913cdf0e10cSrcweir aProperties[ 0 ].Name = rtl::OUString::createFromAscii( "IsFolder" ); 2914cdf0e10cSrcweir aProperties[ 0 ].Handle = -1; 2915cdf0e10cSrcweir uno::Reference< sdbc::XRow > xRow( getPropertyValues( aProperties, xEnv ) ); 2916cdf0e10cSrcweir if ( xRow.is() ) 2917cdf0e10cSrcweir { 2918cdf0e10cSrcweir try 2919cdf0e10cSrcweir { 2920cdf0e10cSrcweir return xRow->getBoolean( 1 ); 2921cdf0e10cSrcweir } 2922cdf0e10cSrcweir catch ( sdbc::SQLException const & ) 2923cdf0e10cSrcweir { 2924cdf0e10cSrcweir } 2925cdf0e10cSrcweir } 2926cdf0e10cSrcweir 2927cdf0e10cSrcweir return sal_False; 2928cdf0e10cSrcweir } 2929cdf0e10cSrcweir 2930cdf0e10cSrcweir //========================================================================= 2931cdf0e10cSrcweir uno::Any Content::MapDAVException( const DAVException & e, sal_Bool bWrite ) 2932cdf0e10cSrcweir { 2933cdf0e10cSrcweir // Map DAVException... 2934cdf0e10cSrcweir uno::Any aException; 2935cdf0e10cSrcweir 2936cdf0e10cSrcweir rtl::OUString aURL; 2937cdf0e10cSrcweir if ( m_bTransient ) 2938cdf0e10cSrcweir { 2939cdf0e10cSrcweir aURL = getParentURL(); 2940cdf0e10cSrcweir if ( aURL.lastIndexOf( '/' ) != ( aURL.getLength() - 1 ) ) 2941cdf0e10cSrcweir aURL += rtl::OUString::createFromAscii( "/" ); 2942cdf0e10cSrcweir 2943cdf0e10cSrcweir aURL += m_aEscapedTitle; 2944cdf0e10cSrcweir } 2945cdf0e10cSrcweir else 2946cdf0e10cSrcweir { 2947cdf0e10cSrcweir aURL = m_xIdentifier->getContentIdentifier(); 2948cdf0e10cSrcweir } 2949cdf0e10cSrcweir 2950cdf0e10cSrcweir switch ( e.getStatus() ) 2951cdf0e10cSrcweir { 2952cdf0e10cSrcweir case SC_NOT_FOUND: 2953cdf0e10cSrcweir { 2954cdf0e10cSrcweir uno::Sequence< uno::Any > aArgs( 1 ); 2955cdf0e10cSrcweir aArgs[ 0 ] <<= beans::PropertyValue( 2956cdf0e10cSrcweir rtl::OUString::createFromAscii("Uri"), -1, 2957cdf0e10cSrcweir uno::makeAny(aURL), 2958cdf0e10cSrcweir beans::PropertyState_DIRECT_VALUE); 2959cdf0e10cSrcweir 2960cdf0e10cSrcweir aException <<= 2961cdf0e10cSrcweir ucb::InteractiveAugmentedIOException( 2962cdf0e10cSrcweir rtl::OUString::createFromAscii( "Not found!" ), 2963cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 2964cdf0e10cSrcweir task::InteractionClassification_ERROR, 2965cdf0e10cSrcweir ucb::IOErrorCode_NOT_EXISTING, 2966cdf0e10cSrcweir aArgs ); 2967cdf0e10cSrcweir return aException; 2968cdf0e10cSrcweir } 2969cdf0e10cSrcweir default: 2970cdf0e10cSrcweir break; 2971cdf0e10cSrcweir } 2972cdf0e10cSrcweir 2973cdf0e10cSrcweir switch ( e.getError() ) 2974cdf0e10cSrcweir { 2975cdf0e10cSrcweir case DAVException::DAV_HTTP_ERROR: 2976cdf0e10cSrcweir { 2977cdf0e10cSrcweir if ( bWrite ) 2978cdf0e10cSrcweir aException <<= 2979cdf0e10cSrcweir ucb::InteractiveNetworkWriteException( 2980cdf0e10cSrcweir e.getData(), 2981cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 2982cdf0e10cSrcweir task::InteractionClassification_ERROR, 2983cdf0e10cSrcweir e.getData() ); 2984cdf0e10cSrcweir else 2985cdf0e10cSrcweir aException <<= 2986cdf0e10cSrcweir ucb::InteractiveNetworkReadException( 2987cdf0e10cSrcweir e.getData(), 2988cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 2989cdf0e10cSrcweir task::InteractionClassification_ERROR, 2990cdf0e10cSrcweir e.getData() ); 2991cdf0e10cSrcweir break; 2992cdf0e10cSrcweir } 2993cdf0e10cSrcweir 2994cdf0e10cSrcweir case DAVException::DAV_HTTP_LOOKUP: 2995cdf0e10cSrcweir aException <<= 2996cdf0e10cSrcweir ucb::InteractiveNetworkResolveNameException( 2997cdf0e10cSrcweir rtl::OUString(), 2998cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 2999cdf0e10cSrcweir task::InteractionClassification_ERROR, 3000cdf0e10cSrcweir e.getData() ); 3001cdf0e10cSrcweir break; 3002cdf0e10cSrcweir 3003cdf0e10cSrcweir // @@@ No matching InteractiveNetwork*Exception 3004cdf0e10cSrcweir // case DAVException::DAV_HTTP_AUTH: 3005cdf0e10cSrcweir // break; 3006cdf0e10cSrcweir 3007cdf0e10cSrcweir // @@@ No matching InteractiveNetwork*Exception 3008cdf0e10cSrcweir // case DAVException::DAV_HTTP_AUTHPROXY: 3009cdf0e10cSrcweir // break; 3010cdf0e10cSrcweir 3011cdf0e10cSrcweir case DAVException::DAV_HTTP_CONNECT: 3012cdf0e10cSrcweir aException <<= 3013cdf0e10cSrcweir ucb::InteractiveNetworkConnectException( 3014cdf0e10cSrcweir rtl::OUString(), 3015cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 3016cdf0e10cSrcweir task::InteractionClassification_ERROR, 3017cdf0e10cSrcweir e.getData() ); 3018cdf0e10cSrcweir break; 3019cdf0e10cSrcweir 3020cdf0e10cSrcweir // @@@ No matching InteractiveNetwork*Exception 3021cdf0e10cSrcweir // case DAVException::DAV_HTTP_TIMEOUT: 3022cdf0e10cSrcweir // break; 3023cdf0e10cSrcweir 3024cdf0e10cSrcweir // @@@ No matching InteractiveNetwork*Exception 3025cdf0e10cSrcweir // case DAVException::DAV_HTTP_REDIRECT: 3026cdf0e10cSrcweir // break; 3027cdf0e10cSrcweir 3028cdf0e10cSrcweir // @@@ No matching InteractiveNetwork*Exception 3029cdf0e10cSrcweir // case DAVException::DAV_SESSION_CREATE: 3030cdf0e10cSrcweir // break; 3031cdf0e10cSrcweir 3032cdf0e10cSrcweir case DAVException::DAV_INVALID_ARG: 3033cdf0e10cSrcweir aException <<= 3034cdf0e10cSrcweir lang::IllegalArgumentException( 3035cdf0e10cSrcweir rtl::OUString(), 3036cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 3037cdf0e10cSrcweir -1 ); 3038cdf0e10cSrcweir break; 3039cdf0e10cSrcweir 3040cdf0e10cSrcweir case DAVException::DAV_LOCKED: 3041cdf0e10cSrcweir #if 1 3042cdf0e10cSrcweir aException <<= 3043cdf0e10cSrcweir ucb::InteractiveLockingLockedException( 3044cdf0e10cSrcweir rtl::OUString::createFromAscii( "Locked!" ), 3045cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 3046cdf0e10cSrcweir task::InteractionClassification_ERROR, 3047cdf0e10cSrcweir aURL, 3048cdf0e10cSrcweir sal_False ); // not SelfOwned 3049cdf0e10cSrcweir #else 3050cdf0e10cSrcweir { 3051cdf0e10cSrcweir uno::Sequence< uno::Any > aArgs( 1 ); 3052cdf0e10cSrcweir aArgs[ 0 ] <<= beans::PropertyValue( 3053cdf0e10cSrcweir rtl::OUString::createFromAscii("Uri"), -1, 3054cdf0e10cSrcweir uno::makeAny(aURL), 3055cdf0e10cSrcweir beans::PropertyState_DIRECT_VALUE); 3056cdf0e10cSrcweir 3057cdf0e10cSrcweir aException <<= 3058cdf0e10cSrcweir ucb::InteractiveAugmentedIOException( 3059cdf0e10cSrcweir rtl::OUString::createFromAscii( "Locked!" ), 3060cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 3061cdf0e10cSrcweir task::InteractionClassification_ERROR, 3062cdf0e10cSrcweir ucb::IOErrorCode_LOCKING_VIOLATION, 3063cdf0e10cSrcweir aArgs ); 3064cdf0e10cSrcweir } 3065cdf0e10cSrcweir #endif 3066cdf0e10cSrcweir break; 3067cdf0e10cSrcweir 3068cdf0e10cSrcweir case DAVException::DAV_LOCKED_SELF: 3069cdf0e10cSrcweir aException <<= 3070cdf0e10cSrcweir ucb::InteractiveLockingLockedException( 3071cdf0e10cSrcweir rtl::OUString::createFromAscii( "Locked (self)!" ), 3072cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 3073cdf0e10cSrcweir task::InteractionClassification_ERROR, 3074cdf0e10cSrcweir aURL, 3075cdf0e10cSrcweir sal_True ); // SelfOwned 3076cdf0e10cSrcweir break; 3077cdf0e10cSrcweir 3078cdf0e10cSrcweir case DAVException::DAV_NOT_LOCKED: 3079cdf0e10cSrcweir aException <<= 3080cdf0e10cSrcweir ucb::InteractiveLockingNotLockedException( 3081cdf0e10cSrcweir rtl::OUString::createFromAscii( "Not locked!" ), 3082cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 3083cdf0e10cSrcweir task::InteractionClassification_ERROR, 3084cdf0e10cSrcweir aURL ); 3085cdf0e10cSrcweir break; 3086cdf0e10cSrcweir 3087cdf0e10cSrcweir case DAVException::DAV_LOCK_EXPIRED: 3088cdf0e10cSrcweir aException <<= 3089cdf0e10cSrcweir ucb::InteractiveLockingLockExpiredException( 3090cdf0e10cSrcweir rtl::OUString::createFromAscii( "Lock expired!" ), 3091cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 3092cdf0e10cSrcweir task::InteractionClassification_ERROR, 3093cdf0e10cSrcweir aURL ); 3094cdf0e10cSrcweir break; 3095cdf0e10cSrcweir 3096cdf0e10cSrcweir default: 3097cdf0e10cSrcweir aException <<= 3098cdf0e10cSrcweir ucb::InteractiveNetworkGeneralException( 3099cdf0e10cSrcweir rtl::OUString(), 3100cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 3101cdf0e10cSrcweir task::InteractionClassification_ERROR ); 3102cdf0e10cSrcweir break; 3103cdf0e10cSrcweir } 3104cdf0e10cSrcweir 3105cdf0e10cSrcweir return aException; 3106cdf0e10cSrcweir } 3107cdf0e10cSrcweir 3108cdf0e10cSrcweir //========================================================================= 3109cdf0e10cSrcweir // static 3110cdf0e10cSrcweir bool Content::shouldAccessNetworkAfterException( const DAVException & e ) 3111cdf0e10cSrcweir { 3112cdf0e10cSrcweir if ( ( e.getStatus() == SC_NOT_FOUND ) || 3113cdf0e10cSrcweir ( e.getError() == DAVException::DAV_HTTP_LOOKUP ) || 3114cdf0e10cSrcweir ( e.getError() == DAVException::DAV_HTTP_CONNECT ) || 3115cdf0e10cSrcweir ( e.getError() == DAVException::DAV_HTTP_AUTH ) || 3116cdf0e10cSrcweir ( e.getError() == DAVException::DAV_HTTP_AUTHPROXY ) ) 3117cdf0e10cSrcweir return false; 3118cdf0e10cSrcweir 3119cdf0e10cSrcweir return true; 3120cdf0e10cSrcweir } 3121cdf0e10cSrcweir 3122cdf0e10cSrcweir //========================================================================= 3123cdf0e10cSrcweir void Content::cancelCommandExecution( 3124cdf0e10cSrcweir const DAVException & e, 3125cdf0e10cSrcweir const uno::Reference< ucb::XCommandEnvironment > & xEnv, 3126cdf0e10cSrcweir sal_Bool bWrite /* = sal_False */ ) 3127cdf0e10cSrcweir throw ( uno::Exception ) 3128cdf0e10cSrcweir { 3129cdf0e10cSrcweir ucbhelper::cancelCommandExecution( MapDAVException( e, bWrite ), xEnv ); 3130cdf0e10cSrcweir // Unreachable 3131cdf0e10cSrcweir } 3132cdf0e10cSrcweir 3133cdf0e10cSrcweir //========================================================================= 3134cdf0e10cSrcweir const rtl::OUString 3135cdf0e10cSrcweir Content::getBaseURI( const std::auto_ptr< DAVResourceAccess > & rResAccess ) 3136cdf0e10cSrcweir { 3137cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 3138cdf0e10cSrcweir 3139cdf0e10cSrcweir // First, try to obtain value of response header "Content-Location". 3140cdf0e10cSrcweir if ( m_xCachedProps.get() ) 3141cdf0e10cSrcweir { 3142cdf0e10cSrcweir rtl::OUString aLocation; 3143cdf0e10cSrcweir m_xCachedProps->getValue( rtl::OUString( 3144cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( 3145cdf0e10cSrcweir "Content-Location" ) ) ) >>= aLocation; 3146cdf0e10cSrcweir if ( aLocation.getLength() ) 3147cdf0e10cSrcweir { 3148cdf0e10cSrcweir try 3149cdf0e10cSrcweir { 3150cdf0e10cSrcweir // Do not use m_xIdentifier->getContentIdentifier() because it 3151cdf0e10cSrcweir // for example does not reflect redirects applied to requests 3152cdf0e10cSrcweir // done using the original URI but m_xResAccess' URI does. 3153cdf0e10cSrcweir return rtl::Uri::convertRelToAbs( rResAccess->getURL(), 3154cdf0e10cSrcweir aLocation ); 3155cdf0e10cSrcweir } 3156cdf0e10cSrcweir catch ( rtl::MalformedUriException const & ) 3157cdf0e10cSrcweir { 3158cdf0e10cSrcweir } 3159cdf0e10cSrcweir } 3160cdf0e10cSrcweir } 3161cdf0e10cSrcweir 3162cdf0e10cSrcweir return rtl::OUString( rResAccess->getURL() ); 3163cdf0e10cSrcweir } 3164cdf0e10cSrcweir 3165cdf0e10cSrcweir //========================================================================= 3166cdf0e10cSrcweir const Content::ResourceType & Content::getResourceType( 3167cdf0e10cSrcweir const uno::Reference< ucb::XCommandEnvironment >& xEnv, 3168cdf0e10cSrcweir const std::auto_ptr< DAVResourceAccess > & rResAccess ) 3169cdf0e10cSrcweir throw ( uno::Exception ) 3170cdf0e10cSrcweir { 3171cdf0e10cSrcweir if ( m_eResourceType == UNKNOWN ) 3172cdf0e10cSrcweir { 3173cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 3174cdf0e10cSrcweir 3175cdf0e10cSrcweir ResourceType eResourceType; 3176cdf0e10cSrcweir eResourceType = m_eResourceType; 3177cdf0e10cSrcweir 3178cdf0e10cSrcweir const rtl::OUString & rURL = rResAccess->getURL(); 3179cdf0e10cSrcweir const rtl::OUString aScheme( 3180cdf0e10cSrcweir rURL.copy( 0, rURL.indexOf( ':' ) ).toAsciiLowerCase() ); 3181cdf0e10cSrcweir 3182cdf0e10cSrcweir try 3183cdf0e10cSrcweir { 3184cdf0e10cSrcweir // Try to fetch some frequently used property value, e.g. those 3185cdf0e10cSrcweir // used when loading documents... along with identifying whether 3186cdf0e10cSrcweir // this is a DAV resource. 3187cdf0e10cSrcweir std::vector< DAVResource > resources; 3188cdf0e10cSrcweir std::vector< rtl::OUString > aPropNames; 3189cdf0e10cSrcweir uno::Sequence< beans::Property > aProperties( 5 ); 3190cdf0e10cSrcweir aProperties[ 0 ].Name 3191cdf0e10cSrcweir = rtl::OUString::createFromAscii( "IsFolder" ); 3192cdf0e10cSrcweir aProperties[ 1 ].Name 3193cdf0e10cSrcweir = rtl::OUString::createFromAscii( "IsDocument" ); 3194cdf0e10cSrcweir aProperties[ 2 ].Name 3195cdf0e10cSrcweir = rtl::OUString::createFromAscii( "IsReadOnly" ); 3196cdf0e10cSrcweir aProperties[ 3 ].Name 3197cdf0e10cSrcweir = rtl::OUString::createFromAscii( "MediaType" ); 3198cdf0e10cSrcweir aProperties[ 4 ].Name 3199cdf0e10cSrcweir = DAVProperties::SUPPORTEDLOCK; 3200cdf0e10cSrcweir 3201cdf0e10cSrcweir ContentProperties::UCBNamesToDAVNames( 3202cdf0e10cSrcweir aProperties, aPropNames ); 3203cdf0e10cSrcweir 3204cdf0e10cSrcweir rResAccess->PROPFIND( 3205cdf0e10cSrcweir DAVZERO, aPropNames, resources, xEnv ); 3206cdf0e10cSrcweir 3207*59ddfc10SAndre Fischer // TODO - is this really only one? 3208cdf0e10cSrcweir if ( resources.size() == 1 ) 3209cdf0e10cSrcweir { 3210cdf0e10cSrcweir m_xCachedProps.reset( 3211cdf0e10cSrcweir new CachableContentProperties( resources[ 0 ] ) ); 3212cdf0e10cSrcweir m_xCachedProps->containsAllNames( 3213cdf0e10cSrcweir aProperties, m_aFailedPropNames ); 3214cdf0e10cSrcweir } 3215cdf0e10cSrcweir 3216cdf0e10cSrcweir eResourceType = DAV; 3217cdf0e10cSrcweir } 3218cdf0e10cSrcweir catch ( DAVException const & e ) 3219cdf0e10cSrcweir { 3220cdf0e10cSrcweir rResAccess->resetUri(); 3221cdf0e10cSrcweir 3222cdf0e10cSrcweir if ( e.getStatus() == SC_METHOD_NOT_ALLOWED ) 3223cdf0e10cSrcweir { 3224cdf0e10cSrcweir // Status SC_METHOD_NOT_ALLOWED is a safe indicator that the 3225cdf0e10cSrcweir // resource is NON_DAV 3226cdf0e10cSrcweir eResourceType = NON_DAV; 3227cdf0e10cSrcweir } 3228cdf0e10cSrcweir } 3229cdf0e10cSrcweir m_eResourceType = eResourceType; 3230cdf0e10cSrcweir } 3231cdf0e10cSrcweir return m_eResourceType; 3232cdf0e10cSrcweir } 3233cdf0e10cSrcweir 3234cdf0e10cSrcweir //========================================================================= 3235cdf0e10cSrcweir const Content::ResourceType & Content::getResourceType( 3236cdf0e10cSrcweir const uno::Reference< ucb::XCommandEnvironment >& xEnv ) 3237cdf0e10cSrcweir throw ( uno::Exception ) 3238cdf0e10cSrcweir { 3239cdf0e10cSrcweir return getResourceType( xEnv, m_xResAccess ); 3240cdf0e10cSrcweir } 3241