Commit c8f67d48 authored by Pavel Vainerman's avatar Pavel Vainerman

(ORep): добавил некоторые проверки

parent 943e9dc2
...@@ -150,6 +150,12 @@ namespace ORepHelpers ...@@ -150,6 +150,12 @@ namespace ORepHelpers
CORBA::Object_var initServ = orb->resolve_initial_references(nsName.c_str()); CORBA::Object_var initServ = orb->resolve_initial_references(nsName.c_str());
ulogrep << "OREPHELP: get rootcontext...(nsName = "<< nsName << ")" <<endl; ulogrep << "OREPHELP: get rootcontext...(nsName = "<< nsName << ")" <<endl;
if (CORBA::is_nil(initServ))
{
string err("ORepHelpers: fail resolve_initial_references '" + nsName + "'");
throw ORepFailed(err.c_str());
}
rootContext = CosNaming::NamingContext::_narrow(initServ); rootContext = CosNaming::NamingContext::_narrow(initServ);
if (CORBA::is_nil(rootContext)) if (CORBA::is_nil(rootContext))
{ {
......
...@@ -83,7 +83,7 @@ bool ObjectRepository::init() const ...@@ -83,7 +83,7 @@ bool ObjectRepository::init() const
* \param oRef - ссылка на объект * \param oRef - ссылка на объект
* \param section - имя секции в которую заносится регистрационная запись * \param section - имя секции в которую заносится регистрационная запись
* \exception ORepFailed - генерируется если произошла ошибка при регистрации * \exception ORepFailed - генерируется если произошла ошибка при регистрации
* \sa registration(const string fullName, const CORBA::Object_ptr oRef) * \sa registration(const std::string& fullName, const CORBA::Object_ptr oRef)
*/ */
void ObjectRepository::registration(const string& name, const ObjectPtr oRef, const string& section, bool force) const void ObjectRepository::registration(const string& name, const ObjectPtr oRef, const string& section, bool force) const
throw(ORepFailed, ObjectNameAlready, InvalidObjectName, NameNotFound) throw(ORepFailed, ObjectNameAlready, InvalidObjectName, NameNotFound)
...@@ -92,18 +92,29 @@ void ObjectRepository::registration(const string& name, const ObjectPtr oRef, co ...@@ -92,18 +92,29 @@ void ObjectRepository::registration(const string& name, const ObjectPtr oRef, co
uinfo << "ObjectRepository(registration): регистрируем " << name << endl; uinfo << "ObjectRepository(registration): регистрируем " << name << endl;
if( CORBA::is_nil(oRef) )
{
err << "ObjectRepository(registrartion): oRef=nil! for '" << name << "'";
throw ORepFailed(err.str());
}
if( name.empty() )
{
err << "ObjectRepository(registration): (InvalidObjectName): empty name?!";
throw ( InvalidObjectName(err.str()) );
}
// Проверка корректности имени // Проверка корректности имени
char bad = ORepHelpers::checkBadSymbols(name); char bad = ORepHelpers::checkBadSymbols(name);
if( bad != 0 ) if( bad != 0 )
{ {
cerr << "orep reg: BAD Symbols" << endl;
err << "ObjectRepository(registration): (InvalidObjectName) " << name; err << "ObjectRepository(registration): (InvalidObjectName) " << name;
err << " содержит недопустимый символ " << bad; err << " содержит недопустимый символ " << bad;
throw ( InvalidObjectName(err.str().c_str()) ); throw ( InvalidObjectName(err.str()) );
} }
CosNaming::Name_var oName = omniURI::stringToName(name.c_str()); CosNaming::Name_var oName = omniURI::stringToName(name.c_str());
CosNaming::NamingContext_var ctx; CosNaming::NamingContext_var ctx = CosNaming::NamingContext::_nil();
for( unsigned int i=0; i<2; i++ ) for( unsigned int i=0; i<2; i++ )
{ {
try try
...@@ -123,13 +134,14 @@ void ObjectRepository::registration(const string& name, const ObjectPtr oRef, co ...@@ -123,13 +134,14 @@ void ObjectRepository::registration(const string& name, const ObjectPtr oRef, co
throw ObjectNameAlready(); throw ObjectNameAlready();
// разрегистриуем, перед повтроной попыткой // разрегистриуем, перед повтроной попыткой
ctx->unbind(oName); if( !CORBA::is_nil(ctx) )
ctx->unbind(oName);
continue; continue;
} }
catch(ORepFailed) catch(ORepFailed)
{ {
string er("ObjectRepository(registrartion): (getContext) не смог зарегистрировать "+name); string er("ObjectRepository(registrartion): (getContext) не смог зарегистрировать "+name);
throw ORepFailed(er.c_str()); throw ORepFailed(er);
} }
catch(CosNaming::NamingContext::NotFound) catch(CosNaming::NamingContext::NotFound)
{ {
...@@ -153,7 +165,10 @@ void ObjectRepository::registration(const string& name, const ObjectPtr oRef, co ...@@ -153,7 +165,10 @@ void ObjectRepository::registration(const string& name, const ObjectPtr oRef, co
} }
} }
throw ORepFailed(err.str().c_str()); if( err.str().empty() )
err << "(ObjectRepository(registrartion): unknown error..";
throw ORepFailed(err.str());
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
...@@ -171,7 +186,7 @@ void ObjectRepository::registration( const std::string& fullName, const UniSetTy ...@@ -171,7 +186,7 @@ void ObjectRepository::registration( const std::string& fullName, const UniSetTy
{ {
// string n(ORepHelpers::getShortName(fullName)); // string n(ORepHelpers::getShortName(fullName));
string n( uconf->oind->getBaseName(fullName) ); string n( uconf->oind->getBaseName(fullName) );
string s(ORepHelpers::getSectionName(fullName.c_str())); string s(ORepHelpers::getSectionName(fullName));
registration(n, oRef, s,force); registration(n, oRef, s,force);
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
...@@ -215,7 +230,8 @@ void ObjectRepository::unregistration(const string& name, const string& section) ...@@ -215,7 +230,8 @@ void ObjectRepository::unregistration(const string& name, const string& section)
if (err.str().empty()) if (err.str().empty())
err << "ObjectRepository(unregistrartion): не смог удалить " << name; err << "ObjectRepository(unregistrartion): не смог удалить " << name;
throw ORepFailed(err.str().c_str());
throw ORepFailed(err.str().c_str());
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/*! /*!
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment