(file) Return to CIMManagedClient.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / ManagedClient

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2