diff options
author | William R. Otte <wotte@dre.vanderbilt.edu> | 2009-02-18 00:53:53 +0000 |
---|---|---|
committer | William R. Otte <wotte@dre.vanderbilt.edu> | 2009-02-18 00:53:53 +0000 |
commit | dda870c757a4fa96d05d1c9e69f167a99f8ff59b (patch) | |
tree | 6363aadd4e118ed39dab828f8cdedb52769668ce | |
parent | 31f2cbbed3c94d5173fe2347f907e86edeb3ff6b (diff) | |
download | ATCD-dda870c757a4fa96d05d1c9e69f167a99f8ff59b.tar.gz |
ChangeLogTag: Wed Feb 18 00:52:18 UTC 2009 William R. Otte <wotte@dre.vanderbilt.edu>
-rw-r--r-- | CIAO/ChangeLog | 19 | ||||
-rw-r--r-- | CIAO/DAnCE/Deployment/Deployment_RepositoryManager.idl | 56 | ||||
-rw-r--r-- | CIAO/DAnCE/RepositoryManager/DAnCE_RepositoryManager_Module_Export.h | 58 | ||||
-rw-r--r-- | CIAO/DAnCE/RepositoryManager/RMadmin.cpp | 3 | ||||
-rw-r--r-- | CIAO/DAnCE/RepositoryManager/RepositoryManager.mpc | 26 | ||||
-rw-r--r-- | CIAO/DAnCE/RepositoryManager/RepositoryManager_Impl.cpp | 1820 | ||||
-rw-r--r-- | CIAO/DAnCE/RepositoryManager/RepositoryManager_Impl.h | 316 | ||||
-rw-r--r-- | CIAO/DAnCE/RepositoryManager/Repository_Manager_Exec.cpp | 6 | ||||
-rw-r--r-- | CIAO/DAnCE/RepositoryManager/Repository_Manager_Module.cpp | 519 | ||||
-rw-r--r-- | CIAO/DAnCE/RepositoryManager/Repository_Manager_Module.h | 128 | ||||
-rw-r--r-- | CIAO/DAnCE/RepositoryManager/ZIP_Wrapper.cpp | 2 | ||||
-rw-r--r-- | CIAO/DAnCE/RepositoryManager/ZIP_Wrapper.h | 2 | ||||
-rw-r--r-- | CIAO/MPC/config/dance_repository_manager.mpb | 4 | ||||
-rw-r--r-- | CIAO/MPC/config/dance_repository_manager_base.mpb | 5 |
14 files changed, 1841 insertions, 1123 deletions
diff --git a/CIAO/ChangeLog b/CIAO/ChangeLog index 3d550d414ce..82ade27ba6f 100644 --- a/CIAO/ChangeLog +++ b/CIAO/ChangeLog @@ -1,3 +1,22 @@ +Wed Feb 18 00:52:18 UTC 2009 William R. Otte <wotte@dre.vanderbilt.edu> + + * DAnCE/Deployment/Deployment_RepositoryManager.idl: + * DAnCE/RepositoryManager/DAnCE_RepositoryManager_Module_Export.h: + * DAnCE/RepositoryManager/RMadmin.cpp: + * DAnCE/RepositoryManager/RepositoryManager.mpc: + * DAnCE/RepositoryManager/RepositoryManager_Impl.h: + * DAnCE/RepositoryManager/RepositoryManager_Impl.cpp: + * DAnCE/RepositoryManager/Repository_Manager_Exec.cpp: + * DAnCE/RepositoryManager/Repository_Manager_Module.h: + * DAnCE/RepositoryManager/Repository_Manager_Module.cpp: + * DAnCE/RepositoryManager/ZIP_Wrapper.h: + * DAnCE/RepositoryManager/ZIP_Wrapper.cpp: + * MPC/config/dance_repository_manager.mpb: + * MPC/config/dance_repository_manager_base.mpb: + + Initial porting work. Still untested, so it will remain + disabled for the time being using dummy_label. + Mon Feb 16 12:53:37 UTC 2009 Marcel Smit <msmit@remedy.nl> * CIAO-INSTALL.html: diff --git a/CIAO/DAnCE/Deployment/Deployment_RepositoryManager.idl b/CIAO/DAnCE/Deployment/Deployment_RepositoryManager.idl index c0484094017..5000b487590 100644 --- a/CIAO/DAnCE/Deployment/Deployment_RepositoryManager.idl +++ b/CIAO/DAnCE/Deployment/Deployment_RepositoryManager.idl @@ -7,41 +7,41 @@ module Deployment { - exception NameExists { - }; + exception NameExists { + }; - exception PackageError { - string source; - string reason; - }; + exception PackageError { + string source; + string reason; + }; - interface RepositoryManager { - void installPackage ( in string installationName, - in string location, - in boolean replace) - raises (NameExists, PackageError); + interface RepositoryManager { + void installPackage (in string installationName, + in string location, + in boolean replace) + raises (NameExists, PackageError); - void createPackage (in string installationName, - in PackageConfiguration package, - in string baseLocation, - in boolean replace) - raises (NameExists, PackageError); + void createPackage (in string installationName, + in PackageConfiguration package, + in string baseLocation, + in boolean replace) + raises (NameExists, PackageError); - PackageConfiguration findPackageByName (in string name) - raises (NoSuchName); - - PackageConfiguration findPackageByUUID (in string UUID) - raises (NoSuchName); - - ::CORBA::StringSeq findNamesByType (in string type); + PackageConfiguration findPackageByName (in string name) + raises (NoSuchName); + + PackageConfiguration findPackageByUUID (in string UUID) + raises (NoSuchName); + + ::CORBA::StringSeq findNamesByType (in string type); - ::CORBA::StringSeq getAllNames (); + ::CORBA::StringSeq getAllNames (); - ::CORBA::StringSeq getAllTypes (); + ::CORBA::StringSeq getAllTypes (); - void deletePackage (in string installationName) - raises (NoSuchName); - }; + void deletePackage (in string installationName) + raises (NoSuchName); + }; }; #endif /* REPOSITOR_MANAGER_IDL */ diff --git a/CIAO/DAnCE/RepositoryManager/DAnCE_RepositoryManager_Module_Export.h b/CIAO/DAnCE/RepositoryManager/DAnCE_RepositoryManager_Module_Export.h new file mode 100644 index 00000000000..b94621bd39b --- /dev/null +++ b/CIAO/DAnCE/RepositoryManager/DAnCE_RepositoryManager_Module_Export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl DAnCE_RepositoryManager_Module +// ------------------------------ +#ifndef DANCE_REPOSITORYMANAGER_MODULE_EXPORT_H +#define DANCE_REPOSITORYMANAGER_MODULE_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (DANCE_REPOSITORYMANAGER_MODULE_HAS_DLL) +# define DANCE_REPOSITORYMANAGER_MODULE_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && DANCE_REPOSITORYMANAGER_MODULE_HAS_DLL */ + +#if !defined (DANCE_REPOSITORYMANAGER_MODULE_HAS_DLL) +# define DANCE_REPOSITORYMANAGER_MODULE_HAS_DLL 1 +#endif /* ! DANCE_REPOSITORYMANAGER_MODULE_HAS_DLL */ + +#if defined (DANCE_REPOSITORYMANAGER_MODULE_HAS_DLL) && (DANCE_REPOSITORYMANAGER_MODULE_HAS_DLL == 1) +# if defined (DANCE_REPOSITORYMANAGER_MODULE_BUILD_DLL) +# define DAnCE_RepositoryManager_Module_Export ACE_Proper_Export_Flag +# define DANCE_REPOSITORYMANAGER_MODULE_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define DANCE_REPOSITORYMANAGER_MODULE_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* DANCE_REPOSITORYMANAGER_MODULE_BUILD_DLL */ +# define DAnCE_RepositoryManager_Module_Export ACE_Proper_Import_Flag +# define DANCE_REPOSITORYMANAGER_MODULE_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define DANCE_REPOSITORYMANAGER_MODULE_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* DANCE_REPOSITORYMANAGER_MODULE_BUILD_DLL */ +#else /* DANCE_REPOSITORYMANAGER_MODULE_HAS_DLL == 1 */ +# define DAnCE_RepositoryManager_Module_Export +# define DANCE_REPOSITORYMANAGER_MODULE_SINGLETON_DECLARATION(T) +# define DANCE_REPOSITORYMANAGER_MODULE_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* DANCE_REPOSITORYMANAGER_MODULE_HAS_DLL == 1 */ + +// Set DANCE_REPOSITORYMANAGER_MODULE_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (DANCE_REPOSITORYMANAGER_MODULE_NTRACE) +# if (ACE_NTRACE == 1) +# define DANCE_REPOSITORYMANAGER_MODULE_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define DANCE_REPOSITORYMANAGER_MODULE_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !DANCE_REPOSITORYMANAGER_MODULE_NTRACE */ + +#if (DANCE_REPOSITORYMANAGER_MODULE_NTRACE == 1) +# define DANCE_REPOSITORYMANAGER_MODULE_TRACE(X) +#else /* (DANCE_REPOSITORYMANAGER_MODULE_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define DANCE_REPOSITORYMANAGER_MODULE_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (DANCE_REPOSITORYMANAGER_MODULE_NTRACE == 1) */ + +#endif /* DANCE_REPOSITORYMANAGER_MODULE_EXPORT_H */ + +// End of auto generated file. diff --git a/CIAO/DAnCE/RepositoryManager/RMadmin.cpp b/CIAO/DAnCE/RepositoryManager/RMadmin.cpp index 91e01a8cb9d..8f5ed3924d9 100644 --- a/CIAO/DAnCE/RepositoryManager/RMadmin.cpp +++ b/CIAO/DAnCE/RepositoryManager/RMadmin.cpp @@ -19,13 +19,12 @@ #include "ace/OS_NS_sys_stat.h" //for filesize and fstat and mkdir #include "ace/streams.h" -#include "Config_Handlers/DnC_Dump.h" #include "RM_Helper.h" //to be able to externalize/internalize a PackageConfiguration #include "tao/CDR.h" //for TAO CDR classes #include "ace/Message_Block.h" //for ACE_Message_Block -#include "Package_Handlers/PCD_Handler.h" +#include "Config_Handlers/Package_Handlers/PCD_Handler.h" #include "orbsvcs/CosNamingC.h" diff --git a/CIAO/DAnCE/RepositoryManager/RepositoryManager.mpc b/CIAO/DAnCE/RepositoryManager/RepositoryManager.mpc index ed13535d7ad..b4fcfb5f116 100644 --- a/CIAO/DAnCE/RepositoryManager/RepositoryManager.mpc +++ b/CIAO/DAnCE/RepositoryManager/RepositoryManager.mpc @@ -1,16 +1,10 @@ // -*- MPC -*- // $Id$ -//RepositoryManager project: implementation of a repository manager -//compleint with the D&C spec - -project (RepositoryManager) : ccm_stub { //ciao_server_dnc, ciao_config_handlers, zlib, ciaoexe { +project (DAnCE_RepositoryManager) : dance_deployment_svnt, ciao_config_handlers, ccm_stub, dance_repository_manager_base, naming, iortable, utils { requires += dummy_label - includes += $(CIAO_ROOT)/tools/Config_Handlers $(ACE_ROOT)/contrib/minizip - //to circumvent an improper include resolution - //in the Package_Handlers/PC_Intf.h - exename = RepositoryManagerDaemon - requires += zlib + includes += $(ACE_ROOT)/contrib + requires += zlib dummy_label after += minizip libs += Package_Config_Handlers minizip @@ -22,23 +16,29 @@ project (RepositoryManager) : ccm_stub { //ciao_server_dnc, ciao_config_handlers RepositoryManagerDaemonC.cpp RepositoryManagerDaemonS.cpp ZIP_Wrapper.cpp - RepositoryManager.cpp RepositoryManager_Impl.cpp RM_Helper.cpp URL_Parser.cpp PC_Updater_T.cpp PC_Updater.cpp + Repository_Manager_Module.cpp } - } +project (DAnCE_RepositoryManager_Exec) : dance_repository_manager, dance_exe { + exename = dance_repository_manager + requires += dummy_label + Source_Files { + Repository_Manager_Exec.cpp + } +} // RMadmin project: a sample client for the RM. -project (RMAdmin) : ccm_stub { //ciao_servant_dnc, ciao_config_handlers, ciaoexe { +project (RMAdmin) : dance_deployment_stub, ciao_config_handlers, naming { requires += dummy_label - exename = RMadmin + exename = dance_rm_admin after += RepositoryManager IDL_Files { diff --git a/CIAO/DAnCE/RepositoryManager/RepositoryManager_Impl.cpp b/CIAO/DAnCE/RepositoryManager/RepositoryManager_Impl.cpp index e09701a184f..10a47e9886c 100644 --- a/CIAO/DAnCE/RepositoryManager/RepositoryManager_Impl.cpp +++ b/CIAO/DAnCE/RepositoryManager/RepositoryManager_Impl.cpp @@ -58,827 +58,820 @@ namespace static const char *RM_RECORD_UUID_SECTION = "UUIDs"; } -//----------------------------------------------------------------- -//Constructor -// -//----------------------------------------------------------------- +namespace DAnCE +{ + + //----------------------------------------------------------------- + //Constructor + // + //----------------------------------------------------------------- -CIAO_RepositoryManagerDaemon_i::CIAO_RepositoryManagerDaemon_i + RepositoryManagerDaemon_i::RepositoryManagerDaemon_i (CORBA::ORB_ptr the_orb, const char* server, const char* install_dir) - : the_orb_ (CORBA::ORB::_duplicate (the_orb)), - install_root_ (""), - HTTP_server_ ("http://"), - install_path (install_dir) -{ - //form the path - this->HTTP_server_ += server; - this->HTTP_server_ += "/"; - this->HTTP_server_ += install_path; - this->HTTP_server_ += "/"; - - //create directory in which the packages will be stored - ACE_OS::mkdir(install_path.c_str ()); - //if dir already exists a -1 is returned - //we ignore this, just need to make sure the directory exists - - ACE_OS::getcwd (this->cwd_, TEMP_LEN); - - this->install_root_ = this->cwd_; - this->install_root_ += "/"; - this->install_root_ += install_path; - - // Install the configuration files to get the names, UUIDs, & types info. - ACE_Configuration_Heap cfg; - cfg.open (); - ACE_Configuration_Section_Key root = cfg.root_section (); - - ACE_Registry_ImpExp config_importer (cfg); - ACE_OS::chdir (install_path.c_str ()); - config_importer.import_config (RM_RECORD_FILE); - ACE_OS::chdir (this->cwd_); - - ACE_CString name; - ACE_Configuration::VALUETYPE type; - ACE_CString path; - - ACE_Configuration_Section_Key NameSection; - cfg.open_section (root, RM_RECORD_NAME_SECTION, 1, NameSection); - u_int index = 0; - while (!cfg.enumerate_values (NameSection, index, name, type)) + : the_orb_ (CORBA::ORB::_duplicate (the_orb)), + install_root_ (""), + HTTP_server_ ("http://"), + install_path (install_dir) { - cfg.get_string_value (NameSection, name.c_str (), path); - this->names_.bind (name, path); + //form the path + this->HTTP_server_ += server; + this->HTTP_server_ += "/"; + this->HTTP_server_ += install_path; + this->HTTP_server_ += "/"; + + //create directory in which the packages will be stored + ACE_OS::mkdir(install_path.c_str ()); + //if dir already exists a -1 is returned + //we ignore this, just need to make sure the directory exists + + ACE_OS::getcwd (this->cwd_, TEMP_LEN); + + this->install_root_ = this->cwd_; + this->install_root_ += "/"; + this->install_root_ += install_path; + + // Install the configuration files to get the names, UUIDs, & types info. + ACE_Configuration_Heap cfg; + cfg.open (); + ACE_Configuration_Section_Key root = cfg.root_section (); + + ACE_Registry_ImpExp config_importer (cfg); + ACE_OS::chdir (install_path.c_str ()); + config_importer.import_config (RM_RECORD_FILE); + ACE_OS::chdir (this->cwd_); + + ACE_CString name; + ACE_Configuration::VALUETYPE type; + ACE_CString path; + + ACE_Configuration_Section_Key NameSection; + cfg.open_section (root, RM_RECORD_NAME_SECTION, 1, NameSection); + u_int index = 0; + while (!cfg.enumerate_values (NameSection, index, name, type)) + { + cfg.get_string_value (NameSection, name.c_str (), path); + this->names_.bind (name, path); - ++index; - } + ++index; + } - ACE_Configuration_Section_Key UUIDSection; - cfg.open_section (root, RM_RECORD_UUID_SECTION, 1, UUIDSection); - index = 0; - while (!cfg.enumerate_values (UUIDSection, index, name, type)) - { - cfg.get_string_value (UUIDSection, name.c_str (), path); - this->uuids_.bind (name, path); + ACE_Configuration_Section_Key UUIDSection; + cfg.open_section (root, RM_RECORD_UUID_SECTION, 1, UUIDSection); + index = 0; + while (!cfg.enumerate_values (UUIDSection, index, name, type)) + { + cfg.get_string_value (UUIDSection, name.c_str (), path); + this->uuids_.bind (name, path); - ++index; - } + ++index; + } - // Add types - index = 0; - for (PCMap_Iterator iter = this->names_.begin (); - iter != this->names_.end (); - ++iter, ++index) - { - PCEntry& element = *iter; + // Add types + index = 0; + for (PCMap_Iterator iter = this->names_.begin (); + iter != this->names_.end (); + ++iter, ++index) + { + PCEntry& element = *iter; - ::Deployment::PackageConfiguration_var pc = this->findPackageByName (element.ext_id_.c_str ()); + ::Deployment::PackageConfiguration_var pc = this->findPackageByName (element.ext_id_.c_str ()); - if(!this->add_type (pc, element.ext_id_.c_str ())) - ACE_ERROR ((LM_ERROR, "Failed to add the type\n")); + if(!this->add_type (pc, element.ext_id_.c_str ())) + ACE_ERROR ((LM_ERROR, "Failed to add the type\n")); + } } -} -//----------------------------------------------------------------- -//Destructor -// -//----------------------------------------------------------------- + //----------------------------------------------------------------- + //Destructor + // + //----------------------------------------------------------------- -CIAO_RepositoryManagerDaemon_i::~CIAO_RepositoryManagerDaemon_i (void) -{ - this->names_.unbind_all (); - this->uuids_.unbind_all (); - this->types_.unbind_all (); -} - -//----------------------------------------------------------------- -//shutdown -// -//----------------------------------------------------------------- + RepositoryManagerDaemon_i::~RepositoryManagerDaemon_i (void) + { + this->names_.unbind_all (); + this->uuids_.unbind_all (); + this->types_.unbind_all (); + } -void CIAO_RepositoryManagerDaemon_i::shutdown () + //----------------------------------------------------------------- + //shutdown + // + //----------------------------------------------------------------- -{ - // Release resource. - this->names_.unbind_all (); - this->uuids_.unbind_all (); - this->types_.unbind_all (); + void RepositoryManagerDaemon_i::shutdown () - this->the_orb_->shutdown (0); -} + { + // Release resource. + this->names_.unbind_all (); + this->uuids_.unbind_all (); + this->types_.unbind_all (); + this->the_orb_->shutdown (0); + } -//----------------------------------------------------------------- -//installPackage -// -//----------------------------------------------------------------- -void CIAO_RepositoryManagerDaemon_i::installPackage ( - const char * installationName, - const char * location, - ::CORBA::Boolean replace - ) -{ + //----------------------------------------------------------------- + //installPackage + // + //----------------------------------------------------------------- - PCEntry *entry = 0; - if (this->names_.find (ACE_CString (installationName), entry) == 0) - { - if (!replace) - throw Deployment::NameExists (); - else - deletePackage (installationName); - } + void RepositoryManagerDaemon_i::installPackage (const char * installationName, + const char * location, + ::CORBA::Boolean replace) + { - //Now lets form the path for the local file - //NOTE: I need the absolute path because I will change to a subdirectory - //when I am parsing the descriptors + PCEntry *entry = 0; + if (this->names_.find (ACE_CString (installationName), entry) == 0) + { + if (!replace) + throw Deployment::NameExists (); + else + deletePackage (installationName); + } - ACE_CString path (this->install_root_); - path += "/"; - path += installationName; + //Now lets form the path for the local file + //NOTE: I need the absolute path because I will change to a subdirectory + //when I am parsing the descriptors - ACE_CString package_path (path); - package_path += ".cpk"; //package extension + ACE_CString path (this->install_root_); + path += "/"; + path += installationName; - ACE_CString pc_path (path); - pc_path += PC_EXTENSION; //external PackageConfiguration extension + ACE_CString package_path (path); + package_path += ".cpk"; //package extension + ACE_CString pc_path (path); + pc_path += PC_EXTENSION; //external PackageConfiguration extension - ACE_CString descriptor_dir (path); - descriptor_dir += "/descriptors/"; //location of the descriptor directory + ACE_CString descriptor_dir (path); + descriptor_dir += "/descriptors/"; //location of the descriptor directory - //check if URL or local file - //download or load into memory - if (ACE_OS::strstr (location, "http://")) - { + //check if URL or local file + //download or load into memory - //TODO: how can I incorporate a Auto_Ptr is explicit release is needed - ACE_Message_Block* mb = 0; - ACE_NEW_THROW_EX (mb, ACE_Message_Block (), CORBA::NO_MEMORY ()); + if (ACE_OS::strstr (location, "http://")) + { - //get the remote file - if (!HTTP_Get (location, *mb)) - { - mb->release (); + //TODO: how can I incorporate a Auto_Ptr is explicit release is needed + ACE_Message_Block* mb = 0; + ACE_NEW_THROW_EX (mb, ACE_Message_Block (), CORBA::NO_MEMORY ()); + + //get the remote file + if (!HTTP_Get (location, *mb)) + { + mb->release (); + throw CORBA::INTERNAL (); + } + + // Write file to designated location on disk + if (!RM_Helper::write_to_disk (package_path.c_str (), *mb)) + { + mb->release (); + throw CORBA::INTERNAL (); + } + + mb->release (); + } + else + { + if (!RM_Helper::copy_from_disk_to_disk (location, package_path.c_str ())) throw CORBA::INTERNAL (); - } + } - // Write file to designated location on disk - if (!RM_Helper::write_to_disk (package_path.c_str (), *mb)) - { - mb->release (); - throw CORBA::INTERNAL (); - } - mb->release (); - } - else - { - if (!RM_Helper::copy_from_disk_to_disk (location, package_path.c_str ())) - throw CORBA::INTERNAL (); - } + ZIP_Wrapper::uncompress (const_cast<char*> (package_path.c_str ()), + const_cast<char*> (this->install_root_.c_str ()), + false //not verbose + ); + //Start the parsing - ZIP_Wrapper::uncompress (const_cast<char*> (package_path.c_str ()), - const_cast<char*> (this->install_root_.c_str ()), - false //not verbose - ); + ACE_CString pc_name; - //Start the parsing + this->find_PC_name (const_cast<char*> (package_path.c_str ()), pc_name); - ACE_CString pc_name; + //if the PackageConfiguration name cannot be found, then there is nothing to install + if (pc_name == "") + { + //clean the extracted files + remove_extracted_package (path.c_str ()); + //remove the package + remove (package_path.c_str ()); - this->find_PC_name (const_cast<char*> (package_path.c_str ()), pc_name); + throw Deployment::PackageError (); + } - //if the PackageConfiguration name cannot be found, then there is nothing to install - if (pc_name == "") - { - //clean the extracted files - remove_extracted_package (path.c_str ()); - //remove the package - remove (package_path.c_str ()); + //TODO: move exception throwing out of this func. User boolean error handling!!! + //TODO: check for errors! + Deployment::PackageConfiguration_var pc; + pc = this->retrieve_PC_from_descriptors (const_cast<char*> (pc_name.c_str ()), + descriptor_dir.c_str ()); - throw Deployment::PackageError (); - } - //TODO: move exception throwing out of this func. User boolean error handling!!! - //TODO: check for errors! - Deployment::PackageConfiguration_var pc; - pc = this->retrieve_PC_from_descriptors (const_cast<char*> (pc_name.c_str ()), - descriptor_dir.c_str ()); + if (this->uuids_.find (ACE_CString (pc->UUID), entry) == 0) + { + //clean the extracted files + remove_extracted_package (path.c_str ()); + //remove the package + remove (package_path.c_str ()); + throw Deployment::NameExists (); + } - if (this->uuids_.find (ACE_CString (pc->UUID), entry) == 0) - { - //clean the extracted files - remove_extracted_package (path.c_str ()); - //remove the package - remove (package_path.c_str ()); + //forming the server path info + ACE_CString server_path (this->HTTP_server_); + server_path += installationName; - throw Deployment::NameExists (); - } + //NOTE: ComponentPackageReferences are currently NOT supported + if (!(pc->basePackage.length () > 0)) + { + //clean the extracted files + remove_extracted_package (path.c_str ()); + //remove the package + remove (package_path.c_str ()); - //forming the server path info - ACE_CString server_path (this->HTTP_server_); - server_path += installationName; + throw CORBA::NO_IMPLEMENT (); + } - //NOTE: ComponentPackageReferences are currently NOT supported - if (!(pc->basePackage.length () > 0)) - { - //clean the extracted files - remove_extracted_package (path.c_str ()); - //remove the package - remove (package_path.c_str ()); + PC_Updater updater (server_path, package_path); - throw CORBA::NO_IMPLEMENT (); - } + if (!updater.update (pc)) + { + ACE_DEBUG ((LM_ERROR, "[RM] problem updating the PackageConfiguration!\n")); - PC_Updater updater (server_path, package_path); + //clean the extracted files + remove_extracted_package (path.c_str ()); + //remove the package + remove (package_path.c_str ()); + throw Deployment::PackageError (); + } - if (!updater.update (pc)) - { - ACE_DEBUG ((LM_ERROR, "[RM] problem updating the PackageConfiguration!\n")); - //clean the extracted files - remove_extracted_package (path.c_str ()); - //remove the package - remove (package_path.c_str ()); - throw Deployment::PackageError (); - } + //now lets externalize the PackageConfiguration, so that we can access it later on + //without having to do the whole parsing again. + //NOTE: Order here is important. Do not populate maps before the externalization! + RM_Helper::externalize (pc, pc_path.c_str ()); + //insert the package into the database + if (this->names_.bind (ACE_CString (installationName), path) == -1) + { + ACE_ERROR ((LM_ERROR, + "[RM] could not bind %s.\n", + installationName)); + + //clean the extracted files + remove_extracted_package (path.c_str ()); + //remove the package + remove (package_path.c_str ()); + //remove the PackageConfiguration externalization + remove (pc_path.c_str ()); + + //throw exception + throw CORBA::INTERNAL (); + } - //now lets externalize the PackageConfiguration, so that we can access it later on - //without having to do the whole parsing again. - //NOTE: Order here is important. Do not populate maps before the externalization! - RM_Helper::externalize (pc, pc_path.c_str ()); + //ALSO NEED THE UUID here + if (this->uuids_.bind (ACE_CString (pc->UUID), path) == -1) + { + ACE_ERROR ((LM_ERROR, + "[RM] could not bind %s.\n", + ACE_CString (pc->UUID).c_str ())); - //insert the package into the database - if (this->names_.bind (ACE_CString (installationName), path) == -1) - { - ACE_ERROR ((LM_ERROR, - "[RM] could not bind %s.\n", - installationName)); + //unbind the name + this->names_.unbind (installationName); - //clean the extracted files - remove_extracted_package (path.c_str ()); - //remove the package - remove (package_path.c_str ()); - //remove the PackageConfiguration externalization - remove (pc_path.c_str ()); + //clean the extracted files + remove_extracted_package (path.c_str ()); + //remove the package + remove (package_path.c_str ()); + //remove the PackageConfiguration externalization + remove (pc_path.c_str ()); - //throw exception - throw CORBA::INTERNAL (); - } + //throw exception + throw CORBA::INTERNAL (); + } - //ALSO NEED THE UUID here - if (this->uuids_.bind (ACE_CString (pc->UUID), path) == -1) - { - ACE_ERROR ((LM_ERROR, - "[RM] could not bind %s.\n", - ACE_CString (pc->UUID).c_str ())); - - //unbind the name - this->names_.unbind (installationName); - - //clean the extracted files - remove_extracted_package (path.c_str ()); - //remove the package - remove (package_path.c_str ()); - //remove the PackageConfiguration externalization - remove (pc_path.c_str ()); - - //throw exception - throw CORBA::INTERNAL (); + //now add the type interface + if(!this->add_type (pc, installationName)) + ACE_ERROR ((LM_ERROR, "Failed to add the type\n")); + + this->dump (); + + this->save (); + + ACE_DEBUG ((LM_INFO, + "Installed PackageConfiguration \n\tname: %s \n\tuuid: %s\n", + installationName, ACE_CString (pc->UUID).c_str ())); } - //now add the type interface - if(!this->add_type (pc, installationName)) - ACE_ERROR ((LM_ERROR, "Failed to add the type\n")); - this->dump (); + //----------------------------------------------------------------- + //createPackage + // + //----------------------------------------------------------------- - this->save (); + void RepositoryManagerDaemon_i::createPackage (const char * installationName, + const ::Deployment::PackageConfiguration & package, + const char * baseLocation, + ::CORBA::Boolean replace) + { + ::Deployment::PackageConfiguration pc = package; - ACE_DEBUG ((LM_INFO, - "Installed PackageConfiguration \n\tname: %s \n\tuuid: %s\n", - installationName, ACE_CString (pc->UUID).c_str ())); -} + // Find if there is a PackageConfiguration with the same name. + PCEntry *entry = 0; + if (this->names_.find (ACE_CString (installationName), entry) == 0) + { + if (!replace) + throw Deployment::NameExists (); + else + deletePackage (installationName); + } + // Find if there is a PackageConfiguration with the same uuid. + if (this->uuids_.find (ACE_CString (pc.UUID), entry) == 0) + throw Deployment::NameExists (); -//----------------------------------------------------------------- -//createPackage -// -//----------------------------------------------------------------- + // Find if the PackageConfiguration has a basePackage. + // NOTE: ComponentPackageReferences are currently NOT supported. + if (!(pc.basePackage.length () > 0)) + throw CORBA::NO_IMPLEMENT (); -void CIAO_RepositoryManagerDaemon_i::createPackage ( - const char * installationName, - const ::Deployment::PackageConfiguration & package, - const char * baseLocation, - ::CORBA::Boolean replace - ) -{ - ::Deployment::PackageConfiguration pc = package; + // Form the path for the local file + ACE_CString path (this->install_root_); + path += "/"; + path += installationName; - // Find if there is a PackageConfiguration with the same name. - PCEntry *entry = 0; - if (this->names_.find (ACE_CString (installationName), entry) == 0) - { - if (!replace) - throw Deployment::NameExists (); - else - deletePackage (installationName); - } + ACE_CString package_path (path); + package_path += ".cpk"; //package extension - // Find if there is a PackageConfiguration with the same uuid. - if (this->uuids_.find (ACE_CString (pc.UUID), entry) == 0) - throw Deployment::NameExists (); + ACE_CString pc_path (path); + pc_path += PC_EXTENSION; //external PackageConfiguration extension - // Find if the PackageConfiguration has a basePackage. - // NOTE: ComponentPackageReferences are currently NOT supported. - if (!(pc.basePackage.length () > 0)) - throw CORBA::NO_IMPLEMENT (); + // Check if URL or local file, download or load into memory + if (ACE_OS::strstr (baseLocation, "http://")) + { + //TODO: how can I incorporate a Auto_Ptr is explicit release is needed + ACE_Message_Block* mb; + ACE_NEW_THROW_EX (mb, ACE_Message_Block (), CORBA::NO_MEMORY ()); + + //get the remote file + if (!HTTP_Get (baseLocation, *mb)) + { + mb->release (); + throw CORBA::INTERNAL (); + } + + // Write file to designated location on disk + if (!RM_Helper::write_to_disk (package_path.c_str (), *mb)) + { + mb->release (); + throw CORBA::INTERNAL (); + } + + mb->release (); + } + else + { + if (!RM_Helper::copy_from_disk_to_disk (baseLocation, package_path.c_str ())) + throw CORBA::INTERNAL (); + } - // Form the path for the local file - ACE_CString path (this->install_root_); - path += "/"; - path += installationName; - ACE_CString package_path (path); - package_path += ".cpk"; //package extension + ZIP_Wrapper::uncompress (const_cast<char*> (package_path.c_str ()), + const_cast<char*> (this->install_root_.c_str ()), + false //not verbose + ); - ACE_CString pc_path (path); - pc_path += PC_EXTENSION; //external PackageConfiguration extension + // Form the server path info + ACE_CString server_path (this->HTTP_server_); + server_path += installationName; - // Check if URL or local file, download or load into memory - if (ACE_OS::strstr (baseLocation, "http://")) - { - //TODO: how can I incorporate a Auto_Ptr is explicit release is needed - ACE_Message_Block* mb; - ACE_NEW_THROW_EX (mb, ACE_Message_Block (), CORBA::NO_MEMORY ()); - - //get the remote file - if (!HTTP_Get (baseLocation, *mb)) - { - mb->release (); - throw CORBA::INTERNAL (); - } + // Update the newly installed package configration informantion. + PC_Updater updater (server_path, package_path); - // Write file to designated location on disk - if (!RM_Helper::write_to_disk (package_path.c_str (), *mb)) - { - mb->release (); - throw CORBA::INTERNAL (); - } + if (!updater.update (pc)) + { + ACE_ERROR ((LM_ERROR, "[RM] problem updating the PackageConfiguration!\n")); + //clean the extracted files + remove_extracted_package (path.c_str ()); + //remove the package + remove (package_path.c_str ()); + throw Deployment::PackageError (); + } - mb->release (); - } - else - { - if (!RM_Helper::copy_from_disk_to_disk (baseLocation, package_path.c_str ())) - throw CORBA::INTERNAL (); - } + // Externalize the PackageConfiguration, so that we can access it later on + // without having to do the whole parsing again. + // NOTE: Order here is important. Do not populate maps before the externalization! + RM_Helper::externalize (pc, pc_path.c_str ()); + // Insert the name of the package. + if (this->names_.bind (ACE_CString (installationName), path) == -1) + { + ACE_ERROR ((LM_ERROR, + "[RM] could not bind %s.\n", + installationName)); + + //clean the extracted files + remove_extracted_package (path.c_str ()); + //remove the package + remove (package_path.c_str ()); + //remove the PackageConfiguration externalization + remove (pc_path.c_str ()); + + //throw exception + throw CORBA::INTERNAL (); + } - ZIP_Wrapper::uncompress (const_cast<char*> (package_path.c_str ()), - const_cast<char*> (this->install_root_.c_str ()), - false //not verbose - ); + // Insert the UUID of the package. + if (this->uuids_.bind (ACE_CString (pc.UUID), path) == -1) + { + ACE_ERROR ((LM_ERROR, + "[RM] could not bind %s.\n", + ACE_CString (pc.UUID).c_str ())); - // Form the server path info - ACE_CString server_path (this->HTTP_server_); - server_path += installationName; + //unbind the name + this->names_.unbind (installationName); - // Update the newly installed package configration informantion. - PC_Updater updater (server_path, package_path); + //clean the extracted files + remove_extracted_package (path.c_str ()); + //remove the package + remove (package_path.c_str ()); + //remove the PackageConfiguration externalization + remove (pc_path.c_str ()); - if (!updater.update (pc)) - { - ACE_ERROR ((LM_ERROR, "[RM] problem updating the PackageConfiguration!\n")); - //clean the extracted files - remove_extracted_package (path.c_str ()); - //remove the package - remove (package_path.c_str ()); - throw Deployment::PackageError (); - } + //throw exception + throw CORBA::INTERNAL (); + } - // Externalize the PackageConfiguration, so that we can access it later on - // without having to do the whole parsing again. - // NOTE: Order here is important. Do not populate maps before the externalization! - RM_Helper::externalize (pc, pc_path.c_str ()); + //now add the type interface + //TODO: CHECK if successful + if(!this->add_type (pc, installationName)) + ACE_ERROR ((LM_ERROR, "Failed to add the type\n")); - // Insert the name of the package. - if (this->names_.bind (ACE_CString (installationName), path) == -1) - { - ACE_ERROR ((LM_ERROR, - "[RM] could not bind %s.\n", - installationName)); + this->dump (); - //clean the extracted files - remove_extracted_package (path.c_str ()); - //remove the package - remove (package_path.c_str ()); - //remove the PackageConfiguration externalization - remove (pc_path.c_str ()); + this->save (); - //throw exception - throw CORBA::INTERNAL (); + ACE_DEBUG ((LM_INFO, + "Created PackageConfiguration \n directory: %s \n name: %s \n uuid: %s\n", + path.c_str (), installationName, ACE_CString (pc.UUID).c_str ())); } - // Insert the UUID of the package. - if (this->uuids_.bind (ACE_CString (pc.UUID), path) == -1) - { - ACE_ERROR ((LM_ERROR, - "[RM] could not bind %s.\n", - ACE_CString (pc.UUID).c_str ())); - - //unbind the name - this->names_.unbind (installationName); - - //clean the extracted files - remove_extracted_package (path.c_str ()); - //remove the package - remove (package_path.c_str ()); - //remove the PackageConfiguration externalization - remove (pc_path.c_str ()); - - //throw exception - throw CORBA::INTERNAL (); - } - //now add the type interface - //TODO: CHECK if successful - if(!this->add_type (pc, installationName)) - ACE_ERROR ((LM_ERROR, "Failed to add the type\n")); + //----------------------------------------------------------------- + //findPackageByName + // + //----------------------------------------------------------------- - this->dump (); + ::Deployment::PackageConfiguration* + RepositoryManagerDaemon_i::findPackageByName (const char * name) - this->save (); + { + // Find out if the PackageConfiguration was installed in the repository, + // return it if found or throw and exception otherwise - ACE_DEBUG ((LM_INFO, - "Created PackageConfiguration \n directory: %s \n name: %s \n uuid: %s\n", - path.c_str (), installationName, ACE_CString (pc.UUID).c_str ())); -} + PCEntry *entry = 0; + if (this->names_.find (ACE_CString (name), entry) != 0) + throw Deployment::NoSuchName (); + //PackageConfiguration was not found -//----------------------------------------------------------------- -//findPackageByName -// -//----------------------------------------------------------------- + ACE_CString pc_path (entry->int_id_.c_str ()); + pc_path += PC_EXTENSION; -::Deployment::PackageConfiguration* -CIAO_RepositoryManagerDaemon_i::findPackageByName (const char * name) + Deployment::PackageConfiguration_var pc; + ACE_NEW_THROW_EX (pc, + Deployment::PackageConfiguration (), + CORBA::NO_MEMORY ()); -{ - // Find out if the PackageConfiguration was installed in the repository, - // return it if found or throw and exception otherwise - PCEntry *entry = 0; + if(!RM_Helper::reincarnate (pc, pc_path.c_str ())) + throw CORBA::INTERNAL (); - if (this->names_.find (ACE_CString (name), entry) != 0) - throw Deployment::NoSuchName (); - //PackageConfiguration was not found + ACE_DEBUG ((LM_INFO, "Successfully looked up \'%s\'.\n", name)); - ACE_CString pc_path (entry->int_id_.c_str ()); - pc_path += PC_EXTENSION; + return pc._retn (); + } - Deployment::PackageConfiguration_var pc; - ACE_NEW_THROW_EX (pc, - Deployment::PackageConfiguration (), - CORBA::NO_MEMORY ()); + //----------------------------------------------------------------- + //findPackageByUUID + // + //----------------------------------------------------------------- - if(!RM_Helper::reincarnate (pc, pc_path.c_str ())) - throw CORBA::INTERNAL (); + ::Deployment::PackageConfiguration* + RepositoryManagerDaemon_i::findPackageByUUID (const char * UUID) - ACE_DEBUG ((LM_INFO, "Successfully looked up \'%s\'.\n", name)); + { + // Find out if the PackageConfiguration was installed in the repository, + // return it if found or throw and exception otherwise - return pc._retn (); -} + PCEntry *entry = 0; + if (this->uuids_.find (ACE_CString (UUID), entry) != 0) + throw Deployment::NoSuchName (); + //PackageConfiguration was not found -//----------------------------------------------------------------- -//findPackageByUUID -// -//----------------------------------------------------------------- + ACE_CString pc_path (entry->int_id_.c_str ()); + pc_path += PC_EXTENSION; -::Deployment::PackageConfiguration* -CIAO_RepositoryManagerDaemon_i::findPackageByUUID (const char * UUID) + Deployment::PackageConfiguration_var pc; + ACE_NEW_THROW_EX (pc, + Deployment::PackageConfiguration (), + CORBA::NO_MEMORY ()); -{ - // Find out if the PackageConfiguration was installed in the repository, - // return it if found or throw and exception otherwise - PCEntry *entry = 0; + if(!RM_Helper::reincarnate (pc, pc_path.c_str ())) + throw CORBA::INTERNAL (); - if (this->uuids_.find (ACE_CString (UUID), entry) != 0) - throw Deployment::NoSuchName (); - //PackageConfiguration was not found + ACE_DEBUG ((LM_INFO, "Successfully looked up %s.\n", UUID)); - ACE_CString pc_path (entry->int_id_.c_str ()); - pc_path += PC_EXTENSION; + return pc._retn (); + } - Deployment::PackageConfiguration_var pc; - ACE_NEW_THROW_EX (pc, - Deployment::PackageConfiguration (), - CORBA::NO_MEMORY ()); + //----------------------------------------------------------------- + //findPackageByType + // + //----------------------------------------------------------------- + ::CORBA::StringSeq * RepositoryManagerDaemon_i::findNamesByType (const char * type) + { + CIEntry *entry = 0; - if(!RM_Helper::reincarnate (pc, pc_path.c_str ())) - throw CORBA::INTERNAL (); + //find the type in the interface map + if (this->types_.find (ACE_CString (type), entry) != 0) + { + //return an empty sequence + CORBA::StringSeq_var seq; + ACE_NEW_THROW_EX (seq, CORBA::StringSeq (0), CORBA::NO_MEMORY ()); - ACE_DEBUG ((LM_INFO, "Successfully looked up %s.\n", UUID)); + return seq._retn (); + } + else + { + CISet ci_set = (*entry).int_id_set_; + + CORBA::ULong len = ci_set.size (); + + //allocate a sequence of the right length + CORBA::StringSeq_var seq; + ACE_NEW_THROW_EX (seq, + CORBA::StringSeq (len), + CORBA::NO_MEMORY ()); + seq->length (len); + + //store the elements in the string sequence + CISet_Iterator ci_set_iter (ci_set); + CORBA::ULong index = 0; + for (ci_set_iter = ci_set.begin (); + ci_set_iter != ci_set.end () && index < len; + ++ci_set_iter, ++index) + { + seq[index] = CORBA::string_dup ((*ci_set_iter).c_str ()); + } + + return seq._retn (); + } + } - return pc._retn (); -} -//----------------------------------------------------------------- -//findPackageByType -// -//----------------------------------------------------------------- + //----------------------------------------------------------------- + //getAllNames + // + //----------------------------------------------------------------- -::CORBA::StringSeq * CIAO_RepositoryManagerDaemon_i::findNamesByType ( - const char * type - ) -{ - CIEntry *entry = 0; + ::CORBA::StringSeq* + RepositoryManagerDaemon_i::getAllNames () - //find the type in the interface map - if (this->types_.find (ACE_CString (type), entry) != 0) { - //return an empty sequence - CORBA::StringSeq_var seq; - ACE_NEW_THROW_EX (seq, CORBA::StringSeq (0), CORBA::NO_MEMORY ()); + //Map.current_size () gives you the current number with the duplicates + //Map.total_size () gives you the allocated space + the empty slots + //Apparently the only way to figure out the number of keys is to + //count them with an iterator. - return seq._retn (); - } - else - { - CISet ci_set = (*entry).int_id_set_; + CORBA::ULong num_entries = 0; - CORBA::ULong len = ci_set.size (); + for (PCMap_Iterator i = this->names_.begin (); + i != this->names_.end (); + ++i) + ++num_entries; - //allocate a sequence of the right length CORBA::StringSeq_var seq; - ACE_NEW_THROW_EX (seq, - CORBA::StringSeq (len), - CORBA::NO_MEMORY ()); - seq->length (len); + ACE_NEW_THROW_EX (seq, CORBA::StringSeq (num_entries), CORBA::NO_MEMORY ()); - //store the elements in the string sequence - CISet_Iterator ci_set_iter (ci_set); - CORBA::ULong index = 0; - for (ci_set_iter = ci_set.begin (); - ci_set_iter != ci_set.end () && index < len; - ++ci_set_iter, ++index) - { - seq[index] = CORBA::string_dup ((*ci_set_iter).c_str ()); - } - - return seq._retn (); - } -} + seq->length (num_entries); -//----------------------------------------------------------------- -//getAllNames -// -//----------------------------------------------------------------- - -::CORBA::StringSeq* -CIAO_RepositoryManagerDaemon_i::getAllNames () + CORBA::ULong index = 0; + for (PCMap_Iterator iter = this->names_.begin (); + iter != this->names_.end () && index < num_entries; + ++iter, ++index) + { + PCEntry& element = *iter; + seq[index] = CORBA::string_dup (element.ext_id_.c_str ()); + } -{ - //Map.current_size () gives you the current number with the duplicates - //Map.total_size () gives you the allocated space + the empty slots - //Apparently the only way to figure out the number of keys is to - //count them with an iterator. + ACE_DEBUG ((LM_INFO, "The number of packages %d\n", seq->length ())); - CORBA::ULong num_entries = 0; + return seq._retn (); //release the underlying CORBA::StringSeq + } - for (PCMap_Iterator i = this->names_.begin (); - i != this->names_.end (); - ++i) - ++num_entries; - CORBA::StringSeq_var seq; - ACE_NEW_THROW_EX (seq, CORBA::StringSeq (num_entries), CORBA::NO_MEMORY ()); + //----------------------------------------------------------------- + //getAllTypes + // + //----------------------------------------------------------------- + ::CORBA::StringSeq * RepositoryManagerDaemon_i::getAllTypes () + { + //Map.current_size () gives you the current number with the duplicates + //Map.total_size () gives you the allocated space + the empty slots + //Apparently the only way to figure out the number of keys is to + //count them with an iterator. - seq->length (num_entries); + CORBA::ULong num_entries = 0; - CORBA::ULong index = 0; - for (PCMap_Iterator iter = this->names_.begin (); - iter != this->names_.end () && index < num_entries; - ++iter, ++index) - { - PCEntry& element = *iter; - seq[index] = CORBA::string_dup (element.ext_id_.c_str ()); - } + for (CIMap_Iterator i = this->types_.begin (); + i != this->types_.end (); + ++i) + ++num_entries; - ACE_DEBUG ((LM_INFO, "The number of packages %d\n", seq->length ())); + CORBA::StringSeq_var seq; + ACE_NEW_THROW_EX (seq, + CORBA::StringSeq (num_entries), + CORBA::NO_MEMORY ()); - return seq._retn (); //release the underlying CORBA::StringSeq -} + seq->length (num_entries); -//----------------------------------------------------------------- -//getAllTypes -// -//----------------------------------------------------------------- + CORBA::ULong index = 0; + for (CIMap_Iterator iter = this->types_.begin (); + iter != this->types_.end () && index < num_entries; + ++iter, ++index) -::CORBA::StringSeq * CIAO_RepositoryManagerDaemon_i::getAllTypes ( + { + CIEntry& element = *iter; + seq[index] = CORBA::string_dup (element.ext_id_.c_str ()); + } - ) -{ - //Map.current_size () gives you the current number with the duplicates - //Map.total_size () gives you the allocated space + the empty slots - //Apparently the only way to figure out the number of keys is to - //count them with an iterator. + ACE_DEBUG ((LM_DEBUG, "The number of types: %d\n", num_entries)); - CORBA::ULong num_entries = 0; + return seq._retn (); //release the underlying CORBA::StringSeq + } - for (CIMap_Iterator i = this->types_.begin (); - i != this->types_.end (); - ++i) - ++num_entries; - CORBA::StringSeq_var seq; - ACE_NEW_THROW_EX (seq, - CORBA::StringSeq (num_entries), - CORBA::NO_MEMORY ()); + //----------------------------------------------------------------- + //DeletePackage + // + //----------------------------------------------------------------- + void RepositoryManagerDaemon_i::deletePackage (const char * installationName) + { + bool internal_err = false; - seq->length (num_entries); + PCEntry *entry = 0; - CORBA::ULong index = 0; - for (CIMap_Iterator iter = this->types_.begin (); - iter != this->types_.end () && index < num_entries; - ++iter, ++index) + if (this->names_.find (ACE_CString (installationName), entry) != 0) + throw Deployment::NoSuchName (); - { - CIEntry& element = *iter; - seq[index] = CORBA::string_dup (element.ext_id_.c_str ()); - } + //cache the package path + ACE_CString path (entry->int_id_.c_str ()); - ACE_DEBUG ((LM_DEBUG, "The number of types: %d\n", num_entries)); + //remove the name association + if (this->names_.unbind (installationName) == -1) + { + ACE_ERROR ((LM_ERROR, + "Unable to unbind %s.\n", + installationName)); + internal_err = true; + } - return seq._retn (); //release the underlying CORBA::StringSeq -} + //the package location + ACE_CString package_path (path); + package_path += ".cpk"; //package extension + //the PackageConfiguration externalization location + ACE_CString pc_path (path); + pc_path += PC_EXTENSION; //external PackageConfiguration extension -//----------------------------------------------------------------- -//DeletePackage -// -//----------------------------------------------------------------- + Deployment::PackageConfiguration_var pc; + ACE_NEW_THROW_EX (pc, + Deployment::PackageConfiguration (), + CORBA::NO_MEMORY ()); -void CIAO_RepositoryManagerDaemon_i::deletePackage ( - const char * installationName - ) -{ - bool internal_err = false; - PCEntry *entry = 0; + if(!RM_Helper::reincarnate (pc, pc_path.c_str ())) + { + ACE_ERROR ((LM_ERROR, "Could not reincarnate PC\n")); + internal_err = true; + } - if (this->names_.find (ACE_CString (installationName), entry) != 0) - throw Deployment::NoSuchName (); + if (this->uuids_.unbind (ACE_CString (pc->UUID)) == -1) + { + ACE_ERROR ((LM_ERROR, "Could not remove UUID\n")); + internal_err = true; + } - //cache the package path - ACE_CString path (entry->int_id_.c_str ()); + //remove the type from the interface map + if (!this->remove_type (pc, installationName)) + { + ACE_ERROR ((LM_ERROR, "Could not remove type\n")); + internal_err = true; + } - //remove the name association - if (this->names_.unbind (installationName) == -1) - { - ACE_ERROR ((LM_ERROR, - "Unable to unbind %s.\n", - installationName)); - internal_err = true; - } + //actually delete the package here! - //the package location - ACE_CString package_path (path); - package_path += ".cpk"; //package extension + //clean the extracted files + remove_extracted_package (path.c_str ()); + //remove the package + remove (package_path.c_str ()); + //remove the PackageConfiguration externalization + remove (pc_path.c_str ()); - //the PackageConfiguration externalization location - ACE_CString pc_path (path); - pc_path += PC_EXTENSION; //external PackageConfiguration extension + this->dump (); - Deployment::PackageConfiguration_var pc; - ACE_NEW_THROW_EX (pc, - Deployment::PackageConfiguration (), - CORBA::NO_MEMORY ()); + this->save (); + if (internal_err) + throw CORBA::INTERNAL (); + else + ACE_DEBUG ((LM_INFO, "Successfully deleted \'%s\'\n", installationName)); - if(!RM_Helper::reincarnate (pc, pc_path.c_str ())) - { - ACE_ERROR ((LM_ERROR, "Could not reincarnate PC\n")); - internal_err = true; } - if (this->uuids_.unbind (ACE_CString (pc->UUID)) == -1) - { - ACE_ERROR ((LM_ERROR, "Could not remove UUID\n")); - internal_err = true; - } - //remove the type from the interface map - if (!this->remove_type (pc, installationName)) + //==========================================HELPER METHODS================================================== + + Deployment::PackageConfiguration* + RepositoryManagerDaemon_i::retrieve_PC_from_package (char* package) { - ACE_ERROR ((LM_ERROR, "Could not remove type\n")); - internal_err = true; - } + char temp[128]; + // ACE_thread_t thread_id = ACE_Thread::self (); + char* PID = ACE_OS::itoa (ACE_OS::getpid (), temp, 10); - //actually delete the package here! + ACE_OS::mkdir(PID); + //if dir already exists a -1 is returned + //we ignore this, just need to make sure the directory exists - //clean the extracted files - remove_extracted_package (path.c_str ()); - //remove the package - remove (package_path.c_str ()); - //remove the PackageConfiguration externalization - remove (pc_path.c_str ()); + //change the working dir + ACE_OS::chdir (PID); - this->dump (); + ACE_CString pcd_name; + //extract the necessary descriptors + if (extract_descriptor_files (package, + pcd_name) < 0) + { + ACE_OS::chdir (this->cwd_); + ACE_ERROR ((LM_ERROR, + "(%P|%t) RepositoryManager: error extracting necessary files\n")); + throw CORBA::INTERNAL (); + } - this->save (); + Deployment::PackageConfiguration_var pc; + //parse the PCD to make sure that there are no package errors + try + { + //CIAO::Config_Handlers::STD_PC_Intf intf (pcd_name.c_str ()); + //pc = intf.get_PC (); + } + catch (...) + { + ACE_ERROR ((LM_ERROR, + "(%P|%t) RepositoryManager: Error parsing the PCD\n")); - if (internal_err) - throw CORBA::INTERNAL (); - else - ACE_DEBUG ((LM_INFO, "Successfully deleted \'%s\'\n", installationName)); + //change back the the old working dir + ACE_OS::chdir (this->cwd_); + throw Deployment::PackageError (); + } + //able to parse the PC. So lets install the package in the repo -} + //we no longer need the descriptors, so lets erase them! + remove_descriptor_files (package); + //change back the the old working dir + ACE_OS::chdir (this->cwd_); -//==========================================HELPER METHODS================================================== + //now lets erase the directory! + ACE_OS::rmdir (PID); + //the ACE_OS::rmdir does not work. Possibly because we need to delete + //the contents first. I will look into it more closely when I am back. -Deployment::PackageConfiguration* -CIAO_RepositoryManagerDaemon_i::retrieve_PC_from_package (char* package) -{ - char temp[128]; - // ACE_thread_t thread_id = ACE_Thread::self (); - char* PID = ACE_OS::itoa (ACE_OS::getpid (), temp, 10); - - ACE_OS::mkdir(PID); - //if dir already exists a -1 is returned - //we ignore this, just need to make sure the directory exists - - //change the working dir - ACE_OS::chdir (PID); - - ACE_CString pcd_name; - //extract the necessary descriptors - if (extract_descriptor_files (package, - pcd_name) < 0) - { - ACE_OS::chdir (this->cwd_); - ACE_ERROR ((LM_ERROR, - "(%P|%t) RepositoryManager: error extracting necessary files\n")); - throw CORBA::INTERNAL (); - } - - Deployment::PackageConfiguration_var pc; - //parse the PCD to make sure that there are no package errors - try - { - //CIAO::Config_Handlers::STD_PC_Intf intf (pcd_name.c_str ()); - //pc = intf.get_PC (); - } - catch (...) - { - ACE_ERROR ((LM_ERROR, - "(%P|%t) RepositoryManager: Error parsing the PCD\n")); - - //change back the the old working dir - ACE_OS::chdir (this->cwd_); - throw Deployment::PackageError (); - } - //able to parse the PC. So lets install the package in the repo - - //we no longer need the descriptors, so lets erase them! - remove_descriptor_files (package); - - //change back the the old working dir - ACE_OS::chdir (this->cwd_); - - //now lets erase the directory! - ACE_OS::rmdir (PID); - //the ACE_OS::rmdir does not work. Possibly because we need to delete - //the contents first. I will look into it more closely when I am back. - - return pc._retn (); -} + return pc._retn (); + } -//function to retvieve a file via HTTP -//stores the file in the passed preallocated ACE_Message_Block -//returns 1 on success -// 0 on error + //function to retvieve a file via HTTP + //stores the file in the passed preallocated ACE_Message_Block + //returns 1 on success + // 0 on error -int CIAO_RepositoryManagerDaemon_i::HTTP_Get (const char* URL, ACE_Message_Block &mb) -{ + int RepositoryManagerDaemon_i::HTTP_Get (const char* URL, ACE_Message_Block &mb) + { URL_Parser *parser = TheURL_Parser::instance (); if (!parser->parseURL (const_cast<char*> (URL))) - return 0; + return 0; // Create a client TAO_HTTP_Client client; @@ -887,182 +880,182 @@ int CIAO_RepositoryManagerDaemon_i::HTTP_Get (const char* URL, ACE_Message_Block if (client.open (parser->filename_, parser->hostname_, parser->port_) == -1) - { + { client.close (); return 0; - } + } // Read from it if (client.read (&mb) <= 0) - { + { client.close (); return 0; - } + } - return 1; -} + return 1; + } -//function to parse and return the PackageConfiguration from the already -//extracted descriptor files -Deployment::PackageConfiguration* -CIAO_RepositoryManagerDaemon_i::retrieve_PC_from_descriptors (const char* pc_name, - const char* descriptor_dir) -{ - //change the working dir - ACE_OS::chdir (descriptor_dir); - - Deployment::PackageConfiguration_var pc = new Deployment::PackageConfiguration (); - //parse the PCD to make sure that there are no package errors - try - { - CIAO::Config_Handlers::Packaging::PCD_Handler::package_config (pc_name, *pc); - } - catch (...) - { - ACE_ERROR ((LM_ERROR, - "(%P|%t) [RM::retrieve_PC_from_descriptors] Error parsing the PCD\n")); - - //change back the the old working dir - ACE_OS::chdir (this->cwd_); - throw Deployment::PackageError (); - } - //able to parse the PC. So lets install the package in the repo - - //change back the the old working dir - ACE_OS::chdir (this->cwd_); - - return pc._retn (); -} + //function to parse and return the PackageConfiguration from the already + //extracted descriptor files + Deployment::PackageConfiguration* + RepositoryManagerDaemon_i::retrieve_PC_from_descriptors (const char* pc_name, + const char* descriptor_dir) + { + //change the working dir + ACE_OS::chdir (descriptor_dir); + Deployment::PackageConfiguration_var pc = new Deployment::PackageConfiguration (); + //parse the PCD to make sure that there are no package errors + try + { + CIAO::Config_Handlers::Packaging::PCD_Handler::package_config (pc_name, *pc); + } + catch (...) + { + ACE_ERROR ((LM_ERROR, + "(%P|%t) [RM::retrieve_PC_from_descriptors] Error parsing the PCD\n")); -//find out what the name of the PackageConfiguration file is -void CIAO_RepositoryManagerDaemon_i::find_PC_name (char* package, ACE_CString& pcd_name) -{ - pcd_name = ""; //empty the contents of the ACE_CString + //change back the the old working dir + ACE_OS::chdir (this->cwd_); + throw Deployment::PackageError (); + } + //able to parse the PC. So lets install the package in the repo - //create a doubly link list - ACE_New_Allocator allocator; - ACE_Double_Linked_List<ZIP_File_Info> list (&allocator); + //change back the the old working dir + ACE_OS::chdir (this->cwd_); - //get the list of files in the package and figure out the names of all necessary files - if (!(ZIP_Wrapper::file_list_info (package, list))) - return; + return pc._retn (); + } - size_t skip_len = ACE_OS::strlen ("descriptors") + 1; - while (!list.is_empty ()) - { - ZIP_File_Info* inf = list.delete_head (); + //find out what the name of the PackageConfiguration file is + void RepositoryManagerDaemon_i::find_PC_name (char* package, ACE_CString& pcd_name) + { + pcd_name = ""; //empty the contents of the ACE_CString - if (ACE_OS::strstr (inf->name_.c_str (), "descriptors")) - if (ACE_OS::strstr (inf->name_.c_str (), ".pcd")) - pcd_name = inf->name_.c_str () + skip_len; + //create a doubly link list + ACE_New_Allocator allocator; + ACE_Double_Linked_List<ZIP_File_Info> list (&allocator); - //deallocate the head of the filename list - delete inf; - } -} + //get the list of files in the package and figure out the names of all necessary files + if (!(ZIP_Wrapper::file_list_info (package, list))) + return; + size_t skip_len = ACE_OS::strlen ("descriptors") + 1; -//We are using Xercesc in the Config_Handlers and unfortunately its API only -//takes a file in the local file system as an argument, thus need to -//write out the contents of the deployent plan to a file -//in the current directory. I use the thread id to guarrantee -//lack of race conditions if multithreading is enabled + while (!list.is_empty ()) + { + ZIP_File_Info* inf = list.delete_head (); -int CIAO_RepositoryManagerDaemon_i::extract_descriptor_files (char* package, ACE_CString& pcd_name) -{ - //create a doubly link list - ACE_New_Allocator allocator; - ACE_Double_Linked_List<ZIP_File_Info> list (&allocator); + if (ACE_OS::strstr (inf->name_.c_str (), "descriptors")) + if (ACE_OS::strstr (inf->name_.c_str (), ".pcd")) + pcd_name = inf->name_.c_str () + skip_len; - //get the list of files in the package and figure out the names of all necessary files - if (!(ZIP_Wrapper::file_list_info (package, list))) - return 0; + //deallocate the head of the filename list + delete inf; + } + } - size_t skip_len = ACE_OS::strlen ("descriptors") + 1; - while (!list.is_empty ()) - { - ZIP_File_Info* inf = list.delete_head (); - ACE_Message_Block* file = 0; - if (ACE_OS::strstr (inf->name_.c_str (), "descriptors")) - { - if (ACE_OS::strstr (inf->name_.c_str (), ".pcd")) - pcd_name = inf->name_.c_str () + skip_len; + //We are using Xercesc in the Config_Handlers and unfortunately its API only + //takes a file in the local file system as an argument, thus need to + //write out the contents of the deployent plan to a file + //in the current directory. I use the thread id to guarrantee + //lack of race conditions if multithreading is enabled - //extract the descriptor from the package - ACE_NEW_RETURN (file, ACE_Message_Block (0,0), 0); - if (!ZIP_Wrapper::get_file(const_cast<char*> (package), - const_cast<char*> (inf->name_.c_str ()), - *file)) - { - ACE_ERROR ((LM_ERROR, - "[RM::extract_descriptor_files] Unable to retrieve file!\n")); - //release the message block chain - file->release (); - return 0; - } - - - //write the file to disk - if(!RM_Helper::write_to_disk (inf->name_.c_str () + skip_len, *file)) - { - ACE_ERROR ((LM_ERROR, - "[RM::extract_descriptor_files] Unable to write out descriptor to disk!\n")); - //release the message block chain - file->release (); - return 0; - } - - //release the message block chain - file->release (); - } - - //deallocate the head of the filename list - delete inf; - } - - return 1; -} + int RepositoryManagerDaemon_i::extract_descriptor_files (char* package, ACE_CString& pcd_name) + { + //create a doubly link list + ACE_New_Allocator allocator; + ACE_Double_Linked_List<ZIP_File_Info> list (&allocator); -int CIAO_RepositoryManagerDaemon_i::remove_descriptor_files (char* package) -{ - int return_code = 1; + //get the list of files in the package and figure out the names of all necessary files + if (!(ZIP_Wrapper::file_list_info (package, list))) + return 0; - //create a doubly link list - ACE_New_Allocator allocator; - ACE_Double_Linked_List<ZIP_File_Info> list (&allocator); + size_t skip_len = ACE_OS::strlen ("descriptors") + 1; - //get the list of files in the package and figure out the names of all necessary files - if (!(ZIP_Wrapper::file_list_info (package, list))) - return 0; + while (!list.is_empty ()) + { + ZIP_File_Info* inf = list.delete_head (); + ACE_Message_Block* file = 0; + if (ACE_OS::strstr (inf->name_.c_str (), "descriptors")) + { + if (ACE_OS::strstr (inf->name_.c_str (), ".pcd")) + pcd_name = inf->name_.c_str () + skip_len; + + //extract the descriptor from the package + ACE_NEW_RETURN (file, ACE_Message_Block (0,0), 0); + if (!ZIP_Wrapper::get_file(const_cast<char*> (package), + const_cast<char*> (inf->name_.c_str ()), + *file)) + { + ACE_ERROR ((LM_ERROR, + "[RM::extract_descriptor_files] Unable to retrieve file!\n")); + //release the message block chain + file->release (); + return 0; + } + + + //write the file to disk + if(!RM_Helper::write_to_disk (inf->name_.c_str () + skip_len, *file)) + { + ACE_ERROR ((LM_ERROR, + "[RM::extract_descriptor_files] Unable to write out descriptor to disk!\n")); + //release the message block chain + file->release (); + return 0; + } + + //release the message block chain + file->release (); + } + + //deallocate the head of the filename list + delete inf; + } - size_t skip_len = ACE_OS::strlen ("descriptors") + 1; - - while (!list.is_empty ()) - { - ZIP_File_Info* inf = list.delete_head (); - if (ACE_OS::strstr (inf->name_.c_str (), "descriptors")) - { - //delete disk - if(remove (inf->name_.c_str () + skip_len)) - { - ACE_ERROR ((LM_ERROR, - "[RM::remove_descriptor_files] Unable to remove file from disk!\n")); - return_code = 0; - } - } - //deallocate the head of the filename list - delete inf; - } - - return return_code; -} + return 1; + } + + int RepositoryManagerDaemon_i::remove_descriptor_files (char* package) + { + int return_code = 1; + + //create a doubly link list + ACE_New_Allocator allocator; + ACE_Double_Linked_List<ZIP_File_Info> list (&allocator); + + //get the list of files in the package and figure out the names of all necessary files + if (!(ZIP_Wrapper::file_list_info (package, list))) + return 0; + + size_t skip_len = ACE_OS::strlen ("descriptors") + 1; + + while (!list.is_empty ()) + { + ZIP_File_Info* inf = list.delete_head (); + if (ACE_OS::strstr (inf->name_.c_str (), "descriptors")) + { + //delete disk + if(remove (inf->name_.c_str () + skip_len)) + { + ACE_ERROR ((LM_ERROR, + "[RM::remove_descriptor_files] Unable to remove file from disk!\n")); + return_code = 0; + } + } + //deallocate the head of the filename list + delete inf; + } + + return return_code; + } -int CIAO_RepositoryManagerDaemon_i::remove_extracted_package (const char* path) + int RepositoryManagerDaemon_i::remove_extracted_package (const char* path) { ACE_TCHAR full_path[MAXPATHLEN]; ACE_OS::getcwd (full_path, sizeof(full_path)); @@ -1072,30 +1065,30 @@ int CIAO_RepositoryManagerDaemon_i::remove_extracted_package (const char* path) ACE_Dirent dir (path); for (ACE_DIRENT *directory; (directory = dir.read ()) != 0;) - { - if (ACE::isdotdir (directory->d_name) == true) - continue; - - ACE_stat stat_buf; - ACE_OS::lstat (directory->d_name, &stat_buf); - - ACE_CString temp = path; - temp += "/"; - temp += directory->d_name; - switch (stat_buf.st_mode & S_IFMT) - { - case S_IFREG: // Either a regular file or an executable. - remove (temp.c_str ()); - break; - - case S_IFDIR: - remove_extracted_package (temp.c_str ()); - break; - - default: - break; - } - } + { + if (ACE::isdotdir (directory->d_name) == true) + continue; + + ACE_stat stat_buf; + ACE_OS::lstat (directory->d_name, &stat_buf); + + ACE_CString temp = path; + temp += "/"; + temp += directory->d_name; + switch (stat_buf.st_mode & S_IFMT) + { + case S_IFREG: // Either a regular file or an executable. + remove (temp.c_str ()); + break; + + case S_IFDIR: + remove_extracted_package (temp.c_str ()); + break; + + default: + break; + } + } ACE_OS::chdir (full_path); @@ -1104,122 +1097,123 @@ int CIAO_RepositoryManagerDaemon_i::remove_extracted_package (const char* path) return 0; } -//function to extract the type of the component from -//the PackageConfiguration and update the interface map -//returns 1 on success -// 0 on error + //function to extract the type of the component from + //the PackageConfiguration and update the interface map + //returns 1 on success + // 0 on error -int CIAO_RepositoryManagerDaemon_i::add_type (Deployment::PackageConfiguration& pc, - const char* name) -{ - if (pc.basePackage.length () > 0) + int RepositoryManagerDaemon_i::add_type (Deployment::PackageConfiguration& pc, + const char* name) { - ::CORBA::StringSeq supportedTypes = pc.basePackage[0] - .implementation[0] - .referencedImplementation - .implements - .supportedType; - - if (supportedTypes.length () != 0) - { - CORBA::ULong len = supportedTypes.length (); - for (CORBA::ULong i = 0; i < len; ++i) + if (pc.basePackage.length () > 0) { - this->types_.bind (ACE_CString (supportedTypes[i]), name); + ::CORBA::StringSeq supportedTypes = pc.basePackage[0] + .implementation[0] + .referencedImplementation + .implements + .supportedType; + + if (supportedTypes.length () != 0) + { + CORBA::ULong len = supportedTypes.length (); + for (CORBA::ULong i = 0; i < len; ++i) + { + this->types_.bind (ACE_CString (supportedTypes[i]), name); + } + } + } + else //ComponentPackageReference + { + //not implemented yet + return 0; } - } - } - else //ComponentPackageReference - { - //not implemented yet - return 0; - } - return 1; -} + return 1; + } -//function to remove the interface type of the component -//being removed from the interface map -//returns 1 on success -// 0 on error + //function to remove the interface type of the component + //being removed from the interface map + //returns 1 on success + // 0 on error -int CIAO_RepositoryManagerDaemon_i::remove_type (Deployment::PackageConfiguration& pc, - const char* name) -{ - if (pc.basePackage.length () > 0) + int RepositoryManagerDaemon_i::remove_type (Deployment::PackageConfiguration& pc, + const char* name) { - ::CORBA::StringSeq supportedTypes = pc.basePackage[0] - .implementation[0] - .referencedImplementation - .implements - .supportedType; - - if (supportedTypes.length () != 0) - { - CORBA::ULong len = supportedTypes.length (); - for (CORBA::ULong i = 0; i < len; ++i) + if (pc.basePackage.length () > 0) { - if (this->types_.unbind (ACE_CString (supportedTypes[i]), ACE_CString (name)) != 0) - ACE_DEBUG ((LM_DEBUG, "Could not find type %s with package name %s!\n", - ACE_CString (supportedTypes[i]).c_str (), - name)); + ::CORBA::StringSeq supportedTypes = pc.basePackage[0] + .implementation[0] + .referencedImplementation + .implements + .supportedType; + + if (supportedTypes.length () != 0) + { + CORBA::ULong len = supportedTypes.length (); + for (CORBA::ULong i = 0; i < len; ++i) + { + if (this->types_.unbind (ACE_CString (supportedTypes[i]), ACE_CString (name)) != 0) + ACE_DEBUG ((LM_DEBUG, "Could not find type %s with package name %s!\n", + ACE_CString (supportedTypes[i]).c_str (), + name)); + } + } + } + else //ComponentPackageReference + { + //not implemented yet + return 0; } - } - } - else //ComponentPackageReference - { - //not implemented yet - return 0; - } - return 1; -} + return 1; + } -//function to dump the state of the RepositoryManager -void CIAO_RepositoryManagerDaemon_i::dump (void) -{ + //function to dump the state of the RepositoryManager + void RepositoryManagerDaemon_i::dump (void) + { #if defined (ACE_HAS_DUMP) - ACE_DEBUG(LM_DEBUG, "NAMES:\n"); - this->names_.dump (); - ACE_DEBUG(LM_DEBUG, "UUIDs:\n"); - this->uuids_.dump (); - ACE_DEBUG (LM_DEBUG, "Component Interface Types:\n"); - this->types_.dump (); + ACE_DEBUG(LM_DEBUG, "NAMES:\n"); + this->names_.dump (); + ACE_DEBUG(LM_DEBUG, "UUIDs:\n"); + this->uuids_.dump (); + ACE_DEBUG (LM_DEBUG, "Component Interface Types:\n"); + this->types_.dump (); #endif /* ACE_HAS_DUMP */ -} - -//function to save the package info of the RepositoryManager -void CIAO_RepositoryManagerDaemon_i::save (void) -{ - // Save the names, UUIDs, & types info to the configuration files. - ACE_Configuration_Heap cfg; - cfg.open (); - ACE_Configuration_Section_Key root = cfg.root_section (); - - ACE_Configuration_Section_Key NameSection; - cfg.open_section (root, RM_RECORD_NAME_SECTION, 1, NameSection); - for (PCMap_Iterator iter = this->names_.begin (); - iter != this->names_.end (); - ++iter) - { - PCEntry& element = *iter; - cfg.set_string_value (NameSection, element.ext_id_.c_str (), element.int_id_.c_str ()); } - ACE_Configuration_Section_Key UUIDSection; - cfg.open_section (root, RM_RECORD_UUID_SECTION, 1, UUIDSection); - for (PCMap_Iterator iter = this->uuids_.begin (); - iter != this->uuids_.end (); - ++iter) + //function to save the package info of the RepositoryManager + void RepositoryManagerDaemon_i::save (void) { - PCEntry& element = *iter; - cfg.set_string_value (UUIDSection, element.ext_id_.c_str (), element.int_id_.c_str ()); - } + // Save the names, UUIDs, & types info to the configuration files. + ACE_Configuration_Heap cfg; + cfg.open (); + ACE_Configuration_Section_Key root = cfg.root_section (); + + ACE_Configuration_Section_Key NameSection; + cfg.open_section (root, RM_RECORD_NAME_SECTION, 1, NameSection); + for (PCMap_Iterator iter = this->names_.begin (); + iter != this->names_.end (); + ++iter) + { + PCEntry& element = *iter; + cfg.set_string_value (NameSection, element.ext_id_.c_str (), element.int_id_.c_str ()); + } - ACE_Registry_ImpExp exporter (cfg); - ACE_OS::chdir (install_path.c_str ()); - exporter.export_config (RM_RECORD_FILE); - ACE_OS::chdir (this->cwd_); + ACE_Configuration_Section_Key UUIDSection; + cfg.open_section (root, RM_RECORD_UUID_SECTION, 1, UUIDSection); + for (PCMap_Iterator iter = this->uuids_.begin (); + iter != this->uuids_.end (); + ++iter) + { + PCEntry& element = *iter; + cfg.set_string_value (UUIDSection, element.ext_id_.c_str (), element.int_id_.c_str ()); + } + + ACE_Registry_ImpExp exporter (cfg); + ACE_OS::chdir (install_path.c_str ()); + exporter.export_config (RM_RECORD_FILE); + ACE_OS::chdir (this->cwd_); + } } diff --git a/CIAO/DAnCE/RepositoryManager/RepositoryManager_Impl.h b/CIAO/DAnCE/RepositoryManager/RepositoryManager_Impl.h index 734ce8fc004..e7b3a9164a1 100644 --- a/CIAO/DAnCE/RepositoryManager/RepositoryManager_Impl.h +++ b/CIAO/DAnCE/RepositoryManager/RepositoryManager_Impl.h @@ -14,7 +14,8 @@ * the D&C spec * * @author Stoyan Paunov - * Shanshan Jiang <shanshan.jiang@vanderbilt.edu> + * @author Shanshan Jiang <shanshan.jiang@vanderbilt.edu> + * @author William R. Otte <wotte@dre.vanderbilt.edu> */ //====================================================================== @@ -48,170 +49,153 @@ namespace static const size_t TEMP_LEN = 1024; } -class CIAO_RepositoryManagerDaemon_i : - public virtual POA_CIAO::RepositoryManagerDaemon +namespace DAnCE { -public: - /// Constructor - CIAO_RepositoryManagerDaemon_i (CORBA::ORB_ptr the_orb, - const char* server = "localhost:5432", - const char* install_dir = "RepositoryManager"); - - /// Destructor - virtual ~CIAO_RepositoryManagerDaemon_i (void); - - virtual - void shutdown ( - - ); - - virtual - void installPackage ( - const char * installationName, - const char * location, - ::CORBA::Boolean replace - ); - - virtual - void createPackage ( - const char * installationName, - const ::Deployment::PackageConfiguration & package, - const char * baseLocation, - ::CORBA::Boolean replace - ); - - virtual - ::Deployment::PackageConfiguration * findPackageByName ( - const char * name - ); - - virtual - ::Deployment::PackageConfiguration * findPackageByUUID ( - const char * UUID - ); - - virtual - ::CORBA::StringSeq * findNamesByType ( - const char * type - ); - - virtual - ::CORBA::StringSeq * getAllNames ( - - ); - - virtual - ::CORBA::StringSeq * getAllTypes ( - - ); - - virtual - void deletePackage ( - const char * installationName - ); - -protected: - - /// Function to parse and return the PackageConfiguration from a specified - /// package - Deployment::PackageConfiguration* retrieve_PC_from_package (char* package); - - /// Find out what the name of the PackageConfiguration file is - void find_PC_name (char* package, ACE_CString& pcd_name); - - /// Function to parse and return the PackageConfiguration from the already - /// extracted descriptor files - Deployment::PackageConfiguration* retrieve_PC_from_descriptors (const char* pc_name, - const char* descriptor_dir); - - - /// Function to retrieve a file via HTTP - /// stores the file in the passed preallocated ACE_Message_Block - /// @retval 1 success - /// @retval 0 error - int HTTP_Get (const char* URL, ACE_Message_Block &mb); - - /// Function to extract all necessary files for parsing the - /// PackageConfiguration descriptor and populating the idl struct. - /// @retval 1 success - /// @retval 0 error - /// - /// @note ACE_CString& pcd_name is an out parameter - int extract_descriptor_files (char* package, - ACE_CString& pcd_name); - - - /// Function to remove the files extracted for parsing the PackageConfiguration - /// descriptor and populating the idl struct. It reads the names of the files - /// from the package. They correspond to the names on disk. - /// @retval 1 on success - /// @retval 0 on error - int remove_descriptor_files (char* package); - - - /// Function to remove the files extracted from the package upon istallation - /// It reads the names of the files from the package. They correspond to the - /// names on disk. It deletes each file, then it deletes the directories that - /// contain them. - /// @note extraction location is path/*archive_name*/ - /// @retval 1 on success - /// @retval 0 on error - int remove_extracted_package (const char* package_path); - - /// Function to extract the type of the component from - /// the PackageConfiguration and update the interface map - /// @retval 1 on success - /// @retval 0 on error - int add_type (::Deployment::PackageConfiguration& pc, - const char* name); - - /// Function to remove the interface type of the component - /// being removed from the interface map - /// @retval 1 on success - /// @retval 0 on error - int remove_type (::Deployment::PackageConfiguration& pc, - const char* name); - - /// Function to dump the state of the RepositoryManager - void dump (void); - - /// Function to save the package info of the RepositoryManager - void save (void); - -private: - /// Cached information about the installed PackageConfigurations - /// A separate map for the installation names and their UUID's - /// Key: PackageConfiguration name or its UUID (CString type) - /// Value: The location of the local copy of the package - - ///Based on the synchronization needed we can parametrize this with either - ///ACE_Null_Mutex or ACE_RW_Mutex - - typedef ACE_Hash_Map_Manager_Ex<ACE_CString, - ACE_CString, - ACE_Hash<ACE_CString>, - ACE_Equal_To<ACE_CString>, - ACE_RW_Mutex> PCMap; - - typedef PCMap::ITERATOR PCMap_Iterator; - typedef PCMap::ENTRY PCEntry; - - - /// Cached information about the installed Component Interfaces - /// A map which associates Component supportedType with the - /// names of packages which implement this component type - /// Key: Component supportedType - /// Value: Unbounded set of the names of installed packages which - /// implement this component type - - ///Based on the synchronization needed we can parametrize this with either - ///ACE_Null_Mutex or ACE_RW_Mutex - - typedef ACE_Hash_Multi_Map_Manager<ACE_CString, - ACE_CString, - ACE_Hash<ACE_CString>, - ACE_Equal_To<ACE_CString>, - ACE_RW_Mutex> CIMap; + class RepositoryManagerDaemon_i : + public virtual POA_CIAO::RepositoryManagerDaemon + { + public: + /// Constructor + RepositoryManagerDaemon_i (CORBA::ORB_ptr the_orb, + const ACE_TCHAR* server = "localhost:5432", + const ACE_TCHAR* install_dir = "RepositoryManager"); + + /// Destructor + virtual ~RepositoryManagerDaemon_i (void); + + virtual void shutdown (); + + virtual + void installPackage (const ACE_TCHAR * installationName, + const ACE_TCHAR * location, + ::CORBA::Boolean replace); + + virtual + void createPackage (const ACE_TCHAR * installationName, + const ::Deployment::PackageConfiguration & package, + const ACE_TCHAR * baseLocation, + ::CORBA::Boolean replace); + + virtual + ::Deployment::PackageConfiguration * findPackageByName (const ACE_TCHAR * name); + + virtual + ::Deployment::PackageConfiguration * findPackageByUUID (const ACE_TCHAR * UUID); + + virtual + ::CORBA::StringSeq * findNamesByType (const ACE_TCHAR * type); + + virtual + ::CORBA::StringSeq * getAllNames (); + + virtual + ::CORBA::StringSeq * getAllTypes (); + + virtual + void deletePackage (const ACE_TCHAR * installationName); + + protected: + + /// Function to parse and return the PackageConfiguration from a specified + /// package + Deployment::PackageConfiguration* retrieve_PC_from_package (ACE_TCHAR* package); + + /// Find out what the name of the PackageConfiguration file is + void find_PC_name (ACE_TCHAR* package, ACE_CString& pcd_name); + + /// Function to parse and return the PackageConfiguration from the already + /// extracted descriptor files + Deployment::PackageConfiguration* retrieve_PC_from_descriptors (const ACE_TCHAR* pc_name, + const ACE_TCHAR* descriptor_dir); + + + /// Function to retrieve a file via HTTP + /// stores the file in the passed preallocated ACE_Message_Block + /// @retval 1 success + /// @retval 0 error + int HTTP_Get (const ACE_TCHAR* URL, ACE_Message_Block &mb); + + /// Function to extract all necessary files for parsing the + /// PackageConfiguration descriptor and populating the idl struct. + /// @retval 1 success + /// @retval 0 error + /// + /// @note ACE_CString& pcd_name is an out parameter + int extract_descriptor_files (ACE_TCHAR* package, + ACE_CString& pcd_name); + + + /// Function to remove the files extracted for parsing the PackageConfiguration + /// descriptor and populating the idl struct. It reads the names of the files + /// from the package. They correspond to the names on disk. + /// @retval 1 on success + /// @retval 0 on error + int remove_descriptor_files (ACE_TCHAR* package); + + + /// Function to remove the files extracted from the package upon istallation + /// It reads the names of the files from the package. They correspond to the + /// names on disk. It deletes each file, then it deletes the directories that + /// contain them. + /// @note extraction location is path/*archive_name*/ + /// @retval 1 on success + /// @retval 0 on error + int remove_extracted_package (const ACE_TCHAR* package_path); + + /// Function to extract the type of the component from + /// the PackageConfiguration and update the interface map + /// @retval 1 on success + /// @retval 0 on error + int add_type (::Deployment::PackageConfiguration& pc, + const ACE_TCHAR* name); + + /// Function to remove the interface type of the component + /// being removed from the interface map + /// @retval 1 on success + /// @retval 0 on error + int remove_type (::Deployment::PackageConfiguration& pc, + const ACE_TCHAR* name); + + /// Function to dump the state of the RepositoryManager + void dump (void); + + /// Function to save the package info of the RepositoryManager + void save (void); + + private: + /// Cached information about the installed PackageConfigurations + /// A separate map for the installation names and their UUID's + /// Key: PackageConfiguration name or its UUID (CString type) + /// Value: The location of the local copy of the package + + ///Based on the synchronization needed we can parametrize this with either + ///ACE_Null_Mutex or ACE_RW_Mutex + + typedef ACE_Hash_Map_Manager_Ex<ACE_CString, + ACE_CString, + ACE_Hash<ACE_CString>, + ACE_Equal_To<ACE_CString>, + ACE_RW_Mutex> PCMap; + + typedef PCMap::ITERATOR PCMap_Iterator; + typedef PCMap::ENTRY PCEntry; + + + /// Cached information about the installed Component Interfaces + /// A map which associates Component supportedType with the + /// names of packages which implement this component type + /// Key: Component supportedType + /// Value: Unbounded set of the names of installed packages which + /// implement this component type + + ///Based on the synchronization needed we can parametrize this with either + ///ACE_Null_Mutex or ACE_RW_Mutex + + typedef ACE_Hash_Multi_Map_Manager<ACE_CString, + ACE_CString, + ACE_Hash<ACE_CString>, + ACE_Equal_To<ACE_CString>, + ACE_RW_Mutex> CIMap; typedef CIMap::ITERATOR CIMap_Iterator; typedef CIMap::ENTRY CIEntry; @@ -234,7 +218,7 @@ private: CORBA::ORB_var the_orb_; /// Will hold the current working directory - char cwd_ [TEMP_LEN]; + ACE_TCHAR cwd_ [TEMP_LEN]; /// Full path for the install directory ACE_CString install_root_; @@ -246,4 +230,6 @@ private: ACE_CString install_path; }; +} + #endif /* REPOSITORYMANAGER_H_ */ diff --git a/CIAO/DAnCE/RepositoryManager/Repository_Manager_Exec.cpp b/CIAO/DAnCE/RepositoryManager/Repository_Manager_Exec.cpp new file mode 100644 index 00000000000..371fabf1406 --- /dev/null +++ b/CIAO/DAnCE/RepositoryManager/Repository_Manager_Exec.cpp @@ -0,0 +1,6 @@ +// $Id$ +#include "Repository_Manager_Module.h" + +#define DANCE_MODULE_MAIN_CLASS_NAME DAnCE_RepositoryManager_Module +#include "Deployment/Module_Main.h" + diff --git a/CIAO/DAnCE/RepositoryManager/Repository_Manager_Module.cpp b/CIAO/DAnCE/RepositoryManager/Repository_Manager_Module.cpp new file mode 100644 index 00000000000..3607bea786e --- /dev/null +++ b/CIAO/DAnCE/RepositoryManager/Repository_Manager_Module.cpp @@ -0,0 +1,519 @@ +// -*- C++ -*- +// $Id$ + +#include "Repository_Manager_Module.h" +#include "ace/Get_Opt.h" +#include "ace/OS.h" +#include "ace/Task.h" +#include "ace/Atomic_Op.h" +#include "tao/IORTable/IORTable.h" +#include "tao/Utils/PolicyList_Destroyer.h" +#include "orbsvcs/CosNamingC.h" +#include "orbsvcs/orbsvcs/Naming/Naming_Loader.h" +#include "DAnCE/Logger/Log_Macros.h" +#include "DAnCE/Deployment/DAnCE_PropertiesC.h" + +#ifdef DANCE_RM_USES_JAWS +#include "JAWS/server/HTTP_Server.h" +#endif + +#include "RepositoryManager_Impl.h" + +ACE_RCSID (DAnCE, + Repository_Manager_Module, + "$Id$") + +namespace DAnCE +{ + namespace Repository_Manager + { + bool + write_IOR (const ACE_TCHAR * ior_file_name, const char* ior) + { + FILE* ior_output_file_ = + ACE_OS::fopen (ior_file_name, ACE_TEXT("w")); + + if (ior_output_file_) + { + ACE_OS::fprintf (ior_output_file_, + "%s", + ior); + ACE_OS::fclose (ior_output_file_); + return true; + } + return false; + } + + class Worker : public virtual ACE_Task_Base + { + public: + Worker (CORBA::ORB_ptr orb) : + orb_(CORBA::ORB::_duplicate (orb)) + { + } + + virtual int svc (void) + { + DANCE_TRACE ("DAnCE::Repository_Manager::Worker::svc"); + + size_t thread_id = ++this->thread_counter_; + + try + { + DANCE_DEBUG ((LM_INFO, DLINFO "DAnCE::Repository_Manager::Worker::svc - " + "Spawning thread %u for the ORB.\n", thread_id)); + this->orb_->run (); + DANCE_DEBUG ((LM_INFO, DLINFO "DAnCE::Repository_Manager::Worker::svc - " + "ORB event loop for thread %u completed successfully.\n", thread_id)); + } + catch (CORBA::Exception &ex) + { + DANCE_ERROR ((LM_ERROR, DLINFO "DAnCE::Repository_Manager::Worker::svc - " + "Caught CORBA exception from ORB event loop for thread %u: %s\n", + thread_id, ex._info ().c_str ())); + return -1; + } + catch (...) + { + DANCE_ERROR ((LM_ERROR, DLINFO "DAnCE::Repository_Manager::Worker::svc - " + "Caught unknown C++ exception from ORB event loop for thread %u\n", + thread_id)); + return -1; + } + + return 0; + } + + private: + ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long> thread_counter_; + CORBA::ORB_var orb_; + }; + } +} + +DAnCE_RepositoryManager_Module::DAnCE_RepositoryManager_Module (void) +{ + DANCE_TRACE("DAnCE_RepositoryManager_Module::DAnCE_RepositoryManager_Module"); +} + +DAnCE_RepositoryManager_Module::~DAnCE_RepositoryManager_Module (void) +{ + DANCE_TRACE ("DAnCE_RepositoryManager_Module::~DAnCE_RepositoryManager_Module"); + + for (Servant_Map::iterator it = this->rm_map_.begin (); + it != this->rm_map_.end (); + ++it) + { + delete (*it).int_id_; + } +} + +const char * +DAnCE_RepositoryManager_Module::usage (void) +{ + DANCE_TRACE ("DAnCE_RepositoryManager_Module::usage"); + return "Node Manager Options:\n" + "\t-n,--name [name]\t Name to register in the naming service\n" + "\t-t,--threads [num]\t Number of threads to run.\n" + "\t-f,--file [name]\t Filename to output IOR.\n" + "\t-p,--package-dir [directory]\t Directory to store packages.\n" + "\t-s,--server-address [address]\t Address of the HTTP server associated with this RM.\n" + "\t-d,--domain-nc [NC]\t Default naming context for domain objects.\n" +#ifdef DANCE_RM_USES_JAWS + "\t--spawn-http\t\t Spawn a JAWS http server, controlled by following options:\n" + "\t--http-port [port]\t Spawn JAWS HTTP server with provided port, default is 5432\n" + "\t--http-threads [number]\t Spawn provided number of threads in HTTP server, default is 1\n" + "\t--http-threading [strategy]\t Use provided threading strategy. POOL (Default), PER_REQUEST, THROTTLE.\n" + "\t--http-io [stratety]\t Use provided I/O strategy. SYNCH (default), ASYNCH.\n" + "\t--http-caching [strategy]\t Use provided caching strategy. NO_CACHE (default), CACHE\n" +#endif + ; + +} + +bool +DAnCE_RepositoryManager_Module::parse_args (int argc, ACE_TCHAR * argv[]) +{ + DANCE_TRACE ("DAnCE_RepositoryManager_Module::parse_args"); + + ACE_Get_Opt get_opts (argc - 1, + argv + 1, + ACE_TEXT(":hd:t:f:p:n:"), + 0, + 0, + ACE_Get_Opt::RETURN_IN_ORDER, + 1); + + get_opts.long_option (ACE_TEXT("help"), 'h', ACE_Get_Opt::NO_ARG); + get_opts.long_option (ACE_TEXT("domain-nc"), 'd', ACE_Get_Opt::ARG_REQUIRED); + get_opts.long_option (ACE_TEXT("file"), 'f', ACE_Get_Opt::ARG_REQUIRED); + get_opts.long_option (ACE_TEXT("threads"), 't', ACE_Get_Opt::ARG_REQUIRED); + get_opts.long_option (ACE_TEXT("package-dir"), 'p', ACE_Get_Opt::ARG_REQUIRED); + get_opts.long_option (ACE_TEXT("name"), 'n', ACE_Get_Opt::ARG_REQUIRED); + get_opts.long_option (ACE_TEXT("server-address"), 's', ACE_Get_Opt::ARG_REQUIRED); +#ifdef DANCE_RM_USES_JAWS + get_opts.long_option (ACE_TEXT("spawn-http"), ACE_Get_Opt::NO_ARG); + get_opts.long_option (ACE_TEXT("http-port"), ACE_Get_Opt::ARG_REQUIRED); + get_opts.long_option (ACE_TEXT("http-threads"), ACE_Get_Opt::ARG_REQUIRED); + get_opts.long_option (ACE_TEXT("http-threading"), ACE_Get_Opt::ARG_REQUIRED); + get_opts.long_option (ACE_TEXT("http-io"), ACE_Get_Opt::ARG_REQUIRED); + get_opts.long_option (ACE_TEXT("http-caching"), ACE_Get_Opt::ARG_REQUIRED); +#endif DANCE_RM_USES_JAWS + + //get_opts.long_option ("help", '?'); + + char c; + while ( (c = get_opts ()) != -1) + { + switch (c) + { + case 'd': + DANCE_DEBUG ((LM_DEBUG, DLINFO "Repository_Manager_Module::parse_args - " + "Binding to provided Domain Naming Context: '%s'\n", + get_opts.opt_arg ())); + this->options_.domain_nc_ = get_opts.opt_arg (); + break; + + case 'f': + DANCE_DEBUG ((LM_DEBUG, DLINFO "Repository_Manager_Module::parse_args - " + "Output filename for IOR is %C\n", + get_opts.opt_arg ())); + this->options_.ior_file_ = get_opts.opt_arg (); + break; + + case 't': + DANCE_DEBUG ((LM_DEBUG, DLINFO "Repository_Manager_Module::parse_args - " + "Number of threads is %C\n", get_opts.opt_arg ())); + this->options_.threads_ = (ACE_OS::atoi (get_opts.opt_arg ())); + break; + + case 'p': + DANCE_DEBUG ((LM_DEBUG, DLINFO "Repository_Manager_Module::parse_args - " + "Package directory is %C\n", + get_opts.opt_arg ())); + this->options_.package_dir_ = get_opts.opt_arg (); + break; + + case 'n': + DANCE_DEBUG ((LM_DEBUG, DLINFO "Repository_Manager_Module::parse_args - " + "Name is %C\n", + get_opts.opt_arg ())); + this->options_.name_ = get_opts.opt_arg (); + break; + + case 's': + DANCE_DEBUG ((LM_DEBUG, DLINFO "Repository_Manager_Module::parse_args - " + "Server address is %C\n", + get_opts.opt_arg ())); + this->options_.server_address_ = get_opts.opt_arg (); + break; + + case 'h': + //case '?': // Display help for use of the server. + //default: + DANCE_ERROR_RETURN ( (LM_ERROR, + this->usage (), + argv [0], c), + false); + break; + + case 0: + if (ACE_OS::strcmp (get_opts.long_option (), ACE_TEXT("spawn-http")) == 0) + { + DANCE_DEBUG ((LM_DEBUG, DLINFO "Repository_Manager_Module::parse_args - " + "Found option to spawn in-process HTTP server\n")); + this->options_.spawn_http_ = true; + } + else if (ACE_OS::strcmp (get_opts.long_option (), ACE_TEXT("http-port")) == 0) + { + DANCE_DEBUG ((LM_DEBUG, DLINFO "Repository_Manager_Module::parse_args - " + "Using %C as the spawned HTTP server port\n", + get_opts.opt_arg ())); + this->options_.spawn_http_ = true; + this->options_.http_port_ = get_opts.opt_arg (); + } + else if (ACE_OS::strcmp (get_opts.long_option (), ACE_TEXT("http-")) == 0) + { + DANCE_DEBUG ((LM_DEBUG, DLINFO "Repository_Manager_Module::parse_args - " + "Using %C as the spawned HTTP number of threads\n", + get_opts.opt_arg ())); + this->options_.spawn_http_ = true; + this->options_.http_threads_ = get_opts.opt_arg (); + } + else if (ACE_OS::strcmp (get_opts.long_option (), ACE_TEXT("http-")) == 0) + { + DANCE_DEBUG ((LM_DEBUG, DLINFO "Repository_Manager_Module::parse_args - " + "Using %C as the spawned HTTP server threading model\n", + get_opts.opt_arg ())); + this->options_.spawn_http_ = true; + this->options_.http_threading_ = get_opts.opt_arg (); + } + else if (ACE_OS::strcmp (get_opts.long_option (), ACE_TEXT("http-")) == 0) + { + DANCE_DEBUG ((LM_DEBUG, DLINFO "Repository_Manager_Module::parse_args - " + "Using %C as the spawned HTTP server IO strategy\n", + get_opts.opt_arg ())); + this->options_.spawn_http_ = true; + this->options_.http_io_ = get_opts.opt_arg (); + } + else if (ACE_OS::strcmp (get_opts.long_option (), ACE_TEXT("http-")) == 0) + { + DANCE_DEBUG ((LM_DEBUG, DLINFO "Repository_Manager_Module::parse_args - " + "Using %C as the spawned HTTP server caching strategy\n", + get_opts.opt_arg ())); + this->options_.spawn_http_ = true; + this->options_.http_caching_ = get_opts.opt_arg (); + } + else + { + DANCE_ERROR ((LM_ERROR, DLINFO "Repository_Manager_Module::parse_args - " + "ERROR: unknown long option %C\n", + get_opts.long_option ())); + } + + break; + + case '\?': + case ':': + DANCE_ERROR ((LM_ERROR, DLINFO "Repository_Manager_Module::parse_args - " + "Options %c:%C requires an argument\n", c, get_opts.opt_opt ())); + break; + + default: + DANCE_DEBUG ((LM_TRACE, DLINFO "Repository_Manager_Module::parse_args - ignoring unknown option %c:%C\n", + c, get_opts.opt_arg ())); + } + + } + + if (this->options_.server_address_ == 0) + { + DANCE_ERROR ((LM_ERROR, DLINFO "Repository_Manager_Module::parse_args - " + "Must provider server address using --server-address option.\n")); + return false; + } + + return true; +} + +CORBA::Object_ptr +DAnCE_RepositoryManager_Module::create_object (CORBA::ORB_ptr orb, + int argc, + ACE_TCHAR *argv[]) +{ + DANCE_TRACE ("DAnCE_RepositoryManager_Module::create_object"); + + try + { + if (CORBA::is_nil(orb)) + { + DANCE_ERROR((LM_ERROR, DLINFO "DAnCE_RepositoryManager_Module::create_object - " + "Attempted to create Repository Manager with a nil orb.\n")); + return CORBA::Object::_nil(); + } + else + { + this->orb_ = CORBA::ORB::_duplicate (orb); + } + + if (ACE_OS::strcmp(orb->id(), this->orb_->id()) != 0) + { + DANCE_DEBUG((LM_TRACE, DLINFO "DAnCE_RepositoryManager_Module::create_object - " + "Resetting NM's orb.\n")); + this->orb_ = CORBA::ORB::_duplicate (orb); + this->domain_nc_ = CosNaming::NamingContext::_nil(); + } + + if (!this->parse_args (argc, argv)) + { + DANCE_ERROR ((LM_ERROR, DLINFO "DAnCE_RepositoryManager_Module::create_object - " + "Failed to parse command line arguments, exiting\n")); + return CORBA::Object::_nil (); + } + + if (this->options_.spawn_http_) + this->spawn_http (); + + this->create_poas (); + + if (this->options_.domain_nc_) + { + try + { + DANCE_DEBUG((LM_TRACE, DLINFO "DAnCE_RepositoryManager_Module::create_object - " + "Resolving DomainNC.\n")); + CORBA::Object_var domain_obj = this->orb_->string_to_object (this->options_.domain_nc_); + if (!CORBA::is_nil (domain_obj.in ())) + { + this->domain_nc_ = CosNaming::NamingContext::_narrow (domain_obj.in()); + if (CORBA::is_nil (this->domain_nc_.in ())) + { + DANCE_ERROR ((LM_ERROR,DLINFO "DAnCE_RepositoryManager_Module::create_object - " + "Narrow to NamingContext return nil for DomainNC.\n")); + return CORBA::Object::_nil (); + } + } + } + catch (CORBA::Exception&) + { + DANCE_DEBUG ((LM_WARNING, DLINFO "DAnCE_RepositoryManager_Module::create_object - " + "DomainNC context not found!\n")); + } + } + + + DANCE_DEBUG ((LM_TRACE, DLINFO "DAnCE_RepositoryManager_Module::create_object - " + "Initializing the IOR Table\n")); + // Initialize IOR table + CORBA::Object_var table_object = orb->resolve_initial_references ("IORTable"); + + IORTable::Table_var adapter = IORTable::Table::_narrow (table_object.in ()); + + if (CORBA::is_nil (adapter.in ())) + { + DANCE_ERROR ((LM_ERROR, DLINFO "DAnCE_RepositoryManager_Module::create_object - " + "Unable to RIR the IORTable.\n")); + return CORBA::Object::_nil (); + } + + + //Creating repository manager servant + DAnCE::RepositoryManagerDaemon_i * rm = new DAnCE::RepositoryManagerDaemon_i (orb, + this->options_.server_address_, + this->options_.package_dir_); + PortableServer::ServantBase_var safe_svt (rm); + + ACE_CString repository_manager_oid; + + if (this->options_.name_ == 0) + repository_manager_oid = "RepositoryManager"; + else + { + repository_manager_oid = this->options_.name_; + repository_manager_oid += ".RepositoryManager"; + } + + // Registering servant in poa + PortableServer::ObjectId_var oid = + PortableServer::string_to_ObjectId (repository_manager_oid.c_str()); + this->rm_poa_->activate_object_with_id (oid, rm); + + // Getting repository manager ior + CORBA::Object_var nm_obj = this->rm_poa_->id_to_reference (oid.in ()); + CORBA::String_var ior = orb->object_to_string (nm_obj.in ()); + + // Binding ior to IOR Table + adapter->bind (repository_manager_oid.c_str (), ior.in ()); + + // Binding repository menager to DomainNC + if (!CORBA::is_nil (this->domain_nc_.in ())) + { + ACE_CString ns_name; + if (this->options_.name_ == 0) + ns_name = "RepositoryManager"; + else ns_name = this->options_.name_; + + DANCE_DEBUG((LM_TRACE, DLINFO "DAnCE_RepositoryManager_Module::create_object - " + "Registering NM in NC as \"%C\".\n", ns_name.c_str ())); + CosNaming::Name name (1); + name.length (1); + name[0].id = CORBA::string_dup (ns_name.c_str ()); + name[0].kind = CORBA::string_dup ("RepositoryManager"); + this->domain_nc_->rebind (name, nm_obj.in ()); + } + + // Writing ior to file + if (0 != this->options_.ior_file_) + { + DANCE_DEBUG ((LM_TRACE, DLINFO "DAnCE_RepositoryManager_Module::create_object - " + "Writing RM IOR %C to file %C.\n", this->options_.ior_file_, ior.in ())); + if (!DAnCE::Repository_Manager::write_IOR (this->options_.ior_file_, ior.in ())) + DANCE_ERROR ((LM_ERROR, DLINFO "DAnCE_RepositoryManager_Module::create_object - " + "Error: Unable to write IOR to file %C\n", + this->options_.ior_file_)); + } + + // Activate POA manager + PortableServer::POAManager_var mgr = this->root_poa_->the_POAManager (); + mgr->activate (); + + // Finishing Deployment part + DANCE_DEBUG ((LM_NOTICE, DLINFO "DAnCE_RepositoryManager_Module::create_object - " + "DAnCE_RepositoryManager is running...\n")); + + DANCE_DEBUG ((LM_DEBUG, DLINFO "DAnCE_RepositoryManager_Module::create_object - " + "RepositoryManager IOR: %s\n", ior.in ())); + + return nm_obj._retn (); + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("DAnCE_RepositoryManager::main\t\n"); + return CORBA::Object::_nil (); + } +} + +void +DAnCE_RepositoryManager_Module::create_poas (void) +{ + DANCE_TRACE("DAnCE_Repository_Manager_Module::create_poas"); + // Get reference to Root POA. + DANCE_DEBUG ((LM_TRACE, DLINFO "DAnCE_RepositoryManager_Module::create_poas - " + "Resolving root POA\n")); + CORBA::Object_var obj = this->orb_->resolve_initial_references ("RootPOA"); + + this->root_poa_ = PortableServer::POA::_narrow (obj.in ()); + + DANCE_DEBUG ((LM_TRACE, DLINFO "DAnCE_RepositoryManager_Module::create_poas - " + "Obtaining the POAManager\n")); + PortableServer::POAManager_var mgr = this->root_poa_->the_POAManager (); + + TAO::Utils::PolicyList_Destroyer policies (2); + policies.length (2); + + try + { + DANCE_DEBUG ((LM_TRACE, DLINFO "DAnCE_RepositoryManager_Module::create_poas - " + "DAnCE_RepositoryManager_Module::create_poas - " + "Creating the \"Repository\" POA.\n")); + + policies[0] = this->root_poa_->create_id_assignment_policy (PortableServer::USER_ID); + policies[1] = this->root_poa_->create_lifespan_policy (PortableServer::PERSISTENT); + this->rm_poa_ = this->root_poa_->create_POA ("Repository", + mgr.in(), + policies); + } + catch (const PortableServer::POA::AdapterAlreadyExists &) + { + DANCE_DEBUG ((LM_INFO, DLINFO "DAnCE_RepositoryManager_Module::create_poas - " + "Using exiswting \"Repository\" POA\n")); + this->rm_poa_ = this->root_poa_->find_POA ("Repository", 0); + } +} + +void +DAnCE_RepositoryManager_Module::spawn_http (void) +{ + DANCE_TRACE ("DAnCE_RepositoryManager_Module::spawn_http"); + + const ACE_TCHAR *name = "HTTP_Server"; + + ACE_CString args; + args += "-p "; + args += this->options_.http_port_; + args += " -n "; + args += this->options_.http_threads_; + args += " -i "; + args += this->options_.http_io_; + args += " -t "; + args += this->options_.http_threading_; + args += " -c "; + args += this->options_.http_caching_; + args += " -b 50 -f THR_NEW_LWP"; + + ACE_Service_Config::current ()->initialize (name, args.c_str ()); +} + +#ifndef BUILD_REPOSITORY_MANAGER_EXE +ACE_FACTORY_DEFINE (DAnCE_RepositoryManager_Module, DAnCE_RepositoryManager_Module) +#endif /*BUILD_REPOSITORY_MANAGER_EXE */ diff --git a/CIAO/DAnCE/RepositoryManager/Repository_Manager_Module.h b/CIAO/DAnCE/RepositoryManager/Repository_Manager_Module.h new file mode 100644 index 00000000000..21804fec10a --- /dev/null +++ b/CIAO/DAnCE/RepositoryManager/Repository_Manager_Module.h @@ -0,0 +1,128 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Repository_Manager_Module.h + * + * $Id$ + * + * @Brief To start RepositoryManager by starter + * + * @author Vinzenz Tornow <vt@prismtech.com> + * @author William R. Otte <wotte@dre.vanderbilt.edu> + */ +//============================================================================= + +#ifndef NODE_MANAGER_MODULE_H +#define NODE_MANAGER_MODULE_H + +#include /**/ "ace/pre.h" + +#include "DAnCE_RepositoryManager_Module_Export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Service_Config.h" +#include "ace/Vector_T.h" +#include "ace/Map_Manager.h" +#include "ace/Null_Mutex.h" +#include "tao/ORB.h" +#include "tao/PortableServer/POAC.h" +#include "orbsvcs/CosNamingC.h" +#include "tao/Object_Loader.h" +#include "Deployment/DAnCE_Loader.h" +#include "DAnCE/Deployment/Deployment_common.h" + +namespace DAnCE +{ + class RepositoryManagerDaemon_i; +} + +/** + * @class Repository_Manager_Module + * + * @brief The shared object that is instantiated when the node manager + * module/library is dynamically loaded. + * + * This class runs the node manager instance + */ +class DAnCE_RepositoryManager_Module_Export DAnCE_RepositoryManager_Module + : public DAnCE::DAnCE_Object_Loader +{ + public: + struct SOptions + { + const ACE_TCHAR * domain_nc_; + const ACE_TCHAR * ior_file_; + size_t threads_; + const ACE_TCHAR * package_dir_; + const ACE_TCHAR * name_; + const ACE_TCHAR * server_address_; + + bool spawn_http_; + const ACE_TCHAR *http_port_; + const ACE_TCHAR *http_threads_; + const ACE_TCHAR *http_threading_; + const ACE_TCHAR *http_io_; + const ACE_TCHAR *http_caching_; + + SOptions() : + domain_nc_ (0), + ior_file_ (0), + threads_ (1), + package_dir_ (ACE_TEXT("RepositoryManager_Packages")), + server_address_ (0), + spawn_http_ (false), + http_port_ ("5432"), + http_threads_ ("1"), + http_threading_ ("POOL"), + http_io_ ("SYNCH"), + http_caching_ ("NO_CACHE") + { + } + }; + + /// Constructor. + DAnCE_RepositoryManager_Module (void); + + /// Destructor. + ~DAnCE_RepositoryManager_Module (void); + + /// Overload the base class method to create a new instance + /// of a DAnCE_RepositoryManager_Module object. + virtual CORBA::Object_ptr create_object (CORBA::ORB_ptr orb, + int argc, + ACE_TCHAR *argv []); + + virtual const ACE_TCHAR * usage (void); + + virtual bool parse_args (int argc, ACE_TCHAR *argv []); + + private: + void create_poas (void); + + void spawn_http (void); + + /// Here we store the servants. + typedef ACE_Map_Manager < ACE_CString, + DAnCE::RepositoryManagerDaemon_i *, + ACE_Null_Mutex > Servant_Map; + + Servant_Map rm_map_; + + CORBA::ORB_var orb_; + CosNaming::NamingContext_var domain_nc_; + + SOptions options_; + + PortableServer::POA_var root_poa_; + PortableServer::POA_var rm_poa_; +}; + +ACE_FACTORY_DECLARE (DAnCE_RepositoryManager_Module, DAnCE_RepositoryManager_Module) + +#include /**/ "ace/post.h" + +#endif /* NODE_MANAGER_MODULE_H */ diff --git a/CIAO/DAnCE/RepositoryManager/ZIP_Wrapper.cpp b/CIAO/DAnCE/RepositoryManager/ZIP_Wrapper.cpp index 382b11d3082..7d8c6f2f256 100644 --- a/CIAO/DAnCE/RepositoryManager/ZIP_Wrapper.cpp +++ b/CIAO/DAnCE/RepositoryManager/ZIP_Wrapper.cpp @@ -23,7 +23,7 @@ #include "ace/OS_Memory.h" //for ACE_NEW* macros #include <string> -#include "unzip.h" +#include "minizip/unzip.h" #define MAXFILENAME (256) #define CASESENSITIVITY (0) #define WRITEBUFFERSIZE (8192) diff --git a/CIAO/DAnCE/RepositoryManager/ZIP_Wrapper.h b/CIAO/DAnCE/RepositoryManager/ZIP_Wrapper.h index 291f99cdba6..cb1be6c2843 100644 --- a/CIAO/DAnCE/RepositoryManager/ZIP_Wrapper.h +++ b/CIAO/DAnCE/RepositoryManager/ZIP_Wrapper.h @@ -28,7 +28,7 @@ #include "ace/OS_NS_fcntl.h" //for open #include "ace/OS_NS_sys_stat.h" //for filesize and mkdir -#include "unzip.h" +#include "minizip/unzip.h" /** diff --git a/CIAO/MPC/config/dance_repository_manager.mpb b/CIAO/MPC/config/dance_repository_manager.mpb new file mode 100644 index 00000000000..b453179b05f --- /dev/null +++ b/CIAO/MPC/config/dance_repository_manager.mpb @@ -0,0 +1,4 @@ +project : dance_logger, dance_deployment_svnt, ciao_config_handlers, ccm_stub, dance_repository_manager_base, naming, iortable, utils { + after += DAnCE_RepositoryManager + libs += DAnCE_RepositoryManager +}
\ No newline at end of file diff --git a/CIAO/MPC/config/dance_repository_manager_base.mpb b/CIAO/MPC/config/dance_repository_manager_base.mpb new file mode 100644 index 00000000000..c73a4562005 --- /dev/null +++ b/CIAO/MPC/config/dance_repository_manager_base.mpb @@ -0,0 +1,5 @@ +feature(jaws) { + includes += $(ACE_ROOT)/apps + libs += JAWS + macros += DANCE_RM_USES_JAWS +}
\ No newline at end of file |