[mapguide-commits] r8529 - in trunk/MgDev: Common/Foundation/Data Common/Foundation/System Common/MapGuideCommon/MapLayer Common/MapGuideCommon/Services Common/PlatformBase/Services Server/src/Common/Manager Server/src/Core Server/src/Services/Drawing Server/src/Services/Feature Server/src/Services/Mapping Server/src/Services/Resource Server/src/Services/ServerAdmin

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue Feb 3 06:30:27 PST 2015


Author: jng
Date: 2015-02-03 06:30:27 -0800 (Tue, 03 Feb 2015)
New Revision: 8529

Modified:
   trunk/MgDev/Common/Foundation/Data/ByteSink.cpp
   trunk/MgDev/Common/Foundation/System/ByteSourceStreamImpl.cpp
   trunk/MgDev/Common/Foundation/System/Util.cpp
   trunk/MgDev/Common/MapGuideCommon/MapLayer/Layer.cpp
   trunk/MgDev/Common/MapGuideCommon/MapLayer/Map.cpp
   trunk/MgDev/Common/MapGuideCommon/Services/ServerInformation.cpp
   trunk/MgDev/Common/PlatformBase/Services/Resource.cpp
   trunk/MgDev/Server/src/Common/Manager/PackageManager.cpp
   trunk/MgDev/Server/src/Common/Manager/ServerManager.cpp
   trunk/MgDev/Server/src/Core/TimedEventHandler.cpp
   trunk/MgDev/Server/src/Services/Drawing/ServerDrawingService.cpp
   trunk/MgDev/Server/src/Services/Feature/ByteSourceRasterStreamImpl.cpp
   trunk/MgDev/Server/src/Services/Mapping/ServerMappingService.cpp
   trunk/MgDev/Server/src/Services/Resource/ApplicationRepositoryManager.cpp
   trunk/MgDev/Server/src/Services/Resource/RepositoryManager.cpp
   trunk/MgDev/Server/src/Services/Resource/ResourceDatabase.cpp
   trunk/MgDev/Server/src/Services/ServerAdmin/ServerAdminService.cpp
Log:
#2524: This submission replaces most areas in the code base where manual null pointer check and throwing of MgNullReferenceException is done with the CHECKNULL macro.

Modified: trunk/MgDev/Common/Foundation/Data/ByteSink.cpp
===================================================================
--- trunk/MgDev/Common/Foundation/Data/ByteSink.cpp	2015-02-03 11:41:32 UTC (rev 8528)
+++ trunk/MgDev/Common/Foundation/Data/ByteSink.cpp	2015-02-03 14:30:27 UTC (rev 8529)
@@ -142,11 +142,7 @@
 ///
 MgByte* MgByteSink::ToBuffer()
 {
-    if (0 == m_reader)
-    {
-        throw new MgNullReferenceException(L"MgByteSink.ToBuffer",
-            __LINE__, __WFILE__, NULL, L"", NULL);
-    }
+    CHECKNULL(m_reader, L"MgByteSink.ToBuffer");
 
     Ptr<MgByte> bytes;
 

Modified: trunk/MgDev/Common/Foundation/System/ByteSourceStreamImpl.cpp
===================================================================
--- trunk/MgDev/Common/Foundation/System/ByteSourceStreamImpl.cpp	2015-02-03 11:41:32 UTC (rev 8528)
+++ trunk/MgDev/Common/Foundation/System/ByteSourceStreamImpl.cpp	2015-02-03 14:30:27 UTC (rev 8529)
@@ -29,11 +29,7 @@
 ///
 ByteSourceMgStreamImpl::ByteSourceMgStreamImpl(MgStream* stream)
 {
-    if (stream == NULL)
-    {
-        throw new MgNullReferenceException(L"ByteSourceMgStreamImpl.ByteSourceMgStreamImpl",
-            __LINE__, __WFILE__, NULL, L"", NULL);
-    }
+    CHECKARGUMENTNULL(stream, L"ByteSourceMgStreamImpl.ByteSourceMgStreamImpl");
 
     m_stream = SAFE_ADDREF(stream);
 }

Modified: trunk/MgDev/Common/Foundation/System/Util.cpp
===================================================================
--- trunk/MgDev/Common/Foundation/System/Util.cpp	2015-02-03 11:41:32 UTC (rev 8528)
+++ trunk/MgDev/Common/Foundation/System/Util.cpp	2015-02-03 14:30:27 UTC (rev 8529)
@@ -62,16 +62,10 @@
 MgObject* MgUtil::CreateMgObject(INT32 classId)
 {
     MgClassFactory* factory = MgClassFactory::GetInstance();
-    if (NULL == factory)
-    {
-        throw new MgNullReferenceException(L"CreateMgObject", __LINE__, __WFILE__, NULL, L"", NULL);
-    }
+    CHECKNULL(factory, L"MgUtil.CreateMgObject");
 
     MgObject* obj = factory->CreateMgObject(classId);
-    if (NULL == obj)
-    {
-        throw new MgNullReferenceException(L"CreateMgObject", __LINE__, __WFILE__, NULL, L"", NULL);
-    }
+    CHECKNULL(obj, L"MgUtil.CreateMgObject");
 
     return obj;
 }

Modified: trunk/MgDev/Common/MapGuideCommon/MapLayer/Layer.cpp
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/MapLayer/Layer.cpp	2015-02-03 11:41:32 UTC (rev 8528)
+++ trunk/MgDev/Common/MapGuideCommon/MapLayer/Layer.cpp	2015-02-03 14:30:27 UTC (rev 8529)
@@ -90,11 +90,7 @@
         baseMap = m_layers->GetMap();
     }
 
-    if (NULL == baseMap)
-    {
-        throw new MgNullReferenceException(L"MgLayer.GetMap",
-            __LINE__, __WFILE__, NULL, L"", NULL);
-    }
+    CHECKNULL(baseMap, L"MgLayer.GetMap");
 
     return baseMap;
 }

Modified: trunk/MgDev/Common/MapGuideCommon/MapLayer/Map.cpp
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/MapLayer/Map.cpp	2015-02-03 11:41:32 UTC (rev 8528)
+++ trunk/MgDev/Common/MapGuideCommon/MapLayer/Map.cpp	2015-02-03 14:30:27 UTC (rev 8529)
@@ -69,11 +69,7 @@
     }
     else if (NULL == m_resourceService.p)
     {
-        if (NULL == m_siteConnection.p)
-        {
-            throw new MgNullReferenceException(L"MgMap.InitializeResourceService",
-                __LINE__, __WFILE__, NULL, L"", NULL);
-        }
+        CHECKNULL(m_siteConnection.p, L"MgMap.InitializeResourceService");
 
         m_resourceService = dynamic_cast<MgResourceService*>(
             m_siteConnection->CreateService(MgServiceType::ResourceService));
@@ -88,11 +84,7 @@
 ///
 MgService* MgMap::GetService(INT32 serviceType)
 {
-    if (NULL == m_siteConnection.p)
-    {
-        throw new MgNullReferenceException(L"MgMap.GetService",
-            __LINE__, __WFILE__, NULL, L"", NULL);
-    }
+    CHECKNULL(m_siteConnection.p, L"MgMap.GetService");
 
     if (MgServiceType::ResourceService == serviceType)
     {
@@ -921,11 +913,7 @@
 
     InitializeResourceService(resourceService);
 
-    if (NULL == m_resId.p)
-    {
-        throw new MgNullReferenceException(L"MgMap.Save",
-            __LINE__, __WFILE__, NULL, L"", NULL);
-    }
+    CHECKNULL(m_resId.p, L"MgMap.Save");
 
     m_inSave = true;
 
@@ -963,11 +951,7 @@
 
     m_resId = SAFE_ADDREF(resourceId);
 
-    if (NULL == m_resId.p)
-    {
-        throw new MgNullReferenceException(L"MgMap.Save",
-            __LINE__, __WFILE__, NULL, L"", NULL);
-    }
+    CHECKNULL(m_resId.p, L"MgMap.Save");
 
     m_inSave = true;
 

Modified: trunk/MgDev/Common/MapGuideCommon/Services/ServerInformation.cpp
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/Services/ServerInformation.cpp	2015-02-03 11:41:32 UTC (rev 8528)
+++ trunk/MgDev/Common/MapGuideCommon/Services/ServerInformation.cpp	2015-02-03 14:30:27 UTC (rev 8529)
@@ -395,11 +395,7 @@
 INT32 MgServerInformation::ToServiceFlags(MgPropertyCollection* hostProps,
     INT32 initialFlags)
 {
-    if (NULL == hostProps)
-    {
-        throw new MgNullReferenceException(
-            L"MgServerInformation.ToServiceFlags", __LINE__, __WFILE__, NULL, L"", NULL);
-    }
+    CHECKARGUMENTNULL(hostProps, L"MgServerInformation.ToServiceFlags");
 
     INT32 serviceFlags = initialFlags;
 

Modified: trunk/MgDev/Common/PlatformBase/Services/Resource.cpp
===================================================================
--- trunk/MgDev/Common/PlatformBase/Services/Resource.cpp	2015-02-03 11:41:32 UTC (rev 8528)
+++ trunk/MgDev/Common/PlatformBase/Services/Resource.cpp	2015-02-03 14:30:27 UTC (rev 8529)
@@ -60,8 +60,7 @@
 //
 void MgResource::Save(MgResourceService* resourceService)
 {
-    if(m_resId == (MgResourceIdentifier*)NULL)
-        throw new MgNullReferenceException(L"MgResource.Save", __LINE__, __WFILE__, NULL, L"", NULL);
+    CHECKNULL(m_resId.p, L"MgResource.Save");
 
     SerializeToRepository(resourceService, false);
 }
@@ -71,8 +70,7 @@
 void MgResource::Save(MgResourceService* resourceService, MgResourceIdentifier* resourceId)
 {
     m_resId = SAFE_ADDREF(resourceId);
-    if(m_resId == (MgResourceIdentifier*)NULL)
-        throw new MgNullReferenceException(L"MgResource.Save", __LINE__, __WFILE__, NULL, L"", NULL);
+    CHECKNULL(m_resId.p, L"MgResource.Save");
 
     SerializeToRepository(resourceService, true);
 }

Modified: trunk/MgDev/Server/src/Common/Manager/PackageManager.cpp
===================================================================
--- trunk/MgDev/Server/src/Common/Manager/PackageManager.cpp	2015-02-03 11:41:32 UTC (rev 8528)
+++ trunk/MgDev/Server/src/Common/Manager/PackageManager.cpp	2015-02-03 14:30:27 UTC (rev 8529)
@@ -89,12 +89,7 @@
     MgConfiguration* configuration = MgConfiguration::GetInstance();
     ACE_ASSERT(NULL != configuration);
 
-    if (NULL == configuration)
-    {
-        throw new MgNullReferenceException(
-            L"MgPackageManager.GetPackagePath",
-            __LINE__, __WFILE__, NULL, L"", NULL);
-    }
+    CHECKNULL(configuration, L"MgPackageManager.GetPackagePath");
 
     configuration->GetStringValue(
         MgConfigProperties::ResourceServicePropertiesSection,

Modified: trunk/MgDev/Server/src/Common/Manager/ServerManager.cpp
===================================================================
--- trunk/MgDev/Server/src/Common/Manager/ServerManager.cpp	2015-02-03 11:41:32 UTC (rev 8528)
+++ trunk/MgDev/Server/src/Common/Manager/ServerManager.cpp	2015-02-03 14:30:27 UTC (rev 8529)
@@ -281,10 +281,7 @@
     MG_LOG_TRACE_ENTRY(L"MgServerManager::GetConfigurationProperties()");
 
     MgConfiguration* pConfiguration = MgConfiguration::GetInstance();
-    if (NULL == pConfiguration)
-    {
-        throw new MgNullReferenceException(L"MgServerManager::GetConfigurationProperties", __LINE__, __WFILE__, NULL, L"", NULL);
-    }
+    CHECKNULL(pConfiguration, L"MgServerManager::GetConfigurationProperties");
 
     // Retrieve the properties
     pProperties = pConfiguration->GetProperties(propertySection);

Modified: trunk/MgDev/Server/src/Core/TimedEventHandler.cpp
===================================================================
--- trunk/MgDev/Server/src/Core/TimedEventHandler.cpp	2015-02-03 11:41:32 UTC (rev 8528)
+++ trunk/MgDev/Server/src/Core/TimedEventHandler.cpp	2015-02-03 14:30:27 UTC (rev 8529)
@@ -47,11 +47,7 @@
     MgServerManager* serverManager = MgServerManager::GetInstance();
     ACE_ASSERT(NULL != serverManager);
 
-    if (NULL == serverManager)
-    {
-        throw new MgNullReferenceException(L"MgTimedEventHandler.Create",
-            __LINE__, __WFILE__, NULL, L"", NULL);
-    }
+    CHECKNULL(serverManager, L"MgTimedEventHandler.Create");
 
     auto_ptr<MgTimedEventHandler> eventHandler;
     bool isSiteServer = serverManager->IsSiteServer();

Modified: trunk/MgDev/Server/src/Services/Drawing/ServerDrawingService.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Drawing/ServerDrawingService.cpp	2015-02-03 11:41:32 UTC (rev 8528)
+++ trunk/MgDev/Server/src/Services/Drawing/ServerDrawingService.cpp	2015-02-03 14:30:27 UTC (rev 8529)
@@ -435,24 +435,15 @@
             piResources = NULL;
         }
 
-        if (0 == pResource)
-        {
-            throw new MgNullReferenceException(L"MgServerDrawingService.EnumerateLayers", __LINE__, __WFILE__, NULL, L"", NULL);
-        }
+        CHECKNULL(pResource, L"MgServerDrawingService.EnumerateLayers");
 
         DWFInputStream* pStream = pResource->getInputStream();
-        if (0 == pStream)
-        {
-            throw new MgNullReferenceException(L"MgServerDrawingService.EnumerateLayers", __LINE__, __WFILE__, NULL, L"", NULL);
-        }
+        CHECKNULL(pStream, L"MgServerDrawingService.EnumerateLayers");
         size_t nBytes = pStream->available();
         char* pBuffer = DWFCORE_ALLOC_MEMORY( char, nBytes );
         pStream->read(pBuffer, nBytes);
         DWFCORE_FREE_OBJECT(pStream);
-        if (0 == pBuffer)
-        {
-            throw new MgNullReferenceException(L"MgServerDrawingService.EnumerateLayers", __LINE__, __WFILE__, NULL, L"", NULL);
-        }
+        CHECKNULL(pBuffer, L"MgServerDrawingService.EnumerateLayers");
 
         // Write the memory buffer to a temporary file
         m_tempW2dFileName = MgFileUtil::GenerateTempFileName(false, /*NOXLATE*/ L"MGDS");
@@ -588,24 +579,15 @@
             piResources = NULL;
         }
 
-        if (0 == pResource)
-        {
-            throw new MgNullReferenceException(L"MgServerDrawingService.EnumerateLayers", __LINE__, __WFILE__, NULL, L"", NULL);
-        }
+        CHECKNULL(pResource, L"MgServerDrawingService.EnumerateLayers");
 
         DWFInputStream* pStream = pResource->getInputStream();
-        if (0 == pStream)
-        {
-            throw new MgNullReferenceException(L"MgServerDrawingService.GetLayer", __LINE__, __WFILE__, NULL, L"", NULL);
-        }
+        CHECKNULL(pStream, L"MgServerDrawingService.GetLayer");
         size_t nBytes = pStream->available();
         char* pBuffer = DWFCORE_ALLOC_MEMORY( char, nBytes );
         pStream->read(pBuffer, nBytes);
         DWFCORE_FREE_OBJECT(pStream);
-        if (0 == pBuffer)
-        {
-            throw new MgNullReferenceException(L"MgServerDrawingService.GetLayer", __LINE__, __WFILE__, NULL, L"", NULL);
-        }
+        CHECKNULL(pBuffer, L"MgServerDrawingService.GetLayer");
 
         // Write the memory buffer to a temporary file
         m_tempW2dFileName = MgFileUtil::GenerateTempFileName(false, /*NOXLATE*/ L"MGDS");

Modified: trunk/MgDev/Server/src/Services/Feature/ByteSourceRasterStreamImpl.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Feature/ByteSourceRasterStreamImpl.cpp	2015-02-03 11:41:32 UTC (rev 8528)
+++ trunk/MgDev/Server/src/Services/Feature/ByteSourceRasterStreamImpl.cpp	2015-02-03 14:30:27 UTC (rev 8529)
@@ -30,10 +30,7 @@
 ///
 ByteSourceRasterStreamImpl::ByteSourceRasterStreamImpl(FdoIStreamReaderTmpl<FdoByte>* stream)
 {
-    if (stream == NULL)
-    {
-        throw new MgNullReferenceException(L"ByteSourceRasterStreamImpl", __LINE__, __WFILE__, NULL, L"", NULL);
-    }
+    CHECKARGUMENTNULL(stream, L"ByteSourceRasterStreamImpl.ctor");
     m_stream = FDO_SAFE_ADDREF(stream);
 }
 

Modified: trunk/MgDev/Server/src/Services/Mapping/ServerMappingService.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Mapping/ServerMappingService.cpp	2015-02-03 11:41:32 UTC (rev 8528)
+++ trunk/MgDev/Server/src/Services/Mapping/ServerMappingService.cpp	2015-02-03 14:30:27 UTC (rev 8529)
@@ -365,22 +365,13 @@
     for (int nMapPlotIndex = 0; nMapPlotIndex < mapPlots->GetCount(); nMapPlotIndex++)
     {
         Ptr<MgMapPlot> mapPlot = mapPlots->GetItem(nMapPlotIndex);
-        if (NULL == mapPlot)
-        {
-            throw new MgNullReferenceException(L"MgServerMappingService.GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
-        }
+        CHECKNULL((MgMapPlot*)mapPlot, L"MgServerMappingService.GenerateMultiPlot");
 
         Ptr<MgMap> map = mapPlot->GetMap();
-        if (NULL == map)
-        {
-            throw new MgNullReferenceException(L"MgServerMappingService.GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
-        }
+        CHECKNULL((MgMap*)map, L"MgServerMappingService.GenerateMultiPlot");
 
         Ptr<MgPlotSpecification> plotSpec = mapPlot->GetPlotSpecification();
-        if (NULL == plotSpec)
-        {
-            throw new MgNullReferenceException(L"MgServerMappingService.GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
-        }
+        CHECKNULL((MgPlotSpecification*)plotSpec, L"MgServerMappingService.GenerateMultiPlot");
 
         Ptr<MgLayout> layout = mapPlot->GetLayout();
 
@@ -400,17 +391,12 @@
 
         // request extenst
         Ptr<MgEnvelope> env = map->GetDataExtent();
-        if (env == NULL)
-        {
-            throw new MgNullReferenceException(L"MgServerMappingService.GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
-        }
+        CHECKNULL((MgEnvelope*)env, L"MgServerMappingService.GenerateMultiPlot");
 
         Ptr<MgCoordinate> ll = env->GetLowerLeftCoordinate();
         Ptr<MgCoordinate> ur = env->GetUpperRightCoordinate();
-        if (ll == NULL || ur == NULL)
-        {
-            throw new MgNullReferenceException(L"MgServerMappingService.GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
-        }
+        CHECKNULL((MgCoordinate*)ll, L"MgServerMappingService.GenerateMultiPlot");
+        CHECKNULL((MgCoordinate*)ur, L"MgServerMappingService.GenerateMultiPlot");
         RS_Bounds b(ll->GetX(), ll->GetY(), ur->GetX(), ur->GetY());
 
         //if requested data extent is not valid, use map definition extent
@@ -418,17 +404,12 @@
         if (!b.IsValid())
         {
             Ptr<MgEnvelope> env2 = map->GetMapExtent();
-            if (env2 == NULL)
-            {
-                throw new MgNullReferenceException(L"MgServerMappingService.GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
-            }
+            CHECKNULL((MgEnvelope*)env2, L"MgServerMappingService.GenerateMultiPlot");
 
             Ptr<MgCoordinate> ll2 = env2->GetLowerLeftCoordinate();
             Ptr<MgCoordinate> ur2 = env2->GetUpperRightCoordinate();
-            if (ll2 == NULL || ur2 == NULL)
-            {
-                throw new MgNullReferenceException(L"MgServerMappingService.GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
-            }
+            CHECKNULL((MgCoordinate*)ll2, L"MgServerMappingService.GenerateMultiPlot");
+            CHECKNULL((MgCoordinate*)ur2, L"MgServerMappingService.GenerateMultiPlot");
 
             b.minx = ll2->GetX();
             b.miny = ll2->GetY();
@@ -438,10 +419,7 @@
 
         // Create a simple print layout containing only the map
         Ptr<MgPrintLayout> printLayout = new MgPrintLayout();
-        if (printLayout == NULL)
-        {
-            throw new MgNullReferenceException(L"MgServerMappingService.GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
-        }
+        CHECKNULL((MgPrintLayout*)printLayout, L"MgServerMappingService.GenerateMultiPlot");
 
         if (NULL != layout)
         {
@@ -491,10 +469,8 @@
         double dMapScale = 0.0;
         Ptr<MgCoordinate> center = new MgCoordinateXY(0, 0);
         Ptr<MgEnvelope> extents = map->GetMapExtent();
-        if (center == NULL || extents == NULL)
-        {
-            throw new MgNullReferenceException(L"MgServerMappingService.GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
-        }
+        CHECKNULL((MgCoordinate*)center, L"MgServerMappingService.GenerateMultiPlot");
+        CHECKNULL((MgEnvelope*)extents, L"MgServerMappingService.GenerateMultiPlot");
 
         switch (mapPlot->GetMapPlotInstruction())
         {
@@ -504,10 +480,7 @@
                 if (dMapScale <= 0)
                 {
                     Ptr<MgEnvelope> extents = map->GetDataExtent();
-                    if (extents == NULL)
-                    {
-                        throw new MgNullReferenceException(L"MgServerMappingService.GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
-                    }
+                    CHECKNULL((MgEnvelope*)extents, L"MgServerMappingService.GenerateMultiPlot");
                     printLayout->ComputeMapOffsetAndSize(dMapScale, extents, metersPerUnit, dr.mapOffsetX(), dr.mapOffsetY(), dr.mapWidth(), dr.mapHeight());
                     double mapWidth = dr.mapWidth();
                     double mapHeight = dr.mapHeight();
@@ -539,10 +512,9 @@
                 //...plotCenter
                 Ptr<MgCoordinate> plotll = extents->GetLowerLeftCoordinate();
                 Ptr<MgCoordinate> plotur = extents->GetUpperRightCoordinate();
-                if (plotll == NULL || plotur == NULL)
-                {
-                    throw new MgNullReferenceException(L"MgServerMappingService.GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
-                }
+                CHECKNULL((MgCoordinate*)plotll, L"MgServerMappingService.GenerateMultiPlot");
+                CHECKNULL((MgCoordinate*)plotur, L"MgServerMappingService.GenerateMultiPlot");
+
                 double minX = plotll->GetX();
                 double minY = plotll->GetY();
                 double maxX = plotur->GetX();
@@ -566,15 +538,9 @@
 
                 map->SetViewScale(dMapScale);
                 center = new MgCoordinateXY(centerX, centerY);
-                if (center == NULL)
-                {
-                    throw new MgNullReferenceException(L"MgServerMappingService.GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
-                }
+                CHECKNULL((MgCoordinate*)center, L"MgServerMappingService.GenerateMultiPlot");
                 Ptr<MgPoint> centerpt = new MgPoint(center);
-                if (centerpt == NULL)
-                {
-                    throw new MgNullReferenceException(L"MgServerMappingService.GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
-                }
+                CHECKNULL((MgPoint*)centerpt, L"MgServerMappingService.GenerateMultiPlot");
                 map->SetViewCenter(centerpt);
                 break;
             }
@@ -650,10 +616,7 @@
         dr.StartMap(&mapInfo, b, dMapScale, dpi, metersPerUnit);
 
         Ptr<MgLayerCollection> layers = map->GetLayers();
-        if (layers == NULL)
-        {
-            throw new MgNullReferenceException(L"MgServerMappingService.GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
-        }
+        CHECKNULL((MgLayerCollection*)layers, L"MgServerMappingService.GenerateMultiPlot");
 
         // Define a polygon to represent the map extents and fill it with the map background color
         dr.StartLayer(NULL, NULL);
@@ -759,16 +722,11 @@
 
     // request extenst
     Ptr<MgEnvelope> env = map->GetDataExtent();
-    if (env == NULL)
-    {
-        throw new MgNullReferenceException(L"MgServerMappingService.GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
-    }
+    CHECKNULL((MgEnvelope*)env, L"MgServerMappingService.GenerateMultiPlot");
     Ptr<MgCoordinate> ll = env->GetLowerLeftCoordinate();
     Ptr<MgCoordinate> ur = env->GetUpperRightCoordinate();
-    if (ll == NULL|| ur == NULL)
-    {
-        throw new MgNullReferenceException(L"MgServerMappingService.GenerateMultiPlot", __LINE__, __WFILE__, NULL, L"", NULL);
-    }
+    CHECKNULL((MgCoordinate*)ll, L"MgServerMappingService.GenerateMultiPlot");
+    CHECKNULL((MgCoordinate*)ur, L"MgServerMappingService.GenerateMultiPlot");
     RS_Bounds b(ll->GetX(), ll->GetY(), ur->GetX(), ur->GetY());
 
     // get a temporary file to write out EPlot DWF to

Modified: trunk/MgDev/Server/src/Services/Resource/ApplicationRepositoryManager.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Resource/ApplicationRepositoryManager.cpp	2015-02-03 11:41:32 UTC (rev 8528)
+++ trunk/MgDev/Server/src/Services/Resource/ApplicationRepositoryManager.cpp	2015-02-03 14:30:27 UTC (rev 8529)
@@ -212,16 +212,8 @@
     {
         MgResourceHeaderManager* resourceHeaderMan = GetResourceHeaderManager();
 
-        if (NULL == resourceHeaderMan)
-        {
-            throw new MgNullReferenceException(
-                L"MgApplicationRepositoryManager.UpdateRepository",
-                __LINE__, __WFILE__, NULL, L"", NULL);
-        }
-        else
-        {
-            resourceHeaderMan->UpdateRepository(resourceInfo, headerDoc);
-        }
+        CHECKNULL(resourceHeaderMan, L"MgApplicationRepositoryManager.UpdateRepository");
+        resourceHeaderMan->UpdateRepository(resourceInfo, headerDoc);
     }
 
     // Update the content document.

Modified: trunk/MgDev/Server/src/Services/Resource/RepositoryManager.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Resource/RepositoryManager.cpp	2015-02-03 11:41:32 UTC (rev 8528)
+++ trunk/MgDev/Server/src/Services/Resource/RepositoryManager.cpp	2015-02-03 14:30:27 UTC (rev 8529)
@@ -664,15 +664,8 @@
     {
         MgResourceHeaderManager* resourceHeaderMan = GetResourceHeaderManager();
 
-        if (NULL == resourceHeaderMan)
-        {
-            throw new MgNullReferenceException(
-                L"MgRepositoryManager.UpdateResource", __LINE__, __WFILE__, NULL, L"", NULL);
-        }
-        else
-        {
-            resourceHeaderMan->UpdateResource(resourceInfo, headerDoc);
-        }
+        CHECKNULL(resourceHeaderMan, L"MgRepositoryManager.UpdateResource");
+        resourceHeaderMan->UpdateResource(resourceInfo, headerDoc);
     }
 
     // Update the content document.

Modified: trunk/MgDev/Server/src/Services/Resource/ResourceDatabase.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Resource/ResourceDatabase.cpp	2015-02-03 11:41:32 UTC (rev 8528)
+++ trunk/MgDev/Server/src/Services/Resource/ResourceDatabase.cpp	2015-02-03 14:30:27 UTC (rev 8529)
@@ -127,11 +127,7 @@
 
         m_db.get_dbname(&fileName, &dbName);
 
-        if (NULL == fileName)
-        {
-            throw new MgNullReferenceException(L"MgResourceDatabase.GetName",
-                __LINE__, __WFILE__, NULL, L"", NULL);
-        }
+        CHECKNULL(fileName, L"MgResourceDatabase.GetName");
 
         name = fileName;
     }

Modified: trunk/MgDev/Server/src/Services/ServerAdmin/ServerAdminService.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/ServerAdmin/ServerAdminService.cpp	2015-02-03 11:41:32 UTC (rev 8528)
+++ trunk/MgDev/Server/src/Services/ServerAdmin/ServerAdminService.cpp	2015-02-03 14:30:27 UTC (rev 8529)
@@ -137,10 +137,7 @@
     MG_LOG_TRACE_ENTRY(L"MgServerAdminService::ClearLog()");
 
     MgLogManager* pMan = MgLogManager::GetInstance();
-    if (NULL == pMan)
-    {
-        throw new MgNullReferenceException(L"MgServerAdminService::ClearLog", __LINE__, __WFILE__, NULL, L"", NULL);
-    }
+    CHECKNULL(pMan, L"MgServerAdminService::ClearLog");
 
     if (log == MgLogFileType::Access)
     {
@@ -231,10 +228,7 @@
     MG_LOG_TRACE_ENTRY(L"MgServerAdminService::GetLog()");
 
     MgLogManager* pMan = MgLogManager::GetInstance();
-    if (NULL == pMan)
-    {
-        throw new MgNullReferenceException(L"MgServerAdminService::GetLog", __LINE__, __WFILE__, NULL, L"", NULL);
-    }
+    CHECKNULL(pMan, L"MgServerAdminService::GetLog");
 
     if (log == MgLogFileType::Access)
     {
@@ -293,10 +287,7 @@
     MG_LOG_TRACE_ENTRY(L"MgServerAdminService::GetLog()");
 
     MgLogManager* pMan = MgLogManager::GetInstance();
-    if (NULL == pMan)
-    {
-        throw new MgNullReferenceException(L"MgServerAdminService::GetLog", __LINE__, __WFILE__, NULL, L"", NULL);
-    }
+    CHECKNULL(pMan, L"MgServerAdminService::GetLog");
 
     if (log == MgLogFileType::Access)
     {
@@ -355,10 +346,7 @@
     MG_LOG_TRACE_ENTRY(L"MgServerAdminService::GetLog()");
 
     MgLogManager* pMan = MgLogManager::GetInstance();
-    if (NULL == pMan)
-    {
-        throw new MgNullReferenceException(L"MgServerAdminService::GetLog", __LINE__, __WFILE__, NULL, L"", NULL);
-    }
+    CHECKNULL(pMan, L"MgServerAdminService::GetLog");
 
     if (log == MgLogFileType::Access)
     {
@@ -417,10 +405,7 @@
     MG_LOG_TRACE_ENTRY(L"MgServerAdminService::GetLogFile()");
 
     MgLogManager* pMan = MgLogManager::GetInstance();
-    if (NULL == pMan)
-    {
-        throw new MgNullReferenceException(L"MgServerAdminService::GetLogFile", __LINE__, __WFILE__, NULL, L"", NULL);
-    }
+    CHECKNULL(pMan, L"MgServerAdminService::GetLogFile");
 
     byteReader = pMan->GetLogFile( logFile );
 
@@ -443,10 +428,7 @@
     MG_LOG_TRACE_ENTRY(L"MgServerAdminService::EnumerateLogs()");
 
     MgLogManager* pMan = MgLogManager::GetInstance();
-    if (NULL == pMan)
-    {
-        throw new MgNullReferenceException(L"MgServerAdminService::GetLog", __LINE__, __WFILE__, NULL, L"", NULL);
-    }
+    CHECKNULL(pMan, L"MgServerAdminService::GetLog");
 
     logs = pMan->EnumerateLogs();
 
@@ -469,10 +451,7 @@
     MG_LOG_TRACE_ENTRY(L"MgServerAdminService::GetConfigurationProperties()");
 
     MgServerManager* pMan = MgServerManager::GetInstance();
-    if (NULL == pMan)
-    {
-        throw new MgNullReferenceException(L"MgServerAdminService::GetConfigurationProperties", __LINE__, __WFILE__, NULL, L"", NULL);
-    }
+    CHECKNULL(pMan, L"MgServerAdminService::GetConfigurationProperties");
 
     pProperties = pMan->GetConfigurationProperties(propertySection);
 
@@ -492,10 +471,7 @@
     MG_LOG_TRACE_ENTRY(L"MgServerAdminService::SetConfigurationProperties()");
 
     MgServerManager* pMan = MgServerManager::GetInstance();
-    if (NULL == pMan)
-    {
-        throw new MgNullReferenceException(L"MgServerAdminService::SetConfigurationProperties", __LINE__, __WFILE__, NULL, L"", NULL);
-    }
+    CHECKNULL(pMan, L"MgServerAdminService::SetConfigurationProperties");
 
     pMan->SetConfigurationProperties(propertySection, properties);
 
@@ -514,10 +490,7 @@
     MG_LOG_TRACE_ENTRY(L"MgServerAdminService::SetConfigurationProperties()");
 
     MgServerManager* pMan = MgServerManager::GetInstance();
-    if (NULL == pMan)
-    {
-        throw new MgNullReferenceException(L"MgServerAdminService::SetConfigurationProperties", __LINE__, __WFILE__, NULL, L"", NULL);
-    }
+    CHECKNULL(pMan, L"MgServerAdminService::SetConfigurationProperties");
 
     pMan->RemoveConfigurationProperties(propertySection, properties);
 
@@ -538,10 +511,7 @@
     MG_LOG_TRACE_ENTRY(L"MgServerAdminService::GetInformationProperties()");
 
     MgServerManager* pMan = MgServerManager::GetInstance();
-    if (NULL == pMan)
-    {
-        throw new MgNullReferenceException(L"MgServerAdminService::GetInformationProperties", __LINE__, __WFILE__, NULL, L"", NULL);
-    }
+    CHECKNULL(pMan, L"MgServerAdminService::GetInformationProperties");
 
     pProperties = pMan->GetInformationProperties();
 
@@ -563,10 +533,7 @@
     MG_LOG_TRACE_ENTRY(L"MgServerAdminService::GetSiteVersion()");
 
     MgServerManager* pMan = MgServerManager::GetInstance();
-    if (NULL == pMan)
-    {
-        throw new MgNullReferenceException(L"MgServerAdminService::GetSiteVersion", __LINE__, __WFILE__, NULL, L"", NULL);
-    }
+    CHECKNULL(pMan, L"MgServerAdminService::GetSiteVersion");
 
     version = pMan->GetSiteVersion();
 
@@ -589,10 +556,7 @@
     MG_LOG_TRACE_ENTRY(L"MgServerAdminService::GetSiteStatus()");
 
     MgServerManager* pMan = MgServerManager::GetInstance();
-    if (NULL == pMan)
-    {
-        throw new MgNullReferenceException(L"MgServerAdminService::GetSiteStatus", __LINE__, __WFILE__, NULL, L"", NULL);
-    }
+    CHECKNULL(pMan, L"MgServerAdminService.GetSiteStatus");
 
     pProperties = pMan->GetSiteStatus();
 
@@ -995,10 +959,7 @@
     MG_LOG_TRACE_ENTRY(L"MgServerAdminService::SetDocument()");
 
     MgServerManager* pMan = MgServerManager::GetInstance();
-    if (NULL == pMan)
-    {
-        throw new MgNullReferenceException(L"MgServerAdminService::SetDocument", __LINE__, __WFILE__, NULL, L"", NULL);
-    }
+    CHECKNULL(pMan, L"MgServerAdminService::SetDocument");
 
     pMan->SetDocument(identifier, data);
 



More information about the mapguide-commits mailing list