[Libreoffice-commits] core.git: ucb/source

Vasily Melenchuk vasily.melenchuk at cib.de
Mon Jul 20 13:42:52 PDT 2015


 ucb/source/ucp/cmis/cmis_content.cxx |   52 ++++++++++++++++++++++++++++++-----
 ucb/source/ucp/cmis/cmis_url.hxx     |   12 ++++----
 2 files changed, 52 insertions(+), 12 deletions(-)

New commits:
commit 0619ed6d9cbc49cf0fbc90438d00950abca9abd0
Author: Vasily Melenchuk <vasily.melenchuk at cib.de>
Date:   Mon Jul 20 12:45:12 2015 +0200

    cmis: throw an error if we were not able to open repository
    
    It was an crash before, if we have stored CMIS url with repository
    that does not exist. Session was created, but with empty repo.
    Now this nuance is checked and slightly improved error reporting for
    cmis.
    
    Change-Id: I447ec767fd735829f8a507733552b26e05cba441
    Reviewed-on: https://gerrit.libreoffice.org/17224
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/ucb/source/ucp/cmis/cmis_content.cxx b/ucb/source/ucp/cmis/cmis_content.cxx
index 7be8c45..bc77db1 100644
--- a/ucb/source/ucp/cmis/cmis_content.cxx
+++ b/ucb/source/ucp/cmis/cmis_content.cxx
@@ -253,6 +253,32 @@ namespace
 
         return property;
     }
+
+    uno::Sequence< uno::Any > generateErrorArguments( const cmis::URL & rURL )
+    {
+        uno::Sequence< uno::Any > aArguments(3);
+
+        size_t i = 0;
+        aArguments[i++] <<= beans::PropertyValue(
+            OUString( "Binding URL" ),
+            - 1,
+            uno::makeAny( rURL.getBindingUrl() ),
+            beans::PropertyState_DIRECT_VALUE );
+
+        aArguments[i++] <<= beans::PropertyValue(
+            OUString( "Username" ),
+            -1,
+            uno::makeAny( rURL.getUsername() ),
+            beans::PropertyState_DIRECT_VALUE );
+
+        aArguments[i++] <<= beans::PropertyValue(
+            OUString( "Repository Id" ),
+            -1,
+            uno::makeAny( rURL.getRepositoryId() ),
+            beans::PropertyState_DIRECT_VALUE );
+
+        return aArguments;
+    }
 }
 
 namespace cmis
@@ -365,14 +391,28 @@ namespace cmis
                 m_pSession = libcmis::SessionFactory::createSession(
                         OUSTR_TO_STDSTR( m_aURL.getBindingUrl( ) ),
                         rUsername, rPassword, OUSTR_TO_STDSTR( m_aURL.getRepositoryId( ) ), false, oauth2Data );
-                if ( m_pSession == NULL )
+                if ( m_pSession == nullptr )
+                {
+                    // Fail: session was not created
+                    ucbhelper::cancelCommandExecution(
+                        ucb::IOErrorCode_INVALID_DEVICE,
+                        generateErrorArguments(m_aURL),
+                        xEnv,
+                        OUString());
+                }
+                else if ( m_pSession->getRepository() == nullptr )
+                {
+                    // Fail: no repository or repository is invalid
                     ucbhelper::cancelCommandExecution(
-                                        ucb::IOErrorCode_INVALID_DEVICE,
-                                        uno::Sequence< uno::Any >( 0 ),
-                                        xEnv,
-                                        OUString( ) );
+                        ucb::IOErrorCode_INVALID_DEVICE,
+                        generateErrorArguments(m_aURL),
+                        xEnv,
+                        OUString("error accessing a repository"));
+                }
                 else
-                    m_pProvider->registerSession( sSessionId, m_pSession );
+                {
+                    m_pProvider->registerSession(sSessionId, m_pSession);
+                }
             }
             else
             {
diff --git a/ucb/source/ucp/cmis/cmis_url.hxx b/ucb/source/ucp/cmis/cmis_url.hxx
index 56b1fc8..14a32c00 100644
--- a/ucb/source/ucp/cmis/cmis_url.hxx
+++ b/ucb/source/ucp/cmis/cmis_url.hxx
@@ -30,12 +30,12 @@ namespace cmis
         public:
             explicit URL( OUString const & urlStr );
 
-            OUString& getObjectPath( ) { return m_sPath; }
-            OUString& getObjectId( ) { return m_sId; }
-            OUString& getBindingUrl( ) { return m_sBindingUrl; }
-            OUString& getRepositoryId( ) { return m_sRepositoryId; }
-            OUString& getUsername( ) { return m_sUser; }
-            OUString& getPassword( ) { return m_sPass; }
+            const OUString& getObjectPath() const { return m_sPath; }
+            const OUString& getObjectId() const { return m_sId; }
+            const OUString& getBindingUrl() const { return m_sBindingUrl; }
+            const OUString& getRepositoryId() const { return m_sRepositoryId; }
+            const OUString& getUsername() const { return m_sUser; }
+            const OUString& getPassword() const { return m_sPass; }
             void setObjectPath( const OUString& sPath );
             void setObjectId( const OUString& sId );
 


More information about the Libreoffice-commits mailing list