ucb: webdav-curl: tdf#101094 (23): Simplify cache removal: MOVE, COPY

[ port of commit 63af1c52c534840d1f55e3041351d24b85edcaa4
  plus move Uris back into try block ]

Change-Id: I8cc7f6e14fcac294531b5be8fdbaf78610a3adfc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123477
Tested-by: Michael Stahl <michael.stahl@allotropia.de>
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
diff --git a/ucb/source/ucp/webdav-curl/webdavcontent.cxx b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
index 5b1fbd5..8917b74 100644
--- a/ucb/source/ucp/webdav-curl/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
@@ -2184,7 +2184,7 @@ uno::Any Content::open(
                                    ucb::IOErrorCode_NOT_EXISTING,
                                    aArgs ) ),
                            xEnv );
                // Unreachable
                        // Unreachable
                    }
                }
                catch ( DAVException const & e )
@@ -2640,12 +2640,12 @@ void Content::transfer(
        xResAccess.reset( new DAVResourceAccess( *m_xResAccess ) );
    }

    CurlUri sourceURI( rArgs.SourceURL );
    CurlUri targetURI( xIdentifier->getContentIdentifier() );

    OUString aTargetURI;
    try
    {
        CurlUri sourceURI( rArgs.SourceURL );
        CurlUri targetURI( xIdentifier->getContentIdentifier() );

        aTargetURI = targetURI.GetPathBaseNameUnescaped();

        // Check source's and target's URL scheme
@@ -2765,13 +2765,13 @@ void Content::transfer(
            // destination resource.  If the Overwrite header is set to
            // "F" then the operation will fail.

            aStaticDAVOptionsCache.removeDAVOptions( sourceURI.GetURI() );
            aStaticDAVOptionsCache.removeDAVOptions( targetURI.GetURI() );
            aSourceAccess.MOVE( sourceURI.GetPath(),
                                targetURI.GetURI(),
                                rArgs.NameClash
                                    == ucb::NameClash::OVERWRITE,
                                Environment );
            aStaticDAVOptionsCache.removeDAVOptions( sourceURI.GetURI() );
            aStaticDAVOptionsCache.removeDAVOptions( targetURI.GetURI() );

            if ( xSource.is() )
            {
@@ -2794,13 +2794,13 @@ void Content::transfer(
            // destination resource.  If the Overwrite header is set to
            // "F" then the operation will fail.

            aStaticDAVOptionsCache.removeDAVOptions( sourceURI.GetURI() );
            aStaticDAVOptionsCache.removeDAVOptions( targetURI.GetURI() );
            aSourceAccess.COPY( sourceURI.GetPath(),
                                targetURI.GetURI(),
                                rArgs.NameClash
                                    == ucb::NameClash::OVERWRITE,
                                Environment );
            aStaticDAVOptionsCache.removeDAVOptions( sourceURI.GetURI() );
            aStaticDAVOptionsCache.removeDAVOptions( targetURI.GetURI() );

// DAV resources store all additional props on server!
//              // Copy own and all children's Additional Core Properties.
@@ -2820,14 +2820,10 @@ void Content::transfer(
    }
    catch ( ucb::IllegalIdentifierException const & )
    {
        aStaticDAVOptionsCache.removeDAVOptions( sourceURI.GetURI() );
        aStaticDAVOptionsCache.removeDAVOptions( targetURI.GetURI() );
        // queryContent
    }
    catch ( DAVException const & e )
    {
        aStaticDAVOptionsCache.removeDAVOptions( sourceURI.GetURI() );
        aStaticDAVOptionsCache.removeDAVOptions( targetURI.GetURI() );
        // [RFC 2518] - WebDAV
        // 412 (Precondition Failed) - The server was unable to maintain
        // the liveness of the properties listed in the propertybehavior