[mapguide-trac] #1398: Upgrade to DbXml 2.5.16

MapGuide Open Source trac_mapguide at osgeo.org
Wed Sep 22 14:05:27 EDT 2010


#1398: Upgrade to DbXml 2.5.16
-----------------------+----------------------------------------------------
   Reporter:  rohitr   |       Owner:  brucedechant       
       Type:  task     |      Status:  new                
   Priority:  low      |   Milestone:  2.3                
  Component:  General  |     Version:  2.2.0              
   Severity:  trivial  |    Keywords:  dbxml, upgrade, oem
External_id:           |  
-----------------------+----------------------------------------------------
Description changed by brucedechant:

Old description:

> 1.> Used !DbEnv.get_DB_ENV and !DbTxn.get_DB_TXN to get the underlying
> DB_ENV and DB_TXN structure and used that with the !DbXml public
> interface.
>
> Changed
> {{{
> environment->GetXmlManager().createTransaction(m_dbTxn)));
> }}}
> to
> {{{
> environment->GetXmlManager().createTransaction(m_dbTxn->get_DB_TXN())));
> }}}
> and
> {{{
> m_xmlMan = XmlManager(&m_dbEnv, DBXML_ALLOW_EXTERNAL_ACCESS);
> }}}
> to
> {{{
> m_xmlMan = XmlManager(m_dbEnv.get_DB_ENV(), DBXML_ALLOW_EXTERNAL_ACCESS);
> }}}
>
> 2.>Added a function DbXml::getContentAsDOM(const !XmlValue &value). and
> used the constructor of the !XmlValue to get an !XmlValue handle on
> xmlDoc. The function is modified from an example in dbxml/example folder.
> Its a hack and I plan to make a proper class pretty soon.
>
> Created 2 files xercesDomTranslator.h and xercesDomTranslator.cpp. These
> are trivially modified forms of the file of the same name in dbxml
> example folder. However the function is trivial and I would make a class
> to encapsulate it, after I finish compilation.
> The function defined is
> {{{
> XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *getContentAsDOM(const
> DbXml::XmlValue &value);
> }}}
> It requires an !XmlValue and this is constructed by the constructor of
> the XmlValue class from the XmlDocument passed to it.
>
> 3.>Since XmlModify has been removed, we can use a simple Xquery Update to
> delete records. For example where our query was
> {{{ query = "/Role/Users/User[Name=<foobar>]"; }}} we change it to    {{{
> query = "delete nodes /Role/Users/User[Name=<foobar>]"; }}} and just
> execute the query with XmlManager::query().
>
> 4.>The function for assigning flags to DbEnv has been changed from
> set_flags to log_set_config. The define LOG_INMEMORY is no longer
> defined. It has been replaced with LOG_IN_MEMORY, which is functionally
> equivalent.
>
> 5.>Included db_cxx.h . Also removed the 'catch' for DbException. This
> isnt completely necessary but seeing that DbXml wants to encapsulate
> DbException inside XmlException and the functionality was similar, I
> removed it.
> {{{
> catch (XmlException& e)
> \
>     {
> \
>         MgStringCollection arguments;
> \
>         STRING message;
> \
> \
>         if (DB_LOCK_DEADLOCK == e.getDbErrno())
> \
>         {
> \
>             message = MgUtil::GetResourceMessage(
> \
>                 MgResources::ResourceService, L"MgRepositoryBusy");
> \
>         }
> \
>         else
> \
>         {
> \
>             MgUtil::MultiByteToWideChar(string(e.what()), message);
> \
>         }
> \
> \
>         arguments.Add(message);
> \
>         mgException = new MgDbXmlException(methodName, __LINE__,
> __WFILE__, NULL, L"MgFormatInnerExceptionMessage", &arguments); \
> (static_cast<MgThirdPartyException*>(mgException.p))->SetErrorCode(e.getDbErrno());
> \
>     }
> }}}
> and
> {{{
> catch (DbException& e)
> \
>     {
> \
>         MgStringCollection arguments;
> \
>         STRING message;
> \
> \
>         if (DB_LOCK_DEADLOCK == e.get_errno())
> \
>         {
> \
>             message = MgUtil::GetResourceMessage(
> \
>                 MgResources::ResourceService, L"MgRepositoryBusy");
> \
>         }
> \
>         else
> \
>         {
> \
>             MgUtil::MultiByteToWideChar(string(e.what()), message);
> \
>         }
> \
> \
>         arguments.Add(message);
> \
>         mgException = new MgDbException(methodName, __LINE__, __WFILE__,
> NULL, L"MgFormatInnerExceptionMessage", &arguments); \
> (static_cast<MgThirdPartyException*>(mgException.p))->SetErrorCode(e.get_errno());
> \
>     }
> }}}
> Since XmlException would be triggered on a DbException and would give the
> same DbErrno and what() string, it seemed redundant to include this. Note
> the initial motivation was this to go with the philosophy of dbxml of
> hiding DB as much as possible. Unfortunately due to MapGuides use of DB
> objects in multiple places, that won't be possible.
>
> 6.>As there is no other option, but to go with LiveValues and afaik there
> appears to be no difference, I have just removed the lines.

New description:

 1.> Used !DbEnv.get_DB_ENV and !DbTxn.get_DB_TXN to get the underlying
 DB_ENV and DB_TXN structure and used that with the !DbXml public
 interface.

 Changed
 {{{
 environment->GetXmlManager().createTransaction(m_dbTxn)));
 }}}
 to
 {{{
 environment->GetXmlManager().createTransaction(m_dbTxn->get_DB_TXN())));
 }}}
 and
 {{{
 m_xmlMan = XmlManager(&m_dbEnv, DBXML_ALLOW_EXTERNAL_ACCESS);
 }}}
 to
 {{{
 m_xmlMan = XmlManager(m_dbEnv.get_DB_ENV(), DBXML_ALLOW_EXTERNAL_ACCESS);
 }}}

 2.>Added a function DbXml::getContentAsDOM(const !XmlValue &value). and
 used the constructor of the !XmlValue to get an !XmlValue handle on
 xmlDoc. The function is modified from an example in dbxml/example folder.
 Its a hack and I plan to make a proper class pretty soon.

 Created 2 files xercesDomTranslator.h and xercesDomTranslator.cpp. These
 are trivially modified forms of the file of the same name in dbxml example
 folder. However the function is trivial and I would make a class to
 encapsulate it, after I finish compilation.
 The function defined is
 {{{
 XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *getContentAsDOM(const
 DbXml::XmlValue &value);
 }}}
 It requires an !XmlValue and this is constructed by the constructor of the
 !XmlValue class from the !XmlDocument passed to it.

 3.>Since !XmlModify has been removed, we can use a simple Xquery Update to
 delete records. For example where our query was

 {{{
 query = "/Role/Users/User[Name=<foobar>]";
 }}}
 we change it to
 {{{
 query = "delete nodes /Role/Users/User[Name=<foobar>]";
 }}}
 and just execute the query with XmlManager::query().

 4.>The function for assigning flags to !DbEnv has been changed from
 set_flags to log_set_config. The define LOG_INMEMORY is no longer defined.
 It has been replaced with LOG_IN_MEMORY, which is functionally equivalent.

 5.>Included db_cxx.h . Also removed the 'catch' for !DbException. This
 isnt completely necessary but seeing that !DbXml wants to encapsulate
 !DbException inside !XmlException and the functionality was similar, I
 removed it.
 {{{
 catch (XmlException& e)
 \
     {
 \
         MgStringCollection arguments;
 \
         STRING message;
 \
 \
         if (DB_LOCK_DEADLOCK == e.getDbErrno())
 \
         {
 \
             message = MgUtil::GetResourceMessage(
 \
                 MgResources::ResourceService, L"MgRepositoryBusy");
 \
         }
 \
         else
 \
         {
 \
             MgUtil::MultiByteToWideChar(string(e.what()), message);
 \
         }
 \
 \
         arguments.Add(message);
 \
         mgException = new MgDbXmlException(methodName, __LINE__,
 __WFILE__, NULL, L"MgFormatInnerExceptionMessage", &arguments); \
 (static_cast<MgThirdPartyException*>(mgException.p))->SetErrorCode(e.getDbErrno());
 \
     }
 }}}
 and
 {{{
 catch (DbException& e)
 \
     {
 \
         MgStringCollection arguments;
 \
         STRING message;
 \
 \
         if (DB_LOCK_DEADLOCK == e.get_errno())
 \
         {
 \
             message = MgUtil::GetResourceMessage(
 \
                 MgResources::ResourceService, L"MgRepositoryBusy");
 \
         }
 \
         else
 \
         {
 \
             MgUtil::MultiByteToWideChar(string(e.what()), message);
 \
         }
 \
 \
         arguments.Add(message);
 \
         mgException = new MgDbException(methodName, __LINE__, __WFILE__,
 NULL, L"MgFormatInnerExceptionMessage", &arguments); \
 (static_cast<MgThirdPartyException*>(mgException.p))->SetErrorCode(e.get_errno());
 \
     }
 }}}
 Since !XmlException would be triggered on a !DbException and would give
 the same !DbErrno and what() string, it seemed redundant to include this.
 Note the initial motivation was this to go with the philosophy of dbxml of
 hiding DB as much as possible. Unfortunately due to MapGuide's use of DB
 objects in multiple places, that won't be possible.

 6.>As there is no other option, but to go with !LiveValues and afaik there
 appears to be no difference, I have just removed the lines.

--

-- 
Ticket URL: <http://trac.osgeo.org/mapguide/ticket/1398#comment:3>
MapGuide Open Source <http://mapguide.osgeo.org/>
MapGuide Open Source Internals


More information about the mapguide-trac mailing list