25#include <officecfg/Office/Common.hxx>
26#include <officecfg/Inet.hxx>
34#include <com/sun/star/beans/IllegalTypeException.hpp>
35#include <com/sun/star/beans/NotRemoveableException.hpp>
36#include <com/sun/star/beans/PropertyAttribute.hpp>
37#include <com/sun/star/beans/PropertyExistException.hpp>
38#include <com/sun/star/beans/PropertySetInfoChange.hpp>
39#include <com/sun/star/beans/PropertySetInfoChangeEvent.hpp>
40#include <com/sun/star/beans/PropertyValue.hpp>
41#include <com/sun/star/io/XActiveDataSink.hpp>
42#include <com/sun/star/io/XOutputStream.hpp>
43#include <com/sun/star/lang/IllegalAccessException.hpp>
44#include <com/sun/star/lang/IllegalArgumentException.hpp>
45#include <com/sun/star/sdbc/SQLException.hpp>
46#include <com/sun/star/task/PasswordContainerInteractionHandler.hpp>
47#include <com/sun/star/ucb/CommandEnvironment.hpp>
48#include <com/sun/star/ucb/CommandFailedException.hpp>
49#include <com/sun/star/ucb/ContentInfoAttribute.hpp>
50#include <com/sun/star/ucb/IllegalIdentifierException.hpp>
51#include <com/sun/star/ucb/InsertCommandArgument.hpp>
52#include <com/sun/star/ucb/InteractiveBadTransferURLException.hpp>
53#include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
54#include <com/sun/star/ucb/InteractiveLockingLockedException.hpp>
55#include <com/sun/star/ucb/InteractiveLockingLockExpiredException.hpp>
56#include <com/sun/star/ucb/InteractiveLockingNotLockedException.hpp>
57#include <com/sun/star/ucb/InteractiveNetworkConnectException.hpp>
58#include <com/sun/star/ucb/InteractiveNetworkGeneralException.hpp>
59#include <com/sun/star/ucb/InteractiveNetworkReadException.hpp>
60#include <com/sun/star/ucb/InteractiveNetworkResolveNameException.hpp>
61#include <com/sun/star/ucb/InteractiveNetworkWriteException.hpp>
62#include <com/sun/star/ucb/MissingInputStreamException.hpp>
63#include <com/sun/star/ucb/MissingPropertiesException.hpp>
64#include <com/sun/star/ucb/NameClash.hpp>
65#include <com/sun/star/ucb/NameClashException.hpp>
66#include <com/sun/star/ucb/OpenCommandArgument3.hpp>
67#include <com/sun/star/ucb/OpenMode.hpp>
68#include <com/sun/star/ucb/PostCommandArgument2.hpp>
69#include <com/sun/star/ucb/PropertyCommandArgument.hpp>
70#include <com/sun/star/ucb/TransferInfo.hpp>
71#include <com/sun/star/ucb/UnsupportedCommandException.hpp>
72#include <com/sun/star/ucb/UnsupportedDataSinkException.hpp>
73#include <com/sun/star/ucb/UnsupportedNameClashException.hpp>
74#include <com/sun/star/ucb/UnsupportedOpenModeException.hpp>
75#include <com/sun/star/ucb/XCommandInfo.hpp>
76#include <com/sun/star/ucb/XPersistentPropertySet.hpp>
77#include <com/sun/star/uno/XComponentContext.hpp>
93void lcl_sendPartialGETRequest(
bool &bError,
95 const std::vector< OUString >& rProps,
96 std::vector< OUString > &aHeaderNames,
97 const std::unique_ptr< DAVResourceAccess > &xResAccess,
98 std::unique_ptr< ContentProperties > &xProps,
99 const uno::Reference< ucb::XCommandEnvironment >& xEnv )
103 aPartialGet.push_back(
106 OUString(
"bytes=0-0" )));
108 bool bIsRequestSize = std::any_of(aHeaderNames.begin(), aHeaderNames.end(),
109 [](
const OUString& rHeaderName) { return rHeaderName ==
"Content-Length"; });
111 if ( bIsRequestSize )
115 aHeaderNames.push_back( OUString(
"Accept-Ranges" ) );
116 aHeaderNames.push_back( OUString(
"Content-Range" ) );
120 xResAccess->GET0( aPartialGet, aHeaderNames, aResource, xEnv );
123 if ( bIsRequestSize )
128 OUString aAcceptRanges, aContentRange, aContentLength;
129 std::vector< DAVPropertyValue > &aResponseProps = aResource.
properties;
130 for (
const auto& rResponseProp : aResponseProps )
132 if ( rResponseProp.Name ==
"Accept-Ranges" )
133 rResponseProp.Value >>= aAcceptRanges;
134 else if ( rResponseProp.Name ==
"Content-Range" )
135 rResponseProp.Value >>= aContentRange;
136 else if ( rResponseProp.Name ==
"Content-Length" )
137 rResponseProp.Value >>= aContentLength;
141 if ( aContentLength.getLength() )
143 nSize = aContentLength.toInt64();
150 aContentRange.getLength() &&
151 aAcceptRanges ==
"bytes" )
156 sal_Int32 nSlash = aContentRange.lastIndexOf(
'/' );
159 OUString aSize = aContentRange.copy( nSlash + 1 );
163 auto it = std::find_if(aResponseProps.begin(), aResponseProps.end(),
164 [](
const DAVPropertyValue& rProp) { return rProp.Name ==
"Content-Length"; });
165 if (it != aResponseProps.end())
175 xProps->addProperties(
200 const uno::Reference< uno::XComponentContext >& rxContext,
202 const uno::Reference< ucb::XContentIdentifier >& Identifier,
204: ContentImplHelper( rxContext, pProvider,
Identifier ),
206 m_eResourceTypeForLocks(
UNKNOWN ),
207 m_pProvider( pProvider ),
208 m_bTransient( false ),
209 m_bCollection( false ),
210 m_bDidGetOrHead( false )
214 initOptsCacheLifeTime();
225 throw ucb::ContentCreationException();
232 const uno::Reference< uno::XComponentContext >& rxContext,
234 const uno::Reference< ucb::XContentIdentifier >& Identifier,
237: ContentImplHelper( rxContext, pProvider,
Identifier ),
239 m_eResourceTypeForLocks(
UNKNOWN ),
240 m_pProvider( pProvider ),
241 m_bTransient( true ),
242 m_bCollection( isCollection ),
243 m_bDidGetOrHead( false )
247 initOptsCacheLifeTime();
249 rxContext, rSessionFactory,
Identifier->getContentIdentifier() ) );
253 throw ucb::ContentCreationException();
272 ContentImplHelper::acquire();
279 ContentImplHelper::release();
290 static_cast< ucb::XContentCreator *
>(
this ) );
295 uno::Reference< task::XInteractionHandler > xIH(
296 task::PasswordContainerInteractionHandler::create(
m_xContext) );
302 uno::Reference< ucb::XCommandEnvironment > xCmdEnv(
303 ucb::CommandEnvironment::create(
306 uno::Reference< ucb::XProgressHandler >() ) );
310 catch ( uno::RuntimeException
const & )
314 catch ( uno::Exception
const & )
319 return aRet.
hasValue() ? aRet : ContentImplHelper::queryInterface( rType );
332 bool bFolder =
false;
336 =
isFolder( uno::Reference< ucb::XCommandEnvironment >() );
338 catch ( uno::RuntimeException
const & )
342 catch ( uno::Exception
const & )
388 return "com.sun.star.comp.ucb.WebDAVContent";
406 bool bFolder =
false;
410 =
isFolder( uno::Reference< ucb::XCommandEnvironment >() );
412 catch ( uno::RuntimeException
const & )
416 catch ( uno::Exception
const & )
432 const ucb::Command& aCommand,
434 const uno::Reference< ucb::XCommandEnvironment >& Environment )
436 SAL_INFO(
"ucb.ucp.webdav",
">>>>> Content::execute: start: command: " <<
aCommand.Name
437 <<
", env: " << (
Environment.is() ?
"present" :
"missing") );
441 if (
aCommand.Name ==
"getPropertyValues" )
448 if ( !(
aCommand.Argument >>= Properties ) )
451 uno::Any( lang::IllegalArgumentException(
452 "Wrong argument type!",
461 else if (
aCommand.Name ==
"setPropertyValues" )
468 if ( !(
aCommand.Argument >>= aProperties ) )
471 uno::Any( lang::IllegalArgumentException(
472 "Wrong argument type!",
482 uno::Any( lang::IllegalArgumentException(
492 else if (
aCommand.Name ==
"getPropertySetInfo" )
502 else if (
aCommand.Name ==
"getCommandInfo" )
517 ucb::OpenCommandArgument3 aOpenCommand;
518 ucb::OpenCommandArgument2 aTmp;
519 if ( !(
aCommand.Argument >>= aTmp ) )
522 uno::Any( lang::IllegalArgumentException(
523 "Wrong argument type!",
529 if ( !(
aCommand.Argument >>= aOpenCommand ) )
532 aOpenCommand.Mode = aTmp.Mode;
533 aOpenCommand.Priority = aTmp.Priority;
534 aOpenCommand.Sink = aTmp.Sink;
535 aOpenCommand.Properties = aTmp.Properties;
536 aOpenCommand.SortingInfo = aTmp.SortingInfo;
539 aRet =
open( aOpenCommand, Environment );
542 else if (
aCommand.Name ==
"insert" )
548 ucb::InsertCommandArgument arg;
549 if ( !(
aCommand.Argument >>= arg ) )
552 uno::Any( lang::IllegalArgumentException(
553 "Wrong argument type!",
560 insert( arg.Data, arg.ReplaceExisting, Environment );
562 else if (
aCommand.Name ==
"delete" )
568 bool bDeletePhysical =
false;
569 aCommand.Argument >>= bDeletePhysical;
578 std::unique_ptr< DAVResourceAccess > xResAccess;
580 osl::Guard< osl::Mutex > aGuard(
m_aMutex );
586 xResAccess->DESTROY( Environment );
588 osl::Guard< osl::Mutex > aGuard(
m_aMutex );
612 ucb::TransferInfo transferArgs;
613 if ( !(
aCommand.Argument >>= transferArgs ) )
616 uno::Any( lang::IllegalArgumentException(
617 "Wrong argument type!",
624 transfer( transferArgs, Environment );
632 ucb::PostCommandArgument2 aArg;
633 if ( !(
aCommand.Argument >>= aArg ) )
636 uno::Any( lang::IllegalArgumentException(
637 "Wrong argument type!",
644 post( aArg, Environment );
667 else if (
aCommand.Name ==
"unlock" )
675 else if (
aCommand.Name ==
"createNewContent" &&
682 ucb::ContentInfo aArg;
683 if ( !(
aCommand.Argument >>= aArg ) )
686 uno::Any( lang::IllegalArgumentException(
687 "Wrong argument type!",
696 else if (
aCommand.Name ==
"addProperty" )
698 ucb::PropertyCommandArgument aPropArg;
699 if ( !(
aCommand.Argument >>= aPropArg ))
702 uno::Any( lang::IllegalArgumentException(
703 "Wrong argument type!",
715 catch (
const beans::PropertyExistException &e )
719 catch (
const beans::IllegalTypeException&e )
723 catch (
const lang::IllegalArgumentException&e )
728 else if (
aCommand.Name ==
"removeProperty" )
731 if ( !(
aCommand.Argument >>= sPropName ) )
734 uno::Any( lang::IllegalArgumentException(
735 "Wrong argument type!",
747 catch(
const beans::UnknownPropertyException &e )
751 catch(
const beans::NotRemoveableException &e )
763 uno::Any( ucb::UnsupportedCommandException(
770 SAL_INFO(
"ucb.ucp.webdav",
"<<<<< Content::execute: end: command: " <<
aCommand.Name);
781 std::unique_ptr< DAVResourceAccess > xResAccess;
788 osl::Guard< osl::Mutex > aGuard(
m_aMutex );
803 const uno::Reference< ucb::XCommandEnvironment >& xEnv )
807 const beans::Property aProperty = aCmdArg.Property;
808 const uno::Any aDefaultValue = aCmdArg.DefaultValue;
811 if ( !aProperty.Name.getLength() )
812 throw lang::IllegalArgumentException(
813 "\"addProperty\" with empty Property.Name",
819 throw beans::IllegalTypeException(
820 "\"addProperty\" unsupported Property.Type",
824 if ( aDefaultValue.
hasValue() && aDefaultValue.getValueType() != aProperty.
Type )
825 throw beans::IllegalTypeException(
826 "\"addProperty\" DefaultValue does not match Property.Type",
836 OUString aSpecialName;
841 ->hasPropertyByName( bIsSpecial ? aSpecialName : aProperty.Name ) )
844 throw beans::PropertyExistException();
853 std::vector< ProppatchValue > aProppatchValues;
854 aProppatchValues.push_back( aValue );
859 std::unique_ptr< DAVResourceAccess > xResAccess;
861 osl::Guard< osl::Mutex > aGuard(
m_aMutex );
868 xResAccess->PROPPATCH( aProppatchValues, xEnv );
870 osl::Guard< osl::Mutex > aGuard(
m_aMutex );
875 beans::PropertySetInfoChangeEvent evt(
877 bIsSpecial ? aSpecialName : aProperty.Name,
879 beans::PropertySetInfoChange::PROPERTY_INSERTED );
889 ContentImplHelper::addProperty( bIsSpecial ? aSpecialName : aProperty.Name,
890 aProperty.Attributes,
904 throw lang::IllegalArgumentException();
908 ContentImplHelper::addProperty( bIsSpecial ? aSpecialName : aProperty.Name,
909 aProperty.Attributes,
915 "Content::addProperty - "
916 "Unsupported resource type!" );
920 catch ( uno::Exception
const & )
923 "Content::addProperty - "
924 "Unable to determine resource type!" );
930 "Content::addProperty - "
931 "Unable to determine resource type!" );
938 const uno::Reference< ucb::XCommandEnvironment >& xEnv )
944 beans::Property aProp
946 ->getPropertyByName( Name );
948 if ( !( aProp.Attributes & beans::PropertyAttribute::REMOVABLE ) )
951 throw beans::NotRemoveableException();
954 catch ( beans::UnknownPropertyException
const & )
964 std::vector< ProppatchValue > aProppatchValues;
966 aProppatchValues.push_back( aValue );
969 std::unique_ptr< DAVResourceAccess > xResAccess;
971 osl::Guard< osl::Mutex > aGuard(
m_aMutex );
978 xResAccess->PROPPATCH( aProppatchValues, xEnv );
980 osl::Guard< osl::Mutex > aGuard(
m_aMutex );
985 beans::PropertySetInfoChangeEvent evt(
989 beans::PropertySetInfoChange::PROPERTY_REMOVED );
999 ContentImplHelper::removeProperty( Name );
1012 throw beans::UnknownPropertyException(Name);
1016 ContentImplHelper::removeProperty( Name );
1021 "Content::removeProperty - "
1022 "Unsupported resource type!" );
1026 catch ( uno::Exception
const & )
1029 "Content::removeProperty - "
1030 "Unable to determine resource type!" );
1036 "Content::removeProperty - "
1037 "Unable to determine resource type!" );
1046 sal_Int16 Attributes,
1049 beans::Property aProperty;
1050 aProperty.Name =
Name;
1051 aProperty.Type = DefaultValue.getValueType();
1052 aProperty.Attributes = Attributes;
1053 aProperty.Handle = -1;
1055 addProperty( ucb::PropertyCommandArgument( aProperty, DefaultValue ),
1056 uno::Reference< ucb::XCommandEnvironment >());
1063 uno::Reference< ucb::XCommandEnvironment >() );
1071uno::Sequence< ucb::ContentInfo > SAL_CALL
1074 osl::Guard< osl::Mutex > aGuard(
m_aMutex );
1076 uno::Sequence< ucb::ContentInfo >
aSeq( 2 );
1080 aSeq.getArray()[ 0 ].Attributes
1081 = ucb::ContentInfoAttribute::INSERT_WITH_INPUTSTREAM
1082 | ucb::ContentInfoAttribute::KIND_DOCUMENT;
1084 beans::Property aProp;
1087 uno::Sequence< beans::Property > aDocProps( 1 );
1088 aDocProps.getArray()[ 0 ] = aProp;
1089 aSeq.getArray()[ 0 ].Properties = aDocProps;
1093 aSeq.getArray()[ 1 ].Attributes
1094 = ucb::ContentInfoAttribute::KIND_FOLDER;
1096 uno::Sequence< beans::Property > aFolderProps( 1 );
1097 aFolderProps.getArray()[ 0 ] = aProp;
1098 aSeq.getArray()[ 1 ].Properties = aFolderProps;
1104uno::Reference< ucb::XContent > SAL_CALL
1107 osl::Guard< osl::Mutex > aGuard(
m_aMutex );
1109 if ( !
Info.Type.getLength() )
1110 return uno::Reference< ucb::XContent >();
1115 return uno::Reference< ucb::XContent >();
1120 "WebdavContent::createNewContent - empty identifier!" );
1122 if ( (
aURL.lastIndexOf(
'/' ) + 1 ) !=
aURL.getLength() )
1128 aURL +=
"New_Collection";
1129 isCollection =
true;
1133 aURL +=
"New_Content";
1134 isCollection =
false;
1137 uno::Reference< ucb::XContentIdentifier > xId(
1138 new ::ucbhelper::ContentIdentifier( aURL ) );
1143 return new ::http_dav_ucp::Content(
m_xContext,
1149 catch ( ucb::ContentCreationException & )
1151 return uno::Reference< ucb::XContent >();
1168 sal_Int32
nPos =
aURL.lastIndexOf(
'/' );
1169 if (
nPos == (
aURL.getLength() - 1 ) )
1175 sal_Int32 nPos1 =
aURL.lastIndexOf(
'/',
nPos );
1177 nPos1 =
aURL.lastIndexOf(
'/', nPos1 );
1191 const uno::Reference< uno::XComponentContext >& rxContext,
1192 const uno::Sequence< beans::Property >& rProperties,
1195 const OUString& rContentId )
1200 = new ::ucbhelper::PropertyValueSet( rxContext );
1202 sal_Int32
nCount = rProperties.getLength();
1205 uno::Reference< beans::XPropertySet > xAdditionalPropSet;
1206 bool bTriedToGetAdditionalPropSet =
false;
1208 const beans::Property* pProps = rProperties.getConstArray();
1209 for ( sal_Int32 n = 0;
n <
nCount; ++
n )
1211 const beans::Property& rProp = pProps[
n ];
1217 xRow->appendObject( rProp, rValue );
1222 if ( !bTriedToGetAdditionalPropSet && !xAdditionalPropSet.is() )
1224 xAdditionalPropSet =
1225 rProvider->getAdditionalPropertySet( rContentId,
1227 bTriedToGetAdditionalPropSet =
true;
1230 if ( !xAdditionalPropSet.is() ||
1231 !xRow->appendPropertySetValue(
1232 xAdditionalPropSet, rProp ) )
1235 xRow->appendVoid( rProp );
1244 const std::unique_ptr< PropertyValueMap > & xProps = rData.
getProperties();
1248 beans::Property aProp;
1250 for (
const auto& rProp : *xProps )
1252 if ( pProvider->
getProperty( rProp.first, aProp ) )
1253 xRow->appendObject( aProp, rProp.second.value() );
1257 uno::Reference< beans::XPropertySet > xSet =
1258 rProvider->getAdditionalPropertySet( rContentId,
false );
1259 xRow->appendPropertySet( xSet );
1262 return uno::Reference<sdbc::XRow>(xRow);
1266void GetPropsUsingHeadRequest(
DAVResource& resource,
1267 const std::unique_ptr< DAVResourceAccess >& xResAccess,
1268 const std::vector< OUString >& aHTTPNames,
1269 const uno::Reference< ucb::XCommandEnvironment >& xEnv)
1271 if (!aHTTPNames.empty())
1300 xResAccess->HEAD(aHTTPNames, resource, xEnv);
1306 const uno::Sequence< beans::Property >& rProperties,
1307 const uno::Reference< ucb::XCommandEnvironment >& xEnv )
1309 std::unique_ptr< ContentProperties > xProps;
1310 std::unique_ptr< ContentProperties > xCachedProps;
1311 std::unique_ptr< DAVResourceAccess > xResAccess;
1312 OUString aUnescapedTitle;
1313 bool bHasAll =
false;
1314 uno::Reference< uno::XComponentContext > xContext;
1315 uno::Reference< ucb::XContentIdentifier > xIdentifier;
1319 osl::Guard< osl::Mutex > aGuard(
m_aMutex );
1332 std::vector< OUString > aMissingProps;
1333 if ( xCachedProps->containsAllNames( rProperties, aMissingProps ) )
1344 bool bNetworkAccessAllowed =
true;
1353 xEnv, xResAccess, &bNetworkAccessAllowed );
1364 std::vector< OUString > aMissingProps;
1365 if ( xCachedProps->containsAllNames(
1366 rProperties, aMissingProps ) )
1382 uno::Sequence< beans::Property >
aProperties(rProperties);
1386 aProperties, aPropNames );
1390 std::vector< DAVResource > resources;
1393 xResAccess->PROPFIND(
1394 DAVZERO, aPropNames, resources, xEnv );
1396 if ( 1 == resources.size() )
1398#if defined SAL_LOG_INFO
1401 std::vector< DAVPropertyValue >::const_iterator it = resources[0].properties.begin();
1402 std::vector< DAVPropertyValue >::const_iterator
end = resources[0].properties.end();
1405 OUString aPropValue;
1407 uno::Sequence< ucb::LockEntry > aSupportedLocks;
1408 if( (*it).Value >>= aPropValue )
1409 SAL_INFO(
"ucb.ucp.webdav",
"PROPFIND (getPropertyValues) - returned property: " << (*it).Name <<
":" << aPropValue );
1410 else if( (*it).Value >>= bValue )
1411 SAL_INFO(
"ucb.ucp.webdav",
"PROPFIND (getPropertyValues) - returned property: " << (*it).Name <<
":" <<
1412 ( bValue ?
"true" :
"false" ) );
1413 else if( (*it).Value >>= aSupportedLocks )
1415 SAL_INFO(
"ucb.ucp.webdav",
"PROPFIND (getPropertyValues) - returned property: " << (*it).Name <<
":" );
1416 for ( sal_Int32 n = 0;
n < aSupportedLocks.getLength(); ++
n )
1418 SAL_INFO(
"ucb.ucp.webdav",
" scope: "
1419 << (aSupportedLocks[n].Scope == ucb::LockScope_SHARED ?
"shared" :
"exclusive")
1421 << (aSupportedLocks[n].
Type != ucb::LockType_WRITE ?
"" :
"write") );
1429 xProps->addProperties(
1439 bNetworkAccessAllowed = bNetworkAccessAllowed
1442 if ( !bNetworkAccessAllowed )
1452 if ( bNetworkAccessAllowed )
1455 std::vector< OUString > aMissingProps;
1457 && xProps->containsAllNames(rProperties, aMissingProps))
1467 std::vector< OUString > aHeaderNames;
1477 aHeaderNames.push_back(
"Content-Type" );
1480 if (!aHeaderNames.empty())
try
1483 GetPropsUsingHeadRequest(resource, xResAccess, aHeaderNames, xEnv);
1487 xProps->addProperties(
1494 xProps->addProperties(aMissingProps,
1525 SAL_WARN(
"ucb.ucp.webdav",
"HEAD probably not implemented: fall back to a partial GET" );
1527 lcl_sendPartialGETRequest( bError,
1542 aDAVOptionsException.
setURL( aTargetURL );
1550 sal_uInt16 ResponseStatusCode =
1571 CurlUri const aUri( xResAccess->getURL() );
1572 aUnescapedTitle = aUri.GetPathBaseNameUnescaped();
1582 else if ( eType ==
DAV )
1587 xProps->addProperty(
"Title",
uno::Any(aUnescapedTitle),
true);
1594 xProps->addProperty(
1599 xProps->addProperty(
1603 xProps->addProperty(
1607 xProps->addProperty(
1626 std::vector< OUString > aMissingProps;
1627 if ( !xProps->containsAllNames(
1628 rProperties, aMissingProps ) )
1631 for ( std::vector< rtl::OUString >::const_iterator it = aMissingProps.begin();
1632 it != aMissingProps.end(); ++it )
1635 if ( (*it) ==
"DateModified" || (*it) ==
"DateCreated" )
1637 util::DateTime aDate;
1638 xProps->addProperty(
1643 else if (bNetworkAccessAllowed)
1647 if ((*it) ==
"IsFolder")
1649 xProps->addProperty(
1654 else if ((*it) ==
"IsDocument")
1656 xProps->addProperty(
1665 sal_Int32
nCount = rProperties.getLength();
1666 for ( sal_Int32 n = 0;
n <
nCount; ++
n )
1668 const OUString rName = rProperties[
n ].Name;
1669 if ( rName ==
"BaseURI" )
1672 xProps->addProperty(
1677 else if ( rName ==
"CreatableContentsInfo" )
1680 bool bFolder =
false;
1681 xProps->getValue(
"IsFolder" )
1683 xProps->addProperty(
1684 "CreatableContentsInfo",
1687 : uno::Sequence< ucb::ContentInfo >() ),
1692 uno::Reference< sdbc::XRow > xResultRow
1697 xIdentifier->getContentIdentifier() );
1700 osl::Guard< osl::Mutex > aGuard(
m_aMutex );
1716 const uno::Sequence< beans::PropertyValue >& rValues,
1717 const uno::Reference< ucb::XCommandEnvironment >& xEnv )
1719 uno::Reference< ucb::XContentIdentifier > xIdentifier;
1722 std::unique_ptr< DAVResourceAccess > xResAccess;
1725 osl::Guard< osl::Mutex > aGuard(
m_aMutex );
1733 uno::Sequence< uno::Any > aRet( rValues.getLength() );
1734 auto aRetRange = asNonConstRange(aRet);
1735 uno::Sequence< beans::PropertyChangeEvent > aChanges( rValues.getLength() );
1736 sal_Int32 nChanged = 0;
1738 beans::PropertyChangeEvent
aEvent;
1739 aEvent.Source = getXWeak();
1742 aEvent.PropertyHandle = -1;
1746 std::vector< ProppatchValue > aProppatchValues;
1747 std::vector< sal_Int32 > aProppatchPropsPositions;
1749 uno::Reference< ucb::XPersistentPropertySet > xAdditionalPropSet;
1750 bool bTriedToGetAdditionalPropSet =
false;
1752 bool bExchange =
false;
1755 sal_Int32 nTitlePos = -1;
1757 uno::Reference< beans::XPropertySetInfo > xInfo;
1759 const beans::PropertyValue*
pValues = rValues.getConstArray();
1760 sal_Int32
nCount = rValues.getLength();
1761 for ( sal_Int32 n = 0;
n <
nCount; ++
n )
1763 const beans::PropertyValue& rValue =
pValues[
n ];
1764 const OUString & rName = rValue.Name;
1766 beans::Property aTmpProp;
1767 xProvider->getProperty( rName, aTmpProp );
1769 if ( aTmpProp.Attributes & beans::PropertyAttribute::READONLY )
1772 aRetRange[
n ] <<= lang::IllegalAccessException(
1773 "Property is read-only!",
1782 if ( rName ==
"ContentType" )
1785 aRetRange[
n ] <<= lang::IllegalAccessException(
1786 "Property is read-only!",
1789 else if ( rName ==
"IsDocument" )
1792 aRetRange[
n ] <<= lang::IllegalAccessException(
1793 "Property is read-only!",
1796 else if ( rName ==
"IsFolder" )
1799 aRetRange[
n ] <<= lang::IllegalAccessException(
1800 "Property is read-only!",
1803 else if ( rName ==
"Title" )
1806 if ( rValue.Value >>= aNewValue )
1809 if ( aNewValue.getLength() > 0 )
1813 CurlUri const aURI(xIdentifier->getContentIdentifier());
1814 aOldTitle = aURI.GetPathBaseNameUnescaped();
1816 if ( aNewValue != aOldTitle )
1823 aNewTitle = aNewValue;
1832 aRetRange[
n ] <<= lang::IllegalArgumentException(
1833 "Invalid content identifier!",
1840 aRetRange[
n ] <<= lang::IllegalArgumentException(
1841 "Empty title not allowed!",
1848 aRetRange[
n ] <<= beans::IllegalTypeException(
1849 "Property value has wrong type!",
1859 OUString aSpecialName;
1866 if ( !xInfo->hasPropertyByName( bIsSpecial ? aSpecialName : rName ) )
1871 aRetRange[
n ] <<= beans::UnknownPropertyException(
1872 "Property is unknown!",
1877 if ( rName ==
"Size" )
1880 aRetRange[
n ] <<= lang::IllegalAccessException(
1881 "Property is read-only!",
1884 else if ( rName ==
"DateCreated" )
1887 aRetRange[
n ] <<= lang::IllegalAccessException(
1888 "Property is read-only!",
1891 else if ( rName ==
"DateModified" )
1894 aRetRange[
n ] <<= lang::IllegalAccessException(
1895 "Property is read-only!",
1898 else if ( rName ==
"MediaType" )
1902 aRetRange[
n ] <<= lang::IllegalAccessException(
1903 "Property is read-only!",
1906 if ( rName ==
"CreatableContentsInfo" )
1909 aRetRange[
n ] <<= lang::IllegalAccessException(
1910 "Property is read-only!",
1919 aProppatchValues.push_back( aValue );
1923 aProppatchPropsPositions.push_back( n );
1928 if ( !bTriedToGetAdditionalPropSet &&
1929 !xAdditionalPropSet.is() )
1933 bTriedToGetAdditionalPropSet =
true;
1936 if ( xAdditionalPropSet.is() )
1941 = xAdditionalPropSet->getPropertyValue( rName );
1942 if ( aOldValue != rValue.Value )
1944 xAdditionalPropSet->setPropertyValue(
1945 rName, rValue.Value );
1947 aEvent.PropertyName = rName;
1948 aEvent.OldValue = aOldValue;
1949 aEvent.NewValue = rValue.Value;
1951 aChanges.getArray()[ nChanged ] =
aEvent;
1955 catch ( beans::UnknownPropertyException
const & e )
1957 aRetRange[
n ] <<= e;
1959 catch ( lang::WrappedTargetException
const & e )
1961 aRetRange[
n ] <<= e;
1963 catch ( beans::PropertyVetoException
const & e )
1965 aRetRange[
n ] <<= e;
1967 catch ( lang::IllegalArgumentException
const & e )
1969 aRetRange[
n ] <<= e;
1974 aRetRange[
n ] <<= uno::Exception(
1975 "No property set for storing the value!",
1983 if ( !bTransient && (!aProppatchValues.empty()) )
1992 xResAccess->PROPPATCH( aProppatchValues, xEnv );
1994 for (
const auto& rProppatchValue : aProppatchValues )
1996 aEvent.PropertyName = rProppatchValue.name;
1998 aEvent.NewValue = rProppatchValue.value;
2000 aChanges.getArray()[ nChanged ] =
aEvent;
2015 std::vector< sal_Int32 >::const_iterator it
2016 = aProppatchPropsPositions.begin();
2017 std::vector< sal_Int32 >::const_iterator
end
2018 = aProppatchPropsPositions.end();
2035 if ( aNewURL.lastIndexOf(
'/' ) != ( aNewURL.getLength() - 1 ) )
2040 uno::Reference< ucb::XContentIdentifier > xNewId
2041 = new ::ucbhelper::ContentIdentifier( aNewURL );
2042 uno::Reference< ucb::XContentIdentifier > xOldId = xIdentifier;
2046 CurlUri const sourceURI( xOldId->getContentIdentifier() );
2047 CurlUri targetURI( xNewId->getContentIdentifier() );
2049 targetURI.SetScheme( sourceURI.GetScheme() );
2057 sourceURI.GetRelativeReference(), targetURI.GetURI(),
false, xEnv );
2071 xResAccess->setURL( aNewURL );
2085 aRetRange[ nTitlePos ] <<= uno::Exception(
2100 if ( aNewTitle.getLength() )
2102 osl::Guard< osl::Mutex > aGuard(
m_aMutex );
2104 aEvent.PropertyName =
"Title";
2105 aEvent.OldValue <<= aOldTitle;
2106 aEvent.NewValue <<= aNewTitle;
2110 aChanges.getArray()[ nChanged ] =
aEvent;
2116 aChanges.realloc( nChanged );
2121 osl::Guard< osl::Mutex > aGuard(
m_aMutex );
2130 const ucb::OpenCommandArgument3 & rArg,
2131 const uno::Reference< ucb::XCommandEnvironment > & xEnv )
2135 bool bOpenFolder = ( ( rArg.Mode == ucb::OpenMode::ALL ) ||
2136 ( rArg.Mode == ucb::OpenMode::FOLDERS ) ||
2137 ( rArg.Mode == ucb::OpenMode::DOCUMENTS ) );
2144 uno::Reference< ucb::XDynamicResultSet > xSet
2154 lang::IllegalArgumentException(
2155 "Non-folder resource cannot be opened as folder! Wrong Open Mode!",
2163 if ( rArg.Sink.is() )
2167 if ( ( rArg.Mode == ucb::OpenMode::DOCUMENT_SHARE_DENY_NONE ) ||
2168 ( rArg.Mode == ucb::OpenMode::DOCUMENT_SHARE_DENY_WRITE ) )
2173 ucb::UnsupportedOpenModeException(
2176 sal_Int16( rArg.Mode ) ) ),
2181 uno::Reference< io::XOutputStream > xOut( rArg.Sink, uno::UNO_QUERY );
2187 std::unique_ptr< DAVResourceAccess > xResAccess;
2190 osl::MutexGuard aGuard(
m_aMutex );
2196 xResAccess->setFlags( rArg.OpeningFlags );
2198 std::vector< OUString > aHeaders;
2201 xResAccess->GET( xOut, aHeaders, aResource, xEnv );
2205 osl::MutexGuard aGuard(
m_aMutex );
2226 uno::Reference< io::XActiveDataSink > xDataSink( rArg.Sink, uno::UNO_QUERY );
2227 if ( xDataSink.is() )
2233 std::unique_ptr< DAVResourceAccess > xResAccess;
2235 osl::MutexGuard aGuard(
m_aMutex );
2240 xResAccess->setFlags( rArg.OpeningFlags );
2244 std::vector< OUString > aHeaders;
2266 uno::Reference< io::XInputStream > xIn
2267 = xResAccess->GET( aHeaders, aResource, xEnv );
2271 osl::MutexGuard aGuard(
m_aMutex );
2285 xDataSink->setInputStream( xIn );
2301 ucb::UnsupportedDataSinkException(
2316 const ucb::PostCommandArgument2 & rArg,
2317 const uno::Reference< ucb::XCommandEnvironment > & xEnv )
2319 uno::Reference< io::XActiveDataSink >
xSink( rArg.Sink, uno::UNO_QUERY );
2324 std::unique_ptr< DAVResourceAccess > xResAccess;
2326 osl::MutexGuard aGuard(
m_aMutex );
2332 uno::Reference< io::XInputStream > xResult
2333 = xResAccess->POST( rArg.MediaType,
2339 osl::MutexGuard aGuard(
m_aMutex );
2344 xSink->setInputStream( xResult );
2354 uno::Reference< io::XOutputStream > xResult( rArg.Sink, uno::UNO_QUERY );
2359 std::unique_ptr< DAVResourceAccess > xResAccess;
2361 osl::MutexGuard aGuard(
m_aMutex );
2367 xResAccess->POST( rArg.MediaType,
2374 osl::MutexGuard aGuard(
m_aMutex );
2389 ucb::UnsupportedDataSinkException(
2407 m_xProvider->queryExistingContents( aAllContents );
2410 sal_Int32 nURLPos =
aURL.lastIndexOf(
'/' );
2412 if ( nURLPos != (
aURL.getLength() - 1 ) )
2418 sal_Int32 nLen =
aURL.getLength();
2420 for (
const auto& rChild : aAllContents )
2424 = xChild->getIdentifier()->getContentIdentifier();
2427 if ( ( aChildURL.getLength() > nLen ) &&
2428 ( aChildURL.startsWith(
aURL ) ) )
2430 sal_Int32
nPos = nLen;
2431 nPos = aChildURL.indexOf(
'/',
nPos );
2433 if ( (
nPos == -1 ) ||
2434 (
nPos == ( aChildURL.getLength() - 1 ) ) )
2437 rChildren.push_back(
2448 const uno::Reference< io::XInputStream > & xInputStream,
2449 bool bReplaceExisting,
2450 const uno::Reference< ucb::XCommandEnvironment >& Environment )
2452 bool bTransient, bCollection;
2453 OUString aEscapedTitle;
2454 std::unique_ptr< DAVResourceAccess > xResAccess;
2457 osl::Guard< osl::Mutex > aGuard(
m_aMutex );
2467 if ( aEscapedTitle.isEmpty() )
2469 SAL_WARN(
"ucb.ucp.webdav",
"Content::insert - Title missing!" );
2471 uno::Sequence<OUString> aProps {
"Title" };
2473 uno::Any( ucb::MissingPropertiesException(
2481 if ( !bReplaceExisting )
2499 if ( !bTransient || !bCollection )
2502 ucb::UnsupportedNameClashException aEx(
2503 "Unable to write without overwrite!",
2505 ucb::NameClash::ERROR );
2507 uno::Reference< task::XInteractionHandler > xIH;
2519 ContinuationFlags::Approve
2520 | ContinuationFlags::Disapprove );
2521 xIH->handle( xRequest );
2527 case ContinuationFlags::NONE:
2532 case ContinuationFlags::Approve:
2534 bReplaceExisting =
true;
2537 case ContinuationFlags::Disapprove:
2539 throw ucb::CommandFailedException(
2541 uno::Reference< uno::XInterface >(),
2547 "Content::insert - "
2548 "Unknown interaction selection!" );
2549 throw ucb::CommandFailedException(
2550 "Unknown interaction selection!",
2551 uno::Reference< uno::XInterface >(),
2568 if (
aURL.lastIndexOf(
'/' ) != (
aURL.getLength() - 1 ) )
2571 aURL += aEscapedTitle;
2575 xResAccess->setURL( aURL );
2581 xResAccess->MKCOL( Environment );
2589 xResAccess->PUT( xInputStream, Environment );
2609 if ( bReplaceExisting )
2615 xResAccess->DESTROY( Environment );
2624 insert( xInputStream, bReplaceExisting, Environment );
2627 osl::Guard< osl::Mutex > aGuard(
m_aMutex );
2641 aTitle = aURI.GetPathBaseNameUnescaped();
2649 ucb::NameClashException(
2652 task::InteractionClassification_ERROR,
2665 osl::Guard< osl::Mutex > aGuard(
m_aMutex );
2667 = new ::ucbhelper::ContentIdentifier( aURL );
2673 osl::Guard< osl::Mutex > aGuard(
m_aMutex );
2679 if ( !xInputStream.is() )
2683 ucb::MissingInputStreamException(
2691 OUString aTargetUrl = xResAccess->getURL();
2698 xResAccess->PUT( xInputStream, Environment );
2708 osl::Guard< osl::Mutex > aGuard(
m_aMutex );
2715 const ucb::TransferInfo & rArgs,
2716 const uno::Reference< ucb::XCommandEnvironment >& Environment )
2718 uno::Reference< uno::XComponentContext > xContext;
2719 uno::Reference< ucb::XContentIdentifier > xIdentifier;
2720 uno::Reference< ucb::XContentProvider > xProvider;
2721 std::unique_ptr< DAVResourceAccess > xResAccess;
2724 osl::Guard< osl::Mutex > aGuard(
m_aMutex );
2732 OUString aTargetURI;
2735 CurlUri sourceURI( rArgs.SourceURL );
2736 CurlUri targetURI( xIdentifier->getContentIdentifier() );
2738 aTargetURI = targetURI.GetPathBaseNameUnescaped();
2742 OUString aScheme = sourceURI.GetScheme().toAsciiLowerCase();
2773 ucb::InteractiveBadTransferURLException(
2774 "Unsupported URL scheme!",
2781 aScheme = targetURI.GetScheme().toAsciiLowerCase();
2801 if ( sourceURI.GetHost().getLength() &&
2802 ( sourceURI.GetHost() != targetURI.GetHost() ) )
2805 uno::Any( ucb::InteractiveBadTransferURLException(
2812 OUString aTitle = rArgs.NewTitle;
2814 if ( aTitle.isEmpty() )
2815 aTitle = sourceURI.GetPathBaseNameUnescaped();
2817 if ( aTitle ==
"/" )
2823 targetURI.AppendPath( aTitle );
2825 OUString
aTargetURL = xIdentifier->getContentIdentifier();
2832 uno::Reference< ucb::XContentIdentifier > xTargetId
2833 = new ::ucbhelper::ContentIdentifier( aTargetURL );
2836 xResAccess->getSessionFactory(),
2837 sourceURI.GetURI() );
2839 if ( rArgs.MoveData )
2841 uno::Reference< ucb::XContentIdentifier > xId
2842 = new ::ucbhelper::ContentIdentifier( rArgs.SourceURL );
2848 xProvider->queryContent( xId ).get() );
2859 aSourceAccess.MOVE( sourceURI.GetRelativeReference(),
2862 == ucb::NameClash::OVERWRITE,
2868 xSource->destroy(
true );
2888 aSourceAccess.COPY( sourceURI.GetRelativeReference(),
2891 == ucb::NameClash::OVERWRITE,
2905 xProvider->queryContent( xTargetId ).get() );
2910 catch ( ucb::IllegalIdentifierException
const & )
2924 switch ( rArgs.NameClash )
2930 ucb::NameClashException(
2933 task::InteractionClassification_ERROR,
2940 case ucb::NameClash::OVERWRITE:
2943 case ucb::NameClash::KEEP:
2944 case ucb::NameClash::RENAME:
2945 case ucb::NameClash::ASK:
2950 ucb::UnsupportedNameClashException(
2953 rArgs.NameClash ) ),
2965 osl::Guard< osl::Mutex > aGuard(
m_aMutex );
2975 uno::Reference< ucb::XContent > xThis =
this;
2979 osl::Guard< osl::Mutex > aGuard(
m_aMutex );
2986 for (
auto& rChild : aChildren )
2988 rChild->destroy( bDeletePhysical );
2994 const uno::Reference< ucb::XCommandEnvironment >& Environment,
2995 const std::unique_ptr< DAVResourceAccess > & rResAccess)
3003 uno::Sequence< ucb::LockEntry > aSupportedLocks;
3005 >>= aSupportedLocks )
3007 for ( sal_Int32 n = 0;
n < aSupportedLocks.getLength(); ++
n )
3009 if ( aSupportedLocks[ n ].Scope
3010 == ucb::LockScope_EXCLUSIVE &&
3011 aSupportedLocks[ n ].
Type
3012 == ucb::LockType_WRITE )
3013 eResourceTypeForLocks =
DAV;
3019 const OUString & rURL =
m_xIdentifier->getContentIdentifier();
3021 if ( eResourceTypeForLocks ==
UNKNOWN )
3043 std::vector< DAVResource > resources;
3045 uno::Sequence< beans::Property >
aProperties( 1 );
3049 rResAccess->PROPFIND(
DAVZERO, aPropNames, resources, Environment );
3051 bool wasSupportedlockFound =
false;
3054 if ( resources.size() == 1 )
3062 std::vector< DAVPropertyValue >::iterator it;
3065 it != resources[0].properties.end(); ++it)
3069 wasSupportedlockFound =
true;
3070 uno::Sequence< ucb::LockEntry > aSupportedLocks;
3071 if ( (*it).Value >>= aSupportedLocks )
3073 for ( sal_Int32 n = 0;
n < aSupportedLocks.getLength(); ++
n )
3078 if ( aSupportedLocks[ n ].Scope == ucb::LockScope_EXCLUSIVE &&
3079 aSupportedLocks[ n ].
Type == ucb::LockType_WRITE )
3082 eResourceTypeForLocks =
DAV;
3083 SAL_INFO(
"ucb.ucp.webdav",
"resourceTypeForLocks - URL: <"
3084 <<
m_xIdentifier->getContentIdentifier() <<
">, DAV lock/unlock supported");
3097 OUString sContentDisposition;
3101 if ((
m_xCachedProps->getValue(
"Content-Disposition") >>= sContentDisposition)
3102 && sContentDisposition.startsWithIgnoreAsciiCase(
"attachment"))
3105 wasSupportedlockFound =
true;
3112 GetPropsUsingHeadRequest(resource, rResAccess, {
"Content-Disposition"},
Environment);
3116 if (it.Name.equalsIgnoreAsciiCase(
"Content-Disposition"))
3118 if ((it.Value >>= sContentDisposition) && sContentDisposition.equalsIgnoreAsciiCase(
"attachment"))
3121 wasSupportedlockFound =
true;
3132 if ( !wasSupportedlockFound && eResourceTypeForLocks ==
DAV_NOLOCK )
3134 SAL_INFO(
"ucb.ucp.webdav",
"This WebDAV server has no supportedlock property, check for allowed LOCK method in OPTIONS" );
3140 eResourceTypeForLocks =
DAV;
3145 rResAccess->resetUri();
3150 SAL_WARN(
"ucb.ucp.webdav",
"resourceTypeForLocks() - URL: <"
3151 <<
m_xIdentifier->getContentIdentifier() <<
"> was not found. ");
3164 SAL_WARN(
"ucb.ucp.webdav",
"resourceTypeForLocks() DAVException (SC_FORBIDDEN, SC_NOT_IMPLEMENTED or SC_METHOD_NOT_ALLOWED) - URL: <"
3166 eResourceTypeForLocks =
NON_DAV;
3170 SAL_WARN(
"ucb.ucp.webdav",
"resourceTypeForLocks() DAVException - URL: <"
3172 eResourceTypeForLocks =
UNKNOWN;
3178 eResourceTypeForLocks =
NON_DAV;
3191 "different resource types for <" << rURL <<
">: "
3194 SAL_INFO(
"ucb.ucp.webdav",
"resourceTypeForLocks() - URL: <"
3200 const uno::Reference< ucb::XCommandEnvironment >& Environment )
3202 std::unique_ptr< DAVResourceAccess > xResAccess;
3204 osl::MutexGuard aGuard(
m_aMutex );
3209 osl::Guard< osl::Mutex > aGuard(
m_aMutex );
3216 const uno::Reference< ucb::XCommandEnvironment >& Environment )
3223 if (
aURL.lastIndexOf(
'/') != (
aURL.getLength() - 1 ) )
3235 std::unique_ptr< DAVResourceAccess > xResAccess;
3237 osl::Guard< osl::Mutex > aGuard(
m_aMutex );
3242 OUString
const user(officecfg::Office::Common::Save::Document::UseUserData::get()
3245 aOwnerAny <<= OUString(
"LibreOffice" + user);
3248 ucb::LockScope_EXCLUSIVE,
3249 ucb::LockType_WRITE,
3250 ucb::LockDepth_ZERO,
3254 uno::Sequence< OUString >() );
3259 xResAccess->LOCK( aLock, Environment );
3262 osl::Guard< osl::Mutex > aGuard(
m_aMutex );
3276 SAL_WARN(
"ucb.ucp.webdav",
"lock(): resource already locked - URL: <"
3279 ucb::InteractiveLockingLockedException(
3282 task::InteractionClassification_ERROR,
3290 SAL_WARN(
"ucb.ucp.webdav",
"lock(): DAVException Authentication error - URL: <"
3303 ucb::InteractiveNetworkWriteException(
3304 "Authentication error while trying to lock! Write only WebDAV perhaps?",
3306 task::InteractionClassification_ERROR,
3327 SAL_WARN(
"ucb.ucp.webdav",
"lock() DAVException (SC_NOT_FOUND, SC_PRECONDITION_FAILED, SC_NOT_IMPLEMENTED or SC_METHOD_NOT_ALLOWED) - URL: <"
3355 SAL_WARN(
"ucb.ucp.webdav",
"lock() DAVException - URL: <"
3364 const uno::Reference< ucb::XCommandEnvironment >& Environment )
3369 std::unique_ptr< DAVResourceAccess > xResAccess;
3371 osl::Guard< osl::Mutex > aGuard(
m_aMutex );
3387 xResAccess->UNLOCK( Environment );
3391 osl::Guard< osl::Mutex > aGuard(
m_aMutex );
3400 SAL_WARN(
"ucb.ucp.webdav",
"unlock(): DAVException::DAV_NOT_LOCKED - URL: <"
3416 SAL_WARN(
"ucb.ucp.webdav",
"unlock() DAVException (SC_NOT_IMPLEMENTED or SC_METHOD_NOT_ALLOWED) - URL: <"
3428 SAL_WARN(
"ucb.ucp.webdav",
"unlock() DAVException - URL: <"
3437 const uno::Reference< ucb::XContentIdentifier >& xNewId )
3442 osl::ClearableGuard< osl::Mutex > aGuard(
m_aMutex );
3444 uno::Reference< ucb::XContent > xThis =
this;
3449 SAL_WARN(
"ucb.ucp.webdav",
"Content::exchangeIdentity - Not persistent!" );
3468 for (
const auto& rChild : aChildren )
3473 uno::Reference< ucb::XContentIdentifier >
3474 xOldChildId = xChild->getIdentifier();
3475 OUString aOldChildURL
3476 = xOldChildId->getContentIdentifier();
3477 OUString aNewChildURL
3478 = aOldChildURL.replaceAt(
3480 aOldURL.getLength(),
3481 xNewId->getContentIdentifier() );
3482 uno::Reference< ucb::XContentIdentifier > xNewChildId
3483 = new ::ucbhelper::ContentIdentifier( aNewChildURL );
3485 if ( !xChild->exchangeIdentity( xNewChildId ) )
3493 "Content::exchangeIdentity - "
3494 "Panic! Cannot exchange identity!" );
3500 const uno::Reference< ucb::XCommandEnvironment >& xEnv )
3503 osl::MutexGuard aGuard(
m_aMutex );
3509 uno::Sequence< beans::Property >
aProperties( 1 );
3511 pProperties[ 0 ].Name =
"IsFolder";
3512 pProperties[ 0 ].Handle = -1;
3518 return xRow->getBoolean( 1 );
3520 catch ( sdbc::SQLException
const & )
3538 if (
aURL.lastIndexOf(
'/' ) != (
aURL.getLength() - 1 ) )
3552 uno::Sequence<uno::Any> aArgs{
uno::Any(beans::PropertyValue(
3553 "Uri", -1,
uno::Any(
aURL), beans::PropertyState_DIRECT_VALUE)) };
3556 ucb::InteractiveAugmentedIOException(
3559 task::InteractionClassification_ERROR,
3560 ucb::IOErrorCode_NOT_EXISTING,
3574 ucb::InteractiveNetworkWriteException(
3577 task::InteractionClassification_ERROR,
3581 ucb::InteractiveNetworkReadException(
3584 task::InteractionClassification_ERROR,
3591 ucb::InteractiveNetworkResolveNameException(
3594 task::InteractionClassification_ERROR,
3609 ucb::InteractiveNetworkConnectException(
3612 task::InteractionClassification_ERROR,
3626 lang::IllegalArgumentException(
3635 ucb::InteractiveLockingLockedException(
3638 task::InteractionClassification_ERROR,
3643 uno::Sequence< uno::Any > aArgs( 1 );
3644 aArgs[ 0 ] <<= beans::PropertyValue(
3645 OUString(
"Uri"), -1,
3647 beans::PropertyState_DIRECT_VALUE);
3650 ucb::InteractiveAugmentedIOException(
3651 OUString(
"Locked!" ),
3653 task::InteractionClassification_ERROR,
3654 ucb::IOErrorCode_LOCKING_VIOLATION,
3662 ucb::InteractiveLockingLockedException(
3665 task::InteractionClassification_ERROR,
3672 ucb::InteractiveLockingNotLockedException(
3675 task::InteractionClassification_ERROR,
3681 ucb::InteractiveLockingLockExpiredException(
3684 task::InteractionClassification_ERROR,
3690 ucb::InteractiveNetworkGeneralException(
3693 task::InteractionClassification_ERROR );
3720 const uno::Reference< ucb::XCommandEnvironment > & xEnv,
3731 osl::Guard< osl::Mutex > aGuard(
m_aMutex );
3738 if ( aLocation.getLength() )
3745 return rtl::Uri::convertRelToAbs( rResAccess->getURL(),
3748 catch ( rtl::MalformedUriException
const & )
3754 return rResAccess->getURL();
3759 const uno::Reference< ucb::XCommandEnvironment >& xEnv,
3760 const std::unique_ptr< DAVResourceAccess > & rResAccess,
3761 bool * networkAccessAllowed )
3784 std::vector< DAVResource > resources;
3786 uno::Sequence< beans::Property >
aProperties( 5 );
3788 pProperties[ 0 ].Name =
"IsFolder";
3789 pProperties[ 1 ].Name =
"IsDocument";
3790 pProperties[ 2 ].Name =
"IsReadOnly";
3791 pProperties[ 3 ].Name =
"MediaType";
3796 rResAccess->PROPFIND(
DAVZERO, aPropNames, resources, xEnv );
3798 if ( resources.size() == 1 )
3800#if defined SAL_LOG_INFO
3803 std::vector< DAVPropertyValue >::const_iterator it = resources[0].properties.begin();
3804 std::vector< DAVPropertyValue >::const_iterator
end = resources[0].properties.end();
3807 OUString aPropValue;
3809 uno::Sequence< ucb::LockEntry > aSupportedLocks;
3810 if((*it).Value >>= aPropValue )
3811 SAL_INFO(
"ucb.ucp.webdav",
"PROPFIND (getResourceType) - ret'd prop: " << (*it).Name <<
":" << aPropValue );
3812 else if( (*it).Value >>= bValue )
3813 SAL_INFO(
"ucb.ucp.webdav",
"PROPFIND (getResourceType) - ret'd prop: " << (*it).Name <<
":" <<
3814 ( bValue ?
"true" :
"false" ) );
3815 else if( (*it).Value >>= aSupportedLocks )
3817 SAL_INFO(
"ucb.ucp.webdav",
"PROPFIND (getResourceType) - ret'd prop: " << (*it).Name <<
":" );
3818 for ( sal_Int32 n = 0;
n < aSupportedLocks.getLength(); ++
n )
3820 SAL_INFO(
"ucb.ucp.webdav",
"PROPFIND (getResourceType) - supportedlock[" << n <<
"]: scope: "
3821 << (aSupportedLocks[n].Scope == ucb::LockScope_SHARED ?
"shared" :
"exclusive")
3823 << (aSupportedLocks[n].
Type != ucb::LockType_WRITE ?
"" :
"write") );
3836 eResourceType =
DAV;
3840 rResAccess->resetUri();
3842 SAL_WARN(
"ucb.ucp.webdav",
"Content::getResourceType returned errors, DAV ExceptionCode: " << e.
getError() <<
", HTTP error: " << e.
getStatus() );
3850 else if (networkAccessAllowed !=
nullptr)
3852 *networkAccessAllowed = *networkAccessAllowed
3890 rResAccess->resetUri();
3902 CurlUri theUri( rResAccess->getURL() );
3903 OUString aHostName = theUri.GetHost();
3904 sal_Int32 nPort = theUri.GetPort();
3937 if ( networkAccessAllowed !=
nullptr )
3938 *networkAccessAllowed =
false;
3949 "different resource types for <" << rResAccess->getURL() <<
">: "
3958 const uno::Reference< ucb::XCommandEnvironment >& xEnv )
3960 std::unique_ptr< DAVResourceAccess > xResAccess;
3962 osl::MutexGuard aGuard(
m_aMutex );
3967 osl::Guard< osl::Mutex > aGuard(
m_aMutex );
3980 nAtime = officecfg::Inet::Settings::OptsCacheLifeImplWeb::get();
3982 std::min( nAtime, sal_uInt32( 3600 ) ) );
3984 nAtime = officecfg::Inet::Settings::OptsCacheLifeDAV::get();
3986 std::min( nAtime, sal_uInt32( 3600 ) ) );
3988 nAtime = officecfg::Inet::Settings::OptsCacheLifeDAVLocked::get();
3990 std::min( nAtime, sal_uInt32( 3600 ) ) );
3992 nAtime = officecfg::Inet::Settings::OptsCacheLifeNotImpl::get();
3994 std::min( nAtime, sal_uInt32( 43200 ) ) );
3996 nAtime = officecfg::Inet::Settings::OptsCacheLifeNotFound::get();
3998 std::min( nAtime, sal_uInt32( 30 ) ) );
4003 const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv,
4005 const std::unique_ptr< DAVResourceAccess > & rResAccess,
4006 bool * networkAccessAllowed )
4016 rResAccess->OPTIONS( aDAVOptions, xEnv );
4018 sal_uInt32 nLifeTime = ( aDAVOptions.
isClass1() ||
4030 aRedirURL = rResAccess->getURL();
4045 rResAccess->resetUri();
4058 SAL_WARN(
"ucb.ucp.webdav",
"OPTIONS - DAVException: DAV_HTTP_TIMEOUT or DAV_HTTP_CONNECT for URL <" <<
m_xIdentifier->getContentIdentifier() <<
">" );
4065 if ( networkAccessAllowed !=
nullptr )
4067 *networkAccessAllowed = *networkAccessAllowed
4074 SAL_WARN(
"ucb.ucp.webdav",
"OPTIONS - DAVException: DAV_HTTP_LOOKUP for URL <" <<
m_xIdentifier->getContentIdentifier() <<
">" );
4079 if ( networkAccessAllowed !=
nullptr )
4081 *networkAccessAllowed = *networkAccessAllowed
4089 SAL_WARN(
"ucb.ucp.webdav",
"OPTIONS - DAVException: DAV_HTTP_AUTH for URL <" <<
m_xIdentifier->getContentIdentifier() <<
">" );
4097 if (xEnv && xEnv->getInteractionHandler())
4102 if ( networkAccessAllowed !=
nullptr )
4104 *networkAccessAllowed = *networkAccessAllowed
4111 SAL_WARN(
"ucb.ucp.webdav",
"OPTIONS - DAVException: DAV_HTTP_AUTHPROXY for URL <" <<
m_xIdentifier->getContentIdentifier() <<
">" );
4116 if ( networkAccessAllowed !=
nullptr )
4118 *networkAccessAllowed = *networkAccessAllowed
4129 SAL_WARN(
"ucb.ucp.webdav",
"OPTIONS - SC_FORBIDDEN for URL <" <<
m_xIdentifier->getContentIdentifier() <<
">" );
4138 SAL_WARN(
"ucb.ucp.webdav",
"OPTIONS - SC_BAD_REQUEST or SC_INTERNAL_SERVER_ERROR for URL <" <<
m_xIdentifier->getContentIdentifier() <<
">, HTTP error: "<< e.
getStatus()
4139 <<
", '" << e.
getData() <<
"'" );
4152 SAL_WARN(
"ucb.ucp.webdav",
"OPTIONS - SC_NOT_IMPLEMENTED or SC_METHOD_NOT_ALLOWED for URL <" <<
m_xIdentifier->getContentIdentifier() <<
">, HTTP error: "<< e.
getStatus()
4153 <<
", '" << e.
getData() <<
"'" );
4167 SAL_WARN(
"ucb.ucp.webdav",
"OPTIONS - Got an SC_NOT_FOUND, but the URL <" <<
m_xIdentifier->getContentIdentifier() <<
"> resource exists" );
4172 SAL_WARN(
"ucb.ucp.webdav",
"OPTIONS - SC_NOT_FOUND for URL <" <<
m_xIdentifier->getContentIdentifier() <<
">" );
4173 if ( networkAccessAllowed !=
nullptr )
4175 *networkAccessAllowed = *networkAccessAllowed
4186 <<
", '" << e.
getData() <<
"'" );
4203 SAL_WARN(
"ucb.ucp.webdav",
"OPTIONS - General DAVException (or max DAV_HTTP_REDIRECT reached) for URL <" <<
m_xIdentifier->getContentIdentifier() <<
">, DAV ExceptionCode: "
4216 if ( networkAccessAllowed !=
nullptr &&
4218 ( CachedResponseStatusCode ==
SC_GONE ) ||
4226 *networkAccessAllowed = *networkAccessAllowed &&
false;
4229 rDAVOptions = aDAVOptions;
4234 const std::unique_ptr< DAVResourceAccess > & rResAccess,
4237 std::vector< rtl::OUString > aHeaderNames;
4245 rResAccess->HEAD( aHeaderNames, aResource, xEnv );
4258 SAL_WARN(
"ucb.ucp.webdav",
"HEAD probably not implemented: fall back to a partial GET" );
4267 aPartialGet.push_back(
4269 OUString(
"Range" ),
4270 OUString(
"bytes=0-0" )));
4272 rResAccess->GET0( aPartialGet,
const PropertyValue * pValues
PropertiesInfo aProperties
css::uno::Sequence< css::uno::Type > SAL_CALL getTypes()
const std::unique_ptr< PropertyValueMap > & getProperties() const
static void UCBNamesToDAVNames(const css::uno::Sequence< css::beans::Property > &rProps, std::vector< OUString > &resources)
const css::uno::Any & getValue(const OUString &rName) const
static void UCBNamesToHTTPNames(const css::uno::Sequence< css::beans::Property > &rProps, std::vector< OUString > &resources)
bool getProperty(const OUString &rPropName, css::beans::Property &rProp)
bool isFolder(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
OUString getBaseURI(const std::unique_ptr< DAVResourceAccess > &rResAccess)
ResourceType m_eResourceTypeForLocks
void cancelCommandExecution(const DAVException &e, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv, bool bWrite=false)
static void removeCachedPropertyNames(const OUString &rURL)
static bool isResourceAvailable(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv, const std::unique_ptr< DAVResourceAccess > &rResAccess, DAVOptions &rDAVOptions)
sal_uInt32 m_nOptsCacheLifeDAVLocked
virtual css::uno::Reference< css::ucb::XContent > SAL_CALL createNewContent(const css::ucb::ContentInfo &Info) override
sal_uInt32 m_nOptsCacheLifeImplWeb
rtl::Reference< Content > ContentRef
virtual css::uno::Sequence< css::ucb::ContentInfo > SAL_CALL queryCreatableContentsInfo() override
sal_uInt32 m_nOptsCacheLifeNotImpl
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
static bool shouldAccessNetworkAfterException(const DAVException &e)
sal_uInt32 m_nOptsCacheLifeDAV
css::uno::Reference< css::sdbc::XRow > getPropertyValues(const css::uno::Sequence< css::beans::Property > &rProperties, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
std::vector< ContentRef > ContentRefList
bool exchangeIdentity(const css::uno::Reference< css::ucb::XContentIdentifier > &xNewId)
void getResourceOptions(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv, DAVOptions &rDAVOptions, const std::unique_ptr< DAVResourceAccess > &rResAccess, bool *networkAccessAllowed=nullptr)
Use OPTIONS method to retrieve the type of the Web resource.
void lock(const css::uno::Reference< css::ucb::XCommandEnvironment > &Environment)
void unlock(const css::uno::Reference< css::ucb::XCommandEnvironment > &Environment)
void removeProperty(const OUString &Name, const css::uno::Reference< css::ucb::XCommandEnvironment > &Environment)
css::uno::Sequence< css::uno::Any > setPropertyValues(const css::uno::Sequence< css::beans::PropertyValue > &rValues, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void insert(const css::uno::Reference< css::io::XInputStream > &xInputStream, bool bReplaceExisting, const css::uno::Reference< css::ucb::XCommandEnvironment > &Environment)
virtual css::uno::Any SAL_CALL execute(const css::ucb::Command &aCommand, sal_Int32 CommandId, const css::uno::Reference< css::ucb::XCommandEnvironment > &Environment) override
std::vector< OUString > m_aFailedPropNames
virtual OUString SAL_CALL getImplementationName() override
ResourceType m_eResourceType
virtual void SAL_CALL acquire() noexcept override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void SAL_CALL release() noexcept override
void initOptsCacheLifeTime()
ResourceType resourceTypeForLocks(const css::uno::Reference< css::ucb::XCommandEnvironment > &rEnvironment, const std::unique_ptr< DAVResourceAccess > &rResAccess)
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
void transfer(const css::ucb::TransferInfo &rArgs, const css::uno::Reference< css::ucb::XCommandEnvironment > &Environment)
css::uno::Any open(const css::ucb::OpenCommandArgument3 &rArg, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
sal_uInt32 m_nOptsCacheLifeNotFound
void queryChildren(ContentRefList &rChildren)
std::unique_ptr< DAVResourceAccess > m_xResAccess
virtual OUString SAL_CALL getContentType() override
virtual void SAL_CALL abort(sal_Int32 CommandId) override
virtual OUString getParentURL() override
void addProperty(const css::ucb::PropertyCommandArgument &aCmdArg, const css::uno::Reference< css::ucb::XCommandEnvironment > &Environment)
ResourceType getResourceType(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
std::unique_ptr< CachableContentProperties > m_xCachedProps
css::uno::Any MapDAVException(const DAVException &e, bool bWrite)
void destroy(bool bDeletePhysical)
ContentProvider * m_pProvider
void post(const css::ucb::PostCommandArgument2 &rArg, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
OUString GetPathBaseName() const
const OUString & getData() const
const ExceptionCode & getError() const
sal_uInt16 getStatus() const
bool getDAVOptions(const OUString &rURL, DAVOptions &rDAVOptions)
void setHeadAllowed(const OUString &rURL, bool HeadAllowed=true)
void removeDAVOptions(const OUString &rURL)
void addDAVOptions(DAVOptions &rDAVOptions, const sal_uInt32 nLifeTime)
const OUString & getHttpResponseStatusText() const
void setURL(const OUString &sURL)
void setHeadAllowed(bool HeadAllowed=true)
bool isHeadAllowed() const
bool isLockAllowed() const
void setRedirectedURL(const OUString &sRedirectedURL)
void setHttpResponseStatusCode(const sal_uInt16 nHttpResponseStatusCode)
sal_uInt16 getHttpResponseStatusCode() const
void setHttpResponseStatusText(const OUString &rHttpResponseStatusText)
static bool supportsType(const css::uno::Type &rType)
static OUString GetOOOUserName()
css::uno::Reference< css::ucb::XPersistentPropertySet > getAdditionalPropertySet(bool bCreate)
void notifyPropertySetInfoChange(const css::beans::PropertySetInfoChangeEvent &evt) const
css::uno::Reference< css::ucb::XCommandInfo > getCommandInfo(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv, bool bCache=true)
rtl::Reference< ContentProviderImplHelper > m_xProvider
bool removeAdditionalPropertySet()
bool exchange(const css::uno::Reference< css::ucb::XContentIdentifier > &rNewId)
css::uno::Reference< css::beans::XPropertySetInfo > getPropertySetInfo(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv, bool bCache=true)
css::uno::Reference< css::ucb::XContentIdentifier > m_xIdentifier
css::uno::Reference< css::uno::XComponentContext > m_xContext
void notifyPropertiesChange(const css::uno::Sequence< css::beans::PropertyChangeEvent > &evt) const
Reference< XInterface > xTarget
tools::SvRef< SvBaseLink > xSink
Sequence< sal_Int8 > aSeq
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType, Interface1 *p1)
const sal_uInt16 SC_NOT_IMPLEMENTED
const sal_uInt16 USC_AUTHPROXY_FAILED
OUString DecodeURI(OUString const &rURI)
const sal_uInt16 USC_LOOKUP_FAILED
const sal_uInt16 SC_FORBIDDEN
const sal_uInt16 USC_CONNECTION_TIMED_OUT
constexpr OUStringLiteral WEBDAV_COLLECTION_TYPE
const sal_uInt16 SC_PRECONDITION_FAILED
OUString EncodeSegment(OUString const &rSegment)
OUString ConnectionEndPointString(std::u16string_view rHostName, sal_uInt16 const nPort)
const sal_uInt16 SC_BAD_REQUEST
const sal_uInt16 SC_INTERNAL_SERVER_ERROR
const sal_uInt16 SC_NOT_FOUND
const sal_uInt16 SC_METHOD_NOT_ALLOWED
const sal_uInt16 USC_AUTH_FAILED
std::vector< DAVRequestHeader > DAVRequestHeaders
std::pair< OUString, OUString > DAVRequestHeader
constexpr OUStringLiteral WEBDAV_CONTENT_SERVICE_NAME
std::vector< ContentImplHelperRef > ContentRefList
void cancelCommandExecution(const uno::Any &rException, const uno::Reference< ucb::XCommandEnvironment > &xEnv)
const PropertyStruct aPropNames[]
static constexpr OUStringLiteral SUPPORTEDLOCK
static bool isUCBSpecialProperty(std::u16string_view rFullName, OUString &rParsedName)
std::vector< DAVPropertyValue > properties
static DAVOptionsCache aStaticDAVOptionsCache
XTYPEPROVIDER_COMMON_IMPL(Content)
#define WEBDAV_CONTENT_TYPE
#define WEBDAV_URL_SCHEME
#define WEBDAVS_URL_SCHEME
#define VNDSUNSTARWEBDAV_URL_SCHEME
#define VNDSUNSTARWEBDAVS_URL_SCHEME