summaryrefslogtreecommitdiff
path: root/TAO/CIAO/DAnCE/spec_RepositoryManager/RepositoryManager_Impl.h
blob: 85a0002c457613c48a4b8c2f7c8fc7c10832c2c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
// $Id$

#ifndef REPOSITORYMANAGERI_H_
#define REPOSITORYMANAGERI_H_

///====================================================================
// filename: RepositoryManager_Impl.h
// Author: Stoyan Paunov	spaunov@isis.vanderbilt.edu
//
// Purpose: This class is the implementation class for the spec
//          complient RepositoryManager
//


#include "RepositoryManagerS.h"
#include "DeploymentS.h"					//added for the deployment stuff

#include "ace/Hash_Map_Manager.h"			//for the ACE_Hash_Map_Manager
#include "ace/Null_Mutex.h"					//for ACE_Null_Mutex
#include "ace/RW_Mutex.h"					//for ACE_RW_Mutex
#include "ace/OS_NS_string.h"				//for ACE_CString
#include "ace/SString.h"


#if !defined (ACE_LACKS_PRAGMA_ONCE)
#pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */


namespace
{
///DIRECTORY WHERE THE PACKAGES WILL BE STORED LOCALLY
const static char* INSTALL_PATH = "RepositoryDir";

const static size_t TEMP_LEN = 512;

const static char* PC_EXTENSION = ".epc";
}

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 extract all necessary files for parsing the PackageConfiguration
	  ///descriptor and populating the idl struct.
	  ///return 1 on success
	  ///       0 on 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*/
	  ///return 1 on success
	  ///       0 on error

	  int remove_extracted_package (const char* package_path, const char* extraction_location);

  private:
	/// Cached information about the installed PackageConfigurations
	/// A separate map for the installation names and their UUID's
    /// Key:	PackageConfiguration name or its UUID (CString type)
    /// Value:	The location of the local copy of the package

	///Based on the synchronization needed we can parametrize this with either
	///ACE_Null_Mutex or ACE_RW_Mutex

    typedef ACE_Hash_Map_Manager_Ex<ACE_CString,
                                    ACE_CString,
                                    ACE_Hash<ACE_CString>,
                                    ACE_Equal_To<ACE_CString>,
                                    ACE_RW_Mutex> PCMap;


	typedef PCMap::iterator PCMap_Iterator;

	//a hash map that associates the names of PackageConfigurations with their location
    PCMap names_;

	//a hash map that associates the UUIDs of PackageConfigurations with their location
	PCMap uuids_;

	CORBA::ORB_var the_orb_;

	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_  */