1 chip 1.1 //%/////////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (c) 2000 - 2003 BMC Software, Hewlett-Packard Company, IBM,
4 // The Open Group, Tivoli Systems
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining a copy
7 // of this software and associated documentation files (the "Software"), to
8 // deal in the Software without restriction, including without limitation the
9 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 // sell copies of the Software, and to permit persons to whom the Software is
11 // furnished to do so, subject to the following conditions:
12 //
13 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
14 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
15 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
16 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
17 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
18 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 //
22 chip 1.1 //==============================================================================
23 //
24 // Author: Chip Vincent (cvincent@us.ibm.com)
25 //
26 // Modified By:
27 //
28 //%/////////////////////////////////////////////////////////////////////////////
29
30 #include "ProviderRegistrarInitializer.h"
31
32 #include <Pegasus/Repository/CIMRepository.h>
33 #include <Pegasus/Server/ProviderRegistrationManager/ProviderRegistrationManager.h>
34
35 #include <Pegasus/Common/Constants.h>
36 #include <Pegasus/Common/Tracer.h>
37 #include <Pegasus/Common/Logger.h>
38
39 PEGASUS_NAMESPACE_BEGIN
40
|
41 chip 1.2 Array<RegistrationRecord> _globalRegistrationTable;
|
42 chip 1.1
43 ProviderRegistrarInitializer::ProviderRegistrarInitializer(void)
44 {
45 }
46
47 ProviderRegistrarInitializer::~ProviderRegistrarInitializer(void)
48 {
49 }
50
51 void ProviderRegistrarInitializer::initialize(CIMRepository * repository)
52 {
53 PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "ProviderRegistrarInitializer::initialize()");
54
55 Array<RegistrationRecord> records;
56
57 repository->read_lock();
58
59 //
60 // get all relevant registration instances from the repository and cache them locally.
61 //
62 // validate instances and remove any that have dangling (incomplete) references. the simplest way to do this with
63 chip 1.1 // the current schema is to ensure that each provider capabilities instance has an associated provider module instance and
64 // provider instance. Keep in mind that each class must have an entry. The provider capability instance is one-to-one
65 // correlated to a class, so it makes sense to start there.
66 //
67
68 Array<CIMInstance> providerCapabilityInstances;
69 Array<CIMInstance> providerInstances;
70 Array<CIMInstance> providerModuleInstances;
71
72 try
73 {
74 providerCapabilityInstances = repository->enumerateInstances("root/PG_interop", "PG_ProviderCapabilities");
75 providerInstances = repository->enumerateInstances("root/PG_Interop", "PG_Provider");
76 providerModuleInstances = repository->enumerateInstances("root/PG_Interop", "PG_ProviderModule");
77 }
78 catch(...)
79 {
80 // suppress exceptions
81 }
82
83 //
84 chip 1.1 // create registration records for each class entry
85 //
86
87 for(Uint32 i = 0, n = providerCapabilityInstances.size(); i < n; i++)
88 {
89 RegistrationRecord record;
90
91 Uint32 pos = 0;
92
93 // get class name
94 if((pos = providerInstances[i].findProperty("Name")) != PEG_NOT_FOUND)
95 {
|
96 chip 1.2 providerInstances[i].getProperty(pos).getValue().get(record.className);
|
97 chip 1.1 }
98
99 // get namespace
100 if((pos = providerInstances[i].findProperty("NameSpace")) != PEG_NOT_FOUND)
101 {
102 // ATTN: must create duplicate entries for each namespace. for now, only
103 // one namespace is support (0 is invalid).
104
|
105 chip 1.2 //Array<String> temp;
|
106 chip 1.1
|
107 chip 1.2 //providerInstances[i].getProperty(pos).getValue().get(temp);
|
108 chip 1.1
|
109 chip 1.2 //record._namespace = temp[0];
|
110 chip 1.1 }
111
112 // get provider name
113 if((pos = providerInstances[i].findProperty("ProviderName")) != PEG_NOT_FOUND)
114 {
|
115 chip 1.2 providerInstances[i].getProperty(pos).getValue().get(record.providerName);
|
116 chip 1.1 }
117
118 // get provider module name
119 if((pos = providerInstances[i].findProperty("ProviderModuleName")) != PEG_NOT_FOUND)
120 {
|
121 chip 1.2 providerInstances[i].getProperty(pos).getValue().get(record.moduleName);
|
122 chip 1.1 }
123 }
124
125 // validate current registration records using cached instances.
126
127 for(Uint32 i = 0, n = records.size(); i < n; i++)
128 {
129 Uint32 pos = 0;
130
131 // find the provider for this record.
132 for(Uint32 i = 0, n = providerInstances.size(); i < n; i++)
133 {
134 String s;
135
136 // get name
137 if((pos = providerInstances[i].findProperty("Name")) != PEG_NOT_FOUND)
138 {
139 providerInstances[i].getProperty(pos).getValue().get(s);
140 }
141
142 // compare record._providerName to PG_Provider.Name
|
143 chip 1.2 if(String::equalNoCase(s, records[i].providerName))
|
144 chip 1.1 {
145 break;
146 }
147 }
148
149 if(i == n)
150 {
151 // not found: must be an invalid entry
152
153 // drop record and log
154 }
155
156 // find the provider module for this record.
157 for(Uint32 i = 0, n = providerModuleInstances.size(); i < n; i++)
158 {
159 String s;
160
161 // get name
162 if((pos = providerModuleInstances[i].findProperty("Name")) != PEG_NOT_FOUND)
163 {
164 providerModuleInstances[i].getProperty(pos).getValue().get(s);
165 chip 1.1 }
166
167 // compare record._moduleName to PG_ProviderModule.Name
|
168 chip 1.2 if(String::equalNoCase(s, records[i].moduleName))
|
169 chip 1.1 {
170 break;
171 }
172 }
173
174 if(i == n)
175 {
176 // not found: must be an invalid entry
177
178 // drop record and log
179 }
180
181 // extract the location property, fully qualify and update the record._moduleName;
182 }
183
184 PEG_METHOD_EXIT();
185 }
186
187 PEGASUS_NAMESPACE_END
|