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

  1 martin 1.105 //%LICENSE////////////////////////////////////////////////////////////////
  2 martin 1.106 //
  3 martin 1.105 // 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.106 //
 10 martin 1.105 // 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.106 //
 17 martin 1.105 // The above copyright notice and this permission notice shall be included
 18              // in all copies or substantial portions of the Software.
 19 martin 1.106 //
 20 martin 1.105 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21 martin 1.106 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 22 martin 1.105 // 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.106 //
 28 martin 1.105 //////////////////////////////////////////////////////////////////////////
 29 mike   1.27  //
 30              //%/////////////////////////////////////////////////////////////////////////////
 31              
 32              #include "CIMClient.h"
 33 kumpf  1.91  #include <Pegasus/Client/CIMClientRep.h>
 34 kumpf  1.92  #include <Pegasus/Common/PegasusVersion.h>
 35 humberto 1.90  
 36 mike     1.27  #include <iostream>
 37 kumpf    1.78  #include <fstream>
 38 mike     1.27  
 39                PEGASUS_USING_STD;
 40                
 41                PEGASUS_NAMESPACE_BEGIN
 42                
 43 kumpf    1.54  ///////////////////////////////////////////////////////////////////////////////
 44                //
 45                // CIMClient
 46                //
 47                ///////////////////////////////////////////////////////////////////////////////
 48                
 49 a.arora  1.97  CIMClient::CIMClient()
 50 kumpf    1.54  {
 51 kumpf    1.104     _rep = new CIMClientRep();
 52                }
 53                
 54                CIMClient::~CIMClient()
 55                {
 56                    delete _rep;
 57                }
 58 kumpf    1.54  
 59 kumpf    1.68  Uint32 CIMClient::getTimeout() const
 60 kumpf    1.54  {
 61 kumpf    1.68      return _rep->getTimeout();
 62 kumpf    1.54  }
 63                
 64 kumpf    1.68  void CIMClient::setTimeout(Uint32 timeoutMilliseconds)
 65 kumpf    1.54  {
 66 kumpf    1.68      _rep->setTimeout(timeoutMilliseconds);
 67 kumpf    1.54  }
 68                
 69                void CIMClient::connect(
 70 kumpf    1.75      const String& host,
 71                    const Uint32 portNumber,
 72 kumpf    1.54      const String& userName,
 73 kumpf    1.104     const String& password)
 74 kumpf    1.54  {
 75 kumpf    1.75      _rep->connect(host, portNumber, userName, password);
 76 kumpf    1.54  }
 77                
 78                void CIMClient::connect(
 79 kumpf    1.75      const String& host,
 80                    const Uint32 portNumber,
 81 kumpf    1.70      const SSLContext& sslContext,
 82 kumpf    1.54      const String& userName,
 83 kumpf    1.104     const String& password)
 84 kumpf    1.54  {
 85 kumpf    1.75      _rep->connect(host, portNumber, sslContext, userName, password);
 86 kumpf    1.54  }
 87                
 88 kumpf    1.65  void CIMClient::connectLocal()
 89 kumpf    1.54  {
 90 kumpf    1.57      _rep->connectLocal();
 91 kumpf    1.54  }
 92                
 93                void CIMClient::disconnect()
 94                {
 95                    _rep->disconnect();
 96                }
 97                
 98 kumpf    1.102 void CIMClient::setRequestAcceptLanguages(const AcceptLanguageList& langs)
 99 chuck    1.85  {
100 kumpf    1.91      _rep->setRequestAcceptLanguages(langs);
101 chuck    1.85  }
102                
103 kumpf    1.102 AcceptLanguageList CIMClient::getRequestAcceptLanguages() const
104 chuck    1.85  {
105 kumpf    1.91      return _rep->getRequestAcceptLanguages();
106 chuck    1.85  }
107 kumpf    1.91  
108 kumpf    1.102 void CIMClient::setRequestContentLanguages(const ContentLanguageList& langs)
109 chuck    1.85  {
110 kumpf    1.91      _rep->setRequestContentLanguages(langs);
111 chuck    1.85  }
112 kumpf    1.91  
113 kumpf    1.102 ContentLanguageList CIMClient::getRequestContentLanguages() const
114 chuck    1.85  {
115 kumpf    1.91      return _rep->getRequestContentLanguages();
116                }
117                
118 kumpf    1.102 ContentLanguageList CIMClient::getResponseContentLanguages() const
119 chuck    1.85  {
120 kumpf    1.91      return _rep->getResponseContentLanguages();
121 humberto 1.86  }
122                
123 kumpf    1.91  void CIMClient::setRequestDefaultLanguages()
124                {
125                    _rep->setRequestDefaultLanguages();
126 chuck    1.85  }
127 kumpf    1.54  
128                CIMClass CIMClient::getClass(
129 kumpf    1.64      const CIMNamespaceName& nameSpace,
130                    const CIMName& className,
131 kumpf    1.54      Boolean localOnly,
132                    Boolean includeQualifiers,
133                    Boolean includeClassOrigin,
134 kumpf    1.104     const CIMPropertyList& propertyList)
135 kumpf    1.54  {
136                    return _rep->getClass(
137                        nameSpace,
138                        className,
139                        localOnly,
140                        includeQualifiers,
141                        includeClassOrigin,
142                        propertyList);
143                }
144                
145                CIMInstance CIMClient::getInstance(
146 kumpf    1.64      const CIMNamespaceName& nameSpace,
147 kumpf    1.56      const CIMObjectPath& instanceName,
148 kumpf    1.54      Boolean localOnly,
149                    Boolean includeQualifiers,
150                    Boolean includeClassOrigin,
151 kumpf    1.104     const CIMPropertyList& propertyList)
152 kumpf    1.54  {
153 thilo.boehm 1.107     CIMInstance inst = _rep->getInstance(
154 kumpf       1.54          nameSpace,
155                           instanceName,
156                           localOnly,
157                           includeQualifiers,
158                           includeClassOrigin,
159 thilo.boehm 1.107         propertyList).getInstance();
160                   
161                       if (!inst.isUninitialized())
162                       {
163                           // remove key bindings, name space and host name form object path.
164                           CIMObjectPath& p =
165                               const_cast<CIMObjectPath&>(inst.getPath());
166                   
167                           CIMName cls = p.getClassName();
168                           p.clear();
169                           p.setClassName(cls);
170                   
171                       }
172 marek       1.108 #ifdef PEGASUS_ENABLE_PROTOCOL_BINARY
173                       CIMClientRep * rep = static_cast<CIMClientRep*>(_rep);
174                       if (rep->_binaryResponse)
175                       {
176                           inst.instanceFilter(includeQualifiers,includeClassOrigin,propertyList);
177                       }
178                   #endif
179 thilo.boehm 1.107 
180                       return inst;
181 kumpf       1.54  }
182                   
183                   void CIMClient::deleteClass(
184 kumpf       1.64      const CIMNamespaceName& nameSpace,
185 kumpf       1.104     const CIMName& className)
186 kumpf       1.54  {
187                       _rep->deleteClass(
188                           nameSpace,
189                           className);
190                   }
191                   
192                   void CIMClient::deleteInstance(
193 kumpf       1.64      const CIMNamespaceName& nameSpace,
194 kumpf       1.104     const CIMObjectPath& instanceName)
195 kumpf       1.54  {
196                       _rep->deleteInstance(
197                           nameSpace,
198                           instanceName);
199                   }
200                   
201                   void CIMClient::createClass(
202 kumpf       1.64      const CIMNamespaceName& nameSpace,
203 kumpf       1.104     const CIMClass& newClass)
204 kumpf       1.54  {
205                       _rep->createClass(
206                           nameSpace,
207                           newClass);
208                   }
209                   
210 kumpf       1.56  CIMObjectPath CIMClient::createInstance(
211 kumpf       1.64      const CIMNamespaceName& nameSpace,
212 kumpf       1.104     const CIMInstance& newInstance)
213 kumpf       1.54  {
214                       return _rep->createInstance(
215                           nameSpace,
216                           newInstance);
217                   }
218                   
219                   void CIMClient::modifyClass(
220 kumpf       1.64      const CIMNamespaceName& nameSpace,
221 kumpf       1.104     const CIMClass& modifiedClass)
222 kumpf       1.54  {
223                       _rep->modifyClass(
224                           nameSpace,
225                           modifiedClass);
226                   }
227                   
228                   void CIMClient::modifyInstance(
229 kumpf       1.64      const CIMNamespaceName& nameSpace,
230 kumpf       1.60      const CIMInstance& modifiedInstance,
231 kumpf       1.54      Boolean includeQualifiers,
232 kumpf       1.104     const CIMPropertyList& propertyList)
233 kumpf       1.54  {
234                       _rep->modifyInstance(
235                           nameSpace,
236                           modifiedInstance,
237                           includeQualifiers,
238                           propertyList);
239                   }
240                   
241                   Array<CIMClass> CIMClient::enumerateClasses(
242 kumpf       1.64      const CIMNamespaceName& nameSpace,
243                       const CIMName& className,
244 kumpf       1.54      Boolean deepInheritance,
245                       Boolean localOnly,
246                       Boolean includeQualifiers,
247 kumpf       1.104     Boolean includeClassOrigin)
248 kumpf       1.54  {
249                       return _rep->enumerateClasses(
250                           nameSpace,
251                           className,
252                           deepInheritance,
253                           localOnly,
254                           includeQualifiers,
255                           includeClassOrigin);
256                   }
257                   
258 kumpf       1.64  Array<CIMName> CIMClient::enumerateClassNames(
259                       const CIMNamespaceName& nameSpace,
260                       const CIMName& className,
261 kumpf       1.104     Boolean deepInheritance)
262 kumpf       1.54  {
263                       return _rep->enumerateClassNames(
264                           nameSpace,
265                           className,
266                           deepInheritance);
267                   }
268                   
269 kumpf       1.60  Array<CIMInstance> CIMClient::enumerateInstances(
270 kumpf       1.64      const CIMNamespaceName& nameSpace,
271                       const CIMName& className,
272 kumpf       1.54      Boolean deepInheritance,
273                       Boolean localOnly,
274                       Boolean includeQualifiers,
275                       Boolean includeClassOrigin,
276 kumpf       1.104     const CIMPropertyList& propertyList)
277 kumpf       1.54  {
278 marek       1.108 #ifndef PEGASUS_ENABLE_PROTOCOL_BINARY
279 thilo.boehm 1.107     Array<CIMInstance> a = _rep->enumerateInstances(
280                               nameSpace,
281                               className,
282                               deepInheritance,
283                               localOnly,
284                               includeQualifiers,
285                               includeClassOrigin,
286 marek       1.108             propertyList).getInstances();
287                   #else
288                       CIMResponseData respData = _rep->enumerateInstances(
289                           nameSpace,
290                           className,
291                           deepInheritance,
292                           localOnly,
293                           includeQualifiers,
294                           includeClassOrigin,
295                           propertyList);
296                   
297                       Array<CIMInstance> a = respData.getInstances();
298                       CIMClientRep * rep = static_cast<CIMClientRep*>(_rep);
299 thilo.boehm 1.107 
300 marek       1.108     if (rep->_binaryResponse)
301                       {
302                           CIMPropertyList returnedPropList = respData.getPropertyList();
303                           for (Uint32 i = 0, n = a.size(); i < n ; i++)
304                           {
305                               CIMInstance & inst = a[i];
306                               inst.instanceFilter(
307                                   includeQualifiers,
308                                   includeClassOrigin,
309                                   returnedPropList);
310                           }
311                       }
312                   #endif    
313 thilo.boehm 1.107     // remove name space and host name to be instance names
314                       for (Uint32 i = 0, n = a.size(); i < n ; i++)
315                       {
316                           if (!a[i].isUninitialized())
317                           {
318                               CIMObjectPath& p = const_cast<CIMObjectPath&>(a[i].getPath());
319                               p.setNameSpace(CIMNamespaceName());
320                               p.setHost(String());
321                           }
322                       }
323                   
324                       return a;
325 kumpf       1.54  }
326                   
327 kumpf       1.56  Array<CIMObjectPath> CIMClient::enumerateInstanceNames(
328 kumpf       1.64      const CIMNamespaceName& nameSpace,
329 kumpf       1.104     const CIMName& className)
330 kumpf       1.54  {
331 thilo.boehm 1.107 
332                       Array<CIMObjectPath> p = _rep->enumerateInstanceNames(
333 kumpf       1.54          nameSpace,
334 thilo.boehm 1.107         className).getInstanceNames();
335                   
336                       // remover name space and host name from object paths to be 
337                       // instance names.
338                       for (Uint32 i = 0, n = p.size(); i < n ; i++)
339                       {
340                           p[i].setNameSpace(CIMNamespaceName());
341                           p[i].setHost(String());
342                       }
343                   
344                       return p;
345                   
346 kumpf       1.54  }
347                   
348 kumpf       1.61  Array<CIMObject> CIMClient::execQuery(
349 kumpf       1.64      const CIMNamespaceName& nameSpace,
350 kumpf       1.54      const String& queryLanguage,
351 kumpf       1.104     const String& query)
352 kumpf       1.54  {
353                       return _rep->execQuery(
354                           nameSpace,
355                           queryLanguage,
356 thilo.boehm 1.107         query).getObjects();
357 kumpf       1.54  }
358                   
359 kumpf       1.61  Array<CIMObject> CIMClient::associators(
360 kumpf       1.64      const CIMNamespaceName& nameSpace,
361 kumpf       1.56      const CIMObjectPath& objectName,
362 kumpf       1.64      const CIMName& assocClass,
363                       const CIMName& resultClass,
364 kumpf       1.54      const String& role,
365                       const String& resultRole,
366                       Boolean includeQualifiers,
367                       Boolean includeClassOrigin,
368 kumpf       1.104     const CIMPropertyList& propertyList)
369 kumpf       1.54  {
370 marek       1.108     CIMResponseData respData = _rep->associators(
371 kumpf       1.54          nameSpace,
372                           objectName,
373                           assocClass,
374                           resultClass,
375                           role,
376                           resultRole,
377                           includeQualifiers,
378                           includeClassOrigin,
379 marek       1.108         propertyList);
380                   
381                       Array<CIMObject> a = respData.getObjects();
382                   #ifdef PEGASUS_ENABLE_PROTOCOL_BINARY
383                       CIMClientRep * rep = static_cast<CIMClientRep*>(_rep);
384                       if (rep->_binaryResponse)
385                       {
386                           CIMPropertyList returnedPropList = respData.getPropertyList();
387                           if ((a.size() > 0) && (a[0].isInstance()))
388                           {
389                               for (Uint32 i = 0, n = a.size(); i < n ; i++)
390                               {    
391                                   CIMObject & obj = a[i];
392                                   obj.instanceFilter(
393                                       includeQualifiers,
394                                       includeClassOrigin,
395                                       propertyList);
396                               }
397                           }
398                       }    
399                   #endif
400 marek       1.108     return a;
401 kumpf       1.54  }
402                   
403 kumpf       1.56  Array<CIMObjectPath> CIMClient::associatorNames(
404 kumpf       1.64      const CIMNamespaceName& nameSpace,
405 kumpf       1.56      const CIMObjectPath& objectName,
406 kumpf       1.64      const CIMName& assocClass,
407                       const CIMName& resultClass,
408 kumpf       1.54      const String& role,
409 kumpf       1.104     const String& resultRole)
410 kumpf       1.54  {
411                       return _rep->associatorNames(
412                           nameSpace,
413                           objectName,
414                           assocClass,
415                           resultClass,
416                           role,
417 thilo.boehm 1.107         resultRole).getInstanceNames();
418 kumpf       1.54  }
419                   
420 kumpf       1.61  Array<CIMObject> CIMClient::references(
421 kumpf       1.64      const CIMNamespaceName& nameSpace,
422 kumpf       1.56      const CIMObjectPath& objectName,
423 kumpf       1.64      const CIMName& resultClass,
424 kumpf       1.54      const String& role,
425                       Boolean includeQualifiers,
426                       Boolean includeClassOrigin,
427 kumpf       1.104     const CIMPropertyList& propertyList)
428 kumpf       1.54  {
429 marek       1.108     CIMResponseData respData = _rep->references(
430 kumpf       1.54          nameSpace,
431                           objectName,
432                           resultClass,
433                           role,
434                           includeQualifiers,
435                           includeClassOrigin,
436 marek       1.108         propertyList);
437                       Array<CIMObject> a = respData.getObjects();
438                   
439                   #ifdef PEGASUS_ENABLE_PROTOCOL_BINARY
440                       CIMClientRep * rep = static_cast<CIMClientRep*>(_rep);
441                       if (rep->_binaryResponse)
442                       {
443                           CIMPropertyList returnedPropList = respData.getPropertyList();
444                           if ((a.size() > 0) && (a[0].isInstance()))
445                           {
446                               for (Uint32 i = 0, n = a.size(); i < n ; i++)
447                               {    
448                                   CIMObject & obj = a[i];
449                                   obj.instanceFilter(
450                                       includeQualifiers,
451                                       includeClassOrigin,
452                                       propertyList);
453                               }
454                           }
455                       }    
456                   #endif
457 marek       1.108     return a;
458 kumpf       1.54  }
459                   
460 kumpf       1.56  Array<CIMObjectPath> CIMClient::referenceNames(
461 kumpf       1.64      const CIMNamespaceName& nameSpace,
462 kumpf       1.56      const CIMObjectPath& objectName,
463 kumpf       1.64      const CIMName& resultClass,
464 kumpf       1.104     const String& role)
465 kumpf       1.54  {
466                       return _rep->referenceNames(
467                           nameSpace,
468                           objectName,
469                           resultClass,
470 thilo.boehm 1.107         role).getInstanceNames();
471 kumpf       1.54  }
472                   
473                   CIMValue CIMClient::getProperty(
474 kumpf       1.64      const CIMNamespaceName& nameSpace,
475 kumpf       1.56      const CIMObjectPath& instanceName,
476 kumpf       1.104     const CIMName& propertyName)
477 kumpf       1.54  {
478                       return _rep->getProperty(
479                           nameSpace,
480                           instanceName,
481                           propertyName);
482                   }
483                   
484                   void CIMClient::setProperty(
485 kumpf       1.64      const CIMNamespaceName& nameSpace,
486 kumpf       1.56      const CIMObjectPath& instanceName,
487 kumpf       1.64      const CIMName& propertyName,
488 kumpf       1.104     const CIMValue& newValue)
489 kumpf       1.54  {
490                       _rep->setProperty(
491                           nameSpace,
492                           instanceName,
493                           propertyName,
494                           newValue);
495                   }
496                   
497                   CIMQualifierDecl CIMClient::getQualifier(
498 kumpf       1.64      const CIMNamespaceName& nameSpace,
499 kumpf       1.104     const CIMName& qualifierName)
500 kumpf       1.54  {
501                       return _rep->getQualifier(
502                           nameSpace,
503                           qualifierName);
504                   }
505                   
506                   void CIMClient::setQualifier(
507 kumpf       1.64      const CIMNamespaceName& nameSpace,
508 kumpf       1.104     const CIMQualifierDecl& qualifierDeclaration)
509 kumpf       1.54  {
510                       _rep->setQualifier(
511                           nameSpace,
512                           qualifierDeclaration);
513                   }
514                   
515                   void CIMClient::deleteQualifier(
516 kumpf       1.64      const CIMNamespaceName& nameSpace,
517 kumpf       1.104     const CIMName& qualifierName)
518 kumpf       1.54  {
519                       _rep->deleteQualifier(
520                           nameSpace,
521                           qualifierName);
522                   }
523                   
524                   Array<CIMQualifierDecl> CIMClient::enumerateQualifiers(
525 kumpf       1.104     const CIMNamespaceName& nameSpace)
526 kumpf       1.54  {
527                       return _rep->enumerateQualifiers(
528                           nameSpace);
529                   }
530                   
531                   CIMValue CIMClient::invokeMethod(
532 kumpf       1.64      const CIMNamespaceName& nameSpace,
533 kumpf       1.56      const CIMObjectPath& instanceName,
534 kumpf       1.64      const CIMName& methodName,
535 kumpf       1.54      const Array<CIMParamValue>& inParameters,
536 kumpf       1.104     Array<CIMParamValue>& outParameters)
537 kumpf       1.54  {
538                       return _rep->invokeMethod(
539                           nameSpace,
540                           instanceName,
541                           methodName,
542                           inParameters,
543                           outParameters);
544 mike        1.27  }
545                   
546 kumpf       1.104 void CIMClient::registerClientOpPerformanceDataHandler(
547                       ClientOpPerformanceDataHandler& handler)
548 w.white     1.101 {
549 kumpf       1.104     _rep->registerClientOpPerformanceDataHandler(handler);
550 w.white     1.101 }
551                   
552                   void CIMClient::deregisterClientOpPerformanceDataHandler()
553                   {
554 kumpf       1.104     _rep->deregisterClientOpPerformanceDataHandler();
555 w.white     1.101 }
556                   
557 mike        1.27  PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2