1 karl 1.3 //%2003////////////////////////////////////////////////////////////////////////
|
2 chip 1.1 //
|
3 karl 1.3 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Development
4 // Company, L. P., IBM Corp., The Open Group, Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.;
6 // IBM Corp.; EMC Corporation, The Open Group.
|
7 chip 1.1 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to
10 // deal in the Software without restriction, including without limitation the
11 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 // sell copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
|
14 karl 1.3 //
|
15 chip 1.1 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
16 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
17 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
18 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
19 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 //
24 //==============================================================================
25 //
26 // Author: Chip Vincent (cvincent@us.ibm.com)
27 //
28 // Modified By:
29 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
32 #include "ProviderRegistrarInitializer.h"
33
34 #include <Pegasus/Repository/CIMRepository.h>
35 #include <Pegasus/Server/ProviderRegistrationManager/ProviderRegistrationManager.h>
36 chip 1.1
37 #include <Pegasus/Common/Constants.h>
38 #include <Pegasus/Common/Tracer.h>
39 #include <Pegasus/Common/Logger.h>
40
41 PEGASUS_NAMESPACE_BEGIN
42
|
43 chip 1.2 Array<RegistrationRecord> _globalRegistrationTable;
|
44 chip 1.1
45 ProviderRegistrarInitializer::ProviderRegistrarInitializer(void)
46 {
47 }
48
49 ProviderRegistrarInitializer::~ProviderRegistrarInitializer(void)
50 {
51 }
52
53 void ProviderRegistrarInitializer::initialize(CIMRepository * repository)
54 {
55 PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "ProviderRegistrarInitializer::initialize()");
56
57 Array<RegistrationRecord> records;
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 // 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 chip 1.1 // 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 // create registration records for each class entry
85 //
86 chip 1.1
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
|