1 karl 1.12 //%2006////////////////////////////////////////////////////////////////////////
|
2 kumpf 1.1 //
|
3 karl 1.2 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
|
6 kumpf 1.1 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.2 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.3 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.12 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 kumpf 1.1 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
15 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
18 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
|
20 karl 1.12 //
|
21 kumpf 1.1 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
22 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
24 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
27 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 //==============================================================================
31 //
32 // Author: Carol Ann Krug Graves, Hewlett-Packard Company
33 // (carolann_graves@hp.com)
34 //
|
35 david.dillard 1.5 // Modified By: David Dillard, VERITAS Software Corp.
36 // (david.dillard@veritas.com)
|
37 kumpf 1.1 //
38 //%/////////////////////////////////////////////////////////////////////////////
39
40 #include <Pegasus/Common/Config.h>
41 #include <Pegasus/Common/Tracer.h>
|
42 kumpf 1.10 #include <Pegasus/Common/LanguageParser.h>
|
43 kumpf 1.1
44 #include "IndicationConstants.h"
45 #include "SubscriptionRepository.h"
46
47 PEGASUS_USING_STD;
48
49 PEGASUS_NAMESPACE_BEGIN
50
51 SubscriptionRepository::SubscriptionRepository (
52 CIMRepository * repository)
53 : _repository (repository)
54 {
55 }
56
57 SubscriptionRepository::~SubscriptionRepository ()
58 {
59 }
60
61 CIMObjectPath SubscriptionRepository::createInstance (
62 CIMInstance instance,
63 const CIMNamespaceName & nameSpace,
64 kumpf 1.1 const String & userName,
|
65 kumpf 1.11 const AcceptLanguageList & acceptLanguages,
66 const ContentLanguageList & contentLanguages,
|
67 kumpf 1.1 Boolean enabled)
68 {
69 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
70 "SubscriptionRepository::createInstance");
71
72 CIMObjectPath instanceRef;
73
74 //
75 // Add creator property to Instance
76 // NOTE: userName is only set if authentication is turned on
77 //
78 String currentUser = userName;
|
79 david.dillard 1.5 if (instance.findProperty (PEGASUS_PROPERTYNAME_INDSUB_CREATOR) ==
|
80 kumpf 1.1 PEG_NOT_FOUND)
81 {
|
82 david.dillard 1.5 instance.addProperty (CIMProperty
|
83 kumpf 1.1 (PEGASUS_PROPERTYNAME_INDSUB_CREATOR, currentUser));
84 }
|
85 david.dillard 1.5 else
|
86 kumpf 1.1 {
|
87 david.dillard 1.5 CIMProperty creator = instance.getProperty
88 (instance.findProperty
|
89 kumpf 1.1 (PEGASUS_PROPERTYNAME_INDSUB_CREATOR));
90 creator.setValue (CIMValue (currentUser));
91 }
|
92 david.dillard 1.5
|
93 kumpf 1.1 // l10n
94 // Add the language properties to the Instance
95 // Note: These came from the Accept-Language and Content-Language
96 // headers in the HTTP message, and may be empty
|
97 kumpf 1.11 AcceptLanguageList acceptLangs = acceptLanguages;
|
98 david.dillard 1.5 if (instance.findProperty (PEGASUS_PROPERTYNAME_INDSUB_ACCEPTLANGS) ==
|
99 kumpf 1.1 PEG_NOT_FOUND)
100 {
|
101 david.dillard 1.5 instance.addProperty (CIMProperty
102 (PEGASUS_PROPERTYNAME_INDSUB_ACCEPTLANGS,
|
103 kumpf 1.10 LanguageParser::buildAcceptLanguageHeader(acceptLangs)));
|
104 kumpf 1.1 }
|
105 david.dillard 1.5 else
|
106 kumpf 1.1 {
|
107 david.dillard 1.5 CIMProperty langs = instance.getProperty
108 (instance.findProperty
|
109 kumpf 1.1 (PEGASUS_PROPERTYNAME_INDSUB_ACCEPTLANGS));
|
110 kumpf 1.10 langs.setValue (CIMValue (
111 LanguageParser::buildAcceptLanguageHeader(acceptLangs)));
|
112 david.dillard 1.5 }
|
113 kumpf 1.1
|
114 kumpf 1.11 ContentLanguageList contentLangs = contentLanguages;
|
115 david.dillard 1.5 if (instance.findProperty (PEGASUS_PROPERTYNAME_INDSUB_CONTENTLANGS) ==
|
116 kumpf 1.1 PEG_NOT_FOUND)
117 {
|
118 david.dillard 1.5 instance.addProperty (CIMProperty
119 (PEGASUS_PROPERTYNAME_INDSUB_CONTENTLANGS,
|
120 kumpf 1.10 LanguageParser::buildContentLanguageHeader(contentLangs)));
|
121 kumpf 1.1 }
|
122 david.dillard 1.5 else
|
123 kumpf 1.1 {
|
124 david.dillard 1.5 CIMProperty langs = instance.getProperty
125 (instance.findProperty
|
126 kumpf 1.1 (PEGASUS_PROPERTYNAME_INDSUB_CONTENTLANGS));
|
127 kumpf 1.10 langs.setValue (CIMValue (
128 LanguageParser::buildContentLanguageHeader(contentLangs)));
|
129 david.dillard 1.5 }
|
130 kumpf 1.1 // l10n -end
131
|
132 carolann.graves 1.4 if ((instance.getClassName ().equal
133 (PEGASUS_CLASSNAME_INDSUBSCRIPTION)) ||
134 (instance.getClassName ().equal
135 (PEGASUS_CLASSNAME_FORMATTEDINDSUBSCRIPTION)))
|
136 kumpf 1.1 {
137 //
138 // Set Time of Last State Change to current date time
139 //
|
140 david.dillard 1.5 CIMDateTime currentDateTime =
|
141 kumpf 1.1 CIMDateTime::getCurrentDateTime ();
|
142 david.dillard 1.5 if (instance.findProperty (_PROPERTY_LASTCHANGE) ==
|
143 kumpf 1.1 PEG_NOT_FOUND)
144 {
|
145 david.dillard 1.5 instance.addProperty
|
146 kumpf 1.1 (CIMProperty (_PROPERTY_LASTCHANGE, currentDateTime));
147 }
|
148 david.dillard 1.5 else
|
149 kumpf 1.1 {
|
150 david.dillard 1.5 CIMProperty lastChange = instance.getProperty
|
151 kumpf 1.1 (instance.findProperty (_PROPERTY_LASTCHANGE));
152 lastChange.setValue (CIMValue (currentDateTime));
153 }
|
154 david.dillard 1.5
|
155 kumpf 1.1 CIMDateTime startDateTime;
156 if (enabled)
157 {
158 startDateTime = currentDateTime;
159 }
160 else
161 {
162 //
163 // If subscription is not enabled, set Subscription
164 // Start Time to null CIMDateTime value
165 //
166 startDateTime = CIMDateTime ();
167 }
168
169 //
170 // Set Subscription Start Time
171 //
|
172 david.dillard 1.5 if (instance.findProperty (_PROPERTY_STARTTIME) ==
|
173 kumpf 1.1 PEG_NOT_FOUND)
174 {
|
175 david.dillard 1.5 instance.addProperty
|
176 kumpf 1.1 (CIMProperty (_PROPERTY_STARTTIME, startDateTime));
177 }
|
178 david.dillard 1.5 else
|
179 kumpf 1.1 {
|
180 david.dillard 1.5 CIMProperty startTime = instance.getProperty
|
181 kumpf 1.1 (instance.findProperty (_PROPERTY_STARTTIME));
182 startTime.setValue (CIMValue (startDateTime));
183 }
184 }
185
186 //
187 // Create instance in repository
188 //
|
189 david.dillard 1.5 try
|
190 kumpf 1.1 {
191 instanceRef = _repository->createInstance (nameSpace, instance);
192 }
|
193 david.dillard 1.5 catch (const CIMException &)
|
194 kumpf 1.1 {
195 PEG_METHOD_EXIT ();
196 throw;
197 }
|
198 david.dillard 1.5 catch (const Exception & exception)
|
199 kumpf 1.1 {
200 PEG_METHOD_EXIT ();
201 throw PEGASUS_CIM_EXCEPTION (CIM_ERR_FAILED, exception.getMessage ());
202 }
203
204 PEG_METHOD_EXIT ();
205 return instanceRef;
206 }
207
208 Boolean SubscriptionRepository::getActiveSubscriptions (
209 Array <CIMInstance> & activeSubscriptions) const
210 {
211 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
212 "SubscriptionRepository::getActiveSubscriptions");
213
214 Array <CIMNamespaceName> nameSpaceNames;
215 Array <CIMInstance> subscriptions;
216 CIMValue subscriptionStateValue;
217 Uint16 subscriptionState;
218 Boolean invalidInstance = false;
219
220 kumpf 1.1 activeSubscriptions.clear ();
221
222 //
223 // Get list of namespaces in repository
224 //
225 nameSpaceNames = _repository->enumerateNameSpaces ();
226
227 //
228 // Get existing subscriptions from each namespace in the repository
229 //
230 for (Uint32 i = 0; i < nameSpaceNames.size (); i++)
231 {
232
233 //
234 // Get existing subscriptions in current namespace
235 //
236 subscriptions = getSubscriptions (nameSpaceNames [i]);
237
238 //
239 // Process each subscription
240 //
241 kumpf 1.1 for (Uint32 j = 0; j < subscriptions.size (); j++)
242 {
243 //
244 // Get subscription state
245 //
246 if (!getState (subscriptions [j], subscriptionState))
247 {
248 //
249 // This instance from the repository is corrupted
250 // Skip it
251 //
252 invalidInstance = true;
253 break;
254 }
255
256 //
257 // Process each enabled subscription
258 //
|
259 w.otsuka 1.14 if ((subscriptionState == STATE_ENABLED) ||
260 (subscriptionState == STATE_ENABLEDDEGRADED))
|
261 kumpf 1.1 {
262 //
|
263 david.dillard 1.5 // CIMInstances returned from repository do not include
|
264 kumpf 1.1 // namespace
265 // Set namespace here
266 //
267 CIMObjectPath instanceName = subscriptions [j].getPath ();
268 instanceName.setNameSpace (nameSpaceNames [i]);
269 subscriptions [j].setPath (instanceName);
270 activeSubscriptions.append (subscriptions [j]);
271 } // if subscription is enabled
272 } // for each subscription
273 } // for each namespace
274
275 PEG_METHOD_EXIT ();
276 return invalidInstance;
277 }
278
|
279 carolann.graves 1.9 Array <CIMInstance> SubscriptionRepository::getAllSubscriptions () const
280 {
281 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
282 "SubscriptionRepository::getAllSubscriptions");
283
284 Array <CIMNamespaceName> nameSpaceNames;
285 Array <CIMInstance> subscriptions;
286 Array <CIMInstance> allSubscriptions;
287
288 //
289 // Get list of namespaces in repository
290 //
291 nameSpaceNames = _repository->enumerateNameSpaces ();
292
293 //
294 // Get all subscriptions from each namespace in the repository
295 //
296 for (Uint32 i = 0; i < nameSpaceNames.size (); i++)
297 {
298 //
299 // Get all subscriptions in current namespace
300 carolann.graves 1.9 //
301 subscriptions = getSubscriptions (nameSpaceNames [i]);
302
303 //
304 // Append subscriptions in current namespace to list of all
305 // subscriptions
306 //
307 allSubscriptions.appendArray (subscriptions);
308 }
309
310 PEG_METHOD_EXIT ();
311 return allSubscriptions;
312 }
313
|
314 kumpf 1.1 Array <CIMInstance> SubscriptionRepository::getSubscriptions (
|
315 carolann.graves 1.6 const CIMNamespaceName & nameSpace) const
|
316 kumpf 1.1 {
317 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
318 "SubscriptionRepository::getSubscriptions");
319
320 Array <CIMInstance> subscriptions;
321
322 //
|
323 kumpf 1.13 // Get the CIM_IndicationSubscription and
324 // CIM_FormattedIndicationSubscription instances in specified namespace
|
325 kumpf 1.1 //
326 try
327 {
|
328 kumpf 1.13 subscriptions = _repository->enumerateInstancesForClass(
329 nameSpace, PEGASUS_CLASSNAME_INDSUBSCRIPTION);
330 subscriptions.appendArray(_repository->enumerateInstancesForClass(
331 nameSpace, PEGASUS_CLASSNAME_FORMATTEDINDSUBSCRIPTION));
|
332 kumpf 1.1 }
|
333 david.dillard 1.5 catch (const CIMException& e)
|
334 kumpf 1.1 {
335 //
336 // Some namespaces may not include the subscription class
337 // In that case, just return no subscriptions
338 // Any other exception is an error
339 //
340 if (e.getCode () != CIM_ERR_INVALID_CLASS)
341 {
342 PEG_METHOD_EXIT ();
|
343 david.dillard 1.5 throw;
|
344 kumpf 1.1 }
345 }
346
|
347 kumpf 1.13 //
348 // Process each subscription
349 //
350 for (Uint32 i = 0; i < subscriptions.size(); i++)
351 {
352 //
353 // CIMInstances returned from repository do not include
354 // namespace
355 // Set namespace here
356 //
357 CIMObjectPath instanceName = subscriptions[i].getPath();
358 instanceName.setNameSpace(nameSpace);
359 subscriptions[i].setPath(instanceName);
360 }
361
|
362 kumpf 1.1 PEG_METHOD_EXIT ();
363 return subscriptions;
364 }
365
366 Boolean SubscriptionRepository::getState (
367 const CIMInstance & instance,
368 Uint16 & state) const
369 {
|
370 david.dillard 1.5 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
|
371 kumpf 1.1 "SubscriptionRepository::getState");
372
|
373 w.otsuka 1.14 Uint32 stateIndex = instance.findProperty (PEGASUS_PROPERTYNAME_SUBSCRIPTION_STATE);
|
374 kumpf 1.1 if (stateIndex != PEG_NOT_FOUND)
375 {
|
376 david.dillard 1.5 CIMValue stateValue = instance.getProperty
|
377 kumpf 1.1 (stateIndex).getValue ();
378 if (stateValue.isNull ())
379 {
|
380 david.dillard 1.5 PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL,
381 Tracer::LEVEL2,
|
382 kumpf 1.1 "Null SubscriptionState property value");
383
384 //
385 // This is a corrupted/invalid instance
386 //
387 return false;
388 }
389 else if ((stateValue.getType () != CIMTYPE_UINT16) ||
390 (stateValue.isArray ()))
391 {
392 String traceString;
393 if (stateValue.isArray ())
394 {
395 traceString.append ("array of ");
396 }
397 traceString.append (cimTypeToString (stateValue.getType ()));
|
398 david.dillard 1.5 PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL,
399 Tracer::LEVEL2,
|
400 kumpf 1.1 "SubscriptionState property value of incorrect type: "
401 + traceString);
402
403 //
404 // This is a corrupted/invalid instance
405 //
406 return false;
407 }
408 else
409 {
410 stateValue.get (state);
411 }
412 }
413 else
414 {
|
415 david.dillard 1.5 PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL,
416 Tracer::LEVEL2,
|
417 kumpf 1.1 "Missing SubscriptionState property");
418
419 //
420 // This is a corrupted/invalid instance
421 //
422 return false;
423 }
424
425 PEG_METHOD_EXIT ();
426 return true;
427 }
428
429 CIMInstance SubscriptionRepository::deleteSubscription (
430 CIMObjectPath & subscription)
431 {
432 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
433 "SubscriptionRepository::deleteSubscription");
434
435 CIMInstance subscriptionInstance;
436 CIMNamespaceName nameSpace = subscription.getNameSpace ();
437 subscription.setNameSpace (CIMNamespaceName ());
438 kumpf 1.1
439 //
440 // Get instance from repository
441 //
442 try
443 {
|
444 david.dillard 1.5 subscriptionInstance = _repository->getInstance (nameSpace,
|
445 kumpf 1.1 subscription);
446 }
447 catch (Exception & exception)
448 {
|
449 david.dillard 1.5 PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2,
|
450 kumpf 1.1 "Exception caught in retrieving subscription (" +
451 subscriptionInstance.getPath ().toString () + "): " +
452 exception.getMessage ());
453
454 //
|
455 david.dillard 1.5 // If the subscription could not be retrieved, it may already have
|
456 kumpf 1.1 // been deleted by another thread
457 //
458 PEG_METHOD_EXIT ();
459 return CIMInstance ();
460 }
461
462 //
463 // Delete the subscription instance
464 //
465 try
466 {
467 _repository->deleteInstance (nameSpace, subscription);
468 }
469 catch (Exception & exception)
470 {
|
471 david.dillard 1.5 PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2,
|
472 kumpf 1.1 "Exception caught in deleting subscription (" +
473 subscriptionInstance.getPath ().toString () + "): " +
474 exception.getMessage ());
475
476 //
|
477 david.dillard 1.5 // If the subscription could not be deleted, it may already have
|
478 kumpf 1.1 // been deleted by another thread
479 //
480 PEG_METHOD_EXIT ();
481 return CIMInstance ();
482 }
483
484 //
485 // Reset namespace in object path
486 //
487 subscription.setNameSpace (nameSpace);
488
489 PEG_METHOD_EXIT ();
490 return subscriptionInstance;
491 }
492
493 Array <CIMInstance> SubscriptionRepository::deleteReferencingSubscriptions (
494 const CIMNamespaceName & nameSpace,
495 const CIMName & referenceProperty,
496 const CIMObjectPath & handler)
497 {
498 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
499 kumpf 1.1 "SubscriptionRepository::deleteReferencingSubscriptions");
500
501 Array <CIMInstance> subscriptions;
502 Array <CIMInstance> deletedSubscriptions;
503
504 //
|
505 carolann.graves 1.9 // Get all subscriptions in all namespaces
|
506 kumpf 1.1 //
|
507 carolann.graves 1.9 subscriptions = getAllSubscriptions ();
|
508 kumpf 1.1
509 //
|
510 david.dillard 1.5 // Check each subscription for a reference to the specified instance
|
511 kumpf 1.1 //
512 for (Uint32 i = 0; i < subscriptions.size (); i++)
513 {
514 //
515 // Get the reference property value from the subscription instance
516 //
517 CIMValue propValue = subscriptions [i].getProperty
518 (subscriptions [i].findProperty (referenceProperty)).getValue ();
519 CIMObjectPath ref;
520 propValue.get (ref);
521
522 //
|
523 carolann.graves 1.9 // If the Handler reference property value includes namespace, check
524 // if it is the namespace of the Handler being deleted.
525 // If the Handler reference property value does not include namespace,
526 // check if the current subscription namespace is the namespace of the
527 // Handler being deleted.
528 //
529 CIMNamespaceName handlerNS = ref.getNameSpace ();
530 if (((handlerNS.isNull ()) &&
531 (subscriptions[i].getPath ().getNameSpace () == nameSpace))
532 || (handlerNS == nameSpace))
533 {
534 //
535 // Remove Host and Namespace from reference property value, if
536 // present, before comparing
537 //
538 CIMObjectPath href ("", CIMNamespaceName (),
539 ref.getClassName (), ref.getKeyBindings ());
540
541 //
542 // Remove Host and Namespace from reference of handler instance to
543 // be deleted, if present, before comparing
544 carolann.graves 1.9 //
545 CIMObjectPath iref ("", CIMNamespaceName (),
546 handler.getClassName (), handler.getKeyBindings ());
|
547 carolann.graves 1.7
|
548 kumpf 1.1 //
|
549 carolann.graves 1.9 // If the current subscription references the specified instance,
550 // delete it
|
551 kumpf 1.1 //
|
552 carolann.graves 1.9 if (iref == href)
|
553 kumpf 1.1 {
554 //
|
555 carolann.graves 1.9 // Delete referencing subscription instance from repository
|
556 kumpf 1.1 //
|
557 carolann.graves 1.9 try
558 {
559 //
560 // Namespace and host must not be set in path passed to
561 // repository
562 //
563 CIMObjectPath path ("", CIMNamespaceName (),
564 subscriptions [i].getPath ().getClassName (),
565 subscriptions [i].getPath ().getKeyBindings ());
566 _repository->deleteInstance
567 (subscriptions [i].getPath ().getNameSpace (), path);
568 }
569 catch (Exception & exception)
570 {
571 //
572 // Deletion of referencing subscription failed
573 //
574 PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL,
575 Tracer::LEVEL2,
576 "Exception caught deleting referencing subscription (" +
577 subscriptions [i].getPath ().toString () + "): " +
578 carolann.graves 1.9 exception.getMessage ());
579 }
580
581 deletedSubscriptions.append (subscriptions [i]);
|
582 kumpf 1.1 }
583 }
584 }
585
586 PEG_METHOD_EXIT ();
587 return deletedSubscriptions;
588 }
589
590 CIMInstance SubscriptionRepository::getHandler (
591 const CIMInstance & subscription) const
592 {
|
593 david.dillard 1.5 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
|
594 kumpf 1.1 "SubscriptionRepository::getHandler");
595
596 CIMValue handlerValue;
597 CIMObjectPath handlerRef;
598 CIMInstance handlerInstance;
|
599 carolann.graves 1.9 CIMNamespaceName nameSpaceName;
|
600 kumpf 1.1
601 //
602 // Get Handler reference from subscription instance
603 //
604 handlerValue = subscription.getProperty (subscription.findProperty
|
605 w.otsuka 1.14 (PEGASUS_PROPERTYNAME_HANDLER)).getValue ();
|
606 kumpf 1.1
607 handlerValue.get (handlerRef);
608
609 //
|
610 carolann.graves 1.9 // Get handler namespace - if not set in Handler reference property value,
611 // namespace is the namespace of the subscription
612 //
613 nameSpaceName = handlerRef.getNameSpace ();
614 if (nameSpaceName.isNull ())
615 {
616 nameSpaceName = subscription.getPath ().getNameSpace ();
617 }
618
619 //
|
620 kumpf 1.1 // Get Handler instance from the repository
621 //
622 try
623 {
624 handlerInstance = _repository->getInstance
|
625 carolann.graves 1.9 (nameSpaceName, handlerRef, false, false, false,
626 CIMPropertyList ());
|
627 kumpf 1.1 }
|
628 carolann.graves 1.8 catch (const Exception & exception)
|
629 kumpf 1.1 {
|
630 carolann.graves 1.8 PEG_TRACE_STRING (TRC_DISCARDED_DATA, Tracer::LEVEL2,
631 "Exception caught trying to get Handler instance (" +
632 handlerRef.toString () + "): " +
633 exception.getMessage ());
|
634 kumpf 1.1 PEG_METHOD_EXIT ();
635 throw;
636 }
637
638 //
639 // Set namespace in path in CIMInstance
640 //
|
641 carolann.graves 1.9 handlerRef.setNameSpace (nameSpaceName);
|
642 kumpf 1.1 handlerInstance.setPath (handlerRef);
643
644 PEG_METHOD_EXIT ();
645 return handlerInstance;
646 }
647
648 Boolean SubscriptionRepository::isTransient (
649 const CIMNamespaceName & nameSpace,
650 const CIMObjectPath & handler) const
651 {
652 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
653 "SubscriptionRepository::isTransient");
654
655 CIMValue persistenceValue;
656 Uint16 persistenceType;
657
658 //
659 // Get the handler instance from the repository
660 //
661 CIMInstance instance;
662
663 kumpf 1.1 try
664 {
|
665 david.dillard 1.5 instance = _repository->getInstance (nameSpace, handler,
|
666 kumpf 1.1 false, false, false, CIMPropertyList ());
667 }
|
668 david.dillard 1.5 catch (const Exception &)
|
669 kumpf 1.1 {
670 PEG_METHOD_EXIT ();
671 throw;
672 }
673
674 //
675 // Get Persistence Type
676 //
677 persistenceValue = instance.getProperty (instance.findProperty
|
678 w.otsuka 1.14 (PEGASUS_PROPERTYNAME_PERSISTENCETYPE)).getValue ();
|
679 kumpf 1.1 persistenceValue.get (persistenceType);
680
|
681 w.otsuka 1.14 if (persistenceType == PERSISTENCE_TRANSIENT)
|
682 kumpf 1.1 {
683 PEG_METHOD_EXIT ();
684 return true;
685 }
686 else
687 {
688 PEG_METHOD_EXIT ();
689 return false;
690 }
691 }
692
693 void SubscriptionRepository::getFilterProperties (
694 const CIMInstance & subscription,
695 String & query,
696 CIMNamespaceName & sourceNameSpace,
|
697 david.dillard 1.5 String & queryLanguage)
|
698 kumpf 1.1 {
699 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
700 "SubscriptionRepository::getFilterProperties");
701
702 CIMValue filterValue;
703 CIMObjectPath filterReference;
704 CIMInstance filterInstance;
|
705 carolann.graves 1.9 CIMNamespaceName nameSpaceName;
|
706 kumpf 1.1
707 filterValue = subscription.getProperty (subscription.findProperty
|
708 w.otsuka 1.14 (PEGASUS_PROPERTYNAME_FILTER)).getValue ();
|
709 kumpf 1.1
710 filterValue.get (filterReference);
711
|
712 carolann.graves 1.9 //
713 // Get filter namespace - if not set in Filter reference property value,
714 // namespace is the namespace of the subscription
715 //
716 nameSpaceName = filterReference.getNameSpace ();
717 if (nameSpaceName.isNull ())
718 {
719 nameSpaceName = subscription.getPath ().getNameSpace ();
720 }
721
|
722 kumpf 1.1 try
723 {
|
724 david.dillard 1.5 filterInstance = _repository->getInstance (nameSpaceName,
|
725 kumpf 1.1 filterReference);
726 }
|
727 david.dillard 1.5 catch (const Exception & exception)
|
728 kumpf 1.1 {
|
729 carolann.graves 1.8 PEG_TRACE_STRING (TRC_DISCARDED_DATA, Tracer::LEVEL2,
730 "Exception caught trying to get Filter instance (" +
|
731 kumpf 1.1 filterReference.toString () + "): " +
732 exception.getMessage ());
733 PEG_METHOD_EXIT ();
734 throw;
735 }
736
|
737 david.dillard 1.5 query = filterInstance.getProperty (filterInstance.findProperty
|
738 w.otsuka 1.14 (PEGASUS_PROPERTYNAME_QUERY)).getValue ().toString ();
|
739 kumpf 1.1
|
740 david.dillard 1.5 sourceNameSpace = filterInstance.getProperty (filterInstance.findProperty
|
741 kumpf 1.1 (_PROPERTY_SOURCENAMESPACE)).getValue ().toString ();
742
743 queryLanguage = filterInstance.getProperty
|
744 w.otsuka 1.14 (filterInstance.findProperty (PEGASUS_PROPERTYNAME_QUERYLANGUAGE)).
|
745 kumpf 1.1 getValue ().toString ();
746
747 PEG_METHOD_EXIT ();
748 }
749
750 void SubscriptionRepository::getFilterProperties (
751 const CIMInstance & subscription,
752 String & query,
|
753 david.dillard 1.5 CIMNamespaceName & sourceNameSpace)
|
754 kumpf 1.1 {
755 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
756 "SubscriptionRepository::getFilterProperties");
757
758 CIMValue filterValue;
759 CIMObjectPath filterReference;
760 CIMInstance filterInstance;
|
761 carolann.graves 1.9 CIMNamespaceName nameSpaceName;
|
762 kumpf 1.1
763 filterValue = subscription.getProperty (subscription.findProperty
|
764 w.otsuka 1.14 (PEGASUS_PROPERTYNAME_FILTER)).getValue ();
|
765 kumpf 1.1
766 filterValue.get (filterReference);
767
|
768 carolann.graves 1.9 //
769 // Get filter namespace - if not set in Filter reference property value,
770 // namespace is the namespace of the subscription
771 //
772 nameSpaceName = filterReference.getNameSpace ();
773 if (nameSpaceName.isNull ())
774 {
775 nameSpaceName = subscription.getPath ().getNameSpace ();
776 }
777
|
778 kumpf 1.1 try
779 {
|
780 david.dillard 1.5 filterInstance = _repository->getInstance (nameSpaceName,
|
781 kumpf 1.1 filterReference);
782 }
|
783 david.dillard 1.5 catch (const Exception & exception)
|
784 kumpf 1.1 {
|
785 david.dillard 1.5 PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2,
|
786 kumpf 1.1 "Exception caught in getting filter instance (" +
787 filterReference.toString () + "): " +
788 exception.getMessage ());
789 PEG_METHOD_EXIT ();
790 throw;
791 }
792
|
793 david.dillard 1.5 query = filterInstance.getProperty (filterInstance.findProperty
|
794 w.otsuka 1.14 (PEGASUS_PROPERTYNAME_QUERY)).getValue ().toString ();
|
795 kumpf 1.1
|
796 david.dillard 1.5 sourceNameSpace = filterInstance.getProperty (filterInstance.findProperty
|
797 kumpf 1.1 (_PROPERTY_SOURCENAMESPACE)).getValue ().toString ();
798
799 PEG_METHOD_EXIT ();
800 }
801
802 void SubscriptionRepository::getFilterProperties (
803 const CIMInstance & subscription,
|
804 david.dillard 1.5 String & query)
|
805 kumpf 1.1 {
806 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
807 "SubscriptionRepository::getFilterProperties");
808
809 CIMValue filterValue;
810 CIMObjectPath filterReference;
811 CIMInstance filterInstance;
|
812 carolann.graves 1.9 CIMNamespaceName nameSpaceName;
|
813 kumpf 1.1
814 filterValue = subscription.getProperty (subscription.findProperty
|
815 w.otsuka 1.14 (PEGASUS_PROPERTYNAME_FILTER)).getValue ();
|
816 kumpf 1.1
817 filterValue.get (filterReference);
818
|
819 carolann.graves 1.9 //
820 // Get filter namespace - if not set in Filter reference property value,
821 // namespace is the namespace of the subscription
822 //
823 nameSpaceName = filterReference.getNameSpace ();
824 if (nameSpaceName.isNull ())
825 {
826 nameSpaceName = subscription.getPath ().getNameSpace ();
827 }
828
|
829 kumpf 1.1 try
830 {
|
831 david.dillard 1.5 filterInstance = _repository->getInstance (nameSpaceName,
|
832 kumpf 1.1 filterReference);
833 }
|
834 david.dillard 1.5 catch (const Exception & exception)
|
835 kumpf 1.1 {
|
836 david.dillard 1.5 PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2,
|
837 kumpf 1.1 "Exception caught in getting filter instance (" +
838 filterReference.toString () + "): " +
839 exception.getMessage ());
840 PEG_METHOD_EXIT ();
841 throw;
842 }
843
|
844 david.dillard 1.5 query = filterInstance.getProperty (filterInstance.findProperty
|
845 w.otsuka 1.14 (PEGASUS_PROPERTYNAME_QUERY)).getValue ().toString ();
|
846 kumpf 1.1
847 PEG_METHOD_EXIT ();
848 }
849
850 Boolean SubscriptionRepository::validateIndicationClassName (
851 const CIMName & indicationClassName,
852 const CIMNamespaceName & nameSpaceName) const
853 {
854 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
855 "SubscriptionRepository::validateIndicationClassName");
856
857 //
858 // Validate that class is an Indication class
859 // The Indication Qualifier should exist and have the value True
860 //
861 Boolean validClass = false;
862 CIMClass theClass;
863
864 try
865 {
|
866 david.dillard 1.5 theClass = _repository->getClass (nameSpaceName, indicationClassName,
|
867 kumpf 1.1 false, true, false, CIMPropertyList ());
868 }
|
869 carolann.graves 1.8 catch (const Exception & exception)
|
870 kumpf 1.1 {
|
871 carolann.graves 1.8 PEG_TRACE_STRING (TRC_DISCARDED_DATA, Tracer::LEVEL2,
872 "Exception caught trying to get indication class (" +
873 indicationClassName.getString () + "): " +
874 exception.getMessage ());
|
875 kumpf 1.1 PEG_METHOD_EXIT ();
876 throw;
877 }
878
879 if (theClass.findQualifier (_QUALIFIER_INDICATION) != PEG_NOT_FOUND)
880 {
881 CIMQualifier theQual = theClass.getQualifier (theClass.findQualifier
882 (_QUALIFIER_INDICATION));
883 CIMValue theVal = theQual.getValue ();
884 if (!theVal.isNull ())
885 {
886 Boolean indicationClass;
887 theVal.get (indicationClass);
888 validClass = indicationClass;
889 }
890 }
891
892 PEG_METHOD_EXIT ();
893 return validClass;
894 }
895
896 kumpf 1.1 Array <CIMName> SubscriptionRepository::getIndicationSubclasses (
897 const CIMNamespaceName & nameSpace,
898 const CIMName & indicationClassName) const
899 {
900 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
901 "SubscriptionRepository::getIndicationSubclasses");
902
903 Array <CIMName> indicationSubclasses;
904
905 try
906 {
907 indicationSubclasses = _repository->enumerateClassNames
908 (nameSpace, indicationClassName, true);
909 }
|
910 david.dillard 1.5 catch (const Exception &)
|
911 kumpf 1.1 {
912 PEG_METHOD_EXIT ();
913 throw;
914 }
915
916 indicationSubclasses.append (indicationClassName);
917
918 PEG_METHOD_EXIT ();
919 return indicationSubclasses;
920 }
921
922 Boolean SubscriptionRepository::reconcileFatalError (
923 const CIMInstance subscription)
924 {
925 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
926 "SubscriptionRepository::reconcileFatalError");
927
928 Boolean removeOrDisable = false;
929
930 //
931 // Get the value of the On Fatal Error Policy property
932 kumpf 1.1 //
933 CIMValue errorPolicyValue;
934 Uint16 onFatalErrorPolicy;
|
935 david.dillard 1.5 errorPolicyValue = subscription.getProperty
936 (subscription.findProperty
|
937 kumpf 1.1 (_PROPERTY_ONFATALERRORPOLICY)).getValue ();
938 errorPolicyValue.get (onFatalErrorPolicy);
939
940 if (errorPolicyValue == _ERRORPOLICY_DISABLE)
941 {
942 //
|
943 david.dillard 1.5 // FUTURE: Failure Trigger Time Interval should be allowed to pass
|
944 kumpf 1.1 // before implementing On Fatal Error Policy
945 //
946 // Set the Subscription State to disabled
947 //
948 _disableSubscription (subscription);
949 removeOrDisable = true;
950 }
951 else if (errorPolicyValue == _ERRORPOLICY_REMOVE)
952 {
953 //
|
954 david.dillard 1.5 // FUTURE: Failure Trigger Time Interval should be allowed to pass
|
955 kumpf 1.1 // before implementing On Fatal Error Policy
956 //
957 // Delete the subscription
958 //
959 _deleteSubscription (subscription);
960 removeOrDisable = true;
961 }
962
963 PEG_METHOD_EXIT ();
964 return removeOrDisable;
965 }
966
967 CIMClass SubscriptionRepository::getClass (
968 const CIMNamespaceName & nameSpaceName,
969 const CIMName & className,
970 Boolean localOnly,
971 Boolean includeQualifiers,
972 Boolean includeClassOrigin,
973 const CIMPropertyList & propertyList) const
974 {
|
975 carolann.graves 1.8 try
976 {
977 return _repository->getClass (nameSpaceName, className, localOnly,
978 includeQualifiers, includeClassOrigin, propertyList);
979 }
980 catch (const Exception & exception)
981 {
982 PEG_TRACE_STRING (TRC_DISCARDED_DATA, Tracer::LEVEL2,
983 "Exception caught trying to get class (" +
984 className.getString () + "): " +
985 exception.getMessage ());
986 throw;
987 }
|
988 kumpf 1.1 }
989
990 CIMInstance SubscriptionRepository::getInstance (
991 const CIMNamespaceName & nameSpace,
992 const CIMObjectPath & instanceName,
993 Boolean localOnly,
994 Boolean includeQualifiers,
995 Boolean includeClassOrigin,
996 const CIMPropertyList & propertyList)
997 {
|
998 david.dillard 1.5 return _repository->getInstance (nameSpace, instanceName, localOnly,
|
999 kumpf 1.1 includeQualifiers, includeClassOrigin, propertyList);
1000 }
1001
1002 void SubscriptionRepository::modifyInstance (
1003 const CIMNamespaceName & nameSpace,
1004 const CIMInstance & modifiedInstance,
1005 Boolean includeQualifiers,
1006 const CIMPropertyList & propertyList)
1007 {
1008 _repository->modifyInstance (nameSpace, modifiedInstance,
1009 includeQualifiers, propertyList);
1010 }
1011
1012 void SubscriptionRepository::deleteInstance (
1013 const CIMNamespaceName & nameSpace,
1014 const CIMObjectPath & instanceName)
1015 {
1016 _repository->deleteInstance (nameSpace, instanceName);
1017 }
1018
1019 Array <CIMInstance> SubscriptionRepository::enumerateInstancesForClass (
1020 kumpf 1.1 const CIMNamespaceName & nameSpace,
1021 const CIMName & className,
1022 Boolean localOnly,
1023 Boolean includeQualifiers,
1024 Boolean includeClassOrigin,
1025 const CIMPropertyList & propertyList)
1026 {
1027 return _repository->enumerateInstancesForClass (nameSpace, className,
|
1028 kumpf 1.13 localOnly, includeQualifiers, includeClassOrigin, propertyList);
|
1029 kumpf 1.1 }
1030
1031 Array <CIMObjectPath> SubscriptionRepository::enumerateInstanceNamesForClass (
1032 const CIMNamespaceName & nameSpace,
|
1033 kumpf 1.13 const CIMName & className)
|
1034 kumpf 1.1 {
|
1035 kumpf 1.13 return _repository->enumerateInstanceNamesForClass(nameSpace, className);
|
1036 kumpf 1.1 }
1037
1038 void SubscriptionRepository::_disableSubscription (
1039 CIMInstance subscription)
1040 {
1041 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
1042 "SubscriptionRepository::_disableSubscription");
1043
1044 //
1045 // Create property list
1046 //
1047 CIMPropertyList propertyList;
1048 Array <CIMName> properties;
|
1049 w.otsuka 1.14 properties.append (PEGASUS_PROPERTYNAME_SUBSCRIPTION_STATE);
|
1050 kumpf 1.1 propertyList = CIMPropertyList (properties);
1051
1052 //
1053 // Set Time of Last State Change to current date time
1054 //
1055 CIMInstance instance = subscription;
1056 CIMDateTime currentDateTime = CIMDateTime::getCurrentDateTime ();
1057 if (instance.findProperty (_PROPERTY_LASTCHANGE) == PEG_NOT_FOUND)
1058 {
|
1059 david.dillard 1.5 instance.addProperty
|
1060 kumpf 1.1 (CIMProperty (_PROPERTY_LASTCHANGE, currentDateTime));
1061 }
|
1062 david.dillard 1.5 else
|
1063 kumpf 1.1 {
|
1064 david.dillard 1.5 CIMProperty lastChange = instance.getProperty
|
1065 kumpf 1.1 (instance.findProperty (_PROPERTY_LASTCHANGE));
1066 lastChange.setValue (CIMValue (currentDateTime));
1067 }
1068
1069 //
1070 // Set Subscription State to Disabled
1071 //
|
1072 david.dillard 1.5 CIMProperty state = instance.getProperty (instance.findProperty
|
1073 w.otsuka 1.14 (PEGASUS_PROPERTYNAME_SUBSCRIPTION_STATE));
1074 state.setValue (CIMValue (STATE_DISABLED));
|
1075 kumpf 1.1
1076 //
1077 // Modify the instance in the repository
1078 //
1079 try
1080 {
|
1081 david.dillard 1.5 _repository->modifyInstance
|
1082 kumpf 1.1 (subscription.getPath ().getNameSpace (),
1083 subscription, false, propertyList);
1084 }
1085 catch (Exception & exception)
1086 {
|
1087 david.dillard 1.5 PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2,
|
1088 kumpf 1.1 "Exception caught in attempting to disable a subscription: " +
1089 exception.getMessage ());
1090 }
1091
1092 PEG_METHOD_EXIT ();
1093 }
1094
1095 void SubscriptionRepository::_deleteSubscription (
1096 const CIMInstance subscription)
1097 {
1098 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
1099 "SubscriptionRepository::_deleteSubscription");
1100
1101 //
1102 // Delete subscription instance from repository
1103 //
1104 try
1105 {
|
1106 david.dillard 1.5 _repository->deleteInstance
1107 (subscription.getPath ().getNameSpace (),
|
1108 kumpf 1.1 subscription.getPath ());
1109 }
1110 catch (Exception & exception)
1111 {
|
1112 david.dillard 1.5 PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2,
|
1113 kumpf 1.1 "Exception caught in attempting to delete a subscription: " +
1114 exception.getMessage ());
1115 }
1116
1117 PEG_METHOD_EXIT ();
1118 }
1119
1120 PEGASUS_NAMESPACE_END
|