15 karl 1.1 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
16 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
17 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
18 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
19 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 //
24 //==============================================================================
25 //
26 // Author: Karl Schopmeyer (k.schopmeyer@opengroup.org)
27 //
28 // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company
29 // (carolann_graves@hp.com)
30 // Karl Schopmeyer - Add Cim_Namespace capabilities.
31 // Karl Schopmeyer - Temp added objectmanager and communication classes
32 //
33 //%////////////////////////////////////////////////////////////////////////////
34
35
36 karl 1.1 ///////////////////////////////////////////////////////////////////////////////
37 // Namespace Provider
38 //
39 // This provider answers to the "false" class __namespace. This is the
40 // deprecated version of manipulation in the DMTF WBEM model. This function
41 // is defined in the CIM Operations over HTTP docuement. However, while
42 // the function exists, no class was ever defined in the CIM model for
43 // __nemaspace. Therefore each implementation is free to provide its own
44 // class definition.
45 ///////////////////////////////////////////////////////////////////////////////
46
47 /* STATUS: In process but running 12 August 2003 KS */
48
49 #include <Pegasus/Common/Config.h>
50 #include <Pegasus/Common/PegasusVersion.h>
51
52 #include <cctype>
53 #include <iostream>
54
55 #include "InteropProvider.h"
56 #include <Pegasus/Common/String.h>
57 karl 1.1 #include <Pegasus/Common/System.h>
58 #include <Pegasus/Common/ArrayInternal.h>
59 #include <Pegasus/Common/CIMName.h>
60 #include <Pegasus/Common/CIMType.h>
61 #include <Pegasus/Common/CIMInstance.h>
62 #include <Pegasus/Common/CIMObjectPath.h>
63 #include <Pegasus/Common/InternalException.h>
64 #include <Pegasus/Common/CIMStatusCode.h>
65 #include <Pegasus/Common/Tracer.h>
66 #include <Pegasus/Common/OperationContext.h>
67 #include <Pegasus/Config/ConfigManager.h>
68
69 // ATTN: KS these are in header
70 #include <Pegasus/Repository/CIMRepository.h>
71 #include <Pegasus/Provider/CIMInstanceProvider.h>
72 //#include <Pegasus/Provider/CIMAssociationProvider.h>
73 #include <Pegasus/Common/ResponseHandler.h>
74
75
76 #include <Pegasus/Common/XmlWriter.h>
77
78 karl 1.1 PEGASUS_USING_STD;
79
80 PEGASUS_NAMESPACE_BEGIN
81 #define CDEBUG(X) PEGASUS_STD(cout) << "InteropProvider " << X << PEGASUS_STD(endl)
82 //#define CDEBUG(X)
83 //#define DEBUG(X) Logger::put (Logger::DEBUG_LOG, "Linux_ProcessorProvider", Logger::INFORMATION, "$0", X)
84
85 /**
86 * Specification for CIM Operations over HTTP
87 *
88 * Version 1.0
89 *
90 * 2.5. Namespace Manipulation
91 * There are no intrinsic methods defined specifically for the
92 * purpose of manipulating CIM Namespaces. However, the modelling
93 * of a CIM Namespace using the class __Namespace, together with
94 * the requirement that the root Namespace MUST be supported by
95 * all CIM Servers, implies that all Namespace operations can be
96 * supported.
97 *
98 * For example:
99 karl 1.1 *
100 * Enumeration of all child Namespaces of a particular Namespace
101 * is realized by calling the intrinsic method
102 * EnumerateInstanceNames against the parent Namespace,
103 * specifying a value for the ClassName parameter of __Namespace.
104 *
105 * Creation of a child Namespace is realized by calling the
106 * intrinsic method CreateInstance against the parent Namespace,
107 * specifying a value for the NewInstance parameter which defines
108 * a valid instance of the class __Namespace and whose Name
109 * property is the desired name of the new Namespace.
110 *
111 */
112
113 /**
114 The constants representing the class names we process
115 */
116 static const CIMName __NAMESPACE_CLASSNAME = CIMName ("__Namespace");
117 static const CIMName CIM_NAMESPACE_CLASSNAME = CIMName ("CIM_Namespace");
118 static const CIMName CIM_OBJECTMANAGER_CLASSNAME = CIMName ("CIM_ObjectManager");
119 static const CIMName CIM_OBJECTMANAGERCOMMUNICATIONMECHANISM_CLASSNAME =
120 karl 1.1 CIMName ("CIM_ObjectManagerCommunicationMechanism");
121 static const CIMName CIM_CIMXMLCOMMUNICATIONMECHANISM_CLASSNAME =
122 CIMName ("CIM_CIMXMLCommunicationMechanism");
123
124
125 // Property Names for __Namespace Class
126 static const CIMName NAMESPACE_PROPERTYNAME = CIMName ("Name");
127 static const CIMNamespaceName ROOTNS = CIMNamespaceName ("root");
128
129
130 // Property names for CIM_ObjectManager Class
131 static const CIMName OM_GATHERSTATISTICALDATA =
132 CIMName ("GatherStatisticalData");
133
134
135 // Property Names for ObjectManagerCommunicationMechanism Class
136 static const CIMName OM_COMMUNICATIONMECHANISM =
137 CIMName ("CommunicationMechanism");
138 static const CIMName OM_FUNCTIONALPROFILESSUPPORTED =
139 CIMName ("FunctionalProfilesSupported");
140 static const CIMName OM_FUNCTIONALPROFILEDESCRIPTIONS =
141 karl 1.1 CIMName ("FunctionalProfileDescriptions");
142 static const CIMName OM_AUTHENTICATIONMECHANISMSSUPPORTED =
143 CIMName ("AuthenticationMechanismsSupported");
144 static const CIMName OM_AUTHENTICATIONMECHANISMDESCRIPTIONS =
145 CIMName ("AuthenticationMechanismDescriptions");
146 static const CIMName OM_MULTIPLEOPERATIONSSUPPORTED =
147 CIMName ("MultipleOperationsSupported");
148 static const CIMName OM_VERSION =
149 CIMName ("Version");
150
151 // Property Names for CIMXML CommunicationMechanism
152
153 static const CIMName CIMVALIDATED =
154 CIMName ("CIMValidated");
155
156 static const String CIMXMLProtocolVersion = "1.0";
157
158
159 // Defines to serve as the ENUM for class selection
160 #define __NAMESPACE 1
161 #define CIM_NAMESPACE 2
162 karl 1.1 #define CIM_OBJECTMANAGER 3
163 #define CIM_OBJECTMANAGERCOMMUNICATIONMECHANISM 4
164 #define CIM_CIMXMLCOMMUNICATIONMECHANISM 5
165
166 // Property names for CIM_Namespace Class
167 static const CIMName CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME =
168 CIMName ("SystemCreationClassName");
169 static const CIMName CIM_NAMESPACE_PROPERTY_SYSTEMNAME =
170 CIMName ("SystemName");
171 static const CIMName CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME =
172 CIMName ("ObjectManagerCreationClassName");
173 static const CIMName CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME =
174 CIMName ("ObjectManagerName");
175 static const CIMName CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME =
176 CIMName ("CreationClassName");
177 static const CIMName CIM_NAMESPACE_PROPERTY_NAME = CIMName ("Name");
178 static const CIMName CIM_NAMESPACE_PROPERTY_CLASSINFO =
179 CIMName ("ClassInfo");
180 static const CIMName CIM_NAMESPACE_PROPERTY_DESCRIPTIONOFCLASSINFO =
181 CIMName ("DescriptionOfClassInfo");
182
183 karl 1.1
184 //***************************************************************
185 // Utility Functions
186 //***************************************************************
187
188 /* Test the keys in the CIM_Namespace for valid values
189 This includes all of the keys above the name key.
190 THis is a dummy for now.
191 ATTN: KS Extend and finish this function.
192 */
193 Boolean _testKeys(const CIMObjectPath& path)
194 {
195 return true;
196 }
197 Boolean _testKeys(const CIMInstance& instance)
198 {
199 return true;
200 }
201
202
203 /* Query the repository for array of all namespacenames
204 karl 1.1 */
205 Array<CIMNamespaceName> InteropProvider::_enumerateNameSpaces()
206 {
207 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
208 "InteropProvider::_enumerateNameSpaces()");
209 Array<CIMNamespaceName> namespaceNames;
210 _repository->read_lock();
211
212 try
213 {
214 namespaceNames = _repository->enumerateNameSpaces();
215 }
216 catch(CIMException& e)
217 {
218 _repository->read_unlock();
219 PEG_METHOD_EXIT();
220 throw e;
221 }
222 catch(Exception& e)
223 {
224 _repository->read_unlock();
225 karl 1.1 PEG_METHOD_EXIT();
226 throw e;
227 }
228
229 _repository->read_unlock();
230 PEG_METHOD_EXIT();
231 return(namespaceNames);
232 }
233
234 /* get the CIM_Namespace Class defintion from the repository or
235 from local static storage.
236 @param namespace in which to look for the class.
237 @param name of class to get.
238 @return the CIMClass object
239 @Exceptions any repository exceptions if class not found.
240 */
241 CIMClass InteropProvider::_getClass(const CIMNamespaceName& nameSpace,
242 const CIMName& className)
243 {
244 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
245 "InteropProvider::_getCIM_NamespaceClass()");
246 karl 1.1 CIMClass myClass;
247 CDEBUG("Get Class from repository " << className.getString());
248 if (myClass.isUninitialized())
249 {
250 _repository->read_lock();
251 try
252 {
253 myClass = _repository->getClass(_operationNamespace, className );
254 }
255 catch(CIMException& e)
256 {
257 _repository->read_unlock();
258 PEG_METHOD_EXIT();
259 throw e;
260 }
261 catch(Exception& e)
262 {
263 _repository->read_unlock();
264 PEG_METHOD_EXIT();
265 throw e;
266 }
267 karl 1.1 _repository->read_unlock();
268 }
269 PEG_METHOD_EXIT();
270 return myClass;
271 }
272
273
274 /* Verify that this is one of the legal classnames and
275 return indicator which.
276 @param - Classname
277 @return - Uint32 indicating type
278 @Exceptions - throws CIMNotSupportedException if invalid class.
279 */
280 Uint32 _verifyValidClassInput(const CIMName& className)
281 {
282 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
283 "InteropProvider::_verifyValidClassInput()");
284 // Verify that ClassName == __Namespace or CIM_Namespace
285 // ATTN: KS Check to determine if equal is case independent
286 CDEBUG("Class Name Input = " << className.getString());
287
288 karl 1.1 if (className.equal(__NAMESPACE_CLASSNAME))
289 {
290 PEG_METHOD_EXIT();
291 return __NAMESPACE;
292 }
293
294 if (className.equal(CIM_OBJECTMANAGER_CLASSNAME))
295 {
296 PEG_METHOD_EXIT();
297 return CIM_OBJECTMANAGER;
298 }
299
300 if (className.equal(CIM_OBJECTMANAGERCOMMUNICATIONMECHANISM_CLASSNAME))
301 {
302 PEG_METHOD_EXIT();
303 return CIM_OBJECTMANAGERCOMMUNICATIONMECHANISM;
304 }
305
306 if (className.equal(CIM_CIMXMLCOMMUNICATIONMECHANISM_CLASSNAME))
307 {
308 PEG_METHOD_EXIT();
309 karl 1.1 return CIM_OBJECTMANAGERCOMMUNICATIONMECHANISM;
310 }
311
312 // Last entry, reverse test and returnOK if CIM_Namespace
313 if (!className.equal(CIM_NAMESPACE_CLASSNAME))
314 {
315 PEG_METHOD_EXIT();
316 throw CIMNotSupportedException
317 (className.getString() + " not supported by Interop Provider");
318 }
319
320
321 PEG_METHOD_EXIT();
322 return CIM_NAMESPACE;
323 }
324
325 /* validate the authorization of the user name against the namespace.
326 */
327 String _validateUserID(const OperationContext & context)
328 {
329 //ATTN-DME-P3-20020522: ADD AUTHORIZATION CHECK TO __NAMESPACE PROVIDER
330 karl 1.1 String userName;
331 try
332 {
333 IdentityContainer container = context.get(IdentityContainer::NAME);
334 userName = container.getUserName();
335 }
336 catch (...)
337 {
338 userName = String::EMPTY;
339 }
340 return userName;
341 }
342
343 /* Create an instance of the CIM_Namespace class which is based
344 on the following CIM MOF Specification
345 [Version ("2.6.0"), Description (
346 "Namespace provides a domain (in other words, a container), "
347 "in which the instances [of a class] are guaranteed to be "
348 "unique per the KEY qualifier definitions. It is named "
349 "relative to the CIM_ObjectManager implementation that "
350 "provides such a domain.") ]
351 karl 1.1 class CIM_Namespace : CIM_ManagedElement {
352
353 [Propagated("CIM_ObjectManager.SystemCreationClassName"), Key,
354 MaxLen (256), Description (
355 "The scoping System's CreationClassName.") ]
356 string SystemCreationClassName;
357
358 [Propagated("CIM_ObjectManager.SystemName"), Key, MaxLen (256),
359 Description ("The scoping System's Name.") ]
360 string SystemName;
361
362 [Propagated ("CIM_ObjectManager.CreationClassName"), Key,
363 MaxLen (256), Description (
364 "The scoping ObjectManager's CreationClassName.") ]
365 string ObjectManagerCreationClassName;
366
367 [Propagated ("CIM_ObjectManager.Name"), Key, MaxLen (256),
368 Description ("The scoping ObjectManager's Name.") ]
369 string ObjectManagerName;
370
371 [Key, MaxLen (256), Description (
372 karl 1.1 "CreationClassName indicates the name of the class or the "
373 "subclass used in the creation of an instance. When used "
374 "with the other key properties of this class, this property "
375 "allows all instances of this class and its subclasses to "
376 "be uniquely identified.") ]
377 string CreationClassName;
378
379 [Key, MaxLen (256), Description (
380 "A string to uniquely identify the Namespace within "
381 "the ObjectManager.") ]
382 string Name;
383
384 [Required, Write, Description (
385 "Enumeration indicating the organization/schema of the "
386 "Namespace's objects. For example, they may be instances "
387 "of classes of a specific CIM version."),
388 ValueMap {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
389 "10", "200", "201", "202"},
390 Values {"Unknown", "Other", "CIM 1.0", "CIM 2.0",
391 "CIM 2.1", "CIM 2.2", "CIM 2.3", "CIM 2.4", "CIM 2.5",
392 "CIM 2.6", "CIM 2.7", "DMI Recast", "SNMP Recast",
393 karl 1.1 "CMIP Recast"},
394 ModelCorrespondence {"CIM_Namespace.DescriptionOfClassInfo"} ]
395 uint16 ClassInfo;
396
397 [Write, Description (
398 "A string providing more detail (beyond the general "
399 "classification in ClassInfo) for the object hierarchy of "
400 "the Namespace."),
401 ModelCorrespondence {"CIM_Namespace.ClassInfo"} ]
402 string DescriptionOfClassInfo;
403 };
404
405 */
406 void _buildInstanceCommonKeys(CIMInstance& instance)
407 {
408
409 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
410 "InteropProvider::_buildInstanceCommonKeys()");
411 String SystemCreationClassName = System::getSystemCreationClassName ();
412 if (SystemCreationClassName == String::EMPTY)
413 {
414 karl 1.1 SystemCreationClassName = "CIM_ComputerSystem";
415 }
416
417 String SystemName = System::getHostName();
418
419 instance.addProperty(
420 (CIMProperty(CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME,
421 SystemCreationClassName)));
422 // SystemName
423 instance.addProperty(
424 (CIMProperty(CIM_NAMESPACE_PROPERTY_SYSTEMNAME,
425 SystemName)));
426 PEG_METHOD_EXIT();
427 }
428
429 CIMInstance _buildInstancCIMXMLCommunicationMechanism()
430 {
431 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
432 "InteropProvider::_buildInstanceCIMXMLCommunicationMechanism()");
433
434 CIMInstance instance(CIM_OBJECTMANAGERCOMMUNICATIONMECHANISM_CLASSNAME);
435 karl 1.1
436 _buildInstanceCommonKeys(instance);
437
438 //CreationClassName
439 instance.addProperty(
440 (CIMProperty(CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME,
441 CIM_OBJECTMANAGERCOMMUNICATIONMECHANISM_CLASSNAME.getString() )));
442
443 String name = "PegasusCommunicationMechanism";
444
445 //Name, this CommunicationMechanism.
446 instance.addProperty(
447 (CIMProperty(CIM_NAMESPACE_PROPERTY_NAME,
448 name )));
449
450 // CommunicationMechanism Property
451 instance.addProperty(
452 (CIMProperty(OM_COMMUNICATIONMECHANISM,
453 Uint16(2) )));
454
455 // CommunicationMechanism Property
456 karl 1.1 instance.addProperty(
457 (CIMProperty(OM_COMMUNICATIONMECHANISM,
458 Uint16(2) )));
459
460 PEG_METHOD_EXIT();
461 return(instance);
462 }
463
464
465 CIMInstance _buildInstancCIMObjectCommunicationMechanism()
466 {
467 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
468 "InteropProvider::_buildInstanceCIMObjectCommunicationMechanism()");
469
470 CIMInstance instance(CIM_CIMXMLCOMMUNICATIONMECHANISM_CLASSNAME);
471
472 _buildInstanceCommonKeys(instance);
473
474
475 //CreationClassName
476 instance.addProperty(
477 karl 1.1 (CIMProperty(CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME,
478 CIM_OBJECTMANAGERCOMMUNICATIONMECHANISM_CLASSNAME.getString() )));
479
480 String name = "PegasusCommunicationMechanism";
481 //Name, this CommunicationMechanism.
482 instance.addProperty(
483 (CIMProperty(CIM_NAMESPACE_PROPERTY_NAME,
484 name )));
485
486 // CommunicationMechanism Property
487 instance.addProperty(
488 (CIMProperty(OM_COMMUNICATIONMECHANISM,
489 Uint16(2) )));
490
491 //Functional Profiles Supported Property.
492 Array<Uint16> profiles;
493 Array<String> profileDescriptions;
494 CIMValue profileValue(profiles);
495 CIMValue profileDescriptionsValue(profileDescriptions);
496
497 profiles.append(2); profileDescriptions.append("Basic Read");
498 karl 1.1 profiles.append(3); profileDescriptions.append("Basic Write");
499 profiles.append(4); profileDescriptions.append("Schema Manipulation");
500 profiles.append(5); profileDescriptions.append("Instance Manipulation");
501 profiles.append(6); profileDescriptions.append("Association Traversal");
502 profiles.append(8); profileDescriptions.append("Qualifier Declaration");
503 profiles.append(9); profileDescriptions.append("Indications");
504
505 instance.addProperty(
506 (CIMProperty(OM_FUNCTIONALPROFILESSUPPORTED,
507 profileValue )));
508 instance.addProperty(
509 (CIMProperty(OM_FUNCTIONALPROFILEDESCRIPTIONS,
510 profileDescriptionsValue )));
511
512 // Multiple OperationsSupported Property
513 instance.addProperty(
514 (CIMProperty(OM_MULTIPLEOPERATIONSSUPPORTED,
515 Boolean(false) )));
516 // AuthenticationMechanismsSupported
517
518 Array<Uint16> authentications;
519 karl 1.1 Array<String> authenticationDescriptions;
520 CIMValue authenticationValue(authentications);
521 CIMValue authenticationDescriptionsValue(authenticationDescriptions);
522 profiles.append(3); profileDescriptions.append("Basic");
523
524 instance.addProperty(
525 (CIMProperty(OM_AUTHENTICATIONMECHANISMSSUPPORTED,
526 authenticationValue )));
527 instance.addProperty(
528 (CIMProperty(OM_AUTHENTICATIONMECHANISMDESCRIPTIONS,
529 authenticationDescriptionsValue )));
530
531 //Version property
532 instance.addProperty(
533 (CIMProperty(OM_VERSION,
534 CIMXMLProtocolVersion )));
535
536 PEG_METHOD_EXIT();
537 return(instance);
538 }
539
540 karl 1.1 String _getObjectManagerName()
541 {
542 return ("PEG_123456789");
543 }
544
545 CIMInstance _buildInstanceCIMObjectManager()
546 {
547 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
548 "InteropProvider::_buildInstanceCIMObjectManager()");
549
550 CIMInstance instance(CIM_OBJECTMANAGER_CLASSNAME);
551
552 _buildInstanceCommonKeys(instance);
553
554 //CreationClassName
555 instance.addProperty(
556 (CIMProperty(CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME,
557 CIM_OBJECTMANAGER_CLASSNAME.getString() )));
558 //Name, this CIMObject Manager.
559 instance.addProperty(
560 (CIMProperty(CIM_NAMESPACE_PROPERTY_NAME,
561 karl 1.1 _getObjectManagerName() )));
562
563 //Property GatherStatisticalData. Note that today we do not
564 // have a dynamic activation for this value.
565
566 #ifdef PEGASUS_HAS_PERFINST
567 Boolean gatherStatData = true;
568 #else
569 Boolean gatherStatData = false;
570 #endif
571 instance.addProperty(
572 (CIMProperty(OM_GATHERSTATISTICALDATA,
|
574 karl 1.1 PEG_METHOD_EXIT();
575 return(instance);
576 }
577
578 /* generate one instance of the CIM_Namespace class with the
579 properties
580 @param namespace name to put into the class
581 @exceptions - exceptions carried forward from create instance
582 and addProperty.
583 */
584 CIMInstance _buildInstanceCIMNamespace(const CIMNamespaceName & nameSpace)
585 {
586 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
587 "InteropProvider::_buildInstanceCIMNamespace()");
588 // Values for test
589 //String SystemCreationClassName = "creationclassname";
590 //String SystemName = "SystemNameValue";
591 String ObjectManagerName = "ObjectManagerNameValue";
592 String ClassInfo = "ClassInfo";
593 String DescriptionOfClassInfo = "DescriptionOfClassInfo";
594
595 karl 1.1 CIMInstance instance(CIM_NAMESPACE_CLASSNAME);
596
597 /* The following moved to common create
598 // Add the properties
599 // SystemCreationClassName
600 instance.addProperty(
601 (CIMProperty(CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME,
602 SystemCreationClassName)));
603 // SystemName
604 instance.addProperty(
605 (CIMProperty(CIM_NAMESPACE_PROPERTY_SYSTEMNAME,
606 SystemName)));
607 */
608 _buildInstanceCommonKeys(instance);
609
610 //ObjectManagerCreationClassName
611 instance.addProperty(
612 (CIMProperty(CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME,
613 CIM_OBJECTMANAGER_CLASSNAME.getString())));
614 //ObjectManagerName
615 // This is the one we have to sort out ATTN: TBD KS P0
616 karl 1.1 instance.addProperty(
617 (CIMProperty(CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME,
618 ObjectManagerName)));
619 //CreationClassName
620 instance.addProperty(
621 (CIMProperty(CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME,
622 CIM_NAMESPACE_CLASSNAME.getString() )));
623 //Name
624 instance.addProperty(
625 (CIMProperty(CIM_NAMESPACE_PROPERTY_NAME,
626 nameSpace.getString() )));
627
628 //ClassInfo
629 instance.addProperty(
630 (CIMProperty(CIM_NAMESPACE_PROPERTY_CLASSINFO,
631 ClassInfo)));
632
633 //DescriptionofClassInfo
634 instance.addProperty(
635 (CIMProperty(CIM_NAMESPACE_PROPERTY_DESCRIPTIONOFCLASSINFO,
636 DescriptionOfClassInfo)));
637 karl 1.1 PEG_METHOD_EXIT();
638 return(instance);
639 }
640 /* given a namespace name, class and instance build the instance path for a
641 the object. This builds all components of the path
642 @param namespace name to build
643 @return CIMObjectPath containing namespace, class and keybinding
644 components of path
645 @exceptions - TBD
646 */
647 // ATTN: KS Build path from instance and instance from class. Not sure
648 // we want to always do this. Consider change to build keys directly
649
650 CIMObjectPath InteropProvider::_buildInstancePath(const CIMNamespaceName& name,
651 const CIMName className,
652 const CIMInstance& instance)
653 {
654 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
655 "InteropProvider::_buildInstancePath()");
656
657 // get the class CIM_Namespace class to use in building path
658 karl 1.1 //CIMNamespaceName thisNamespace = classReference.getNameSpace();
659 CIMClass thisClass = _getClass(_operationNamespace, className);
660
661 // XmlWriter::printInstanceElement(instance);
662
663 CIMObjectPath ref = instance.buildPath(thisClass);
664
665 CDEBUG("Built path. path = " << ref.toString() );
666 PEG_METHOD_EXIT();
667 return(ref);
668 }
669
670
671 /* _isNamespace determines if the namespace in the second
672 parameter is in the array in the first parameter.
673 @param array of possible namespaces
674 @param canidate namespace
675 @return - true if found
676 */
677 Boolean _isNamespace(
678 Array<CIMNamespaceName>& namespaceNames,
679 karl 1.1 CIMNamespaceName& namespaceName)
680
681 {
682 Boolean found = false;
683 for(Uint32 i = 0; i < namespaceNames.size(); i++)
684 {
685 if(namespaceNames[i].equal ( namespaceName))
686 {
687 return true;
688 }
689 }
690 return false;
691 }
692
693 Boolean _isChild(
694 CIMNamespaceName& parentNamespaceName,
695 CIMNamespaceName& namespaceName)
696
697 {
698 String parent = parentNamespaceName.getString();
699 String child = namespaceName.getString();
700 karl 1.1 //
701 // If length of namespace name is shorter than or equal to the
702 // length of parent namespace name, cannot be a child
703 //
704 if (child.size () <= parent.size ())
705 {
706 return false;
707 }
708
709 //
710 // Compare prefix substring of namespace name with parent namespace name
711 //
712 else if (String::equalNoCase (child.subString (0, parent.size ()), parent))
713 {
714 return true;
715 }
716 return false;
717 }
718 //**************************************************************
719 // Overloaded functions to get key value with different params
720 //**************************************************************
721 karl 1.1
722 /* find the name key in the keybindings and return the value.
723 Executes exception if the key not found
724 @param object path we will search
725 @param keyName - Name of the key to find.
726 @return value of name property
727 @exceptions CIMInvalidParameterException
728 */
729 String _getKeyValue(const CIMObjectPath& instanceName, const CIMName& keyName)
730 {
731 Array<CIMKeyBinding> kbArray = instanceName.getKeyBindings();
732
733 // find the correct key binding
734 for (Uint32 i = 0; i < kbArray.size(); i++)
735 {
736 if (kbArray[i].getName() == keyName)
737 {
738 return (kbArray[i].getValue());
739 }
740 }
741 throw CIMInvalidParameterException("Invalid key property: " + keyName.getString());
742 karl 1.1 }
743
744 String _getKeyValue(const CIMInstance& instance, const CIMName& keyName)
745 {
746 Uint32 pos;
747 CIMValue propertyValue;
748
749 pos = instance.findProperty(keyName);
750 if (pos == PEG_NOT_FOUND)
751 {
752 throw CIMPropertyNotFoundException
753 (NAMESPACE_PROPERTYNAME.getString());
754 }
755
756 propertyValue = instance.getProperty(pos).getValue();
757 if (propertyValue.getType() != CIMTYPE_STRING)
758 {
759 throw CIMInvalidParameterException("Invalid type for property: "
760 + NAMESPACE_PROPERTYNAME.getString());
761 }
762 String name;
763 karl 1.1 propertyValue.get(name);
764 return(name);
765 //ATTN: KS Returns String whereas below returns CIMNamespaceName.
766 }
767
768 /* gets the key value for the __Namespace property "name"
769 from the instance provided. Sets childNamespaceName and
770 isRelativeName fields
771 This overload called if instance provided.
772 */
773 void _getKeyValue (
774 const CIMInstance& namespaceInstance,
775 CIMNamespaceName& childNamespaceName,
776 Boolean& isRelativeName)
777
778 {
779 //Validate key property
780
781 Uint32 pos;
782 CIMValue propertyValue;
783
784 karl 1.1 // [Key, MaxLen (256), Description (
785 // "A string that uniquely identifies the Namespace "
786 // "within the ObjectManager.") ]
787 // string Name;
788
789 pos = namespaceInstance.findProperty(NAMESPACE_PROPERTYNAME);
790 if (pos == PEG_NOT_FOUND)
791 {
792 throw CIMPropertyNotFoundException
793 (NAMESPACE_PROPERTYNAME.getString());
794 }
795
796 propertyValue = namespaceInstance.getProperty(pos).getValue();
797 if (propertyValue.getType() != CIMTYPE_STRING)
798 {
799 throw CIMInvalidParameterException("Invalid type for property: "
800 + NAMESPACE_PROPERTYNAME.getString());
801 }
802
803 String cnsName;
804 propertyValue.get(cnsName);
805 karl 1.1 childNamespaceName = CIMNamespaceName (cnsName);
806
807 isRelativeName = !(childNamespaceName.isNull());
808
809 }
810 /* gets the key value for the __Namespace property "name"
811 from the instance provided. Sets childNamespaceName and
812 isRelativeName fields
813 This overload called if object path provided.
814 */
815
816 void _getKeyValue (
817 const CIMObjectPath& instanceName,
818 CIMNamespaceName& childNamespaceName,
819 Boolean& isRelativeName)
820 {
821
822 Array<CIMKeyBinding> kbArray = instanceName.getKeyBindings();
823 if ((kbArray.size() == 1) &&
824 (kbArray[0].getName() == NAMESPACE_PROPERTYNAME))
825 {
826 karl 1.1 childNamespaceName = CIMNamespaceName (kbArray[0].getValue());
827 isRelativeName = !(childNamespaceName.isNull());
828 }
829 else
830 {
831 throw CIMInvalidParameterException("Invalid key property: ");
832 }
833 }
834
835 /* generate the full namespace name from the parent and child
836 components
837 @param namespaceNames - List of all namespaces
838 @param parentNamespaceName
839 @param childNamespaceName
840 @param Boolean isrelative
841 @return full namespacename created from parent + child
842 Note that if isrelative is true, parent is tested for validty
843 */
844 CIMNamespaceName _generateFullNamespaceName(
845 Array<CIMNamespaceName>& namespaceNames,
846 CIMNamespaceName& parentNamespaceName,
847 karl 1.1 CIMNamespaceName& childNamespaceName,
848 Boolean isRelativeName)
849
850 {
851 // If isRelativeName is true, then the parentNamespace
852 // MUST exist
853 //
854 CIMNamespaceName fullNamespaceName;
855
856 if (isRelativeName)
857 {
858 if (!_isNamespace(namespaceNames, parentNamespaceName))
859 {
860 throw CIMObjectNotFoundException("Parent namespace does not exist: "
861 + parentNamespaceName.getString());
862 }
863 // Create full namespace name by prepending parentNamespaceName
864 fullNamespaceName = CIMNamespaceName (parentNamespaceName.getString()
865 + "/" + childNamespaceName.getString());
866 }
867 else
868 karl 1.1 {
869 fullNamespaceName = parentNamespaceName;
870 }
871 return(fullNamespaceName);
872
873 }
874
875 //***************************************************************************
876 // The following section is the Instance Operation processors
877 //***************************************************************************
878 // createInstance
879 //***************************************************************************
880 void InteropProvider::createInstance(
881 const OperationContext & context,
882 const CIMObjectPath & instanceReference,
883 const CIMInstance& myInstance,
884 ObjectPathResponseHandler & handler)
885 {
886 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::createInstance()");
887
888 CIMNamespaceName childNamespaceName;
889 karl 1.1 CIMNamespaceName newNamespaceName;
890 Boolean isRelativeName;
891 CDEBUG("CreateInstance " << instanceReference.toString());
892 // operation namespace needed internally to get class.
893 _operationNamespace = instanceReference.getNameSpace();
894
895 // Verify that ClassName is correct and get value
896 Uint32 classEnum = _verifyValidClassInput(instanceReference.getClassName());
897
898 String userName = _validateUserID(context);
899 CIMObjectPath newInstanceReference;
900
901 if (classEnum == CIM_OBJECTMANAGERCOMMUNICATIONMECHANISM)
902 throw CIMNotSupportedException("InteropProvider::createInstance");
903
904 if (classEnum == CIM_CIMXMLCOMMUNICATIONMECHANISM)
905 throw CIMNotSupportedException("InteropProvider::createInstance");
906
907 if (classEnum == CIM_NAMESPACE)
908 {
909 CDEBUG("Create Class from CIM_Namespace");
910 karl 1.1 Boolean isGood = _testKeys(instanceReference);
911 String namespaceName;
912 newNamespaceName = _getKeyValue(myInstance, CIM_NAMESPACE_PROPERTY_NAME);
913 // ATTN: KS TBD
914 //Array<CIMKeyBinding> keyBindings;
915 //keyBindings = _buildKeyBindings();
916 //newInstanceReference.set(String::EMPTY, namespaceName,
917 // CIM_NAMESPACE_CLASSNAME, keyBindings);
918 //CDEBUG("Create namespace = " << newNamespaceName);
919 CIMInstance instance = _buildInstanceCIMNamespace(namespaceName);
920 newInstanceReference = _buildInstancePath(CIMNamespaceName(namespaceName),
921 CIM_NAMESPACE_CLASSNAME, instance);
922 }
923 else // Process the __Namespace request to get namespace name value
924 {
925 _getKeyValue(myInstance, childNamespaceName, isRelativeName);
926 CIMNamespaceName parentNamespaceName = instanceReference.getNameSpace();
927
928 PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4,
929 "childNamespaceName = " + childNamespaceName.getString() +
930 ", isRelativeName = " +
931 karl 1.1 (isRelativeName?String("true"):String("false")) +
932 ", parentNamespaceName = " + parentNamespaceName.getString());
933
934 Array<CIMNamespaceName> namespaceNames;
935 namespaceNames = _enumerateNameSpaces();
936
937 newNamespaceName = _generateFullNamespaceName(
938 namespaceNames, parentNamespaceName,
939 childNamespaceName, isRelativeName);
940
941 // return key (i.e., CIMObjectPath) for newly created namespace
942
943 Array<CIMKeyBinding> keyBindings;
944 keyBindings.append(CIMKeyBinding(NAMESPACE_PROPERTYNAME,
945 isRelativeName?childNamespaceName.getString():
946 parentNamespaceName.getString(),
947 CIMKeyBinding::STRING));
948 //Add namespace class and keybindings
949 newInstanceReference.set(String::EMPTY, parentNamespaceName,
950 __NAMESPACE_CLASSNAME, keyBindings);
951 }
952 karl 1.1 // Create the new namespace
953 try
954 {
955 _repository->createNameSpace(newNamespaceName);
956
957 PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4,
958 "Namespace = " + newNamespaceName.getString() +
959 " successfully created.");
960 // ATTN: Add standardlog entry here.
961 }
962 catch(CIMException& e)
963 {
964 _repository->write_unlock();
965 PEG_METHOD_EXIT();
966 throw e;
967 }
968 catch(Exception& e)
969 {
970 _repository->write_unlock();
971 PEG_METHOD_EXIT();
972 throw e;
973 karl 1.1 }
974
975 _repository->write_unlock();
976
977 // begin processing the request
978 handler.processing();
979
980
981 handler.deliver(newInstanceReference);
982
983 // complete processing the request
984 handler.complete();
985
986 PEG_METHOD_EXIT();
987 return;
988 }
989
990 //***************************************************************************
991 // deleteInstance
992 //***************************************************************************
993 void InteropProvider::deleteInstance(
994 karl 1.1 const OperationContext & context,
995 const CIMObjectPath & instanceName,
996 ResponseHandler & handler)
997 {
998 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::deleteInstance");
999 CDEBUG("deleteInstance" << instanceName.toString());
1000 CIMNamespaceName childNamespaceName;
1001 CIMNamespaceName deleteNamespaceName;
1002 Boolean isRelativeName;
1003
1004 // Verify that ClassName is correct and get value
1005 Uint32 classEnum = _verifyValidClassInput(instanceName.getClassName());
1006
1007 String userName = _validateUserID(context);
1008
1009 Array<CIMNamespaceName> namespaceNames;
1010 namespaceNames = _enumerateNameSpaces();
1011
1012 if (classEnum == CIM_OBJECTMANAGERCOMMUNICATIONMECHANISM)
1013 throw CIMNotSupportedException("InteropProvider::createInstance");
1014
1015 karl 1.1 if (classEnum == CIM_CIMXMLCOMMUNICATIONMECHANISM)
1016 throw CIMNotSupportedException("InteropProvider::createInstance");
1017
1018 if (classEnum == CIM_NAMESPACE)
1019 {
1020 _testKeys(instanceName);
1021 deleteNamespaceName = _getKeyValue(instanceName, CIM_NAMESPACE_PROPERTY_NAME);
1022 CDEBUG("Delete namespace = " << deleteNamespaceName );
1023 }
1024 else // Procesing for __namespace
1025 {
1026
1027 _getKeyValue(instanceName, childNamespaceName, isRelativeName);
1028 CIMNamespaceName parentNamespaceName = instanceName.getNameSpace();
1029
1030 PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4,
1031 "childNamespaceName = " + childNamespaceName.getString() +
1032 (isRelativeName?String("true"):String("false")) +
1033 ", parentNamespaceName = " + parentNamespaceName.getString());
1034
1035 // begin processing the request
1036 karl 1.1
1037 deleteNamespaceName = _generateFullNamespaceName(
1038 namespaceNames, parentNamespaceName,
1039 childNamespaceName, isRelativeName);
1040 }
1041
1042 // ATTN: KS Why THis???
1043 if (deleteNamespaceName.equal (ROOTNS))
1044 {
1045 throw CIMNotSupportedException("root namespace cannot be deleted.");
1046 }
1047
1048 _repository->deleteNameSpace(deleteNamespaceName);
1049
1050 PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4,
1051 "Namespace = " + deleteNamespaceName.getString() +
1052 " successfully deleted.");
1053 // ATTN: Log entry for deletion.
1054 handler.processing();
1055
1056 // complete processing the request
1057 karl 1.1 handler.complete();
1058
1059 PEG_METHOD_EXIT();
1060 return ;
1061 }
1062
1063 //***************************************************************************
1064 // getInstance
1065 //***************************************************************************
1066 void InteropProvider::getInstance(
1067 const OperationContext & context,
1068 const CIMObjectPath & instanceName,
1069 const Boolean includeQualifiers,
1070 const Boolean includeClassOrigin,
1071 const CIMPropertyList & properatyList,
1072 InstanceResponseHandler & handler)
1073 {
1074 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::getInstance");
1075
1076 // Verify that ClassName is correct and get value
1077 Uint32 classEnum = _verifyValidClassInput(instanceName.getClassName());
1078 karl 1.1
1079 String userName = _validateUserID(context);
1080
1081 // begin processing the request
1082 handler.processing();
1083 if (classEnum == CIM_OBJECTMANAGER)
1084 {
1085 CIMInstance instance = _buildInstanceCIMObjectManager();
1086 handler.deliver(instance);
1087 handler.complete();
1088 PEG_METHOD_EXIT();
1089 return;
1090 }
1091
1092 if (classEnum == CIM_OBJECTMANAGERCOMMUNICATIONMECHANISM)
1093 {
1094 CIMInstance instance = _buildInstancCIMObjectCommunicationMechanism();
1095 handler.deliver(instance);
1096 handler.complete();
1097 PEG_METHOD_EXIT();
1098 return;
1099 karl 1.1 }
1100
1101
1102 if (classEnum == CIM_CIMXMLCOMMUNICATIONMECHANISM)
1103 {
1104 CIMInstance instance = _buildInstancCIMXMLCommunicationMechanism();
1105 handler.deliver(instance);
1106 handler.complete();
1107 PEG_METHOD_EXIT();
1108 return;
1109
1110 }
1111
1112 // Get List of namespaces
1113 Array<CIMNamespaceName> namespaceNames;
1114 namespaceNames = _enumerateNameSpaces();
1115 CIMInstance instance;
1116
1117
1118 if (classEnum == CIM_NAMESPACE)
1119 {
1120 karl 1.1 // Not clear what we have to take into account here.
1121 // get the namespace from the name value.
1122 // should check the other keys to see if valid.
1123 CIMNamespaceName namespaceName;
1124 namespaceName = _getKeyValue(instanceName, CIM_NAMESPACE_PROPERTY_NAME);
1125 // ATTN: Why this CIMNamespaceName parentNamespaceName = instanceName.getNameSpace();
1126
1127 if (!_isNamespace(namespaceNames, namespaceName))
1128 {
1129 throw CIMObjectNotFoundException("Namespace does not exist: "
1130 + namespaceName.getString());
1131 }
1132 PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4,
1133 "Namespace = " + namespaceName.getString() + " successfully found.");
1134 instance = _buildInstanceCIMNamespace(namespaceName);
1135 }
1136 else // processing for __Namespace
1137 {
1138 CIMNamespaceName childNamespaceName;
1139 CIMNamespaceName getNamespaceName;
1140 Boolean isRelativeName;
1141 karl 1.1
1142 _getKeyValue(instanceName, childNamespaceName, isRelativeName);
1143 CIMNamespaceName parentNamespaceName = instanceName.getNameSpace();
1144
1145 PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4,
1146 "childNamespaceName = " + childNamespaceName.getString() +
1147 (isRelativeName?String("true"):String("false")) +
1148 ", parentNamespaceName = " + parentNamespaceName.getString());
1149
1150
1151 getNamespaceName = _generateFullNamespaceName(
1152 namespaceNames, parentNamespaceName,
1153 childNamespaceName, isRelativeName);
1154
1155 // exception if not valid namespace
1156 if (!_isNamespace(namespaceNames, getNamespaceName))
1157 {
1158 throw CIMObjectNotFoundException("Namespace deos not exist: "
1159 + getNamespaceName.getString());
1160 }
1161 PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4,
1162 karl 1.1 "Namespace = " + getNamespaceName.getString() +
1163 " successfully found.");
1164
1165 //Set name of class
1166 CIMInstance instance(__NAMESPACE_CLASSNAME);
1167
1168 //
1169 // construct the instance
1170 //
1171 instance.addProperty(CIMProperty(NAMESPACE_PROPERTYNAME,
1172 isRelativeName?childNamespaceName.getString():
1173 parentNamespaceName.getString()));
1174 //instance.setPath(instanceName);
1175 }
1176
1177 handler.deliver(instance);
1178
1179 // complete processing the request
1180 handler.complete();
1181
1182 PEG_METHOD_EXIT();
1183 karl 1.1 return ;
1184 }
1185
1186 //***************************************************************************
1187 // enumerateInstances
1188 //***************************************************************************
1189 void InteropProvider::enumerateInstances(
1190 const OperationContext & context,
1191 const CIMObjectPath & ref,
1192 const Boolean includeQualifiers,
1193 const Boolean includeClassOrigin,
1194 const CIMPropertyList& propertyList,
1195 InstanceResponseHandler & handler)
1196 {
1197 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::enumerateInstances()");
1198 CDEBUG("EnumerateInstances");
1199 // Verify that ClassName is correct and get value
1200 Uint32 classEnum = _verifyValidClassInput(ref.getClassName());
1201
1202 String userName = _validateUserID(context);
1203
1204 karl 1.1 // The following 3 classes deliver a single instance because
1205 // that is all there is today.
1206 if (classEnum == CIM_OBJECTMANAGER)
1207 {
1208 CIMInstance instance = _buildInstanceCIMObjectManager();
1209 handler.deliver(instance);
1210 handler.complete();
1211 PEG_METHOD_EXIT();
1212 return;
1213 }
1214
1215 if (classEnum == CIM_OBJECTMANAGERCOMMUNICATIONMECHANISM)
1216 {
1217 CIMInstance instance = _buildInstancCIMObjectCommunicationMechanism();
1218 handler.deliver(instance);
1219 handler.complete();
1220 PEG_METHOD_EXIT();
1221 return;
1222 }
1223
1224
1225 karl 1.1 if (classEnum == CIM_CIMXMLCOMMUNICATIONMECHANISM)
1226 {
1227 CIMInstance instance = _buildInstancCIMXMLCommunicationMechanism();
1228 handler.deliver(instance);
1229 handler.complete();
1230 PEG_METHOD_EXIT();
1231 return;
1232
1233 }
1234
1235 // ATTN: Fix this up. should not be here.
1236 CIMNamespaceName parentNamespaceName = ref.getNameSpace();
1237
1238 // ATTN KS Fix this so references both types of namespace
1239 PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4,
1240 "parentNamespaceName = " + parentNamespaceName.getString());
1241
1242 // begin processing the request
1243 handler.processing();
1244
1245 Array<CIMNamespaceName> namespaceNames = _enumerateNameSpaces();
1246 karl 1.1
1247 Array<CIMInstance> instanceArray;
1248 CDEBUG("Found " << namespaceNames.size() << " namespaces.");
1249 // Build response objects based on class requested
1250 for (Uint32 i = 0; i < namespaceNames.size(); i++)
1251 {
1252 CDEBUG("For namespace' " << namespaceNames[i].getString());
1253 CDEBUG("Evaluate ClassEnum" << classEnum);
1254 if (classEnum == CIM_NAMESPACE)
1255 {
1256 CDEBUG("Evaluate CIM_Namespace" << classEnum);
1257 // Create a valid CIM_Namespace Instance
1258 CIMInstance instance = _buildInstanceCIMNamespace(namespaceNames[i]);
1259 instanceArray.append(instance);
1260
1261 PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4,
1262 "Namespace = " + namespaceNames[i].getString());
1263
1264 }
1265 else // the else covers __NAMESPACE
1266 {
1267 karl 1.1 // Build the instances. For now simply build the __Namespace instances
1268 // the only property is name.
1269 if (_isChild(parentNamespaceName, namespaceNames[i]))
1270 {
1271 CIMInstance instance(__NAMESPACE_CLASSNAME);
1272 instance.addProperty(
1273 (CIMProperty(NAMESPACE_PROPERTYNAME,
1274 namespaceNames[i].getString().subString
1275 (parentNamespaceName.getString().size()+1,
1276 namespaceNames[i].getString().size()-
1277 parentNamespaceName.getString().size()-1))));
1278
1279 instanceArray.append(instance);
1280
1281 //instance.setPath(instanceName);
1282 PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4,
1283 "childNamespace = " + namespaceNames[i].getString());
1284 }
1285 }
1286 }
1287 handler.deliver(instanceArray);
1288 karl 1.1
1289 // complete processing the request
1290 handler.complete();
1291
1292 PEG_METHOD_EXIT();
1293 }
1294
1295 //***************************************************************************
1296 // enumerateInstanceNames
1297 //***************************************************************************
1298
1299 void InteropProvider::enumerateInstanceNames(
1300 const OperationContext & context,
1301 const CIMObjectPath & classReference,
1302 ObjectPathResponseHandler & handler)
1303 {
1304 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
1305 "InteropProvider::enumerateInstanceNames()");
1306
1307 // operation namespace needed internally to get class.
1308 _operationNamespace = classReference.getNameSpace();
1309 karl 1.1
1310 Uint32 classEnum = _verifyValidClassInput(classReference.getClassName());
1311
1312 // begin processing the request
1313 handler.processing();
1314
1315 // The following 3 classes deliver a single instance because
1316 // that is all there is today.
1317 if (classEnum == CIM_OBJECTMANAGER)
1318 {
1319 CIMInstance instance = _buildInstanceCIMObjectManager();
1320 CIMObjectPath ref = _buildInstancePath(CIMNamespaceName(),
1321 CIM_OBJECTMANAGER_CLASSNAME, instance);
1322 handler.deliver(ref);
1323 handler.complete();
1324 PEG_METHOD_EXIT();
1325 return;
1326 }
1327
1328 if (classEnum == CIM_OBJECTMANAGERCOMMUNICATIONMECHANISM)
1329 {
1330 karl 1.1 CIMInstance instance = _buildInstancCIMObjectCommunicationMechanism();
1331 CIMObjectPath ref = _buildInstancePath(CIMNamespaceName(),
1332 CIM_OBJECTMANAGERCOMMUNICATIONMECHANISM_CLASSNAME, instance);
1333 handler.deliver(ref);
1334 handler.complete();
1335 PEG_METHOD_EXIT();
1336 return;
1337 }
1338
1339
1340 if (classEnum == CIM_CIMXMLCOMMUNICATIONMECHANISM)
1341 {
1342 CIMInstance instance = _buildInstancCIMXMLCommunicationMechanism();
1343 CIMObjectPath ref = _buildInstancePath(CIMNamespaceName(),
1344 CIM_CIMXMLCOMMUNICATIONMECHANISM_CLASSNAME, instance);
1345 handler.deliver(ref);
1346 handler.complete();
1347 PEG_METHOD_EXIT();
1348 return;
1349
1350 }
1351 karl 1.1
1352 String userName = _validateUserID(context);
1353
1354 // ATTN: Move this trace
1355 CIMNamespaceName parentNamespaceName = classReference.getNameSpace();
1356 PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4,
1357 "parentNamespaceName = " + parentNamespaceName.getString());
1358 CDEBUG("Enumerate Instance Names. ns = " << parentNamespaceName.getString());
1359
1360 // Get list of all namespaces
1361 Array<CIMNamespaceName> namespaceNames = _enumerateNameSpaces();
1362 CDEBUG("Found " << namespaceNames.size() << " namespaces.");
1363
1364 // Build the cimObjectPath for each namespace found
1365 for (Uint32 i = 0; i < namespaceNames.size(); i++)
1366 {
1367 if (classEnum == CIM_NAMESPACE)
1368 {
1369
1370 CDEBUG("Calling BuildInstancePath for "<< namespaceNames[i].getString() );
1371 CIMInstance instance = _buildInstanceCIMNamespace(namespaceNames[i]);
1372 karl 1.1 CIMObjectPath ref = _buildInstancePath(CIMNamespaceName(namespaceNames[i]),
1373 CIM_NAMESPACE_CLASSNAME, instance);
1374
1375 handler.deliver(ref);
1376
1377 PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4,
1378 "namespace = " + namespaceNames[i].getString());
1379 }
1380 else
1381 {
1382 Array<CIMKeyBinding> keyBindings;
1383 // Build the __Namespace objectpath
1384 // Note that for the moment, the only property is name.
1385 if (_isChild(parentNamespaceName, namespaceNames[i]))
1386 {
1387 keyBindings.clear();
1388 keyBindings.append(CIMKeyBinding(NAMESPACE_PROPERTYNAME,
1389 namespaceNames[i].getString().subString
1390 (parentNamespaceName.getString().size()+1,
1391 namespaceNames[i].getString().size()-
1392 parentNamespaceName.getString().size()-1),
1393 karl 1.1 CIMKeyBinding::STRING));
1394
1395 CIMObjectPath ref(String::EMPTY, parentNamespaceName,
1396 __NAMESPACE_CLASSNAME, keyBindings);
1397
1398 handler.deliver(ref);
1399 PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4,
1400 "childNamespace = " + namespaceNames[i].getString());
1401 }
1402 }
1403 }
1404
1405 handler.complete();
1406
1407 PEG_METHOD_EXIT();
1408 }
1409
1410
1411 //**************************************************************
1412 //**************************************************************
1413 // Association Functions
1414 karl 1.1 //**************************************************************
1415 //**************************************************************
1416
1417 void InteropProvider::associators(
1418 const OperationContext & context,
1419 const CIMObjectPath & objectName,
1420 const CIMName & associationClass,
1421 const CIMName & resultClass,
1422 const String & role,
1423 const String & resultRole,
1424 const Boolean includeQualifiers,
1425 const Boolean includeClassOrigin,
1426 const CIMPropertyList & propertyList,
1427 ObjectResponseHandler & handler)
1428 {
1429 throw CIMNotSupportedException("AssociationProvider::associators");
1430 }
1431
1432 void InteropProvider::associatorNames(
1433 const OperationContext & context,
1434 const CIMObjectPath & objectName,
1435 karl 1.1 const CIMName & associationClass,
1436 const CIMName & resultClass,
1437 const String & role,
1438 const String & resultRole,
1439 ObjectPathResponseHandler & handler)
1440 {
1441 throw CIMNotSupportedException("AssociationProvider::associatorNames");
1442 }
1443
1444 void InteropProvider::references(
1445 const OperationContext & context,
1446 const CIMObjectPath & objectName,
1447 const CIMName & resultClass,
1448 const String & role,
1449 const Boolean includeQualifiers,
1450 const Boolean includeClassOrigin,
1451 const CIMPropertyList & propertyList,
1452 ObjectResponseHandler & handler)
1453 {
1454 throw CIMNotSupportedException("AssociationProvider::references");
1455 }
1456 karl 1.1
1457 void InteropProvider::referenceNames(
1458 const OperationContext & context,
1459 const CIMObjectPath & objectName,
1460 const CIMName & resultClass,
1461 const String & role,
1462 ObjectPathResponseHandler & handler)
1463 {
1464 throw CIMNotSupportedException("AssociationProvider::referenceNames");
1465 }
1466
1467 PEGASUS_NAMESPACE_END
1468 // END_OF_FILE
|