[mapguide-commits] r7201 - in sandbox/adsk/2.5k: . Common/CoordinateSystem Common/Geometry/CoordinateSystem

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Wed Nov 7 01:13:52 PST 2012


Author: baertelchen
Date: 2012-11-07 01:13:51 -0800 (Wed, 07 Nov 2012)
New Revision: 7201

Modified:
   sandbox/adsk/2.5k/
   sandbox/adsk/2.5k/Common/CoordinateSystem/CoordSysCatalog.cpp
   sandbox/adsk/2.5k/Common/Geometry/CoordinateSystem/CoordinateSystemCatalog.h
Log:
Have MgCoordinateSystemCatalog::AreDictionaryFilesWritable() to check [m_sUserDir], too (part of RFC 127)

--> Merged from trunk (at revision 7200) <--

The [MgCoordinateSystemCatalog::AreDictionaryFilesWritable()] method checks, whether updating definitions in any of CS-Map's dictionary can be done.

Due to the implementation of RFC127, we've to make sure, that [AreDictionaryFilesWritable] checks the alternative user directory for writing access, i.e. 
[m_sUserDir] instead of [m_sDir]. But only, if [SetUserDictionaryDir()] had been successfully called before. Because all updates will end up in modifying the files in
[m_sUserDir] anyway.

I've now changed the implementation of [AreDictionaryFilesWritable] to check whether [m_sUserDir] can be written to (if set).
If not available, the code behaves as before, i.e. it will check, whether all CSD files can be updated in [m_sDir].

Added the documentation to the CoordinateSystemCatalog.h header.

Changes reviewed by Hugues.


Property changes on: sandbox/adsk/2.5k
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/2.4/MgDev:6749-6756,6777-6783,6785-6787,6789,6791-6794,6796-6801,6954-6962,6986-7006
/sandbox/rfc94:5099-5163
   + /branches/2.4/MgDev:6749-6756,6777-6783,6785-6787,6789,6791-6794,6796-6801,6954-6962,6986-7006
/sandbox/rfc94:5099-5163
/trunk/MgDev:7190-7200

Modified: sandbox/adsk/2.5k/Common/CoordinateSystem/CoordSysCatalog.cpp
===================================================================
--- sandbox/adsk/2.5k/Common/CoordinateSystem/CoordSysCatalog.cpp	2012-11-07 09:06:52 UTC (rev 7200)
+++ sandbox/adsk/2.5k/Common/CoordinateSystem/CoordSysCatalog.cpp	2012-11-07 09:13:51 UTC (rev 7201)
@@ -453,15 +453,18 @@
     return m_sUserDir;
 }
 
-//cgeck if the files are writable
+//check if the files are writable
 //The read mode was tracked down when the file names were set up
-//if the files were not valif an assertion was thorwn at that time
+//if the files were not valid an assertion was thorwn at that time
 //this additional method can check if the files can be open in write mode
 //if the file names and path have not yet been set up, an assertion is thrown
 bool CCoordinateSystemCatalog::AreDictionaryFilesWritable()
 {
     MG_TRY()
 
+    //the default dictionary path must contain the relevant CSD files,
+    //whereas the directory into which we might store any user-defined
+    //definitions does not necessarily contain any of the CSD files
     if (m_sDir.empty()
         || !m_pCsDict || m_pCsDict->GetFileName().empty()
         || !m_pDtDict || m_pDtDict->GetFileName().empty()
@@ -474,8 +477,27 @@
         throw new MgCoordinateSystemInitializationFailedException(L"MgCoordinateSystemCatalog.AreDictionaryFilesWritable", __LINE__, __WFILE__, NULL, L"MgCoordinateSystemNotReadyException", NULL);
     }
 
+    //the [m_sUserDir] will only contain something, if [SetUserDictionaryDir] had been called
+    //successfully before - either by the automatic initialization or explicitly
+    //
+    if (!m_sUserDir.empty()) 
+    {
+        //note, that we're assuming here that if we can write to the directory
+        //we'll also be able to write-open any CSD file contained in it.
+        //As this here is just a pre-check for the current point in time,
+        //the actual attempt to write to the CSD file might then still fail what is
+        //unlikely and should actually be considered a problem in the user-specific setup of the CSD
+        //files & folder
+        return ValidateFile(
+            m_sUserDir.c_str(),    //path to directory 
+            true,    //must exist 
+            true,    //must be a directory 
+            true,    //must be writable? 
+            NULL);
+    }
+
+    EFileValidity reason;
     STRING sPath=m_pElDict->GetPath();
-    EFileValidity reason;
     if (!ValidateFile(
         sPath.c_str(),          //file name
         true,                   //must exist

Modified: sandbox/adsk/2.5k/Common/Geometry/CoordinateSystem/CoordinateSystemCatalog.h
===================================================================
--- sandbox/adsk/2.5k/Common/Geometry/CoordinateSystem/CoordinateSystemCatalog.h	2012-11-07 09:06:52 UTC (rev 7200)
+++ sandbox/adsk/2.5k/Common/Geometry/CoordinateSystem/CoordinateSystemCatalog.h	2012-11-07 09:13:51 UTC (rev 7201)
@@ -96,6 +96,24 @@
     virtual MgCoordinateSystemProjectionInformation* GetProjectionInformation()=0;
     virtual MgCoordinateSystemUnitInformation* GetUnitInformation()=0;
     virtual MgCoordinateSystemDictionaryUtility* GetDictionaryUtility()=0;
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Checks whether any kind of definition supported by this catalog can be updated in the dictionary files currently in use.
+    ///
+    /// Depending on whether this catalog uses a specific directory to store user-provided definitions in, this method
+    /// will perform the following checks:
+    /// \li <b>No specific directory supplied:</b> The target directory is verified to contain all required CSD files.
+    /// If all have been found, they are verified to be writable. If not all CSD files have been found or
+    /// if at least one CSD files cannot be written to, this method will return false.
+    /// \li <b>Specific directory supplied:</b> The target directory is verified to exist and that it is writable, i.e.
+    /// new files can be created in it. Any existing CSD files are assumed to be writeable then, too.
+    ///
+    /// \return Returns true, if definitions can be updated, incl. adding and deletion, as per the definition above.
+    /// Otherwise false.
+    /// \remarks
+    /// Note, that even if this method returns true, the caller must be prepared that the actual
+    /// update request of a definition might still fail.
     virtual bool AreDictionaryFilesWritable()=0;
 
 INTERNAL_API:



More information about the mapguide-commits mailing list