diff options
Diffstat (limited to 'ucb/source/ucp/webdav/webdavcontent.cxx')
-rw-r--r-- | ucb/source/ucp/webdav/webdavcontent.cxx | 1556 |
1 files changed, 982 insertions, 574 deletions
diff --git a/ucb/source/ucp/webdav/webdavcontent.cxx b/ucb/source/ucp/webdav/webdavcontent.cxx index 060d1e2b92f3..1679f9bf8a53 100644 --- a/ucb/source/ucp/webdav/webdavcontent.cxx +++ b/ucb/source/ucp/webdav/webdavcontent.cxx @@ -2,9 +2,9 @@ * * $RCSfile: webdavcontent.cxx,v $ * - * $Revision: 1.21 $ + * $Revision: 1.22 $ * - * last change: $Author: kso $ $Date: 2001-06-18 08:22:51 $ + * last change: $Author: kso $ $Date: 2001-06-25 08:51:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -93,9 +93,30 @@ #ifndef _COM_SUN_STAR_UCB_INTERACTIVEBADTRANSFRERURLEXCEPTION_HPP_ #include <com/sun/star/ucb/InteractiveBadTransferURLException.hpp> #endif +#ifndef _COM_SUN_STAR_UCB_INTERACTIVEIOEXCEPTION_HPP_ +#include <com/sun/star/ucb/InteractiveIOException.hpp> +#endif +#ifndef _COM_SUN_STAR_UCB_INTERACTIVENETWORKCONNECTEXCEPTION_HPP_ +#include <com/sun/star/ucb/InteractiveNetworkConnectException.hpp> +#endif +#ifndef _COM_SUN_STAR_UCB_INTERACTIVENETWORKGENBERALEXCEPTION_HPP_ +#include <com/sun/star/ucb/InteractiveNetworkGeneralException.hpp> +#endif +#ifndef _COM_SUN_STAR_UCB_INTERACTIVENETWORKREADEXCEPTION_HPP_ +#include <com/sun/star/ucb/InteractiveNetworkReadException.hpp> +#endif +#ifndef _COM_SUN_STAR_UCB_INTERACTIVENETWORKRESOLVENAMEEXCEPTION_HPP_ +#include <com/sun/star/ucb/InteractiveNetworkResolveNameException.hpp> +#endif +#ifndef _COM_SUN_STAR_UCB_INTERACTIVENETWORKWRITEEXCEPTION_HPP_ +#include <com/sun/star/ucb/InteractiveNetworkWriteException.hpp> +#endif #ifndef _COM_SUN_STAR_UCB_NAMECLASH_HPP_ #include <com/sun/star/ucb/NameClash.hpp> #endif +#ifndef _COM_SUN_STAR_UCB_NAMECLASHEXCEPTION_HPP_ +#include <com/sun/star/ucb/NameClashException.hpp> +#endif #ifndef _COM_SUN_STAR_UCB_OPENCOMMANDARGUMENT2_HPP_ #include <com/sun/star/ucb/OpenCommandArgument2.hpp> #endif @@ -111,6 +132,24 @@ #ifndef _COM_SUN_STAR_UCB_XPERSISTENTPROPERTYSET_HPP_ #include <com/sun/star/ucb/XPersistentPropertySet.hpp> #endif +#ifndef _COM_SUN_STAR_UCB_MISSINGINPUTSTREAMEXCEPTION_HPP_ +#include <com/sun/star/ucb/MissingInputStreamException.hpp> +#endif +#ifndef _COM_SUN_STAR_UCB_MISSINGPROPERTIESEXCEPTION_HPP_ +#include <com/sun/star/ucb/MissingPropertiesException.hpp> +#endif +#ifndef _COM_SUN_STAR_UCB_UNSUPPORTEDCOMMANDEXCEPTION_HPP_ +#include <com/sun/star/ucb/UnsupportedCommandException.hpp> +#endif +#ifndef _COM_SUN_STAR_UCB_UNSUPPORTEDDATASINKEXCEPTION_HPP_ +#include <com/sun/star/ucb/UnsupportedDataSinkException.hpp> +#endif +#ifndef _COM_SUN_STAR_UCB_UNSUPPORTEDNAMECLASHEXCEPTION_HPP_ +#include <com/sun/star/ucb/UnsupportedNameClashException.hpp> +#endif +#ifndef _COM_SUN_STAR_UCB_UNSUPPORTEDOPENMODEEXCEPTION_HPP_ +#include <com/sun/star/ucb/UnsupportedOpenModeException.hpp> +#endif #ifndef _UCBHELPER_CONTENTIDENTIFIER_HXX #include <ucbhelper/contentidentifier.hxx> @@ -118,6 +157,12 @@ #ifndef _UCBHELPER_PROPERTYVALUESET_HXX #include <ucbhelper/propertyvalueset.hxx> #endif +#ifndef _UCBHELPER_INTERACTIONREQUEST_HXX +#include <ucbhelper/interactionrequest.hxx> +#endif +#ifndef _UCBHELPER_CANCELCOMMANDEXECUTION_HXX_ +#include <ucbhelper/cancelcommandexecution.hxx> +#endif #ifndef _WEBDAV_UCP_CONTENT_HXX #include "webdavcontent.hxx" @@ -138,17 +183,8 @@ #include "UCBDeadPropertyValue.hxx" #endif -using namespace com::sun::star::container; -using namespace com::sun::star::beans; -using namespace com::sun::star::util; -using namespace com::sun::star::lang; -using namespace com::sun::star::sdbc; -using namespace com::sun::star::ucb; -using namespace com::sun::star::uno; -using namespace com::sun::star::io; -using namespace cppu; -using namespace rtl; - +using namespace com::sun; +using namespace com::sun::star; using namespace webdav_ucp; //========================================================================= @@ -161,11 +197,12 @@ using namespace webdav_ucp; //========================================================================= // ctr for content on an existing webdav resource -Content::Content( const Reference< XMultiServiceFactory >& rxSMgr, - ContentProvider* pProvider, - const Reference< XContentIdentifier >& Identifier, - DAVSessionFactory* pSessionFactory ) - throw ( ContentCreationException ) +Content::Content( + const uno::Reference< lang::XMultiServiceFactory >& rxSMgr, + ContentProvider* pProvider, + const uno::Reference< star::ucb::XContentIdentifier >& Identifier, + DAVSessionFactory* pSessionFactory ) + throw ( star::ucb::ContentCreationException ) : ContentImplHelper( rxSMgr, pProvider, Identifier ), m_pProvider( pProvider ), m_bTransient( sal_False ), @@ -178,7 +215,7 @@ Content::Content( const Reference< XMultiServiceFactory >& rxSMgr, } catch ( DAVException const & ) { - throw ContentCreationException(); + throw star::ucb::ContentCreationException(); } NeonUri aURI( Identifier->getContentIdentifier() ); @@ -187,12 +224,13 @@ Content::Content( const Reference< XMultiServiceFactory >& rxSMgr, //========================================================================= // ctr for content on an non-existing webdav resource -Content::Content( const Reference< XMultiServiceFactory >& rxSMgr, - ContentProvider* pProvider, - const Reference< XContentIdentifier >& Identifier, - DAVSessionFactory* pSessionFactory, - sal_Bool isCollection ) - throw ( ContentCreationException ) +Content::Content( + const uno::Reference< lang::XMultiServiceFactory >& rxSMgr, + ContentProvider* pProvider, + const uno::Reference< star::ucb::XContentIdentifier >& Identifier, + DAVSessionFactory* pSessionFactory, + sal_Bool isCollection ) + throw ( star::ucb::ContentCreationException ) : ContentImplHelper( rxSMgr, pProvider, Identifier, sal_False ), m_pProvider( pProvider ), m_bTransient( sal_True ), @@ -205,7 +243,7 @@ Content::Content( const Reference< XMultiServiceFactory >& rxSMgr, } catch ( DAVException const & ) { - throw ContentCreationException(); + throw star::ucb::ContentCreationException(); } // Do not set m_aEscapedTitle here! Content::insert relays on this!!! @@ -225,7 +263,7 @@ Content::~Content() // virtual void SAL_CALL Content::acquire() - throw( RuntimeException ) + throw( uno::RuntimeException ) { ContentImplHelper::acquire(); } @@ -233,22 +271,24 @@ void SAL_CALL Content::acquire() //========================================================================= // virtual void SAL_CALL Content::release() - throw( RuntimeException ) + throw( uno::RuntimeException ) { ContentImplHelper::release(); } //========================================================================= // virtual -Any SAL_CALL Content::queryInterface( const Type & rType ) - throw ( RuntimeException ) +uno::Any SAL_CALL Content::queryInterface( const uno::Type & rType ) + throw ( uno::RuntimeException ) { // Note: isFolder may require network activities! So call it only // if it is really necessary!!! - Any aRet = cppu::queryInterface( rType, - static_cast< XContentCreator * >( this ) ); + uno::Any aRet = cppu::queryInterface( rType, + static_cast< star::ucb::XContentCreator * >( this ) ); if ( aRet.hasValue() ) - return isFolder( Reference< XCommandEnvironment >() ) ? aRet : Any(); + return isFolder( uno::Reference< star::ucb::XCommandEnvironment >() ) + ? aRet + : uno::Any(); return aRet.hasValue() ? aRet : ContentImplHelper::queryInterface( rType ); } @@ -263,45 +303,46 @@ XTYPEPROVIDER_COMMON_IMPL( Content ); //========================================================================= // virtual -Sequence< Type > SAL_CALL Content::getTypes() - throw( RuntimeException ) +uno::Sequence< uno::Type > SAL_CALL Content::getTypes() + throw( uno::RuntimeException ) { - static OTypeCollection* pCollection = NULL; + static cppu::OTypeCollection* pCollection = NULL; if ( !pCollection ) { osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); if ( !pCollection ) { - if ( isFolder( Reference< XCommandEnvironment >() ) ) + if ( isFolder( + uno::Reference< star::ucb::XCommandEnvironment >() ) ) { - static OTypeCollection aCollection( - CPPU_TYPE_REF( XTypeProvider ), - CPPU_TYPE_REF( XServiceInfo ), - CPPU_TYPE_REF( XComponent ), - CPPU_TYPE_REF( XContent ), - CPPU_TYPE_REF( XCommandProcessor ), - CPPU_TYPE_REF( XPropertiesChangeNotifier ), - CPPU_TYPE_REF( XCommandInfoChangeNotifier ), - CPPU_TYPE_REF( XPropertyContainer ), - CPPU_TYPE_REF( XPropertySetInfoChangeNotifier ), - CPPU_TYPE_REF( XChild ), - CPPU_TYPE_REF( XContentCreator ) ); // !! + static cppu::OTypeCollection aCollection( + CPPU_TYPE_REF( lang::XTypeProvider ), + CPPU_TYPE_REF( lang::XServiceInfo ), + CPPU_TYPE_REF( lang::XComponent ), + CPPU_TYPE_REF( star::ucb::XContent ), + CPPU_TYPE_REF( star::ucb::XCommandProcessor ), + CPPU_TYPE_REF( beans::XPropertiesChangeNotifier ), + CPPU_TYPE_REF( star::ucb::XCommandInfoChangeNotifier ), + CPPU_TYPE_REF( beans::XPropertyContainer ), + CPPU_TYPE_REF( beans::XPropertySetInfoChangeNotifier ), + CPPU_TYPE_REF( container::XChild ), + CPPU_TYPE_REF( star::ucb::XContentCreator ) ); // !! pCollection = &aCollection; } else { - static OTypeCollection aCollection( - CPPU_TYPE_REF( XTypeProvider ), - CPPU_TYPE_REF( XServiceInfo ), - CPPU_TYPE_REF( XComponent ), - CPPU_TYPE_REF( XContent ), - CPPU_TYPE_REF( XCommandProcessor ), - CPPU_TYPE_REF( XPropertiesChangeNotifier ), - CPPU_TYPE_REF( XCommandInfoChangeNotifier ), - CPPU_TYPE_REF( XPropertyContainer ), - CPPU_TYPE_REF( XPropertySetInfoChangeNotifier ), - CPPU_TYPE_REF( XChild ) ); + static cppu::OTypeCollection aCollection( + CPPU_TYPE_REF( lang::XTypeProvider ), + CPPU_TYPE_REF( lang::XServiceInfo ), + CPPU_TYPE_REF( lang::XComponent ), + CPPU_TYPE_REF( star::ucb::XContent ), + CPPU_TYPE_REF( star::ucb::XCommandProcessor ), + CPPU_TYPE_REF( beans::XPropertiesChangeNotifier ), + CPPU_TYPE_REF( star::ucb::XCommandInfoChangeNotifier ), + CPPU_TYPE_REF( beans::XPropertyContainer ), + CPPU_TYPE_REF( beans::XPropertySetInfoChangeNotifier ), + CPPU_TYPE_REF( container::XChild ) ); pCollection = &aCollection; } } @@ -316,20 +357,21 @@ Sequence< Type > SAL_CALL Content::getTypes() //========================================================================= // virtual -OUString SAL_CALL Content::getImplementationName() - throw( RuntimeException ) +rtl::OUString SAL_CALL Content::getImplementationName() + throw( uno::RuntimeException ) { - return OUString::createFromAscii( "com.sun.star.comp.ucb.WebDAVContent" ); + return rtl::OUString::createFromAscii( + "com.sun.star.comp.ucb.WebDAVContent" ); } //========================================================================= // virtual -Sequence< OUString > SAL_CALL Content::getSupportedServiceNames() - throw( RuntimeException ) +uno::Sequence< rtl::OUString > SAL_CALL Content::getSupportedServiceNames() + throw( uno::RuntimeException ) { - Sequence< OUString > aSNS( 1 ); + uno::Sequence< rtl::OUString > aSNS( 1 ); aSNS.getArray()[ 0 ] - = OUString::createFromAscii( WEBDAV_CONTENT_SERVICE_NAME ); + = rtl::OUString::createFromAscii( WEBDAV_CONTENT_SERVICE_NAME ); return aSNS; } @@ -340,13 +382,13 @@ Sequence< OUString > SAL_CALL Content::getSupportedServiceNames() //========================================================================= // virtual -OUString SAL_CALL Content::getContentType() - throw( RuntimeException ) +rtl::OUString SAL_CALL Content::getContentType() + throw( uno::RuntimeException ) { - if ( isFolder( Reference< XCommandEnvironment >() ) ) - return OUString::createFromAscii( WEBDAV_COLLECTION_TYPE ); + if ( isFolder( uno::Reference< star::ucb::XCommandEnvironment >() ) ) + return rtl::OUString::createFromAscii( WEBDAV_COLLECTION_TYPE ); - return OUString::createFromAscii( WEBDAV_CONTENT_TYPE ); + return rtl::OUString::createFromAscii( WEBDAV_CONTENT_TYPE ); } //========================================================================= @@ -356,13 +398,15 @@ OUString SAL_CALL Content::getContentType() //========================================================================= // virtual -Any SAL_CALL Content::execute( const Command& aCommand, - sal_Int32 CommandId, - const Reference< - XCommandEnvironment >& Environment ) - throw( Exception, CommandAbortedException, RuntimeException ) +uno::Any SAL_CALL Content::execute( + const star::ucb::Command& aCommand, + sal_Int32 CommandId, + const uno::Reference< star::ucb::XCommandEnvironment >& Environment ) + throw( uno::Exception, + star::ucb::CommandAbortedException, + uno::RuntimeException ) { - Any aRet; + uno::Any aRet; if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "getPropertyValues" ) ) ) @@ -371,11 +415,17 @@ Any SAL_CALL Content::execute( const Command& aCommand, // getPropertyValues ////////////////////////////////////////////////////////////////// - Sequence< Property > Properties; + uno::Sequence< beans::Property > Properties; if ( !( aCommand.Argument >>= Properties ) ) { - OSL_ENSURE( sal_False, "Wrong argument type!" ); - return Any(); + ucbhelper::cancelCommandExecution( + uno::makeAny( lang::IllegalArgumentException( + rtl::OUString::createFromAscii( + "Wrong argument type!" ), + static_cast< cppu::OWeakObject * >( this ), + -1 ) ), + Environment ); + // Unreachable } aRet <<= getPropertyValues( Properties, Environment ); @@ -387,17 +437,29 @@ Any SAL_CALL Content::execute( const Command& aCommand, // setPropertyValues ////////////////////////////////////////////////////////////////// - Sequence< PropertyValue > aProperties; + uno::Sequence< beans::PropertyValue > aProperties; if ( !( aCommand.Argument >>= aProperties ) ) { - OSL_ENSURE( sal_False, "Wrong argument type!" ); - return Any(); + ucbhelper::cancelCommandExecution( + uno::makeAny( lang::IllegalArgumentException( + rtl::OUString::createFromAscii( + "Wrong argument type!" ), + static_cast< cppu::OWeakObject * >( this ), + -1 ) ), + Environment ); + // Unreachable } if ( !aProperties.getLength() ) { - OSL_ENSURE( sal_False, "No properties!" ); - return Any(); + ucbhelper::cancelCommandExecution( + uno::makeAny( lang::IllegalArgumentException( + rtl::OUString::createFromAscii( + "No properties!" ), + static_cast< cppu::OWeakObject * >( this ), + -1 ) ), + Environment ); + // Unreachable } setPropertyValues( aProperties, Environment ); @@ -430,89 +492,106 @@ Any SAL_CALL Content::execute( const Command& aCommand, // open ////////////////////////////////////////////////////////////////// - OpenCommandArgument2 aOpenCommand; - if ( aCommand.Argument >>= aOpenCommand ) + star::ucb::OpenCommandArgument2 aOpenCommand; + if ( !( aCommand.Argument >>= aOpenCommand ) ) { - sal_Bool bOpenFolder = - ( ( aOpenCommand.Mode == OpenMode::ALL ) || - ( aOpenCommand.Mode == OpenMode::FOLDERS ) || - ( aOpenCommand.Mode == OpenMode::DOCUMENTS ) ); + ucbhelper::cancelCommandExecution( + uno::makeAny( lang::IllegalArgumentException( + rtl::OUString::createFromAscii( + "Wrong argument type!" ), + static_cast< cppu::OWeakObject * >( this ), + -1 ) ), + Environment ); + // Unreachable + } - if ( bOpenFolder && isFolder( Environment ) ) - { - // Open collection. - - Reference< XDynamicResultSet > xSet - = new DynamicResultSet( m_xSMgr, - this, - aOpenCommand, - Environment ); - aRet <<= xSet; - } + sal_Bool bOpenFolder = + ( ( aOpenCommand.Mode == star::ucb::OpenMode::ALL ) || + ( aOpenCommand.Mode == star::ucb::OpenMode::FOLDERS ) || + ( aOpenCommand.Mode == star::ucb::OpenMode::DOCUMENTS ) ); - if ( aOpenCommand.Sink.is() ) + if ( bOpenFolder && isFolder( Environment ) ) + { + // Open collection. + + uno::Reference< star::ucb::XDynamicResultSet > xSet + = new DynamicResultSet( + m_xSMgr, this, aOpenCommand, Environment ); + aRet <<= xSet; + } + + if ( aOpenCommand.Sink.is() ) + { + // Open document. + + if ( ( aOpenCommand.Mode + == star::ucb::OpenMode::DOCUMENT_SHARE_DENY_NONE ) || + ( aOpenCommand.Mode + == star::ucb::OpenMode::DOCUMENT_SHARE_DENY_WRITE ) ) { - // Open document. + // Currently(?) unsupported. + ucbhelper::cancelCommandExecution( + uno::makeAny( + star::ucb::UnsupportedOpenModeException( + rtl::OUString(), + static_cast< cppu::OWeakObject * >( this ), + sal_Int16( aOpenCommand.Mode ) ) ), + Environment ); + // Unreachable + } - if ( ( aOpenCommand.Mode - == OpenMode::DOCUMENT_SHARE_DENY_NONE ) || - ( aOpenCommand.Mode - == OpenMode::DOCUMENT_SHARE_DENY_WRITE ) ) + rtl::OUString aURL = m_xIdentifier->getContentIdentifier(); + uno::Reference< io::XOutputStream > xOut + = uno::Reference< io::XOutputStream >( + aOpenCommand.Sink, uno::UNO_QUERY ); + if ( xOut.is() ) + { + // PUSH: write data + try { - // Currently(?) unsupported. - throw CommandAbortedException(); + m_aResAccess.GET( xOut, Environment ); } - - OUString aURL = m_xIdentifier->getContentIdentifier(); - Reference< XOutputStream > xOut - = Reference< XOutputStream >(aOpenCommand.Sink, UNO_QUERY ); - if ( xOut.is() ) - { - // PUSH: write data + catch ( DAVException const & e ) + { + cancelCommandExecution( e, Environment ); + // Unreachable + } + } + else + { + uno::Reference< io::XActiveDataSink > xDataSink + = uno::Reference< io::XActiveDataSink >( + aOpenCommand.Sink, uno::UNO_QUERY ); + if ( xDataSink.is() ) + { + // PULL: wait for client read try { - m_aResAccess.GET( xOut, Environment ); + uno::Reference< io::XInputStream > xIn + = m_aResAccess.GET( Environment ); + xDataSink->setInputStream( xIn ); } - catch ( DAVException const & ) + catch ( DAVException const & e ) { -// OSL_ENSURE( sal_False, "GET : DAVException" ); - throw CommandAbortedException(); + cancelCommandExecution( e, Environment ); + // Unreachable } - } + } else - { - Reference< XActiveDataSink > xDataSink - = Reference< XActiveDataSink >( - aOpenCommand.Sink, UNO_QUERY ); - if ( xDataSink.is() ) - { - // PULL: wait for client read - try - { - Reference< XInputStream > xIn - = m_aResAccess.GET( Environment ); - xDataSink->setInputStream( xIn ); - } - catch ( DAVException &) - { -// OSL_ENSURE( sal_False, "GET : DAVException" ); - throw CommandAbortedException(); - } - } - else - { - // Note: aOpenCommand.Sink may contain an XStream - // implementation. Support for this type of - // sink is optional... - throw CommandAbortedException(); - } - } - } - } - else - { - OSL_ENSURE( sal_False, "Content::execute - invalid parameter!" ); - throw CommandAbortedException(); + { + // Note: aOpenCommand.Sink may contain an XStream + // implementation. Support for this type of + // sink is optional... + ucbhelper::cancelCommandExecution( + uno::makeAny( + star::ucb::UnsupportedDataSinkException( + rtl::OUString(), + static_cast< cppu::OWeakObject * >( this ), + aOpenCommand.Sink ) ), + Environment ); + // Unreachable + } + } } } else if ( aCommand.Name.equalsAsciiL( @@ -522,11 +601,17 @@ Any SAL_CALL Content::execute( const Command& aCommand, // insert ////////////////////////////////////////////////////////////////// - InsertCommandArgument arg; + star::ucb::InsertCommandArgument arg; if ( !( aCommand.Argument >>= arg ) ) { - OSL_ENSURE( sal_False, "Wrong argument type!" ); - return Any(); + ucbhelper::cancelCommandExecution( + uno::makeAny( lang::IllegalArgumentException( + rtl::OUString::createFromAscii( + "Wrong argument type!" ), + static_cast< cppu::OWeakObject * >( this ), + -1 ) ), + Environment ); + // Unreachable } insert( arg.Data, arg.ReplaceExisting, Environment ); @@ -550,158 +635,42 @@ Any SAL_CALL Content::execute( const Command& aCommand, { m_aResAccess.DESTROY( Environment ); } - catch ( DAVException & ) + catch ( DAVException const & e ) { - OSL_ENSURE( sal_False, "DESTROY : DAVException" ); - throw CommandAbortedException(); + cancelCommandExecution( e, Environment, sal_True ); + // Unreachable } // } // Propagate destruction. destroy( bDeletePhysical ); -// DAV resources store all additional props on server! -// // Remove own and all children's Additional Core Properties. -// removeAdditionalPropertySet( sal_True ); + // Remove own and all children's Additional Core Properties. + removeAdditionalPropertySet( sal_True ); } else if ( aCommand.Name.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM( "transfer" ) ) ) + RTL_CONSTASCII_STRINGPARAM( "transfer" ) ) + && isFolder( Environment ) ) { - TransferInfo transferArgs; - if ( !( aCommand.Argument >>= transferArgs ) ) - throw CommandAbortedException(); - - if ( !isFolder( Environment ) ) - throw CommandAbortedException(); + ////////////////////////////////////////////////////////////////// + // transfer + // ( Not available at documents ) + ////////////////////////////////////////////////////////////////// - if ( transferArgs.NameClash == NameClash::KEEP || - transferArgs.NameClash == NameClash::RENAME ) + star::ucb::TransferInfo transferArgs; + if ( !( aCommand.Argument >>= transferArgs ) ) { - // @@@ RENAME and KEEP are not directly implemented - // by WebDAV methods. KEEP is deprecated and it - // is okay to abort in this case. - - throw CommandAbortedException(); + ucbhelper::cancelCommandExecution( + uno::makeAny( lang::IllegalArgumentException( + rtl::OUString::createFromAscii( + "Wrong argument type!" ), + static_cast< cppu::OWeakObject * >( this ), + -1 ) ), + Environment ); + // Unreachable } - try - { - NeonUri sourceURI( transferArgs.SourceURL ); - NeonUri targetURI( m_xIdentifier->getContentIdentifier() ); - - // Check source's and target's URL scheme - // - const OUString aScheme = sourceURI.GetScheme().toAsciiLowerCase(); - if ( aScheme.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM( WEBDAV_URL_SCHEME ) ) ) - { - sourceURI.SetScheme( - OUString::createFromAscii( HTTP_URL_SCHEME ) ); - } - else - { - if ( !aScheme.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM( HTTP_URL_SCHEME ) ) && - !aScheme.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM( HTTPS_URL_SCHEME ) ) ) - throw InteractiveBadTransferURLException(); - } - - if ( targetURI.GetScheme().toAsciiLowerCase().equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM( WEBDAV_URL_SCHEME ) ) ) - targetURI.SetScheme( - OUString::createFromAscii( HTTP_URL_SCHEME ) ); - - // @@@ This implementation of 'transfer' only works - // if the source and target are located at same host. - // (Neon does not support cross-server copy/move) - - // Check for same host - // - if ( sourceURI.GetHost().getLength() && - sourceURI.GetHost() != targetURI.GetHost() ) - throw InteractiveBadTransferURLException(); - - if ( !transferArgs.NewTitle.getLength() ) - transferArgs.NewTitle = sourceURI.GetPathBaseNameUnescaped(); - - if ( transferArgs.NewTitle.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM( "/" ) ) ) - throw CommandAbortedException(); - - targetURI.AppendPath( transferArgs.NewTitle ); - - OUString aTargetURL = m_xIdentifier->getContentIdentifier(); - if ( ( aTargetURL.lastIndexOf( '/' ) + 1 ) != aTargetURL.getLength() ) - aTargetURL += OUString::createFromAscii( "/" ); - - aTargetURL += transferArgs.NewTitle; - - Reference< XContentIdentifier > xTargetId - = new ::ucb::ContentIdentifier( m_xSMgr, aTargetURL ); - - Reference< XContentIdentifier > xId - = new ::ucb::ContentIdentifier( m_xSMgr, - transferArgs.SourceURL ); - - DAVResourceAccess aSourceAccess( m_xSMgr, - m_aResAccess.getSessionFactory(), - sourceURI.GetURI() ); - - if ( transferArgs.MoveData == sal_True ) - { - // Note: The static cast is okay here, because its sure that - // m_xProvider is always the WebDAVContentProvider. - vos::ORef< Content > xSource - = static_cast< Content * >( - m_xProvider->queryContent( xId ).get() ); - - aSourceAccess.MOVE( sourceURI.GetPath(), - targetURI.GetURI(), - transferArgs.NameClash - == NameClash::OVERWRITE, - Environment ); - - if ( xSource.isValid() ) - { - // Propagate destruction to listeners. - xSource->destroy( sal_True ); - } - -// DAV resources store all additional props on server! -// // Rename own and all children's Additional Core Properties. -// renameAdditionalPropertySet( xId->getContentIdentifier(), -// xTargetId->getContentIdentifier(), -// sal_True ); - } - else - { - aSourceAccess.COPY( sourceURI.GetPath(), - targetURI.GetURI(), - transferArgs.NameClash - == NameClash::OVERWRITE, - Environment ); - -// DAV resources store all additional props on server! -// // Copy own and all children's Additional Core Properties. -// copyAdditionalPropertySet( xId->getContentIdentifier(), -// xTargetId->getContentIdentifier(), -// sal_True ); - } - - // Note: The static cast is okay here, because its sure that - // m_xProvider is always the WebDAVContentProvider. - vos::ORef< Content > xTarget - = static_cast< Content * >( - m_xProvider->queryContent( xTargetId ).get() ); - - // Announce transfered content in its new folder. - xTarget->inserted(); - } - catch ( DAVException const & ) - { - throw CommandAbortedException(); - } + transfer( transferArgs, Environment ); } else { @@ -709,8 +678,12 @@ Any SAL_CALL Content::execute( const Command& aCommand, // Unsupported command ////////////////////////////////////////////////////////////////// - OSL_ENSURE( sal_False, "Content::execute - unsupported command!" ); - throw CommandAbortedException(); + ucbhelper::cancelCommandExecution( + uno::makeAny( star::ucb::UnsupportedCommandException( + rtl::OUString(), + static_cast< cppu::OWeakObject * >( this ) ) ), + Environment ); + // Unreachable } return aRet; @@ -719,7 +692,7 @@ Any SAL_CALL Content::execute( const Command& aCommand, //========================================================================= // virtual void SAL_CALL Content::abort( sal_Int32 CommandId ) - throw( RuntimeException ) + throw( uno::RuntimeException ) { // @@@ Implement logic to abort running commands, if this makes // sense for your content. @@ -732,12 +705,13 @@ void SAL_CALL Content::abort( sal_Int32 CommandId ) //========================================================================= // virtual -void SAL_CALL Content::addProperty( - const OUString& Name, sal_Int16 Attributes, const Any& DefaultValue ) - throw( PropertyExistException, - IllegalTypeException, - IllegalArgumentException, - RuntimeException ) +void SAL_CALL Content::addProperty( const rtl::OUString& Name, + sal_Int16 Attributes, + const uno::Any& DefaultValue ) + throw( beans::PropertyExistException, + beans::IllegalTypeException, + lang::IllegalArgumentException, + uno::RuntimeException ) { // if ( m_bTransient ) // @@@ ??? @@ -745,14 +719,14 @@ void SAL_CALL Content::addProperty( // osl::Guard< osl::Mutex > aGuard( m_aMutex ); if ( !Name.getLength() ) - throw IllegalArgumentException(); + throw lang::IllegalArgumentException(); // Check property type. if ( !UCBDeadPropertyValue::supportsType( DefaultValue.getValueType() ) ) { OSL_ENSURE( sal_False, "Content::addProperty - " "Unsupported property type!" ); - throw IllegalTypeException(); + throw beans::IllegalTypeException(); } ////////////////////////////////////////////////////////////////////// @@ -763,14 +737,14 @@ void SAL_CALL Content::addProperty( // @@@ Need real command environment here, but where to get it from? // XPropertyContainer interface should be replaced by // XCommandProcessor commands! - Reference< XCommandEnvironment > xEnv; + uno::Reference< star::ucb::XCommandEnvironment > xEnv; // Note: This requires network access! if ( getPropertySetInfo( xEnv, sal_False /* don't cache data */ ) ->hasPropertyByName( Name ) ) { // Property does already exist. - throw PropertyExistException(); + throw beans::PropertyExistException(); } ////////////////////////////////////////////////////////////////////// @@ -788,11 +762,11 @@ void SAL_CALL Content::addProperty( m_aResAccess.PROPPATCH( aProppatchValues, xEnv ); // Notify propertyset info change listeners. - PropertySetInfoChangeEvent evt( - static_cast< OWeakObject * >( this ), + beans::PropertySetInfoChangeEvent evt( + static_cast< cppu::OWeakObject * >( this ), Name, -1, // No handle available - PropertySetInfoChange::PROPERTY_INSERTED ); + beans::PropertySetInfoChange::PROPERTY_INSERTED ); notifyPropertySetInfoChange( evt ); } catch ( DAVException const & ) @@ -805,7 +779,7 @@ void SAL_CALL Content::addProperty( if ( caps.class1 ) { // DAV resource! - throw IllegalArgumentException(); + throw lang::IllegalArgumentException(); } else { @@ -818,40 +792,40 @@ void SAL_CALL Content::addProperty( } catch ( DAVException const & ) { - throw IllegalArgumentException(); + throw lang::IllegalArgumentException(); } } } //========================================================================= // virtual -void SAL_CALL Content::removeProperty( const OUString& Name ) - throw( UnknownPropertyException, - NotRemoveableException, - RuntimeException ) +void SAL_CALL Content::removeProperty( const rtl::OUString& Name ) + throw( beans::UnknownPropertyException, + beans::NotRemoveableException, + uno::RuntimeException ) { // osl::Guard< osl::Mutex > aGuard( m_aMutex ); // @@@ Need real command environment here, but where to get it from? // XPropertyContainer interface should be replaced by // XCommandProcessor commands! - Reference< XCommandEnvironment > xEnv; + uno::Reference< star::ucb::XCommandEnvironment > xEnv; #if 0 - // @@@ REMOVEABLE z.Z. nicht richtig and der PropSetInfo gesetzt!!! + // @@@ REMOVEABLE z.Z. nicht richtig an der PropSetInfo gesetzt!!! try { - Property aProp = getPropertySetInfo( xEnv, - sal_False /* don't cache data */ ) - ->getPropertyByName( Name ); + beans::Property aProp + = getPropertySetInfo( xEnv, sal_False /* don't cache data */ ) + ->getPropertyByName( Name ); - if ( !( aProp.Attributes & PropertyAttribute::REMOVEABLE ) ) + if ( !( aProp.Attributes & beans::PropertyAttribute::REMOVEABLE ) ) { // Not removeable! - throw NotRemoveableException(); + throw beans::NotRemoveableException(); } } - catch ( UnknownPropertyException const & ) + catch ( beans::UnknownPropertyException const & ) { // OSL_ENSURE( sal_False, "removeProperty - Unknown property!" ); throw; @@ -865,18 +839,18 @@ void SAL_CALL Content::removeProperty( const OUString& Name ) try { std::vector< ProppatchValue > aProppatchValues; - ProppatchValue aValue( PROPREMOVE, Name, Any() ); + ProppatchValue aValue( PROPREMOVE, Name, uno::Any() ); aProppatchValues.push_back( aValue ); // Remove property value from server. m_aResAccess.PROPPATCH( aProppatchValues, xEnv ); // Notify propertyset info change listeners. - PropertySetInfoChangeEvent evt( - static_cast< OWeakObject * >( this ), + beans::PropertySetInfoChangeEvent evt( + static_cast< cppu::OWeakObject * >( this ), Name, -1, // No handle available - PropertySetInfoChange::PROPERTY_REMOVED ); + beans::PropertySetInfoChange::PROPERTY_REMOVED ); notifyPropertySetInfoChange( evt ); } catch ( DAVException const & ) @@ -889,7 +863,7 @@ void SAL_CALL Content::removeProperty( const OUString& Name ) if ( caps.class1 ) { // DAV resource! - throw UnknownPropertyException(); + throw beans::UnknownPropertyException(); } else { @@ -901,7 +875,7 @@ void SAL_CALL Content::removeProperty( const OUString& Name ) } catch ( DAVException const & ) { - throw UnknownPropertyException(); + throw beans::UnknownPropertyException(); } } } @@ -913,37 +887,38 @@ void SAL_CALL Content::removeProperty( const OUString& Name ) //========================================================================= // virtual -Sequence< ContentInfo > SAL_CALL +uno::Sequence< star::ucb::ContentInfo > SAL_CALL Content::queryCreatableContentsInfo() - throw( RuntimeException ) + throw( uno::RuntimeException ) { // if ( isFolder() ) { osl::Guard< osl::Mutex > aGuard( m_aMutex ); - Sequence< ContentInfo > aSeq( 2 ); + uno::Sequence< star::ucb::ContentInfo > aSeq( 2 ); // document. aSeq.getArray()[ 0 ].Type - = OUString::createFromAscii( WEBDAV_CONTENT_TYPE ); + = rtl::OUString::createFromAscii( WEBDAV_CONTENT_TYPE ); aSeq.getArray()[ 0 ].Attributes - = ContentInfoAttribute::INSERT_WITH_INPUTSTREAM - | ContentInfoAttribute::KIND_DOCUMENT; + = star::ucb::ContentInfoAttribute::INSERT_WITH_INPUTSTREAM + | star::ucb::ContentInfoAttribute::KIND_DOCUMENT; - Property aProp; + beans::Property aProp; m_pProvider->getProperty( - OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ), aProp ); + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ), aProp ); - Sequence< Property > aDocProps( 1 ); + uno::Sequence< beans::Property > aDocProps( 1 ); aDocProps.getArray()[ 0 ] = aProp; aSeq.getArray()[ 0 ].Properties = aDocProps; // folder. aSeq.getArray()[ 1 ].Type - = OUString::createFromAscii( WEBDAV_COLLECTION_TYPE ); - aSeq.getArray()[ 1 ].Attributes = ContentInfoAttribute::KIND_FOLDER; + = rtl::OUString::createFromAscii( WEBDAV_COLLECTION_TYPE ); + aSeq.getArray()[ 1 ].Attributes + = star::ucb::ContentInfoAttribute::KIND_FOLDER; - Sequence< Property > aFolderProps( 1 ); + uno::Sequence< beans::Property > aFolderProps( 1 ); aFolderProps.getArray()[ 0 ] = aProp; aSeq.getArray()[ 1 ].Properties = aFolderProps; return aSeq; @@ -961,45 +936,46 @@ Content::queryCreatableContentsInfo() //========================================================================= // virtual -Reference< XContent > SAL_CALL Content::createNewContent( const ContentInfo& Info ) - throw( RuntimeException ) +uno::Reference< star::ucb::XContent > SAL_CALL +Content::createNewContent( const star::ucb::ContentInfo& Info ) + throw( uno::RuntimeException ) { // if ( isFolder() ) { osl::Guard< osl::Mutex > aGuard( m_aMutex ); if ( !Info.Type.getLength() ) - return Reference< XContent >(); + return uno::Reference< star::ucb::XContent >(); if ( ( !Info.Type.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( WEBDAV_COLLECTION_TYPE ) ) ) && ( !Info.Type.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( WEBDAV_CONTENT_TYPE ) ) ) ) - return Reference< XContent >(); + return uno::Reference< star::ucb::XContent >(); - OUString aURL = m_xIdentifier->getContentIdentifier(); + rtl::OUString aURL = m_xIdentifier->getContentIdentifier(); OSL_ENSURE( aURL.getLength() > 0, "WebdavContent::createNewContent - empty identifier!" ); if ( ( aURL.lastIndexOf( '/' ) + 1 ) != aURL.getLength() ) - aURL += OUString::createFromAscii( "/" ); + aURL += rtl::OUString::createFromAscii( "/" ); sal_Bool isCollection; if ( Info.Type.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( WEBDAV_COLLECTION_TYPE ) ) ) { - aURL += OUString::createFromAscii( "[New_Collection]" ); + aURL += rtl::OUString::createFromAscii( "[New_Collection]" ); isCollection = sal_True; } else { - aURL += OUString::createFromAscii( "[New_Content]" ); + aURL += rtl::OUString::createFromAscii( "[New_Content]" ); isCollection = sal_False; } - Reference< XContentIdentifier > xId( + uno::Reference< star::ucb::XContentIdentifier > xId( new ::ucb::ContentIdentifier( m_xSMgr, aURL ) ); // create the local content @@ -1011,23 +987,23 @@ Reference< XContent > SAL_CALL Content::createNewContent( const ContentInfo& Inf m_aResAccess.getSessionFactory(), isCollection ); } - catch ( ContentCreationException & ) + catch ( star::ucb::ContentCreationException & ) { - return Reference< XContent >(); + return uno::Reference< star::ucb::XContent >(); } } /* else { OSL_ENSURE( sal_False, "createNewContent called on non-folder object!" ); - return Reference< XContent >(); + return uno::Reference< star::ucb::XContent >(); } */ } //========================================================================= // virtual -OUString Content::getParentURL() +rtl::OUString Content::getParentURL() { // <scheme>:// -> "" // <scheme>://foo -> "" @@ -1036,7 +1012,7 @@ OUString Content::getParentURL() // <scheme>://foo/bar/ -> <scheme>://foo/ // <scheme>://foo/bar/abc -> <scheme>://foo/bar/ - OUString aURL = m_xIdentifier->getContentIdentifier(); + rtl::OUString aURL = m_xIdentifier->getContentIdentifier(); sal_Int32 nPos = aURL.lastIndexOf( '/' ); if ( nPos == ( aURL.getLength() - 1 ) ) @@ -1050,9 +1026,9 @@ OUString Content::getParentURL() nPos1 = aURL.lastIndexOf( '/', nPos1 ); if ( nPos1 == -1 ) - return OUString(); + return rtl::OUString(); - return OUString( aURL.copy( 0, nPos + 1 ) ); + return rtl::OUString( aURL.copy( 0, nPos + 1 ) ); } //========================================================================= @@ -1062,28 +1038,28 @@ OUString Content::getParentURL() //========================================================================= // static -Reference< XRow > Content::getPropertyValues( - const Reference< XMultiServiceFactory >& rSMgr, - const Sequence< Property >& rProperties, - const ContentProperties& rData, - const vos::ORef< ucb::ContentProviderImplHelper >& rProvider, - const OUString& rContentId ) +uno::Reference< sdbc::XRow > Content::getPropertyValues( + const uno::Reference< lang::XMultiServiceFactory >& rSMgr, + const uno::Sequence< beans::Property >& rProperties, + const ContentProperties& rData, + const rtl::Reference< ::ucb::ContentProviderImplHelper >& rProvider, + const rtl::OUString& rContentId ) { // Note: Empty sequence means "get values of all supported properties". - vos::ORef< ::ucb::PropertyValueSet > xRow + rtl::Reference< ::ucb::PropertyValueSet > xRow = new ::ucb::PropertyValueSet( rSMgr ); sal_Int32 nCount = rProperties.getLength(); if ( nCount ) { - Reference< XPropertySet > xAdditionalPropSet; + uno::Reference< beans::XPropertySet > xAdditionalPropSet; sal_Bool bTriedToGetAdditonalPropSet = sal_False; - const Property* pProps = rProperties.getConstArray(); + const beans::Property* pProps = rProperties.getConstArray(); for ( sal_Int32 n = 0; n < nCount; ++n ) { - const Property& rProp = pProps[ n ]; + const beans::Property& rProp = pProps[ n ]; // Process Core properties. @@ -1091,10 +1067,10 @@ Reference< XRow > Content::getPropertyValues( RTL_CONSTASCII_STRINGPARAM( "ContentType" ) ) ) { if ( rData.pIsFolder && *rData.pIsFolder ) - xRow->appendString( rProp, OUString::createFromAscii( + xRow->appendString( rProp, rtl::OUString::createFromAscii( WEBDAV_COLLECTION_TYPE ) ); else - xRow->appendString( rProp, OUString::createFromAscii( + xRow->appendString( rProp, rtl::OUString::createFromAscii( WEBDAV_CONTENT_TYPE ) ); } else if ( rProp.Name.equalsAsciiL( @@ -1204,7 +1180,7 @@ Reference< XRow > Content::getPropertyValues( { if ( rData.plockdiscovery ) xRow->appendObject( rProp, - makeAny( *rData.plockdiscovery ) ); + uno::makeAny( *rData.plockdiscovery ) ); else xRow->appendVoid( rProp ); } @@ -1212,14 +1188,14 @@ Reference< XRow > Content::getPropertyValues( { if ( rData.presourcetype ) xRow->appendObject( rProp, - makeAny( *rData.presourcetype ) ); + uno::makeAny( *rData.presourcetype ) ); else xRow->appendVoid( rProp ); } else if ( rProp.Name.equals( DAVProperties::SOURCE ) ) { if ( rData.psource ) - xRow->appendObject( rProp, makeAny( *rData.psource ) ); + xRow->appendObject( rProp, uno::makeAny( *rData.psource ) ); else xRow->appendVoid( rProp ); } @@ -1227,7 +1203,7 @@ Reference< XRow > Content::getPropertyValues( { if ( rData.psupportedlock ) xRow->appendObject( rProp, - makeAny( *rData.psupportedlock ) ); + uno::makeAny( *rData.psupportedlock ) ); else xRow->appendVoid( rProp ); } @@ -1254,10 +1230,10 @@ Reference< XRow > Content::getPropertyValues( && !xAdditionalPropSet.is() ) { xAdditionalPropSet - = Reference< XPropertySet >( + = uno::Reference< beans::XPropertySet >( rProvider->getAdditionalPropertySet( rContentId, sal_False ), - UNO_QUERY ); + uno::UNO_QUERY ); bTriedToGetAdditonalPropSet = sal_True; } @@ -1281,30 +1257,32 @@ Reference< XRow > Content::getPropertyValues( { // Append all Core Properties. ContentProvider * pProvider - = static_cast< ContentProvider * >( rProvider.getBodyPtr() ); - Property aProp; + = static_cast< ContentProvider * >( rProvider.get() ); + beans::Property aProp; pProvider->getProperty( - OUString( RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) ), aProp ); + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) ), aProp ); if ( rData.pIsFolder && *rData.pIsFolder ) - xRow->appendString( aProp, OUString::createFromAscii( + xRow->appendString( aProp, rtl::OUString::createFromAscii( WEBDAV_COLLECTION_TYPE ) ); else - xRow->appendString( aProp, OUString::createFromAscii( + xRow->appendString( aProp, rtl::OUString::createFromAscii( WEBDAV_CONTENT_TYPE ) ); pProvider->getProperty( - OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ), aProp ); + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ), aProp ); xRow->appendString( aProp, rData.aTitle ); pProvider->getProperty( - OUString( RTL_CONSTASCII_USTRINGPARAM( "IsDocument" ) ), aProp ); + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "IsDocument" ) ), aProp ); if ( rData.pIsDocument ) xRow->appendBoolean( aProp, *rData.pIsDocument ); else xRow->appendBoolean( aProp, sal_True ); pProvider->getProperty( - OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ), aProp ); + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ), aProp ); if ( rData.pIsFolder ) xRow->appendBoolean( aProp, *rData.pIsFolder ); else @@ -1313,14 +1291,14 @@ Reference< XRow > Content::getPropertyValues( if ( rData.pSize ) { pProvider->getProperty( - OUString( RTL_CONSTASCII_USTRINGPARAM( "Size" ) ), aProp ); + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Size" ) ), aProp ); xRow->appendLong( aProp, *rData.pSize ); } if ( rData.pDateCreated ) { pProvider->getProperty( - OUString( RTL_CONSTASCII_USTRINGPARAM( "DateCreated" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DateCreated" ) ), aProp ); xRow->appendTimestamp( aProp, *rData.pDateCreated ); } @@ -1328,7 +1306,7 @@ Reference< XRow > Content::getPropertyValues( if ( rData.pDateModified ) { pProvider->getProperty( - OUString( RTL_CONSTASCII_USTRINGPARAM( "DateModified" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DateModified" ) ), aProp ); xRow->appendTimestamp( aProp, *rData.pDateModified ); } @@ -1336,7 +1314,8 @@ Reference< XRow > Content::getPropertyValues( if ( rData.pgetcontenttype ) { pProvider->getProperty( - OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ), aProp ); + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ), aProp ); xRow->appendString( aProp, *rData.pgetcontenttype ); } @@ -1385,7 +1364,7 @@ Reference< XRow > Content::getPropertyValues( if ( rData.plockdiscovery ) { pProvider->getProperty( DAVProperties::LOCKDISCOVERY, aProp ); - xRow->appendObject( aProp, makeAny( *rData.plockdiscovery ) ); + xRow->appendObject( aProp, uno::makeAny( *rData.plockdiscovery ) ); } if ( rData.presourcetype ) @@ -1397,13 +1376,13 @@ Reference< XRow > Content::getPropertyValues( if ( rData.psource ) { pProvider->getProperty( DAVProperties::SOURCE, aProp ); - xRow->appendObject( aProp, makeAny( *rData.psource ) ); + xRow->appendObject( aProp, uno::makeAny( *rData.psource ) ); } if ( rData.psupportedlock ) { pProvider->getProperty( DAVProperties::SUPPORTEDLOCK, aProp ); - xRow->appendObject( aProp, makeAny( *rData.psupportedlock ) ); + xRow->appendObject( aProp, uno::makeAny( *rData.psupportedlock ) ); } // Process additional properties (DAV "dead" properties). @@ -1412,7 +1391,7 @@ Reference< XRow > Content::getPropertyValues( PropertyValueMap::const_iterator it = rData.pOtherProps->begin(); PropertyValueMap::const_iterator end = rData.pOtherProps->end(); - Property aProp; + beans::Property aProp; while ( it != end ) { pProvider->getProperty( (*it).first, aProp ); @@ -1422,19 +1401,19 @@ Reference< XRow > Content::getPropertyValues( } // Append all local Additional Core Properties. - Reference< XPropertySet > xSet( + uno::Reference< beans::XPropertySet > xSet( rProvider->getAdditionalPropertySet( rContentId, sal_False ), - UNO_QUERY ); + uno::UNO_QUERY ); xRow->appendPropertySet( xSet ); } - return Reference< XRow >( xRow.getBodyPtr() ); + return uno::Reference< sdbc::XRow >( xRow.get() ); } //========================================================================= -Reference< XRow > Content::getPropertyValues( - const Sequence< Property >& rProperties, - const Reference< XCommandEnvironment >& xEnv ) +uno::Reference< sdbc::XRow > Content::getPropertyValues( + const uno::Sequence< beans::Property >& rProperties, + const uno::Reference< star::ucb::XCommandEnvironment >& xEnv ) { osl::Guard< osl::Mutex > aGuard( m_aMutex ); @@ -1446,7 +1425,9 @@ Reference< XRow > Content::getPropertyValues( ContentProperties( NeonUri::unescape( m_aEscapedTitle ), m_bCollection ), - m_xProvider, + rtl::Reference< + ::ucb::ContentProviderImplHelper >( + m_xProvider.getBodyPtr() ), m_xIdentifier->getContentIdentifier() ); } @@ -1461,12 +1442,14 @@ Reference< XRow > Content::getPropertyValues( ContentProperties( NeonUri::unescape( m_aEscapedTitle ), m_bCollection ), - m_xProvider, + rtl::Reference< + ::ucb::ContentProviderImplHelper >( + m_xProvider.getBodyPtr() ), m_xIdentifier->getContentIdentifier() ); } bool bSuccess = true; - std::vector< OUString > aPropNames; + std::vector< rtl::OUString > aPropNames; ContentProperties::UCBNamesToDAVNames( rProperties, aPropNames ); std::vector< DAVResource > resources; @@ -1476,9 +1459,8 @@ Reference< XRow > Content::getPropertyValues( { m_aResAccess.PROPFIND( ZERO, aPropNames, resources, xEnv ); } - catch ( DAVException & ) + catch ( DAVException const & ) { -// OSL_ENSURE( sal_False, "PROPFIND : DAVException" ); bSuccess = false; } } @@ -1490,7 +1472,9 @@ Reference< XRow > Content::getPropertyValues( return getPropertyValues( m_xSMgr, rProperties, ContentProperties( resources[ 0 ] ), - m_xProvider, + rtl::Reference< + ::ucb::ContentProviderImplHelper >( + m_xProvider.getBodyPtr() ), m_xIdentifier->getContentIdentifier() ); } else @@ -1501,22 +1485,25 @@ Reference< XRow > Content::getPropertyValues( ContentProperties( NeonUri::unescape( m_aEscapedTitle ), sal_False /* no collection */ ), - m_xProvider, + rtl::Reference< + ::ucb::ContentProviderImplHelper >( + m_xProvider.getBodyPtr() ), m_xIdentifier->getContentIdentifier() ); } } //========================================================================= -void Content::setPropertyValues( const Sequence< PropertyValue >& rValues, - const Reference< XCommandEnvironment >& xEnv ) +void Content::setPropertyValues( + const uno::Sequence< beans::PropertyValue >& rValues, + const uno::Reference< star::ucb::XCommandEnvironment >& xEnv ) { osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex ); - Sequence< PropertyChangeEvent > aChanges( rValues.getLength() ); + uno::Sequence< beans::PropertyChangeEvent > aChanges( rValues.getLength() ); sal_Int32 nChanged = 0; - PropertyChangeEvent aEvent; - aEvent.Source = static_cast< OWeakObject * >( this ); + beans::PropertyChangeEvent aEvent; + aEvent.Source = static_cast< cppu::OWeakObject * >( this ); aEvent.Further = sal_False; // aEvent.PropertyName = aEvent.PropertyHandle = -1; @@ -1528,61 +1515,53 @@ void Content::setPropertyValues( const Sequence< PropertyValue >& rValues, std::vector< ProppatchValue > aProppatchValues; - Reference< XPersistentPropertySet > xAdditionalPropSet; + uno::Reference< star::ucb::XPersistentPropertySet > xAdditionalPropSet; sal_Bool bTriedToGetAdditonalPropSet = sal_False; sal_Bool bExchange = sal_False; - OUString aNewTitle; - OUString aOldTitle; + rtl::OUString aNewTitle; + rtl::OUString aOldTitle; - Reference< XPropertySetInfo > xInfo; + uno::Reference< beans::XPropertySetInfo > xInfo; - const PropertyValue* pValues = rValues.getConstArray(); + const beans::PropertyValue* pValues = rValues.getConstArray(); sal_Int32 nCount = rValues.getLength(); for ( sal_Int32 n = 0; n < nCount; ++n ) { - const PropertyValue& rValue = pValues[ n ]; + const beans::PropertyValue& rValue = pValues[ n ]; - Property aTmpProp; + beans::Property aTmpProp; m_pProvider->getProperty( rValue.Name, aTmpProp ); - if ( aTmpProp.Attributes & PropertyAttribute::READONLY ) + if ( aTmpProp.Attributes & beans::PropertyAttribute::READONLY ) { // Read-only property! continue; } - if ( !xInfo.is() ) - xInfo - = getPropertySetInfo( xEnv, sal_False /* don't cache data */ ); + ////////////////////////////////////////////////////////////////// + // Mandatory props. + ////////////////////////////////////////////////////////////////// - if ( !xInfo->hasPropertyByName( rValue.Name ) ) + if ( rValue.Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( "ContentType" ) ) ) { - // Check, whether property exists. Abort otherwise. - // PROPPATCH::set would add the property automatically, which - // is not allowed for "setPropertyValues" command! - continue; + // Read-only property! } - -// if ( rValue.Name.equalsAsciiL( -// RTL_CONSTASCII_STRINGPARAM( "ContentType" ) ) ) -// { -// // Read-only property! -// } -// else if ( rValue.Name.equalsAsciiL( -// RTL_CONSTASCII_STRINGPARAM( "IsDocument" ) ) ) -// { -// // Read-only property! -// } -// else if ( rValue.Name.equalsAsciiL( -// RTL_CONSTASCII_STRINGPARAM( "IsFolder" ) ) ) -// { -// // Read-only property! -// } - /*else*/ if ( rValue.Name.equalsAsciiL( + else if ( rValue.Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( "IsDocument" ) ) ) + { + // Read-only property! + } + else if ( rValue.Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( "IsFolder" ) ) ) + { + // Read-only property! + } + else if ( rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Title" ) ) ) { - OUString aNewValue; + rtl::OUString aNewValue; if ( rValue.Value >>= aNewValue ) { // No empty titles! @@ -1603,91 +1582,112 @@ void Content::setPropertyValues( const Sequence< PropertyValue >& rValues, } } } -// else if ( rValue.Name.equalsAsciiL( -// RTL_CONSTASCII_STRINGPARAM( "Size" ) ) ) -// { -// // Read-only property! -// } -// else if ( rValue.Name.equalsAsciiL( -// RTL_CONSTASCII_STRINGPARAM( "DateCreated" ) ) ) -// { -// // Read-only property! -// } -// else if ( rValue.Name.equalsAsciiL( -// RTL_CONSTASCII_STRINGPARAM( "DateModified" ) ) ) -// { -// // Read-only property! -// } -// else if ( rValue.Name.equalsAsciiL( -// RTL_CONSTASCII_STRINGPARAM( "MediaType" ) ) ) -// { -// // Read-only property! -// // (but could be writable, if 'getcontenttype' would be) -// } else { - if ( !bCheckedForDAV ) - { - bCheckedForDAV = sal_True; + ////////////////////////////////////////////////////////////// + // Optional props. + ////////////////////////////////////////////////////////////// - try - { - DAVCapabilities caps; - m_aResAccess.OPTIONS( caps, xEnv ); - bDAV = caps.class1; - } - catch ( DAVException const & ) - { - bDAV = sal_False; - } + if ( !xInfo.is() ) + xInfo = getPropertySetInfo( xEnv, + sal_False /* don't cache data */ ); + + if ( !xInfo->hasPropertyByName( rValue.Name ) ) + { + // Check, whether property exists. Abort otherwise. + // PROPPATCH::set would add the property automatically, which + // is not allowed for "setPropertyValues" command! + continue; } - if ( bDAV ) + if ( rValue.Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( "Size" ) ) ) + { + // Read-only property! + } + else if ( rValue.Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( "DateCreated" ) ) ) + { + // Read-only property! + } + else if ( rValue.Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( "DateModified" ) ) ) { - // Property value will be set on server. - ProppatchValue aValue( PROPSET, rValue.Name, rValue.Value ); - aProppatchValues.push_back( aValue ); + // Read-only property! + } + else if ( rValue.Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( "MediaType" ) ) ) + { + // Read-only property! + // (but could be writable, if 'getcontenttype' would be) } else { - // Property value will be stored in local property store. - if ( !bTriedToGetAdditonalPropSet && !xAdditionalPropSet.is() ) + if ( !bCheckedForDAV ) { - xAdditionalPropSet = getAdditionalPropertySet( sal_False ); - bTriedToGetAdditonalPropSet = sal_True; - } + bCheckedForDAV = sal_True; - if ( xAdditionalPropSet.is() ) - { try { - Any aOldValue - = xAdditionalPropSet->getPropertyValue( - rValue.Name ); - if ( aOldValue != rValue.Value ) - { - xAdditionalPropSet->setPropertyValue( - rValue.Name, rValue.Value ); - - aEvent.PropertyName = rValue.Name; - aEvent.OldValue = aOldValue; - aEvent.NewValue = rValue.Value; - - aChanges.getArray()[ nChanged ] = aEvent; - nChanged++; - } - } - catch ( UnknownPropertyException ) - { + DAVCapabilities caps; + m_aResAccess.OPTIONS( caps, xEnv ); + bDAV = caps.class1; } - catch ( WrappedTargetException ) + catch ( DAVException const & ) { + bDAV = sal_False; } - catch ( PropertyVetoException ) + } + + if ( bDAV ) + { + // Property value will be set on server. + ProppatchValue aValue( PROPSET, rValue.Name, rValue.Value ); + aProppatchValues.push_back( aValue ); + } + else + { + // Property value will be stored in local property store. + if ( !bTriedToGetAdditonalPropSet && + !xAdditionalPropSet.is() ) { + xAdditionalPropSet + = getAdditionalPropertySet( sal_False ); + bTriedToGetAdditonalPropSet = sal_True; } - catch ( IllegalArgumentException ) + + if ( xAdditionalPropSet.is() ) { + try + { + uno::Any aOldValue + = xAdditionalPropSet->getPropertyValue( + rValue.Name ); + if ( aOldValue != rValue.Value ) + { + xAdditionalPropSet->setPropertyValue( + rValue.Name, rValue.Value ); + + aEvent.PropertyName = rValue.Name; + aEvent.OldValue = aOldValue; + aEvent.NewValue = rValue.Value; + + aChanges.getArray()[ nChanged ] = aEvent; + nChanged++; + } + } + catch ( beans::UnknownPropertyException ) + { + } + catch ( lang::WrappedTargetException ) + { + } + catch ( beans::PropertyVetoException ) + { + } + catch ( lang::IllegalArgumentException ) + { + } } } } @@ -1709,7 +1709,7 @@ void Content::setPropertyValues( const Sequence< PropertyValue >& rValues, while ( it != end ) { aEvent.PropertyName = (*it).name; - aEvent.OldValue = Any(); // @@@ to expensive to obtain...! + aEvent.OldValue = uno::Any(); // @@@ to expensive to obtain! aEvent.NewValue = (*it).value; aChanges.getArray()[ nChanged ] = aEvent; @@ -1729,21 +1729,22 @@ void Content::setPropertyValues( const Sequence< PropertyValue >& rValues, { // Assemble new content identifier... - OUString aNewURL = getParentURL(); + rtl::OUString aNewURL = getParentURL(); if ( aNewURL.lastIndexOf( '/' ) != ( aNewURL.getLength() - 1 ) ) - aNewURL += OUString::createFromAscii( "/" ); + aNewURL += rtl::OUString::createFromAscii( "/" ); aNewURL += NeonUri::escapeSegment( aNewTitle ); - Reference< XContentIdentifier > xNewId - = new ::ucb::ContentIdentifier( m_xSMgr, aNewURL ); - Reference< XContentIdentifier > xOldId = m_xIdentifier; + uno::Reference< star::ucb::XContentIdentifier > xNewId + = new ::ucb::ContentIdentifier( m_xSMgr, aNewURL ); + uno::Reference< star::ucb::XContentIdentifier > xOldId + = m_xIdentifier; try { NeonUri sourceURI( xOldId->getContentIdentifier() ); NeonUri targetURI( xNewId->getContentIdentifier() ); - targetURI.SetScheme( OUString::createFromAscii( "http" ) ); + targetURI.SetScheme( rtl::OUString::createFromAscii( "http" ) ); m_aResAccess.MOVE( sourceURI.GetPath(), targetURI.GetURI(), sal_False, xEnv ); @@ -1771,21 +1772,21 @@ void Content::setPropertyValues( const Sequence< PropertyValue >& rValues, else { // Do not set new title! - aNewTitle = OUString(); + aNewTitle = rtl::OUString(); } } catch ( DAVException const & ) { // Do not set new title! - aNewTitle = OUString(); + aNewTitle = rtl::OUString(); } } if ( aNewTitle.getLength() ) { - aEvent.PropertyName = OUString::createFromAscii( "Title" ); - aEvent.OldValue = makeAny( aOldTitle ); - aEvent.NewValue = makeAny( aNewTitle ); + aEvent.PropertyName = rtl::OUString::createFromAscii( "Title" ); + aEvent.OldValue = uno::makeAny( aOldTitle ); + aEvent.NewValue = uno::makeAny( aNewTitle ); m_aEscapedTitle = NeonUri::escapeSegment( aNewTitle ); @@ -1811,13 +1812,13 @@ void Content::queryChildren( ContentRefList& rChildren ) ::ucb::ContentRefList aAllContents; m_xProvider->queryExistingContents( aAllContents ); - OUString aURL = m_xIdentifier->getContentIdentifier(); + rtl::OUString aURL = m_xIdentifier->getContentIdentifier(); sal_Int32 nPos = aURL.lastIndexOf( '/' ); if ( nPos != ( aURL.getLength() - 1 ) ) { // No trailing slash found. Append. - aURL += OUString::createFromAscii( "/" ); + aURL += rtl::OUString::createFromAscii( "/" ); } sal_Int32 nLen = aURL.getLength(); @@ -1828,7 +1829,8 @@ void Content::queryChildren( ContentRefList& rChildren ) while ( it != end ) { ::ucb::ContentImplHelperRef xChild = (*it); - OUString aChildURL = xChild->getIdentifier()->getContentIdentifier(); + rtl::OUString aChildURL + = xChild->getIdentifier()->getContentIdentifier(); // Is aURL a prefix of aChildURL? if ( ( aChildURL.getLength() > nLen ) && @@ -1852,27 +1854,74 @@ void Content::queryChildren( ContentRefList& rChildren ) } //========================================================================= -void Content::insert( const Reference< XInputStream > & xInputStream, - sal_Bool bReplaceExisting, - const Reference< XCommandEnvironment >& Environment ) - throw( CommandAbortedException ) +void Content::insert( + const uno::Reference< io::XInputStream > & xInputStream, + sal_Bool bReplaceExisting, + const uno::Reference< star::ucb::XCommandEnvironment >& Environment ) + throw( uno::Exception ) { osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex ); - if ( m_bTransient ) + // Check, if all required properties are present. + + if ( m_aEscapedTitle.getLength() == 0 ) { - // Check, if all required properties are present. + OSL_ENSURE( sal_False, "Content::insert - Title missing!" ); + + uno::Sequence< rtl::OUString > aProps( 1 ); + aProps[ 0 ] = rtl::OUString::createFromAscii( "Title" ); + ucbhelper::cancelCommandExecution( + uno::makeAny( star::ucb::MissingPropertiesException( + rtl::OUString(), + static_cast< cppu::OWeakObject * >( this ), + aProps ) ), + Environment ); + // Unreachable + } - if ( m_aEscapedTitle.getLength() == 0 ) +#if 0 + // This an API change that will be done in the future!!! + + /* [RFC 2616] - HTTP + + The PUT method requests that the enclosed entity be stored under the + supplied Request-URI. If the Request-URI refers to an already + existing resource, the enclosed entity SHOULD be considered as a + modified version of the one residing on the origin server. + */ + + /* [RFC 2518] - WebDAV + + MKCOL creates a new collection resource at the location specified by + the Request-URI. If the resource identified by the Request-URI is + non-null then the MKCOL MUST fail. + */ + + if ( !bReplaceExisting ) + { + // Complain on PUT, continue on MKCOL. + if ( !m_bTransient || ( m_bTransient && !m_bCollection ) ) { - OSL_ENSURE( sal_False, "Content::insert - Title missing!" ); - throw CommandAbortedException(); + ucbhelper::cancelCommandExecution( + uno::makeAny( + star::ucb::UnsupportedNameClashException( + rtl::OUString::createFromAscii( + "Unable to write without overwrite!" ), + static_cast< cppu::OWeakObject * >( this ), + star::ucb::NameClash::ERROR ) ), + Environment ); + + // Unreachable } + } +#endif + if ( m_bTransient ) + { // Assemble new content identifier... - OUString aURL = getParentURL(); + rtl::OUString aURL = getParentURL(); if ( aURL.lastIndexOf( '/' ) != ( aURL.getLength() - 1 ) ) - aURL += OUString::createFromAscii( "/" ); + aURL += rtl::OUString::createFromAscii( "/" ); aURL += m_aEscapedTitle; @@ -1885,10 +1934,56 @@ void Content::insert( const Reference< XInputStream > & xInputStream, else m_aResAccess.PUT( xInputStream, Environment ); } - catch ( DAVException const & ) + catch ( DAVException const & e ) { -// OSL_ENSURE( sal_False, "MKCOL/PUT: DAVException" ); - throw CommandAbortedException(); + if ( m_bCollection ) + { + if ( e.getStatus() == 405 ) + { + // [RFC 2518] - WebDAV + // 405 (Method Not Allowed) - MKCOL can only be + // executed on a deleted/non-existent resource. + + if ( bReplaceExisting ) + { + // Destroy old resource. + try + { + m_aResAccess.DESTROY( Environment ); + } + catch ( DAVException const & e ) + { + cancelCommandExecution( e, Environment, sal_True ); + // Unreachable + } + + // Insert (recursion!). + insert( xInputStream, bReplaceExisting, Environment ); + + // Success! + return; + } + else + { + NeonUri aURI( aURL ); + const rtl::OUString aTitle + = aURI.GetPathBaseNameUnescaped(); + + ucbhelper::cancelCommandExecution( + uno::makeAny( + star::ucb::NameClashException( + rtl::OUString(), + static_cast< cppu::OWeakObject * >( this ), + task::InteractionClassification_ERROR, + aTitle ) ), + Environment ); + // Unreachable + } + } + } + + cancelCommandExecution( e, Environment, sal_True ); + // Unreachable } m_xIdentifier = new ::ucb::ContentIdentifier( m_xSMgr, aURL ); @@ -1901,41 +1996,244 @@ void Content::insert( const Reference< XInputStream > & xInputStream, { if ( !xInputStream.is() ) { - OSL_ENSURE( sal_False, - "Content::insert - Persistent, but no new data stream!" ); - throw CommandAbortedException(); + ucbhelper::cancelCommandExecution( + uno::makeAny( + star::ucb::MissingInputStreamException( + rtl::OUString(), + static_cast< cppu::OWeakObject * >( this ) ) ), + Environment ); + // Unreachable } -/* - Just try a PUT! (isFolder requires network access) - if ( isFolder( Environment ) ) - { - OSL_ENSURE( sal_False, - "Content::insert - Data stream + folder!" ); - throw CommandAbortedException(); - } -*/ try { m_aResAccess.PUT( xInputStream, Environment ); } - catch ( DAVException const & ) + catch ( DAVException const & e ) { -// OSL_ENSURE( sal_False, "Content::insert - PUT: DAVException" ); - throw CommandAbortedException(); + cancelCommandExecution( e, Environment, sal_True ); + // Unreachable } + } +} + +//========================================================================= +void Content::transfer( + const star::ucb::TransferInfo & rArgs, + const uno::Reference< star::ucb::XCommandEnvironment >& Environment ) + throw( uno::Exception ) +{ + NeonUri sourceURI( rArgs.SourceURL ); + NeonUri targetURI( m_xIdentifier->getContentIdentifier() ); + + try + { + // Check source's and target's URL scheme + // + const rtl::OUString aScheme = sourceURI.GetScheme().toAsciiLowerCase(); + if ( aScheme.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( WEBDAV_URL_SCHEME ) ) ) + { + sourceURI.SetScheme( + rtl::OUString::createFromAscii( HTTP_URL_SCHEME ) ); + } + else + { + if ( !aScheme.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( HTTP_URL_SCHEME ) ) && + !aScheme.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( HTTPS_URL_SCHEME ) ) ) + { + ucbhelper::cancelCommandExecution( + uno::makeAny( + star::ucb::InteractiveBadTransferURLException( + rtl::OUString::createFromAscii( + "Unsupported URL scheme!" ), + static_cast< cppu::OWeakObject * >( this ) ) ), + Environment ); + // Unreachable + } + } + + if ( targetURI.GetScheme().toAsciiLowerCase().equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( WEBDAV_URL_SCHEME ) ) ) + targetURI.SetScheme( + rtl::OUString::createFromAscii( HTTP_URL_SCHEME ) ); + + // @@@ This implementation of 'transfer' only works + // if the source and target are located at same host. + // (Neon does not support cross-server copy/move) + + // Check for same host + // + if ( sourceURI.GetHost().getLength() && + ( sourceURI.GetHost() != targetURI.GetHost() ) ) + { + ucbhelper::cancelCommandExecution( + uno::makeAny( star::ucb::InteractiveBadTransferURLException( + rtl::OUString::createFromAscii( + "Different hosts!" ), + static_cast< cppu::OWeakObject * >( this ) ) ), + Environment ); + // Unreachable + } + + rtl::OUString aTitle = rArgs.NewTitle; + + if ( !aTitle.getLength() ) + aTitle = sourceURI.GetPathBaseNameUnescaped(); + + if ( aTitle.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "/" ) ) ) + { + // kso: ??? + aTitle = rtl::OUString(); + } + + targetURI.AppendPath( aTitle ); + + rtl::OUString aTargetURL = m_xIdentifier->getContentIdentifier(); + if ( ( aTargetURL.lastIndexOf( '/' ) + 1 ) + != aTargetURL.getLength() ) + aTargetURL += rtl::OUString::createFromAscii( "/" ); + + aTargetURL += aTitle; + + uno::Reference< star::ucb::XContentIdentifier > xTargetId + = new ::ucb::ContentIdentifier( m_xSMgr, aTargetURL ); + + DAVResourceAccess aSourceAccess( m_xSMgr, + m_aResAccess.getSessionFactory(), + sourceURI.GetURI() ); + + if ( rArgs.MoveData == sal_True ) + { + uno::Reference< star::ucb::XContentIdentifier > xId + = new ::ucb::ContentIdentifier( m_xSMgr, rArgs.SourceURL ); + // Note: The static cast is okay here, because its sure that + // m_xProvider is always the WebDAVContentProvider. + rtl::Reference< Content > xSource + = static_cast< Content * >( + m_xProvider->queryContent( xId ).get() ); + + // [RFC 2518] - WebDAV + // If a resource exists at the destination and the Overwrite + // header is "T" then prior to performing the move the server + // MUST perform a DELETE with "Depth: infinity" on the + // destination resource. If the Overwrite header is set to + // "F" then the operation will fail. + + aSourceAccess.MOVE( sourceURI.GetPath(), + targetURI.GetURI(), + rArgs.NameClash + == star::ucb::NameClash::OVERWRITE, + Environment ); + + if ( xSource.is() ) + { + // Propagate destruction to listeners. + xSource->destroy( sal_True ); + } + +// DAV resources store all additional props on server! +// // Rename own and all children's Additional Core Properties. +// renameAdditionalPropertySet( xId->getContentIdentifier(), +// xTargetId->getContentIdentifier(), +// sal_True ); + } + else + { + // [RFC 2518] - WebDAV + // If a resource exists at the destination and the Overwrite + // header is "T" then prior to performing the copy the server + // MUST perform a DELETE with "Depth: infinity" on the + // destination resource. If the Overwrite header is set to + // "F" then the operation will fail. + + aSourceAccess.COPY( sourceURI.GetPath(), + targetURI.GetURI(), + rArgs.NameClash + == star::ucb::NameClash::OVERWRITE, + Environment ); + +// DAV resources store all additional props on server! +// // Copy own and all children's Additional Core Properties. +// copyAdditionalPropertySet( xId->getContentIdentifier(), +// xTargetId->getContentIdentifier(), +// sal_True ); + } + + // Note: The static cast is okay here, because its sure that + // m_xProvider is always the WebDAVContentProvider. + rtl::Reference< Content > xTarget + = static_cast< Content * >( + m_xProvider->queryContent( xTargetId ).get() ); + + // Announce transfered content in its new folder. + xTarget->inserted(); + } + catch ( star::ucb::IllegalIdentifierException const & ) + { + // queryContent + } + catch ( DAVException const & e ) + { + // [RFC 2518] - WebDAV + // 412 (Precondition Failed) - The server was unable to maintain + // the liveness of the properties listed in the propertybehavior + // XML element or the Overwrite header is "F" and the state of + // the destination resource is non-null. + + if ( e.getStatus() == 412 ) + { + switch ( rArgs.NameClash ) + { + case star::ucb::NameClash::ERROR: + { + ucbhelper::cancelCommandExecution( + uno::makeAny( + star::ucb::NameClashException( + rtl::OUString(), + static_cast< cppu::OWeakObject * >( this ), + task::InteractionClassification_ERROR, + targetURI.GetPathBaseNameUnescaped() ) ), + Environment ); + // Unreachable + } + + case star::ucb::NameClash::OVERWRITE: + break; + + case star::ucb::NameClash::KEEP: // deprecated + case star::ucb::NameClash::RENAME: + case star::ucb::NameClash::ASK: + default: + { + ucbhelper::cancelCommandExecution( + uno::makeAny( + star::ucb::UnsupportedNameClashException( + rtl::OUString(), + static_cast< cppu::OWeakObject * >( this ), + rArgs.NameClash ) ), + Environment ); + // Unreachable + } + } + } + + cancelCommandExecution( e, Environment, sal_True ); + // Unreachable } } //========================================================================= void Content::destroy( sal_Bool bDeletePhysical ) - throw( CommandAbortedException ) + throw( uno::Exception ) { // @@@ take care about bDeletePhysical -> trashcan support - OUString aURL = m_xIdentifier->getContentIdentifier(); + rtl::OUString aURL = m_xIdentifier->getContentIdentifier(); - Reference< XContent > xThis = this; + uno::Reference< star::ucb::XContent > xThis = this; deleted(); @@ -1958,14 +2256,14 @@ void Content::destroy( sal_Bool bDeletePhysical ) //========================================================================= sal_Bool Content::exchangeIdentity( - const Reference< XContentIdentifier >& xNewId ) + const uno::Reference< star::ucb::XContentIdentifier >& xNewId ) { if ( !xNewId.is() ) return sal_False; osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex ); - Reference< XContent > xThis = this; + uno::Reference< star::ucb::XContent > xThis = this; // Already persistent? if ( m_bTransient ) @@ -1979,7 +2277,7 @@ sal_Bool Content::exchangeIdentity( // Fail, if a content with given id already exists. // if ( !hasData( xNewId ) ) { - OUString aOldURL = m_xIdentifier->getContentIdentifier(); + rtl::OUString aOldURL = m_xIdentifier->getContentIdentifier(); aGuard.clear(); if ( exchange( xNewId ) ) @@ -1997,16 +2295,18 @@ sal_Bool Content::exchangeIdentity( ContentRef xChild = (*it); // Create new content identifier for the child... - Reference< XContentIdentifier > xOldChildId - = xChild->getIdentifier(); - OUString aOldChildURL = xOldChildId->getContentIdentifier(); - OUString aNewChildURL + uno::Reference< star::ucb::XContentIdentifier > + xOldChildId = xChild->getIdentifier(); + rtl::OUString aOldChildURL + = xOldChildId->getContentIdentifier(); + rtl::OUString aNewChildURL = aOldChildURL.replaceAt( 0, aOldURL.getLength(), xNewId->getContentIdentifier() ); - Reference< XContentIdentifier > xNewChildId - = new ::ucb::ContentIdentifier( m_xSMgr, aNewChildURL ); + uno::Reference< star::ucb::XContentIdentifier > + xNewChildId + = new ::ucb::ContentIdentifier( m_xSMgr, aNewChildURL ); if ( !xChild->exchangeIdentity( xNewChildId ) ) return sal_False; @@ -2024,7 +2324,8 @@ sal_Bool Content::exchangeIdentity( } //========================================================================= -sal_Bool Content::isFolder( const Reference< XCommandEnvironment >& xEnv ) +sal_Bool Content::isFolder( + const uno::Reference< star::ucb::XCommandEnvironment >& xEnv ) { if ( m_bTransient ) { @@ -2032,7 +2333,7 @@ sal_Bool Content::isFolder( const Reference< XCommandEnvironment >& xEnv ) } else { - std::vector< OUString > aPropNames; + std::vector< rtl::OUString > aPropNames; aPropNames.push_back( DAVProperties::RESOURCETYPE ); std::vector< DAVResource > resources; @@ -2040,10 +2341,8 @@ sal_Bool Content::isFolder( const Reference< XCommandEnvironment >& xEnv ) { m_aResAccess.PROPFIND( ZERO, aPropNames, resources, xEnv ); } - catch ( DAVException & ) + catch ( DAVException const & ) { -// OSL_ENSURE( sal_False, "PROPFIND : DAVException" ); - return sal_False; } if ( resources.size() != 1 ) @@ -2054,3 +2353,112 @@ sal_Bool Content::isFolder( const Reference< XCommandEnvironment >& xEnv ) && *aContentProperties.pIsFolder ); } } + +//========================================================================= +void Content::cancelCommandExecution( + const DAVException & e, + const uno::Reference< star::ucb::XCommandEnvironment > & xEnv, + sal_Bool bWrite /* = sal_False */ ) + throw ( uno::Exception ) +{ + // Map DAVException... + uno::Any aException; + switch ( e.getError() ) + { + case DAVException::DAV_HTTP_ERROR: + if ( bWrite ) + aException <<= + star::ucb::InteractiveNetworkWriteException( + rtl::OUString(), + static_cast< cppu::OWeakObject * >( this ), + task::InteractionClassification_ERROR, + e.getData() ); + else + aException <<= + star::ucb::InteractiveNetworkReadException( + rtl::OUString(), + static_cast< cppu::OWeakObject * >( this ), + task::InteractionClassification_ERROR, + e.getData() ); + break; + + case DAVException::DAV_HTTP_LOOKUP: + aException <<= + star::ucb::InteractiveNetworkResolveNameException( + rtl::OUString(), + static_cast< cppu::OWeakObject * >( this ), + task::InteractionClassification_ERROR, + e.getData() ); + break; + +// case DAVException::DAV_HTTP_AUTH: +// break; +// +// case DAVException::DAV_HTTP_AUTHPROXY: +// break; +// +// case DAVException::DAV_HTTP_SERVERAUTH: +// break; +// +// case DAVException::DAV_HTTP_PROXYAUTH: +// break; + + case DAVException::DAV_HTTP_CONNECT: + aException <<= + star::ucb::InteractiveNetworkConnectException( + rtl::OUString(), + static_cast< cppu::OWeakObject * >( this ), + task::InteractionClassification_ERROR, + e.getData() ); + break; + +/* + case DAVException::DAV_HTTP_TIMEOUT: + break; +*/ + +// case DAVException::DAV_HTTP_REDIRECT: +// break; + +// case DAVException::DAV_SESSION_CREATE: +// break; + + case DAVException::DAV_INVALID_ARG: + aException <<= + lang::IllegalArgumentException( + rtl::OUString(), + static_cast< cppu::OWeakObject * >( this ), + -1 ); + break; + + case DAVException::DAV_FILE_OPEN: + ucbhelper::cancelCommandExecution( + star::ucb::IOErrorCode_CANT_READ, + e.getData(), + xEnv, + rtl::OUString::createFromAscii( + "Cannot open file!" ), + this ); + // Unreachable! + + case DAVException::DAV_FILE_WRITE: + ucbhelper::cancelCommandExecution( + star::ucb::IOErrorCode_CANT_WRITE, + e.getData(), + xEnv, + rtl::OUString::createFromAscii( + "Cannot write to file!" ), + this ); + // Unreachable! + + default: + aException <<= + star::ucb::InteractiveNetworkGeneralException( + rtl::OUString(), + static_cast< cppu::OWeakObject * >( this ), + task::InteractionClassification_ERROR ); + break; + } + + ucbhelper::cancelCommandExecution( aException, xEnv ); +} |