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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2