User: rt      
Date: 05/06/27 01:26:01

Modified:
 /dba/dbaccess/source/core/dataaccess/
  ModelImpl.cxx

Log:
 INTEGRATION: CWS hslqdb3 (1.4.50); FILE MERGED
 2005/06/21 14:37:40 fs 1.4.50.1: #i45749# only commit storages if they're not 
readonly

File Changes:

Directory: /dba/dbaccess/source/core/dataaccess/
================================================

File [changed]: ModelImpl.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/ModelImpl.cxx?r1=1.4&r2=1.5
Delta lines:  +51 -31
---------------------
--- ModelImpl.cxx       30 Mar 2005 11:54:58 -0000      1.4
+++ ModelImpl.cxx       27 Jun 2005 08:25:59 -0000      1.5
@@ -430,17 +430,12 @@
 // 
-----------------------------------------------------------------------------
 void ODatabaseModelImpl::commitRootStorage()
 {
-       try
-       {
-               Reference< XTransactedObject > xTransact( getStorage(), 
UNO_QUERY );
-        OSL_ENSURE( xTransact.is() || !getStorage().is(), 
"ODatabaseModelImpl::commitRootStorage: cannot commit the storage (missing 
interface)!" );
-               if ( xTransact.is() )
-                       xTransact->commit();
-       }
-       catch(Exception)
-       {
-        OSL_ENSURE( false, "ODatabaseModelImpl::commitRootStorage: caught an 
exception!" );
-       }
+#if OSL_DEBUG_LEVEL > 0
+    bool bSuccess =
+#endif
+    commitStorageIfWriteable_ignoreErrors( getStorage() );
+    OSL_ENSURE( bSuccess || !getStorage().is(),
+        "ODatabaseModelImpl::commitRootStorage: could commit the storage!" );
 }
 // 
-----------------------------------------------------------------------------
 Reference<XStorage> ODatabaseModelImpl::getStorage()
@@ -537,23 +532,51 @@
        return xStorage;
 }
 // 
-----------------------------------------------------------------------------
-sal_Bool ODatabaseModelImpl::commitEmbeddedStorage()
+bool ODatabaseModelImpl::commitStorageIfWriteable( const Reference< XStorage 
>& _rxStorage ) SAL_THROW(( IOException, WrappedTargetException, 
RuntimeException ))
 {
-       sal_Bool bStore = sal_False;
+    bool bSuccess = false;
+       Reference<XTransactedObject> xTrans( _rxStorage, UNO_QUERY );
+       if ( xTrans.is() )
+    {
+        sal_Int32 nMode = ElementModes::READ;
        try
        {
-               TStorages::iterator aFind = 
m_aStorages.find(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("database")));
-               if ( aFind != m_aStorages.end() )
+            Reference< XPropertySet > xStorageProps( _rxStorage, 
UNO_QUERY_THROW );
+                       xStorageProps->getPropertyValue(
+                ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OpenMode" ) ) ) 
>>= nMode;
+        }
+        catch( const Exception& )
                {
-                       Reference<XTransactedObject> 
xTrans(aFind->second,UNO_QUERY);
-                       if ( bStore = xTrans.is() )
+               OSL_ENSURE( sal_False, 
"ODatabaseModelImpl::commitStorageIfWriteable: could not determine the OpenMode 
of the storage!" );
+        }
+
+        if ( ( nMode & ElementModes::WRITE ) != 0 )
                                xTrans->commit();
+        bSuccess = true;
                }
+    return bSuccess;
+}
+// 
-----------------------------------------------------------------------------
+bool ODatabaseModelImpl::commitStorageIfWriteable_ignoreErrors( const 
Reference< XStorage >& _rxStorage ) SAL_THROW(())
+{
+    bool bSuccess = false;
+    try
+    {
+        bSuccess = commitStorageIfWriteable( _rxStorage );
        }
-       catch(Exception&)
+    catch( const Exception& )
        {
-               OSL_ENSURE(0,"Exception Caught: Could not store embedded 
database!");
+           OSL_ENSURE( sal_False, 
"ODatabaseModelImpl::commitStorageIfWriteable_ignoreErrors: caught an 
exception!" );
        }
+    return bSuccess;
+}
+// 
-----------------------------------------------------------------------------
+sal_Bool ODatabaseModelImpl::commitEmbeddedStorage()
+{
+       sal_Bool bStore = sal_False;
+       TStorages::iterator aFind = 
m_aStorages.find(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("database")));
+       if ( aFind != m_aStorages.end() )
+        bStore = commitStorageIfWriteable_ignoreErrors( aFind->second );
        return bStore;
 }
 // 
-----------------------------------------------------------------------------
@@ -639,21 +662,18 @@
        return m_refCount;
 }
 // 
-----------------------------------------------------------------------------
-void ODatabaseModelImpl::commitStorages()
+void ODatabaseModelImpl::commitStorages() SAL_THROW(( IOException, 
RuntimeException ))
 {
     try
     {
         TStorages::iterator aIter = m_aStorages.begin();
         TStorages::iterator aEnd = m_aStorages.end();
         for (; aIter != aEnd ; ++aIter)
-        {
-            Reference<XTransactedObject> xTrans(aIter->second,UNO_QUERY);
-            if ( xTrans.is() )
-                xTrans->commit();
-        }
+            commitStorageIfWriteable( aIter->second );
     }
     catch(WrappedTargetException)
     {
+        // WrappedTargetException not allowed to leave
         throw IOException();
     }
 }




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to