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