1 karl 1.8 //%2006////////////////////////////////////////////////////////////////////////
|
2 a.arora 1.2 //
|
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 a.arora 1.2 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.3 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.4 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.8 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 a.arora 1.2 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
15 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
18 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
|
20 karl 1.8 //
|
21 a.arora 1.2 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
22 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
24 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
27 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 //==============================================================================
31 // Author: Mike Brasher (mbrasher@bmc.com)
32 // Marek Szermutzky (MSzermutzky@de.ibm.com) PEP#139 Stage2
33 //
34 // Modified By: Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com)
35 // Yi Zhou, Hewlett-Packard Company (yi_zhou@hp.com)
36 // Nag Boranna, Hewlett-Packard Company (nagaraja_boranna@hp.com)
37 // Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
38 // Carol Ann Krug Graves, Hewlett-Packard Company
39 // (carolann_graves@hp.com)
40 // Jair Santos, Hewlett-Packard Company (jair.santos@hp.com)
|
41 david.dillard 1.5 // David Dillard, VERITAS Software Corp.
42 // (david.dillard@veritas.com)
|
43 a.arora 1.2 //
44 //%/////////////////////////////////////////////////////////////////////////////
45
46 #include "CIMManagedClient.h"
47
48 PEGASUS_NAMESPACE_BEGIN
49
50 // class constructor
51 CIMManagedClient::CIMManagedClient()
52 {
|
53 david.dillard 1.6 // *shrugs*
54 // using this constructor doesn't seem to clever
55 // remind, if you use it, don't forget to set the ConnectionManager
56 // via setConnectionManager()
57 setPegasusDefaultPort();
58 _cccm = 0;
|
59 a.arora 1.2 }
60
61 CIMManagedClient::CIMManagedClient(CIMClientConnectionManager* cccm)
62 {
|
63 david.dillard 1.6 CDEBUG("Using given CIMClientConnectionManager*");
64 setPegasusDefaultPort();
65 _cccm = cccm;
|
66 a.arora 1.2 }
|
67 david.dillard 1.6
|
68 a.arora 1.2 void CIMManagedClient::setConnectionManager(CIMClientConnectionManager* cccm)
69 {
|
70 kumpf 1.9 // delete _cccm;
|
71 david.dillard 1.6 _cccm = cccm;
|
72 a.arora 1.2 }
73
74 CIMClientConnectionManager* CIMManagedClient::getConnectionManager(void)
75 {
|
76 david.dillard 1.6 return _cccm;
|
77 a.arora 1.2 }
78
79 CIMManagedClient::~CIMManagedClient()
80 {
|
81 david.dillard 1.6 // ubs, we shouldn't delete the ClientConnectionManager,
82 // as we don't know what it is anyway
|
83 kumpf 1.9 // delete _cccm;
|
84 a.arora 1.2 }
85
86 // l10n start
|
87 david.dillard 1.6 void CIMManagedClient::setRequestAcceptLanguages(
88 const String& host,
89 const String& port,
|
90 kumpf 1.7 const AcceptLanguageList& langs
|
91 david.dillard 1.6 )
|
92 a.arora 1.2 {
|
93 david.dillard 1.6 CIMClientRep * _rep;
94 _rep = getTargetCIMOM(host, port, CIMNamespaceName());
|
95 a.arora 1.2 _rep->setRequestAcceptLanguages(langs);
96 }
97
|
98 kumpf 1.7 AcceptLanguageList CIMManagedClient::getRequestAcceptLanguages(
|
99 david.dillard 1.6 const String& host,
100 const String& port
101 ) const
|
102 a.arora 1.2 {
|
103 david.dillard 1.6 CIMClientRep * _rep;
104 _rep = getTargetCIMOM(host, port, CIMNamespaceName());
|
105 a.arora 1.2 return _rep->getRequestAcceptLanguages();
106 }
107
|
108 david.dillard 1.6 void CIMManagedClient::setRequestContentLanguages(
109 const String& host,
110 const String& port,
|
111 kumpf 1.7 const ContentLanguageList& langs
|
112 david.dillard 1.6 )
|
113 a.arora 1.2 {
|
114 david.dillard 1.6 CIMClientRep * _rep;
115 _rep = getTargetCIMOM(host, port, CIMNamespaceName());
|
116 a.arora 1.2 _rep->setRequestContentLanguages(langs);
117 }
118
|
119 kumpf 1.7 ContentLanguageList CIMManagedClient::getRequestContentLanguages(const String& host, const String& port) const
|
120 a.arora 1.2 {
|
121 david.dillard 1.6 CIMClientRep * _rep;
122 _rep = getTargetCIMOM(host, port, CIMNamespaceName());
|
123 a.arora 1.2 return _rep->getRequestContentLanguages();
124 }
125
|
126 kumpf 1.7 ContentLanguageList CIMManagedClient::getResponseContentLanguages(const String& host, const String& port) const
|
127 a.arora 1.2 {
|
128 david.dillard 1.6 CIMClientRep * _rep;
129 _rep = getTargetCIMOM(host, port, CIMNamespaceName());
|
130 a.arora 1.2 return _rep->getResponseContentLanguages();
131 }
132
133 void CIMManagedClient::setRequestDefaultLanguages(const String& host, const String& port)
134 {
|
135 david.dillard 1.6 CIMClientRep * _rep;
136 _rep = getTargetCIMOM(host, port, CIMNamespaceName());
|
137 a.arora 1.2 _rep->setRequestDefaultLanguages();
138 }
139 // l10n end
140
141 Array<CIMObjectPath> CIMManagedClient::enumerateInstanceNames(
|
142 david.dillard 1.6 const String& host,
143 const String& port,
|
144 a.arora 1.2 const CIMNamespaceName& nameSpace,
145 const CIMName& className)
146 {
|
147 david.dillard 1.6 // test if host and namespace are provided
148 hasHostandNameSpace(host, nameSpace);
149 CIMClientRep * _rep;
150 _rep = getTargetCIMOM(host, port, nameSpace);
151 Array<CIMObjectPath> returnedInstanceNames = _rep->enumerateInstanceNames(nameSpace, className);
152 for (Uint32 i = 0; i < returnedInstanceNames.size(); i++)
153 {
154 returnedInstanceNames[i].setHost(_getHostwithPort(host, port));
155 returnedInstanceNames[i].setNameSpace(nameSpace);
156 }
157 return returnedInstanceNames;
|
158 a.arora 1.2 }
159
160 Array<CIMInstance> CIMManagedClient::enumerateInstances(
|
161 david.dillard 1.6 const String& host,
162 const String& port,
|
163 a.arora 1.2 const CIMNamespaceName& nameSpace,
164 const CIMName& className,
165 Boolean deepInheritance,
166 Boolean localOnly,
167 Boolean includeQualifiers,
168 Boolean includeClassOrigin,
169 const CIMPropertyList& propertyList
170 )
171 {
|
172 david.dillard 1.6 // test if host and namespace are provided
173 hasHostandNameSpace(host, nameSpace);
174 CIMClientRep * _rep;
175 _rep = getTargetCIMOM(host, port, nameSpace);
|
176 a.arora 1.2
|
177 david.dillard 1.6 Array<CIMInstance> returnedNamedInstances = _rep->enumerateInstances(
|
178 a.arora 1.2 nameSpace,
179 className,
180 deepInheritance,
181 localOnly,
182 includeQualifiers,
183 includeClassOrigin,
184 propertyList);
185
186 // adding host, port and namespace to every Instance to make sure object path is
187 // full specified
188 for (Uint32 i = 0; i < returnedNamedInstances.size(); i++)
189 {
190 CIMObjectPath chgObjectPath = CIMObjectPath(returnedNamedInstances[i].getPath());
|
191 david.dillard 1.6
|
192 a.arora 1.2 chgObjectPath.setHost(_getHostwithPort(host, port));
193 chgObjectPath.setNameSpace(nameSpace);
194
195 returnedNamedInstances[i].setPath(chgObjectPath);
196 }
197 return returnedNamedInstances;
198 }
199
200 Array<CIMObject> CIMManagedClient::execQuery(
201 const String& host,
202 const String& port,
203 const CIMNamespaceName& nameSpace,
204 const String& queryLanguage,
205 const String& query
206 )
207 {
208 // test if host and namespace are provided
209 hasHostandNameSpace(host, nameSpace);
210 CIMClientRep * _rep;
211 _rep = getTargetCIMOM(host, port, nameSpace);
212 Array<CIMObject> returnedCimObjects = _rep->execQuery(
213 a.arora 1.2 nameSpace,
214 queryLanguage,
215 query);
216 // check if all objects contain a full specified object path
217 for (Uint32 i = 0; i < returnedCimObjects.size(); i++)
218 {
219 CIMObjectPath chgObjectPath = CIMObjectPath(returnedCimObjects[i].getPath());
220 // if there is no cimom and no namespace specified, set the current as default
221 // if there is no namespace, but a cimom specified, add the current namespace
222 // if there is no cimom, but a namespace specified, add the current cimom
223 // if there are both cimom and namespace specified, do nothing
224 // thus, only do something if either cimom or namespace is missing
225
226 // test for empty cimom
227 if (chgObjectPath.getHost() == String::EMPTY)
228 {
229 chgObjectPath.setHost(_getHostwithPort(host, port));
|
230 david.dillard 1.6 }
|
231 a.arora 1.2 // test for empty namespace
232 if (chgObjectPath.getNameSpace().isNull())
233 {
234 chgObjectPath.setNameSpace(nameSpace);
235 }
236 returnedCimObjects[i].setPath(chgObjectPath);
237 }
238 return returnedCimObjects;
239 }
240
241
242 Array<CIMClass> CIMManagedClient::enumerateClasses(
243 const String& host,
244 const String& port,
245 const CIMNamespaceName& nameSpace,
246 const CIMName& className,
247 Boolean deepInheritance,
248 Boolean localOnly,
249 Boolean includeQualifiers,
250 Boolean includeClassOrigin
251 )
252 a.arora 1.2 {
253 // test if host and namespace are provided
254 hasHostandNameSpace(host, nameSpace);
255 CIMClientRep * _rep;
256 _rep = getTargetCIMOM(host, port, nameSpace);
257
258 Array<CIMClass> returnedCimClasses = _rep->enumerateClasses(
259 nameSpace,
260 className,
261 deepInheritance,
262 localOnly,
263 includeQualifiers,
264 includeClassOrigin);
265
266 // adding host, port and namespace to every Instance to make sure object path is
267 // full specified
268 for (Uint32 i = 0; i < returnedCimClasses.size(); i++)
269 {
270 CIMObjectPath chgObjectPath = CIMObjectPath(returnedCimClasses[i].getPath());
|
271 david.dillard 1.6
|
272 a.arora 1.2 chgObjectPath.setHost(_getHostwithPort(host,port));
273 chgObjectPath.setNameSpace(nameSpace);
274
275 returnedCimClasses[i].setPath(chgObjectPath);
276 }
277 return returnedCimClasses;
278 }
279
280 Array<CIMName> CIMManagedClient::enumerateClassNames(
281 const String& host,
282 const String& port,
283 const CIMNamespaceName& nameSpace,
284 const CIMName& className,
285 Boolean deepInheritance
286 )
287 {
288 // test if host and namespace are provided
289 hasHostandNameSpace(host, nameSpace);
290 CIMClientRep * _rep;
291 _rep = getTargetCIMOM(host, port, nameSpace);
292 return _rep->enumerateClassNames(
293 a.arora 1.2 nameSpace,
294 className,
295 deepInheritance);
296 }
297
298 CIMClass CIMManagedClient::getClass(
299 const String& host,
300 const String& port,
301 const CIMNamespaceName& nameSpace,
302 const CIMName& className,
303 Boolean localOnly,
304 Boolean includeQualifiers,
305 Boolean includeClassOrigin,
306 const CIMPropertyList& propertyList
307 )
308 {
309 // test if host and namespace are provided
310 hasHostandNameSpace(host, nameSpace);
311 CIMClientRep * _rep;
312 _rep = getTargetCIMOM(host, port, nameSpace);
313 CIMClass returnedCimClass = _rep->getClass(
314 a.arora 1.2 nameSpace,
315 className,
316 localOnly,
317 includeQualifiers,
318 includeClassOrigin,
319 propertyList);
320
321 CIMObjectPath chgObjectPath = CIMObjectPath(returnedCimClass.getPath());
|
322 david.dillard 1.6
|
323 a.arora 1.2 chgObjectPath.setHost(_getHostwithPort(host, port));
324 chgObjectPath.setNameSpace(nameSpace);
325
326 returnedCimClass.setPath(chgObjectPath);
327 return returnedCimClass;
328 }
329
330 void CIMManagedClient::createClass(
331 const String& host,
332 const String& port,
333 const CIMNamespaceName& nameSpace,
334 const CIMClass& newClass
335 )
336 {
337 // test if host and namespace are provided
338 hasHostandNameSpace(host, nameSpace);
339 CIMClientRep * _rep;
340 _rep = getTargetCIMOM(host, port, nameSpace);
341 _rep->createClass(
342 nameSpace,
343 newClass);
344 a.arora 1.2 }
345
346 void CIMManagedClient::deleteClass(
347 const String& host,
348 const String& port,
349 const CIMNamespaceName& nameSpace,
350 const CIMName& className
351 )
352 {
353 // test if host and namespace are provided
354 hasHostandNameSpace(host, nameSpace);
355 CIMClientRep * _rep;
356 _rep = getTargetCIMOM(host, port, nameSpace);
357 _rep->deleteClass(
358 nameSpace,
359 className);
360 }
361
362 void CIMManagedClient::deleteQualifier(
363 const String& host,
364 const String& port,
365 a.arora 1.2 const CIMNamespaceName& nameSpace,
366 const CIMName& qualifierName
367 )
368 {
369 // test if host and namespace are provided
370 hasHostandNameSpace(host, nameSpace);
371 CIMClientRep * _rep;
372 _rep = getTargetCIMOM(host, port, nameSpace);
373 _rep->deleteQualifier(
374 nameSpace,
375 qualifierName);
376 }
377
378 CIMQualifierDecl CIMManagedClient::getQualifier(
379 const String& host,
380 const String& port,
381 const CIMNamespaceName& nameSpace,
382 const CIMName& qualifierName
383 )
384 {
385 // test if host and namespace are provided
386 a.arora 1.2 hasHostandNameSpace(host, nameSpace);
387 CIMClientRep * _rep;
388 _rep = getTargetCIMOM(host, port, nameSpace);
389 return _rep->getQualifier(
390 nameSpace,
391 qualifierName);
392 }
393
394 Array<CIMQualifierDecl> CIMManagedClient::enumerateQualifiers(
395 const String& host,
396 const String& port,
397 const CIMNamespaceName& nameSpace
398 )
399 {
400 // test if host and namespace are provided
401 hasHostandNameSpace(host, nameSpace);
402 CIMClientRep * _rep;
403 _rep = getTargetCIMOM(host, port, nameSpace);
404 return _rep->enumerateQualifiers(
405 nameSpace);
406 }
407 a.arora 1.2
408
409 void CIMManagedClient::modifyClass(
410 const String& host,
411 const String& port,
412 const CIMNamespaceName& nameSpace,
413 const CIMClass& modifiedClass
414 )
415 {
416 // test if host and namespace are provided
417 hasHostandNameSpace(host, nameSpace);
418 CIMClientRep * _rep;
419 _rep = getTargetCIMOM(host, port, nameSpace);
420 _rep->modifyClass(
421 nameSpace,
422 modifiedClass);
423 }
424
425 void CIMManagedClient::setQualifier(
426 const String& host,
427 const String& port,
428 a.arora 1.2 const CIMNamespaceName& nameSpace,
429 const CIMQualifierDecl& qualifierDeclaration
430 )
431 {
432 // test if host and namespace are provided
433 hasHostandNameSpace(host, nameSpace);
434 CIMClientRep * _rep;
435 _rep = getTargetCIMOM(host, port, nameSpace);
436 _rep->setQualifier(
437 nameSpace,
438 qualifierDeclaration);
439 }
440
441 CIMValue CIMManagedClient::getProperty(
442 const CIMObjectPath& instanceName,
443 const CIMName& propertyName
444 )
445 {
446 hasHostandNameSpace(instanceName);
447 CIMClientRep * _rep;
448 _rep = getTargetCIMOM(instanceName);
449 a.arora 1.2 return _rep->getProperty(
450 instanceName.getNameSpace(),
451 instanceName,
452 propertyName);
453 }
454
455 void CIMManagedClient::setProperty(
456 const CIMObjectPath& instanceName,
457 const CIMName& propertyName,
458 const CIMValue& newValue
459 )
460 {
461 hasHostandNameSpace(instanceName);
462 CIMClientRep * _rep;
463 _rep = getTargetCIMOM(instanceName);
464 _rep->setProperty(
465 instanceName.getNameSpace(),
466 instanceName,
467 propertyName,
468 newValue);
469 }
470 a.arora 1.2
471
472 void CIMManagedClient::deleteInstance(
473 const CIMObjectPath& instanceName
474 )
475 {
476 hasHostandNameSpace(instanceName);
477 CIMClientRep * _rep;
478 _rep = getTargetCIMOM(instanceName);
479 _rep->deleteInstance(
480 instanceName.getNameSpace(),
481 instanceName);
482 }
483
484 CIMObjectPath CIMManagedClient::createInstance(
485 const CIMInstance& newInstance
486 )
487 {
488 hasHostandNameSpace(newInstance);
489 // save name space for later usage
490 CIMNamespaceName reqNameSpace = CIMNamespaceName(newInstance.getPath().getNameSpace());
491 a.arora 1.2 CIMClientRep * _rep;
492 _rep = getTargetCIMOM(newInstance.getPath());
493 CIMObjectPath returnedObjectPath = _rep->createInstance(
494 reqNameSpace,
495 newInstance);
496 // put host and namespace back into object path, so it is definite fully specified
497 returnedObjectPath.setHost(newInstance.getPath().getHost());
498 returnedObjectPath.setNameSpace(reqNameSpace);
499 return returnedObjectPath;
500 }
501
502 CIMInstance CIMManagedClient::getInstance(
503 const CIMObjectPath& instanceName,
504 Boolean localOnly,
505 Boolean includeQualifiers,
506 Boolean includeClassOrigin,
507 const CIMPropertyList& propertyList
508 )
509 {
510 hasHostandNameSpace(instanceName);
511 CIMNamespaceName reqNameSpace = CIMNamespaceName(instanceName.getNameSpace());
512 a.arora 1.2 CIMClientRep * _rep;
513 _rep = getTargetCIMOM(instanceName);
514 CIMInstance returnedCimInstance = _rep->getInstance(
515 reqNameSpace,
516 instanceName,
517 localOnly,
518 includeQualifiers,
519 includeClassOrigin,
520 propertyList);
521 /*
522 CIMObjectPath chgObjectPath = CIMObjectPath(returnedCimInstance.getPath());
523
524 chgObjectPath.setHost(instanceName.getHost());
525 chgObjectPath.setNameSpace(reqNameSpace);
526
527 returnedCimInstance.setPath(chgObjectPath);
528 */
529 // changed to take over the entire CIMObjectPath that was given ...
530 returnedCimInstance.setPath(instanceName);
531
532 return returnedCimInstance;
533 a.arora 1.2 }
534
535 void CIMManagedClient::modifyInstance(
536 const CIMInstance& modifiedInstance,
537 Boolean includeQualifiers,
538 const CIMPropertyList& propertyList
539 )
540 {
541 hasHostandNameSpace(modifiedInstance);
542 CIMClientRep * _rep;
543 _rep = getTargetCIMOM(modifiedInstance.getPath());
544 _rep->modifyInstance(
545 modifiedInstance.getPath().getNameSpace(),
546 modifiedInstance,
547 includeQualifiers,
548 propertyList);
549 }
550
551
552 CIMValue CIMManagedClient::invokeMethod(
553 const CIMObjectPath& instanceName,
554 a.arora 1.2 const CIMName& methodName,
555 const Array<CIMParamValue>& inParameters,
556 Array<CIMParamValue>& outParameters
557 )
558 {
559 hasHostandNameSpace(instanceName);
560 CIMClientRep * _rep;
561 _rep = getTargetCIMOM(instanceName);
562 return _rep->invokeMethod(
563 instanceName.getNameSpace(),
564 instanceName,
565 methodName,
566 inParameters,
567 outParameters);
568 }
569
570 Array<CIMObjectPath> CIMManagedClient::associatorNames(
571 const CIMObjectPath& objectName,
572 const CIMName& assocClass,
573 const CIMName& resultClass,
574 const String& role,
575 a.arora 1.2 const String& resultRole
576 )
577 {
578 hasHostandNameSpace(objectName);
579 CIMClientRep * _rep;
580 _rep = getTargetCIMOM(objectName);
581 Array<CIMObjectPath> retAssocNames = _rep->associatorNames(
582 objectName.getNameSpace(),
583 objectName,
584 assocClass,
585 resultClass,
586 role,
587 resultRole);
588
589 for (Uint32 i = 0; i < retAssocNames.size(); i++)
590 {
591 try
592 {
593 // check if all object paths are fully qualified
594 hasHostandNameSpace(retAssocNames[i]);
595 }
596 a.arora 1.2 catch(TypeMismatchException tme)
597 {
598 // should throw nasty exception about missing namespace ....
599 // TODO: prepare exception for this
600 MessageLoaderParms retTypeMismatchMessage = MessageLoaderParms("Client.CIMClientRep.TYPEMISMATCH_PORTMISMATCH",
601 "Returned CIM object path incomplete specified.");
602 throw TypeMismatchException(retTypeMismatchMessage);
603 }
604 }
605 return retAssocNames;
606 }
607
608 Array<CIMObject> CIMManagedClient::associators(
609 const CIMObjectPath& objectName,
610 const CIMName& assocClass,
611 const CIMName& resultClass,
612 const String& role,
613 const String& resultRole,
614 Boolean includeQualifiers,
615 Boolean includeClassOrigin,
616 const CIMPropertyList& propertyList
617 a.arora 1.2 )
618 {
619 hasHostandNameSpace(objectName);
620 CIMClientRep * _rep;
621 _rep = getTargetCIMOM(objectName);
622 Array<CIMObject> retAssoc = _rep->associators(
623 objectName.getNameSpace(),
624 objectName,
625 assocClass,
626 resultClass,
627 role,
628 resultRole,
629 includeQualifiers,
630 includeClassOrigin,
631 propertyList);
632 for (Uint32 i = 0; i < retAssoc.size(); i++)
633 {
634 // check if all object paths are fully qualified
|
635 david.dillard 1.6 try
|
636 a.arora 1.2 {
637 hasHostandNameSpace(retAssoc[i].getPath());
638 }
639 catch(TypeMismatchException tme)
640 {
641 // should throw nasty exception about missing namespace ....
642 // TODO: prepare exception for this
643 MessageLoaderParms retTypeMismatchMessage = MessageLoaderParms("Client.CIMClientRep.TYPEMISMATCH_PORTMISMATCH",
644 "Returned CIM object path incomplete specified.");
645 throw TypeMismatchException(retTypeMismatchMessage);
646 }
647 }
648 return retAssoc;
649 }
650
651 Array<CIMObject> CIMManagedClient::references(
652 const CIMObjectPath& objectName,
653 const CIMName& resultClass,
654 const String& role,
655 Boolean includeQualifiers,
656 Boolean includeClassOrigin,
657 a.arora 1.2 const CIMPropertyList& propertyList
658 )
659 {
660 hasHostandNameSpace(objectName);
661 CIMClientRep * _rep;
662 _rep = getTargetCIMOM(objectName);
663 Array<CIMObject> retRefer = _rep->references(
664 objectName.getNameSpace(),
665 objectName,
666 resultClass,
667 role,
668 includeQualifiers,
669 includeClassOrigin,
670 propertyList);
671
672 for (Uint32 i = 0; i < retRefer.size(); i++)
673 {
674 // check if all object paths are fully qualified
|
675 david.dillard 1.6 try
|
676 a.arora 1.2 {
677 hasHostandNameSpace(retRefer[i].getPath());
678 }
679 catch(TypeMismatchException tme)
680 {
681 // should throw nasty exception about missing namespace ....
682 // TODO: prepare exception for this
683 MessageLoaderParms retTypeMismatchMessage = MessageLoaderParms("Client.CIMClientRep.TYPEMISMATCH_PORTMISMATCH",
684 "Returned CIM object path incomplete specified.");
685 throw TypeMismatchException(retTypeMismatchMessage);
686 }
687 }
688 return retRefer;
689 }
690
691 Array<CIMObjectPath> CIMManagedClient::referenceNames(
692 const CIMObjectPath& objectName,
693 const CIMName& resultClass,
694 const String& role
695 )
696 {
697 a.arora 1.2 hasHostandNameSpace(objectName);
698 CIMClientRep * _rep;
699 _rep = getTargetCIMOM(objectName);
700 Array<CIMObjectPath> retReferNames = _rep->referenceNames(
701 objectName.getNameSpace(),
702 objectName,
703 resultClass,
704 role);
705 for (Uint32 i = 0; i < retReferNames.size(); i++)
706 {
707 try
708 {
709 // check if all object paths are fully qualified
710 hasHostandNameSpace(retReferNames[i]);
711 }
712 catch(TypeMismatchException tme)
713 {
714 // should throw nasty exception about missing namespace ....
715 // TODO: prepare exception for this
716 MessageLoaderParms retTypeMismatchMessage = MessageLoaderParms("Client.CIMClientRep.TYPEMISMATCH_PORTMISMATCH",
717 "Returned CIM object path incomplete specified.");
718 a.arora 1.2 throw TypeMismatchException(retTypeMismatchMessage);
719 }
720 }
721 return retReferNames;
722 }
723
724
725
|
726 david.dillard 1.5 void CIMManagedClient::hasHostandNameSpace(const String& _host, const CIMNamespaceName& _nameSpace)
|
727 a.arora 1.2 {
728 MessageLoaderParms typeMismatchMessage;
729 if (_host == String::EMPTY)
730 {
731 // should throw nasty exception about missing hostname ....
732 // TODO: prepare exception for this
733 typeMismatchMessage = MessageLoaderParms("Client.CIMClientRep.TYPEMISMATCH_PORTMISMATCH",
734 "Failed validation of CIM object path: no host name specified");
|
735 david.dillard 1.6 throw TypeMismatchException(typeMismatchMessage);
|
736 a.arora 1.2 }
737 if (_nameSpace.isNull())
738 {
739 // should throw nasty exception about missing namespace ....
740 // TODO: prepare exception for this
741 typeMismatchMessage = MessageLoaderParms("Client.CIMClientRep.TYPEMISMATCH_PORTMISMATCH",
742 "Failed validation of CIM object path: no namespace specified");
|
743 david.dillard 1.6 throw TypeMismatchException(typeMismatchMessage);
|
744 a.arora 1.2 }
745 CDEBUG("No exception thrown, seems the host and namespace are there.");
746 }
747
|
748 david.dillard 1.5 void CIMManagedClient::hasHostandNameSpace(const CIMObjectPath& inObjectPath)
|
749 a.arora 1.2 {
750 CDEBUG("hasHostandNameSpace(inObjectPath.getHost(), inObjectPath.getNameSpace())=" << inObjectPath.getHost() << "," << inObjectPath.getNameSpace());
751 hasHostandNameSpace(inObjectPath.getHost(), inObjectPath.getNameSpace());
752 }
753
|
754 david.dillard 1.5 void CIMManagedClient::hasHostandNameSpace(const CIMInstance& inInstance)
|
755 a.arora 1.2 {
756 hasHostandNameSpace(inInstance.getPath());
757 }
758
759 CIMClientRep* CIMManagedClient::getTargetCIMOM(const String& _host,const String& _port, const CIMNamespaceName& _nameSpace) const
760 {
761 CIMClientRep * targetCIMOM;
762 if (strtoul((const char*) _port.getCString(), NULL, 0) == 0)
|
763 david.dillard 1.6 {
|
764 a.arora 1.2 CDEBUG("no port given explicitly, thus we use the default port:" << _pegasusDefaultPort);
765 // no port given explicitly, thus we use the default port of 5988
766 // lets determine if there is a connection for this object path available
767 targetCIMOM = _cccm->getConnection(_host, _pegasusDefaultPort, _nameSpace);
768 } else {
769 // lets determine if there is a connection for this object path available
770 targetCIMOM = _cccm->getConnection(_host, _port, _nameSpace);
771 }
772 // damn, somehow we missed to construct a CIMClientRep for this connection
773 // shouldn't be possible at all, but one never knows everything
774 if (targetCIMOM == 0)
775 {
776 // throw some crazy exception
777 // TODO: invent exception
778 MessageLoaderParms typeMismatchMessage = MessageLoaderParms("Client.CIMClientRep.TYPEMISMATCH_PORTMISMATCH",
779 "No valid CIMOM connection configured for: ($0:$1) ",
|
780 david.dillard 1.6 _host, _port);
781 throw TypeMismatchException(typeMismatchMessage);
|
782 a.arora 1.2 }
783 CDEBUG("targetCIMOM=" << targetCIMOM);
784 return targetCIMOM;
785 }
786
787 CIMClientRep* CIMManagedClient::getTargetCIMOM(const CIMObjectPath& inObjectPath) const
788 {
789 String inHost, inPort;
790 CIMNamespaceName inNameSpace;
791 inNameSpace = inObjectPath.getNameSpace();
792
793 // need to create our own Host String object, as we split it in two pieces
794 // thus change it ...
795 inHost = String(inObjectPath.getHost());
796
797 // test if a host is given at all not necessary here
798 // if there is no we failed to detect that before anyway
799 // wonder how that should possibly happen???
800
801 // splitting the port from hostname
802 int i = inHost.find(":");
803 a.arora 1.2 // only if there is a ":" we should split a port address from hostname string
804 if (i > 0)
805 {
806 inPort = inHost.subString(i+1);
807 inHost.remove(i);
808 } else
809 {
810 // if there is no : , there is no port, we use the default empty port
811 inPort = String::EMPTY;
812 }
813 return getTargetCIMOM(inHost, inPort, inNameSpace);
814 }
815
816
817 void CIMManagedClient::setPegasusDefaultPort()
818 {
819 _pegasusDefaultPort = String("5988");
820 }
821
822 String CIMManagedClient::_getHostwithPort(const String& host, const String& port)
823 {
824 a.arora 1.2 String hostwithport=String(host);
825 hostwithport.append(":");
826 hostwithport.append(port);
827 return hostwithport;
828 }
829
830 PEGASUS_NAMESPACE_END
|