[GME-commit] GMESRC/GME/XmlBackEnd CoreXmlFile.cpp, 1.31, 1.32 CoreXmlFile.h, 1.15, 1.16
Log messages of CVS commits
gme-commit at list.isis.vanderbilt.edu
Wed Feb 20 16:08:54 CST 2008
- Previous message: [GME-commit] GMESRC/GME/Gme GMEApp.cpp,1.149,1.150
- Next message: [GME-commit] GMESRC/GME/XmlBackEnd DOMErrorPrinter.cpp, NONE, 1.1 DOMErrorPrinter.h, NONE, 1.1 CoreXmlFile.cpp, 1.32, 1.33 CoreXmlFile.h, 1.16, 1.17 OperOptions.cpp, 1.3, 1.4 OperOptions.h, 1.2, 1.3 XmlBackEnd.vcproj, 1.9, 1.10
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /project/gme-repository/GMESRC/GME/XmlBackEnd
In directory escher:/tmp/cvs-serv5965
Modified Files:
CoreXmlFile.cpp CoreXmlFile.h
Log Message:
Better error handling, message written to the console for errors and exceptions.
CVS User: Zoltan Molnar, ISIS (zolmol)
Index: CoreXmlFile.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/XmlBackEnd/CoreXmlFile.cpp,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** CoreXmlFile.cpp 20 Feb 2008 19:10:16 -0000 1.31
--- CoreXmlFile.cpp 20 Feb 2008 22:08:52 -0000 1.32
***************
*** 3006,3010 ****
--- 3006,3013 ----
FILE * f = fopen( m_cacheFileName.c_str(), "wb" );
if( f==NULL )
+ {
+ sendMsg( "Exception: Could not create binary cache file!", MSG_ERROR);
HR_THROW(E_FILEOPEN);
+ }
XmlObjVecIter i;
***************
*** 3132,3150 ****
void CCoreXmlFile::createProjectFile()
{
- // in case of clearcase directory must be created with clearcase (no addelement, grrrr!)
- if ( m_sourceControl == SC_CLEARCASE ) { } // done
- else if( m_sourceControl == SC_SUBVERSION) { } // done
- else if( m_sourceControl == SC_SOURCESAFE) { } // done
- else // done
- {
- // create project folder
- //if( CreateDirectory(m_folderPath.c_str(),NULL) == 0 )
- // HR_THROW(E_FILEOPEN);
- }
-
// create projet file
FILE * f = fopen( m_projectFileName.c_str(), "wt" );
if( f == NULL )
{
AfxMessageBox( (std::string( "Could not create file ") + m_projectFileName).c_str());
HR_THROW(E_FILEOPEN);
--- 3135,3143 ----
void CCoreXmlFile::createProjectFile()
{
// create projet file
FILE * f = fopen( m_projectFileName.c_str(), "wt" );
if( f == NULL )
{
+ sendMsg( "Exception: Could not create project file '" + m_projectFileName + "'!", MSG_ERROR);
AfxMessageBox( (std::string( "Could not create file ") + m_projectFileName).c_str());
HR_THROW(E_FILEOPEN);
***************
*** 3236,3239 ****
--- 3229,3237 ----
}
DOMElement * e = doc->getDocumentElement();
+ if( e == NULL)
+ {
+ sendMsg( "Null document element error during parsing of '" + m_projectFileName + "'!", MSG_ERROR);
+ HR_THROW(E_FILEOPEN);
+ }
XMLCh* x_vssDatabase = XMLString::transcode("VSSDatabase");
***************
*** 3651,3664 ****
ASSERT( domimpl != NULL );
! parser = domimpl->createDOMBuilder( DOMImplementationLS::MODE_SYNCHRONOUS, NULL );
ASSERT( parser != NULL );
XERCES_CPP_NAMESPACE::DOMDocument * doc = parser->parseURI( fileName );
! if( 0 == doc->getDocumentElement())
{
DOMNodeList* list = doc->getChildNodes();
! for( int i = (int) list->getLength() - 1; i >= 0 ; --i)
{
DOMNode * node = list->item(i);
if( node->getNodeType() == DOMNode::NodeType::TEXT_NODE)
--- 3649,3677 ----
ASSERT( domimpl != NULL );
! parser = !domimpl? 0: domimpl->createDOMBuilder( DOMImplementationLS::MODE_SYNCHRONOUS, NULL );
ASSERT( parser != NULL );
+ if( !domimpl || !parser)
+ {
+ sendMsg( std::string( "Could not create parser for file ") + fileName + "!", MSG_ERROR);
+ HR_THROW(E_FILEOPEN);
+ }
XERCES_CPP_NAMESPACE::DOMDocument * doc = parser->parseURI( fileName );
! if( doc == NULL)
! {
! sendMsg( std::string( "Could not parse file ") + fileName + "!", MSG_ERROR);
! HR_THROW(E_FILEOPEN);
! }
!
! DOMElement * doc_e = doc->getDocumentElement();
! if( doc_e == NULL)
{
+ // todo linenumbers
+ bool might_be_ok = false;
DOMNodeList* list = doc->getChildNodes();
! if( list) for( int i = (int) list->getLength() - 1; i >= 0 ; --i)
{
+ might_be_ok = true;
DOMNode * node = list->item(i);
if( node->getNodeType() == DOMNode::NodeType::TEXT_NODE)
***************
*** 3673,3680 ****
}
}
}
! readObject( doc->getDocumentElement(), pointers, NULL, fullLoad, lastWriteTime );
delete parser;
--- 3686,3703 ----
}
}
+ if( !might_be_ok)
+ sendMsg( std::string( "Null document element was found while parsing file ") + fileName + "!", MSG_ERROR);
+ // reload it, might be nonzero now (only in fairy tales probably)
+ doc_e = doc->getDocumentElement();
+ }
+ if( doc_e == NULL)
+ {
+ sendMsg( std::string( "Exception: Null document element during parsing of ") + fileName + "!", MSG_ERROR);
+ HR_THROW(E_FILEOPEN);
}
!
! readObject( doc_e, pointers, NULL, fullLoad, lastWriteTime );
delete parser;
***************
*** 3692,3695 ****
--- 3715,3723 ----
void CCoreXmlFile::readObject(DOMElement * e, UnresolvedPointerVec& pointers, XmlObject * parent, bool fullLoad, CTime lastWriteTime )
{
+ if( e == NULL)
+ {
+ sendMsg( "Exception: readObject invoked with null element!", MSG_ERROR);
+ HR_THROW(E_FILEOPEN);
+ }
// what is the deleted container policy? if XML attribute is used code below is needed
#ifdef DEBUG
***************
*** 4142,4150 ****
BOOL res;
res = CreateDirectory( m_folderPath.c_str(), NULL);
! if( !res) HR_THROW(E_FILEOPEN);
// create project folder on the server
CComObjPtr<IVSSItem> proj_main_item = createFolderSS( item, m_projectName.c_str(), m_folderPath.c_str());
! if( !proj_main_item) HR_THROW(E_FILEOPEN);
//CComObjPtr<IVSSItem> item2;
--- 4170,4186 ----
BOOL res;
res = CreateDirectory( m_folderPath.c_str(), NULL);
! if( !res)
! {
! sendMsg( "Exception: Could not create project folder '" + m_folderPath + "'!", MSG_ERROR);
! HR_THROW(E_FILEOPEN);
! }
// create project folder on the server
CComObjPtr<IVSSItem> proj_main_item = createFolderSS( item, m_projectName.c_str(), m_folderPath.c_str());
! if( !proj_main_item)
! {
! sendMsg( "Exception: Could not create versioned folder '" + m_projectName + "'!", MSG_ERROR);
! HR_THROW(E_FILEOPEN);
! }
//CComObjPtr<IVSSItem> item2;
***************
*** 4161,4164 ****
--- 4197,4202 ----
succ = createHashedFolders();
if( !succ) {
+
+ sendMsg( "Exception: Could not create initial directory structure!", MSG_ERROR);
AfxMessageBox( "Could not create initial directory structure.");
HR_THROW(E_FILEOPEN);
***************
*** 4204,4207 ****
--- 4242,4246 ----
if( !succ) {
+ sendMsg( "Exception: Could not create initial project structure on server!", MSG_ERROR);
AfxMessageBox( "Could not create initial project structure on server.");
HR_THROW(E_FILEOPEN);
***************
*** 4509,4550 ****
}
- void CCoreXmlFile::addToSS( const std::string& p_path)
- {
- #if(0)
- CComObjPtr<IVSSItem> item;
- CComBSTR parentProject = m_vssParentPath.c_str();
- COMTHROW( m_vssDatabase->get_VSSItem( parentProject, false, &(item.p)) );
-
- // create project folder locally
- BOOL res = CreateDirectory( m_folderPath.c_str(), NULL);
- if( !res) HR_THROW(E_FILEOPEN);
-
- // create project folder on the server
- CComObjPtr<IVSSItem> proj_main_item = createFolderSS( item, m_projectName.c_str(), m_folderPath.c_str());
-
- createFolderSS( p_erfeporf, p_path, local);
- createFolderSS( proj_main_item, lev1, lev1full.c_str());//(m_folderPath + "\\" + lev1).c_str());
- // get project item
- CComObjPtr<IVSSItem> project_item;
-
- CComBSTR a_path;
- if( m_hashFileNames && ( m_hashVal == 2 || m_hashVal == 5))
- a_path = (m_vssPath + p_path.substr( m_folderPath.size(), p_path.size() - m_folderPath.size() - strlen("\\ce21dcacd8dced44896c385d004c6fa4.xml"))).c_str();
- else
- a_path = m_vssPath.c_str();
-
- COMTHROW( m_vssDatabase->get_VSSItem( a_path, false, &(project_item.p)) );
-
- // add to source control projecct
- CComObjPtr<IVSSItem> item;
- CComBSTR fileName2 = fileName.c_str();
- if( project_item->Add( fileName2, NULL, 0, &(item.p)) == 0 )
- {
- // check it out
- //checkOutContainer( container );
- }
- #endif
- }
-
void CCoreXmlFile::addToSourceControl(XmlObject * container, bool p_fileExisted)
{
--- 4548,4551 ----
***************
*** 4825,4839 ****
DOMImplementationLS * domimpl = DOMImplementationRegistry::getDOMImplementation(NULL);
ASSERT( domimpl != NULL );
! parser = domimpl->createDOMBuilder( DOMImplementationLS::MODE_SYNCHRONOUS, NULL );
ASSERT( parser != NULL );
XERCES_CPP_NAMESPACE::DOMDocument * doc = parser->parseURI( m_localFileName.c_str() );
if( doc == NULL )
HR_THROW(E_FILEOPEN);
DOMElement * doc_e = doc->getDocumentElement();
!
! if( !doc_e)
! return;
XMLCh * x_users = XMLString::transcode( ParserLiterals::Signer::users);
--- 4826,4850 ----
DOMImplementationLS * domimpl = DOMImplementationRegistry::getDOMImplementation(NULL);
ASSERT( domimpl != NULL );
! parser = !domimpl? 0: domimpl->createDOMBuilder( DOMImplementationLS::MODE_SYNCHRONOUS, NULL );
ASSERT( parser != NULL );
+ if( !domimpl || !parser)
+ {
+ m_parent->sendMsg( "Exception: Could not create parser!", MSG_ERROR);
+ HR_THROW(E_FILEOPEN);
+ }
XERCES_CPP_NAMESPACE::DOMDocument * doc = parser->parseURI( m_localFileName.c_str() );
if( doc == NULL )
+ {
+ m_parent->sendMsg( "Exception: Could not parse signature file!", MSG_ERROR);
HR_THROW(E_FILEOPEN);
+ }
DOMElement * doc_e = doc->getDocumentElement();
! if( doc_e == NULL)
! {
! m_parent->sendMsg( "Exception: Null document element in signature file!", MSG_ERROR);
! HR_THROW(E_FILEOPEN);
! }
XMLCh * x_users = XMLString::transcode( ParserLiterals::Signer::users);
***************
*** 4943,4947 ****
{
if( parser) delete parser;
! m_parent->sendMsg( "Parser exception during singature file update!", MSG_ERROR);
return;
}
--- 4954,4958 ----
{
if( parser) delete parser;
! m_parent->sendMsg( "Parser exception during signature file update!", MSG_ERROR);
return;
}
***************
*** 4956,4969 ****
DOMImplementationLS * domimpl = DOMImplementationRegistry::getDOMImplementation(NULL);
ASSERT( domimpl != NULL );
! parser = domimpl->createDOMBuilder( DOMImplementationLS::MODE_SYNCHRONOUS, NULL );
ASSERT( parser != NULL );
XERCES_CPP_NAMESPACE::DOMDocument * doc = parser->parseURI( m_localFileName.c_str());
if( doc == NULL )
HR_THROW(E_FILEOPEN);
! DOMElement * doc_e = doc->getDocumentElement();
! if( !doc_e)
! return res;
XMLCh* x_users = XMLString::transcode( ParserLiterals::Signer::users);
--- 4967,4991 ----
DOMImplementationLS * domimpl = DOMImplementationRegistry::getDOMImplementation(NULL);
ASSERT( domimpl != NULL );
! parser = !domimpl? 0: domimpl->createDOMBuilder( DOMImplementationLS::MODE_SYNCHRONOUS, NULL );
ASSERT( parser != NULL );
+ if( !domimpl || !parser)
+ {
+ m_parent->sendMsg( "Exception: Could not create parser!", MSG_ERROR);
+ HR_THROW(E_FILEOPEN);
+ }
XERCES_CPP_NAMESPACE::DOMDocument * doc = parser->parseURI( m_localFileName.c_str());
if( doc == NULL )
+ {
+ m_parent->sendMsg( "Exception: Could not parse signature file!", MSG_ERROR);
HR_THROW(E_FILEOPEN);
! }
! DOMElement * doc_e = doc->getDocumentElement();
! if( doc_e == NULL)
! {
! m_parent->sendMsg( "Exception: Null document element in signature file!", MSG_ERROR);
! HR_THROW(E_FILEOPEN);
! }
XMLCh* x_users = XMLString::transcode( ParserLiterals::Signer::users);
***************
*** 5119,5132 ****
DOMImplementationLS * domimpl = DOMImplementationRegistry::getDOMImplementation(NULL);
ASSERT( domimpl != NULL );
! parser = domimpl->createDOMBuilder( DOMImplementationLS::MODE_SYNCHRONOUS, NULL );
ASSERT( parser != NULL );
XERCES_CPP_NAMESPACE::DOMDocument * doc = parser->parseURI( m_localFileName.c_str() );
if( doc == NULL )
HR_THROW(E_FILEOPEN);
! DOMElement * doc_e = doc->getDocumentElement();
! if( !doc_e)
! return;
XMLCh* ITEM_xiteral = XMLString::transcode( ParserLiterals::Protector::item);
--- 5141,5165 ----
DOMImplementationLS * domimpl = DOMImplementationRegistry::getDOMImplementation(NULL);
ASSERT( domimpl != NULL );
! parser = !domimpl? 0: domimpl->createDOMBuilder( DOMImplementationLS::MODE_SYNCHRONOUS, NULL );
ASSERT( parser != NULL );
+ if( !domimpl || !parser)
+ {
+ m_parent->sendMsg( "Exception: Could not create parser!", MSG_ERROR);
+ HR_THROW(E_FILEOPEN);
+ }
XERCES_CPP_NAMESPACE::DOMDocument * doc = parser->parseURI( m_localFileName.c_str() );
if( doc == NULL )
+ {
+ m_parent->sendMsg( "Exception: Could not parse file '" + m_localFileName + "'!", MSG_ERROR);
HR_THROW(E_FILEOPEN);
! }
! DOMElement * doc_e = doc->getDocumentElement();
! if( doc_e == NULL)
! {
! m_parent->sendMsg( "Exception: Null document element in file '" + m_localFileName + "'!", MSG_ERROR);
! HR_THROW(E_FILEOPEN);
! }
XMLCh* ITEM_xiteral = XMLString::transcode( ParserLiterals::Protector::item);
***************
*** 5197,5200 ****
--- 5230,5234 ----
catch(...)
{
+ m_parent->sendMsg( "Exception while writing protection file '" + m_localFileName + "'!", MSG_ERROR);
if( parser) delete parser;
return;
***************
*** 5208,5221 ****
DOMImplementationLS * domimpl = DOMImplementationRegistry::getDOMImplementation(NULL);
ASSERT( domimpl != NULL );
! parser = domimpl->createDOMBuilder( DOMImplementationLS::MODE_SYNCHRONOUS, NULL );
ASSERT( parser != NULL );
XERCES_CPP_NAMESPACE::DOMDocument * doc = parser->parseURI( m_localFileName.c_str() );
if( doc == NULL )
HR_THROW(E_FILEOPEN);
! DOMElement * doc_e = doc->getDocumentElement();
! if( !doc_e)
! return;
XMLCh* ITEM_xiteral = XMLString::transcode( ParserLiterals::Protector::item);
--- 5242,5266 ----
DOMImplementationLS * domimpl = DOMImplementationRegistry::getDOMImplementation(NULL);
ASSERT( domimpl != NULL );
! parser = !domimpl? 0: domimpl->createDOMBuilder( DOMImplementationLS::MODE_SYNCHRONOUS, NULL );
ASSERT( parser != NULL );
+ if( !domimpl || !parser)
+ {
+ m_parent->sendMsg( "Exception: Could not create parser!", MSG_ERROR);
+ HR_THROW(E_FILEOPEN);
+ }
XERCES_CPP_NAMESPACE::DOMDocument * doc = parser->parseURI( m_localFileName.c_str() );
if( doc == NULL )
+ {
+ m_parent->sendMsg( "Exception: Could not parse file '" + m_localFileName + "'!", MSG_ERROR);
HR_THROW(E_FILEOPEN);
! }
! DOMElement * doc_e = doc->getDocumentElement();
! if( doc_e == NULL)
! {
! m_parent->sendMsg( "Exception: Null document element in file '" + m_localFileName + "'!", MSG_ERROR);
! HR_THROW(E_FILEOPEN);
! }
XMLCh* ITEM_xiteral = XMLString::transcode( ParserLiterals::Protector::item);
***************
*** 5256,5259 ****
--- 5301,5309 ----
doc->normalizeDocument();
DOMElement * doc_f = doc->getDocumentElement();
+ if( doc_f == NULL)
+ {
+ m_parent->sendMsg( "Exception: Null document element in file '" + m_localFileName + "' after normalization!", MSG_ERROR);
+ HR_THROW(E_FILEOPEN);
+ }
// replace sequences of '\n' with just one
***************
*** 5283,5286 ****
--- 5333,5341 ----
DOMWriter* writer = domimpl->createDOMWriter();
+ if( writer == NULL)
+ {
+ m_parent->sendMsg( "Exception: Could not create DOM Writer for '" + m_localFileName + "'!", MSG_ERROR);
+ HR_THROW(E_FILEOPEN);
+ }
if( writer->canSetFeature( XMLUni::fgDOMWRTDiscardDefaultContent, true))
***************
*** 5306,5309 ****
--- 5361,5365 ----
catch(...)
{
+ m_parent->sendMsg( "Exception while purging protection file '" + m_localFileName + "'!", MSG_ERROR);
if( parser) delete parser;
return;
***************
*** 5852,5855 ****
--- 5908,5912 ----
}
} catch(...) {
+ sendMsg( "Exception: Could not create initial directory structure!", MSG_ERROR);
AfxMessageBox( "Could not create initial directory structure.");
HR_THROW(E_FILEOPEN);
***************
*** 6034,6037 ****
--- 6091,6095 ----
if( !succ)
{
+ sendMsg( "Exception: Could not create initial directory structure!", MSG_ERROR);
AfxMessageBox( "Could not create initial directory structure");
HR_THROW(E_FILEOPEN);
***************
*** 6213,6217 ****
if( !isVersionedInSVN( m_svnUrl, /*isDir = */true))
{
! AfxMessageBox( (std::string( "Location directory '") + m_svnUrl + "' does not exists yet in SVN ").c_str());
HR_THROW(E_FILEOPEN);
}
--- 6271,6276 ----
if( !isVersionedInSVN( m_svnUrl, /*isDir = */true))
{
! sendMsg( "Exception: Location directory '" + m_svnUrl + "' does not exist on the SVN server!", MSG_ERROR);
! AfxMessageBox( (std::string( "Location directory '") + m_svnUrl + "' does not exist on the SVN server").c_str());
HR_THROW(E_FILEOPEN);
}
***************
*** 6220,6223 ****
--- 6279,6283 ----
if( isVersionedInSVN( m_svnUrl + "/" + m_projectName, /*isDir = */true, /* suppressErrorMsg = */true))
{
+ sendMsg( "Exception: Project '" + m_projectName + "' already found at '" + m_svnUrl + "'. Project creation aborted.", MSG_ERROR);
AfxMessageBox( (std::string( "Project '") + m_projectName + "' already found at '" + m_svnUrl + "'. Project creation aborted.").c_str());
HR_THROW(E_FILEOPEN);
***************
*** 6227,6232 ****
if( !main_created)
{
! std::string m = "Could not create on server directory: " + m_svnUrl + "/" + m_projectName;
! AfxMessageBox( m.c_str());
HR_THROW(E_FILEOPEN);
}
--- 6287,6292 ----
if( !main_created)
{
! sendMsg( "Exception: Could not create on server directory: " + m_svnUrl + "/" + m_projectName, MSG_ERROR);
! AfxMessageBox( (std::string( "Could not create on server directory: ") + m_svnUrl + "/" + m_projectName).c_str());
HR_THROW(E_FILEOPEN);
}
***************
*** 6239,6242 ****
--- 6299,6303 ----
int succ = createHashedFolders();
if( !succ) {
+ sendMsg( "Exception: Could not create initial directory structure.", MSG_ERROR);
AfxMessageBox( "Could not create initial directory structure.");
HR_THROW(E_FILEOPEN);
***************
*** 6246,6249 ****
--- 6307,6311 ----
succ = addSVN( m_contentPath, true /*=recursive*/);
if( !succ) {
+ sendMsg( "Exception: Could not add initial directory structure to server.", MSG_ERROR);
AfxMessageBox( "Could not add initial directory structure to server.");
HR_THROW(E_FILEOPEN);
***************
*** 6253,6256 ****
--- 6315,6319 ----
succ = commitSVN( m_contentPath, true);
if( !succ) {
+ sendMsg( "Exception: Could not commit initial directory structure.", MSG_ERROR);
AfxMessageBox( "Could not commit initial directory structure.");
HR_THROW(E_FILEOPEN);
Index: CoreXmlFile.h
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/XmlBackEnd/CoreXmlFile.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** CoreXmlFile.h 20 Feb 2008 19:10:16 -0000 1.15
--- CoreXmlFile.h 20 Feb 2008 22:08:52 -0000 1.16
***************
*** 667,671 ****
void rollBackTheCheckOutContainer( XmlObject * obj);
- void addToSS ( const std::string& p_path);
void addToSourceControl (XmlObject * container, bool p_fileExisted);
--- 667,670 ----
- Previous message: [GME-commit] GMESRC/GME/Gme GMEApp.cpp,1.149,1.150
- Next message: [GME-commit] GMESRC/GME/XmlBackEnd DOMErrorPrinter.cpp, NONE, 1.1 DOMErrorPrinter.h, NONE, 1.1 CoreXmlFile.cpp, 1.32, 1.33 CoreXmlFile.h, 1.16, 1.17 OperOptions.cpp, 1.3, 1.4 OperOptions.h, 1.2, 1.3 XmlBackEnd.vcproj, 1.9, 1.10
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the GME-commit
mailing list