[mapguide-commits] r6712 - in branches/2.4/MgDev: Common/MapGuideCommon/Resources Server/src/Common/Manager Server/src/Services/Feature

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Thu May 31 04:35:49 PDT 2012


Author: jng
Date: 2012-05-31 04:35:48 -0700 (Thu, 31 May 2012)
New Revision: 6712

Modified:
   branches/2.4/MgDev/Common/MapGuideCommon/Resources/mapguide_en.res
   branches/2.4/MgDev/Server/src/Common/Manager/FdoConnectionManager.cpp
   branches/2.4/MgDev/Server/src/Common/Manager/FdoConnectionManager.h
   branches/2.4/MgDev/Server/src/Services/Feature/ServerDescribeSchema.cpp
   branches/2.4/MgDev/Server/src/Services/Feature/ServerFeatureService.cpp
   branches/2.4/MgDev/Server/src/Services/Feature/ServerFeatureServiceExceptionDef.h
Log:
#2005: Record feature source ids where possible for any MgFdoException that gets thrown

Modified: branches/2.4/MgDev/Common/MapGuideCommon/Resources/mapguide_en.res
===================================================================
--- branches/2.4/MgDev/Common/MapGuideCommon/Resources/mapguide_en.res	2012-05-31 11:25:25 UTC (rev 6711)
+++ branches/2.4/MgDev/Common/MapGuideCommon/Resources/mapguide_en.res	2012-05-31 11:35:48 UTC (rev 6712)
@@ -229,6 +229,7 @@
 MgFailedToLoadFdoLibrary                              = Failed to load FDO library.
 MgFailedToRetrieveSystemExceptionMesage               = Failed to retrieve the system exception mesage. This message may not be unicode compliant.
 MgFailedToRetrieveThirdPartyExceptionMesage           = Failed to retrieve the third party exception mesage. This message may not be unicode compliant.
+MgFeatureSourceFormatInnerExceptionMessage            = Error occurred in Feature Source (%1): %2
 MgFeatureReaderIdNotFound                             = The feature reader ID was not found.
 MgFilenamesIdentical                                  = The filenames cannot be the same.
 MgFormatAllExceptionDetail                            = - %1(%2)

Modified: branches/2.4/MgDev/Server/src/Common/Manager/FdoConnectionManager.cpp
===================================================================
--- branches/2.4/MgDev/Server/src/Common/Manager/FdoConnectionManager.cpp	2012-05-31 11:25:25 UTC (rev 6711)
+++ branches/2.4/MgDev/Server/src/Common/Manager/FdoConnectionManager.cpp	2012-05-31 11:35:48 UTC (rev 6712)
@@ -313,7 +313,7 @@
             __LINE__, __WFILE__, &arguments, L"", NULL);
     }
 
-    MG_FDOCONNECTION_MANAGER_CATCH(L"MgFdoConnectionManager.Open")
+    MG_FDOCONNECTION_MANAGER_CATCH_WITH_FEATURE_SOURCE(L"MgFdoConnectionManager.Open", resourceIdentifier)
     if (mgException != NULL)
     {
         // There was an exception so remove any connection
@@ -323,6 +323,31 @@
             // Update the # of current connections
             providerInfo->DecrementCurrentConnections();
         }
+
+        //HACK-ish: If an MgFdoException was thrown from below, keep the relevant details and 
+        //attach the feature source id. The end message will look a bit ugly, but the full contents
+        //of the inner exception is preserved. We have to do this because none of the methods called
+        //here that could throw MgFdoException accept a MgResourceIdentifier which we require to use
+        //any _WITH_FEATURE_SOURCE macro with
+        //
+        //MgException really needs better inner exception absorption mechanisms here
+        MgFdoException* ex = dynamic_cast<MgFdoException*>(mgException.p);
+        if (NULL != ex)
+        {
+            MgServerManager* serverManager = MgServerManager::GetInstance();
+            STRING locale = (NULL == serverManager) ?
+                MgResources::DefaultMessageLocale : serverManager->GetDefaultMessageLocale();
+
+            STRING message = ex->GetDetails(locale);
+            message += L"\n";
+            message += ex->GetStackTrace(locale);
+            MgStringCollection args;
+            args.Add(resourceIdentifier->ToString());
+            args.Add(message);
+
+            //Replace the exception to be thrown with our one
+            mgException = new MgFdoException(L"MgFdoConnectionManager.Open", __LINE__, __WFILE__, NULL, L"MgFeatureSourceFormatInnerExceptionMessage", &args);
+        }
     }
     MG_FDOCONNECTION_MANAGER_THROW()
 
@@ -621,7 +646,7 @@
                                               resourceIdentifier->ToString(),
                                               ltName);
 
-    MG_FDOCONNECTION_MANAGER_CATCH_AND_THROW(L"MgFdoConnectionManager.FindFdoConnection")
+    MG_FDOCONNECTION_MANAGER_CATCH_AND_THROW_WITH_FEATURE_SOURCE(L"MgFdoConnectionManager.FindFdoConnection", resourceIdentifier)
 
     return pFdoConnection.Detach();
 }
@@ -2269,7 +2294,7 @@
         iterProviderInfoCollection++;
     }
 
-    MG_FDOCONNECTION_MANAGER_CATCH_AND_THROW(L"MgFdoConnectionManager.SetCachedFdoConnectionAsInvalid")
+    MG_FDOCONNECTION_MANAGER_CATCH_AND_THROW_WITH_FEATURE_SOURCE(L"MgFdoConnectionManager.SetCachedFdoConnectionAsInvalid", resource)
 
     return success;
 }

Modified: branches/2.4/MgDev/Server/src/Common/Manager/FdoConnectionManager.h
===================================================================
--- branches/2.4/MgDev/Server/src/Common/Manager/FdoConnectionManager.h	2012-05-31 11:25:25 UTC (rev 6711)
+++ branches/2.4/MgDev/Server/src/Common/Manager/FdoConnectionManager.h	2012-05-31 11:35:48 UTC (rev 6712)
@@ -35,6 +35,9 @@
 #define MG_FDOCONNECTION_MANAGER_THROW()                       MG_FEATURE_SERVICE_THROW()
 #define MG_FDOCONNECTION_MANAGER_CATCH_AND_THROW(methodName)   MG_FEATURE_SERVICE_CATCH_AND_THROW(methodName)
 
+#define MG_FDOCONNECTION_MANAGER_CATCH_WITH_FEATURE_SOURCE(methodName, fsId)             MG_FEATURE_SERVICE_CATCH_WITH_FEATURE_SOURCE(methodName, fsId)
+#define MG_FDOCONNECTION_MANAGER_CATCH_AND_THROW_WITH_FEATURE_SOURCE(methodName, fsId)   MG_FEATURE_SERVICE_CATCH_AND_THROW_WITH_FEATURE_SOURCE(methodName, fsId)
+
 typedef struct {
     STRING ltName;                              // Current long transaction name for this connection
     FdoIConnection* pFdoConnection;

Modified: branches/2.4/MgDev/Server/src/Services/Feature/ServerDescribeSchema.cpp
===================================================================
--- branches/2.4/MgDev/Server/src/Services/Feature/ServerDescribeSchema.cpp	2012-05-31 11:25:25 UTC (rev 6711)
+++ branches/2.4/MgDev/Server/src/Services/Feature/ServerDescribeSchema.cpp	2012-05-31 11:35:48 UTC (rev 6712)
@@ -635,7 +635,7 @@
         m_cacheManager->CheckPermission(resource, MgResourcePermission::ReadOnly);
     }
 
-    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgServerDescribeSchema.DescribeSchemaAsXml")
+    MG_FEATURE_SERVICE_CATCH_AND_THROW_WITH_FEATURE_SOURCE(L"MgServerDescribeSchema.DescribeSchemaAsXml", resource)
 
     return schemaXml;
 }
@@ -1070,7 +1070,7 @@
         m_cacheManager->CheckPermission(resource, MgResourcePermission::ReadOnly);
     }
 
-    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgServerDescribeSchema.GetClassDefinition")
+    MG_FEATURE_SERVICE_CATCH_AND_THROW_WITH_FEATURE_SOURCE(L"MgServerDescribeSchema.GetClassDefinition", resource)
 
     return classDefinition.Detach();
 }
@@ -1192,7 +1192,7 @@
     }
 
 
-    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgServerDescribeSchema.GetIdentityProperties")
+    MG_FEATURE_SERVICE_CATCH_AND_THROW_WITH_FEATURE_SOURCE(L"MgServerDescribeSchema.GetIdentityProperties", resource)
 
     return classDefs.Detach();
 }

Modified: branches/2.4/MgDev/Server/src/Services/Feature/ServerFeatureService.cpp
===================================================================
--- branches/2.4/MgDev/Server/src/Services/Feature/ServerFeatureService.cpp	2012-05-31 11:25:25 UTC (rev 6711)
+++ branches/2.4/MgDev/Server/src/Services/Feature/ServerFeatureService.cpp	2012-05-31 11:35:48 UTC (rev 6712)
@@ -240,7 +240,7 @@
     MgServerFeatureConnection msfc(resource);
     result = msfc.IsConnectionOpen();
 
-    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgServerFeatureService.TestConnection")
+    MG_FEATURE_SERVICE_CATCH_AND_THROW_WITH_FEATURE_SOURCE(L"MgServerFeatureService.TestConnection", resource)
 
     return result;
 }
@@ -340,7 +340,7 @@
     MgServerDescribeSchema msds;
     schemas = msds.DescribeSchema(resource, schemaName, classNames);
 
-    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgServerFeatureService.DescribeSchema");
+    MG_FEATURE_SERVICE_CATCH_AND_THROW_WITH_FEATURE_SOURCE(L"MgServerFeatureService.DescribeSchema", resource);
 
     return schemas.Detach();
 }
@@ -385,7 +385,7 @@
     MgServerDescribeSchema msds;
     schemaXml = msds.DescribeSchemaAsXml(resource, schemaName, classNames);
 
-    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgServerFeatureService.DescribeSchemaAsXml");
+    MG_FEATURE_SERVICE_CATCH_AND_THROW_WITH_FEATURE_SOURCE(L"MgServerFeatureService.DescribeSchemaAsXml", resource);
 
     return schemaXml;
 }
@@ -459,7 +459,7 @@
     MgServerSelectFeatures mssf;
     reader = (MgFeatureReader*)mssf.SelectFeatures(resource, className, options, false);
 
-    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgServerFeatureService.SelectFeatures")
+    MG_FEATURE_SERVICE_CATCH_AND_THROW_WITH_FEATURE_SOURCE(L"MgServerFeatureService.SelectFeatures", resource)
 
     return reader.Detach();
 }
@@ -567,7 +567,7 @@
     MgServerSelectFeatures mssf;
     reader = (MgDataReader*)mssf.SelectFeatures(resource, className, options, true);
 
-    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgServerFeatureService.SelectAggregate");
+    MG_FEATURE_SERVICE_CATCH_AND_THROW_WITH_FEATURE_SOURCE(L"MgServerFeatureService.SelectAggregate", resource);
 
     return reader.Detach();
 }
@@ -707,7 +707,7 @@
 
     transaction = transactionPool->CreateTransaction(resource);
 
-    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgServerFeatureService.BeginTransaction")
+    MG_FEATURE_SERVICE_CATCH_AND_THROW_WITH_FEATURE_SOURCE(L"MgServerFeatureService.BeginTransaction", resource)
 
     return transaction.Detach();
 }
@@ -973,7 +973,7 @@
     MgServerGetSpatialContexts msgsc;
     reader = msgsc.GetSpatialContexts(resource);
 
-    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgServerFeatureService.GetSpatialContexts")
+    MG_FEATURE_SERVICE_CATCH_AND_THROW_WITH_FEATURE_SOURCE(L"MgServerFeatureService.GetSpatialContexts", resource)
 
     return reader.Detach();
 }
@@ -1067,7 +1067,7 @@
     // set the name in the manager
     MgLongTransactionManager::SetLongTransactionName(sessionId, featureSourceId, longTransactionName);
 
-    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgServerFeatureService.SetLongTransaction")
+    MG_FEATURE_SERVICE_CATCH_AND_THROW_WITH_FEATURE_SOURCE(L"MgServerFeatureService.SetLongTransaction", featureSourceId)
 
     return true;
 }
@@ -1263,11 +1263,11 @@
 
             if (NULL == classFound.p)
             {
-				STRING qualifiedName = currSchemaName;
-				qualifiedName += L":";
-				qualifiedName += currClassName;
-				MgStringCollection args;
-				args.Add(qualifiedName);
+                STRING qualifiedName = currSchemaName;
+                qualifiedName += L":";
+                qualifiedName += currClassName;
+                MgStringCollection args;
+                args.Add(qualifiedName);
                 throw new MgObjectNotFoundException(L"DescribeWfsFeatureType",
                     __LINE__, __WFILE__, NULL, L"MgNoNameForObject", &args);
             }
@@ -1315,7 +1315,7 @@
 
     byteReader = bs->GetReader();
 
-    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgServerFeatureService.DescribeWfsFeatureType")
+    MG_FEATURE_SERVICE_CATCH_AND_THROW_WITH_FEATURE_SOURCE(L"MgServerFeatureService.DescribeWfsFeatureType", featureSourceId)
 
     return byteReader.Detach();
 }

Modified: branches/2.4/MgDev/Server/src/Services/Feature/ServerFeatureServiceExceptionDef.h
===================================================================
--- branches/2.4/MgDev/Server/src/Services/Feature/ServerFeatureServiceExceptionDef.h	2012-05-31 11:25:25 UTC (rev 6711)
+++ branches/2.4/MgDev/Server/src/Services/Feature/ServerFeatureServiceExceptionDef.h	2012-05-31 11:35:48 UTC (rev 6712)
@@ -46,6 +46,27 @@
                                                                               \
     MG_CATCH(methodName)                                                      \
 
+#define MG_FEATURE_SERVICE_CATCH_WITH_FEATURE_SOURCE(methodName, fsId)        \
+    }                                                                         \
+    catch (FdoException* e)                                                   \
+    {                                                                         \
+        STRING messageId;                                                     \
+        MgStringCollection arguments;                                         \
+        wchar_t* buf = (wchar_t*)e->GetExceptionMessage();                    \
+        INT64 nativeErrorCode = e->GetNativeErrorCode();                      \
+                                                                              \
+        if (NULL != buf)                                                      \
+        {                                                                     \
+            messageId = L"MgFeatureSourceFormatInnerExceptionMessage";        \
+            arguments.Add(fsId->ToString());                                  \
+            arguments.Add(buf);                                               \
+        }                                                                     \
+                                                                              \
+        FDO_SAFE_RELEASE(e);                                                  \
+        mgException = new MgFdoException(methodName, __LINE__, __WFILE__, NULL, messageId, &arguments, nativeErrorCode); \
+                                                                              \
+    MG_CATCH(methodName)                                                      \
+
 #define MG_FEATURE_SERVICE_THROW()                                            \
     MG_THROW()                                                                \
 
@@ -54,6 +75,11 @@
                                                                               \
     MG_FEATURE_SERVICE_THROW()                                                \
 
+#define MG_FEATURE_SERVICE_CATCH_AND_THROW_WITH_FEATURE_SOURCE(methodName, fsId) \
+    MG_FEATURE_SERVICE_CATCH_WITH_FEATURE_SOURCE(methodName, fsId)            \
+                                                                              \
+    MG_FEATURE_SERVICE_THROW()                                                \
+
 // The catch below is used when we want to mark a connection as no longer valid because
 // the underlying RDBMS has been stopped or the connection has been lost.
 
@@ -96,7 +122,8 @@
                 pFdoConnectionManager->SetCachedFdoConnectionAsInvalid(resource); \
             }                                                                 \
                                                                               \
-            messageId = L"MgFormatInnerExceptionMessage";                     \
+            messageId = L"MgFeatureSourceFormatInnerExceptionMessage";        \
+            arguments.Add(resource->ToString());                              \
             arguments.Add(buf);                                               \
         }                                                                     \
                                                                               \



More information about the mapguide-commits mailing list