summaryrefslogtreecommitdiff
path: root/ucb
diff options
context:
space:
mode:
authorKai Sommerfeld <kso@openoffice.org>2002-09-24 13:15:50 +0000
committerKai Sommerfeld <kso@openoffice.org>2002-09-24 13:15:50 +0000
commit24f19e7ec5acf277cd1db2ee82799a0fcb1b819a (patch)
tree21c183fb01afcf8c55ab7714ba2d6f663b89dfab /ucb
parent9d99bc95c446232234c6156dc056656bc1891096 (diff)
#102945# - Added support for new property "BaseURI".
Diffstat (limited to 'ucb')
-rw-r--r--ucb/source/ucp/webdav/ContentProperties.cxx39
-rw-r--r--ucb/source/ucp/webdav/ContentProperties.hxx21
-rw-r--r--ucb/source/ucp/webdav/DAVRequestEnvironment.hxx6
-rw-r--r--ucb/source/ucp/webdav/webdavcontent.cxx68
-rw-r--r--ucb/source/ucp/webdav/webdavcontent.hxx6
-rw-r--r--ucb/source/ucp/webdav/webdavcontentcaps.cxx30
6 files changed, 140 insertions, 30 deletions
diff --git a/ucb/source/ucp/webdav/ContentProperties.cxx b/ucb/source/ucp/webdav/ContentProperties.cxx
index 1810cb827dc5..3ca2d99fce89 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.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: kso $ $Date: 2002-09-16 14:37:09 $
+ * last change: $Author: kso $ $Date: 2002-09-24 14:15:49 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -288,10 +288,7 @@ ContentProperties::ContentProperties( const DAVResource& rResource )
if ( rResource.uri.getStr()[ rResource.uri.getLength() - 1 ]
== sal_Unicode( '/' ) )
- {
-// if ( pIsFolder && *pIsFolder )
- m_bTrailingSlash = sal_True;
- }
+ m_bTrailingSlash = sal_True;
}
//=========================================================================
@@ -320,10 +317,11 @@ ContentProperties::ContentProperties( const rtl::OUString & rTitle )
//=========================================================================
ContentProperties::ContentProperties( const ContentProperties & rOther )
: m_aEscapedTitle( rOther.m_aEscapedTitle ),
+ m_xProps( rOther.m_xProps.get()
+ ? new PropertyValueMap( *rOther.m_xProps )
+ : new PropertyValueMap ),
m_bTrailingSlash( rOther.m_bTrailingSlash )
{
- if ( rOther.m_xProps.get() )
- m_xProps.reset( new PropertyValueMap( *rOther.m_xProps ) );
}
//=========================================================================
@@ -505,18 +503,27 @@ void ContentProperties::UCBNamesToHTTPNames(
void ContentProperties::getMappableHTTPHeaders(
std::vector< rtl::OUString > & rHeaderNames )
{
+ // -> DateModified
rHeaderNames.push_back(
rtl::OUString::createFromAscii( "Last-Modified" ) );
+
+ // -> MediaType
rHeaderNames.push_back(
rtl::OUString::createFromAscii( "Content-Type" ) );
+
+ // -> Size
rHeaderNames.push_back(
rtl::OUString::createFromAscii( "Content-Length" ) );
+
+ // -> BaseURI
+ rHeaderNames.push_back(
+ rtl::OUString::createFromAscii( "Content-Location" ) );
}
//=========================================================================
bool ContentProperties::containsAllNames(
- const uno::Sequence< beans::Property >& rProps,
- std::vector< rtl::OUString > & rNamesNotContained )
+ const uno::Sequence< beans::Property >& rProps,
+ std::vector< rtl::OUString > & rNamesNotContained ) const
{
rNamesNotContained.clear();
@@ -535,8 +542,9 @@ bool ContentProperties::containsAllNames(
}
//=========================================================================
-void ContentProperties::add( const std::vector< rtl::OUString > & rProps,
- const ContentProperties & rContentProps )
+void ContentProperties::addProperties(
+ 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();
@@ -559,3 +567,10 @@ void ContentProperties::add( const std::vector< rtl::OUString > & rProps,
}
}
+//=========================================================================
+void ContentProperties::addProperty( const rtl::OUString & rName,
+ const com::sun::star::uno::Any & rValue )
+{
+ (*m_xProps)[ rName ] = rValue;
+}
+
diff --git a/ucb/source/ucp/webdav/ContentProperties.hxx b/ucb/source/ucp/webdav/ContentProperties.hxx
index 61a6d13b73d1..828ec8ed0a3b 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.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: kso $ $Date: 2002-09-18 16:01:07 $
+ * last change: $Author: kso $ $Date: 2002-09-24 14:15:49 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -173,20 +173,27 @@ public:
// 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 );
+ bool containsAllNames(
+ const com::sun::star::uno::Sequence<
+ com::sun::star::beans::Property >& rProps,
+ std::vector< rtl::OUString > & rNamesNotContained ) const;
// 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 );
+ void addProperties( const std::vector< rtl::OUString > & rProps,
+ const ContentProperties & rContentProps );
+
+ // overwrites probably existing entry.
+ void addProperty( const rtl::OUString & rName,
+ const com::sun::star::uno::Any & rValue );
bool isTrailingSlash() const { return m_bTrailingSlash; }
const rtl::OUString & getEscapedTitle() const { return m_aEscapedTitle; }
+ // Not good to expose implementation details, but this is actually an
+ // internal class.
const std::auto_ptr< PropertyValueMap > & getProperties() const
{ return m_xProps; }
diff --git a/ucb/source/ucp/webdav/DAVRequestEnvironment.hxx b/ucb/source/ucp/webdav/DAVRequestEnvironment.hxx
index 08a937fe6233..8fec1b14b5e4 100644
--- a/ucb/source/ucp/webdav/DAVRequestEnvironment.hxx
+++ b/ucb/source/ucp/webdav/DAVRequestEnvironment.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: DAVRequestEnvironment.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: kso $ $Date: 2002-09-24 13:20:37 $
+ * last change: $Author: kso $ $Date: 2002-09-24 14:15:49 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -61,8 +61,6 @@
#ifndef _DAVREQUESTENVIRONMENT_HXX_
#define _DAVREQUESTENVIRONMENT_HXX_
-#include <memory>
-
#ifndef _RTL_REF_HXX_
#include <rtl/ref.hxx>
#endif
diff --git a/ucb/source/ucp/webdav/webdavcontent.cxx b/ucb/source/ucp/webdav/webdavcontent.cxx
index 881a55756d0c..dfdbd8747750 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.35 $
+ * $Revision: 1.36 $
*
- * last change: $Author: kso $ $Date: 2002-09-23 10:16:10 $
+ * last change: $Author: kso $ $Date: 2002-09-24 14:15:49 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -70,6 +70,9 @@
#ifndef _OSL_DIAGNOSE_H_
#include <osl/diagnose.h>
#endif
+#ifndef _RTL_URI_HXX_
+#include <rtl/uri.hxx>
+#endif
#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
#include <com/sun/star/beans/PropertyAttribute.hpp>
@@ -1397,7 +1400,33 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
if ( !xProps->containsAllNames( rProperties, aMissingProps ) )
{
// Add props contained in cache...
- xProps->add( aMissingProps, *m_xCachedProps );
+ xProps->addProperties( aMissingProps, *m_xCachedProps );
+ }
+ }
+
+ // Add BaseURI property, if requested.
+ if ( !xProps->contains(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BaseURI" ) ) ) )
+ {
+ sal_Int32 nCount = rProperties.getLength();
+ if ( nCount )
+ {
+ const beans::Property* pProps = rProperties.getConstArray();
+ for ( sal_Int32 n = 0; n < nCount; ++n )
+ {
+ const rtl::OUString & rName = pProps[ n ].Name;
+
+ if ( rName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( "BaseURI" ) ) )
+ {
+ // BaseURI requested! Append value.
+ xProps->addProperty( rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "BaseURI" ) ),
+ uno::makeAny( getBaseURI() ) );
+ break;
+ }
+ }
}
}
@@ -2487,3 +2516,36 @@ void Content::cancelCommandExecution(
// Unreachable
}
+//=========================================================================
+const rtl::OUString Content::getBaseURI()
+{
+ // First, try to obtain value of response header "Content-Location".
+ if ( m_xCachedProps.get() )
+ {
+ rtl::OUString aLocation;
+ m_xCachedProps->getValue( rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "Content-Location" ) ) ) >>= aLocation;
+ if ( aLocation.getLength() )
+ {
+#if 0
+ // @@@ rtl::Uri::convertRelToAbs not yet available, will be after release
+ // of 6.1 EA2.
+ try
+ {
+ // Do not use m_xIdentifier->getContentIdentifier() because it
+ // for example does not reflect redirects applied to requests
+ // done using the original URI but m_xResAccess' URI does.
+ return rtl::Uri::convertRelToAbs( m_xResAccess->getURL(),
+ aLocation );
+ }
+ catch ( rtl::MalformedUriException const & )
+ {
+ }
+#endif
+ }
+ }
+
+ return rtl::OUString( m_xResAccess->getURL() );
+}
+
diff --git a/ucb/source/ucp/webdav/webdavcontent.hxx b/ucb/source/ucp/webdav/webdavcontent.hxx
index fbad172effaa..a21ac8c27bbf 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.15 $
+ * $Revision: 1.16 $
*
- * last change: $Author: kso $ $Date: 2002-09-16 14:37:14 $
+ * last change: $Author: kso $ $Date: 2002-09-24 14:15:50 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -164,6 +164,8 @@ private:
const ::com::sun::star::uno::Reference<
::com::sun::star::ucb::XContentIdentifier >& xNewId );
+ const rtl::OUString getBaseURI();
+
// Command "insert"
void insert( const ::com::sun::star::uno::Reference<
::com::sun::star::io::XInputStream > & xInputStream,
diff --git a/ucb/source/ucp/webdav/webdavcontentcaps.cxx b/ucb/source/ucp/webdav/webdavcontentcaps.cxx
index b63147c4ff4a..8abdc6f54d20 100644
--- a/ucb/source/ucp/webdav/webdavcontentcaps.cxx
+++ b/ucb/source/ucp/webdav/webdavcontentcaps.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: webdavcontentcaps.cxx,v $
*
- * $Revision: 1.11 $
+ * $Revision: 1.12 $
*
- * last change: $Author: kso $ $Date: 2002-09-23 10:16:10 $
+ * last change: $Author: kso $ $Date: 2002-09-24 14:15:50 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -213,6 +213,14 @@ bool ContentProvider::getProperty(
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::READONLY ) );
+ m_pProps->insert(
+ beans::Property(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BaseURI" ) ),
+ -1,
+ getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::READONLY ) );
+
// Standard DAV properties.
m_pProps->insert(
@@ -384,6 +392,7 @@ uno::Sequence< beans::Property > Content::getProperties(
sal_Bool bHasIsDocument = sal_False;
sal_Bool bHasIsFolder = sal_False;
sal_Bool bHasTitle = sal_False;
+ sal_Bool bHasBaseURI = sal_False;
sal_Bool bHasDateCreated = sal_False;
sal_Bool bHasDateModified = sal_False;
sal_Bool bHasMediaType = sal_False;
@@ -438,6 +447,12 @@ uno::Sequence< beans::Property > Content::getProperties(
{
bHasTitle = sal_True;
}
+ else if ( !bHasBaseURI &&
+ (*it).equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( "BaseURI" ) ) )
+ {
+ bHasBaseURI = sal_True;
+ }
else if ( !bHasDateCreated &&
(*it).equalsAsciiL(
RTL_CONSTASCII_STRINGPARAM( "DateCreated" ) ) )
@@ -481,10 +496,21 @@ uno::Sequence< beans::Property > Content::getProperties(
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ) );
if ( !bHasTitle )
+ {
+ // Always present since it can be calculated from content's URI.
aPropSet.insert(
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ) );
+ }
// Add optional properties.
+
+ if ( !bHasBaseURI )
+ {
+ // Always present since it can be calculated from content's URI.
+ aPropSet.insert(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BaseURI" ) ) );
+ }
+
if ( !bHasDateCreated && bHasCreationDate )
aPropSet.insert(
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DateCreated" ) ) );