summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormxiong <mxiong@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2005-07-29 04:15:58 +0000
committermxiong <mxiong@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2005-07-29 04:15:58 +0000
commit0715efb1c39c68b0ab7665e8699d4b5f5f3d5c87 (patch)
treedf1a505d6bad3eb32849c4fe78a472ed344c9083
parentcc8966d7ef12aedde220d71ecb4a3f16d1c0bc35 (diff)
downloadATCD-0715efb1c39c68b0ab7665e8699d4b5f5f3d5c87.tar.gz
ChangeLogTag: Thu Jul 28 23:00:11 2005 Ming Xiong <mxiong@dre.vanderbilt.edu>
-rw-r--r--TAO/CIAO/ChangeLog22
-rw-r--r--TAO/CIAO/DAnCE/new_RepositoryManager/Options.cpp54
-rw-r--r--TAO/CIAO/DAnCE/new_RepositoryManager/Options.h14
-rw-r--r--TAO/CIAO/DAnCE/new_RepositoryManager/README.txt2
-rw-r--r--TAO/CIAO/DAnCE/new_RepositoryManager/RepositoryManager.cpp132
-rw-r--r--TAO/CIAO/DAnCE/new_RepositoryManager/RepositoryManager.idl13
-rw-r--r--TAO/CIAO/DAnCE/new_RepositoryManager/RepositoryManager_Impl.cpp575
-rw-r--r--TAO/CIAO/DAnCE/new_RepositoryManager/RepositoryManager_Impl.h229
-rw-r--r--TAO/CIAO/DAnCE/new_RepositoryManager/ZIP_Wrapper.cpp330
-rw-r--r--TAO/CIAO/DAnCE/new_RepositoryManager/ZIP_Wrapper.h99
-rw-r--r--TAO/CIAO/DAnCE/new_RepositoryManager/new_RepositoryManager.mpc26
11 files changed, 1167 insertions, 329 deletions
diff --git a/TAO/CIAO/ChangeLog b/TAO/CIAO/ChangeLog
index e3e33f6adaa..d65c9c0a737 100644
--- a/TAO/CIAO/ChangeLog
+++ b/TAO/CIAO/ChangeLog
@@ -1,9 +1,25 @@
+Thu Jul 28 23:00:11 2005 Ming Xiong <mxiong@dre.vanderbilt.edu>
+
+ * DAnCE/new_RepositoryManager/Options.cpp
+ * DAnCE/new_RepositoryManager/Options.h
+ * DAnCE/new_RepositoryManager/README.txt
+ * DAnCE/new_RepositoryManager/RepositoryManager.cpp
+ * DAnCE/new_RepositoryManager/RepositoryManager.idl
+ * DAnCE/new_RepositoryManager/RepositoryManager_Impl.cpp
+ * DAnCE/new_RepositoryManager/RepositoryManager_Impl.h
+ * DAnCE/new_RepositoryManager/ZIP_Wrapper.cpp
+ * DAnCE/new_RepositoryManager/ZIP_Wrapper.h
+ * DAnCE/new_RepositoryManager/new_RepositoryManager.mpc
+
+ Checked in the changes to new_RepositoryManager
+
+
Fri Jul 29 03:52:11 2005 William Otte <wotte@dre.vanderbilt.edu>
- * DAnCE/Plan_Launcher/Plan_Launcher.mpc
+ * DAnCE/Plan_Launcher/Plan_Launcher.mpc
- Made is such that Plan_Launcher_Impl library gets generated
- and installed.
+ Made is such that Plan_Launcher_Impl library gets generated
+ and installed.
Wed Jul 28 15:18:14 2005 Ming Xiong <mxiong@dre.vanderbilt.edu>
diff --git a/TAO/CIAO/DAnCE/new_RepositoryManager/Options.cpp b/TAO/CIAO/DAnCE/new_RepositoryManager/Options.cpp
index 04c2987e27d..a8dc818bbb6 100644
--- a/TAO/CIAO/DAnCE/new_RepositoryManager/Options.cpp
+++ b/TAO/CIAO/DAnCE/new_RepositoryManager/Options.cpp
@@ -21,7 +21,7 @@ Options::instance (void)
void
Options::parse_args (int argc, ACE_TCHAR *argv[])
{
- ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("n:l:a:idps"));
+ ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("n:l:u:ifds"));
int c;
@@ -34,53 +34,55 @@ Options::parse_args (int argc, ACE_TCHAR *argv[])
case 'd':
this->delete_ = true;
break;
- case 'p':
- this->plan_ = true;
+ case 'f':
+ this->find_ = true;
break;
- case 's':
+ case 's':
this->shutdown_ = true;
break;
case 'n':
- this->package_ = get_opt.opt_arg ();
+ this->name_ = get_opt.opt_arg ();
break;
case 'l':
- this->local_path_ = get_opt.opt_arg ();
+ this->path_ = get_opt.opt_arg ();
break;
- case 'a':
- this->artifact_ = get_opt.opt_arg ();
+ case 'u':
+ this->uuid_ = get_opt.opt_arg ();
break;
// Usage fallthrough.
default:
- this->usage ();
-
+ this->usage ();
+
}
- if ((this->package_ == "") && (this->shutdown_ == false))
- this->usage ();
- if (this->package_ != "")
+ if ((this->name_ == "") && (this->shutdown_ == false) && (this->uuid_ == ""))
+ this->usage ();
+ else if (this->name_ != "")
{
- if (!(this->install_ || this->plan_ || this->delete_ || (this->artifact_ != "")))
- this->usage ();
- else if (this->install_ && this->local_path_ == "")
- this->usage ();
+ if (!(this->install_ || this->find_ || this->delete_))
+ this->usage ();
+ else if (this->install_ && this->path_ == "")
+ this->usage ();
}
+ else if (this->uuid_ != "" && !this->find_)
+ this->usage ();
}
void Options::usage (void)
{
- ACE_DEBUG ((LM_DEBUG, "OPTIONS: -s <shutdown> -n <:package> [-i <install> -l <:local_path>] \
- [-d <delete>] [-p <plan>] [-a <artifact>]\n"));
+ ACE_DEBUG ((LM_DEBUG, "OPTIONS: -s <shutdown> -n <:name> [-i <install> -l <:path>] \
+ [-d <delete>] [-f <find>] [-u <:uuid>]\n"));
ACE_OS::exit (1);
}
Options::Options (void)
- : package_ (""),
- local_path_ (""),
- artifact_ (""),
- delete_ (false),
- install_ (false),
- plan_ (false),
- shutdown_ (false)
+ : name_ (""),
+ uuid_ (""),
+ path_ (""),
+ delete_ (false),
+ install_ (false),
+ find_ (false),
+ shutdown_ (false)
{
}
diff --git a/TAO/CIAO/DAnCE/new_RepositoryManager/Options.h b/TAO/CIAO/DAnCE/new_RepositoryManager/Options.h
index f9439579846..0f8f5a928c2 100644
--- a/TAO/CIAO/DAnCE/new_RepositoryManager/Options.h
+++ b/TAO/CIAO/DAnCE/new_RepositoryManager/Options.h
@@ -34,14 +34,14 @@ public:
void parse_args (int argc, ACE_TCHAR *argv[]);
// parses commandline arguments
- ACE_CString package_;
+ ACE_CString name_;
// Name of package
- ACE_CString local_path_;
- // specifies the local path for install
+ ACE_CString uuid_;
+ // Name of package
- ACE_CString artifact_;
- // Implementation Artifact requested
+ ACE_CString path_;
+ // specifies the local path for install
bool delete_;
// delete the package_ name
@@ -49,8 +49,8 @@ public:
bool install_;
// installs the package_ name
- bool plan_;
- // retrieves the DeploymentPlan specified in the package_ name
+ bool find_;
+ // installs the package_ name
bool shutdown_;
//shutdown the RepositoryManagerDemon
diff --git a/TAO/CIAO/DAnCE/new_RepositoryManager/README.txt b/TAO/CIAO/DAnCE/new_RepositoryManager/README.txt
index c93ee19a083..29495032206 100644
--- a/TAO/CIAO/DAnCE/new_RepositoryManager/README.txt
+++ b/TAO/CIAO/DAnCE/new_RepositoryManager/README.txt
@@ -28,5 +28,3 @@ to compile the idl with the tao_idl compiler:
tao_idl -GI new_RepositoryManager.idl -I%TAO_ROOT% -I%TAO_ROOT%\tao -I%TAO_ROOT%\orbsvcs -I%CIAO_ROOT%\DAnCE\ciao
-
-
diff --git a/TAO/CIAO/DAnCE/new_RepositoryManager/RepositoryManager.cpp b/TAO/CIAO/DAnCE/new_RepositoryManager/RepositoryManager.cpp
index 1e1d92d2fb3..ebe07839060 100644
--- a/TAO/CIAO/DAnCE/new_RepositoryManager/RepositoryManager.cpp
+++ b/TAO/CIAO/DAnCE/new_RepositoryManager/RepositoryManager.cpp
@@ -1,13 +1,13 @@
// $Id$
-/**
- * @file RepositoryManager.cpp
+/***
+ * file RepositoryManager.cpp
*
- * @author Stoyan Paunov <spaunov@isis.vanderbilt.edu>
+ * author Stoyan Paunov <spaunov@isis.vanderbilt.edu>
**/
-#include "new_RepositoryManager_Impl.h"
+#include "RepositoryManager_Impl.h"
#include "ace/OS_NS_stdio.h"
#include "ace/streams.h"
#include "ace/Auto_Ptr.h"
@@ -16,11 +16,11 @@ using namespace std;
namespace
{
- ///name of the file holding the IOR of the RM
- const char * rm_ior = "RepositoryManagerDeamon.ior";
+///name of the file holding the IOR of the RM
+const char * rm_ior = "RepositoryManagerDeamon.ior";
- ///default number of worker threads to run in the multi-threaded RM
- const unsigned int nthreads = 3;
+///default number of worker threads to run in the multi-threaded RM
+const unsigned int nthreads = 3;
}
@@ -53,75 +53,75 @@ private:
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
- try
- {
- //init the ORB
- CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
-
- //Get the root POA object
- CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA");
-
- //downcast to POA type
- PortableServer::POA_var root_poa = PortableServer::POA::_narrow (obj.in ());
-
- //activate the POA manager
- PortableServer::POAManager_var mgr = root_poa->the_POAManager ();
- mgr->activate ();
-
- //create a servant
- CIAO_new_RepositoryManagerDaemon_i* repo = new CIAO_new_RepositoryManagerDaemon_i (orb.in ());
-
- //trasfer ownership to the POA
- PortableServer::ServantBase_var distributor_owner_transfer(repo);
-
- //register and implicitly activate servant
- CIAO::new_RepositoryManagerDaemon_var RepositoryManagerDeamon = repo->_this ();
-
- //convert the IOR to string
- CORBA::String_var ior = orb->object_to_string (RepositoryManagerDeamon.in ());
-
- //output the IOR to a file
- FILE* ior_out = ACE_OS::fopen (rm_ior, "w");
-
- if (ior_out == 0)
+ try
+ {
+ //init the ORB
+ CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
+
+ //Get the root POA object
+ CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA");
+
+ //downcast to POA type
+ PortableServer::POA_var root_poa = PortableServer::POA::_narrow (obj.in ());
+
+ //activate the POA manager
+ PortableServer::POAManager_var mgr = root_poa->the_POAManager ();
+ mgr->activate ();
+
+ //create a servant
+ CIAO_RepositoryManagerDaemon_i* repo = new CIAO_RepositoryManagerDaemon_i (orb.in ());
+
+ //trasfer ownership to the POA
+ PortableServer::ServantBase_var distributor_owner_transfer(repo);
+
+ //register and implicitly activate servant
+ CIAO::RepositoryManagerDaemon_var RepositoryManagerDeamon = repo->_this ();
+
+ //convert the IOR to string
+ CORBA::String_var ior = orb->object_to_string (RepositoryManagerDeamon.in ());
+
+ //output the IOR to a file
+ FILE* ior_out = ACE_OS::fopen (rm_ior, "w");
+
+ if (ior_out == 0)
ACE_ERROR_RETURN ((LM_ERROR,
"Cannot open output file for writing IOR: %s",
rm_ior),
- 1);
-
- ACE_OS::fprintf (ior_out, "%s", ior.in ());
- ACE_OS::fclose (ior_out);
-
- Worker worker (orb.in ());
- if (worker.activate (THR_NEW_LWP | THR_JOINABLE,
- nthreads) != 0)
- ACE_ERROR_RETURN ((LM_ERROR,
- "Cannot activate client threads\n"),
- 1);
+ 1);
+
+ ACE_OS::fprintf (ior_out, "%s", ior.in ());
+ ACE_OS::fclose (ior_out);
- worker.thr_mgr ()->wait ();
+ Worker worker (orb.in ());
+ if (worker.activate (THR_NEW_LWP | THR_JOINABLE,
+ nthreads) != 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Cannot activate client threads\n"),
+ 1);
- ACE_DEBUG ((LM_DEBUG, "event loop finished\n"));
+ worker.thr_mgr ()->wait ();
- //done
- return 0;
+ ACE_DEBUG ((LM_DEBUG, "event loop finished\n"));
- //Start accepting requests
- orb->run ();
+ //done
+ return 0;
- //allow objects registered with the POA ot get cleaned-up
- root_poa->destroy (1, 1);
+ //Start accepting requests
+ orb->run ();
- //shutdown the orb
- orb->shutdown (1);
+ //allow objects registered with the POA ot get cleaned-up
+ root_poa->destroy (1, 1);
- return 0;
- }
- catch (CORBA::Exception &ex) {
- cerr << "CORBA Exception: " << ex << endl;
+ //shutdown the orb
+ orb->shutdown (1);
+
+ return 0;
+ }
+ catch (CORBA::Exception &ex) {
+ cerr << "CORBA Exception: " << ex << endl;
- return 1;
- }
+ return 1;
+ }
return 0;
diff --git a/TAO/CIAO/DAnCE/new_RepositoryManager/RepositoryManager.idl b/TAO/CIAO/DAnCE/new_RepositoryManager/RepositoryManager.idl
new file mode 100644
index 00000000000..5293ed4fcbe
--- /dev/null
+++ b/TAO/CIAO/DAnCE/new_RepositoryManager/RepositoryManager.idl
@@ -0,0 +1,13 @@
+// $Id$
+
+#include "Deployment.idl"
+
+module CIAO
+{
+ interface RepositoryManagerDaemon : Deployment::RepositoryManager
+ {
+ // Shutdown the daemon process.
+ oneway void shutdown ();
+ };
+};
+
diff --git a/TAO/CIAO/DAnCE/new_RepositoryManager/RepositoryManager_Impl.cpp b/TAO/CIAO/DAnCE/new_RepositoryManager/RepositoryManager_Impl.cpp
new file mode 100644
index 00000000000..8d755b711b1
--- /dev/null
+++ b/TAO/CIAO/DAnCE/new_RepositoryManager/RepositoryManager_Impl.cpp
@@ -0,0 +1,575 @@
+
+
+
+//***************************IMPORTANT**********************************
+//
+// The following implementation is not meant to be production
+// quality code. Actualy it is a quicky hacked up solution that
+// needs much improvement. The current goal is to provide an
+// implementation that conforms to the spec defined RepositoryManager
+// We will be using this code only for testing purposes. There WILL be
+// MAJOR performance improvements in the future. The code also needs
+// exhaustive testing because I have not tested all test cases.
+//
+// Best regards, Stoyan
+//
+//***************************IMPORTANT**********************************
+
+
+
+
+
+
+// -*- C++ -*-
+//
+// $Id$
+
+// **** Code generated by the The ACE ORB (TAO) IDL Compiler ****
+// TAO and the TAO IDL Compiler have been developed by:
+// Center for Distributed Object Computing
+// Washington University
+// St. Louis, MO
+// USA
+// http://www.cs.wustl.edu/~schmidt/doc-center.html
+// and
+// Distributed Object Computing Laboratory
+// University of California at Irvine
+// Irvine, CA
+// USA
+// http://doc.ece.uci.edu/
+// and
+// Institute for Software Integrated Systems
+// Vanderbilt University
+// Nashville, TN
+// USA
+// http://www.isis.vanderbilt.edu/
+//
+// Information about TAO is available at:
+// http://www.cs.wustl.edu/~schmidt/TAO.html
+
+// TAO_IDL - Generated from
+// .\be\be_codegen.cpp:925
+
+
+
+
+
+///====================================================================
+// filename: RepositoryManager_Impl.cpp
+// Author: Stoyan Paunov spaunov@isis.vanderbilt.edu
+//
+
+#include "RepositoryManager_Impl.h"
+
+#include "ace/OS_NS_fcntl.h" //for open
+#include "ace/OS_NS_unistd.h" //for close
+#include "ace/OS_NS_sys_stat.h" //for filesize and fstat and mkdir
+#include "ace/OS_NS_string.h" //for ACE_CString
+
+
+//to remove a file or dir from the local filesystem need remove () from stdio.h
+// ---> need to include ace/OS_NS_stdio.h which would include the correct file for any OS!
+#include "ace/OS_NS_stdio.h"
+
+#include "ZIP_Wrapper.h" //Wrapper around zzip
+#include "ace/Containers_T.h" //for ACE_Double_Linked_List
+#include "ace/Malloc_Allocator.h" //for ACE_New_Allocator needed by the doubly link list
+
+//for the PackageConfiguration parsing
+#include "Config_Handlers/STD_PC_Intf.h"
+#include "Config_Handlers/Deployment.hpp"
+#include "ciao/Deployment_DataC.h"
+#include "Config_Handlers/XML_Helper.h"
+#include "xercesc/dom/DOM.hpp"
+
+#include "ace/Thread.h" //for obtaining the ID of the current thread
+#include "ace/OS_NS_stdlib.h" //for itoa ()
+
+
+
+#include <iostream>
+using namespace std;
+
+
+
+// Implementation skeleton constructor
+CIAO_RepositoryManagerDaemon_i::CIAO_RepositoryManagerDaemon_i (CORBA::ORB_ptr the_orb)
+: the_orb_ (CORBA::ORB::_duplicate (the_orb))
+{
+ //create directory in which the packages will be stored
+
+ ACE_OS::mkdir(RM_STORAGE_PATH);
+ //if dir already exists a -1 is returned
+ //we ignore this, just need to make sure the directory exists
+}
+
+// Implementation skeleton destructor
+CIAO_RepositoryManagerDaemon_i::~CIAO_RepositoryManagerDaemon_i (void)
+{
+ this->names_.unbind_all ();
+ this->uuids_.unbind_all ();
+}
+
+void CIAO_RepositoryManagerDaemon_i::shutdown (
+
+ )
+ ACE_THROW_SPEC ((
+ CORBA::SystemException
+ ))
+{
+ // Add your implementation here
+ this->names_.unbind_all ();
+ this->uuids_.unbind_all ();
+
+ this->the_orb_->shutdown (0);
+}
+
+
+void CIAO_RepositoryManagerDaemon_i::installPackage (
+ const char * installationName,
+ const char * location
+ )
+ ACE_THROW_SPEC ((
+ CORBA::SystemException,
+ ::Deployment::NameExists,
+ ::Deployment::PackageError
+ ))
+{
+ // Add your implementation here
+
+ ACE_Hash_Map_Entry <ACE_CString, ACE_CString> *entry;
+
+ if (this->names_.find (ACE_CString (installationName), entry) == 0)
+ ACE_THROW (Deployment::NameExists ());
+
+ //check is URL or local
+ //download or load into memory
+
+ size_t length = 0;
+ CORBA::Octet* file = 0;
+
+ if (strstr (location, "http://"))
+ ACE_THROW (CORBA::NO_IMPLEMENT ());
+ else
+ {
+ //read the package from disk and store in the RM directory
+ //see if you can substiture this with a memory mapped file
+ //for better perofrmance (mimic zero copy here)
+ file = read_from_disk (location, length);
+
+ if (!file)
+ ACE_THROW (CORBA::INTERNAL ());
+ }
+
+ //need to make this an absolute path since I am changing the working dir
+ char temp[512];
+ char* cwd = ACE_OS::getcwd (temp, 512);
+ ACE_CString path (cwd);
+ path += "/";
+ path += RM_STORAGE_PATH;
+ path += "/";
+ path += installationName;
+ path += ".cpk";
+
+ //Store the package in the local RM dir for future retrieval
+ if (this->write_to_disk (path.c_str (), file, length) == -1)
+ ACE_THROW (CORBA::INTERNAL ());
+
+ Deployment::PackageConfiguration_var pc = retrieve_PC( const_cast<char*> (path.c_str ()), cwd);
+
+ //insert the package into the database
+ this->names_.bind (ACE_CString (installationName), path);
+
+ //ALSO NEED THE UUID here
+ this->uuids_.bind (ACE_CString (pc->UUID), path);
+
+ cout << pc->label << endl;
+ cout << pc->UUID << endl;
+}
+
+void CIAO_RepositoryManagerDaemon_i::createPackage (
+ const char * installationName,
+ const ::Deployment::PackageConfiguration & package,
+ const char * baseLocation,
+ ::CORBA::Boolean replace
+ )
+ ACE_THROW_SPEC ((
+ CORBA::SystemException,
+ ::Deployment::NameExists,
+ ::Deployment::PackageError
+ ))
+{
+ // Add your implementation here
+ ACE_THROW (CORBA::NO_IMPLEMENT ());
+}
+
+::Deployment::PackageConfiguration * CIAO_RepositoryManagerDaemon_i::findPackageByName (
+ const char * name
+ )
+ ACE_THROW_SPEC ((
+ CORBA::SystemException,
+ ::Deployment::NoSuchName
+ ))
+{
+ // Add your implementation here
+
+ // Find out if the PackageConfiguration was installed in the repository,
+ // return it if found or throw and exception otherwise
+
+ ACE_Hash_Map_Entry <ACE_CString, ACE_CString> *entry = 0;
+
+ if (this->names_.find (ACE_CString (name), entry) != 0)
+ ACE_THROW (Deployment::NoSuchName ());
+ //PackageConfiguration was not found
+
+ char temp[512];
+ char* cwd = ACE_OS::getcwd (temp, 512);
+
+ Deployment::PackageConfiguration_var pc = retrieve_PC(const_cast<char*> (entry->int_id_.c_str ()), cwd);
+
+ return pc._retn ();
+}
+
+::Deployment::PackageConfiguration * CIAO_RepositoryManagerDaemon_i::findPackageByUUID (
+ const char * UUID
+ )
+ ACE_THROW_SPEC ((
+ CORBA::SystemException,
+ ::Deployment::NoSuchName
+ ))
+{
+ // Add your implementation here
+
+ //NOTE: The following code actually works but I have not gotten
+ //the DELETE to remove the UUIDs and I am not allowing this code
+ //to be used for right now because the RM stays in an inconsistent
+ //state. A package can be deleted but it is still retrievable by is UUID.
+ ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0);
+
+
+ // Find out if the PackageConfiguration was installed in the repository,
+ // return it if found or throw and exception otherwise
+
+ ACE_Hash_Map_Entry <ACE_CString, ACE_CString> *entry = 0;
+
+ if (this->uuids_.find (ACE_CString (UUID), entry) != 0)
+ ACE_THROW (Deployment::NoSuchName ());
+ //PackageConfiguration was not found
+
+ char temp[512];
+ char* cwd = ACE_OS::getcwd (temp, 512);
+
+ Deployment::PackageConfiguration_var pc = retrieve_PC(const_cast<char*> (entry->int_id_.c_str ()), cwd);
+
+ return pc._retn ();
+}
+
+::CORBA::StringSeq * CIAO_RepositoryManagerDaemon_i::findNamesByType (
+ const char * type
+ )
+ ACE_THROW_SPEC ((
+ CORBA::SystemException
+ ))
+{
+ // Add your implementation here
+ ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0);
+}
+
+::CORBA::StringSeq * CIAO_RepositoryManagerDaemon_i::getAllNames (
+
+ )
+ ACE_THROW_SPEC ((
+ CORBA::SystemException
+ ))
+{
+ // Add your implementation here
+
+ CORBA::ULong num_entries = this->names_.current_size ();
+ CORBA::StringSeq_var seq = new CORBA::StringSeq (num_entries);
+
+ CORBA::ULong index = 0;
+ for (PCMap_Iterator iter = this->names_.begin ();
+ iter != this->names_.end () && index < num_entries;
+ iter++)
+
+ seq[index] = const_cast<char*> (((*iter).int_id_).c_str ()); //this looks hideous, but as lond as it works!
+
+
+ return seq._retn (); //release the underlying CORBA::StringSeq
+}
+
+::CORBA::StringSeq * CIAO_RepositoryManagerDaemon_i::getAllTypes (
+
+ )
+ ACE_THROW_SPEC ((
+ CORBA::SystemException
+ ))
+{
+ // Add your implementation here
+ ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0);
+}
+
+void CIAO_RepositoryManagerDaemon_i::deletePackage (
+ const char * installationName
+ )
+ ACE_THROW_SPEC ((
+ CORBA::SystemException,
+ ::Deployment::NoSuchName
+ ))
+{
+ // Add your implementation here
+
+ ACE_Hash_Map_Entry <ACE_CString, ACE_CString> *entry;
+
+ if (this->names_.find (ACE_CString (installationName), entry) != 0)
+ ACE_THROW (Deployment::NoSuchName ());
+ else
+ this->names_.unbind (installationName);
+
+ //do the same for the UUID!!!!
+ //TODO: NEED TO DO THIS LATER
+
+
+ //actually delete the package here!
+ // I need to figure out how to do that without causing some race condition
+ bool purge = false;
+ if (purge)
+ {
+ ACE_CString path (RM_STORAGE_PATH);
+ path += "/";
+ path += installationName;
+ path += ".cpk";
+
+ remove (path.c_str ());
+ }
+}
+
+//==========================================HELPER METHODS========================================================
+
+Deployment::PackageConfiguration* CIAO_RepositoryManagerDaemon_i::retrieve_PC (char* package, char* cwd)
+{
+ char temp[128];
+ unsigned int thread_id = ACE_Thread::self ();
+ char* PID = ACE_OS::itoa (thread_id, 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_necessary_files (package,
+ PID,
+ pcd_name) < 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ "(%P|%t) RepositoryManager: error extracting necessary files\n"));
+ ACE_THROW (CORBA::INTERNAL ());
+ }
+
+ Deployment::PackageConfiguration_var pc;
+ //parse the PCD to make sure that there are no package errors
+ ACE_TRY
+ {
+ CIAO::Config_Handlers::STD_PC_Intf intf (pcd_name.c_str ());
+
+ pc = intf.get_PC ();
+ }
+ ACE_CATCHALL
+ {
+ ACE_ERROR ((LM_ERROR,
+ "(%P|%t) RepositoryManager: Error parsing the PCD\n"));
+ ACE_THROW (Deployment::PackageError ());
+ }
+ ACE_ENDTRY;
+ //able to parse the PC. So lets install the package in the repo
+
+ //change back the the old working dir
+ ACE_OS::chdir (cwd);
+
+ //we no longer need the descriptors, so lets erase them!
+ 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 ();
+}
+
+
+
+//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
+
+int CIAO_RepositoryManagerDaemon_i::extract_necessary_files (char* package, char* PID, ACE_CString& pcd_name)
+{
+ //create a ZIP wrapper
+ ZIP_Wrapper zip;
+
+ //create a doubly link list
+ ACE_New_Allocator allocator;
+ ACE_Double_Linked_List<ZIP_File_Info> list (&allocator);
+
+
+ char temp[512];
+ char* cwd = ACE_OS::getcwd (temp, 512);
+
+ //get the list of files in the package and figure out the names of all necessary files
+ if (!(zip.file_list_info (package, list)))
+ return -1;
+
+ 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"))
+ {
+ if (ACE_OS::strstr (inf->name_.c_str (), ".pcd"))
+ pcd_name = inf->name_.c_str () + skip_len;
+
+ //extract the descriptor from the package
+ ACE_Message_Block file (0,0);
+ if (!zip.get_file(const_cast<char*> (package),
+ const_cast<char*> (inf->name_.c_str ()),
+ file))
+ {
+ ACE_TEXT ("[RM::install] Unable to retrieve file!\n");
+ return -1;
+ }
+
+
+ //write the file to disk
+ if(!this->write_to_disk (inf->name_.c_str () + skip_len, file))
+ {
+ ACE_TEXT ("[RM::install] Unable to write out descriptor to disk!\n");
+ return -1;
+ }
+ }
+ //deallocate the head of the filename list
+ delete inf;
+ }
+
+}
+
+
+//---------------------------------------------------------------------
+//These are a bit obsolete but until I am sure I will keep them
+
+//This function attempts to write a sequence of bytes to
+//a specified location. A -1 is returned in the case of an error
+//and a 1 upon success
+
+int CIAO_RepositoryManagerDaemon_i::write_to_disk (
+ const char* full_path,
+ const CORBA::Octet* buffer,
+ size_t length
+ )
+{
+
+ // Open a file handle to the local filesystem
+ ACE_HANDLE handle = ACE_OS::open (full_path, O_CREAT | O_TRUNC | O_WRONLY);
+ if (handle == ACE_INVALID_HANDLE)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("[RM::write_to_disk] file creation error")),
+ -1);
+
+ //write the data to the file
+ if (ACE_OS::write (handle, buffer, length) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("[RM::write_to_disk] file write error")),
+ -1);
+
+ // Close the file handle
+ ACE_OS::close (handle);
+
+ return 1;
+}
+
+
+//This function attempts to read a sequence of bytes into an
+//ACE_Message_Block from a specified location. A -1 is returned
+//in the case of an error and a 1 upon success
+
+int CIAO_RepositoryManagerDaemon_i::write_to_disk
+ (const char* full_path,
+ ACE_Message_Block& mb,
+ bool replace
+ )
+{
+
+ ACE_stat stat;
+
+ if (ACE_OS::stat(full_path, &stat) != -1 && !replace)
+ return 0;
+
+ // Open a file handle to the local filesystem
+ ACE_HANDLE handle = ACE_OS::open (full_path, O_CREAT | O_TRUNC | O_WRONLY);
+ if (handle == ACE_INVALID_HANDLE)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("[RM::write_to_disk] file creation error")),
+ -1);
+
+ //write the data to the file
+ for (ACE_Message_Block * curr = &mb; curr != 0; curr = curr->cont ())
+ if (ACE_OS::write_n (handle, curr->rd_ptr(), curr->length()) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("write error")),
+ -1);
+
+ // Close the file handle
+ ACE_OS::close (handle);
+
+ return 1;
+}
+
+//This function attempts to read a sequence of bytes from a specified
+//location and returns an octet sequence. A -1 is returned
+//in the case of an error and a 1 upon success
+
+CORBA::Octet* CIAO_RepositoryManagerDaemon_i::read_from_disk (
+ const char* full_path,
+ size_t &length
+ )
+{
+ //open the file
+
+ ACE_HANDLE handle = ACE_OS::open (full_path, O_RDONLY);
+ if (handle == ACE_INVALID_HANDLE)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("[RM::read_from_disk] file open error")),
+ 0);
+
+ ACE_stat file_info;
+
+ ACE_OS::fstat (handle, &file_info);
+
+ CORBA::Octet* buffer = new CORBA::Octet[file_info.st_size];
+
+ if (buffer == 0)
+ return 0;
+
+ //read the contents of the file into the buffer
+ if (ACE_OS::read_n (handle, buffer, file_info.st_size) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("[RM::write_to_disk] file write error")),
+ 0);
+
+ // Close the file handle
+ ACE_OS::close (handle);
+
+ length = file_info.st_size;
+ return buffer;
+}
+
diff --git a/TAO/CIAO/DAnCE/new_RepositoryManager/RepositoryManager_Impl.h b/TAO/CIAO/DAnCE/new_RepositoryManager/RepositoryManager_Impl.h
new file mode 100644
index 00000000000..a58132bc537
--- /dev/null
+++ b/TAO/CIAO/DAnCE/new_RepositoryManager/RepositoryManager_Impl.h
@@ -0,0 +1,229 @@
+// -*- C++ -*-
+//
+// $Id$
+
+// **** Code generated by the The ACE ORB (TAO) IDL Compiler ****
+// TAO and the TAO IDL Compiler have been developed by:
+// Center for Distributed Object Computing
+// Washington University
+// St. Louis, MO
+// USA
+// http://www.cs.wustl.edu/~schmidt/doc-center.html
+// and
+// Distributed Object Computing Laboratory
+// University of California at Irvine
+// Irvine, CA
+// USA
+// http://doc.ece.uci.edu/
+// and
+// Institute for Software Integrated Systems
+// Vanderbilt University
+// Nashville, TN
+// USA
+// http://www.isis.vanderbilt.edu/
+//
+// Information about TAO is available at:
+// http://www.cs.wustl.edu/~schmidt/TAO.html
+
+// TAO_IDL - Generated from
+// .\be\be_codegen.cpp:859
+
+
+
+#ifndef REPOSITORYMANAGERI_H_
+#define REPOSITORYMANAGERI_H_
+
+///====================================================================
+// filename: RepositoryManager_Impl.h
+// Author: Stoyan Paunov spaunov@isis.vanderbilt.edu
+//
+// Purpose: This class is the implementation class for the spec
+// complient RepositoryManager
+//
+
+
+#include "RepositoryManagerS.h"
+#include "DeploymentS.h" //added for the deployment stuff
+
+#include "ace/Hash_Map_Manager.h" //for the ACE_Hash_Map_Manager
+#include "ace/Null_Mutex.h" //for ACE_Null_Mutex
+#include "ace/RW_Mutex.h" //for ACE_RW_Mutex
+#include "ace/OS_NS_string.h" //for ACE_CString
+#include "ace/SString.h"
+
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+
+namespace
+{
+///DIRECTORY WHERE THE PACKAGES WILL BE STORED LOCALLY
+const static char* RM_STORAGE_PATH = "./RepositoryDir";
+}
+
+class CIAO_RepositoryManagerDaemon_i : public virtual POA_CIAO::RepositoryManagerDaemon, public virtual PortableServer::RefCountServantBase
+{
+public:
+ //Constructor
+ CIAO_RepositoryManagerDaemon_i (CORBA::ORB_ptr the_orb);
+
+ //Destructor
+ virtual ~CIAO_RepositoryManagerDaemon_i (void);
+
+ virtual
+ void shutdown (
+
+ )
+ ACE_THROW_SPEC ((
+ CORBA::SystemException
+ ));
+
+ virtual
+ void installPackage (
+ const char * installationName,
+ const char * location
+ )
+ ACE_THROW_SPEC ((
+ CORBA::SystemException,
+ ::Deployment::NameExists,
+ ::Deployment::PackageError
+ ));
+
+ virtual
+ void createPackage (
+ const char * installationName,
+ const ::Deployment::PackageConfiguration & package,
+ const char * baseLocation,
+ ::CORBA::Boolean replace
+ )
+ ACE_THROW_SPEC ((
+ CORBA::SystemException,
+ ::Deployment::NameExists,
+ ::Deployment::PackageError
+ ));
+
+ virtual
+ ::Deployment::PackageConfiguration * findPackageByName (
+ const char * name
+ )
+ ACE_THROW_SPEC ((
+ CORBA::SystemException,
+ ::Deployment::NoSuchName
+ ));
+
+ virtual
+ ::Deployment::PackageConfiguration * findPackageByUUID (
+ const char * UUID
+ )
+ ACE_THROW_SPEC ((
+ CORBA::SystemException,
+ ::Deployment::NoSuchName
+ ));
+
+ virtual
+ ::CORBA::StringSeq * findNamesByType (
+ const char * type
+ )
+ ACE_THROW_SPEC ((
+ CORBA::SystemException
+ ));
+
+ virtual
+ ::CORBA::StringSeq * getAllNames (
+
+ )
+ ACE_THROW_SPEC ((
+ CORBA::SystemException
+ ));
+
+ virtual
+ ::CORBA::StringSeq * getAllTypes (
+
+ )
+ ACE_THROW_SPEC ((
+ CORBA::SystemException
+ ));
+
+ virtual
+ void deletePackage (
+ const char * installationName
+ )
+ ACE_THROW_SPEC ((
+ CORBA::SystemException,
+ ::Deployment::NoSuchName
+ ));
+
+ protected:
+
+ ///function to parse and return the PackageConfiguration
+ Deployment::PackageConfiguration* retrieve_PC (char* package, char* cwd);
+
+ ///function to extract all necessary files for parsing the PackageConfiguration
+ ///descriptor and populating the idl struct.
+ ///return 1 on success
+ /// -1 on error
+
+ int extract_necessary_files (char* package,
+ char* PID,
+ ACE_CString& pcd_name);
+
+ ///function that writes out a file to a specified location on the hand disk
+ ///returns 1 on success
+ /// -1 on error
+
+ int write_to_disk (const char* full_path,
+ const CORBA::Octet* buffer,
+ size_t length
+ );
+
+
+ ///function that writes out a file to a specified location on the hand disk
+ ///returns 1 on success
+ /// 0 on already exists and replace == false
+ /// -1 on error
+
+ int write_to_disk (const char* full_path,
+ ACE_Message_Block& mb,
+ bool replace = true
+ );
+
+
+ ///function to read the contents of a file from disk into a CORBA::OctetSeq
+ ///returns a pointer to a CORBA::Octet buffer and updated the lenght on success
+ /// 0 on failure
+
+ CORBA::Octet* read_from_disk (const char* full_path, size_t &lenght);
+
+ 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;
+
+ //a hash map that associates the names of PackageConfigurations with their location
+ PCMap names_;
+
+ //a hash map that associates the UUIDs of PackageConfigurations with their location
+ PCMap uuids_;
+
+ CORBA::ORB_var the_orb_;
+
+};
+
+
+#endif /* REPOSITORYMANAGERI_H_ */
+
diff --git a/TAO/CIAO/DAnCE/new_RepositoryManager/ZIP_Wrapper.cpp b/TAO/CIAO/DAnCE/new_RepositoryManager/ZIP_Wrapper.cpp
index b0c2688345c..bd103747ebe 100644
--- a/TAO/CIAO/DAnCE/new_RepositoryManager/ZIP_Wrapper.cpp
+++ b/TAO/CIAO/DAnCE/new_RepositoryManager/ZIP_Wrapper.cpp
@@ -1,47 +1,48 @@
// $Id$
-/**
- * @file ZIP_Wrapper.cpp
- * @author Stoyan Paunov <spaunov@isis.vanderbilt.edu
- *
- * Purpose: to provide a wrapper around ZZIPlib for easy handling of
- * ZIP archives. This wrapper can me used as an auxiliary class that
- * allows a program to become ZIP-aware.
- */
-
-#include "ace/Containers_T.h" //for ACE_Double_Linked_List
-#include "ace/Message_Block.h" //for ACE_Message_Block
-
-#include "ace/OS_NS_fcntl.h" //for open
-#include "ace/OS_NS_unistd.h" //for close
+///====================================================================
+// filename: ZIP_Wrapper.cpp
+// Author: Stoyan Paunov spaunov@isis.vanderbilt.edu
+//
+// Purpose: to provide a wrapper around ZZIPlib for easy handling of
+// ZIP archives. This wrapper can me used as an auxiliary
+// class that allows a program to become ZIP-aware
+
+
+
+#include "ace/Containers_T.h" //for ACE_Double_Linked_List
+#include "ace/Message_Block.h" //for ACE_Message_Block
+
+#include "ace/OS_NS_fcntl.h" //for open
+#include "ace/OS_NS_unistd.h" //for close
#include "ace/OS_NS_sys_stat.h" //for filesize and mkdir
#include <string>
-#include <memory> //for auto_ptr
+#include <memory> //for auto_ptr
/////////////////////////////////////////////////////////////////////////////
//NOTE: some #defines problems with zzip & ACE - put these 2 lines on top!!!!
/////////////////////////////////////////////////////////////////////////////
-#include "zziplib.h" //for ZZIP
+#include "zziplib.h" //for ZZIP
#include "ZIP_Wrapper.h"
//ZIP_File_Info constructor
ZIP_File_Info::ZIP_File_Info (char* name, size_t size)
- : name_ (name),
- size_ (size),
- next_ (0),
- prev_ (0)
+ : name_ (name),
+ size_ (size),
+ next_ (0),
+ prev_ (0)
{
}
//ZIP_File_Info default constructor
ZIP_File_Info::ZIP_File_Info ()
- : name_ (""),
- size_ (0),
- next_ (0),
- prev_ (0)
+ : name_ (""),
+ size_ (0),
+ next_ (0),
+ prev_ (0)
{
}
@@ -49,100 +50,101 @@ ZIP_File_Info::ZIP_File_Info ()
//get a list of the files in the archive
size_t ZIP_Wrapper::file_list_info (char* zip_name, ACE_Double_Linked_List<ZIP_File_Info> &list)
{
- size_t num = 0; //number of files in archive
- ZZIP_DIR * dir; //pointer to a zip archive
- ZZIP_DIRENT * dir_entry; //pointer to a file within the archive
+ size_t num = 0; //number of files in archive
+ ZZIP_DIR * dir; //pointer to a zip archive
+ ZZIP_DIRENT * dir_entry; //pointer to a file within the archive
- //open the zip archive
- dir = zzip_opendir(zip_name);
+ //open the zip archive
+ dir = zzip_opendir(zip_name);
- if (!dir)
- return false;
+ if (!dir)
+ return 0;
- //read each dir entry and show one line of info per file
- while (dir_entry = zzip_readdir (dir))
- {
- //retrieve the name of the file
- char* name = dir_entry->d_name;
+ //read each dir entry and show one line of info per file
+ while (dir_entry = zzip_readdir (dir))
+ {
+ //retrieve the name of the file
+ char* name = dir_entry->d_name;
- //remove the subpath part if any NOTE: Lunux style assumed, need to check
- //while(char* next = strstr(name, "/"))
- // name = next + 1;
+ //remove the subpath part if any NOTE: Lunux style assumed, need to check
+ //while(char* next = strstr(name, "/"))
+ // name = next + 1;
- list.insert_tail (new ZIP_File_Info (name, dir_entry->st_size));
- }
+ list.insert_tail (new ZIP_File_Info (name, dir_entry->st_size));
+ num++;
+ }
- zzip_closedir(dir);
- return 0;
+ zzip_closedir(dir);
+ return num;
}
//get file and store it into an ACE_Message_Block
bool ZIP_Wrapper::get_file (char* accessor, ACE_Message_Block &file)
{
- bool return_code = true;
+ bool return_code = true;
- ZZIP_FILE* zip_file = zzip_open (accessor, O_RDONLY| O_BINARY);
+ ZZIP_FILE* zip_file = zzip_open (accessor, O_RDONLY| O_BINARY);
- if (! zip_file)
- return false;
-
- int num_read;
- file.size(BUFSIZ);
- ACE_Message_Block* head = &file;
+ if (! zip_file)
+ return false;
+
+ int num_read;
+ file.size(BUFSIZ);
+ ACE_Message_Block* head = &file;
- // read chunks of 16 bytes into buf and print them to stdout
- while (0 < (num_read = zzip_read(zip_file, head->wr_ptr(), head->size())))
+ // read chunks of 16 bytes into buf and print them to stdout
+ while (0 < (num_read = zzip_read(zip_file, head->wr_ptr(), head->size())))
{
- head->wr_ptr (num_read);
- head->cont (new ACE_Message_Block (BUFSIZ));
- head = head->cont ();
- }
+ head->wr_ptr (num_read);
+ head->cont (new ACE_Message_Block (BUFSIZ));
+ head = head->cont ();
+ }
- if (num_read == -1)
- return_code = false;
+ if (num_read == -1)
+ return_code = false;
- zzip_file_close (zip_file);
-
- return return_code;
+ zzip_file_close (zip_file);
+
+ return return_code;
}
bool ZIP_Wrapper::get_file (char* archive_path, char* filename, ACE_Message_Block &file)
{
- bool return_code = true;
- ZZIP_DIR * dir; //pointer to a zip archive
+ bool return_code = true;
+ ZZIP_DIR * dir; //pointer to a zip archive
- //open the zip archive
- dir = zzip_opendir(archive_path);
+ //open the zip archive
+ dir = zzip_opendir(archive_path);
- if (!dir)
- return false;
+ if (!dir)
+ return false;
- //get the handle to the file
- ZZIP_FILE* zip_file = zzip_file_open (dir, filename, O_RDONLY | O_BINARY);
+ //get the handle to the file
+ ZZIP_FILE* zip_file = zzip_file_open (dir, filename, O_RDONLY | O_BINARY);
- if (!zip_file)
- return false;
-
- int num_read;
- file.size(BUFSIZ);
- ACE_Message_Block* head = &file;
+ if (!zip_file)
+ return false;
+
+ int num_read;
+ file.size(BUFSIZ);
+ ACE_Message_Block* head = &file;
- //read the file into the ACE_Message_Block
- while (0 < (num_read = zzip_read(zip_file, head->wr_ptr(), head->size())))
+ //read the file into the ACE_Message_Block
+ while (0 < (num_read = zzip_read(zip_file, head->wr_ptr(), head->size())))
{
- head->wr_ptr (num_read);
- head->cont (new ACE_Message_Block (BUFSIZ));
- head = head->cont ();
- }
-
- if (num_read == -1)
- return_code = false;
-
- zzip_file_close (zip_file);
- zzip_closedir(dir);
-
- return return_code;
+ head->wr_ptr (num_read);
+ head->cont (new ACE_Message_Block (BUFSIZ));
+ head = head->cont ();
+ }
+
+ if (num_read == -1)
+ return_code = false;
+
+ zzip_file_close (zip_file);
+ zzip_closedir(dir);
+
+ return return_code;
}
@@ -153,90 +155,90 @@ bool ZIP_Wrapper::get_file (char* archive_path, char* filename, ACE_Message_Bloc
//the path is assumed to be an existing directory
bool ZIP_Wrapper::uncompress (char* zip_archive, char* path)
{
- ZZIP_DIR * dir; //pointer to a zip archive
- ZZIP_DIRENT * dir_entry; //pointer to a file within the archive
- ZZIP_FILE* file; //pointer to a zip file within an archive
+ ZZIP_DIR * dir; //pointer to a zip archive
+ ZZIP_DIRENT * dir_entry; //pointer to a file within the archive
+ ZZIP_FILE* file; //pointer to a zip file within an archive
- //open the zip archive
- dir = zzip_opendir(zip_archive);
+ //open the zip archive
+ dir = zzip_opendir(zip_archive);
- if (!dir)
- return false;
-
- //??????
- //check if a directory with the name if the archive exists
- //If not, create it. Else, existing files will be truncated upon open.
- //??????
-
- //get the name of the archive
- std::string arch_dir (path);
- arch_dir += "/";
- arch_dir += zip_archive;
- arch_dir[arch_dir.length () - 4] = '\0'; //NOTE: Assumes .zip extension
-
- //create directory
- ACE_OS::mkdir(arch_dir.c_str()); //if dir exists -1 is returned and ignored
-
- //read each dir entry and show one line of info per file
- while (dir_entry = zzip_readdir (dir))
- {
- //retrieve the name of the file
- char* name = dir_entry->d_name;
-
- //remove the subpath part if any NOTE: Lunux style assumed, need to check
- while(char* next = strstr(name, "/"))
- name = next + 1;
-
- //open a zip handle
- file = zzip_file_open(dir, dir_entry->d_name, O_RDONLY | O_BINARY);
- if (!file)
- return false;
-
- //allocate buffer
-
- //TODO: change to ACE_NEW_RETURN
- std::auto_ptr<char> buffer;
- buffer.reset ( new char [dir_entry->st_size + 1]);
-
- //read in the data
- zzip_read(file, &(*buffer), dir_entry->st_size);
-
- //close the zip handle
- zzip_file_close (file);
-
- //create file name + path to open
- std::string file_path (arch_dir.c_str ()); //NOTE: need the c-style char to stop at '\0'
- file_path += "/";
- file_path += name;
-
- //print out the file to be uncompressed
- ACE_OS::write(ACE_STDOUT, file_path.c_str (), file_path.length () );
- ACE_OS::write(ACE_STDOUT, "\n", 1);
-
- // Open a file handle to the local filesystem
- ACE_HANDLE handle = ACE_OS::open (file_path.c_str (), O_CREAT | O_TRUNC | O_WRONLY);
- if (handle == ACE_INVALID_HANDLE)
- ACE_ERROR_RETURN ((LM_ERROR,
+ if (!dir)
+ return false;
+
+ //??????
+ //check if a directory with the name if the archive exists
+ //If not, create it. Else, existing files will be truncated upon open.
+ //??????
+
+ //get the name of the archive
+ std::string arch_dir (path);
+ arch_dir += "/";
+ arch_dir += zip_archive;
+ arch_dir[arch_dir.length () - 4] = '\0'; //NOTE: Assumes .zip extension
+
+ //create directory
+ ACE_OS::mkdir(arch_dir.c_str()); //if dir exists -1 is returned and ignored
+
+ //read each dir entry and show one line of info per file
+ while (dir_entry = zzip_readdir (dir))
+ {
+ //retrieve the name of the file
+ char* name = dir_entry->d_name;
+
+ //remove the subpath part if any NOTE: Lunux style assumed, need to check
+ while(char* next = strstr(name, "/"))
+ name = next + 1;
+
+ //open a zip handle
+ file = zzip_file_open(dir, dir_entry->d_name, O_RDONLY | O_BINARY);
+ if (!file)
+ return false;
+
+ //allocate buffer
+
+ //TODO: change to ACE_NEW_RETURN
+ std::auto_ptr<char> buffer;
+ buffer.reset ( new char [dir_entry->st_size + 1]);
+
+ //read in the data
+ zzip_read(file, &(*buffer), dir_entry->st_size);
+
+ //close the zip handle
+ zzip_file_close (file);
+
+ //create file name + path to open
+ std::string file_path (arch_dir.c_str ()); //NOTE: need the c-style char to stop at '\0'
+ file_path += "/";
+ file_path += name;
+
+ //print out the file to be uncompressed
+ ACE_OS::write(ACE_STDOUT, file_path.c_str (), file_path.length () );
+ ACE_OS::write(ACE_STDOUT, "\n", 1);
+
+ // Open a file handle to the local filesystem
+ ACE_HANDLE handle = ACE_OS::open (file_path.c_str (), O_CREAT | O_TRUNC | O_WRONLY);
+ if (handle == ACE_INVALID_HANDLE)
+ ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ("[uncompress] file creation error")),
- 0);
+ 0);
- //write the uncompressed data to the file
- if (ACE_OS::write (handle, &(*buffer), dir_entry->st_size) == -1)
+ //write the uncompressed data to the file
+ if (ACE_OS::write (handle, &(*buffer), dir_entry->st_size) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ("[uncompress] file write error")),
- 0);
+ 0);
- // Close the file handle
- ACE_OS::close (handle);
+ // Close the file handle
+ ACE_OS::close (handle);
- //free buffer
- //TODO: check if auto_ptr has a fxn to release the memory before scope is exited
- //delete [] buffer;
+ //free buffer
+ //TODO: check if auto_ptr has a fxn to release the memory before scope is exited
+ //delete [] buffer;
- }
+ }
- zzip_closedir(dir);
- return true;
+ zzip_closedir(dir);
+ return true;
}
diff --git a/TAO/CIAO/DAnCE/new_RepositoryManager/ZIP_Wrapper.h b/TAO/CIAO/DAnCE/new_RepositoryManager/ZIP_Wrapper.h
index 217f7ba72a0..d25e23e5331 100644
--- a/TAO/CIAO/DAnCE/new_RepositoryManager/ZIP_Wrapper.h
+++ b/TAO/CIAO/DAnCE/new_RepositoryManager/ZIP_Wrapper.h
@@ -1,73 +1,74 @@
// $Id$
-/**
- * @file ZIP_Wrapper.h
- * @author Stoyan Paunov <spaunov@isis.vanderbilt.edu>
- *
- * Purpose: to provide a wrapper around ZZIPlib for easy handling of
- * ZIP archives. This wrapper can me used as an auxiliary class that
- * allows a program to become ZIP-aware
- */
+///====================================================================
+// filename: ZIP_Wrapper.h
+// Author: Stoyan Paunov spaunov@isis.vanderbilt.edu
+//
+// Purpose: to provide a wrapper around ZZIPlib for easy handling of
+// ZIP archives. This wrapper can me used as an auxiliary
+// class that allows a program to become ZIP-aware
+
#ifndef _ZIP_WRAPPER_H_
#define _ZIP_WRAPPER_H_
-#include "ace/Containers_T.h" //for ACE_Double_Linked_List
-#include "ace/Message_Block.h" //for ACE_Message_Block
+#include "ace/Containers_T.h" //for ACE_Double_Linked_List
+#include "ace/Message_Block.h" //for ACE_Message_Block
-#include "ace/OS_NS_fcntl.h" //for open
+#include "ace/OS_NS_fcntl.h" //for open
#include "ace/OS_NS_sys_stat.h" //for filesize and mkdir
#include <string>
-
-/**
- * @class ZIP_File_Info
- * This class is used as a carrier of information about entities
- * residing inside a ZIP archive
- */
+
+///===================================================================
+//Class definition for ZIP_File_Info
+//
+// Description: This class is used as a carrier of information
+// about entities residing inside a ZIP archive
+
class ZIP_File_Info
{
public:
- std::string name_;
- size_t size_;
- ZIP_File_Info* next_;
- ZIP_File_Info* prev_;
+ std::string name_;
+ size_t size_;
+ ZIP_File_Info* next_;
+ ZIP_File_Info* prev_;
- ZIP_File_Info (char* name, size_t size);
- ZIP_File_Info ();
+ ZIP_File_Info (char* name, size_t size);
+ ZIP_File_Info ();
};
-
-/**
- * @class ZIP_Wrapper
- *
- * This class is the actual workhorse that provides all of the
- * necessary functionality
- */
+
+///===================================================================
+//Class definition for ZIP_Wrapper
+//
+//@Description: This class is the actual workhorse that provides all of
+// the necessary functionality
+
class ZIP_Wrapper
{
public:
- /// get a list of the files in the archive
- size_t file_list_info (char* zip_name, ACE_Double_Linked_List<ZIP_File_Info> &list);
-
- /// get file and store it into an ACE_Message_Block
- /// need to provide the correct accessor string. It formed by the ZIP_Options
- /// singleton on argument parsing and stored in ZIP_Options::instance()->read_file_
- /// ACE_Message_Block is null-terminated, but this is not reflected in the size!
- bool get_file (char* accessor, ACE_Message_Block &file);
-
- /// additional get_file function to avert subdirectory traversal problems with
- /// zziplib accessors
- bool get_file (char* archive_path, char* filename, ACE_Message_Block &file);
-
- /// uncompress
- /// the uncompress format will be
- /// mkdir(name of zip archive)
- /// store all files in that directory.
- /// the path is assumed to be an existing directory
- bool uncompress (char* zip_archive, char* path = "");
+ //get a list of the files in the archive
+ size_t file_list_info (char* zip_name, ACE_Double_Linked_List<ZIP_File_Info> &list);
+
+ //get file and store it into an ACE_Message_Block
+ //need to provide the correct accessor string. It formed by the ZIP_Options
+ //singleton on argument parsing and stored in ZIP_Options::instance()->read_file_
+ //ACE_Message_Block is null-terminated, but this is not reflected in the size!
+ bool get_file (char* accessor, ACE_Message_Block &file);
+
+ //additional get_file function to avert subdirectory traversal problems with
+ //zziplib accessors
+ bool get_file (char* archive_path, char* filename, ACE_Message_Block &file);
+
+ //uncompress
+ //the uncompress format will be
+ //mkdir(name of zip archive)
+ //store all files in that directory.
+ //the path is assumed to be an existing directory
+ bool uncompress (char* zip_archive, char* path = "");
};
#endif
diff --git a/TAO/CIAO/DAnCE/new_RepositoryManager/new_RepositoryManager.mpc b/TAO/CIAO/DAnCE/new_RepositoryManager/new_RepositoryManager.mpc
index e3816a1d7c7..b8ac78bc0be 100644
--- a/TAO/CIAO/DAnCE/new_RepositoryManager/new_RepositoryManager.mpc
+++ b/TAO/CIAO/DAnCE/new_RepositoryManager/new_RepositoryManager.mpc
@@ -1,7 +1,10 @@
-// $Id$
+// -*- MPC -*-
+// RepositoryManager.mpc v1.0 Stoyan
+//RepositoryManager project: implementation of a repository manager
+//compleint with the D&C spec
-project (new_RepositoryManager) : ciao_server_dnc,ciao_deployment_svnt, ciao_deployment_stub, taoexe, xerces, exceptions, zzip, zlib {
+project (spec_RepositoryManager) : ciao_server_dnc,ciao_deployment_svnt, ciao_deployment_stub, taoexe, xerces, exceptions, zzip, zlib {
exename = RepositoryManagerDeamon
after += XSC_Config_Handlers
@@ -10,36 +13,35 @@ project (new_RepositoryManager) : ciao_server_dnc,ciao_deployment_svnt, ciao_dep
requires += zzip zlib
IDL_Files {
- new_RepositoryManager.idl
+ RepositoryManager.idl
}
Source_Files {
- new_RepositoryManagerC.cpp
- new_RepositoryManagerS.cpp
+ RepositoryManagerC.cpp
+ RepositoryManagerS.cpp
ZIP_Wrapper.cpp
RepositoryManager.cpp
- new_RepositoryManager_Impl.cpp
+ RepositoryManager_Impl.cpp
}
}
-// -*- MPC -*-
-// RMadmin.mpc v1.0 Stoyan
+// RMadmin project: a sample client for the RM.
-project (RMAdmin) : ciao_client_dnc, ciao_deployment_stub, exceptions {
+project (spec_RMAdmin) : ciao_client_dnc, ciao_deployment_stub, exceptions {
exename = RMadmin
- after += new_RepositoryManager
+ after += RepositoryManager
after += XSC_Config_Handlers
libs += XSC_Config_Handlers
libs += CIAO_DnC_Client
IDL_Files {
- new_RepositoryManager.idl
+ RepositoryManager.idl
}
Source_Files {
RMadmin.cpp
- new_RepositoryManagerC.cpp
+ RepositoryManagerC.cpp
Options.cpp
}
}