summaryrefslogtreecommitdiff
path: root/TAO/CIAO/DAnCE/RepositoryManager
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/CIAO/DAnCE/RepositoryManager')
-rw-r--r--TAO/CIAO/DAnCE/RepositoryManager/HTTP_Client.cpp59
-rw-r--r--TAO/CIAO/DAnCE/RepositoryManager/HTTP_Client.h72
-rw-r--r--TAO/CIAO/DAnCE/RepositoryManager/HTTP_Handler.cpp203
-rw-r--r--TAO/CIAO/DAnCE/RepositoryManager/HTTP_Handler.h86
-rw-r--r--TAO/CIAO/DAnCE/RepositoryManager/Options.cpp111
-rw-r--r--TAO/CIAO/DAnCE/RepositoryManager/Options.h78
-rw-r--r--TAO/CIAO/DAnCE/RepositoryManager/PC_Updater.cpp269
-rw-r--r--TAO/CIAO/DAnCE/RepositoryManager/PC_Updater.h113
-rw-r--r--TAO/CIAO/DAnCE/RepositoryManager/PC_Updater_T.cpp20
-rw-r--r--TAO/CIAO/DAnCE/RepositoryManager/PC_Updater_T.h40
-rw-r--r--TAO/CIAO/DAnCE/RepositoryManager/README.txt30
-rw-r--r--TAO/CIAO/DAnCE/RepositoryManager/RM_Helper.cpp253
-rw-r--r--TAO/CIAO/DAnCE/RepositoryManager/RM_Helper.h101
-rw-r--r--TAO/CIAO/DAnCE/RepositoryManager/RMadmin.cpp274
-rw-r--r--TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager.cpp166
-rw-r--r--TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager.idl (renamed from TAO/CIAO/DAnCE/RepositoryManager/RepositoryManagerDaemon.idl)3
-rw-r--r--TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager.mpc50
-rw-r--r--TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager_Impl.cpp1215
-rw-r--r--TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager_Impl.h432
-rw-r--r--TAO/CIAO/DAnCE/RepositoryManager/Repository_Manager.cpp305
-rw-r--r--TAO/CIAO/DAnCE/RepositoryManager/Repository_Manager_conf.h33
-rw-r--r--TAO/CIAO/DAnCE/RepositoryManager/URL_Parser.cpp103
-rw-r--r--TAO/CIAO/DAnCE/RepositoryManager/URL_Parser.h68
-rw-r--r--TAO/CIAO/DAnCE/RepositoryManager/Update_Plan.cpp462
-rw-r--r--TAO/CIAO/DAnCE/RepositoryManager/Update_Plan.h123
-rw-r--r--TAO/CIAO/DAnCE/RepositoryManager/ZIP_Wrapper.cpp299
-rw-r--r--TAO/CIAO/DAnCE/RepositoryManager/ZIP_Wrapper.h86
27 files changed, 1232 insertions, 3822 deletions
diff --git a/TAO/CIAO/DAnCE/RepositoryManager/HTTP_Client.cpp b/TAO/CIAO/DAnCE/RepositoryManager/HTTP_Client.cpp
deleted file mode 100644
index 73a8071f305..00000000000
--- a/TAO/CIAO/DAnCE/RepositoryManager/HTTP_Client.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-// $Id$
-
-// HTTP_Client.cpp, Stoyan
-
-#include "HTTP_Client.h"
-#include "HTTP_Handler.h"
-#include "ace/OS_NS_string.h"
-
-HTTP_Client::HTTP_Client (void)
-{
-}
-
-HTTP_Client::~HTTP_Client (void)
-{
- this->close ();
-}
-
-// initialize address and filename. No network i/o in open
-int
-HTTP_Client::open (const ACE_TCHAR *filename,
- const ACE_TCHAR *hostname,
- u_short port)
-{
- filename_ = ACE_OS::strdup (filename);
- inet_addr_.set (port, hostname);
- return 0;
-}
-
-// read from connection length bytes from offset, into Message block
-int
-HTTP_Client::read (ACE_Message_Block *mb)
-{
-
- // Create a HTTP_Client Reader
- HTTP_Reader HTTP_reader (mb, filename_);
- HTTP_Handler *brp = &HTTP_reader;
-
- // Connect to the server
- if (connector_.connect (brp, inet_addr_) == -1)
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "HTTP_Client::read():Connector error"), -1);
-
- return HTTP_reader.byte_count ();
-
-}
-
-// close down the HTTP_Client
-int
-HTTP_Client::close (void)
-{
-
- if (filename_)
- {
- ACE_OS::free ((void *) filename_);
- filename_ = 0;
- }
- return 0;
-
-}
-
diff --git a/TAO/CIAO/DAnCE/RepositoryManager/HTTP_Client.h b/TAO/CIAO/DAnCE/RepositoryManager/HTTP_Client.h
deleted file mode 100644
index ac0f9cbea92..00000000000
--- a/TAO/CIAO/DAnCE/RepositoryManager/HTTP_Client.h
+++ /dev/null
@@ -1,72 +0,0 @@
-
-/* -*- C++ -*- */
-
-//=============================================================================
-/**
- * @file HTTP_Client.h
- *
- * $Id$
- *
- * This is the HTTP_Client class, which is the API for doing file
- * uploads/downloads.
- *
- * @author Stoyan Paunov
- */
-//=============================================================================
-
-
-#ifndef HTTP_Client_H
-#define HTTP_Client_H
-
-
-#include "ace/INET_Addr.h"
-#include "ace/Svc_Handler.h"
-#include "ace/SOCK_Connector.h"
-#include "ace/Connector.h"
-#include "ace/Message_Block.h"
-#include "HTTP_Handler.h"
-
-/**
- * @class HTTP_Client
- *
- * @brief HTTP_Client is intended to provide application API to
- * classes that wish to do network i/o at a very
- * high level of abstraction.
- *
- * This class provides the ability to retrieve data from
- * the network, of specified length and offset, and potentially
- * use any protocol "under the hood" to do so. It currently
- * uses HTTP. See HTTP_Handler also.
- */
-class HTTP_Client
-{
-public:
- HTTP_Client (void);
- ~HTTP_Client (void);
-
- /// Initializes the class with the given filename, hostname and port.
- /// it should be called with the filename, before any read/write calls
- int open (const ACE_TCHAR *filename,
- const ACE_TCHAR *hostname = ACE_DEFAULT_SERVER_HOST,
- u_short port = 80);
-
- /// Starts a connection, and reads a file from the server into
- /// Message_Block mb
- int read (ACE_Message_Block *mb);
-
- /// Frees memory allocated for filename.
- int close ();
-
-private:
- /// Store the internet address of the server
- ACE_INET_Addr inet_addr_;
-
- /// The filename
- ACE_TCHAR *filename_;
-
- /// The connector endpoint to initiate the client connection
- ACE_Connector<HTTP_Handler, ACE_SOCK_CONNECTOR> connector_;
-
-};
-
-#endif /* HTTP_Client_H */
diff --git a/TAO/CIAO/DAnCE/RepositoryManager/HTTP_Handler.cpp b/TAO/CIAO/DAnCE/RepositoryManager/HTTP_Handler.cpp
deleted file mode 100644
index ffd85ca1ebf..00000000000
--- a/TAO/CIAO/DAnCE/RepositoryManager/HTTP_Handler.cpp
+++ /dev/null
@@ -1,203 +0,0 @@
-// $Id$
-
-// HTTP_Handler.cpp, Stoyan
-
-#include "HTTP_Handler.h"
-#include "ace/OS_NS_stdio.h"
-#include "ace/OS_NS_string.h"
-#include "ace/OS_NS_strings.h"
-
-// Empty constructor for compliance with new Connector behavior.
-HTTP_Handler::HTTP_Handler (void)
-{
-}
-
-// Always use this constructor
-HTTP_Handler::HTTP_Handler (ACE_Message_Block * mb,
- ACE_TCHAR *filename) :
- mb_ (mb),
- filename_ (ACE_OS::strdup (filename)),
- bytecount_ (0)
-{
-}
-
-HTTP_Handler::~HTTP_Handler (void)
-{
- if (filename_)
- {
- ACE_OS::free (filename_);
- filename_ = 0;
- }
-}
-
-// Called by Connector after connection is established
-int
-HTTP_Handler::open (void *)
-{
- if (this->send_request () != 0)
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "HTTP_Handler::open():send_request failed\n"), -1);
-
- if (this->receive_reply () != 0)
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "HTTP_Handler::open():receive_reply failed\n"), -1);
- return 0;
-
-}
-
-// No-op
-int
-HTTP_Handler::close (u_long)
-{
- return 0;
-}
-
-// Always overridden by the derived classes
-int
-HTTP_Handler::send_request (void)
-{
- return -1;
-}
-
-// Always overridden by the derived classes
-int
-HTTP_Handler::receive_reply (void)
-{
- return -1;
-}
-
-// used to retrieve the number of bytes read/written by the
-// last operation on the Blob
-size_t
-HTTP_Handler::byte_count (void)
-{
- return bytecount_;
-}
-
-// Reader **************************************************
-
-HTTP_Reader::HTTP_Reader (ACE_Message_Block * mb,
- ACE_TCHAR *filename,
- const char *request_prefix,
- const char *request_suffix) :
- HTTP_Handler (mb, filename),
- request_prefix_ (request_prefix),
- request_suffix_ (request_suffix)
-{
-}
-
-// Send the HTTP request
-int
-HTTP_Reader::send_request (void)
-{
- char mesg [MAX_HEADER_SIZE];
-
- // Check to see if the request is too big
- if (MAX_HEADER_SIZE < (ACE_OS::strlen (request_prefix_)
- + ACE_OS::strlen (filename_)
- + ACE_OS::strlen (request_suffix_) + 4))
- ACE_ERROR_RETURN((LM_ERROR,"Request too large!"), -1);
-
- // Create a message to send to the server requesting retrieval of the file
- int len = ACE_OS::sprintf (mesg, "%s %s %s", request_prefix_, filename_, request_suffix_);
-
- // Send the message to server
- if (peer ().send_n (mesg, len) != len)
- ACE_ERROR_RETURN((LM_ERROR,"Error sending request\n"), -1);
-
-
- return 0;
-}
-
-// Recieve the HTTP Reply
-int
-HTTP_Reader::receive_reply (void)
-{
- size_t num_recvd = 0;
- char buf [MTU+1];
- char *buf_ptr = 0;
- size_t bytes_read = 0;
-
- // Receive the first MTU bytes and strip the header off.
- // Note that we assume that the header will fit into MTU bytes.
-
- if (peer ().recv_n (buf, MTU, 0, &num_recvd) >= 0)
- {
- //Make sure that response type is 200 OK
- if (ACE_OS::strstr (buf,"200 OK") == 0)
- ACE_ERROR_RETURN ((LM_ERROR,
- "HTTP_Reader::receiveReply(): Response is not 200 OK\n" ), -1);
-
- // Search for the header termination string "\r\n\r\n", or "\n\n". If
- // found, move past it to get to the data portion.
- if ((buf_ptr = ACE_OS::strstr (buf,"\r\n\r\n")) != 0)
- buf_ptr += 4;
- else if ((buf_ptr = ACE_OS::strstr (buf, "\n\n")) != 0) //for compatibility with JAWS
- buf_ptr += 2;
- else
- buf_ptr = buf;
-
- // Determine number of data bytes read. This is equal to the
- // total bytes read minus number of header bytes.
- bytes_read = num_recvd - (buf_ptr - buf);
-
- }
- else
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "HTTP_Reader::receiveReply():Error while reading header\n"), -1);
-
- // ***************************************************************
- // At this point, we have stripped off the header and are ready to
- // process data. buf_ptr points to the data
-
- //set the size of the ACE_Message_Block to the current bytes read
- //NOTE: this function reallocates if necessary
- //this->mb_->size (bytes_read);
-
- ACE_Message_Block* temp; //pointer used temporarily
- //for memory allocations before
- //chaining to Message_Block
-
- ACE_Message_Block* curr = this->mb_;
-
- ACE_NEW_RETURN (temp, ACE_Message_Block (bytes_read), -1);
- curr->cont (temp);
-
- curr = curr->cont ();
-
- // Copy over all the data bytes into our message buffer.
- if (curr->copy (buf_ptr, bytes_read) == -1)
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n",
- "HTTP_Reader::receiveReply():Error copying data into Message_Block\n" ), -1);
-
- //read the rest of the data into a number of ACE_Message_Blocks and
- //chain them together in a link list fashion
-
- num_recvd = 0;
-
- do
- {
- if (curr->space () == 0)
- {
- ACE_NEW_RETURN (temp, ACE_Message_Block (MTU), -1);
- curr->cont (temp);
- curr = curr->cont ();
- }
-
- if (peer ().recv_n (curr->wr_ptr (), curr->space (), 0, &num_recvd) >= 0)
- {
- //move the write pointer
- curr->wr_ptr (num_recvd);
-
- //increment bytes_read
- bytes_read += num_recvd;
-
- }
- else
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "HTTP_Reader::receiveReply():Error while reading header\n"), -1);
-
- }while (num_recvd != 0);
-
- // Set the byte count to number of bytes received
- this->bytecount_ = bytes_read;
-
- return 0;
-}
-
diff --git a/TAO/CIAO/DAnCE/RepositoryManager/HTTP_Handler.h b/TAO/CIAO/DAnCE/RepositoryManager/HTTP_Handler.h
deleted file mode 100644
index d1e9aae2894..00000000000
--- a/TAO/CIAO/DAnCE/RepositoryManager/HTTP_Handler.h
+++ /dev/null
@@ -1,86 +0,0 @@
-
-/* -*- C++ -*- */
-
-//=============================================================================
-/**
- * @file HTTP_Handler.h
- *
- * $Id$
- *
- * HTTP_Handler is a base class for HTTP_Reader and
- * HTTP_Writer which are created in response to calls to
- * read/write, as appropriate
- *
- *
- * @author Stoyan Paunov
- */
-//=============================================================================
-
-
-#ifndef HTTP_HANDLER_H
-#define HTTP_HANDLER_H
-
-#include "ace/SOCK_Stream.h"
-#include "ace/Svc_Handler.h"
-#include "ace/Message_Block.h"
-
-/**
- * @class HTTP_Handler
- * class to retrieve data via HTTP
- */
-class HTTP_Handler : public ACE_Svc_Handler <ACE_SOCK_STREAM, ACE_NULL_SYNCH>
-{
-public:
- /// Null constructor, insures that it works properly with Connector
- HTTP_Handler (void);
-
- /// Always use this constructor to make HTTP_Handlers
- HTTP_Handler (ACE_Message_Block *mb,
- ACE_TCHAR *filename);
-
- /// returns the number of bytes read/written in the last operation.
- size_t byte_count (void);
-
- /// Activate this instance of the <HTTP_Handler>
- virtual int open (void * = 0);
-
- /// Close down the Blob
- virtual int close (u_long flags = 0);
-
- ~HTTP_Handler (void);
-
-protected:
- virtual int send_request (void);
- virtual int receive_reply (void);
-
- ACE_Message_Block *mb_;
- ACE_TCHAR *filename_;
- size_t bytecount_;
- enum
- {
- /// The handler assumes that the first 2048 bytes of a server response
- /// contains the header
- MAX_HEADER_SIZE = 2048,
-
- /// set the MAX_TRANSMISSION_UNIT (MTU) = BUFSIZ as defined by OS
- MTU = BUFSIZ
- };
-};
-
-class HTTP_Reader : public HTTP_Handler
-{
-public:
- HTTP_Reader (ACE_Message_Block *mb,
- ACE_TCHAR *filename,
- const char *request_prefix = "GET",
- const char *request_suffix = "HTTP/1.0\r\n\r\n");
-
-private:
- //NOTE: these functions return -1 on error
- int send_request (void);
- int receive_reply (void);
- const char *request_prefix_;
- const char *request_suffix_;
-};
-
-#endif /* HTTP_HANDLER_H */
diff --git a/TAO/CIAO/DAnCE/RepositoryManager/Options.cpp b/TAO/CIAO/DAnCE/RepositoryManager/Options.cpp
deleted file mode 100644
index 6503e01aa3e..00000000000
--- a/TAO/CIAO/DAnCE/RepositoryManager/Options.cpp
+++ /dev/null
@@ -1,111 +0,0 @@
-// $Id$
-
-// Options.cpp,v Stoyan
-
-#include "ace/Get_Opt.h"
-#include "ace/ARGV.h"
-#include "Options.h"
-
-
-bool
-Options::parse_args (int argc, ACE_TCHAR *argv[])
-{
- ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("n:l:u:ifdsTNa"));
-
- int c;
-
- while ((c = get_opt ()) != -1)
- switch (c)
- {
- case 'i':
- this->install_ = true;
- break;
- case 'd':
- this->delete_ = true;
- break;
- case 'f':
- this->find_ = true;
- break;
- case 's':
- this->shutdown_ = true;
- break;
- case 'n':
- this->name_ = get_opt.opt_arg ();
- break;
- case 'l':
- this->path_ = get_opt.opt_arg ();
- break;
- case 'u':
- this->uuid_ = get_opt.opt_arg ();
- break;
- case 'N':
- this->all_names_ = true;
- break;
- case 'T':
- this->all_types_ = true;
- break;
- case 'a':
- this->names_by_type_ = true;
- break;
- // Usage fallthrough.
- default:
- this->usage ();
- return false;
- }
-
- if ((this->name_ == "")
- && (this->shutdown_ == false)
- && (this->uuid_ == "")
- && (this->all_names_ == false)
- && (this->all_types_ == false))
- {
- this->usage ();
- return false;
- }
- else if (this->name_ != "")
- {
- if (!(this->install_ || this->find_ || this->delete_))
- {
- this->usage ();
- return false;
- }
- else if (this->install_ && this->path_ == "")
- {
- this->usage ();
- return false;
- }
- }
- else if (this->uuid_ != "")
- {
- if (!this->find_ && !this->names_by_type_)
- {
- this->usage ();
- return false;
- }
- }
-
- return true;
-}
-
-/// @todo Exit is not nice, return -1 so that the caller can do something and
-/// we don't exit abruptly
-void Options::usage (void)
-{
- ACE_DEBUG ((LM_INFO, "OPTIONS: -s <shutdown> -n <:name> [-i <install> -l <:path>] \
- [-d <delete>] [-f <find>] [-u <:uuid> [-a <names by type>] ] \
- [-N <all names>] [-T <all types>]\n"));
-}
-
-Options::Options (void)
- : name_ (""),
- uuid_ (""),
- path_ (""),
- delete_ (false),
- install_ (false),
- find_ (false),
- all_names_ (false),
- all_types_ (false),
- names_by_type_ (false),
- shutdown_ (false)
-{
-}
diff --git a/TAO/CIAO/DAnCE/RepositoryManager/Options.h b/TAO/CIAO/DAnCE/RepositoryManager/Options.h
deleted file mode 100644
index ac65d008762..00000000000
--- a/TAO/CIAO/DAnCE/RepositoryManager/Options.h
+++ /dev/null
@@ -1,78 +0,0 @@
-// $Id$
-
-/* -*- C++ -*- */
-
-//=============================================================================
-/**
- * @file Options.h
- *
- * $Id$
- *
- * TheOptions is an Options class wrapped into an ACE_Singleton
- * with Null_Mutex because the client is single-threaded.
- *
- *
- * @author Stoyan Paunov
- */
-//=============================================================================
-
-
-#ifndef RM_OPTIONS_H
-#define RM_OPTIONS_H
-
-#include "ace/Get_Opt.h"
-#include "ace/SString.h" //for ACE_CString
-#include "ace/Singleton.h" //for ACE_Singleton
-#include "ace/Null_Mutex.h" //for ACE_Null_Mutex
-
-//forward declaration
-class Options;
-
-typedef ACE_Singleton <Options, ACE_Null_Mutex> TheOptions;
-
-class Options
-{
-public:
-
- ///constructor
- Options (void);
-
- /// parses commandline arguments
- bool parse_args (int argc, ACE_TCHAR *argv[]);
-
- /// Name of package
- ACE_CString name_;
-
- /// Name of package
- ACE_CString uuid_;
-
- /// specifies the local path for install
- ACE_CString path_;
-
- /// delete the name_
- bool delete_;
-
- /// installs the name_
- bool install_;
-
- /// finds the name_
- bool find_;
-
- /// get all Names
- bool all_names_;
-
- /// get all types
- bool all_types_;
-
- /// find all names by type
- bool names_by_type_;
-
- /// shutdown the RepositoryManagerDemon
- bool shutdown_;
-
-protected:
- //usage function
- void usage (void);
-};
-
-#endif /* RM_OPTIONS_H */
diff --git a/TAO/CIAO/DAnCE/RepositoryManager/PC_Updater.cpp b/TAO/CIAO/DAnCE/RepositoryManager/PC_Updater.cpp
deleted file mode 100644
index 9858d39a3c5..00000000000
--- a/TAO/CIAO/DAnCE/RepositoryManager/PC_Updater.cpp
+++ /dev/null
@@ -1,269 +0,0 @@
-// $Id$
-
-#include "ace/Log_Msg.h"
-#include "ciao/Deployment_DataC.h"
-#include "PC_Updater.h"
-#include "PC_Updater_T.h"
-#include "ace/Containers_T.h" //for ACE_Double_Linked_List
-
-
-#include <iostream>
-using namespace std;
-
-namespace
-{
- const size_t TEMP_LEN = 1024;
-}
-
-using namespace PC_Updater_T;
-
-
- //PATH of glory/gory to update the locations of the IADs
- //
- //PackageConfiguration something;
- //ComponentPackageDescriptions basePackage;
- //PackagedComponentImplementations implementation;
- //ComponentImplementationDescription referencedImplementation;
- //
- //MONOLITHIC Component:
- //MonolithicImplementationDescriptions monolithicImpl;
- //NamedImplementationArtifacts primaryArtifact;
- //ImplementationArtifactDescription referencedArtifact;
- //::CORBA::StringSeq location;
- //
- //ASSEMBLY-BASED Component
- //ComponentAssemblyDescriptions assemblyImpl;
- //SubcomponentInstantiationDescriptions instance;
- //ComponentPackageDescriptions package;
- //...
-
-
- /*
- * PC_Updater Constructors
- */
-
-PC_Updater::PC_Updater (const char* server_path, const char* package)
-: server_path_ (server_path),
- file_list_ (&allocator_),
- package_ (package),
- success_ (true)
-{
-}
-
-
-PC_Updater::PC_Updater (ACE_CString& server_path, ACE_CString& package)
-: server_path_ (server_path),
- file_list_ (&allocator_),
- package_ (package),
- success_ (true)
-{
-}
-
- /*
- * PC_Updater - Destructor
- */
-
-PC_Updater::~PC_Updater ()
-{
- this->clear_list ();
-}
-
-
-void PC_Updater::clear_list ()
-{
- while (!this->file_list_.is_empty ())
- {
- ZIP_File_Info* inf = this->file_list_.delete_head ();
-
- //deallocate the head of the filename list
- delete inf;
- }
-}
-
-
- /*
- * PC_Updater - Object update methods
- */
-
-
- // PackageConfiguration
-
- bool PC_Updater::update (const ::Deployment::PackageConfiguration &pc)
- {
- //get the list of files in the package and figure out the names of all necessary files
- if (!ZIP_Wrapper::file_list_info (const_cast <char*> (this->package_.c_str ()), this->file_list_))
- return false;
-
- update_sequence (pc.basePackage, this);
-
- return this->success_;
- }
-
-
- // ComponentInterfaceDescription
-
- void PC_Updater::update (const ::Deployment::ComponentInterfaceDescription &cid)
- {
- }
-
- // Requirement
-
- void PC_Updater::update (const ::Deployment::Requirement &req)
- {
- }
-
-
- // ComponentExternalPortEndpoint
-
- void PC_Updater::update (const ::Deployment::ComponentExternalPortEndpoint &cepe)
- {
- }
-
-
-
- // ImplementationDependency
-
- void PC_Updater::update(const Deployment::ImplementationDependency &id)
- {
- }
-
- // ComponentPackageReference
-
- void PC_Updater::update (const ::Deployment::ComponentPackageReference &cpr)
- {
- }
-
- // SubcomponentInstantiationDescription
-
- void PC_Updater::update (const ::Deployment::SubcomponentInstantiationDescription &sid)
- {
- update_sequence (sid.package, this);
- }
-
- // SubcomponentPortEndpoint
-
- void PC_Updater::update (const ::Deployment::SubcomponentPortEndpoint& spe)
- {
- }
-
- // AssemblyConnectionDescription
-
- void PC_Updater::update (const ::Deployment::AssemblyConnectionDescription &acd)
- {
- }
-
-
- // AssemblyPropertyMapping
-
- void
- PC_Updater::update (const ::Deployment::AssemblyPropertyMapping &apm)
- {
- }
-
- // ComponentAssemblyDescription
-
- void PC_Updater::update (const ::Deployment::ComponentAssemblyDescription& cad)
- {
- update_sequence (cad.instance, this);
- }
-
- // ImplementationArtifactDescription
-
- void PC_Updater::update (const ::Deployment::ImplementationArtifactDescription &iad)
- {
- bool found = false;
-
- //cout << "label: " << iad.label << endl;
- //cout << "location: " << CORBA::string_dup (iad.location[0].in ()) << endl;
-
- ACE_Double_Linked_List_Iterator<ZIP_File_Info> iter (this->file_list_);
- char str [TEMP_LEN];
-
- while (!iter.done ())
- {
- ACE_OS::strncpy ( str, iter.next ()->name_.c_str (), TEMP_LEN);
- //weird. Need to call next to get current ?!?!
-
- const char* name;
- const char* ext;
-
- name = ACE_OS::strstr (str, iad.location[0].in ());
-
- if (name)
- {
- ext = ACE_OS::strstr (name, ".");
-
- ACE_CString loc (this->server_path_);
- loc += iad.location[0].in ();
- loc += ext;
-
- iad.location[0] = CORBA::string_dup (loc.c_str ());
-
- //cout << "new location: " << iad.location[0].in () << endl << endl;
-
- found = true;
- break;
- }
- iter++;
- }
-
- if (!found)
- this->success_ = false;
- }
-
- // NamedImplementationArtifact
-
- void PC_Updater::update (const ::Deployment::NamedImplementationArtifact &nia)
- {
- update (nia.referencedArtifact);
- }
-
- // ImplementationRequirement
-
- void PC_Updater::update (const ::Deployment::ImplementationRequirement &ir)
- {
- }
-
- // MonolithicImplementationDescription
-
- void PC_Updater::update (const ::Deployment::MonolithicImplementationDescription &mid)
- {
- update_sequence (mid.primaryArtifact, this);
- }
-
- // Capability
-
- void PC_Updater::update (const ::Deployment::Capability &capability)
- {
- }
-
-
-
- // ComponentImplementationDescription
-
- void PC_Updater::update (
- const ::Deployment::ComponentImplementationDescription &cid)
- {
- update_sequence (cid.assemblyImpl, this);
- update_sequence (cid.monolithicImpl, this);
- }
-
- // PackagedComponentImplementation
-
- void PC_Updater::update (const ::Deployment::PackagedComponentImplementation &pci)
- {
- PC_Updater::update (pci.referencedImplementation);
- }
-
- // ComponentPackageDescription
-
- void PC_Updater::update (const ::Deployment::ComponentPackageDescription &comppkgdesc)
- {
- update_sequence (comppkgdesc.implementation, this);
- }
-
-
- // Property
- void PC_Updater::update (const Deployment::Property& property)
- {
- }
diff --git a/TAO/CIAO/DAnCE/RepositoryManager/PC_Updater.h b/TAO/CIAO/DAnCE/RepositoryManager/PC_Updater.h
deleted file mode 100644
index a60de14a90a..00000000000
--- a/TAO/CIAO/DAnCE/RepositoryManager/PC_Updater.h
+++ /dev/null
@@ -1,113 +0,0 @@
-
-/* -*- C++ -*- */
-
-//========================================================================
-/**
- * file PC_Updater.h
- *
- * $Id$
- *
- * This class is used to update the location field of the implementation
- * artifacts in the PackageConfiguration, so that they point to the
- * physical libraries on the collocated HTTP server
- *
- * author Stoyan Paunov <spaunov@isis.vanderbilt.edu>
- */
-//========================================================================
-
-#ifndef PC_UPDATER_H
-#define PC_UPDATER_H
-#include /**/ "ace/pre.h"
-
-#include "ciao/DeploymentC.h"
-#include "ace/SString.h" //for the ACE_CString
-
-#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
-
-#if !defined (ACE_LACKS_PRAGMA_ONCE)
-#pragma once
-#endif /* ACE_LACKS_PRAGMA_ONCE */
-
-/**
- * @class PC_Updater
- *
- * This class defines a set of overloaded methods used to update
- * the contents of a PackageConfiguration. More specifically the class
- * goes through the PackageConfiguration and updates the locations of the
- * artifacts, wrt to their location on the HTTP server.
- */
-class PC_Updater
-{
-public:
-
- /// Constructors
-
- PC_Updater (const char* server_path, const char* package);
- PC_Updater (ACE_CString& server_path, ACE_CString& package);
-
- ~PC_Updater ();
-
- /// A whole slew of overloaded routines for different IDL
- /// data types part of the PackageConfiguration.
-
- bool update (const ::Deployment::PackageConfiguration &pc);
-
- void update (const ::Deployment::Property &property);
-
- void update (const ::Deployment::AssemblyConnectionDescription &acd);
-
- void update (const ::Deployment::AssemblyPropertyMapping &apm);
-
- void update (const ::Deployment::ComponentPackageDescription &comppkgdesc);
-
- void update (const ::Deployment::MonolithicImplementationDescription &mid);
-
- void update (const ::Deployment::PackagedComponentImplementation &pci);
-
- void update (const ::Deployment::SubcomponentPortEndpoint &spe);
-
- void update (const ::Deployment::Requirement &requirement);
-
- void update (const ::Deployment::ComponentExternalPortEndpoint &cepe);
-
- void update (const ::Deployment::ComponentPackageReference &cpr);
-
- void update (const ::Deployment::ComponentImplementationDescription &cid);
-
- void update (const ::Deployment::SubcomponentInstantiationDescription &sid);
-
- void update (const ::Deployment::NamedImplementationArtifact &named_implementation);
-
- void update (const ::Deployment::ComponentInterfaceDescription &cid);
-
- void update (const ::Deployment::Capability &capability);
-
- void update (const ::Deployment::ImplementationArtifactDescription &iad);
-
- void update (const ::Deployment::ImplementationRequirement &ir);
-
- void update(const Deployment::ImplementationDependency &id);
-
- void update (const ::Deployment::ComponentAssemblyDescription& cad);
-
-protected:
-
- void clear_list ();
-
-private:
-
- ACE_CString server_path_;
-
- /// create a doubly link list
- ACE_New_Allocator allocator_;
- ACE_Double_Linked_List<ZIP_File_Info> file_list_;
-
- ACE_CString package_;
- bool success_;
-};
-
-#include /**/ "ace/post.h"
-
-#endif /* PC_UPDATER_H */
diff --git a/TAO/CIAO/DAnCE/RepositoryManager/PC_Updater_T.cpp b/TAO/CIAO/DAnCE/RepositoryManager/PC_Updater_T.cpp
deleted file mode 100644
index f1b53537735..00000000000
--- a/TAO/CIAO/DAnCE/RepositoryManager/PC_Updater_T.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-// $Id$
-#ifndef PC_UPDATER_T_C
-#define PC_UPDATER_T_C
-#include "PC_Updater.h"
-#include "PC_Updater_T.h"
-
-namespace PC_Updater_T
-{
- /// Dumps a sequence
- template <typename SEQUENCE>
- void update_sequence (const SEQUENCE &seq, PC_Updater* updater)
- {
- const CORBA::ULong size = seq.length ();
-
- for (CORBA::ULong i = 0; i < size; ++i)
- updater->update (seq[i]);
- }
-}
-
-#endif /* PC_Updater_C */
diff --git a/TAO/CIAO/DAnCE/RepositoryManager/PC_Updater_T.h b/TAO/CIAO/DAnCE/RepositoryManager/PC_Updater_T.h
deleted file mode 100644
index 0e3eb05b5f5..00000000000
--- a/TAO/CIAO/DAnCE/RepositoryManager/PC_Updater_T.h
+++ /dev/null
@@ -1,40 +0,0 @@
-
-/* -*- C++ -*- */
-
-//==================================================================
-/**
- * file PC_Updater_T.h
- *
- * $Id$
- *
- * author Stoyan Paunov <spaunov@isis.vanderbilt.edu>
- */
-//=====================================================================
-
-#ifndef CIAO_CONFIG_HANDLERS_PC_UPDATER_T_H
-#define CIAO_CONFIG_HANDLERS_PC_UPDATER_T_H
-#include /**/ "ace/pre.h"
-
-#include "ace/config-lite.h"
-
-#if !defined (ACE_LACKS_PRAGMA_ONCE)
-#pragma once
-#endif /* ACE_LACKS_PRAGMA_ONCE */
-
-namespace PC_Updater_T
-{
- template <typename SEQUENCE>
- static void update_sequence (const SEQUENCE &seq);
-}
-
-#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
-#include "PC_Updater_T.cpp"
-#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
-
-#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
-#pragma implementation ("PC_Updater_T.cpp")
-#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
-
-
-#include /**/ "ace/post.h"
-#endif /*CIAO_CONFIG_HANDLERS_PC_Updater_T_H*/
diff --git a/TAO/CIAO/DAnCE/RepositoryManager/README.txt b/TAO/CIAO/DAnCE/RepositoryManager/README.txt
deleted file mode 100644
index e4cd2fa6397..00000000000
--- a/TAO/CIAO/DAnCE/RepositoryManager/README.txt
+++ /dev/null
@@ -1,30 +0,0 @@
-This is the README file for the Repository Manager (RM).
-
-In order to be able to compile the RM you need to have ZZIP lib because the Repository
-Manager (RM) uses it to read the contents of CCM packages. ZZIP itself is a C++ wrapper
-around ZLIB, thus you will also need ZLIB. In order to compile the RM successfully
-you will need to do the following:
-
-1. Download ZLIB and ZZIP-LIB
-2. Compile the multi-threaded versions of these libraries
-3. [on Windows] create a separate directory for each library; create an include and a lib
-subdirectory within them. Then copy the libraries files in the library subdirectory.
-Copy zlib.h in the zlib_path/include and copy zziplib.h, zzip-conf.h and zzip-msvc.h
-(for Windows platforms; Linux might have its own file!!!). This step might be easier if
-you find a binary package of the libraries and just install it.
-4. Set $ZLIB_ROOT and $ZZIP_ROOT to point to the directories where you placed the
-libraries and the include files.
-5. Turn on zzip and zlib in default.features for MPC.
-6. MPC will handle the rest.
-
-
-Things to watch out for:
-On Windows make sure that you are linking the right ZIP libraries
-together with the rest of the libraries, i.e. if you are building the debug version of ACE,
-TAO and CIAO, then use the debug version of the ZIP libraries. Otherwise the RM will compile
-but it will not work properly.
-
-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/RepositoryManager/RM_Helper.cpp b/TAO/CIAO/DAnCE/RepositoryManager/RM_Helper.cpp
deleted file mode 100644
index 9c14b6b9608..00000000000
--- a/TAO/CIAO/DAnCE/RepositoryManager/RM_Helper.cpp
+++ /dev/null
@@ -1,253 +0,0 @@
-// $Id$
-
-#include "RM_Helper.h"
-#include "ciao/Packaging_DataC.h" //for the PackageConfiguration declaration
-#include "tao/CDR.h" //for TAO CDR classes
-#include "ace/Message_Block.h" //for ACE_Message_Block
-#include "ace/Auto_Ptr.h" //for Auto_Ptr
-#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
-
-
-void RM_Helper::pc_to_cdr (const Deployment::PackageConfiguration& pc, TAO_OutputCDR& cdr)
-{
- cdr << pc;
-}
-
-
-void RM_Helper::cdr_to_pc (Deployment::PackageConfiguration& pc, TAO_InputCDR& cdr)
-{
- cdr >> pc;
-}
-
-
-bool RM_Helper::externalize (const Deployment::PackageConfiguration& pc, const char* path)
-{
- size_t bufsiz = 0;
- TAO_OutputCDR out (bufsiz);
-
- RM_Helper::pc_to_cdr (pc, out);
-
- const ACE_Message_Block* mb = out.begin ();
-
- return write_pc_to_disk (path, *(const_cast<ACE_Message_Block*> (mb)));
-}
-
-bool RM_Helper::reincarnate (Deployment::PackageConfiguration& pc, const char* path)
-{
- size_t length = 0;
- ACE_Auto_Ptr<ACE_Message_Block> mb (read_pc_from_disk (path, length));
-
- if (!mb.get ())
- return false;
-
- TAO_InputCDR in (mb.get ());
-
- RM_Helper::cdr_to_pc (pc, in);
-
- return true;
-}
-
-
-//---------------------------------------------------------------------
-//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 0 is returned in the case of an error
-//and a 1 upon success
-
-bool RM_Helper::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")),
- 0);
-
- //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")),
- 0);
-
- // Close the file handle
- ACE_OS::close (handle);
-
- return 1;
-}
-
-
-//This function attempts to write a sequence of bytes from an
-//ACE_Message_Block to a specified location. A 0 is returned
-//in the case of an error and a 1 upon success
-
-bool RM_Helper::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")),
- 0);
-
- //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")),
- 0);
-
- // Close the file handle
- ACE_OS::close (handle);
-
- return 1;
-}
-
-
-//This function attempts to write a sequence of bytes from an
-//ACE_Message_Block to a specified location. A 0 is returned
-//in the case of an error and a 1 upon success
-//
-//NOTE: This function write the contents in a way that preserves the
-//structure of the ACE_Message_Block. It is relevant for
-//PackageConfigurations ONLY
-
-
-bool RM_Helper::write_pc_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")),
- 0);
-
- //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")),
- 0);
-
- // 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 0 is returned
-//in the case of an error and a 1 upon success
-
-CORBA::Octet* RM_Helper::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;
- ACE_NEW_RETURN (buffer, CORBA::Octet[file_info.st_size], 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::read_from_disk] file read error")),
- 0);
-
- // Close the file handle
- ACE_OS::close (handle);
-
- length = file_info.st_size;
- return buffer;
-}
-
-
-
- ///function to read the contents of a file from disk into an ACE_Message_Block
- ///returns a pointer to an ACE_Message_Block and updates the lenght on success
- /// 0 on failure
-
-
-ACE_Message_Block* RM_Helper::read_pc_from_disk (
- const char* full_path,
- size_t &length
- )
-{
- length = 0;
-
- //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_mb_from_disk] file open error")),
- 0);
-
- ACE_stat file_info;
-
- ACE_OS::fstat (handle, &file_info);
-
- ACE_Message_Block* mb;
- ACE_NEW_RETURN (mb, ACE_Message_Block (file_info.st_size + 1), 0);
-
- //read the contents of the file into the buffer
- if (ACE_OS::read_n (handle, mb->wr_ptr (), file_info.st_size) == -1)
- ACE_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("%p\n"),
- ACE_TEXT ("[RM::read_mb_from_disk] file read error")),
- 0);
-
- mb->length (file_info.st_size);
-
- // Close the file handle
- ACE_OS::close (handle);
-
- length = file_info.st_size;
- return mb;
-}
diff --git a/TAO/CIAO/DAnCE/RepositoryManager/RM_Helper.h b/TAO/CIAO/DAnCE/RepositoryManager/RM_Helper.h
deleted file mode 100644
index fb2f8a61db0..00000000000
--- a/TAO/CIAO/DAnCE/RepositoryManager/RM_Helper.h
+++ /dev/null
@@ -1,101 +0,0 @@
-
-/* -*- C++ -*- */
-
-//=============================================================================
-/**
- * @file RM_Helper.h
- *
- * $Id$
- *
- * This class aggregates a number of helper functions used by the
- * CIAO RepositoryManager
- *
- *
- * @author Stoyan Paunov
- */
-//=============================================================================
-
-#ifndef RM_HELPER_H_
-#define RM_HELPER_H_
-
-
-#include "ciao/Packaging_DataC.h" //for the PackageConfiguration declaration
-#include "tao/CDR.h" //for TAO CDR classes
-#include "ace/Message_Block.h" //for ACE_Message_Block
-
-//int operator<< (ACE_OutputCDR& cdr, const Deployment::PackageConfiguration& pc);
-//int operator>> (ACE_InputCDR& cdr, Deployment::PackageConfiguration& pc);
-//Similar operators are generated by the IDL compiler
-//
-//Do search for "Deployment::PackageConfiguration &" in Packaging_DataC.cpp
-//
-//::CORBA::Boolean operator<< (
-// TAO_OutputCDR &strm,
-// const Deployment::PackageConfiguration &_tao_aggregate
-//
-//::CORBA::Boolean operator>> (
-// TAO_InputCDR &strm,
-// Deployment::PackageConfiguration &_tao_aggregate
-// )
-
-
-class RM_Helper
-{
-public:
-
- static void pc_to_cdr (const Deployment::PackageConfiguration& pc, TAO_OutputCDR& cdr);
-
- static void cdr_to_pc (Deployment::PackageConfiguration& pc, TAO_InputCDR& cdr);
-
- static bool externalize (const Deployment::PackageConfiguration& pc, const char* path);
-
- static bool reincarnate (Deployment::PackageConfiguration& pc, const char* path);
-
- ///function that writes out a file to a specified location on the hard disk
- ///returns 1 on success
- /// 0 on error
-
- static bool 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
- /// 0 on error
-
- static bool write_to_disk (const char* full_path,
- ACE_Message_Block& mb,
- bool replace = true
- );
-
- ///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
- /// 0 on error
- ///
- ///NOTE: This function is relevant for PackageConfigurations ONLY
-
- static bool write_pc_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 updates the lenght on success
- /// 0 on failure
-
- static CORBA::Octet* read_from_disk (const char* full_path, size_t &length);
-
- ///function to read the contents of a file from disk into an ACE_Message_Block
- ///returns a pointer to an ACE_Message_Block and updates the lenght on success
- /// 0 on failure
-
-
- static ACE_Message_Block* read_pc_from_disk (const char* full_path, size_t &length);
-
-};
-
-#endif
diff --git a/TAO/CIAO/DAnCE/RepositoryManager/RMadmin.cpp b/TAO/CIAO/DAnCE/RepositoryManager/RMadmin.cpp
deleted file mode 100644
index 2a884d2bd16..00000000000
--- a/TAO/CIAO/DAnCE/RepositoryManager/RMadmin.cpp
+++ /dev/null
@@ -1,274 +0,0 @@
-
-/* -*- C++ -*- */
-
-/***
- * file RMClient.cpp
- *
- * $Id$
- *
- * A sample client to the RepositoryManager showcasing how to use it
- *
- * author Stoyan Paunov <spaunov@isis.vanderbilt.edu>
- **/
-
-#include "RepositoryManagerDaemonC.h"
-#include "Options.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 "Config_Handlers/DnC_Dump.h"
-
-#include <iostream>
-using namespace std;
-
-#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
-
-
-
-//IOR file of the RM
-const char * ior = "file://RepositoryManagerDeamon.ior";
-
-
-///=============================COUPLE OF HELPER METHORS==================================
-CORBA::Octet* read_from_disk (
- const char* full_path,
- size_t &length
- );
-
-int write_to_disk (
- const char* full_path,
- const CORBA::Octet* buffer,
- size_t length
- );
-///========================================================================================
-
-
-///main function that provides a sample interface for RM clients
-
-int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
-{
- ACE_TRY_NEW_ENV
- {
- // Initialize orb
- CORBA::ORB_var orb = CORBA::ORB_init (argc, argv,
- ""ACE_ENV_ARG_PARAMETER);
-
- ACE_TRY_CHECK;
-
-
- CORBA::Object_var obj =
- orb->string_to_object (ior
- ACE_ENV_ARG_PARAMETER);
- ACE_TRY_CHECK;
-
- CIAO::RepositoryManagerDaemon_var rm =
- CIAO::RepositoryManagerDaemon::_narrow (obj.in ()
- ACE_ENV_ARG_PARAMETER);
- ACE_TRY_CHECK;
-
- if (CORBA::is_nil (rm.in ()))
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "Unable to acquire RepositoryManagerDaemon's objref\n"),
- -1);
- }
-
-
- Options* options = TheOptions::instance ();
- if (!options->parse_args (argc, argv))
- return -1;
-
- if (options->shutdown_)
- {
- rm->shutdown ();
- }
- else if (options->all_names_)
- {
- try
- {
- CORBA::StringSeq_var seq = rm->getAllNames ();
- cout << "Known Names:\n";
- cout << "Seq length () : " << seq->length () << endl;
- for (size_t i = 0;
- i < seq->length ();
- ++i)
- cout << seq[i].in () << endl;
- }
- catch (CORBA::Exception & ex)
- {
- cout << "\nException caught!" << ex << "\n";
- return 0;
- }
- }
- else if (options->all_types_)
- {
- try
- {
- CORBA::StringSeq_var seq = rm->getAllTypes ();
- cout << "Known Component Interface Types:\n";
- for (size_t i = 0;
- i < seq->length ();
- ++i)
- cout << seq[i].in () << endl;
- }
- catch (CORBA::Exception & ex)
- {
- cout << "\nException caught!" << ex << "\n";
- return 0;
- }
- }
- else if (options->uuid_ != "" && options->names_by_type_)
- {
- try
- {
- CORBA::StringSeq_var seq = rm->findNamesByType (options->uuid_.c_str ());
- cout << "Known Component Interface Types:\n";
- for (size_t i = 0;
- i < seq->length ();
- ++i)
- cout << seq[i].in () << endl;
- }
- catch (CORBA::Exception & ex)
- {
- cout << "\nException caught!" << ex << "\n";
- return 0;
- }
-
- }
- else if (options->install_)
- {
- try
- {
- rm->installPackage (options->name_.c_str (), options->path_.c_str ());
- }
- catch (CORBA::Exception & ex)
- {
- cout << "\nException caught!" << ex << "\n";
- return 0;
- }
-
- cout << "\nReassuring that the package in the repository ..." << endl;
- try
- {
- Deployment::PackageConfiguration_var pc = rm->findPackageByName (options->name_.c_str ());
- cout << "The package was found!" << endl;
- cout << "Label: " << pc->label << endl;
- cout << "UUID: " << pc->UUID << endl;
- }
- catch (CORBA::Exception &)
- {
- cout << "\nError! Package not found!" << endl;
- }
- }
- else if (options->delete_)
- {
- try
- {
- rm->deletePackage (options->name_.c_str ());
- cout << options->name_.c_str () << " deleted" << endl;
- }
- catch (CORBA::Exception & ex)
- {
- cout << "\nException: " << ex << endl;
- }
-
- }
- else if (options->find_)
- {
- if (options->name_ != "")
- {
- Deployment::PackageConfiguration_var pc = rm->findPackageByName (options->name_.c_str ());
- cout << "The package was found!" << endl;
- Deployment::DnC_Dump::dump (pc);
- }
- else
- {
- Deployment::PackageConfiguration_var pc = rm->findPackageByUUID (options->uuid_.c_str ());
- cout << "The package was found!" << endl;
- Deployment::DnC_Dump::dump (pc);
- }
- }
-
- orb->shutdown (1);
- ACE_TRY_CHECK;
- }
- ACE_CATCHANY
- {
- ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
- "Unknown exception \n");
- return -1;
- }
- ACE_ENDTRY;
-
- return 0;
-}
-
-
-
-CORBA::Octet* 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 = 0;
- ACE_NEW_RETURN (buffer, CORBA::Octet[file_info.st_size], 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;
-}
-
-
-int 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;
-}
-
diff --git a/TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager.cpp b/TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager.cpp
deleted file mode 100644
index b8a94492920..00000000000
--- a/TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager.cpp
+++ /dev/null
@@ -1,166 +0,0 @@
-
-/* -*- C++ -*- */
-
-//======================================================================
-/**
- * @file RepositoryManager.cpp
- *
- * $Id$
- *
- * Description:
- * Main driver program for the CIAO RepositoryManager
- * Please run as follows:
- * RepositoryManagerDeamon [int:nthreads]
- *
- * @author Stoyan Paunov
- */
-//======================================================================
-
-#include "RepositoryManager_Impl.h"
-#include "ace/OS_NS_stdio.h"
-#include "ace/streams.h"
-#include "ace/Auto_Ptr.h"
-#include "ace/Task.h"
-using namespace std;
-
-namespace
-{
-/// 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
-unsigned int nthreads = 3;
-}
-
-
-/**
- * @class Worker
- *
- * Class that implements the service routine of the worker threads
- * of the repository manager
- */
-class Worker : public ACE_Task_Base
-{
-public:
- /// ctor
- Worker (CORBA::ORB_ptr orb);
-
- /// The thread entry point.
- virtual int svc (void);
-
-private:
- /// The orb
- CORBA::ORB_var orb_;
-};
-
-
-///Main function
-
-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_RepositoryManagerDaemon_i* repo;
- ACE_NEW_RETURN (repo, CIAO_RepositoryManagerDaemon_i (orb.in ()), 1);
-
- //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);
-
- if (argc > 1)
- nthreads = ACE_OS::atoi (argv[1]);
-
- Worker worker (orb.in ());
- if (worker.activate (THR_NEW_LWP | THR_JOINABLE, nthreads) != 0)
- ACE_ERROR_RETURN ((LM_ERROR,
- "Cannot activate worker threads\n"),
- 1);
-
- worker.thr_mgr ()->wait ();
-
- ACE_DEBUG ((LM_DEBUG, "event loop finished\n"));
-
- //done
- return 0;
-
- //Start accepting requests
- orb->run ();
-
- //allow objects registered with the POA ot get cleaned-up
- root_poa->destroy (1, 1);
-
- //shutdown the orb
- orb->shutdown (1);
-
- return 0;
- }
- catch (CORBA::Exception &ex) {
- cerr << "CORBA Exception: " << ex << endl;
-
- return 1;
- }
-
-
- return 0;
-}
-
-
-
-// ****************************************************************
-
-///Constuctor for the worker class
-Worker::Worker (CORBA::ORB_ptr orb)
- : orb_ (CORBA::ORB::_duplicate (orb))
-{
-}
-
-///implementation of the service routine inherited from ACE::Task_Base
-
-int Worker::svc (void)
-{
- ACE_DECLARE_NEW_CORBA_ENV;
- ACE_TRY
- {
- this->orb_->run (ACE_ENV_SINGLE_ARG_PARAMETER);
- ACE_TRY_CHECK;
- }
- ACE_CATCHANY
- {
- }
- ACE_ENDTRY;
- return 0;
-}
-
-
diff --git a/TAO/CIAO/DAnCE/RepositoryManager/RepositoryManagerDaemon.idl b/TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager.idl
index f86e14c1c8b..1fc19b0d1be 100644
--- a/TAO/CIAO/DAnCE/RepositoryManager/RepositoryManagerDaemon.idl
+++ b/TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager.idl
@@ -1,6 +1,6 @@
// $Id$
-#include "RepositoryManager.idl"
+#include "Deployment.idl"
module CIAO
{
@@ -10,4 +10,3 @@ module CIAO
oneway void shutdown ();
};
};
-
diff --git a/TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager.mpc b/TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager.mpc
index b1300b1f92e..4e059b669b2 100644
--- a/TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager.mpc
+++ b/TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager.mpc
@@ -1,48 +1,24 @@
// -*- MPC -*-
// $Id$
-//RepositoryManager project: implementation of a repository manager
-//compleint with the D&C spec
-
-project (RepositoryManager) : ciao_server_dnc, ciao_config_handlers, zzip, zlib {
-
- exename = RepositoryManagerDeamon
- requires += zzip zlib
+project(Repository_Manager): ciao_server_dnc,ciao_deployment_svnt, ciao_deployment_stub, taoexe, xerces, exceptions {
+ exename = executor
+ after += Config_Handlers ExecutionManager_stub NodeManager_stub
+ includes += /usr/include $(CIAO_ROOT)/tools
+ libpaths += /usr/lib
+ libs += Config_Handlers NodeManager_stub
+ libs += ExecutionManager_stub CIAO_DnC_Server
+ after += Config_Handlers
IDL_Files {
- RepositoryManagerDaemon.idl
+ RepositoryManager.idl
}
Source_Files {
- RepositoryManagerDaemonC.cpp
- RepositoryManagerDaemonS.cpp
- ZIP_Wrapper.cpp
- RepositoryManager.cpp
+ RepositoryManagerC.cpp
+ RepositoryManagerS.cpp
+ Update_Plan.cpp
+ Repository_Manager.cpp
RepositoryManager_Impl.cpp
- RM_Helper.cpp
- URL_Parser.cpp
- HTTP_Handler.cpp
- HTTP_Client.cpp
- PC_Updater_T.cpp
- PC_Updater.cpp
- }
-}
-
-
-// RMadmin project: a sample client for the RM.
-
-project (RMAdmin) : ciao_servant_dnc, ciao_config_handlers {
- exename = RMadmin
- after += RepositoryManager
-
- IDL_Files {
- RepositoryManagerDaemon.idl
- }
-
- Source_Files {
- RMadmin.cpp
- RepositoryManagerDaemonC.cpp
- Options.cpp
- RM_Helper.cpp
}
}
diff --git a/TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager_Impl.cpp b/TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager_Impl.cpp
index a529c07f84a..da85e59cf55 100644
--- a/TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager_Impl.cpp
+++ b/TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager_Impl.cpp
@@ -1,1130 +1,205 @@
+/* -*- C++ -*- */
// $Id$
-//====================================================================
-/**
- * @file RepositoryManager_Impl.cpp
- *
- * $Id$
- *
- * Description: Actial implementation of the RepoMan
- *
- * @author Stoyan Paunov
- */
-//====================================================================
-
#include "RepositoryManager_Impl.h"
+#include "Repository_Manager_conf.h"
+#include "Old_Config_Handlers/TPD_Handler.h"
+#include "Old_Config_Handlers/DnC_Dump.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
-#include "ace/OS_Memory.h" //for ACE_NEW* macros
-
-
-//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
-
-//for the PackageConfiguration parsing
-#include "Config_Handlers/STD_PC_Intf.h"
-#include "ciao/Deployment_DataC.h"
-#include "ciao/Packaging_DataC.h"
-#include "Config_Handlers/Utils/XML_Helper.h"
-#include "xercesc/dom/DOM.hpp"
-
-#include "RM_Helper.h" //to be able to externalize/internalize a PackageConfiguration
-#include "ace/Message_Block.h" //for ACE_Message_Block
-
-#include "ace/Thread.h" //for obtaining the ID of the current thread
-#include "ace/OS_NS_stdlib.h" //for itoa ()
-
-#include "URL_Parser.h" //for parsing the URL
-#include "HTTP_Client.h" //the HTTP client class to downloading packages
-
-#include "PC_Updater.h" //A visitor class to walk through the elements of the PC
-
-#include <iostream>
-using namespace std;
-
-//-----------------------------------------------------------------
-//Constructor
-//
-//-----------------------------------------------------------------
-
-CIAO_RepositoryManagerDaemon_i::CIAO_RepositoryManagerDaemon_i (CORBA::ORB_ptr the_orb, const char* server)
- : the_orb_ (CORBA::ORB::_duplicate (the_orb)),
- install_root_ (""),
- HTTP_server_ (server)
+CIAO::RepositoryManager_Impl::RepositoryManager_Impl
+ (CORBA::ORB_ptr orb,
+ PortableServer::POA_ptr poa)
+ : orb_ (CORBA::ORB::_duplicate (orb)),
+ poa_ (PortableServer::POA::_duplicate (poa)),
+ pc_table_ (MAX_PACKAGES)
{
- //create directory in which the packages will be stored
-
- ACE_OS::mkdir(INSTALL_PATH);
- //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;
}
-//-----------------------------------------------------------------
-//Destructor
-//
-//-----------------------------------------------------------------
-
-CIAO_RepositoryManagerDaemon_i::~CIAO_RepositoryManagerDaemon_i (void)
+CIAO::RepositoryManager_Impl::RepositoryManager_Impl ()
+ : pc_table_ (MAX_PACKAGES)
{
- this->names_.unbind_all ();
- this->uuids_.unbind_all ();
}
-//-----------------------------------------------------------------
-//shutdown
-//
-//-----------------------------------------------------------------
-
-void CIAO_RepositoryManagerDaemon_i::shutdown ()
-
- ACE_THROW_SPEC ((
- CORBA::SystemException
- ))
+CIAO::RepositoryManager_Impl::~RepositoryManager_Impl ()
{
-
- this->names_.unbind_all ();
- this->uuids_.unbind_all ();
-
- this->the_orb_->shutdown (0);
}
-
-//-----------------------------------------------------------------
-//installPackage
-//
-//-----------------------------------------------------------------
-
-void CIAO_RepositoryManagerDaemon_i::installPackage (
- const char * installationName,
- const char * location
- )
- ACE_THROW_SPEC ((
- CORBA::SystemException,
- ::Deployment::NameExists,
- ::Deployment::PackageError
- ))
+void
+CIAO::RepositoryManager_Impl::
+installPackage (const char* installation_name,
+ const char* location
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Deployment::NameExists,
+ Deployment::PackageError))
{
-
- PCEntry *entry = 0;
-
- if (this->names_.find (ACE_CString (installationName), entry) == 0)
- ACE_THROW (Deployment::NameExists ());
-
- //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 path (this->install_root_);
- path += "/";
- path += installationName;
-
- 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
-
-
- //check if URL or local file
- //download or load into memory
-
- size_t length = 0;
-
- if (ACE_OS::strstr (location, "http://"))
+ try
{
-
- //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::INTERNAL ());
- ACE_CHECK_RETURN (0);
-
- //get the remote file
- if (!HTTP_Get (location, *mb))
- {
- mb->release ();
- ACE_THROW (CORBA::INTERNAL ());
- }
-
- // Write file to designated location on disk
- if (!RM_Helper::write_to_disk (package_path.c_str (), *mb))
- {
- mb->release ();
- ACE_THROW (CORBA::INTERNAL ());
- }
-
- mb->release ();
+ xercesc::XMLPlatformUtils::Initialize();
}
- else
- {
- CORBA::Octet* file = 0;
-
- //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 = RM_Helper::read_from_disk (location, length);
-
- if (!file)
- ACE_THROW (CORBA::INTERNAL ());
-
- //Store the package in the local RM dir for future retrieval
- if (!RM_Helper::write_to_disk (package_path.c_str (), file, length))
+ catch (const XMLException& xml_e)
{
- delete file;
- ACE_THROW (CORBA::INTERNAL ());
- }
-
- //NOTE: MEMORY LEAK UNLESS delete file; change to Auto_Ptr
- delete file;
+ char* message = XMLString::transcode (xml_e.getMessage());
+ ACE_Auto_Basic_Array_Ptr<char> cleanup_message (message);
+ ACE_DEBUG ((LM_DEBUG, "Error during initialization : %s\n", message));
+ return;
}
-
-
- ZIP_Wrapper::uncompress (const_cast<char*> (package_path.c_str ()),
- const_cast<char*> (this->install_root_.c_str ()),
- false //not verbose
- );
-
- //Start the parsing
-
- ACE_CString pc_name;
-
- this->find_PC_name (const_cast<char*> (package_path.c_str ()), pc_name);
-
- //if the PackageConfiguration name cannot be found, then there is nothing to install
- if (pc_name == "")
- ACE_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 ());
-
-
- //forming the server path info
- ACE_CString server_path (this->HTTP_server_);
- server_path += installationName;
- server_path += "/implementations/";
-
- //NOTE: ComponentPackageReferences are currently NOT supported
- if (!(pc->basePackage.length () > 0))
- ACE_THROW (CORBA::NO_IMPLEMENT ());
-
- PC_Updater updater (server_path, package_path);
-
- if (!updater.update (pc))
+ try
{
- ACE_DEBUG ((LM_ERROR, "[RM] problem updating the PackageConfiguration!\n"));
- remove_extracted_package (package_path.c_str (), path.c_str ());
- remove (package_path.c_str ());
- ACE_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_DEBUG ((LM_ERROR,
- "[RM] could not bind %s.\n",
- installationName));
-
- //clean the extracted files
- remove_extracted_package (package_path.c_str (), path.c_str ());
- //remove the package
- remove (package_path.c_str ());
- //remove the PackageConfiguration externalization
- remove (pc_path.c_str ());
-
- //throw exception
- ACE_THROW (CORBA::INTERNAL ());
- }
-
- //ALSO NEED THE UUID here
- if (this->uuids_.bind (ACE_CString (pc->UUID), path) == -1)
- {
- ACE_DEBUG ((LM_ERROR,
- "[RM] could not bind %s.\n",
- pc->UUID));
-
- //unbind the name
- this->names_.unbind (installationName);
-
- //clean the extracted files
- remove_extracted_package (package_path.c_str (), path.c_str ());
- //remove the package
- remove (package_path.c_str ());
- //remove the PackageConfiguration externalization
- remove (pc_path.c_str ());
-
- //throw exception
- ACE_THROW (CORBA::INTERNAL ());
- }
-
-#if defined ASSEMBLY_INTERFACE_SUPPORT
- //now add the type interface
- //TODO: CHECK if successful
- if(!this->add_type (pc, installationName))
- ACE_DEBUG ((LM_ERROR, "Failed to add the type\n"));
-#endif
-
- this->dump ();
-
- ACE_DEBUG ((LM_INFO,
- "Installed PackageConfiguration \n\tname: %s \n\tuuid: %s\n",
- installationName, pc->UUID));
-}
-
+ CIAO::Config_Handler::Config_Error_Handler tpd_err_handler;
+ CIAO::Config_Handler::Config_Error_Handler pc_err_handler;
+ auto_ptr<DOMBuilder> tpd_parser (CIAO::Config_Handler::Utils::
+ create_parser ());
+ tpd_parser->setErrorHandler(&tpd_err_handler);
+ DOMDocument* tpd_doc = tpd_parser->parseURI (location);
-//-----------------------------------------------------------------
-//createPackage
-//
-//-----------------------------------------------------------------
-
-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
- ))
-{
- ACE_THROW (CORBA::NO_IMPLEMENT ());
-}
-
-
-//-----------------------------------------------------------------
-//findPackageByName
-//
-//-----------------------------------------------------------------
-
-::Deployment::PackageConfiguration*
-CIAO_RepositoryManagerDaemon_i::findPackageByName (const char * name)
-
- ACE_THROW_SPEC ((
- CORBA::SystemException,
- ::Deployment::NoSuchName
- ))
-{
- // Find out if the PackageConfiguration was installed in the repository,
- // return it if found or throw and exception otherwise
-
- PCEntry *entry = 0;
-
- if (this->names_.find (ACE_CString (name), entry) != 0)
- ACE_THROW (Deployment::NoSuchName ());
- //PackageConfiguration was not found
-
- ACE_CString pc_path (entry->int_id_.c_str ());
- pc_path += PC_EXTENSION;
-
- Deployment::PackageConfiguration_var pc;
- ACE_NEW_THROW_EX (pc,
- Deployment::PackageConfiguration (),
- CORBA::INTERNAL ());
-
- ACE_CHECK_RETURN (0);
-
- if(!RM_Helper::reincarnate (pc, pc_path.c_str ()))
- ACE_THROW_RETURN (CORBA::INTERNAL (), 0);
-
- ACE_DEBUG ((LM_INFO, "Successfully looked up \'%s\'.\n", name));
-
- return pc._retn ();
-}
-
-
-//-----------------------------------------------------------------
-//findPackageByUUID
-//
-//-----------------------------------------------------------------
-
-::Deployment::PackageConfiguration*
-CIAO_RepositoryManagerDaemon_i::findPackageByUUID (const char * UUID)
-
- ACE_THROW_SPEC ((
- CORBA::SystemException,
- ::Deployment::NoSuchName
- ))
-{
- // Find out if the PackageConfiguration was installed in the repository,
- // return it if found or throw and exception otherwise
-
- PCEntry *entry = 0;
-
- if (this->uuids_.find (ACE_CString (UUID), entry) != 0)
- ACE_THROW (Deployment::NoSuchName ());
- //PackageConfiguration was not found
-
- ACE_CString pc_path (entry->int_id_.c_str ());
- pc_path += PC_EXTENSION;
-
- Deployment::PackageConfiguration_var pc;
- ACE_NEW_THROW_EX (pc,
- Deployment::PackageConfiguration (),
- CORBA::INTERNAL ());
-
- ACE_CHECK_RETURN (0);
-
- if(!RM_Helper::reincarnate (pc, pc_path.c_str ()))
- ACE_THROW_RETURN (CORBA::INTERNAL (), 0);
-
- ACE_DEBUG ((LM_INFO, "Successfully looked up %s.\n", UUID));
-
- return pc._retn ();
-}
-
-//-----------------------------------------------------------------
-//findPackageByType
-//
-//-----------------------------------------------------------------
-
-::CORBA::StringSeq * CIAO_RepositoryManagerDaemon_i::findNamesByType (
- const char * type
- )
- ACE_THROW_SPEC ((
- CORBA::SystemException
- ))
-{
-
-#if !defined ASSEMBLY_INTERFACE_SUPPORT
- ACE_THROW (CORBA::NO_IMPLEMENT ());
-#endif
-
-#if defined ASSEMBLY_INTERFACE_SUPPORT
-
- CIEntry *entry = 0;
-
- //find the type in the interface map
- if (!this->types_.find (ACE_CString (type), entry))
- {
- //return an empty sequence
- CORBA::StringSeq_var seq;
- ACE_NEW_THROW_EX (seq, CORBA::StringSeq (0), CORBA::INTERNAL ());
- ACE_CHECK_RETURN (0);
- return seq._retn ();
- }
- else
- {
- //The CORBA::StringSeq is implemented as an array and growing
- //one at a time on demand is very inefficient due to the
- //deallocations and reallocations. This is why we figure out the
- //number of elements in advance and then create a CORBA::StringSeq
- //of the right length
-
- CIBucket_Iterator counter (this->types_, type);
-
- CIBucket_Iterator end (this->types_,
- type,
- 1 /*tail = true*/);
+ if (tpd_err_handler.getErrors())
+ {
+ throw Deployment::PackageError ();
+ }
- //count the number of components implementing this type
- CORBA::ULong num_entries = 0;
- for (;
- counter != end;
- ++counter)
- ++num_entries;
+ CIAO::Config_Handler::TPD_Handler top_pc_handler
+ (tpd_doc,
+ DOMNodeFilter::SHOW_ELEMENT |
+ DOMNodeFilter::SHOW_TEXT);
+ ACE_TString package_location = top_pc_handler.
+ process_TopLevelPackageDescription ();
- //allocate a sequence of the right length
- CORBA::StringSeq_var seq;
- ACE_NEW_THROW_EX (seq,
- CORBA::StringSeq (num_entries),
- CORBA::INTERNAL ());
+ auto_ptr<DOMBuilder> pc_parser (CIAO::Config_Handler::Utils::
+ create_parser ());
+ pc_parser->setErrorHandler(&pc_err_handler);
+ DOMDocument* pc_doc = pc_parser->parseURI (package_location.c_str());
- ACE_CHECK_RETURN (0);
+ if (pc_err_handler.getErrors())
+ {
+ throw Deployment::PackageError ();
+ }
- //store the elements in the string sequence
- CIBucket_Iterator iter (this->types_, type);
- CORBA::ULong index = 0;
- for (;
- iter != end && index < num_entries;
- ++iter, ++index)
- {
- CIEntry& element = *iter;
- seq[index] = CORBA::string_dup (element.int_id_.c_str ());
+ CIAO::Config_Handler::PC_Handler pc_handler (pc_doc,
+ DOMNodeFilter::SHOW_ELEMENT |
+ DOMNodeFilter::SHOW_TEXT);
+ Deployment::PackageConfiguration pc;
+ pc_handler.process_PackageConfiguration (pc);
+ //Deployment::DnC_Dump::dump (pc);
+ this->pc_table_.bind (installation_name, (pc));
+ //Deployment::DnC_Dump::dump (*(&pc));
}
-
- return seq._retn ();
- }
-
-#endif
-}
-
-
-//-----------------------------------------------------------------
-//getAllNames
-//
-//-----------------------------------------------------------------
-
-::CORBA::StringSeq*
-CIAO_RepositoryManagerDaemon_i::getAllNames ()
-
- ACE_THROW_SPEC ((
- CORBA::SystemException
- ))
-{
- //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.
-
- CORBA::ULong num_entries = 0;
-
- 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::INTERNAL ());
-
- ACE_CHECK_RETURN (0);
-
- seq->length (num_entries);
-
- CORBA::ULong index = 0;
- for (PCMap_Iterator iter = this->names_.begin ();
- iter != this->names_.end () && index < num_entries;
- ++iter, ++index)
- {
- CIEntry& element = *iter;
- seq[index] = CORBA::string_dup (element.ext_id_.c_str ());
- }
-
- ACE_DEBUG ((LM_INFO, "Current # packages [ %d ]\n", seq->length ()));
-
- return seq._retn (); //release the underlying CORBA::StringSeq
-}
-
-
-//-----------------------------------------------------------------
-//getAllTypes
-//
-//-----------------------------------------------------------------
-
-::CORBA::StringSeq * CIAO_RepositoryManagerDaemon_i::getAllTypes (
-
- )
- ACE_THROW_SPEC ((
- CORBA::SystemException
- ))
-{
-
-#if !defined ASSEMBLY_INTERFACE_SUPPORT
- ACE_THROW (CORBA::NO_IMPLEMENT ());
-#endif
-
-#if defined ASSEMBLY_INTERFACE_SUPPORT
-
- //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.
-
- CORBA::ULong num_entries = 0;
-
- for (PCMap_Iterator i = this->names_.begin ();
- i != this->names_.end ();
- ++i)
- ++num_entries;
-
- ACE_DEBUG ((LM_DEBUG, "# names: %d\n", num_entries));
-
-
- CORBA::StringSeq_var seq;
- ACE_NEW_THROW_EX (seq,
- CORBA::StringSeq (num_entries),
- CORBA::INTERNAL ());
-
- ACE_CHECK_RETURN (0);
-
- seq->length (num_entries);
-
- CORBA::ULong index = 0;
- for (CIMap_Iterator iter = this->types_.begin ();
- iter != this->types_.end () && index < num_entries;
- ++iter, ++index)
-
- {
- CIEntry& element = *iter;
- seq[index] = CORBA::string_dup (element.int_id_.c_str ());
- }
-
- return seq._retn (); //release the underlying CORBA::StringSeq
-
-#endif
-}
-
-
-//-----------------------------------------------------------------
-//DeletePackage
-//
-//-----------------------------------------------------------------
-
-void CIAO_RepositoryManagerDaemon_i::deletePackage (
- const char * installationName
- )
- ACE_THROW_SPEC ((
- CORBA::SystemException,
- ::Deployment::NoSuchName
- ))
-{
- bool internal_err = false;
-
- PCEntry *entry = 0;
-
- if (this->names_.find (ACE_CString (installationName), entry) != 0)
- ACE_THROW (Deployment::NoSuchName ());
-
- //cache the package path
- ACE_CString path (entry->int_id_.c_str ());
-
- //remove the name association
- if (this->names_.unbind (installationName) == -1)
- {
- ACE_DEBUG ((LM_ERROR,
- "Unable to unbind %s.\n",
- installationName));
- internal_err = true;
- }
-
- //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
-
- Deployment::PackageConfiguration_var pc;
- ACE_NEW_THROW_EX (pc,
- Deployment::PackageConfiguration (),
- CORBA::INTERNAL ());
-
- ACE_CHECK_RETURN (0);
-
- if(!RM_Helper::reincarnate (pc, pc_path.c_str ()))
- {
- ACE_DEBUG ((LM_ERROR, "Could not reincarnate PC\n"));
- internal_err = true;
- }
-
- //if (this->uuids_.find (ACE_CString (pc->UUID), entry) != 0)
- //{
- // ACE_DEBUG ((LM_ERROR, "Could not remove UUID\n"));
- // internal_err = true;
- //}
- //else
- // //remove the UUID association
- // this->uuids_.unbind (entry->int_id_.c_str ());
-
- if (this->uuids_.unbind (ACE_CString (pc->UUID)) == -1)
- {
- ACE_DEBUG ((LM_ERROR, "Could not remove UUID\n"));
- internal_err = true;
- }
-
-#if defined ASSEMBLY_INTERFACE_SUPPORT
- //remove the type from the interface map
- if (!this->remove_type (pc, installationName))
- {
- ACE_DEBUG ((LM_ERROR, "Could not remove type\n"));
- internal_err = true;
- }
-#endif
-
- //actually delete the package here!
-
- //clean the extracted files
- remove_extracted_package (package_path.c_str (), path.c_str ());
- //remove the package
- remove (package_path.c_str ());
- //remove the PackageConfiguration externalization
- remove (pc_path.c_str ());
-
- this->dump ();
-
- if (internal_err)
- ACE_THROW (CORBA::INTERNAL ());
- else
- ACE_DEBUG ((LM_INFO, "Successfully deleting \'%s\'\n", installationName));
-
-}
-
-
-
-
-
-//==========================================HELPER METHODS==================================================
-
-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)
+ catch (CORBA::Exception& ex)
{
- ACE_OS::chdir (this->cwd_);
- ACE_ERROR ((LM_ERROR,
- "(%P|%t) RepositoryManager: error extracting necessary files\n"));
- ACE_THROW (CORBA::INTERNAL ());
+ ACE_PRINT_EXCEPTION (ex, "Caught CORBA Exception: ");
+ return;
}
-
- Deployment::PackageConfiguration_var pc;
- //parse the PCD to make sure that there are no package errors
- ACE_TRY
+ catch (const DOMException& e)
{
- CIAO::Config_Handlers::STD_PC_Intf intf (pcd_name.c_str ());
+ const unsigned int maxChars = 2047;
+ XMLCh errText[maxChars + 1];
- pc = intf.get_PC ();
+ ACE_ERROR ((LM_ERROR, "\nException occured while parsing %s: \
+ \n",location));
+ ACE_ERROR ((LM_ERROR, "DOMException code: %d\n ", e.code));
+ if (DOMImplementation::loadDOMExceptionMsg (e.code, errText, maxChars))
+ {
+ char* message = XMLString::transcode (errText);
+ ACE_Auto_Basic_Array_Ptr<char> cleanup_message (message);
+ ACE_ERROR ((LM_ERROR, "Message is: %s\n", message));
+ }
+ ACE_ERROR ((LM_ERROR, "Caught DOM exception\n"));
+ return;
}
- ACE_CATCHALL
+ 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_);
- ACE_THROW (Deployment::PackageError ());
+ ACE_ERROR ((LM_ERROR, "Caught unknown exception\n"));
+ return;
}
- ACE_ENDTRY;
- //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 ();
}
-
-//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)
+void
+CIAO::RepositoryManager_Impl::
+createPackage (const char*,
+ const Deployment::PackageConfiguration&,
+ const char*,
+ CORBA::Boolean
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Deployment::NameExists,
+ Deployment::PackageError))
{
- URL_Parser *parser = TheURL_Parser::instance ();
- if (!parser->parseURL (const_cast<char*> (URL)))
- return 0;
-
- // Create a client
- HTTP_Client client;
-
- // Open the client
- 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;
+ ACE_THROW (CORBA::NO_IMPLEMENT ());
}
-
-
-//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;
- //parse the PCD to make sure that there are no package errors
- ACE_TRY
- {
- CIAO::Config_Handlers::STD_PC_Intf intf (pc_name);
-
- pc = intf.get_PC ();
+CIAO::RepositoryManager_Impl::findPackageByName (const char* name
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Deployment::NoSuchName))
+{
+ Deployment::PackageConfiguration pc;
+ if (pc_table_.find (name, pc) == 0)
+ {
+ //Deployment::PackageConfiguration* dup_pc = pc;
+ //Deployment::DnC_Dump::dump (*pc);
+ //return dup_pc;
+ Deployment::PackageConfiguration_var pc_var = 0;
+ ACE_NEW_THROW_EX (pc_var,
+ Deployment::PackageConfiguration (pc),
+ CORBA::NO_MEMORY ());
+ //Deployment::DnC_Dump::dump (*pc_var);
+ return pc_var._retn ();
}
- ACE_CATCHALL
- {
- 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_);
- 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 (this->cwd_);
-
- return pc._retn ();
-}
-
-
-//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
-
- //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;
-
- size_t skip_len = ACE_OS::strlen ("descriptors") + 1;
-
- while (!list.is_empty ())
+ else
{
- 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;
-
- //deallocate the head of the filename list
- delete inf;
+ ACE_THROW_RETURN (Deployment::NoSuchName (), 0);
}
}
-
-//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_descriptor_files (char* package, ACE_CString& pcd_name)
+Deployment::PackageConfiguration*
+CIAO::RepositoryManager_Impl::
+findPackageByUUID (const char*
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Deployment::NoSuchName))
{
- //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 ();
- 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;
- }
-
- return 1;
+ ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0);
}
-int CIAO_RepositoryManagerDaemon_i::remove_descriptor_files (char* package)
+CORBA::StringSeq*
+CIAO::RepositoryManager_Impl::
+findNamesByType (const char*
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException))
{
- 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 write out descriptor to disk!\n"));
- return_code = 0;
- }
- }
- //deallocate the head of the filename list
- delete inf;
- }
-
- return return_code;
+ ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0);
}
-//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.
-//return 1 on success
-// 0 on error
-
-int CIAO_RepositoryManagerDaemon_i::remove_extracted_package
-(const char* package_path,
- const char* extraction_location)
+CORBA::StringSeq*
+CIAO::RepositoryManager_Impl::
+getAllNames (ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException))
{
- //change the working dir
- if (ACE_OS::chdir (extraction_location) == -1)
- ACE_ERROR_RETURN ((LM_ERROR,
- "[RM::remove_extracted_package] Unable to chdir to doomed directory!\n"),
- 0);
-
- 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 (const_cast <char*> (package_path), list)))
- {
- //change back the the old working dir
- ACE_OS::chdir (this->cwd_);
- return 0;
- }
-
- while (!list.is_empty ())
- {
- ZIP_File_Info* inf = list.delete_head ();
-
- //delete file from disk
- if(remove (inf->name_.c_str ()))
- {
- ACE_ERROR ((LM_ERROR,
- "[RM::remove_extracted files] Unable to delete %s!\n", inf->name_.c_str ()));
- return_code = 0;
- }
-
- //deallocate the head of the filename list
- delete inf;
- }
-
- //now remove the descriptors and implementations directories.
- ACE_OS::rmdir ("descriptors");
- ACE_OS::rmdir ("implementations");
-
- //now go one directory up and delete the extraction directory
- ACE_OS::chdir (this->install_root_.c_str ());
- ACE_OS::rmdir (extraction_location);
-
- //change back the the old working dir
- ACE_OS::chdir (this->cwd_);
-
- return return_code;
+ ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0);
}
-#if defined ASSEMBLY_INTERFACE_SUPPORT
-
-//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)
+CORBA::StringSeq*
+CIAO::RepositoryManager_Impl::
+getAllTypes (ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException))
{
- const char* ifaceUUID = 0;
- //
- if (pc.basePackage.length () > 0)
- {
- ifaceUUID = pc.basePackage[0]
- .implementation[0]
- .referencedImplementation
- .implements
- .specificType.in ();
- //.UUID.in ();
-
- ACE_DEBUG ((LM_DEBUG, "storing under: %s\n", ifaceUUID));
-
- CIEntry *entry = 0;
-
- //create an entry for this interface type
- if (this->types_.bind (ACE_CString (ifaceUUID),
- ACE_CString (name)/*pc.label.in ()*/ ) != 0)
- return 0;
-
- }
- else //ComponentPackageReference
- {
- //not implemented yet
- return 0;
- }
-
- return 1;
+ ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0);
}
-
-
-//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)
+void
+CIAO::RepositoryManager_Impl::
+deletePackage (const char*
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Deployment::NoSuchName))
{
- const char* ifaceUUID = 0;
- //
- if (pc.basePackage.length () > 0)
- {
- ifaceUUID = pc.basePackage[0]
- .implementation[0]
- .referencedImplementation
- .implements
- .specificType.in ();
- //.UUID.in ();
-
- ACE_DEBUG ((LM_DEBUG, "removing by: %s\n", ifaceUUID));
-
- CIEntry *entry = 0;
-
- //find the type in the interface map
- if (this->types_.find (ACE_CString (ifaceUUID), entry) == 0)
- {
- ACE_DEBUG ((LM_DEBUG, "Type to be removed: ",
- "KEY: %s", entry->ext_id_.c_str (),
- " VAL: %s\n", entry->int_id_.c_str ()));
- }
- else
- ACE_DEBUG ((LM_DEBUG, "Could not find type!\n"));
-
- ACE_DEBUG ((LM_DEBUG, "Attempting to remove: %s\n", ifaceUUID));
- CIBucket_Iterator iter (this->types_, ACE_CString (ifaceUUID));
-
- CIBucket_Iterator end (this->types_,
- ACE_CString (ifaceUUID),
- 1 /*tail = true*/);
- for (;
- iter != end;
- ++iter)
- {
- CIEntry& element = *iter;
-
- if(!(strcmp (element.int_id_.c_str (), name /*pc.label.in ()*/)))
- {
- //clashes are not allowed so this must be the ONLY
- //element that we are interested in
-
- //lets remove this element
- this->types_.unbind (&element);
- return 1;
- }
- }
-
- }
- else //ComponentPackageReference
- {
- //not implemented yet
- return 0;
- }
-
- return 1;
+ ACE_THROW (CORBA::NO_IMPLEMENT ());
}
-#endif //for has ASSEMBLY_INTERFACE_SUPPORT
-
-//function to dump the state of the RepositoryManager
-void CIAO_RepositoryManagerDaemon_i::dump (void)
+void
+CIAO::RepositoryManager_Impl::shutdown (ACE_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException))
{
-#if defined (ACE_HAS_DUMP)
-
- ACE_DEBUG(LM_DEBUG, "NAMES:\n");
- this->names_.dump ();
- ACE_DEBUG(LM_DEBUG, "UUIDs:\n");
- this->uuids_.dump ();
-
-#if defined ASSEMBLY_INTERFACE_SUPPORT
- ACE_DEBUG (LM_DEBUG, "Component Interface Types:\n");
- this->types_.dump ();
-#endif
-
-#endif /* ACE_HAS_DUMP */
+ this->orb_->shutdown (1 ACE_ENV_SINGLE_ARG_PARAMETER);
}
-
diff --git a/TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager_Impl.h b/TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager_Impl.h
index 6538f254a9d..cfb9e4f715b 100644
--- a/TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager_Impl.h
+++ b/TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager_Impl.h
@@ -1,294 +1,162 @@
-
-/* -*- C++ -*- */
-
-//======================================================================
-/**
+/*=======================================================================
+ *
* @file RepositoryManager_Impl.h
*
* $Id$
*
- * Description:
- * This file is the main implementation file for the RepositoryManager
- * in CIAO. We have used a number of techniques in order to increase
- * scalability of the RepoMan while still maintaining complience with
- * the D&C spec
+ * @brief This file contains implementation for
+ * Deployment::RepositoryManager interface.
*
- * @author Stoyan Paunov
- */
-//======================================================================
-
-#ifndef REPOSITORYMANAGERI_H_
-#define REPOSITORYMANAGERI_H_
-
-
-//-----------------------------NOTE---------------------------------
-//I need to disable all the code which has to do with interface
-//type information because we currently do not support assembly
-//interfaces which causes undesired behavior with respect to the
-//hash tables because the specificType field in assembly interfaces
-//is empty, so two unrelated intefaces appear to be related.
-
-//uncomment this line to turn on the code that relates to interface types
-//#define ASSEMBLY_INTERFACE_SUPPORT 1
-
-
-#include "RepositoryManagerDaemonS.h"
-
-#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"
+ * @author Jaiganesh Balasubramanian <jai@dre.vanderbilt.edu>
+ *
+ *======================================================================*/
+
+#ifndef REPOSITORYMANAGER_IMPL_H
+#define REPOSITORYMANAGER_IMPL_H
+#include /**/ "ace/pre.h"
+
+#include "RepositoryManagerS.h"
+#include "ace/Get_Opt.h"
+#include "RepositoryManager_Impl.h"
+#include "ace/Synch.h"
+#include "ace/Hash_Map_Manager.h"
+#include "ace/Auto_Ptr.h"
+#include "ace/Log_Msg.h"
+#include "ace/OS_main.h"
+#include "tao/Exception.h"
+#include "CIAO/DAnCE/Old_Config_Handlers/XercesString.h"
+#include <xercesc/util/XMLUniDefs.hpp>
+#include <xercesc/parsers/XercesDOMParser.hpp>
+#include <xercesc/parsers/AbstractDOMParser.hpp>
+#include "CIAO/DAnCE/Old_Config_Handlers/Config_Handler_export.h"
+#include "CIAO/DAnCE/Old_Config_Handlers/Domain_Handler.h"
+#include "CIAO/DAnCE/Old_Config_Handlers/PC_Handler.h"
+#include "CIAO/DAnCE/Old_Config_Handlers/Plan_Handler.h"
+#include "CIAO/DAnCE/Old_Config_Handlers/CompImplDesc_Handler.h"
+#include "CIAO/DAnCE/Old_Config_Handlers/DnC_Dump.h"
+#include "CIAO/DAnCE/Old_Config_Handlers/Utils.h"
+#include "CIAO/DAnCE/Old_Config_Handlers/Config_Error_Handler.h"
+
+using Config_Handler::XStr;
+using xercesc::XMLUni;
+using xercesc::XMLString;
+using xercesc::XMLException;
+using xercesc::DOMException;
+using xercesc::DOMBuilder;
+using xercesc::DOMImplementationRegistry;
+using xercesc::DOMImplementationLS;
+using xercesc::DOMImplementation;
+using xercesc::DOMAttr;
+using xercesc::DOMNamedNodeMap;
+using xercesc::DOMLocator;
+using xercesc::DOMError;
+using xercesc::DOMNodeList;
+using xercesc::DOMDocument;
+using xercesc::DOMDocumentTraversal;
+using xercesc::DOMNodeIterator;
+using xercesc::DOMNode;
+using xercesc::DOMNodeFilter;
+using xercesc::XercesDOMParser;
+using xercesc::AbstractDOMParser;
#if !defined (ACE_LACKS_PRAGMA_ONCE)
-#pragma once
+# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
-namespace
+/**
+ *
+ * @class ReposityManager_Impl
+ *
+ * @brief This class implements the RepositoryManager. RepositoryManager
+ * assists the execution process after the planning stage.
+ *
+ */
+namespace CIAO
{
- /// Directory where the packages will be stored locally
- const static char* INSTALL_PATH = "RepositoryDir";
-
- const static size_t TEMP_LEN = 512;
-
- const static char* PC_EXTENSION = ".epc";
+ class RepositoryManager_Impl
+ : public virtual POA_CIAO::RepositoryManagerDaemon
+ {
+
+ public:
+
+ RepositoryManager_Impl ();
+
+ /// Constructor.
+ RepositoryManager_Impl (CORBA::ORB_ptr orb,
+ PortableServer::POA_ptr poa
+ ACE_ENV_ARG_DECL);
+
+ virtual void installPackage (const char* installation_name,
+ const char* location
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Deployment::NameExists,
+ Deployment::PackageError));
+
+ virtual void createPackage (const char* installation_name,
+ const Deployment::PackageConfiguration& pc,
+ const char* base_location,
+ CORBA::Boolean replace
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Deployment::NameExists,
+ Deployment::PackageError));
+
+ virtual Deployment::PackageConfiguration*
+ findPackageByName (const char* name
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Deployment::NoSuchName));
+
+ virtual Deployment::PackageConfiguration*
+ findPackageByUUID (const char* name
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Deployment::NoSuchName));
+
+ virtual CORBA::StringSeq*
+ findNamesByType (const char* type
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual CORBA::StringSeq*
+ getAllNames (ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual CORBA::StringSeq*
+ getAllTypes (ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual void
+ deletePackage (const char* name
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Deployment::NoSuchName));
+
+ virtual void
+ shutdown (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ protected:
+
+ ~RepositoryManager_Impl ();
+ // destructor
+
+ typedef ACE_Hash_Map_Manager_Ex<const char *,
+ Deployment::PackageConfiguration,
+ ACE_Hash<const char *>, ACE_Equal_To<const char *>,
+ TAO_SYNCH_MUTEX> pc_table;
+
+ typedef pc_table::iterator pc_iterator;
+ // Cached ORB pointer
+ CORBA::ORB_var orb_;
+
+ // Cached POA pointer
+ PortableServer::POA_var poa_;
+
+ pc_table pc_table_;
+ };
}
-class CIAO_RepositoryManagerDaemon_i :
- public virtual POA_CIAO::RepositoryManagerDaemon
-{
-public:
- /// Constructor
- CIAO_RepositoryManagerDaemon_i (CORBA::ORB_ptr the_orb,
- const char* server = "http://localhost:5432/");
-
- /// 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 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.
- ///return 1 on success
- /// 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*/
- ///returns 1 on success
- /// 0 on error
-
- int remove_extracted_package (const char* package_path, const char* extraction_location);
-
-#if defined ASSEMBLY_INTERFACE_SUPPORT
- ///function to extract the type of the component from
- ///the PackageConfiguration and update the interface map
- ///returns 1 on success
- /// 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
- ///returns 1 on success
- /// 0 on error
-
- int remove_type (::Deployment::PackageConfiguration& pc,
- const char* name);
-
-#endif
-
- ///function to dump the state of the RepositoryManager
- void dump (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 ACE_Hash_Map_Entry <ACE_CString,ACE_CString> PCEntry;
-
-
- /// Cached information about the installed Component Interfaces
- /// A map which associates Component Interface UUIDs with the
- /// names of packages which implement this component type
- /// Key: Component Interface UUID
- /// Value: linked list 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_Map_Manager_Ex<ACE_CString,
- ACE_CString,
- ACE_Hash<ACE_CString>,
- ACE_Equal_To<ACE_CString>,
- ACE_RW_Mutex> CIMap;
-
-
- typedef CIMap::iterator CIMap_Iterator;
- typedef ACE_Hash_Map_Entry <ACE_CString,ACE_CString> CIEntry;
- typedef ACE_Hash_Map_Bucket_Iterator<ACE_CString,
- ACE_CString,
- ACE_Hash<ACE_CString>,
- ACE_Equal_To<ACE_CString>,
- ACE_RW_Mutex> CIBucket_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_;
-
-#if defined ASSEMBLY_INTERFACE_SUPPORT
- //a hash map which associates Component Interface
- //UUIDs with their implementations
- CIMap types_;
-#endif
-
- //the ORB
- CORBA::ORB_var the_orb_;
-
- char cwd_ [TEMP_LEN]; //will hold the current working directory
- ACE_CString install_root_; //full path for the install directory
- ACE_CString HTTP_server_; //location of the server
-
-};
-
-#endif /* REPOSITORYMANAGER_H_ */
-
+#include /**/ "ace/post.h"
+#endif /* REPOSITORYMANAGER_IMPL_H */
diff --git a/TAO/CIAO/DAnCE/RepositoryManager/Repository_Manager.cpp b/TAO/CIAO/DAnCE/RepositoryManager/Repository_Manager.cpp
new file mode 100644
index 00000000000..b04f594cc91
--- /dev/null
+++ b/TAO/CIAO/DAnCE/RepositoryManager/Repository_Manager.cpp
@@ -0,0 +1,305 @@
+// $Id$
+
+#include "RepositoryManager_Impl.h"
+#include "Update_Plan.h"
+#include "ExecutionManager/ExecutionManagerC.h"
+#include "Config_Handlers/DnC_Dump.h"
+#include "NodeManager/NodeManagerC.h"
+#include "ace/OS_NS_stdio.h"
+#include "ace/streams.h"
+#include "ace/Auto_Ptr.h"
+using namespace std;
+
+const char * exec_ior = "file://exec_mgr.ior";
+const char * node_daemon_ior = 0;
+
+static void
+usage (const ACE_TCHAR* program)
+{
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Usage: %s -p <URI> -d <URI> -k <EX_IOR> \
+ -t <NODE_MANAGER_IOR> \n")
+ ACE_TEXT (" <URI>: URI identifying the package\n"),
+ program));
+}
+
+int
+ACE_TMAIN (int argc, ACE_TCHAR *argv[])
+{
+ // Initialize orb
+ CORBA::ORB_var orb =
+ CORBA::ORB_init (argc,
+ argv,
+ ""
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (-1);
+
+ // top level package URL
+ char* package_url = 0;
+
+ // deployment plan URL
+ char* plan_url = 0;
+
+ ACE_Get_Arg_Opt<char> get_opt (argc, argv, ACE_TEXT ("p:d:k:t:"));
+ int c;
+
+ while ((c = get_opt ()) != EOF)
+ {
+ switch (c)
+ {
+ case 'p':
+ package_url = get_opt.opt_arg ();
+ break;
+ case 'd':
+ plan_url = get_opt.opt_arg ();
+ break;
+ case 'k':
+ exec_ior = get_opt.opt_arg ();
+ break;
+ case 't':
+ node_daemon_ior = get_opt.opt_arg ();
+ break;
+ default:
+ usage(argv[0]);
+ return -1;
+ }
+ }
+
+ if (package_url == 0) {
+ usage(argv[0]);
+ return -1;
+ }
+
+ if (plan_url == 0) {
+ usage(argv[0]);
+ return -1;
+ }
+
+ try
+ {
+ xercesc::XMLPlatformUtils::Initialize();
+ }
+
+ catch (const XMLException& xml_e)
+ {
+ char* message = XMLString::transcode (xml_e.getMessage());
+ ACE_Auto_Basic_Array_Ptr<char> cleanup_message (message);
+ ACE_DEBUG ((LM_DEBUG, "Error during initialization : %s\n", message));
+ return 1;
+ }
+ try
+ {
+ // get a reference to the parser.
+ auto_ptr<DOMBuilder> plan_parser (
+ CIAO::Config_Handler::Utils::create_parser ()
+ );
+
+ CIAO::Config_Handler::Config_Error_Handler handler;
+ plan_parser->setErrorHandler(&handler);
+
+ auto_ptr<DOMBuilder> tpd_parser (
+ CIAO::Config_Handler::Utils::create_parser ()
+ );
+
+ CIAO::Config_Handler::Config_Error_Handler tpd_handler;
+ tpd_parser->setErrorHandler(&tpd_handler);
+
+ // use the parser to parse the deployment plan URL and create
+ // a DOM document.
+ DOMDocument* plan_doc = plan_parser->parseURI (plan_url);
+
+ if (handler.getErrors())
+ {
+ return 1;
+ }
+
+ //DOMDocument* tpd_doc = tpd_parser->parseURI (package_url);
+
+ //ACE_UNUSED_ARG (tpd_doc);
+
+ if (tpd_handler.getErrors())
+ {
+ return 1;
+ }
+
+ if (plan_doc == NULL)
+ {
+ ACE_DEBUG ((LM_DEBUG, "Null DOM Document obtained, \
+ May be the URL is wrong!!\n"));
+ throw CIAO::Null_Dom_Document ();
+ }
+
+ // free up DOMBuilder. DOMBuilder also deletes the DOMDocument memory.
+ //auto_ptr<DOMBuilder> cleanup_parser (parser);
+
+ // call the Deployment Plan handler to parse the XML descriptor.
+ CIAO::Config_Handler::Plan_Handler plan_handler (
+ plan_doc,
+ DOMNodeFilter::SHOW_ELEMENT | DOMNodeFilter::SHOW_TEXT
+ );
+
+ Deployment::DeploymentPlan plan;
+ plan_handler.process_plan (plan);
+
+ // call the PackageConfiguration handler to parse the XML descriptor.
+ Deployment::PackageConfiguration* pc;
+
+ CIAO::RepositoryManager_Impl *rep_impl = 0;
+ ACE_NEW_RETURN (rep_impl,
+ CIAO::RepositoryManager_Impl (),
+ -1);
+ PortableServer::ServantBase_var owner_transfer (rep_impl);
+
+ rep_impl->installPackage ("PC", package_url);
+ pc = rep_impl->findPackageByName ("PC");
+ //Deployment::DnC_Dump::dump (*pc);
+
+ CIAO::REF_MAP ref_map;
+ CIAO::REF_MAP primary_ref_map;
+
+ // traverse the PackageConfiguration IDL data structure and
+ // update the deployment plan IDL data structure.
+ CIAO::traverse_package (pc, plan, ref_map, primary_ref_map);
+
+ //Deployment::DnC_Dump::dump (plan);
+
+ // Pass the parsed plan to the Execution Manager to start the
+ // Deployment Process.
+
+ CORBA::Object_var obj = orb->string_to_object (exec_ior
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ CIAO::ExecutionManagerDaemon_var exec_mgr =
+ CIAO::ExecutionManagerDaemon::_narrow (obj.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ if (CORBA::is_nil (exec_mgr.in ()))
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Executor: nil Execution Manager reference, \
+ narrow failed\n"));
+ return 1;
+
+ }
+
+ CIAO::NodeManager_var node_mgr;
+ if (node_daemon_ior != 0)
+ {
+ CORBA::Object_var node_mgr_obj =
+ orb->string_to_object (node_daemon_ior
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ node_mgr =
+ CIAO::NodeManager::_narrow (node_mgr_obj.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ if (CORBA::is_nil (node_mgr.in ()))
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Executor: nil Node Manager reference, \
+ narrow failed\n"));
+ return 1;
+ }
+ }
+
+ ACE_DEBUG ((LM_DEBUG, "Executor: Obtained Execution Manager ref \n"));
+ Deployment::DomainApplicationManager_var dapp_mgr =
+ exec_mgr->preparePlan (plan, 1);
+
+ if (CORBA::is_nil (dapp_mgr.in ()))
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Executor:preparePlan call failed:nil \
+ DomainApplicationManager reference\n"));
+ return 1;
+ }
+ ACE_DEBUG ((LM_DEBUG,
+ "Executor: Obtained DomainApplication Manager ref \n"));
+
+ // Create a dummy set of properties and start the
+ // Launching of applications
+ Deployment::Properties_var properties;
+ ACE_NEW_RETURN (properties,
+ Deployment::Properties,
+ 1);
+ ACE_DEBUG ((LM_DEBUG, "Executor: start Launch application....."));
+
+ // Do not start the Application immediately
+ int start = 0;
+ dapp_mgr->startLaunch (properties.in (), start);
+ ACE_DEBUG ((LM_DEBUG, "[success]\n"));
+
+ // Call finish Launch to complete the connections
+ ACE_DEBUG ((LM_DEBUG, "Executor: finish Launch application....."));
+ dapp_mgr->finishLaunch (start);
+ ACE_DEBUG ((LM_DEBUG, "[success]\n"));
+
+ // Call start to activate components
+ ACE_DEBUG ((LM_DEBUG, "Executor: start activating components..."));
+ dapp_mgr->start ();
+ ACE_DEBUG ((LM_DEBUG, "[success]\n"));
+
+ ACE_DEBUG ((LM_DEBUG, "Executor: Application Deployed successfully \n"));
+ ACE_DEBUG ((LM_DEBUG, "Press <Enter> to tear down application \n"));
+
+ char dummy [256];
+ cin.getline (dummy, 256);
+ // Tear down the assembly
+
+ ACE_DEBUG ((LM_DEBUG, "Executor: destroy the application....."));
+ dapp_mgr->destroyApplication ();
+ ACE_DEBUG ((LM_DEBUG, "[success]\n"));
+
+ ACE_DEBUG ((LM_DEBUG, "Executor: destroy the manager....."));
+ exec_mgr->destroyManager (dapp_mgr.in ());
+ ACE_DEBUG ((LM_DEBUG, "[success]\n"));
+
+ if (node_daemon_ior != 0)
+ {
+ ACE_DEBUG ((LM_DEBUG, "shutting down node manager \n"));
+ exec_mgr->shutdown (); // shut down execution manager.
+ ACE_DEBUG ((LM_DEBUG, "[success]\n"));
+
+ ACE_DEBUG ((LM_DEBUG, "shutting down node manager \n"));
+ node_mgr->shutdown (); // shut down the node manager.
+ ACE_DEBUG ((LM_DEBUG, "[success]\n"));
+ }
+
+ orb->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
+ catch (CORBA::Exception& ex)
+ {
+ ACE_PRINT_EXCEPTION (ex, "Caught CORBA Exception: ");
+ return -1;
+ }
+ catch (const DOMException& e)
+ {
+ const unsigned int maxChars = 2047;
+ XMLCh errText[maxChars + 1];
+
+ ACE_ERROR ((LM_ERROR, "\nException occured while parsing %s: \
+ \n",plan_url));
+ ACE_ERROR ((LM_ERROR, "DOMException code: %d\n ", e.code));
+ if (DOMImplementation::loadDOMExceptionMsg (e.code, errText, maxChars))
+ {
+ char* message = XMLString::transcode (errText);
+ ACE_Auto_Basic_Array_Ptr<char> cleanup_message (message);
+ ACE_ERROR ((LM_ERROR, "Message is: %s\n", message));
+ }
+ //ACE_PRINT_EXCEPTION ("Caught DOM Exception: ");
+ ACE_ERROR ((LM_ERROR, "Caught DOM exception\n"));
+ return -1;
+ }
+ catch (...)
+ {
+ ACE_ERROR ((LM_ERROR, "Caught unknown exception\n"));
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/TAO/CIAO/DAnCE/RepositoryManager/Repository_Manager_conf.h b/TAO/CIAO/DAnCE/RepositoryManager/Repository_Manager_conf.h
new file mode 100644
index 00000000000..c746f4d6a9c
--- /dev/null
+++ b/TAO/CIAO/DAnCE/RepositoryManager/Repository_Manager_conf.h
@@ -0,0 +1,33 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Repository_Manager_conf.h
+ *
+ * $Id$
+ *
+ * @author Jaiganesh Balasubramanian <jai@dre.vanderbilt.edu>
+ */
+//=============================================================================
+
+
+#ifndef REPOSITORY_MANAGER_CONF_H
+#define REPOSITORY_MANAGER_CONF_H
+
+#include /**/ "ace/pre.h"
+
+#include "ace/config-all.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+
+#ifndef MAX_PACKAGES_DEF
+/// The number of packages that need to be configured
+const long MAX_PACKAGES = 15;
+#endif /* MAX_PACKAGES_DEF */
+
+#include /**/ "ace/post.h"
+
+#endif /* REPOSITORY_MANAGER_CONF_H */
diff --git a/TAO/CIAO/DAnCE/RepositoryManager/URL_Parser.cpp b/TAO/CIAO/DAnCE/RepositoryManager/URL_Parser.cpp
deleted file mode 100644
index 7eed65dafbb..00000000000
--- a/TAO/CIAO/DAnCE/RepositoryManager/URL_Parser.cpp
+++ /dev/null
@@ -1,103 +0,0 @@
-// $Id$
-
-#include "ace/Get_Opt.h"
-#include "ace/ARGV.h"
-#include "URL_Parser.h"
-
-#include "ace/OS_NS_string.h"
-
-bool
-URL_Parser::parse_args (int argc, ACE_TCHAR *argv[])
-{
- ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("rwu:h:p:f:d"));
-
- bool success = true;
- int c;
-
- while ((c = get_opt ()) != -1)
- switch (c)
- {
- case 'd':
- this->debug_ = 1;
- break;
- case 'u':
- success = parseURL (get_opt.opt_arg ());
- break;
- // Usage fallthrough.
- default:
- success = false;
- }
- if (this->hostname_ == 0 || this->filename_ == 0)
- success = false;
-
- return success;
-}
-
-URL_Parser::URL_Parser (void)
- : hostname_ ("127.0.0.1"),
- port_ (ACE_DEFAULT_HTTP_SERVER_PORT),
- filename_ (0),
- debug_ (0)
-{
-}
-
-bool URL_Parser::parseURL (char* url)
-{
- char* ptr;
- bool success = true;
-
- if (ptr = ACE_OS::strstr (url, "http://"))
- url += ACE_OS::strlen ("http://");
-
- if (url[0] == '/')
- {
- this->filename_ = ACE_OS::strdup (url);
- }
- else
- {
- if (ptr = ACE_OS::strstr (url, ":"))
- this->port_ = ACE_OS::atoi (ptr + 1);
- else
- ptr = ACE_OS::strstr (url, "/");
-
- if(!ptr)
- success = false;
- else
- {
- size_t host_len = ptr - url;
- ACE_NEW_RETURN (this->hostname_, char [host_len + 1], false);
- ACE_OS::strncpy (this->hostname_, url, host_len);
- this->hostname_ [host_len] = '\0';
-
- if (ptr = ACE_OS::strstr (ptr, "/"))
- {
- this->filename_ = ACE_OS::strdup(ptr);
- }
- else
- success = false;
- }
- }
- return success;
-}
-
-
-void URL_Parser::Error (void)
-{
- ACE_DEBUG ((LM_DEBUG, "./http_client -u http://hostname:port/filename [-d]\n"));
-
-}
-
-
- URL_Parser::~URL_Parser()
- {
- if(this->hostname_)
- {
- delete [] this->hostname_;
- this->hostname_ =0;
- }
- if (this->filename_)
- {
- ACE_OS::free (this->filename_);
- this->filename_ = 0;
- }
- }
diff --git a/TAO/CIAO/DAnCE/RepositoryManager/URL_Parser.h b/TAO/CIAO/DAnCE/RepositoryManager/URL_Parser.h
deleted file mode 100644
index aaaeab4960c..00000000000
--- a/TAO/CIAO/DAnCE/RepositoryManager/URL_Parser.h
+++ /dev/null
@@ -1,68 +0,0 @@
-
-/* -*- C++ -*- */
-
-//=============================================================================
-/**
- * @file URL_Parser.h
- *
- * $Id$
- *
- * Parses a URL into its logical chunks
- *
- *
- * @author Stoyan Paunov
- */
-//=============================================================================
-
-
-#ifndef URL_PARSER_H
-#define URL_PARSER_H
-
-#include "ace/Get_Opt.h"
-#include "ace/ARGV.h"
-#include "ace/Singleton.h" //for ACE_Singleton
-#include "ace/Null_Mutex.h" //for ACE_Null_Mutex
-
-//forward declaration
-class URL_Parser;
-
-typedef ACE_Singleton <URL_Parser, ACE_Null_Mutex> TheURL_Parser;
-
-
-class URL_Parser
-{
-public:
-
- friend class ACE_Singleton <URL_Parser, ACE_Null_Mutex>;
-
- /// parses commandline arguments
- bool parse_args (int argc, ACE_TCHAR *argv[]);
-
- //return false on failure
- bool parseURL (char* url);
-
- void Error (void);
-
- /// Hostname to connect to
- ACE_TCHAR *hostname_;
-
- /// Port number to use
- u_short port_;
-
- /// Filename to upload/download
- ACE_TCHAR *filename_;
-
- /// turns on verbosity
- int debug_;
-
- //destructor
- ~URL_Parser (void);
-
-protected:
- URL_Parser (void);
- // protected constructor, singleton
-};
-
-
-
-#endif /* URL_PARSER_H */
diff --git a/TAO/CIAO/DAnCE/RepositoryManager/Update_Plan.cpp b/TAO/CIAO/DAnCE/RepositoryManager/Update_Plan.cpp
new file mode 100644
index 00000000000..9f7b77a7799
--- /dev/null
+++ b/TAO/CIAO/DAnCE/RepositoryManager/Update_Plan.cpp
@@ -0,0 +1,462 @@
+// $Id$
+
+#include "RepositoryManager_Impl.h"
+#include "Update_Plan.h"
+#include "DeploymentC.h"
+#include "ace/Hash_Map_Manager.h"
+#include "ace/OS_NS_stdio.h"
+#include "ace/streams.h"
+
+ACE_RCSID (DAnCE,
+ RepositoryManager,
+ "$Id$")
+
+using namespace Deployment;
+
+namespace CIAO
+{
+ void
+ traverse_package (PackageConfiguration* &pc,
+ DeploymentPlan &plan,
+ REF_MAP &ref_map,
+ REF_MAP &primary_ref_map)
+ {
+ // traverse the package configuration structure to get to the
+ // BasePackage which consists of assemblies.
+ //
+ REF_MAP plan_ref_map;
+ CORBA::ULong bp_len =
+ pc->basePackage.length ();
+
+ for (CORBA::ULong x = 0; x != bp_len; ++x)
+ {
+ CORBA::ULong impl_len =
+ pc->basePackage[x].implementation.length ();
+
+ for (CORBA::ULong y = 0;
+ y != impl_len;
+ ++y)
+ {
+ // traverse the .cpd file and get to the referenced .cid file
+ //
+ ComponentImplementationDescription cid =
+ pc->basePackage[x].implementation[y].referencedImplementation;
+ CORBA::ULong assembly_len = cid.assemblyImpl.length ();
+
+ for (CORBA::ULong z = 0;
+ z != assembly_len;
+ ++z)
+ {
+ // traverse the .cid file and get to each
+ // of the "assemblyImpl" tags.
+ //
+ ComponentAssemblyDescription assembly =
+ cid.assemblyImpl[z];
+ //
+ // traverse the individual assembly.
+ //
+ traverse_assembly (assembly, plan, ref_map, primary_ref_map,
+ plan_ref_map);
+ }
+ }
+ }
+ }
+
+ void
+ traverse_assembly (ComponentAssemblyDescription &assembly,
+ DeploymentPlan &plan,
+ REF_MAP &ref_map, REF_MAP &primary_ref_map,
+ REF_MAP &plan_ref_map)
+ {
+ // traverse the assembly (ComponentAssemblyDescription) and
+ // processes the instances and the connection within the assembly.
+ //
+ CORBA::ULong ins_len = assembly.instance.length ();
+ for (CORBA::ULong k = 0; k < ins_len; ++k)
+ {
+ SubcomponentInstantiationDescription ins =
+ assembly.instance[k];
+ const char* in_name = ins.name;
+
+ CORBA::ULong plan_ins_len =
+ plan.instance.length ();
+
+ for (CORBA::ULong l = 0; l < plan_ins_len; ++l)
+ {
+ const char* plan_name = plan.instance[l].name;
+ if (ACE_OS::strcmp (plan_name, in_name) == 0)
+ {
+ traverse_assembly_instance (ins, plan, l,
+ ref_map, primary_ref_map,
+ plan_ref_map);
+ }
+ }
+ }
+
+ CORBA::ULong assembly_conn_len =
+ assembly.connection.length ();
+
+ for (CORBA::ULong m = 0; m < assembly_conn_len; ++m)
+ {
+ AssemblyConnectionDescription
+ assembly_connection = assembly.connection[m];
+ traverse_assembly_connection (assembly,
+ assembly_connection,
+ plan);
+ }
+ }
+
+ void
+ traverse_assembly_connection (ComponentAssemblyDescription
+ &assembly,
+ AssemblyConnectionDescription
+ &assembly_connection,
+ DeploymentPlan &plan)
+ {
+ // traverse the assembly connection and get information about the
+ // portName and the instances at each end of the connection.
+ // Also traverse the InterfaceDescriptions for each of those instances
+ // and populate the portKind information.
+ //
+ CORBA::ULong con_length (plan.connection.length ());
+ plan.connection.length (con_length + 1);
+ CORBA::ULong iepe_len = assembly_connection.internalEndpoint.length ();
+ for (CORBA::ULong n = 0; n < iepe_len; ++n)
+ {
+ CORBA::ULong iep_len (plan.connection[con_length].
+ internalEndpoint.length ());
+ plan.connection[con_length].internalEndpoint
+ .length (iep_len + 1);
+ plan.connection[con_length].internalEndpoint
+ [iep_len].portName = assembly_connection.
+ internalEndpoint[n].portName;
+ CORBA::ULong ins_ref = assembly_connection.internalEndpoint[n].
+ instanceRef;
+ const char* ins_name = assembly.instance[ins_ref].name;
+ CORBA::ULong plan_ins_len = plan.instance.length ();
+ for (CORBA::ULong w = 0; w < plan_ins_len; ++w)
+ {
+ const char* pl_name = plan.instance[w].name;
+ if (ACE_OS::strcmp (pl_name, ins_name) == 0)
+ {
+ plan.connection[con_length].internalEndpoint
+ [iep_len].instanceRef = w;
+ break;
+ }
+ }
+ traverse_interface (assembly.instance[ins_ref],
+ plan.connection[con_length].
+ internalEndpoint[iep_len]);
+ }
+ }
+
+ void
+ traverse_interface (SubcomponentInstantiationDescription
+ &instance,
+ PlanSubcomponentPortEndpoint
+ &pspe)
+ {
+ // traverse the InterfaceDescription of the instance and get information
+ // about the portkind of the port.
+ //
+ CORBA::ULong pack_len = instance.package.length ();
+ for (CORBA::ULong m = 0; m < pack_len; ++m)
+ {
+ ComponentPackageDescription
+ package = instance.package[m];
+
+ ComponentInterfaceDescription
+ cid = package.realizes;
+
+ CORBA::ULong port_len = cid.port.length ();
+
+ for (CORBA::ULong n = 0; n < port_len; ++n)
+ {
+ const char* main_port_name = cid.port[n].name;
+ const char* port_name = pspe.portName;
+ if (ACE_OS::strcmp (main_port_name, port_name) == 0)
+ {
+ pspe.kind = cid.port[n].kind;
+ }
+ }
+ }
+ }
+
+ void
+ traverse_assembly_instance (
+ SubcomponentInstantiationDescription
+ &instance,
+ DeploymentPlan &plan, int l,
+ REF_MAP &ref_map, REF_MAP &primary_ref_map,
+ REF_MAP &plan_ref_map)
+ {
+ // Each instance has a package.
+ // Each package has an implementation and their correspoding artifacts.
+ // Traverse this information and populate the artifact and the
+ // implementation information within the DeploymentPlan.
+ //
+ ART_REF_MAP art_ref_map;
+
+ update_config_property (instance, plan.instance[l]);
+
+ CORBA::ULong pack_len = instance.package.length ();
+ for (CORBA::ULong m = 0; m < pack_len; ++m)
+ {
+ ComponentPackageDescription
+ package = instance.package[m];
+ CORBA::ULong pack_impl_len = package.implementation.length ();
+
+ for (CORBA::ULong n = 0; n < pack_impl_len; ++n)
+ {
+ PackagedComponentImplementation
+ impl = package.implementation[n];
+ CORBA::ULong impl_length (plan.implementation.length ());
+ plan.implementation.length (impl_length + 1);
+ plan.implementation[impl_length].name = plan.instance[l].name;
+ plan.instance[l].implementationRef = impl_length;
+ CORBA::ULong mono_impl_len =
+ impl.referencedImplementation.monolithicImpl.length ();
+
+ for (CORBA::ULong p = 0; p < mono_impl_len; ++p)
+ {
+ MonolithicImplementationDescription
+ mid = impl.referencedImplementation.monolithicImpl[p];
+
+ update_artifacts (mid, plan, plan.instance[l],
+ ref_map, primary_ref_map, art_ref_map,
+ plan_ref_map,
+ plan.implementation[impl_length]);
+ }
+ update_impl_config_property (impl, plan.implementation[impl_length],
+ plan.instance[l]);
+ }
+ }
+ }
+
+ void
+ update_artifacts (MonolithicImplementationDescription &mid,
+ DeploymentPlan &plan,
+ InstanceDeploymentDescription &instance,
+ REF_MAP &ref_map, REF_MAP &primary_ref_map,
+ ART_REF_MAP &art_ref_map,
+ REF_MAP &plan_ref_map,
+ MonolithicDeploymentDescription &mdd)
+ {
+ ref_map.unbind_all ();
+ primary_ref_map.unbind_all ();
+ art_ref_map.unbind_all ();
+ CORBA::ULong prim_art_len = mid.primaryArtifact.length ();
+ for (CORBA::ULong q = 0; q < prim_art_len; ++q)
+ {
+ ImplementationArtifactDescription
+ pack_iad = mid.primaryArtifact[q].referencedArtifact;
+ ACE_TString artifact_name = (const char*)mid.primaryArtifact[q].name;
+ int arti_len;
+ int plan_arti_len;
+ CORBA::ULong art_length (plan.artifact.length ());
+
+ if (ref_map.find (artifact_name, arti_len) != 0)
+ {
+ if (plan_ref_map.find (artifact_name, plan_arti_len) != 0)
+ {
+ plan.artifact.length (art_length + 1);
+ plan.artifact[art_length].name = mid.primaryArtifact[q].name;
+ plan.artifact[art_length].node = instance.node;
+ ref_map.bind (artifact_name, art_length);
+ plan_ref_map.bind (artifact_name, art_length);
+ primary_ref_map.bind (artifact_name, art_length);
+ CORBA::ULong art_ref_len (mdd.artifactRef.length ());
+ mdd.artifactRef.length (art_ref_len + 1);
+ mdd.artifactRef[art_ref_len] = art_length;
+ update_artifact_location (pack_iad,
+ plan.artifact[art_length]);
+ update_artifact_property (pack_iad,
+ plan.artifact[art_length]);
+ }
+ else
+ {
+ art_length = plan_arti_len;
+ ref_map.bind (artifact_name, art_length);
+ primary_ref_map.bind (artifact_name, art_length);
+ CORBA::ULong art_ref_len (mdd.artifactRef.length ());
+ mdd.artifactRef.length (art_ref_len + 1);
+ mdd.artifactRef[art_ref_len] = art_length;
+ update_artifact_location (pack_iad,
+ plan.artifact[art_length]);
+ update_artifact_property (pack_iad,
+ plan.artifact[art_length]);
+ }
+ }
+ update_common_artifact_and_art_ref (pack_iad,
+ primary_ref_map, ref_map,
+ art_ref_map, plan_ref_map, mdd,
+ plan, instance);
+ }
+ }
+
+ void
+ update_common_artifact_and_art_ref (
+ ImplementationArtifactDescription
+ &pack_iad,
+ REF_MAP &primary_ref_map,
+ REF_MAP &ref_map,
+ ART_REF_MAP &art_ref_map,
+ REF_MAP &plan_ref_map,
+ MonolithicDeploymentDescription &mid,
+ DeploymentPlan &plan,
+ InstanceDeploymentDescription
+ &instance)
+ {
+ int plan_arti_len;
+ int arti_len;
+ CORBA::ULong new_art_length;
+ CORBA::ULong deps_len = pack_iad.dependsOn.length ();
+ for (CORBA::ULong g = 0; g < deps_len; ++g)
+ {
+ ACE_TString dep_name =
+ (const char*)pack_iad.dependsOn[g].name;
+
+ if (ref_map.find (dep_name, arti_len) == 0)
+ {
+ if (primary_ref_map.find (dep_name, arti_len) != 0)
+ {
+ if (art_ref_map.find (arti_len, arti_len) != 0)
+ {
+ update_impl_art_ref (mid, arti_len);
+ art_ref_map.bind (arti_len, arti_len);
+ }
+ }
+ }
+ else
+ {
+ ImplementationArtifactDescription
+ depends_iad = pack_iad.dependsOn[g].
+ referencedArtifact;
+ if (plan_ref_map.find (dep_name, plan_arti_len) != 0)
+ {
+ new_art_length = plan.artifact.length ();
+ plan.artifact.length (new_art_length + 1);
+ plan.artifact[new_art_length].name =
+ pack_iad.dependsOn[g].name;
+ plan.artifact[new_art_length].node = instance.node;
+ update_artifact_location (depends_iad,
+ plan.artifact
+ [new_art_length]);
+ ref_map.bind (
+ (const char*)plan.artifact[new_art_length].name,
+ new_art_length);
+ plan_ref_map.bind (
+ (const char*)plan.artifact[new_art_length].name,
+ new_art_length);
+ update_impl_art_ref (mid, new_art_length);
+ art_ref_map.bind (new_art_length, new_art_length);
+ }
+ else
+ {
+ new_art_length = plan_arti_len;
+ ref_map.bind (
+ (const char*)plan.artifact[new_art_length].name,
+ new_art_length);
+ update_impl_art_ref (mid, new_art_length);
+ art_ref_map.bind (new_art_length, new_art_length);
+ }
+ }
+ }
+ }
+
+ void
+ update_config_property (SubcomponentInstantiationDescription &sub_instance,
+ InstanceDeploymentDescription &instance)
+ {
+ CORBA::ULong pro_len =
+ sub_instance.configProperty.length ();
+
+ for (CORBA::ULong x = 0; x < pro_len; ++x)
+ {
+ CORBA::ULong ins_pro_len (instance.configProperty. length ());
+ instance.configProperty.length (ins_pro_len + 1);
+ instance.configProperty[ins_pro_len]
+ = sub_instance.configProperty[x];
+ }
+ }
+
+ void
+ update_impl_config_property (PackagedComponentImplementation
+ &impl,
+ MonolithicDeploymentDescription
+ &mid,
+
+ InstanceDeploymentDescription
+ &instance)
+ {
+ int update_flag;
+ CORBA::ULong pro_len =
+ impl.referencedImplementation.configProperty.length ();
+
+ for (CORBA::ULong x = 0; x < pro_len; ++x)
+ {
+ update_flag = 1;
+ CORBA::ULong impl_pro_len (mid.execParameter.length ());
+ mid.execParameter.length (impl_pro_len + 1);
+ mid.execParameter[impl_pro_len]
+ = impl.referencedImplementation.configProperty[x];
+ const char* property_name =
+ impl.referencedImplementation.configProperty[x].name;
+ CORBA::ULong ins_pro_len (instance.configProperty. length ());
+ for (CORBA::ULong y = 0; y < ins_pro_len; ++y)
+ {
+ const char* ins_pro_name = instance.configProperty[y].name;
+ if (ACE_OS::strcmp (ins_pro_name, property_name) == 0)
+ {
+ update_flag = 0;
+ break;
+ }
+ }
+ if (update_flag == 1)
+ {
+ instance.configProperty.length (ins_pro_len + 1);
+ instance.configProperty[ins_pro_len]
+ = impl.referencedImplementation.configProperty[x];
+ }
+ }
+ }
+
+ void
+ update_impl_art_ref (MonolithicDeploymentDescription &mid,
+ int arti_len)
+ {
+ CORBA::ULong new_art_ref_len (mid.artifactRef.length ());
+ mid.artifactRef.length (new_art_ref_len + 1);
+ mid.artifactRef[new_art_ref_len] = arti_len;
+ }
+
+ void
+ update_artifact_location (ImplementationArtifactDescription
+ &pack_iad,
+ ArtifactDeploymentDescription
+ &plan_artifact)
+ {
+ CORBA::ULong loc_len = pack_iad.location.length ();
+ for (CORBA::ULong e = 0; e < loc_len; ++e)
+ {
+ CORBA::ULong art_loc_len (plan_artifact.location.length ());
+ plan_artifact.location.length (art_loc_len + 1);
+ plan_artifact.location[art_loc_len] = pack_iad.location[e];
+ }
+ }
+
+ void
+ update_artifact_property (ImplementationArtifactDescription
+ &pack_iad,
+ ArtifactDeploymentDescription
+ &plan_artifact)
+ {
+ CORBA::ULong para_len = pack_iad.execParameter.length ();
+ for (CORBA::ULong f = 0; f < para_len; ++f)
+ {
+ CORBA::ULong art_pro_len (plan_artifact.execParameter.length ());
+ plan_artifact.execParameter.length (art_pro_len + 1);
+ plan_artifact.execParameter[art_pro_len] = pack_iad.execParameter[f];
+ }
+ }
+}
diff --git a/TAO/CIAO/DAnCE/RepositoryManager/Update_Plan.h b/TAO/CIAO/DAnCE/RepositoryManager/Update_Plan.h
new file mode 100644
index 00000000000..9c3125092fd
--- /dev/null
+++ b/TAO/CIAO/DAnCE/RepositoryManager/Update_Plan.h
@@ -0,0 +1,123 @@
+/*=======================================================================
+ *
+ * @file Update_Plan.h
+ *
+ * $Id$
+ *
+ * @brief This file contains declarations for helper functions
+ * used in updating the deployment plan data structure from
+ * PackageConfiguration data structure.
+ *
+ * @author Jaiganesh Balasubramanian <jai@dre.vanderbilt.edu>
+ *
+ *======================================================================*/
+
+#ifndef CIAO_REPOSITORY_MANAGER_UPDATE_PLAN_H
+#define CIAO_REPOSITORY_MANAGER_UPDATE_PLAN_H
+#include /**/ "ace/pre.h"
+
+#include "ace/Hash_Map_Manager.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+
+namespace Deployment
+{
+ struct SubcomponentInstantiationDescription;
+ struct DeploymentPlan;
+ struct ComponentAssemblyDescription;
+ struct SubcomponentInstantiationDescription;
+ struct AssemblyConnectionDescription;
+}
+
+namespace CIAO
+{
+ class Null_Dom_Document { };
+ // exception thrown when we have a null dom document.
+
+ typedef ACE_Hash_Map_Manager<ACE_TString, int, ACE_Null_Mutex> REF_MAP;
+ typedef ACE_Hash_Map_Manager<int, int, ACE_Null_Mutex> ART_REF_MAP;
+
+ void
+ traverse_assembly_instance (Deployment::
+ SubcomponentInstantiationDescription &instance,
+ Deployment::DeploymentPlan &plan,
+ int l,
+ REF_MAP &ref_map,
+ REF_MAP &primary_ref_map,
+ REF_MAP &plan_ref_map);
+
+ void traverse_assembly (Deployment::ComponentAssemblyDescription &assembly,
+ Deployment::DeploymentPlan &plan,
+ REF_MAP &ref_map, REF_MAP &primary_ref_map,
+ REF_MAP &plan_ref_map);
+
+ void traverse_interface (Deployment::SubcomponentInstantiationDescription
+ &instance,
+ Deployment::PlanSubcomponentPortEndpoint
+ &pspe);
+
+ void traverse_assembly_connection (Deployment::ComponentAssemblyDescription
+ &assembly,
+ Deployment::AssemblyConnectionDescription
+ &assembly_connection,
+ Deployment::DeploymentPlan &plan);
+
+ void traverse_package (Deployment::PackageConfiguration* &pc,
+ Deployment::DeploymentPlan &plan,
+ REF_MAP &ref_map, REF_MAP &primary_ref_map);
+
+ void update_artifacts (Deployment::MonolithicImplementationDescription &mid,
+ Deployment::DeploymentPlan &plan,
+ Deployment::InstanceDeploymentDescription &instance,
+ REF_MAP &ref_map, REF_MAP &primary_ref_map,
+ ART_REF_MAP &art_ref_map,
+ REF_MAP &plan_ref_map,
+ Deployment::MonolithicDeploymentDescription &mdd);
+
+ void update_artifact_location (Deployment::ImplementationArtifactDescription
+ &pack_iad,
+ Deployment::ArtifactDeploymentDescription
+ &plan_artifact);
+
+ void update_artifact_property (Deployment::ImplementationArtifactDescription
+ &pack_iad,
+ Deployment::ArtifactDeploymentDescription
+ &plan_artifact);
+
+ void update_impl_art_ref (Deployment::MonolithicDeploymentDescription
+ &mid, int art_len);
+
+ void update_impl_config_property (Deployment::
+ PackagedComponentImplementation &impl,
+ Deployment::
+ MonolithicDeploymentDescription &mid,
+ Deployment::
+ InstanceDeploymentDescription
+ &instance);
+
+ void update_config_property (Deployment::
+ SubcomponentInstantiationDescription
+ &sub_instance,
+ Deployment::
+ InstanceDeploymentDescription
+ &instance);
+
+ void update_common_artifact_and_art_ref (Deployment::
+ ImplementationArtifactDescription &pack_iad,
+ REF_MAP &primary_ref_map,
+ REF_MAP &ref_map,
+ ART_REF_MAP &art_ref_map,
+ REF_MAP &plan_ref_map,
+ Deployment::MonolithicDeploymentDescription
+ &mid,
+ Deployment::DeploymentPlan &plan,
+ Deployment::
+ InstanceDeploymentDescription
+ &instance);
+}
+
+#include /**/ "ace/post.h"
+#endif /* CIAO_REPOSITORY_MANAGER_UPDATE_PLAN_H*/
diff --git a/TAO/CIAO/DAnCE/RepositoryManager/ZIP_Wrapper.cpp b/TAO/CIAO/DAnCE/RepositoryManager/ZIP_Wrapper.cpp
deleted file mode 100644
index f910374f71f..00000000000
--- a/TAO/CIAO/DAnCE/RepositoryManager/ZIP_Wrapper.cpp
+++ /dev/null
@@ -1,299 +0,0 @@
-
-//=======================================================================
-/**
- * @file ZIP_Wrapper.cpp
- *
- * $Id$
- *
- * Purpose: implementing the ZIP_Wrapper class
- *
- * @author Stoyan Paunov
- */
-//=======================================================================
-
-
-#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_string.h" //for strncpy
-#include "ace/SString.h" //for ACE_CString
-#include "ace/OS_NS_sys_stat.h" //for stat
-#include "ace/OS_NS_sys_stat.h" //for filesize and mkdir
-#include "ace/OS_Memory.h" //for ACE_NEW* macros
-
-#include <string>
-#include <memory> //for auto_ptr
-
-/////////////////////////////////////////////////////////////////////////////
-//NOTE: some #defines problems with zzip & ACE - put these 2 lines on top!!!!
-/////////////////////////////////////////////////////////////////////////////
-#include "zzip/zzip.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)
-{
-}
-
-//ZIP_File_Info default constructor
-ZIP_File_Info::ZIP_File_Info ()
- : name_ (""),
- size_ (0),
- next_ (0),
- prev_ (0)
-{
-}
-
-
-//get a list of the files in the archive
-int 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 = 0; //pointer to a zip archive
- ZZIP_DIRENT * dir_entry = 0; //pointer to a file within the archive
-
- //open the zip archive
- dir = zzip_opendir(zip_name);
-
- 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;
-
- //remove the subpath part if any NOTE: Lunux style assumed, need to check
- //while(char* next = strstr(name, "/"))
- // name = next + 1;
-
- ZIP_File_Info* next;
- ACE_NEW_RETURN (next, ZIP_File_Info (name, dir_entry->st_size), -1);
-
- list.insert_tail (next);
- num++;
- }
-
- 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;
-
- ZZIP_FILE* zip_file = zzip_open (accessor, O_RDONLY| O_BINARY);
-
- if (!zip_file)
- return false;
-
- int num_read = 0;
- 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())))
- {
- head->wr_ptr (num_read);
- ACE_Message_Block* next;
- ACE_NEW_RETURN (next, ACE_Message_Block (BUFSIZ), false);
- head->cont (next);
- head = head->cont ();
- }
-
- if (num_read < 0)
- return_code = false;
-
- 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
-
- //open the zip archive
- dir = zzip_opendir(archive_path);
-
- if (!dir)
- return false;
-
- //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 = 0;
- ACE_Message_Block* head = &file;
-
- //read the file into the ACE_Message_Block
- do
- {
- if (head->space () == 0)
- {
- ACE_Message_Block* next;
- ACE_NEW_RETURN (next, ACE_Message_Block (BUFSIZ), false);
- head->cont ();
- head = head->cont ();
- }
-
- num_read = zzip_read(zip_file, head->wr_ptr(), head->space());
-
- if (num_read > 0)
- head->wr_ptr (num_read);
-
- } while (num_read > 0);
-
- if (num_read < 0)
- return_code = false;
-
- zzip_file_close (zip_file);
- zzip_closedir(dir);
-
- return return_code;
-}
-
-
-//uncompress
-//the uncompress format will be
-//mkdir(name of zip archive).
-//the path is assumed to be an existing directory
-//directory structure of archive is recreated
-bool ZIP_Wrapper::uncompress (char* zip_archive, char* path, bool verbose)
-{
- ZZIP_DIR * dir = 0; //pointer to a zip archive
- ZZIP_DIRENT * dir_entry = 0; //pointer to a file within the archive
- ZZIP_FILE* file = 0; //pointer to a zip file within an 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
- ACE_CString arch_dir (path);
- arch_dir += "/";
-
- //get only the name of the archive; remove path info
- char* n = ACE_OS::strstr (zip_archive, "/");
- char* zip_name = 0;
- while (n != NULL)
- {
- zip_name = ++n;
- n = ACE_OS::strstr (n, "/");
- }
-
- arch_dir += zip_name;
- //NOTE: Assumes .zip or cpk extension
- arch_dir = arch_dir.substring (0, arch_dir.length () - 4);
-
- //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
-
- //let's try to create the directory structure for the package
- char dir_name [2048];
- char* next = ACE_OS::strstr (name, "/");
- while (next != NULL)
- {
- ACE_CString location (arch_dir);
- ACE_OS::strncpy (dir_name, name, next - name + 1);
- dir_name[next - name + 1] = '\0';
-
- location += "/";
- location += dir_name;
-
- ACE_stat stat;
- if (ACE_OS::stat (location.c_str (), &stat) == -1)
- ACE_OS::mkdir (location.c_str ());
-
- next++;
- next = ACE_OS::strstr (next, "/");
- }
-
- //open a zip handle
- file = zzip_file_open(dir, dir_entry->d_name, O_RDONLY | O_BINARY);
- if (!file)
- return false;
-
- //allocate buffer
-
- //std::auto_ptr releases the memory upon reset.
- //ACE_Auto_Ptr does not support this functionality
- std::auto_ptr<char> buffer;
- char* temp;
- ACE_NEW_RETURN (temp, char [dir_entry->st_size + 1], false);
- buffer.reset (temp);
-
- //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
- if (verbose)
- {
- 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)
- {
- zzip_closedir(dir);
- ACE_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("%p\n"),
- ACE_TEXT ("[uncompress] file creation error")),
- 0);
- }
-
- //write the uncompressed data to the file
- if (ACE_OS::write (handle, &(*buffer), dir_entry->st_size) == -1)
- {
- zzip_closedir(dir);
- ACE_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("%p\n"),
- ACE_TEXT ("[uncompress] file write error")),
- 0);
- }
-
- // Close the file handle
- ACE_OS::close (handle);
- }
-
- zzip_closedir(dir);
- return true;
-}
diff --git a/TAO/CIAO/DAnCE/RepositoryManager/ZIP_Wrapper.h b/TAO/CIAO/DAnCE/RepositoryManager/ZIP_Wrapper.h
deleted file mode 100644
index ddb3eb480e8..00000000000
--- a/TAO/CIAO/DAnCE/RepositoryManager/ZIP_Wrapper.h
+++ /dev/null
@@ -1,86 +0,0 @@
-
-/* -*- C++ -*- */
-
-//=======================================================================
-/**
- * @file ZIP_Wrapper.h
- *
- * $Id$
- *
- * 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
- *
- * @author Stoyan Paunov
- */
-//=======================================================================
-
-#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/SString.h" //for ACE_CString
-
-#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 ZIP_File_Info
-{
-public:
- ACE_CString name_;
- size_t size_;
- ZIP_File_Info* next_;
- ZIP_File_Info* prev_;
-
- ZIP_File_Info (char* name, size_t size);
- ZIP_File_Info ();
-};
-
-/**
- * @class ZIP_Wrappers
- *
- * 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
- ///returns -1 on failure
- static int 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!
- ///
- /// NOTE: Be sure to release the message block even if the function returns
- /// false becuase the return value might be due to unsuccessful allocation
- static bool get_file (char* accessor, ACE_Message_Block &file);
-
- /// Additional get_file function to avert subdirectory traversal problems with
- /// zziplib accessors
- ///
- /// NOTE: Be sure to release the message block even if the function returns
- /// false becuase the return value might be due to unsuccessful allocation
- static 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
- static bool uncompress (char* zip_archive, char* path = "", bool verbose = true);
-};
-
-#endif