From: prascle Date: Mon, 24 Jan 2005 06:26:52 +0000 (+0000) Subject: PR: debug for save study, filters not known components (Interface Applicative) X-Git-Tag: V2_2_0a2~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bdfedda34da6a6b254d16373a7d4d1a7861d896c;p=modules%2Fkernel.git PR: debug for save study, filters not known components (Interface Applicative) --- diff --git a/src/Container/SALOME_ContainerManager.cxx b/src/Container/SALOME_ContainerManager.cxx index 14e377405..d5fad0ae9 100644 --- a/src/Container/SALOME_ContainerManager.cxx +++ b/src/Container/SALOME_ContainerManager.cxx @@ -9,7 +9,7 @@ using namespace std; -const char *SALOME_ContainerManager::_ContainerManagerNameInNS="ContainerManager"; +const char *SALOME_ContainerManager::_ContainerManagerNameInNS="/ContainerManager"; SALOME_ContainerManager::SALOME_ContainerManager(CORBA::ORB_ptr orb) { @@ -41,6 +41,7 @@ void SALOME_ContainerManager::ShutdownContainers() vector vec=_NS->list_directory_recurs(); for(vector::iterator iter=vec.begin();iter!=vec.end();iter++) { + SCRUTE((*iter)); CORBA::Object_var obj=_NS->Resolve((*iter).c_str()); Engines::Container_var cont=Engines::Container::_narrow(obj); if(!CORBA::is_nil(cont)) @@ -79,6 +80,7 @@ Engines::Container_ptr SALOME_ContainerManager::FindOrStartContainer(const char if ( count != 10 ) MESSAGE( count << ". Waiting for FactoryServer on " << theMachine); string containerNameInNS=BuildContainerNameInNS(containerName,theMachine.c_str()); + SCRUTE(containerNameInNS); CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str()); ret=Engines::Container::_narrow(obj); } @@ -110,6 +112,7 @@ char* SALOME_ContainerManager::FindBest(const Engines::MachineList& possibleComp Engines::Container_ptr SALOME_ContainerManager::FindContainer(const char *containerName,const char *theMachine) { string containerNameInNS(BuildContainerNameInNS(containerName,theMachine)); + SCRUTE(containerNameInNS); CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str()); if( !CORBA::is_nil(obj) ) return Engines::Container::_narrow(obj); diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx index cbc8b24ec..d846594ab 100644 --- a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx @@ -48,6 +48,7 @@ SALOME_LifeCycleCORBA::SALOME_LifeCycleCORBA(SALOME_NamingService *ns) _NS = ns; //add try catch CORBA::Object_var obj=_NS->Resolve(SALOME_ContainerManager::_ContainerManagerNameInNS); + ASSERT( !CORBA::is_nil(obj)); _ContManager=Engines::ContainerManager::_narrow(obj); } @@ -88,6 +89,34 @@ string SALOME_LifeCycleCORBA::ContainerName( return theComputerContainer ; } +bool SALOME_LifeCycleCORBA::isKnownComponentClass(const char *componentName) +{ + + try + { + CORBA::Object_var obj = _NS->Resolve("/Kernel/ModulCatalog"); + SALOME_ModuleCatalog::ModuleCatalog_var Catalog = + SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj) ; + SALOME_ModuleCatalog::Acomponent_ptr compoInfo = + Catalog->GetComponent(componentName); + if (CORBA::is_nil (compoInfo)) + { + INFOS("Catalog Error : Component not found in the catalog"); + return false; + } + else return true; + } + catch (ServiceUnreachable&) + { + INFOS("Caught exception: Naming Service Unreachable"); + } + catch (...) + { + INFOS("Caught unknown exception."); + } + return false; +} + string SALOME_LifeCycleCORBA::ComputerPath( const char * theComputer ) { CORBA::String_var path; @@ -109,6 +138,7 @@ Engines::Component_ptr SALOME_LifeCycleCORBA::FindOrLoad_Component (const char *containerName, const char *componentName) { + if (! isKnownComponentClass(componentName)) return Engines::Component::_nil(); char *stContainer=strdup(containerName); string st2Container(stContainer); int rg=st2Container.find("/"); @@ -139,6 +169,7 @@ Engines::Component_ptr SALOME_LifeCycleCORBA::FindOrLoad_Component Engines::Component_ptr SALOME_LifeCycleCORBA::FindOrLoad_Component(const Engines::MachineParameters& params, const char *componentName) { + if (! isKnownComponentClass(componentName)) return Engines::Component::_nil(); Engines::MachineList_var listOfMachine=_ContManager->GetFittingResources(params,componentName); Engines::Component_ptr ret=FindComponent(params.container_name,componentName,listOfMachine); if(CORBA::is_nil(ret)) @@ -151,6 +182,7 @@ Engines::Component_ptr SALOME_LifeCycleCORBA::FindComponent(const char *containe const char *componentName, const Engines::MachineList& listOfMachines) { + if (! isKnownComponentClass(componentName)) return Engines::Component::_nil(); if(containerName[0]!='\0') { Engines::MachineList_var machinesOK=new Engines::MachineList; diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx index ed5c78c25..249d4c0aa 100644 --- a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx @@ -48,6 +48,7 @@ public: const char *componentName); Engines::Component_ptr FindOrLoad_Component(const char *containerName, const char *componentName); + bool isKnownComponentClass(const char *componentName); protected: //! Establish if a component called "componentName" in a container called "containerName" exists among the list of resources //! in "listOfMachines". This method uses Naming Service to find the component.