[mapguide-commits] r1094 - in trunk/MgDev: Common/PlatformBase/Services Server/src/Common/Manager Server/src/Services/Feature Server/src/Services/Resource

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Mon Feb 5 23:15:25 EST 2007


Author: tonyfang
Date: 2007-02-05 23:15:24 -0500 (Mon, 05 Feb 2007)
New Revision: 1094

Modified:
   trunk/MgDev/Common/PlatformBase/Services/ResourceDefs.cpp
   trunk/MgDev/Common/PlatformBase/Services/ResourceDefs.h
   trunk/MgDev/Server/src/Common/Manager/UnmanagedDataManager.cpp
   trunk/MgDev/Server/src/Common/Manager/UnmanagedDataManager.h
   trunk/MgDev/Server/src/Services/Feature/ServerGetSchemaMapping.cpp
   trunk/MgDev/Server/src/Services/Resource/ApplicationRepositoryManager.cpp
   trunk/MgDev/Server/src/Services/Resource/TagManager.cpp
   trunk/MgDev/Server/src/Services/Resource/TagManager.h
Log:
MapGuide RFC 12 - Unmanaged Data API Changes
- substitute unmanaged data mappings in GetSchemaMapping API
- move SubstituteMappingTag from TagManager to UnmanagedDataManager (so it can be re-used by GetSchemaMapping)

Modified: trunk/MgDev/Common/PlatformBase/Services/ResourceDefs.cpp
===================================================================
--- trunk/MgDev/Common/PlatformBase/Services/ResourceDefs.cpp	2007-02-05 21:44:33 UTC (rev 1093)
+++ trunk/MgDev/Common/PlatformBase/Services/ResourceDefs.cpp	2007-02-06 04:15:24 UTC (rev 1094)
@@ -63,8 +63,6 @@
 const STRING MgResourceTag::Username                = L"%MG_USERNAME%";
 const STRING MgResourceTag::Password                = L"%MG_PASSWORD%";
 const STRING MgResourceTag::DataFilePath            = L"%MG_DATA_FILE_PATH%";
-const STRING MgResourceTag::MappingBegin            = L"%MG_[";
-const STRING MgResourceTag::MappingEnd              = L"]%";
 
 
 ///////////////////////////////////////////////////////////////////////////////

Modified: trunk/MgDev/Common/PlatformBase/Services/ResourceDefs.h
===================================================================
--- trunk/MgDev/Common/PlatformBase/Services/ResourceDefs.h	2007-02-05 21:44:33 UTC (rev 1093)
+++ trunk/MgDev/Common/PlatformBase/Services/ResourceDefs.h	2007-02-06 04:15:24 UTC (rev 1094)
@@ -270,20 +270,6 @@
     /// given resource. The trailing "/" is included.
     ///
     static const STRING DataFilePath;   ///\if INTERNAL value("%MG_DATA_FILE_PATH%") \endif
-
-
-    ////////////////////////////////////////////////////////////////
-    /// \brief
-    /// This tag signifies beginning of unmanaged data mapping name.
-    ///
-    static const STRING MappingBegin;   ///\if INTERNAL value("%MG_[") \endif
-
-
-    ////////////////////////////////////////////////////////////////
-    /// \brief
-    /// This tag signifies end of unmanaged data mapping name.
-    ///
-    static const STRING MappingEnd;     ///\if INTERNAL value("]%") \endif
 };
 
 

Modified: trunk/MgDev/Server/src/Common/Manager/UnmanagedDataManager.cpp
===================================================================
--- trunk/MgDev/Server/src/Common/Manager/UnmanagedDataManager.cpp	2007-02-05 21:44:33 UTC (rev 1093)
+++ trunk/MgDev/Server/src/Common/Manager/UnmanagedDataManager.cpp	2007-02-06 04:15:24 UTC (rev 1094)
@@ -24,15 +24,16 @@
 // Process-wide MgUnmanagedDataManager
 Ptr<MgUnmanagedDataManager> MgUnmanagedDataManager::sm_unmanagedDataManager = (MgUnmanagedDataManager*)NULL;
 
-//Ptr<MgPropertyCollection> MgUnmanagedDataManager::m_unmanagedDataMappings = (MgPropertyCollection*)NULL;
-
 const STRING MgUnmanagedDataManager::Folders              = L"FOLDERS";
 const STRING MgUnmanagedDataManager::Files                = L"FILES";
 const STRING MgUnmanagedDataManager::Both                 = L"BOTH";
 const STRING MgUnmanagedDataManager::OpenSquareBracket    = L"[";
 const STRING MgUnmanagedDataManager::ClosedSquareBracket  = L"]";
 
+const string MgUnmanagedDataManager::MappingBegin         = "%MG_[";
+const string MgUnmanagedDataManager::MappingEnd           = "]%";
 
+
 ///////////////////////////////////////////////////////////////////////////////
 /// \brief
 /// Constructs the object.
@@ -395,6 +396,65 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 /// \brief
+/// Substitutes unmanaged data mappings
+///
+int MgUnmanagedDataManager::SubstituteMappingTag(REFSTRING doc)
+{
+    string temp = MgUtil::WideCharToMultiByte(doc);
+    int result = SubstituteMappingTag(temp);
+
+    doc = MgUtil::MultiByteToWideChar(temp);
+    return result;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \brief
+/// Substitutes unmanaged data mappings
+///
+int MgUnmanagedDataManager::SubstituteMappingTag(string& doc)
+{
+    int count = 0;
+    size_t startPos, endPos;
+    size_t len1 = MgUnmanagedDataManager::MappingBegin.length();
+    size_t len2 = MgUnmanagedDataManager::MappingEnd.length();
+
+    while (string::npos != (startPos = doc.find(MgUnmanagedDataManager::MappingBegin)))
+    {
+        // beginTag found, now look for endTag
+        while (string::npos != (endPos = doc.find(MgUnmanagedDataManager::MappingEnd)))
+        {
+            // extract out the mapping name
+            string mappingName = doc.substr(startPos + len1, endPos - startPos - len1);
+            size_t nameLen = mappingName.length();
+
+            // find the mapping name in the map, and then replace it
+            MgPropertyCollection* mappings = MgUnmanagedDataManager::GetInstance()->GetUnmanagedDataMappings();
+            if (mappings != NULL)
+            {
+                Ptr<MgStringProperty> stringProp = dynamic_cast<MgStringProperty*>(mappings->FindItem(MgUtil::MultiByteToWideChar(mappingName)));
+                if (stringProp != NULL)
+                {
+                    STRING mappingDir = stringProp->GetValue();
+
+                    // replace the mappingName with the actual directory
+                    if (!MgFileUtil::EndsWithSlash(mappingDir))
+                        MgFileUtil::AppendSlashToEndOfPath(mappingDir);
+
+                    size_t dirLen = mappingDir.length();
+
+                    doc.replace(startPos, len1 + nameLen + len2, MgUtil::WideCharToMultiByte(mappingDir), 0, dirLen);
+                    ++count;
+                    break;
+                }
+            }
+        }
+    }
+
+    return count;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \brief
 /// Returns unmanaged data 
 ///
 MgByteReader* MgUnmanagedDataManager::EnumerateUnmanagedData(CREFSTRING path, bool recursive, CREFSTRING select, CREFSTRING filter)

Modified: trunk/MgDev/Server/src/Common/Manager/UnmanagedDataManager.h
===================================================================
--- trunk/MgDev/Server/src/Common/Manager/UnmanagedDataManager.h	2007-02-05 21:44:33 UTC (rev 1093)
+++ trunk/MgDev/Server/src/Common/Manager/UnmanagedDataManager.h	2007-02-06 04:15:24 UTC (rev 1094)
@@ -56,7 +56,8 @@
 
     static MgUnmanagedDataManager* GetInstance();
     MgPropertyCollection* GetUnmanagedDataMappings();
-//    static void ConvertUnmanagedDataMappingName(REFSTRING path); // TODO: remove
+    static int SubstituteMappingTag(REFSTRING data);
+    static int SubstituteMappingTag(string& data);
     void Initialize();
 
     virtual void Dispose();
@@ -76,6 +77,9 @@
 
     static const STRING OpenSquareBracket;
     static const STRING ClosedSquareBracket;
+
+    static const string MappingBegin;
+    static const string MappingEnd;
 };
 
 #endif

Modified: trunk/MgDev/Server/src/Services/Feature/ServerGetSchemaMapping.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Feature/ServerGetSchemaMapping.cpp	2007-02-05 21:44:33 UTC (rev 1093)
+++ trunk/MgDev/Server/src/Services/Feature/ServerGetSchemaMapping.cpp	2007-02-06 04:15:24 UTC (rev 1094)
@@ -17,6 +17,7 @@
 
 #include "ServerFeatureServiceDefs.h"
 #include "ServerGetSchemaMapping.h"
+#include "UnmanagedDataManager.h"
 
 MgServerGetSchemaMapping::MgServerGetSchemaMapping() :
     m_bytes(NULL)
@@ -39,7 +40,10 @@
     // Connect to the provider
     FdoPtr<FdoIConnection> fdoConnection;
 
-    MgServerFeatureConnection msfc(providerName, partialConnString);
+    STRING data = partialConnString;
+    MgUnmanagedDataManager::SubstituteMappingTag(data);
+
+    MgServerFeatureConnection msfc(providerName, data);
     if (( msfc.IsConnectionOpen() ) || ( msfc.IsConnectionPending() ))
     {
         fdoConnection = msfc.GetConnection();

Modified: trunk/MgDev/Server/src/Services/Resource/ApplicationRepositoryManager.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Resource/ApplicationRepositoryManager.cpp	2007-02-05 21:44:33 UTC (rev 1093)
+++ trunk/MgDev/Server/src/Services/Resource/ApplicationRepositoryManager.cpp	2007-02-06 04:15:24 UTC (rev 1094)
@@ -360,11 +360,9 @@
         dataBindingInfo.SetLoginUsername(m_currUserInfo->GetUserName());
         dataBindingInfo.SetLoginPassword(m_currUserInfo->GetPassword());
 
-        if (resource->IsResourceTypeOf(MgResourceType::FeatureSource))
-        {
-            // turn on substitute unmanaged data mappings
-            dataBindingInfo.SetSubstituteUnmanagedDataMappings(true);
-        }
+        // turn on substitute unmanaged data mappings
+        dataBindingInfo.SetSubstituteUnmanagedDataMappings(
+            resource->IsResourceTypeOf(MgResourceType::FeatureSource));
 
         byteReader = resourceContentMan->GetResource(resource,
             &dataBindingInfo);

Modified: trunk/MgDev/Server/src/Services/Resource/TagManager.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Resource/TagManager.cpp	2007-02-05 21:44:33 UTC (rev 1093)
+++ trunk/MgDev/Server/src/Services/Resource/TagManager.cpp	2007-02-06 04:15:24 UTC (rev 1094)
@@ -323,10 +323,7 @@
 
     if (dataBindingInfo.GetSubstituteUnmanagedDataMappings())
     {
-        count += SubstituteMappingTag(
-            MgUtil::WideCharToMultiByte(MgResourceTag::MappingBegin), 
-            MgUtil::WideCharToMultiByte(MgResourceTag::MappingEnd), 
-            doc);
+        count += MgUnmanagedDataManager::SubstituteMappingTag(doc);
     }
 
     CheckTagStrings(doc);
@@ -368,53 +365,6 @@
     return SubstituteTag(tagName, tagValue, doc);
 }
 
-///////////////////////////////////////////////////////////////////////////////
-/// \brief
-/// Substitutes the mapping tag.
-///
-int MgTagManager::SubstituteMappingTag(const string& beginTag, const string& endTag, string& doc)
-{
-    int count = 0;
-    size_t startPos, endPos;
-    size_t len1 = beginTag.length();
-    size_t len2 = endTag.length();
-
-    while (string::npos != (startPos = doc.find(beginTag)))
-    {
-        // beginTag found, now look for endTag
-        while (string::npos != (endPos = doc.find(endTag)))
-        {
-            // extract out the mapping name
-            string mappingName = doc.substr(startPos + len1, endPos - startPos - len1);
-            size_t nameLen = mappingName.length();
-
-            // find the mapping name in the map, and then replace it
-            MgPropertyCollection* mappings = MgUnmanagedDataManager::GetInstance()->GetUnmanagedDataMappings();
-            if (mappings != NULL)
-            {
-                Ptr<MgStringProperty> stringProp = dynamic_cast<MgStringProperty*>(mappings->FindItem(MgUtil::MultiByteToWideChar(mappingName)));
-                if (stringProp != NULL)
-                {
-                    STRING mappingDir = stringProp->GetValue();
-
-                    // replace the mappingName with the actual directory
-                    if (!MgFileUtil::EndsWithSlash(mappingDir))
-                        MgFileUtil::AppendSlashToEndOfPath(mappingDir);
-
-                    size_t dirLen = mappingDir.length();
-
-                    doc.replace(startPos, len1 + nameLen + len2, MgUtil::WideCharToMultiByte(mappingDir), 0, dirLen);
-                    ++count;
-                    break;
-                }
-            }
-        }
-    }
-
-    return count;
-}
-
-
 ///----------------------------------------------------------------------------
 /// <summary>
 /// Gets the specified tag.

Modified: trunk/MgDev/Server/src/Services/Resource/TagManager.h
===================================================================
--- trunk/MgDev/Server/src/Services/Resource/TagManager.h	2007-02-05 21:44:33 UTC (rev 1093)
+++ trunk/MgDev/Server/src/Services/Resource/TagManager.h	2007-02-06 04:15:24 UTC (rev 1094)
@@ -58,7 +58,6 @@
 
     int SubstituteTag(const string& name, const string& value, string& doc);
     int SubstituteTag(CREFSTRING name, CREFSTRING value, string& doc);
-    int SubstituteMappingTag(const string& beginMapping, const string& endMapping, string& doc);
     void AddTag(CREFSTRING name, const MgTagInfo& tagInfo);
 
 private:



More information about the mapguide-commits mailing list