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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2