[mapguide-commits] r7200 - in trunk/MgDev/Common: CoordinateSystem Geometry/CoordinateSystem
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Wed Nov 7 01:06:53 PST 2012
Author: baertelchen
Date: 2012-11-07 01:06:52 -0800 (Wed, 07 Nov 2012)
New Revision: 7200
Modified:
trunk/MgDev/Common/CoordinateSystem/CoordSysCatalog.cpp
trunk/MgDev/Common/Geometry/CoordinateSystem/CoordinateSystemCatalog.h
Log:
Have MgCoordinateSystemCatalog::AreDictionaryFilesWritable() to check [m_sUserDir], too (part of RFC 127)
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.
Modified: trunk/MgDev/Common/CoordinateSystem/CoordSysCatalog.cpp
===================================================================
--- trunk/MgDev/Common/CoordinateSystem/CoordSysCatalog.cpp 2012-11-07 07:38:08 UTC (rev 7199)
+++ trunk/MgDev/Common/CoordinateSystem/CoordSysCatalog.cpp 2012-11-07 09:06:52 UTC (rev 7200)
@@ -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: trunk/MgDev/Common/Geometry/CoordinateSystem/CoordinateSystemCatalog.h
===================================================================
--- trunk/MgDev/Common/Geometry/CoordinateSystem/CoordinateSystemCatalog.h 2012-11-07 07:38:08 UTC (rev 7199)
+++ trunk/MgDev/Common/Geometry/CoordinateSystem/CoordinateSystemCatalog.h 2012-11-07 09:06:52 UTC (rev 7200)
@@ -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