diff options
author | Kai Sommerfeld <kso@openoffice.org> | 2002-09-16 13:37:14 +0000 |
---|---|---|
committer | Kai Sommerfeld <kso@openoffice.org> | 2002-09-16 13:37:14 +0000 |
commit | 9823b0d7ca0b9f595e47cfd997bb98163733b1ab (patch) | |
tree | 326314b4a267cd361840a5f606f06d8f573e1d12 /ucb/source/ucp/webdav | |
parent | 10db94ce3892912305069e111ea7096c8afff61d (diff) |
*** empty log message ***
Diffstat (limited to 'ucb/source/ucp/webdav')
-rw-r--r-- | ucb/source/ucp/webdav/ContentProperties.cxx | 374 | ||||
-rw-r--r-- | ucb/source/ucp/webdav/ContentProperties.hxx | 235 | ||||
-rw-r--r-- | ucb/source/ucp/webdav/DAVResource.hxx | 5 | ||||
-rw-r--r-- | ucb/source/ucp/webdav/DAVResourceAccess.cxx | 66 | ||||
-rw-r--r-- | ucb/source/ucp/webdav/DAVResourceAccess.hxx | 34 | ||||
-rw-r--r-- | ucb/source/ucp/webdav/DAVSession.hxx | 22 | ||||
-rw-r--r-- | ucb/source/ucp/webdav/NeonHeadRequest.cxx | 17 | ||||
-rw-r--r-- | ucb/source/ucp/webdav/NeonHeadRequest.hxx | 6 | ||||
-rw-r--r-- | ucb/source/ucp/webdav/NeonSession.cxx | 202 | ||||
-rw-r--r-- | ucb/source/ucp/webdav/NeonSession.hxx | 184 | ||||
-rw-r--r-- | ucb/source/ucp/webdav/webdavcontent.cxx | 678 | ||||
-rw-r--r-- | ucb/source/ucp/webdav/webdavcontent.hxx | 6 | ||||
-rw-r--r-- | ucb/source/ucp/webdav/webdavdatasupplier.cxx | 38 |
13 files changed, 868 insertions, 999 deletions
diff --git a/ucb/source/ucp/webdav/ContentProperties.cxx b/ucb/source/ucp/webdav/ContentProperties.cxx index 46310e76bfef..1810cb827dc5 100644 --- a/ucb/source/ucp/webdav/ContentProperties.cxx +++ b/ucb/source/ucp/webdav/ContentProperties.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ContentProperties.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: kso $ $Date: 2002-08-29 09:00:11 $ + * last change: $Author: kso $ $Date: 2002-09-16 14:37:09 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -69,6 +69,10 @@ #include <osl/diagnose.h> #endif +#ifndef _COM_SUN_STAR_UTIL_DATETIME_HPP_ +#include <com/sun/star/util/DateTime.hpp> +#endif + #ifndef _NEONURI_HXX_ #include "NeonUri.hxx" #endif @@ -81,6 +85,9 @@ #ifndef _WEBDAV_DATETIME_HELPER_HXX #include "DateTimeHelper.hxx" #endif +#ifndef _WEBDAV_UCP_PROVIDER_HXX +#include "webdavprovider.hxx" +#endif #ifndef _WEBDAV_UCP_CONTENTPROPERTIES_HXX #include "ContentProperties.hxx" @@ -120,7 +127,7 @@ a response header ) ============================================================================= -Important: HTTP headers with not be mapped to DAV properties; only to UCB +Important: HTTP headers will not be mapped to DAV properties; only to UCB properties. (Content-Length,Content-Type,Last-Modified) */ @@ -132,34 +139,22 @@ Important: HTTP headers with not be mapped to DAV properties; only to UCB //========================================================================= //========================================================================= +// static member! +uno::Any ContentProperties::m_aEmptyAny; + ContentProperties::ContentProperties( const DAVResource& rResource ) -: bTrailingSlash( sal_False ), - pIsDocument( 0 ), - pIsFolder( 0 ), - pSize( 0 ), - pDateCreated( 0 ), - pDateModified( 0 ), - pMediaType( 0 ), - pgetcontenttype( 0 ), - pcreationdate( 0 ), - pdisplayname( 0 ), - pgetcontentlanguage( 0 ), - pgetcontentlength( 0 ), - pgetetag( 0 ), - pgetlastmodified( 0 ), - plockdiscovery( 0 ), - presourcetype( 0 ), - psource( 0 ), - psupportedlock( 0 ), - pOtherProps( 0 ) +: m_xProps( new PropertyValueMap ), + m_bTrailingSlash( false ) { OSL_ENSURE( rResource.uri.getLength(), - "ContentProperties::ContentProperties - Empty URL!" ); + "ContentProperties ctor - Empty resource URI!" ); - // title + // Title NeonUri aURI( rResource.uri ); - aTitle = aURI.GetPathBaseNameUnescaped(); - aEscapedTitle = aURI.GetPathBaseName(); + m_aEscapedTitle = aURI.GetPathBaseName(); + + (*m_xProps)[ rtl::OUString::createFromAscii( "Title" ) ] + = uno::makeAny( aURI.GetPathBaseNameUnescaped() ); std::vector< beans::PropertyValue >::const_iterator it = rResource.properties.begin(); @@ -172,158 +167,122 @@ ContentProperties::ContentProperties( const DAVResource& rResource ) if ( aProp.Name.equals( DAVProperties::CREATIONDATE ) ) { - pcreationdate = new rtl::OUString; - aProp.Value >>= *pcreationdate; + // Map DAV:creationdate to UCP:DateCreated + rtl::OUString aValue; + aProp.Value >>= aValue; + util::DateTime aDate; + DateTimeHelper::convert( aValue, aDate ); - // Map the DAV:creationdate to UCP:DateCreated - pDateCreated = new util::DateTime; - DateTimeHelper::convert( *pcreationdate, *pDateCreated ); - } - else if ( aProp.Name.equals( DAVProperties::DISPLAYNAME ) ) - { - pdisplayname = new rtl::OUString; - aProp.Value >>= *pdisplayname; - } - else if ( aProp.Name.equals( DAVProperties::GETCONTENTLANGUAGE ) ) - { - pgetcontentlanguage = new rtl::OUString; - aProp.Value >>= *pgetcontentlanguage; + (*m_xProps)[ rtl::OUString::createFromAscii( "DateCreated" ) ] + = uno::makeAny( aDate ); } +// else if ( aProp.Name.equals( DAVProperties::DISPLAYNAME ) ) +// { +// } +// else if ( aProp.Name.equals( DAVProperties::GETCONTENTLANGUAGE ) ) +// { +// } else if ( aProp.Name.equals( DAVProperties::GETCONTENTLENGTH ) ) { - pgetcontentlength = new rtl::OUString; - aProp.Value >>= *pgetcontentlength; - - // Map the DAV:getcontentlength to UCP:Size - if ( !pSize ) - pSize = new sal_Int64; + // Map DAV:getcontentlength to UCP:Size + rtl::OUString aValue; + aProp.Value >>= aValue; - *pSize = pgetcontentlength->toInt64(); + (*m_xProps)[ rtl::OUString::createFromAscii( "Size" ) ] + = uno::makeAny( aValue.toInt64() ); } else if ( aProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Content-Length" ) ) ) { - // Do not map Content-Lenght entity header to DAV:getcontentlength! - - // No extra member for this. Store with "other" props. - if ( !pOtherProps ) - pOtherProps = new PropertyValueMap; + // Do NOT map Content-Lenght entity header to DAV:getcontentlength! + // Only DAV resources have this property. + // Map Content-Length entity header to UCP:Size rtl::OUString aValue; aProp.Value >>= aValue; - (*pOtherProps)[ aProp.Name ] = aProp.Value; - // Map the Content-Length entity header to UCP:Size - if ( !pSize ) - pSize = new sal_Int64; - - *pSize = aValue.toInt64(); + (*m_xProps)[ rtl::OUString::createFromAscii( "Size" ) ] + = uno::makeAny( aValue.toInt64() ); } else if ( aProp.Name.equals( DAVProperties::GETCONTENTTYPE ) ) { - pgetcontenttype = new rtl::OUString; - aProp.Value >>= *pgetcontenttype; - - // Map the DAV:getcontenttype to UCP:MediaType - if ( !pMediaType ) - pMediaType = new rtl::OUString; - - *pMediaType = *pgetcontenttype; + // Map DAV:getcontenttype to UCP:MediaType (1:1) + (*m_xProps)[ rtl::OUString::createFromAscii( "MediaType" ) ] + = aProp.Value; } else if ( aProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Content-Type" ) ) ) { - // Do not map Content-Type entity header to DAV:getcontenttype! - - // No extra member for this. Store with "other" props. - if ( !pOtherProps ) - pOtherProps = new PropertyValueMap; - - (*pOtherProps)[ aProp.Name ] = aProp.Value; - - // Map the Content-Type entity header to UCP:Size - rtl::OUString aValue; - aProp.Value >>= aValue; + // Do NOT map Content-Type entity header to DAV:getcontenttype! + // Only DAV resources have this property. - if ( !pMediaType ) - pMediaType = new rtl::OUString; - - *pMediaType = aValue; - } - else if ( aProp.Name.equals( DAVProperties::GETETAG ) ) - { - pgetetag = new rtl::OUString; - aProp.Value >>= *pgetetag; + // Map DAV:getcontenttype to UCP:MediaType (1:1) + (*m_xProps)[ rtl::OUString::createFromAscii( "MediaType" ) ] + = aProp.Value; } +// else if ( aProp.Name.equals( DAVProperties::GETETAG ) ) +// { +// } else if ( aProp.Name.equals( DAVProperties::GETLASTMODIFIED ) ) { - pgetlastmodified = new rtl::OUString; - aProp.Value >>= *pgetlastmodified; - - // Map the DAV:getlastmodified to UCP:DateModified - if ( !pDateModified ) - pDateModified = new util::DateTime; + // Map the DAV:getlastmodified entity header to UCP:DateModified + rtl::OUString aValue; + aProp.Value >>= aValue; + util::DateTime aDate; + DateTimeHelper::convert( aValue, aDate ); - DateTimeHelper::convert( *pgetlastmodified, *pDateModified ); + (*m_xProps)[ rtl::OUString::createFromAscii( "DateModified" ) ] + = uno::makeAny( aDate ); } else if ( aProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Last-Modified" ) ) ) { // Do not map Last-Modified entity header to DAV:getlastmodified! + // Only DAV resources have this property. - // No extra member for this. Store with "other" props. - if ( !pOtherProps ) - pOtherProps = new PropertyValueMap; - + // Map the Last-Modified entity header to UCP:DateModified rtl::OUString aValue; aProp.Value >>= aValue; - (*pOtherProps)[ aProp.Name ] = aProp.Value; - - // Map the Content-Length entity header to UCP:Size - if ( !pDateModified ) - pDateModified = new util::DateTime; + util::DateTime aDate; + DateTimeHelper::convert( aValue, aDate ); - DateTimeHelper::convert( aValue, *pDateModified ); - } - - else if ( aProp.Name.equals( DAVProperties::LOCKDISCOVERY ) ) - { - plockdiscovery = new uno::Sequence< ucb::Lock >; - aProp.Value >>= *plockdiscovery; + (*m_xProps)[ rtl::OUString::createFromAscii( "DateModified" ) ] + = uno::makeAny( aDate ); } +// else if ( aProp.Name.equals( DAVProperties::LOCKDISCOVERY ) ) +// { +// } else if ( aProp.Name.equals( DAVProperties::RESOURCETYPE ) ) { - presourcetype = new rtl::OUString; - aProp.Value >>= *presourcetype; - - pIsFolder = new sal_Bool( sal_False ); - pIsDocument = new sal_Bool( sal_True ); + rtl::OUString aValue; + aProp.Value >>= aValue; - // Map the DAV:resourceype to UCP:IsFolder, UCP:IsDocument - if ( presourcetype->equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM( "collection" ) ) ) - { - *pIsDocument = sal_False; - *pIsFolder = sal_True; - } - } - else if ( aProp.Name.equals( DAVProperties::SOURCE ) ) - { - psource = new uno::Sequence< ucb::Link >; - aProp.Value >>= *psource; + // Map DAV:resourceype to UCP:IsFolder, UCP:IsDocument, UCP:ContentType + sal_Bool bFolder = + aValue.equalsIgnoreAsciiCaseAsciiL( + RTL_CONSTASCII_STRINGPARAM( "collection" ) ); + + (*m_xProps)[ rtl::OUString::createFromAscii( "IsFolder" ) ] + = uno::makeAny( bFolder ); + (*m_xProps)[ rtl::OUString::createFromAscii( "IsDocument" ) ] + = uno::makeAny( sal_Bool( !bFolder ) ); + (*m_xProps)[ rtl::OUString::createFromAscii( "ContentType" ) ] + = uno::makeAny( bFolder + ? rtl::OUString::createFromAscii( + WEBDAV_COLLECTION_TYPE ) + : rtl::OUString::createFromAscii( + WEBDAV_CONTENT_TYPE ) ); } - else if ( aProp.Name.equals( DAVProperties::SUPPORTEDLOCK ) ) - { - psupportedlock = new uno::Sequence< ucb::LockEntry >; - aProp.Value >>= *psupportedlock; - } - else - { - if ( !pOtherProps ) - pOtherProps = new PropertyValueMap; +// else if ( aProp.Name.equals( DAVProperties::SOURCE ) ) +// { +// } +// else if ( aProp.Name.equals( DAVProperties::SUPPORTEDLOCK ) ) +// { +// } + + // Save property. + (*m_xProps)[ aProp.Name ] = aProp.Value; - (*pOtherProps)[ aProp.Name ] = aProp.Value; - } ++it; } @@ -331,59 +290,57 @@ ContentProperties::ContentProperties( const DAVResource& rResource ) == sal_Unicode( '/' ) ) { // if ( pIsFolder && *pIsFolder ) - bTrailingSlash = sal_True; + m_bTrailingSlash = sal_True; } } //========================================================================= ContentProperties::ContentProperties( const rtl::OUString & rTitle, sal_Bool bFolder ) -: aTitle( rTitle ), - bTrailingSlash( sal_False ), - pIsDocument( new sal_Bool( !bFolder ) ), - pIsFolder( new sal_Bool( bFolder ) ), - pSize( 0 ), - pDateCreated( 0 ), - pDateModified( 0 ), - pMediaType( 0 ), - pgetcontenttype( 0 ), - pcreationdate( 0 ), - pdisplayname( 0 ), - pgetcontentlanguage( 0 ), - pgetcontentlength( 0 ), - pgetetag( 0 ), - pgetlastmodified( 0 ), - plockdiscovery( 0 ), - presourcetype( 0 ), - psource( 0 ), - psupportedlock( 0 ), - pOtherProps( 0 ) +: m_xProps( new PropertyValueMap ), + m_bTrailingSlash( sal_False ) { + (*m_xProps)[ rtl::OUString::createFromAscii( "Title" ) ] + = uno::makeAny( rTitle ); + (*m_xProps)[ rtl::OUString::createFromAscii( "IsFolder" ) ] + = uno::makeAny( bFolder ); + (*m_xProps)[ rtl::OUString::createFromAscii( "IsDocument" ) ] + = uno::makeAny( sal_Bool( !bFolder ) ); } //========================================================================= ContentProperties::ContentProperties( const rtl::OUString & rTitle ) -: aTitle( rTitle ), - bTrailingSlash( sal_False ), - pIsDocument( 0 ), - pIsFolder( 0 ), - pSize( 0 ), - pDateCreated( 0 ), - pDateModified( 0 ), - pMediaType( 0 ), - pgetcontenttype( 0 ), - pcreationdate( 0 ), - pdisplayname( 0 ), - pgetcontentlanguage( 0 ), - pgetcontentlength( 0 ), - pgetetag( 0 ), - pgetlastmodified( 0 ), - plockdiscovery( 0 ), - presourcetype( 0 ), - psource( 0 ), - psupportedlock( 0 ), - pOtherProps( 0 ) +: m_xProps( new PropertyValueMap ), + m_bTrailingSlash( sal_False ) +{ + (*m_xProps)[ rtl::OUString::createFromAscii( "Title" ) ] + = uno::makeAny( rTitle ); +} + +//========================================================================= +ContentProperties::ContentProperties( const ContentProperties & rOther ) +: m_aEscapedTitle( rOther.m_aEscapedTitle ), + m_bTrailingSlash( rOther.m_bTrailingSlash ) +{ + if ( rOther.m_xProps.get() ) + m_xProps.reset( new PropertyValueMap( *rOther.m_xProps ) ); +} + +//========================================================================= +bool ContentProperties::contains( const rtl::OUString & rName ) const { + return ( m_xProps->find( rName ) != m_xProps->end() ); +} + +//========================================================================= +const uno::Any & ContentProperties::getValue( + const rtl::OUString & rName ) const +{ + PropertyValueMap::const_iterator it = m_xProps->find( rName ); + if ( it != m_xProps->end() ) + return (*it).second; + + return m_aEmptyAny; } //========================================================================= @@ -541,5 +498,64 @@ void ContentProperties::UCBNamesToHTTPNames( propertyNames.push_back( rProp.Name ); } } +} +//========================================================================= +// static +void ContentProperties::getMappableHTTPHeaders( + std::vector< rtl::OUString > & rHeaderNames ) +{ + rHeaderNames.push_back( + rtl::OUString::createFromAscii( "Last-Modified" ) ); + rHeaderNames.push_back( + rtl::OUString::createFromAscii( "Content-Type" ) ); + rHeaderNames.push_back( + rtl::OUString::createFromAscii( "Content-Length" ) ); } + +//========================================================================= +bool ContentProperties::containsAllNames( + const uno::Sequence< beans::Property >& rProps, + std::vector< rtl::OUString > & rNamesNotContained ) +{ + rNamesNotContained.clear(); + + sal_Int32 nCount = rProps.getLength(); + for ( sal_Int32 n = 0; n < nCount; ++n ) + { + const rtl::OUString & rName = rProps[ n ].Name; + if ( !contains( rName ) ) + { + // Not found. + rNamesNotContained.push_back( rName ); + } + } + + return ( rNamesNotContained.size() == 0 ); +} + +//========================================================================= +void ContentProperties::add( const std::vector< rtl::OUString > & rProps, + const ContentProperties & rContentProps ) +{ + std::vector< rtl::OUString >::const_iterator it = rProps.begin(); + std::vector< rtl::OUString >::const_iterator end = rProps.end(); + + while ( it != end ) + { + const rtl::OUString & rName = (*it); + + if ( !contains( rName ) ) // ignore duplicates + { + const uno::Any & rValue = rContentProps.getValue( rName ); + if ( rValue.hasValue() ) + { + // Add it. + (*m_xProps)[ rName ] = rValue; + } + } + + ++it; + } +} + diff --git a/ucb/source/ucp/webdav/ContentProperties.hxx b/ucb/source/ucp/webdav/ContentProperties.hxx index 54cbe4f674ef..9753ba9624ce 100644 --- a/ucb/source/ucp/webdav/ContentProperties.hxx +++ b/ucb/source/ucp/webdav/ContentProperties.hxx @@ -2,9 +2,9 @@ * * $RCSfile: ContentProperties.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: kso $ $Date: 2002-08-29 09:00:12 $ + * last change: $Author: kso $ $Date: 2002-09-16 14:37:10 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,29 +62,30 @@ #ifndef _WEBDAV_UCP_CONTENTPROPERTIES_HXX #define _WEBDAV_UCP_CONTENTPROPERTIES_HXX +#include <memory> #include <vector> #include <hash_map> -#ifndef _COM_SUN_STAR_UCB_LINK_HPP_ -#include <com/sun/star/ucb/Link.hpp> +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring.hxx> #endif -#ifndef _COM_SUN_STAR_UCB_LOCK_HPP_ -#include <com/sun/star/ucb/Lock.hpp> +#ifndef _COM_SUN_STAR_UNO_ANY_HXX_ +#include <com/sun/star/uno/Any.hxx> #endif -#ifndef _COM_SUN_STAR_UCB_LOCKENTRY_HPP_ -#include <com/sun/star/ucb/LockEntry.hpp> -#endif -#ifndef _COM_SUN_STAR_UTIL_DATETIME_HPP_ -#include <com/sun/star/util/DateTime.hpp> +#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_ +#include <com/sun/star/uno/Sequence.hxx> #endif namespace com { namespace sun { namespace star { namespace beans { struct Property; + struct PropertyValue; } } } } namespace webdav_ucp { +struct DAVResource; + //========================================================================= struct equalString @@ -131,7 +132,12 @@ public: // Micro props for non-existing contents. ContentProperties( const rtl::OUString & rTitle ); - inline ~ContentProperties(); + ContentProperties( const ContentProperties & rOther ); + + bool contains( const rtl::OUString & rName ) const; + + const com::sun::star::uno::Any & + getValue( const rtl::OUString & rName ) const; // Maps the UCB property names contained in rProps with their DAV property // counterparts, if possible. All unmappable properties will be included @@ -159,198 +165,41 @@ public: std::vector< rtl::OUString > & resources, bool bIncludeUnmatched = true ); - sal_Bool isTrailingSlash() const { return bTrailingSlash; } + // Returns a list of HTTP header names that can be mapped to UCB property + // names. + static void getMappableHTTPHeaders( + std::vector< rtl::OUString > & rHeaderNames ); - ///////////////////////////////////////////////////////////////////////// - // UCB properties - ///////////////////////////////////////////////////////////////////////// - sal_Bool queryTitle( rtl::OUString & rTitle ) const - { - rTitle = aTitle; - return true; - } + // return true, if all properties contained in rProps are contained in + // this ContentProperties instance. Otherwiese, false will be returned. + // rNamesNotContained contain the missing names. + bool containsAllNames( const com::sun::star::uno::Sequence< + com::sun::star::beans::Property >& rProps, + std::vector< rtl::OUString > & rNamesNotContained ); - sal_Bool queryEscapedTitle( rtl::OUString & rTitle ) const - { - rTitle = aEscapedTitle; - return true; - } + // adds all properties described by rProps that are actually contained in + // rContentProps to this instance. In case of duplicates the value + // already contained in this will left anchanged. + void add( const std::vector< rtl::OUString > & rProps, + const ContentProperties & rContentProps ); - sal_Bool queryIsFolder( sal_Bool & rbFolder ) const - { - if ( pIsFolder ) rbFolder = *pIsFolder; - return !!pIsFolder; - } + bool isTrailingSlash() const { return m_bTrailingSlash; } - sal_Bool queryIsDocument( sal_Bool & rbDocument ) const - { - if ( pIsDocument ) rbDocument = *pIsDocument; - return !!pIsDocument; - } + const rtl::OUString & getEscapedTitle() const { return m_aEscapedTitle; } - sal_Bool querySize( sal_Int64 & rSize ) const - { - if ( pSize ) rSize = *pSize; - return !!pSize; - } - - sal_Bool queryDateCreated( ::com::sun::star::util::DateTime & rDate ) const - { - if ( pDateCreated ) rDate = *pDateCreated; - return !!pDateCreated; - } - - sal_Bool queryDateModified( ::com::sun::star::util::DateTime & rDate ) const - { - if ( pDateModified ) rDate = *pDateModified; - return !!pDateModified; - } - - sal_Bool queryMediaType( rtl::OUString & rType ) const - { - if ( pMediaType ) rType = *pMediaType; - return !!pMediaType; - } - - ///////////////////////////////////////////////////////////////////////// - // DAV properties - ///////////////////////////////////////////////////////////////////////// - - sal_Bool queryDAVCreationDate( rtl::OUString & rDate ) const - { - if ( pcreationdate ) rDate = *pcreationdate; - return !!pcreationdate; - } - - sal_Bool queryDAVDisplayName( rtl::OUString & rName ) const - { - if ( pdisplayname ) rName = *pdisplayname; - return !!pdisplayname; - } - - sal_Bool queryDAVContentType( rtl::OUString & rType ) const - { - if ( pgetcontenttype ) rType = *pgetcontenttype; - return !!pgetcontenttype; - } - - sal_Bool queryDAVContentLanguage( rtl::OUString & rLang ) const - { - if ( pgetcontentlanguage ) rLang = *pgetcontentlanguage; - return !!pgetcontentlanguage; - } - - sal_Bool queryDAVContentLength( rtl::OUString & rLen ) const - { - if ( pgetcontentlength ) rLen = *pgetcontentlength; - return !!pgetcontentlength; - } - - sal_Bool queryDAVETag( rtl::OUString & rTag ) const - { - if ( pgetetag ) rTag = *pgetetag; - return !!pgetetag; - } - - sal_Bool queryDAVLastModified( rtl::OUString & rDate ) const - { - if ( pgetlastmodified ) rDate = *pgetlastmodified; - return !!pgetlastmodified; - } - - sal_Bool queryDAVLockDiscovery( - ::com::sun::star::uno::Sequence< - ::com::sun::star::ucb::Lock >& rLocks ) const - { - if ( plockdiscovery ) rLocks = *plockdiscovery; - return !!plockdiscovery; - } - - sal_Bool queryDAVResourceType( rtl::OUString & rType ) const - { - if ( presourcetype ) rType = *presourcetype; - return !!presourcetype; - } - - sal_Bool queryDAVSource( - ::com::sun::star::uno::Sequence< - ::com::sun::star::ucb::Link >& rLinks ) const - { - if ( psource ) rLinks = *psource; - return !!psource; - } - - sal_Bool queryDAVSupportedLock( - ::com::sun::star::uno::Sequence< - ::com::sun::star::ucb::LockEntry >& rEntries ) const - { - if ( psource ) rEntries = *psupportedlock; - return !!psupportedlock; - } - - ///////////////////////////////////////////////////////////////////////// - // Other properties (i.e. HTTP entity headers, DAV dead properties) - ///////////////////////////////////////////////////////////////////////// - - const PropertyValueMap * getOtherProperties() const { return pOtherProps; } + const std::auto_ptr< PropertyValueMap > getProperties() const + { return m_xProps; } private: - // Mandatory UCB props. - ::rtl::OUString aTitle; // Title - ::rtl::OUString aEscapedTitle; // escaped Title - sal_Bool bTrailingSlash; - - sal_Bool * pIsFolder; - sal_Bool * pIsDocument; + ::rtl::OUString m_aEscapedTitle; // escaped Title + std::auto_ptr< PropertyValueMap > m_xProps; + bool m_bTrailingSlash; - // Optional UCB props. - sal_Int64 * pSize; // Size <- getcontentlength - ::com::sun::star::util::DateTime * pDateCreated; // DateCreated <- creationdate - ::com::sun::star::util::DateTime * pDateModified; // DateModified <- getlastmodified + static com::sun::star::uno::Any m_aEmptyAny; - ::rtl::OUString * pMediaType; - - // DAV props. - ::rtl::OUString * pgetcontenttype; - ::rtl::OUString * pcreationdate; - ::rtl::OUString * pdisplayname; - ::rtl::OUString * pgetcontentlanguage; - ::rtl::OUString * pgetcontentlength; - ::rtl::OUString * pgetetag; - ::rtl::OUString * pgetlastmodified; - ::com::sun::star::uno::Sequence< - ::com::sun::star::ucb::Lock > * plockdiscovery; - ::rtl::OUString * presourcetype; - ::com::sun::star::uno::Sequence< - ::com::sun::star::ucb::Link > * psource; - ::com::sun::star::uno::Sequence< - ::com::sun::star::ucb::LockEntry > * psupportedlock; - - PropertyValueMap * pOtherProps; + ContentProperties & operator=( const ContentProperties & ); // n.i. }; -inline ContentProperties::~ContentProperties() -{ - delete pIsFolder; - delete pIsDocument; - delete pSize; - delete pDateCreated; - delete pDateModified; - delete pMediaType; - delete pgetcontenttype; - delete pcreationdate; - delete pdisplayname; - delete pgetcontentlanguage; - delete pgetcontentlength; - delete pgetetag; - delete pgetlastmodified; - delete plockdiscovery; - delete presourcetype; - delete psource; - delete psupportedlock; - delete pOtherProps; -} - }; #endif /* !_WEBDAV_UCP_CONTENTPROPERTIES_HXX */ diff --git a/ucb/source/ucp/webdav/DAVResource.hxx b/ucb/source/ucp/webdav/DAVResource.hxx index 8116b020fceb..74c21337a5ca 100644 --- a/ucb/source/ucp/webdav/DAVResource.hxx +++ b/ucb/source/ucp/webdav/DAVResource.hxx @@ -2,9 +2,9 @@ * * $RCSfile: DAVResource.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: kso $ $Date: 2001-05-16 15:29:59 $ + * last change: $Author: kso $ $Date: 2002-09-16 14:37:10 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -83,6 +83,7 @@ struct DAVResource ::rtl::OUString uri; std::vector < com::sun::star::beans::PropertyValue > properties; + DAVResource() {} DAVResource( const ::rtl::OUString & inUri ) : uri( inUri ) {} }; diff --git a/ucb/source/ucp/webdav/DAVResourceAccess.cxx b/ucb/source/ucp/webdav/DAVResourceAccess.cxx index c41501911d21..3005e63e5201 100644 --- a/ucb/source/ucp/webdav/DAVResourceAccess.cxx +++ b/ucb/source/ucp/webdav/DAVResourceAccess.cxx @@ -2,9 +2,9 @@ * * $RCSfile: DAVResourceAccess.cxx,v $ * - * $Revision: 1.12 $ + * $Revision: 1.13 $ * - * last change: $Author: kso $ $Date: 2002-08-30 13:24:40 $ + * last change: $Author: kso $ $Date: 2002-09-16 14:37:11 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -299,7 +299,7 @@ void DAVResourceAccess::PROPPATCH( const std::vector< ProppatchValue >& rValues, //========================================================================= void DAVResourceAccess::HEAD( const std::vector< rtl::OUString > & rHeaderNames, - std::vector< DAVResource > & rResources, + DAVResource & rResource, const uno::Reference< ucb::XCommandEnvironment >& xEnv ) throw( DAVException ) @@ -312,7 +312,7 @@ void DAVResourceAccess::HEAD( const std::vector< rtl::OUString > & rHeaderNames, bRetry = sal_False; try { - m_xSession->HEAD( m_aPath, rHeaderNames, rResources, xEnv ); + m_xSession->HEAD( m_aPath, rHeaderNames, rResource, xEnv ); } catch ( DAVException & e ) { @@ -379,6 +379,64 @@ void DAVResourceAccess::GET( uno::Reference< io::XOutputStream > & rStream, } //========================================================================= +uno::Reference< io::XInputStream > DAVResourceAccess::GET( + const std::vector< rtl::OUString > & rHeaderNames, + DAVResource & rResource, + const uno::Reference< ucb::XCommandEnvironment > & xEnv ) + throw( DAVException ) +{ + initialize(); + + uno::Reference< io::XInputStream > xStream; + sal_Bool bRetry; + do + { + bRetry = sal_False; + try + { + xStream = m_xSession->GET( m_aPath, rHeaderNames, rResource, xEnv ); + } + catch ( DAVException & e ) + { + bRetry = handleException( e ); + if ( !bRetry ) + throw; + } + } + while ( bRetry ); + + return xStream; +} + +//========================================================================= +void DAVResourceAccess::GET( + uno::Reference< io::XOutputStream > & rStream, + const std::vector< rtl::OUString > & rHeaderNames, + DAVResource & rResource, + const uno::Reference< ucb::XCommandEnvironment > & xEnv ) + throw( DAVException ) +{ + initialize(); + + sal_Bool bRetry; + do + { + bRetry = sal_False; + try + { + m_xSession->GET( m_aPath, rStream, rHeaderNames, rResource, xEnv ); + } + catch ( DAVException & e ) + { + bRetry = handleException( e ); + if ( !bRetry ) + throw; + } + } + while ( bRetry ); +} + +//========================================================================= void DAVResourceAccess::PUT( const uno::Reference< io::XInputStream > & rStream, const uno::Reference< ucb::XCommandEnvironment > & xEnv ) diff --git a/ucb/source/ucp/webdav/DAVResourceAccess.hxx b/ucb/source/ucp/webdav/DAVResourceAccess.hxx index 43d5d10e0a46..a81c486642ac 100644 --- a/ucb/source/ucp/webdav/DAVResourceAccess.hxx +++ b/ucb/source/ucp/webdav/DAVResourceAccess.hxx @@ -2,9 +2,9 @@ * * $RCSfile: DAVResourceAccess.hxx,v $ * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * - * last change: $Author: kso $ $Date: 2002-08-29 09:00:12 $ + * last change: $Author: kso $ $Date: 2002-09-16 14:37:11 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -174,21 +174,37 @@ public: void HEAD( const std::vector< rtl::OUString > & rHeaderNames, // empty == 'all' - std::vector< DAVResource > & rResources, + DAVResource & rResource, const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv ) throw( DAVException ); com::sun::star::uno::Reference< com::sun::star::io::XInputStream > - GET( const com::sun::star::uno::Reference< - com::sun::star::ucb::XCommandEnvironment > & xEnv ) + GET( const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment > & xEnv ) throw( DAVException ); void - GET( com::sun::star::uno::Reference< - com::sun::star::io::XOutputStream > & rStream, - const com::sun::star::uno::Reference< - com::sun::star::ucb::XCommandEnvironment > & xEnv ) + GET( com::sun::star::uno::Reference< + com::sun::star::io::XOutputStream > & rStream, + const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment > & xEnv ) + throw( DAVException ); + + com::sun::star::uno::Reference< com::sun::star::io::XInputStream > + GET( const std::vector< rtl::OUString > & rHeaderNames, // empty == 'all' + DAVResource & rResource, + const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment > & xEnv ) + throw( DAVException ); + + void + GET( com::sun::star::uno::Reference< + com::sun::star::io::XOutputStream > & rStream, + const std::vector< rtl::OUString > & rHeaderNames, // empty == 'all' + DAVResource & rResource, + const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment > & xEnv ) throw( DAVException ); void diff --git a/ucb/source/ucp/webdav/DAVSession.hxx b/ucb/source/ucp/webdav/DAVSession.hxx index 4b18eeb7eaeb..e4c3c68149f3 100644 --- a/ucb/source/ucp/webdav/DAVSession.hxx +++ b/ucb/source/ucp/webdav/DAVSession.hxx @@ -2,9 +2,9 @@ * * $RCSfile: DAVSession.hxx,v $ * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * - * last change: $Author: kso $ $Date: 2002-08-29 09:00:12 $ + * last change: $Author: kso $ $Date: 2002-09-16 14:37:12 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -157,7 +157,7 @@ public: virtual void HEAD( const ::rtl::OUString & inPath, const std::vector< ::rtl::OUString > & inHeaderNames, - std::vector< DAVResource > & ioResources, + DAVResource & ioResource, const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& inEnv ) throw( DAVException ) = 0; @@ -174,6 +174,22 @@ public: com::sun::star::ucb::XCommandEnvironment >& inEnv ) throw( DAVException ) = 0; + virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream > + GET( const ::rtl::OUString & inPath, + const std::vector< ::rtl::OUString > & inHeaderNames, + DAVResource & ioResource, + const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment >& inEnv ) + throw( DAVException ) = 0; + + virtual void GET( const ::rtl::OUString & inPath, + com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& o, + const std::vector< ::rtl::OUString > & inHeaderNames, + DAVResource & ioResource, + const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment >& inEnv ) + throw( DAVException ) = 0; + virtual void PUT( const ::rtl::OUString & inPath, const com::sun::star::uno::Reference< com::sun::star::io::XInputStream >& s, diff --git a/ucb/source/ucp/webdav/NeonHeadRequest.cxx b/ucb/source/ucp/webdav/NeonHeadRequest.cxx index bc62becd67a2..7113324759c0 100644 --- a/ucb/source/ucp/webdav/NeonHeadRequest.cxx +++ b/ucb/source/ucp/webdav/NeonHeadRequest.cxx @@ -2,9 +2,9 @@ * * $RCSfile: NeonHeadRequest.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: kso $ $Date: 2002-08-29 09:00:12 $ + * last change: $Author: kso $ $Date: 2002-09-16 14:37:12 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -149,12 +149,11 @@ NeonHeadRequest::NeonHeadRequest( HttpSession* inSession, const rtl::OUString & inPath, const std::vector< ::rtl::OUString > & inHeaderNames, - std::vector< DAVResource >& ioResources, + DAVResource & ioResource, int & nError ) { - // Add own entry to resources list. - ioResources.clear(); - ioResources.push_back( DAVResource( inPath ) ); + ioResource.uri = inPath; + ioResource.properties.clear(); // Create and dispatch HEAD request. Install catcher for all response // header fields. @@ -164,7 +163,7 @@ NeonHeadRequest::NeonHeadRequest( HttpSession* inSession, inPath, RTL_TEXTENCODING_UTF8 ) ); - NeonHeadRequestContext aCtx( &ioResources.back(), &inHeaderNames ); + NeonHeadRequestContext aCtx( &ioResource, &inHeaderNames ); ne_add_response_header_catcher( req, NHR_ResponseHeaderCatcher, &aCtx ); nError = ne_request_dispatch( req ); @@ -173,10 +172,6 @@ NeonHeadRequest::NeonHeadRequest( HttpSession* inSession, nError = NE_ERROR; ne_request_destroy( req ); - - // #87585# - Sometimes neon lies (because some servers lie). - if ( ( nError == NE_OK ) && ioResources.empty() ) - nError = NE_ERROR; } // ------------------------------------------------------------------- diff --git a/ucb/source/ucp/webdav/NeonHeadRequest.hxx b/ucb/source/ucp/webdav/NeonHeadRequest.hxx index 6ba6ebf50269..7965fd4c963a 100644 --- a/ucb/source/ucp/webdav/NeonHeadRequest.hxx +++ b/ucb/source/ucp/webdav/NeonHeadRequest.hxx @@ -2,9 +2,9 @@ * * $RCSfile: NeonHeadRequest.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: kso $ $Date: 2002-08-29 09:00:13 $ + * last change: $Author: kso $ $Date: 2002-09-16 14:37:12 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -81,7 +81,7 @@ public: NeonHeadRequest( HttpSession* inSession, const rtl::OUString & inPath, const std::vector< ::rtl::OUString > & inHeaderNames, - std::vector< DAVResource > & ioResources, + DAVResource & ioResource, int & nError ); ~NeonHeadRequest(); }; diff --git a/ucb/source/ucp/webdav/NeonSession.cxx b/ucb/source/ucp/webdav/NeonSession.cxx index 0a155d5b39a0..d69bbfdc3710 100644 --- a/ucb/source/ucp/webdav/NeonSession.cxx +++ b/ucb/source/ucp/webdav/NeonSession.cxx @@ -2,9 +2,9 @@ * * $RCSfile: NeonSession.cxx,v $ * - * $Revision: 1.22 $ + * $Revision: 1.23 $ * - * last change: $Author: kso $ $Date: 2002-09-03 13:06:53 $ + * last change: $Author: kso $ $Date: 2002-09-16 14:37:12 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -184,6 +184,35 @@ static sal_uInt16 makeStatusCode( const rtl::OUString & rStatusText ) return sal_uInt16( rStatusText.copy( 0, nPos ).toInt32() ); } +// ------------------------------------------------------------------- +struct NeonRequestContext +{ + uno::Reference< io::XOutputStream > xOutputStream; + rtl::Reference< NeonInputStream > xInputStream; + const std::vector< ::rtl::OUString > * pHeaderNames; + DAVResource * pResource; + + NeonRequestContext( uno::Reference< io::XOutputStream > & xOutStrm ) + : xOutputStream( xOutStrm ), xInputStream( 0 ), + pHeaderNames( 0 ), pResource( 0 ) {} + + NeonRequestContext( const rtl::Reference< NeonInputStream > & xInStrm ) + : xOutputStream( 0 ), xInputStream( xInStrm ), + pHeaderNames( 0 ), pResource( 0 ) {} + + NeonRequestContext( uno::Reference< io::XOutputStream > & xOutStrm, + const std::vector< ::rtl::OUString > & inHeaderNames, + DAVResource & ioResource ) + : xOutputStream( xOutStrm ), xInputStream( 0 ), + pHeaderNames( &inHeaderNames ), pResource( &ioResource ) {} + + NeonRequestContext( const rtl::Reference< NeonInputStream > & xInStrm, + const std::vector< ::rtl::OUString > & inHeaderNames, + DAVResource & ioResource ) + : xOutputStream( 0 ), xInputStream( xInStrm ), + pHeaderNames( &inHeaderNames ), pResource( &ioResource ) {} +}; + //-------------------------------------------------------------------- //-------------------------------------------------------------------- // @@ -203,9 +232,12 @@ extern "C" void NeonSession_ResponseBlockReader( void * inUserData, // neon calls this function with (inLen == 0)... if ( inLen > 0 ) { - NeonInputStream * theInputStream - = static_cast< NeonInputStream *>( inUserData ); - theInputStream->AddToStream( inBuf, inLen ); + NeonRequestContext * pCtx + = static_cast< NeonRequestContext * >( inUserData ); + rtl::Reference< NeonInputStream > xInputStream = pCtx->xInputStream; + + if ( xInputStream.is() ) + xInputStream->AddToStream( inBuf, inLen ); } } @@ -220,15 +252,15 @@ extern "C" void NeonSession_ResponseBlockWriter( void * inUserData, // neon calls this function with (inLen == 0)... if ( inLen > 0 ) { - uno::Reference< io::XOutputStream > * theOutputStreamPtr - = static_cast< uno::Reference< io::XOutputStream > * >( - inUserData ); - uno::Reference< io::XOutputStream > theOutputStream - = *theOutputStreamPtr; - - const uno::Sequence< sal_Int8 > theSequence( - (sal_Int8 *)inBuf, inLen ); - theOutputStream->writeBytes( theSequence ); + NeonRequestContext * pCtx + = static_cast< NeonRequestContext * >( inUserData ); + uno::Reference< io::XOutputStream > xOutputStream = pCtx->xOutputStream; + + if ( xOutputStream.is() ) + { + const uno::Sequence< sal_Int8 > aSeq( (sal_Int8 *)inBuf, inLen ); + xOutputStream->writeBytes( aSeq ); + } } } @@ -359,6 +391,59 @@ extern "C" void NeonSession_PreSendRequest( ne_request * req, } } +extern "C" void NeonSession_ResponseHeaderCatcher( void * userdata, + const char * value ) +{ + rtl::OUString aHeader( rtl::OUString::createFromAscii( value ) ); + sal_Int32 nPos = aHeader.indexOf( ':' ); + + if ( nPos != -1 ) + { + rtl::OUString aHeaderName( aHeader.copy( 0, nPos ) ); + + NeonRequestContext * pCtx + = static_cast< NeonRequestContext * >( userdata ); + + // Note: Empty vector means that all headers are requested. + bool bIncludeIt = ( pCtx->pHeaderNames->size() == 0 ); + + if ( !bIncludeIt ) + { + // Check whether this header was requested. + std::vector< ::rtl::OUString >::const_iterator it( + pCtx->pHeaderNames->begin() ); + const std::vector< ::rtl::OUString >::const_iterator end( + pCtx->pHeaderNames->end() ); + + while ( it != end ) + { + if ( (*it) == aHeaderName ) + break; + + ++it; + } + + if ( it != end ) + bIncludeIt = true; + } + + if ( bIncludeIt ) + { + // Create & set the PropertyValue + beans::PropertyValue thePropertyValue; + thePropertyValue.Handle = -1; + thePropertyValue.Name = aHeaderName; + thePropertyValue.State = beans::PropertyState_DIRECT_VALUE; + + if ( nPos < aHeader.getLength() ) + thePropertyValue.Value <<= aHeader.copy( nPos + 1 ).trim(); + + // Add the newly created PropertyValue + pCtx->pResource->properties.push_back( thePropertyValue ); + } + } +} + // ------------------------------------------------------------------- // Constructor // ------------------------------------------------------------------- @@ -690,7 +775,7 @@ void NeonSession::PROPPATCH( const rtl::OUString & inPath, // ------------------------------------------------------------------- void NeonSession::HEAD( const ::rtl::OUString & inPath, const std::vector< ::rtl::OUString > & inHeaderNames, - std::vector< DAVResource > & ioResources, + DAVResource & ioResource, const uno::Reference< ucb::XCommandEnvironment >& inEnv ) throw( DAVException ) @@ -703,7 +788,7 @@ void NeonSession::HEAD( const ::rtl::OUString & inPath, NeonHeadRequest theRequest( m_pHttpSession, inPath, inHeaderNames, - ioResources, + ioResource, theRetVal ); HandleError( theRetVal ); } @@ -721,14 +806,16 @@ uno::Reference< io::XInputStream > NeonSession::GET( m_xEnv = inEnv; - NeonInputStream * theInputStream = new NeonInputStream; + rtl::Reference< NeonInputStream > xInputStream( new NeonInputStream ); + NeonRequestContext aCtx( xInputStream ); int theRetVal = GET( m_pHttpSession, rtl::OUStringToOString( inPath, RTL_TEXTENCODING_UTF8 ), NeonSession_ResponseBlockReader, - theInputStream ); + 0, + &aCtx ); HandleError( theRetVal ); - return theInputStream; + return uno::Reference< io::XInputStream >( xInputStream.get() ); } // ------------------------------------------------------------------- @@ -744,11 +831,70 @@ void NeonSession::GET( const rtl::OUString & inPath, m_xEnv = inEnv; + NeonRequestContext aCtx( ioOutputStream ); int theRetVal = GET( m_pHttpSession, rtl::OUStringToOString( inPath, RTL_TEXTENCODING_UTF8 ), NeonSession_ResponseBlockWriter, - &ioOutputStream ); + 0, + &aCtx ); + HandleError( theRetVal ); +} + +// ------------------------------------------------------------------- +// GET +// ------------------------------------------------------------------- +uno::Reference< io::XInputStream > NeonSession::GET( + const rtl::OUString & inPath, + const std::vector< ::rtl::OUString > & inHeaderNames, + DAVResource & ioResource, + const uno::Reference< ucb::XCommandEnvironment > & inEnv ) + throw ( DAVException ) +{ + osl::Guard< osl::Mutex > theGuard( m_aMutex ); + + m_xEnv = inEnv; + + ioResource.uri = inPath; + ioResource.properties.clear(); + + rtl::Reference< NeonInputStream > xInputStream( new NeonInputStream ); + NeonRequestContext aCtx( xInputStream, inHeaderNames, ioResource ); + int theRetVal = GET( m_pHttpSession, + rtl::OUStringToOString( + inPath, RTL_TEXTENCODING_UTF8 ), + NeonSession_ResponseBlockReader, + NeonSession_ResponseHeaderCatcher, + &aCtx ); + HandleError( theRetVal ); + return uno::Reference< io::XInputStream >( xInputStream.get() ); +} + +// ------------------------------------------------------------------- +// GET +// ------------------------------------------------------------------- +void NeonSession::GET( + const rtl::OUString & inPath, + uno::Reference< io::XOutputStream > & ioOutputStream, + const std::vector< ::rtl::OUString > & inHeaderNames, + DAVResource & ioResource, + const uno::Reference< ucb::XCommandEnvironment > & inEnv ) + throw ( DAVException ) +{ + osl::Guard< osl::Mutex > theGuard( m_aMutex ); + + m_xEnv = inEnv; + + ioResource.uri = inPath; + ioResource.properties.clear(); + + NeonRequestContext aCtx( ioOutputStream, inHeaderNames, ioResource ); + int theRetVal = GET( m_pHttpSession, + rtl::OUStringToOString( + inPath, RTL_TEXTENCODING_UTF8 ), + NeonSession_ResponseBlockWriter, + NeonSession_ResponseHeaderCatcher, + &aCtx ); HandleError( theRetVal ); } @@ -804,19 +950,20 @@ uno::Reference< io::XInputStream > NeonSession::POST( m_xEnv = inEnv; - NeonInputStream * theInputStream = new NeonInputStream; + rtl::Reference< NeonInputStream > xInputStream( new NeonInputStream ); + NeonRequestContext aCtx( xInputStream ); int theRetVal = POST( m_pHttpSession, rtl::OUStringToOString( inPath, RTL_TEXTENCODING_UTF8 ), reinterpret_cast< const char * >( aDataToSend.getConstArray() ), NeonSession_ResponseBlockReader, - theInputStream, + &aCtx, rContentType, rReferer ); HandleError( theRetVal ); - return theInputStream; + return uno::Reference< io::XInputStream >( xInputStream.get() ); } // ------------------------------------------------------------------- @@ -840,13 +987,14 @@ void NeonSession::POST( const rtl::OUString & inPath, m_xEnv = inEnv; + NeonRequestContext aCtx( oOutputStream ); int theRetVal = POST( m_pHttpSession, rtl::OUStringToOString( inPath, RTL_TEXTENCODING_UTF8 ), reinterpret_cast< const char * >( aDataToSend.getConstArray() ), NeonSession_ResponseBlockWriter, - &oOutputStream, + &aCtx, rContentType, rReferer ); @@ -1240,16 +1388,14 @@ void NeonSession::Lockit( const Lock & inLock, bool inLockit ) int NeonSession::GET( ne_session * sess, const char * uri, ne_block_reader reader, + ne_header_handler handler, void * userdata ) { //struct get_context ctx; ne_request * req = ne_request_create( sess, "GET", uri ); int ret; - ///* Read the value of the Content-Length header into ctx.total */ - //ne_add_response_header_handler( req, "Content-Length", - // ne_handle_numeric_header, - // &ctx.total); + ne_add_response_header_catcher( req, handler, userdata ); ne_add_response_body_reader( req, ne_accept_2xx, reader, userdata ); diff --git a/ucb/source/ucp/webdav/NeonSession.hxx b/ucb/source/ucp/webdav/NeonSession.hxx index 46f39521b41d..b47e44903694 100644 --- a/ucb/source/ucp/webdav/NeonSession.hxx +++ b/ucb/source/ucp/webdav/NeonSession.hxx @@ -2,9 +2,9 @@ * * $RCSfile: NeonSession.hxx,v $ * - * $Revision: 1.14 $ + * $Revision: 1.15 $ * - * last change: $Author: kso $ $Date: 2002-09-03 13:06:53 $ + * last change: $Author: kso $ $Date: 2002-09-16 14:37:12 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -150,101 +150,132 @@ class NeonSession : public DAVSession void setUserName( const rtl::OUString & rUserName ); void setPassWord( const rtl::OUString & rPassWord ); - virtual void OPTIONS( const ::rtl::OUString & inPath, - DAVCapabilities & outCapabilities, - const com::sun::star::uno::Reference< - com::sun::star::ucb::XCommandEnvironment >& inEnv ) + virtual void + OPTIONS( const ::rtl::OUString & inPath, + DAVCapabilities & outCapabilities, + const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment > & inEnv ) throw ( DAVException ); // allprop & named - virtual void PROPFIND( const ::rtl::OUString & inPath, - const Depth inDepth, - const std::vector< ::rtl::OUString > & inPropNames, - std::vector< DAVResource > & ioResources, - const com::sun::star::uno::Reference< - com::sun::star::ucb::XCommandEnvironment >& inEnv ) + virtual void + PROPFIND( const ::rtl::OUString & inPath, + const Depth inDepth, + const std::vector< ::rtl::OUString > & inPropNames, + std::vector< DAVResource > & ioResources, + const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment > & inEnv ) throw ( DAVException ); // propnames - virtual void PROPFIND( const ::rtl::OUString & inPath, - const Depth inDepth, - std::vector< DAVResourceInfo >& ioResInfo, - const com::sun::star::uno::Reference< - com::sun::star::ucb::XCommandEnvironment >& inEnv ) + virtual void + PROPFIND( const ::rtl::OUString & inPath, + const Depth inDepth, + std::vector< DAVResourceInfo >& ioResInfo, + const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment > & inEnv ) throw ( DAVException ); - virtual void PROPPATCH( const ::rtl::OUString & inPath, - const std::vector< ProppatchValue > & inValues, - const com::sun::star::uno::Reference< - com::sun::star::ucb::XCommandEnvironment >& inEnv ) + virtual void + PROPPATCH( const ::rtl::OUString & inPath, + const std::vector< ProppatchValue > & inValues, + const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment > & inEnv ) throw( DAVException ); - virtual void HEAD( const ::rtl::OUString & inPath, - const std::vector< ::rtl::OUString > & inHeaderNames, - std::vector< DAVResource > & ioResources, - const com::sun::star::uno::Reference< - com::sun::star::ucb::XCommandEnvironment >& inEnv ) + virtual void + HEAD( const ::rtl::OUString & inPath, + const std::vector< ::rtl::OUString > & inHeaderNames, + DAVResource & ioResource, + const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment > & inEnv ) throw( DAVException ); - virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream > - GET( const ::rtl::OUString & inPath, - const com::sun::star::uno::Reference< - com::sun::star::ucb::XCommandEnvironment >& inEnv ) + virtual com::sun::star::uno::Reference< + com::sun::star::io::XInputStream > + GET( const ::rtl::OUString & inPath, + const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment > & inEnv ) throw ( DAVException ); - virtual void GET( const ::rtl::OUString & inPath, - com::sun::star::uno::Reference< - com::sun::star::io::XOutputStream > & ioOutputStream, - const com::sun::star::uno::Reference< - com::sun::star::ucb::XCommandEnvironment >& inEnv ) + virtual void + GET( const ::rtl::OUString & inPath, + com::sun::star::uno::Reference< + com::sun::star::io::XOutputStream > & ioOutputStream, + const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment > & inEnv ) throw ( DAVException ); + virtual com::sun::star::uno::Reference< + com::sun::star::io::XInputStream > + GET( const ::rtl::OUString & inPath, + const std::vector< ::rtl::OUString > & inHeaderNames, + DAVResource & ioResource, + const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment > & inEnv ) + throw ( DAVException ); - virtual void PUT( const ::rtl::OUString & inPath, - const com::sun::star::uno::Reference< - com::sun::star::io::XInputStream > & inInputStream, - const com::sun::star::uno::Reference< - com::sun::star::ucb::XCommandEnvironment >& inEnv ) + virtual void + GET( const ::rtl::OUString & inPath, + com::sun::star::uno::Reference< + com::sun::star::io::XOutputStream > & ioOutputStream, + const std::vector< ::rtl::OUString > & inHeaderNames, + DAVResource & ioResource, + const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment > & inEnv ) throw ( DAVException ); - virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream > - POST( const rtl::OUString & inPath, - const rtl::OUString & rContentType, - const rtl::OUString & rReferer, - const com::sun::star::uno::Reference< - com::sun::star::io::XInputStream > & inInputStream, - const com::sun::star::uno::Reference< - com::sun::star::ucb::XCommandEnvironment >& inEnv ) + virtual void + PUT( const ::rtl::OUString & inPath, + const com::sun::star::uno::Reference< + com::sun::star::io::XInputStream > & inInputStream, + const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment > & inEnv ) throw ( DAVException ); - virtual void POST( const rtl::OUString & inPath, - const rtl::OUString & rContentType, - const rtl::OUString & rReferer, - const com::sun::star::uno::Reference< - com::sun::star::io::XInputStream > & inInputStream, - com::sun::star::uno::Reference< - com::sun::star::io::XOutputStream > & oOutputStream, - const com::sun::star::uno::Reference< - com::sun::star::ucb::XCommandEnvironment >& inEnv ) + virtual com::sun::star::uno::Reference< + com::sun::star::io::XInputStream > + POST( const rtl::OUString & inPath, + const rtl::OUString & rContentType, + const rtl::OUString & rReferer, + const com::sun::star::uno::Reference< + com::sun::star::io::XInputStream > & inInputStream, + const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment >& inEnv ) throw ( DAVException ); - virtual void MKCOL( const ::rtl::OUString & inPath, - const com::sun::star::uno::Reference< - com::sun::star::ucb::XCommandEnvironment >& inEnv ) + virtual void + POST( const rtl::OUString & inPath, + const rtl::OUString & rContentType, + const rtl::OUString & rReferer, + const com::sun::star::uno::Reference< + com::sun::star::io::XInputStream > & inInputStream, + com::sun::star::uno::Reference< + com::sun::star::io::XOutputStream > & oOutputStream, + const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment > & inEnv ) throw ( DAVException ); - virtual void COPY( const ::rtl::OUString & inSourceURL, - const ::rtl::OUString & inDestinationURL, - const com::sun::star::uno::Reference< - com::sun::star::ucb::XCommandEnvironment >& inEnv, - sal_Bool inOverWrite ) + virtual void + MKCOL( const ::rtl::OUString & inPath, + const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment > & inEnv ) throw ( DAVException ); - virtual void MOVE( const ::rtl::OUString & inSourceURL, - const ::rtl::OUString & inDestinationURL, - const com::sun::star::uno::Reference< - com::sun::star::ucb::XCommandEnvironment >& inEnv, - sal_Bool inOverWrite ) + virtual void + COPY( const ::rtl::OUString & inSourceURL, + const ::rtl::OUString & inDestinationURL, + const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment >& inEnv, + sal_Bool inOverWrite ) + throw ( DAVException ); + + virtual void + MOVE( const ::rtl::OUString & inSourceURL, + const ::rtl::OUString & inDestinationURL, + const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment >& inEnv, + sal_Bool inOverWrite ) throw ( DAVException ); virtual void DESTROY( const ::rtl::OUString & inPath, @@ -274,12 +305,12 @@ class NeonSession : public DAVSession throw ( DAVException ); // Create a Neon session for server at supplied host & port - HttpSession * CreateSession( const ::rtl::OUString & inScheme, - const ::rtl::OUString & inHostName, - int inPort, - const ::rtl::OUString & inProxyName, - int inProxyPort, - const ::rtl::OUString & inUserInfo ) + HttpSession * CreateSession( const ::rtl::OUString & inScheme, + const ::rtl::OUString & inHostName, + int inPort, + const ::rtl::OUString & inProxyName, + int inProxyPort, + const ::rtl::OUString & inUserInfo ) throw( DAVException ); // Note: Uncomment the following if locking support is required @@ -291,6 +322,7 @@ class NeonSession : public DAVSession static int GET( ne_session * sess, const char * uri, ne_block_reader reader, + ne_header_handler handler, void * userdata ); // Buffer-based PUT implementation. Neon only has file descriptor- diff --git a/ucb/source/ucp/webdav/webdavcontent.cxx b/ucb/source/ucp/webdav/webdavcontent.cxx index 938e19252663..df15546d3a0d 100644 --- a/ucb/source/ucp/webdav/webdavcontent.cxx +++ b/ucb/source/ucp/webdav/webdavcontent.cxx @@ -2,9 +2,9 @@ * * $RCSfile: webdavcontent.cxx,v $ * - * $Revision: 1.32 $ + * $Revision: 1.33 $ * - * last change: $Author: kso $ $Date: 2002-08-29 09:00:13 $ + * last change: $Author: kso $ $Date: 2002-09-16 14:37:13 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,6 +59,8 @@ * ************************************************************************/ +#define CACHE_RESPONSE_HEADERS 1 + /************************************************************************** TODO ************************************************************************** @@ -555,7 +557,23 @@ uno::Any SAL_CALL Content::execute( // PUSH: write data try { +#ifdef CACHE_RESPONSE_HEADERS + // throw away previously cached headers. + m_xCachedProps.reset(); + + DAVResource aResource; + std::vector< rtl::OUString > aHeaders; +// // Obtain list containing all HTTP headers that can +// // be mapped to UCB properties. +// ContentProperties::getMappableHTTPHeaders( aHeaders ); + + m_xResAccess->GET( xOut, aHeaders, aResource, Environment ); + + // cache headers. + m_xCachedProps.reset( new ContentProperties( aResource ) ); +#else m_xResAccess->GET( xOut, Environment ); +#endif } catch ( DAVException const & e ) { @@ -573,8 +591,27 @@ uno::Any SAL_CALL Content::execute( // PULL: wait for client read try { +#ifdef CACHE_RESPONSE_HEADERS + // throw away previously cached headers. + m_xCachedProps.reset(); + + DAVResource aResource; + std::vector< rtl::OUString > aHeaders; +// // Obtain list containing all HTTP headers that can +// // be mapped to UCB properties. +// ContentProperties::getMappableHTTPHeaders( aHeaders ); + + uno::Reference< io::XInputStream > xIn + = m_xResAccess->GET( + aHeaders, aResource, Environment ); + + // cache headers. + m_xCachedProps.reset( + new ContentProperties( aResource ) ); +#else uno::Reference< io::XInputStream > xIn = m_xResAccess->GET( Environment ); +#endif xDataSink->setInputStream( xIn ); } catch ( DAVException const & e ) @@ -1159,384 +1196,57 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues( { const beans::Property& rProp = pProps[ n ]; - // Process Core properties. - - if ( rProp.Name.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM( "ContentType" ) ) ) - { - sal_Bool bFolder, bDocument; - if ( rData.queryIsFolder( bFolder ) && bFolder ) - xRow->appendString( rProp, rtl::OUString::createFromAscii( - WEBDAV_COLLECTION_TYPE ) ); - else if ( rData.queryIsDocument( bDocument ) && bDocument ) - xRow->appendString( rProp, rtl::OUString::createFromAscii( - WEBDAV_CONTENT_TYPE ) ); - else - xRow->appendVoid( rProp ); - } - else if ( rProp.Name.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM( "Title" ) ) ) + // Process standard UCB, DAV and HTTP properties. + const uno::Any & rValue = rData.getValue( rProp.Name ); + if ( rValue.hasValue() ) { - rtl::OUString aTitle; - if ( rData.queryTitle( aTitle ) ) - xRow->appendString ( rProp, aTitle ); - else - xRow->appendVoid( rProp ); + xRow->appendObject( rProp, rValue ); } - else if ( rProp.Name.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM( "IsDocument" ) ) ) - { - sal_Bool bDocument; - if ( rData.queryIsDocument( bDocument ) ) - xRow->appendBoolean( rProp, bDocument ); - else - xRow->appendVoid( rProp ); - } - else if ( rProp.Name.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM( "IsFolder" ) ) ) - { - sal_Bool bFolder; - if ( rData.queryIsFolder( bFolder ) ) - xRow->appendBoolean( rProp, bFolder ); - else - xRow->appendVoid( rProp ); - } - else if ( rProp.Name.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM( "Size" ) ) ) - { - sal_Int64 nSize; - if ( rData.querySize( nSize) ) - xRow->appendLong( rProp, nSize ); - else - xRow->appendVoid( rProp ); - } - else if ( rProp.Name.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM( "DateCreated" ) ) ) - { - util::DateTime aDateCreated; - if ( rData.queryDateCreated( aDateCreated ) ) - xRow->appendTimestamp( rProp, aDateCreated ); - else - xRow->appendVoid( rProp ); - } - else if ( rProp.Name.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM( "DateModified" ) ) ) - { - util::DateTime aDateModified; - if ( rData.queryDateModified( aDateModified ) ) - xRow->appendTimestamp( rProp, aDateModified ); - else - xRow->appendVoid( rProp ); - - } - else if ( rProp.Name.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM( "MediaType" ) ) ) - { - rtl::OUString aType; - if ( rData.queryMediaType( aType ) ) - xRow->appendString( rProp, aType ); - else - xRow->appendVoid( rProp ); - } - else if ( rProp.Name.equals( DAVProperties::CREATIONDATE ) ) - { - rtl::OUString aCreateionDate; - if ( rData.queryDAVCreationDate( aCreateionDate ) ) - xRow->appendString( rProp, aCreateionDate ); - else - xRow->appendVoid( rProp ); - } - else if ( rProp.Name.equals( DAVProperties::DISPLAYNAME ) ) - { - rtl::OUString aDisplayName; - if ( rData.queryDAVDisplayName( aDisplayName ) ) - xRow->appendString( rProp, aDisplayName ); - else - xRow->appendVoid( rProp ); - } - else if ( rProp.Name.equals( DAVProperties::GETCONTENTLANGUAGE ) ) - { - rtl::OUString aLanguage; - if ( rData.queryDAVContentLanguage( aLanguage ) ) - xRow->appendString( rProp, aLanguage ); - else - xRow->appendVoid( rProp ); - } - else if ( rProp.Name.equals( DAVProperties::GETCONTENTLENGTH ) ) - { - rtl::OUString aLength; - if ( rData.queryDAVContentLength( aLength ) ) - xRow->appendString( rProp, aLength ); - else - xRow->appendVoid( rProp ); - } - else if ( rProp.Name.equals( DAVProperties::GETCONTENTTYPE ) ) - { - rtl::OUString aType; - if ( rData.queryDAVContentType( aType ) ) - xRow->appendString( rProp, aType ); - else - xRow->appendVoid( rProp ); - } - else if ( rProp.Name.equals( DAVProperties::GETETAG ) ) - { - rtl::OUString aTag; - if ( rData.queryDAVETag( aTag ) ) - xRow->appendString( rProp, aTag ); - else - xRow->appendVoid( rProp ); - } - else if ( rProp.Name.equals( DAVProperties::GETLASTMODIFIED ) ) - { - rtl::OUString aDate; - if ( rData.queryDAVLastModified( aDate ) ) - xRow->appendString( rProp, aDate ); - else - xRow->appendVoid( rProp ); - } - else if ( rProp.Name.equals( DAVProperties::LOCKDISCOVERY ) ) - { - uno::Sequence< star::ucb::Lock > aLocks; - if ( rData.queryDAVLockDiscovery( aLocks ) ) - xRow->appendObject( rProp, uno::makeAny( aLocks ) ); - else - xRow->appendVoid( rProp ); - } - else if ( rProp.Name.equals( DAVProperties::RESOURCETYPE ) ) - { - rtl::OUString aType; - if ( rData.queryDAVResourceType( aType ) ) - xRow->appendString( rProp, aType ); - else - xRow->appendVoid( rProp ); - } - else if ( rProp.Name.equals( DAVProperties::SOURCE ) ) - { - uno::Sequence< star::ucb::Link > aSource; - if ( rData.queryDAVSource( aSource ) ) - xRow->appendObject( rProp, uno::makeAny( aSource ) ); - else - xRow->appendVoid( rProp ); - } - else if ( rProp.Name.equals( DAVProperties::SUPPORTEDLOCK ) ) - { - uno::Sequence< star::ucb::LockEntry > aLockEntries; - if ( rData.queryDAVSupportedLock( aLockEntries ) ) - xRow->appendObject( rProp, - uno::makeAny( aLockEntries ) ); - else - xRow->appendVoid( rProp ); - } else { - sal_Bool bAppended = sal_False; - - const PropertyValueMap * pOtherProps - = rData.getOtherProperties(); - if ( pOtherProps ) + // Process local Additional Properties. + if ( !bTriedToGetAdditonalPropSet && !xAdditionalPropSet.is() ) { - // Process additional properties (DAV "dead" properties). - const PropertyValueMap::const_iterator it - = pOtherProps->find( rProp.Name ); - if ( it != pOtherProps->end() ) - { - xRow->appendObject( rProp, (*it).second ); - bAppended = sal_True; - } + xAdditionalPropSet + = uno::Reference< beans::XPropertySet >( + rProvider->getAdditionalPropertySet( rContentId, + sal_False ), + uno::UNO_QUERY ); + bTriedToGetAdditonalPropSet = sal_True; } - if ( !bAppended ) + if ( !xAdditionalPropSet.is() || + !xRow->appendPropertySetValue( + xAdditionalPropSet, rProp ) ) { - // Process local additional properties. - if ( !bTriedToGetAdditonalPropSet - && !xAdditionalPropSet.is() ) - { - xAdditionalPropSet - = uno::Reference< beans::XPropertySet >( - rProvider->getAdditionalPropertySet( - rContentId, sal_False ), - uno::UNO_QUERY ); - bTriedToGetAdditonalPropSet = sal_True; - } - - if ( xAdditionalPropSet.is() ) - { - if ( xRow->appendPropertySetValue( - xAdditionalPropSet, rProp ) ) - bAppended = sal_True; - } - } - - if ( !bAppended ) - { - // Append empty entry. - xRow->appendVoid( rProp ); + // Append empty entry. + xRow->appendVoid( rProp ); } } } } else { - // Append all Core Properties. - ContentProvider * pProvider - = static_cast< ContentProvider * >( rProvider.get() ); - beans::Property aProp; - - rtl::OUString aString; - if ( rData.queryTitle( aString ) ) - { - pProvider->getProperty( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "Title" ) ), aProp ); - xRow->appendString( aProp, aString ); - } - - sal_Bool bBool; - if ( rData.queryIsDocument( bBool ) && bBool ) - { - pProvider->getProperty( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) ), aProp ); - xRow->appendString( aProp, rtl::OUString::createFromAscii( - WEBDAV_CONTENT_TYPE ) ); - pProvider->getProperty( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "IsDocument" ) ), aProp ); - xRow->appendBoolean( aProp, bBool ); - } - - if ( rData.queryIsFolder( bBool ) && bBool ) - { - pProvider->getProperty( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) ), aProp ); - xRow->appendString( aProp, rtl::OUString::createFromAscii( - WEBDAV_COLLECTION_TYPE ) ); - pProvider->getProperty( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ), aProp ); - xRow->appendBoolean( aProp, bBool ); - } - - sal_Int64 nInt64; - if ( rData.querySize( nInt64 ) ) - { - pProvider->getProperty( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Size" ) ), aProp ); - xRow->appendLong( aProp, nInt64 ); - } - - util::DateTime aDateTime; - if ( rData.queryDateCreated( aDateTime ) ) - { - pProvider->getProperty( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DateCreated" ) ), - aProp ); - xRow->appendTimestamp( aProp, aDateTime ); - } - - if ( rData.queryDateModified( aDateTime ) ) - { - pProvider->getProperty( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DateModified" ) ), - aProp ); - xRow->appendTimestamp( aProp, aDateTime ); - } - - if ( rData.queryMediaType( aString ) ) - { - pProvider->getProperty( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ), aProp ); - xRow->appendString( aProp, aString ); - } - - if ( rData.queryDAVCreationDate( aString ) ) - { - pProvider->getProperty( DAVProperties::CREATIONDATE, aProp ); - xRow->appendString( aProp, aString ); - } + // Append all standard UCB, DAV and HTTP properties. - if ( rData.queryDAVDisplayName( aString ) ) - { - pProvider->getProperty( DAVProperties::DISPLAYNAME, aProp ); - xRow->appendString( aProp, aString ); - } + const std::auto_ptr< PropertyValueMap > xProps = rData.getProperties(); - if ( rData.queryDAVContentLanguage( aString ) ) - { - pProvider->getProperty( DAVProperties::GETCONTENTLANGUAGE, aProp ); - xRow->appendString( aProp, aString ); - } - - if ( rData.queryDAVContentLength( aString ) ) - { - pProvider->getProperty( DAVProperties::GETCONTENTLENGTH, aProp ); - xRow->appendString( aProp, aString ); - } - - if ( rData.queryDAVContentType( aString ) ) - { - pProvider->getProperty( DAVProperties::GETCONTENTTYPE, aProp ); - xRow->appendString( aProp, aString ); - } - - if ( rData.queryDAVETag( aString ) ) - { - pProvider->getProperty( DAVProperties::GETETAG, aProp ); - xRow->appendString( aProp, aString ); - } + PropertyValueMap::const_iterator it = xProps->begin(); + PropertyValueMap::const_iterator end = xProps->end(); - if ( rData.queryDAVLastModified( aString ) ) - { - pProvider->getProperty( DAVProperties::GETLASTMODIFIED, aProp ); - xRow->appendString( aProp, aString ); - } - - uno::Sequence< star::ucb::Lock > aLocks; - if ( rData.queryDAVLockDiscovery( aLocks ) ) - { - pProvider->getProperty( DAVProperties::LOCKDISCOVERY, aProp ); - xRow->appendObject( aProp, uno::makeAny( aLocks ) ); - } - - if ( rData.queryDAVResourceType( aString ) ) - { - pProvider->getProperty( DAVProperties::RESOURCETYPE, aProp ); - xRow->appendString( aProp, aString ); - } - - uno::Sequence< star::ucb::Link > aLinks; - if ( rData.queryDAVSource( aLinks ) ) - { - pProvider->getProperty( DAVProperties::SOURCE, aProp ); - xRow->appendObject( aProp, uno::makeAny( aLinks ) ); - } - - uno::Sequence< star::ucb::LockEntry > aLockEntries; - if ( rData.queryDAVSupportedLock( aLockEntries ) ) - { - pProvider->getProperty( DAVProperties::SUPPORTEDLOCK, aProp ); - xRow->appendObject( aProp, uno::makeAny( aLockEntries ) ); - } + ContentProvider * pProvider + = static_cast< ContentProvider * >( rProvider.get() ); + beans::Property aProp; - // Process additional properties (DAV "dead" properties). - const PropertyValueMap * pOtherProps = rData.getOtherProperties(); - if ( pOtherProps ) + while ( it != end ) { - PropertyValueMap::const_iterator it = pOtherProps->begin(); - PropertyValueMap::const_iterator end = pOtherProps->end(); - - beans::Property aProp; - while ( it != end ) - { - pProvider->getProperty( (*it).first, aProp ); + if ( pProvider->getProperty( (*it).first, aProp ) ) xRow->appendObject( aProp, (*it).second ); - it++; - } + + ++it; } - // Append all local Additional Core Properties. + // Append all local Additional Properties. uno::Reference< beans::XPropertySet > xSet( rProvider->getAdditionalPropertySet( rContentId, sal_False ), uno::UNO_QUERY ); @@ -1553,122 +1263,145 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues( { osl::Guard< osl::Mutex > aGuard( m_aMutex ); - if ( m_bTransient ) + std::auto_ptr< ContentProperties > xProps; + bool bHasAll = false; + + // First, ask cache... + if ( m_xCachedProps.get() ) { - // No PROPFIND, but minimal local props. - return getPropertyValues( m_xSMgr, - rProperties, - ContentProperties( - NeonUri::unescape( m_aEscapedTitle ), - m_bCollection ), - rtl::Reference< - ::ucb::ContentProviderImplHelper >( - m_xProvider.getBodyPtr() ), - m_xIdentifier->getContentIdentifier() ); + std::vector< rtl::OUString > aMissingProps; + if ( m_xCachedProps->containsAllNames( rProperties, aMissingProps ) ) + { + // All requested properties are already in cache! No server + // access needed. + bHasAll = true; + xProps.reset( new ContentProperties( *m_xCachedProps.get() ) ); + } } - // Only title requested? No PROPFIND necessary. - if ( ( rProperties.getLength() == 1 ) - && - rProperties[ 0 ].Name.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM( "Title" ) ) ) + if ( !xProps.get() ) { - return getPropertyValues( m_xSMgr, - rProperties, - ContentProperties( - NeonUri::unescape( m_aEscapedTitle ), - m_bCollection ), - rtl::Reference< - ::ucb::ContentProviderImplHelper >( - m_xProvider.getBodyPtr() ), - m_xIdentifier->getContentIdentifier() ); + // No server access for just created (not yet committed) objects. + // Only a minimal set of properties supported at this stage. + if ( m_bTransient ) + xProps.reset( new ContentProperties( NeonUri::unescape( + m_aEscapedTitle ), + m_bCollection ) ); } - bool bSuccess = true; - std::vector< rtl::OUString > aPropNames; - ContentProperties::UCBNamesToDAVNames( rProperties, aPropNames ); - - std::vector< DAVResource > resources; - if ( aPropNames.size() > 0 ) + if ( !xProps.get() ) { - try - { - m_xResAccess->PROPFIND( ZERO, aPropNames, resources, xEnv ); - } - catch ( DAVException const & e ) - { - if ( ( e.getStatus() == 404 /* not found */ ) || - ( e.getError() == DAVException::DAV_HTTP_LOOKUP ) ) - { - // PROPFIND failed, only Title prop available. - return getPropertyValues( m_xSMgr, - rProperties, - ContentProperties( - NeonUri::unescape( - m_aEscapedTitle ) ), - rtl::Reference< - ::ucb::ContentProviderImplHelper >( - m_xProvider.getBodyPtr() ), - m_xIdentifier - ->getContentIdentifier() ); - } - - bSuccess = false; - } + // No server access if only Title property is requested because + // it's always calculated from Content's URI. + if ( ( rProperties.getLength() == 1 ) && + rProperties[ 0 ].Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( "Title" ) ) ) + xProps.reset( new ContentProperties( NeonUri::unescape( + m_aEscapedTitle ) ) ); } - if ( !bSuccess ) + if ( !xProps.get() ) { - // PROPFIND failed. Try a HEAD request; possibly the requested - // properties can by obtained this way. + // Obtain values from server... + + bool bNetAccessSucceeded = false; + std::vector< DAVResource > resources; - // Note: I set bIncludeUnmatched to false, because I want to avoid - // every HEAD request not really needed. + std::vector< rtl::OUString > aPropNames; + ContentProperties::UCBNamesToDAVNames( rProperties, aPropNames ); - std::vector< rtl::OUString > aHeaderNames; - ContentProperties::UCBNamesToHTTPNames( rProperties, - aHeaderNames, - false /* bIncludeUnmatched */ ); - if ( aHeaderNames.size() > 0 ) + if ( aPropNames.size() > 0 ) { try { - resources.clear(); - m_xResAccess->HEAD( aHeaderNames, resources, xEnv ); - bSuccess = true; + m_xResAccess->PROPFIND( ZERO, aPropNames, resources, xEnv ); + bNetAccessSucceeded = true; } - catch ( DAVException const & ) + catch ( DAVException const & e ) { - bSuccess = false; + if ( ( e.getStatus() == 404 /* not found */ ) || + ( e.getError() == DAVException::DAV_HTTP_LOOKUP ) ) + { + // PROPFIND failed, only Title prop available. + xProps.reset( new ContentProperties( + NeonUri::unescape( m_aEscapedTitle ) ) ); + } } } - } + else + { + bNetAccessSucceeded = true; + } - bSuccess &= ( resources.size() == 1 ); + if ( !bNetAccessSucceeded ) + { + // PROPFIND failed. Try a HEAD request; possibly the requested + // properties can by obtained this way. - if ( bSuccess ) - { - return getPropertyValues( m_xSMgr, - rProperties, - ContentProperties( resources[ 0 ] ), - rtl::Reference< - ::ucb::ContentProviderImplHelper >( - m_xProvider.getBodyPtr() ), - m_xIdentifier->getContentIdentifier() ); + std::vector< rtl::OUString > aHeaderNames; + ContentProperties::UCBNamesToHTTPNames( + rProperties, aHeaderNames, false /* bIncludeUnmatched */ ); + + // Note: Setting bIncludeUnmatched to true would provide support for + // obtaining arbitrary header values, but will result in additional + // network traffic (HEAD requests). For the moment it is okay only + // to support the header values which can be mapped to UCB + // properties (like "Content-Length" header <-> "Size" property) + + if ( aHeaderNames.size() > 0 ) + { + try + { + resources.clear(); + + DAVResource resource; + m_xResAccess->HEAD( aHeaderNames, resource, xEnv ); + + resources.push_back( resource ); + bNetAccessSucceeded = true; + } + catch ( DAVException const & ) + { + bNetAccessSucceeded = false; + } + } + } + + bNetAccessSucceeded &= ( resources.size() == 1 ); + + if ( bNetAccessSucceeded ) + { + xProps.reset( new ContentProperties( resources[ 0 ] ) ); + } + else + { + xProps.reset( new ContentProperties( + NeonUri::unescape( m_aEscapedTitle ) ) ); + } } - else + + OSL_ENSURE( xProps.get(), "Content::getPropertyValues - no properties!" ); + + // All values obtained? If not, is there something valueable in the local + // cache? + + if ( !bHasAll && m_xCachedProps.get() ) { - // PROPFIND failed, but minimal local props "available". - return getPropertyValues( m_xSMgr, - rProperties, - ContentProperties( - NeonUri::unescape( m_aEscapedTitle ), - sal_False /* no collection */ ), - rtl::Reference< - ::ucb::ContentProviderImplHelper >( - m_xProvider.getBodyPtr() ), - m_xIdentifier->getContentIdentifier() ); + std::vector< rtl::OUString > aMissingProps; + if ( !xProps->containsAllNames( rProperties, aMissingProps ) ) + { + // Add props contained in cache... + xProps->add( aMissingProps, *m_xCachedProps ); + } } + + return getPropertyValues( m_xSMgr, + rProperties, + *xProps, + rtl::Reference< + ::ucb::ContentProviderImplHelper >( + m_xProvider.getBodyPtr() ), + m_xIdentifier->getContentIdentifier() ); } //========================================================================= @@ -1711,9 +1444,10 @@ uno::Sequence< uno::Any > Content::setPropertyValues( for ( sal_Int32 n = 0; n < nCount; ++n ) { const beans::PropertyValue& rValue = pValues[ n ]; + const rtl::OUString & rName = rValue.Name; beans::Property aTmpProp; - m_pProvider->getProperty( rValue.Name, aTmpProp ); + m_pProvider->getProperty( rName, aTmpProp ); if ( aTmpProp.Attributes & beans::PropertyAttribute::READONLY ) { @@ -1729,8 +1463,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( // Mandatory props. ////////////////////////////////////////////////////////////////// - if ( rValue.Name.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM( "ContentType" ) ) ) + if ( rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ContentType" ) ) ) { // Read-only property! aRet[ n ] <<= lang::IllegalAccessException( @@ -1738,8 +1471,8 @@ uno::Sequence< uno::Any > Content::setPropertyValues( "Property is read-only!" ), static_cast< cppu::OWeakObject * >( this ) ); } - else if ( rValue.Name.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM( "IsDocument" ) ) ) + else if ( rName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( "IsDocument" ) ) ) { // Read-only property! aRet[ n ] <<= lang::IllegalAccessException( @@ -1747,8 +1480,8 @@ uno::Sequence< uno::Any > Content::setPropertyValues( "Property is read-only!" ), static_cast< cppu::OWeakObject * >( this ) ); } - else if ( rValue.Name.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM( "IsFolder" ) ) ) + else if ( rName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( "IsFolder" ) ) ) { // Read-only property! aRet[ n ] <<= lang::IllegalAccessException( @@ -1756,8 +1489,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( "Property is read-only!" ), static_cast< cppu::OWeakObject * >( this ) ); } - else if ( rValue.Name.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM( "Title" ) ) ) + else if ( rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Title" ) ) ) { rtl::OUString aNewValue; if ( rValue.Value >>= aNewValue ) @@ -1809,7 +1541,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( xInfo = getPropertySetInfo( xEnv, sal_False /* don't cache data */ ); - if ( !xInfo->hasPropertyByName( rValue.Name ) ) + if ( !xInfo->hasPropertyByName( rName ) ) { // Check, whether property exists. Skip otherwise. // PROPPATCH::set would add the property automatically, which @@ -1821,8 +1553,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( continue; } - if ( rValue.Name.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM( "Size" ) ) ) + if ( rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Size" ) ) ) { // Read-only property! aRet[ n ] <<= lang::IllegalAccessException( @@ -1830,7 +1561,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( "Property is read-only!" ), static_cast< cppu::OWeakObject * >( this ) ); } - else if ( rValue.Name.equalsAsciiL( + else if ( rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "DateCreated" ) ) ) { // Read-only property! @@ -1839,7 +1570,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( "Property is read-only!" ), static_cast< cppu::OWeakObject * >( this ) ); } - else if ( rValue.Name.equalsAsciiL( + else if ( rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "DateModified" ) ) ) { // Read-only property! @@ -1848,7 +1579,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( "Property is read-only!" ), static_cast< cppu::OWeakObject * >( this ) ); } - else if ( rValue.Name.equalsAsciiL( + else if ( rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "MediaType" ) ) ) { // Read-only property! @@ -1879,7 +1610,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( if ( bDAV ) { // Property value will be set on server. - ProppatchValue aValue( PROPSET, rValue.Name, rValue.Value ); + ProppatchValue aValue( PROPSET, rName, rValue.Value ); aProppatchValues.push_back( aValue ); // remember position within sequence of values (for @@ -1902,14 +1633,13 @@ uno::Sequence< uno::Any > Content::setPropertyValues( try { uno::Any aOldValue - = xAdditionalPropSet->getPropertyValue( - rValue.Name ); + = xAdditionalPropSet->getPropertyValue( rName ); if ( aOldValue != rValue.Value ) { xAdditionalPropSet->setPropertyValue( - rValue.Name, rValue.Value ); + rName, rValue.Value ); - aEvent.PropertyName = rValue.Name; + aEvent.PropertyName = rName; aEvent.OldValue = aOldValue; aEvent.NewValue = rValue.Value; @@ -2625,8 +2355,12 @@ sal_Bool Content::isFolder( return sal_False; ContentProperties aContentProperties( resources[ 0 ] ); - sal_Bool bFolder; - return ( aContentProperties.queryIsFolder( bFolder ) && bFolder ); + const uno::Any & rValue + = aContentProperties.getValue( + rtl::OUString::createFromAscii( "IsFolder" ) ); + sal_Bool bFolder = sal_False; + rValue >>= bFolder; + return bFolder; } } diff --git a/ucb/source/ucp/webdav/webdavcontent.hxx b/ucb/source/ucp/webdav/webdavcontent.hxx index a8623b37ac25..fbad172effaa 100644 --- a/ucb/source/ucp/webdav/webdavcontent.hxx +++ b/ucb/source/ucp/webdav/webdavcontent.hxx @@ -2,9 +2,9 @@ * * $RCSfile: webdavcontent.hxx,v $ * - * $Revision: 1.14 $ + * $Revision: 1.15 $ * - * last change: $Author: kso $ $Date: 2001-11-26 09:45:37 $ + * last change: $Author: kso $ $Date: 2002-09-16 14:37:14 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -121,6 +121,7 @@ class Content : public ::ucb::ContentImplHelper, public com::sun::star::ucb::XContentCreator { std::auto_ptr< DAVResourceAccess > m_xResAccess; + std::auto_ptr< ContentProperties > m_xCachedProps; // locally cached props rtl::OUString m_aEscapedTitle; ContentProvider* m_pProvider; // No need for a ref, base class holds object sal_Bool m_bTransient; @@ -147,6 +148,7 @@ private: ::com::sun::star::beans::Property >& rProperties, const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& xEnv ); + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > setPropertyValues( const ::com::sun::star::uno::Sequence< diff --git a/ucb/source/ucp/webdav/webdavdatasupplier.cxx b/ucb/source/ucp/webdav/webdavdatasupplier.cxx index 4b0a484e1af7..16a2b0e3f13c 100644 --- a/ucb/source/ucp/webdav/webdavdatasupplier.cxx +++ b/ucb/source/ucp/webdav/webdavdatasupplier.cxx @@ -2,9 +2,9 @@ * * $RCSfile: webdavdatasupplier.cxx,v $ * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * - * last change: $Author: kso $ $Date: 2002-08-29 09:00:14 $ + * last change: $Author: kso $ $Date: 2002-09-16 14:37:14 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -216,9 +216,7 @@ rtl::OUString DataSupplier::queryContentIdentifierString( sal_uInt32 nIndex ) if ( ( aId.lastIndexOf( '/' ) + 1 ) != aId.getLength() ) aId += rtl::OUString::createFromAscii( "/" ); - rtl::OUString aTitle; - props.queryEscapedTitle( aTitle ); - aId += aTitle; + aId += props.getEscapedTitle(); if ( props.isTrailingSlash() ) aId += rtl::OUString::createFromAscii( "/" ); @@ -486,25 +484,31 @@ sal_Bool DataSupplier::getData() { case com::sun::star::ucb::OpenMode::FOLDERS: { - sal_Bool bFolder; - if ( !( pContentProperties->queryIsFolder( bFolder ) - && bFolder ) ) - { - // Entry is not a folder. + sal_Bool bFolder = sal_False; + + const uno::Any & rValue + = pContentProperties->getValue( + rtl::OUString::createFromAscii( "IsFolder" ) ); + rValue >>= bFolder; + + if ( !bFolder ) continue; - } + break; } case com::sun::star::ucb::OpenMode::DOCUMENTS: { - sal_Bool bDocument; - if ( !( pContentProperties->queryIsDocument( bDocument ) - && bDocument ) ) - { - // Entry is not a document. + sal_Bool bDocument = sal_False; + + const uno::Any & rValue + = pContentProperties->getValue( + rtl::OUString::createFromAscii( "IsDocument" ) ); + rValue >>= bDocument; + + if ( !bDocument ) continue; - } + break; } |