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 marek 1.15 PEG_TRACE_CSTRING (TRC_INDICATION_SERVICE_INTERNAL,
|
381 david.dillard 1.5 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 marek 1.15 PEG_TRACE_CSTRING (TRC_INDICATION_SERVICE_INTERNAL,
|
416 david.dillard 1.5 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 w.otsuka 1.16 String & queryLanguage,
698 String & filterName)
|
699 kumpf 1.1 {
700 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
701 "SubscriptionRepository::getFilterProperties");
702
703 CIMValue filterValue;
704 CIMObjectPath filterReference;
705 CIMInstance filterInstance;
|
706 carolann.graves 1.9 CIMNamespaceName nameSpaceName;
|
707 kumpf 1.1
708 filterValue = subscription.getProperty (subscription.findProperty
|
709 w.otsuka 1.14 (PEGASUS_PROPERTYNAME_FILTER)).getValue ();
|
710 kumpf 1.1
711 filterValue.get (filterReference);
712
|
713 carolann.graves 1.9 //
714 // Get filter namespace - if not set in Filter reference property value,
715 // namespace is the namespace of the subscription
716 //
717 nameSpaceName = filterReference.getNameSpace ();
718 if (nameSpaceName.isNull ())
719 {
720 nameSpaceName = subscription.getPath ().getNameSpace ();
721 }
722
|
723 kumpf 1.1 try
724 {
|
725 david.dillard 1.5 filterInstance = _repository->getInstance (nameSpaceName,
|
726 kumpf 1.1 filterReference);
727 }
|
728 david.dillard 1.5 catch (const Exception & exception)
|
729 kumpf 1.1 {
|
730 carolann.graves 1.8 PEG_TRACE_STRING (TRC_DISCARDED_DATA, Tracer::LEVEL2,
731 "Exception caught trying to get Filter instance (" +
|
732 kumpf 1.1 filterReference.toString () + "): " +
733 exception.getMessage ());
734 PEG_METHOD_EXIT ();
735 throw;
736 }
737
|
738 david.dillard 1.5 query = filterInstance.getProperty (filterInstance.findProperty
|
739 w.otsuka 1.14 (PEGASUS_PROPERTYNAME_QUERY)).getValue ().toString ();
|
740 kumpf 1.1
|
741 david.dillard 1.5 sourceNameSpace = filterInstance.getProperty (filterInstance.findProperty
|
742 kumpf 1.1 (_PROPERTY_SOURCENAMESPACE)).getValue ().toString ();
743
744 queryLanguage = filterInstance.getProperty
|
745 w.otsuka 1.14 (filterInstance.findProperty (PEGASUS_PROPERTYNAME_QUERYLANGUAGE)).
|
746 kumpf 1.1 getValue ().toString ();
747
|
748 w.otsuka 1.16 filterName = filterInstance.getProperty
749 (filterInstance.findProperty (PEGASUS_PROPERTYNAME_NAME)).
750 getValue ().toString ();
751
|
752 kumpf 1.1 PEG_METHOD_EXIT ();
753 }
754
755 void SubscriptionRepository::getFilterProperties (
756 const CIMInstance & subscription,
757 String & query,
|
758 david.dillard 1.5 CIMNamespaceName & sourceNameSpace)
|
759 kumpf 1.1 {
760 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
761 "SubscriptionRepository::getFilterProperties");
762
763 CIMValue filterValue;
764 CIMObjectPath filterReference;
765 CIMInstance filterInstance;
|
766 carolann.graves 1.9 CIMNamespaceName nameSpaceName;
|
767 kumpf 1.1
768 filterValue = subscription.getProperty (subscription.findProperty
|
769 w.otsuka 1.14 (PEGASUS_PROPERTYNAME_FILTER)).getValue ();
|
770 kumpf 1.1
771 filterValue.get (filterReference);
772
|
773 carolann.graves 1.9 //
774 // Get filter namespace - if not set in Filter reference property value,
775 // namespace is the namespace of the subscription
776 //
777 nameSpaceName = filterReference.getNameSpace ();
778 if (nameSpaceName.isNull ())
779 {
780 nameSpaceName = subscription.getPath ().getNameSpace ();
781 }
782
|
783 kumpf 1.1 try
784 {
|
785 david.dillard 1.5 filterInstance = _repository->getInstance (nameSpaceName,
|
786 kumpf 1.1 filterReference);
787 }
|
788 david.dillard 1.5 catch (const Exception & exception)
|
789 kumpf 1.1 {
|
790 david.dillard 1.5 PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2,
|
791 kumpf 1.1 "Exception caught in getting filter instance (" +
792 filterReference.toString () + "): " +
793 exception.getMessage ());
794 PEG_METHOD_EXIT ();
795 throw;
796 }
797
|
798 david.dillard 1.5 query = filterInstance.getProperty (filterInstance.findProperty
|
799 w.otsuka 1.14 (PEGASUS_PROPERTYNAME_QUERY)).getValue ().toString ();
|
800 kumpf 1.1
|
801 david.dillard 1.5 sourceNameSpace = filterInstance.getProperty (filterInstance.findProperty
|
802 kumpf 1.1 (_PROPERTY_SOURCENAMESPACE)).getValue ().toString ();
803
804 PEG_METHOD_EXIT ();
805 }
806
807 void SubscriptionRepository::getFilterProperties (
808 const CIMInstance & subscription,
|
809 david.dillard 1.5 String & query)
|
810 kumpf 1.1 {
811 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
812 "SubscriptionRepository::getFilterProperties");
813
814 CIMValue filterValue;
815 CIMObjectPath filterReference;
816 CIMInstance filterInstance;
|
817 carolann.graves 1.9 CIMNamespaceName nameSpaceName;
|
818 kumpf 1.1
819 filterValue = subscription.getProperty (subscription.findProperty
|
820 w.otsuka 1.14 (PEGASUS_PROPERTYNAME_FILTER)).getValue ();
|
821 kumpf 1.1
822 filterValue.get (filterReference);
823
|
824 carolann.graves 1.9 //
825 // Get filter namespace - if not set in Filter reference property value,
826 // namespace is the namespace of the subscription
827 //
828 nameSpaceName = filterReference.getNameSpace ();
829 if (nameSpaceName.isNull ())
830 {
831 nameSpaceName = subscription.getPath ().getNameSpace ();
832 }
833
|
834 kumpf 1.1 try
835 {
|
836 david.dillard 1.5 filterInstance = _repository->getInstance (nameSpaceName,
|
837 kumpf 1.1 filterReference);
838 }
|
839 david.dillard 1.5 catch (const Exception & exception)
|
840 kumpf 1.1 {
|
841 david.dillard 1.5 PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2,
|
842 kumpf 1.1 "Exception caught in getting filter instance (" +
843 filterReference.toString () + "): " +
844 exception.getMessage ());
845 PEG_METHOD_EXIT ();
846 throw;
847 }
848
|
849 david.dillard 1.5 query = filterInstance.getProperty (filterInstance.findProperty
|
850 w.otsuka 1.14 (PEGASUS_PROPERTYNAME_QUERY)).getValue ().toString ();
|
851 kumpf 1.1
852 PEG_METHOD_EXIT ();
853 }
854
855 Boolean SubscriptionRepository::validateIndicationClassName (
856 const CIMName & indicationClassName,
857 const CIMNamespaceName & nameSpaceName) const
858 {
859 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
860 "SubscriptionRepository::validateIndicationClassName");
861
862 //
863 // Validate that class is an Indication class
864 // The Indication Qualifier should exist and have the value True
865 //
866 Boolean validClass = false;
867 CIMClass theClass;
868
869 try
870 {
|
871 david.dillard 1.5 theClass = _repository->getClass (nameSpaceName, indicationClassName,
|
872 kumpf 1.1 false, true, false, CIMPropertyList ());
873 }
|
874 carolann.graves 1.8 catch (const Exception & exception)
|
875 kumpf 1.1 {
|
876 carolann.graves 1.8 PEG_TRACE_STRING (TRC_DISCARDED_DATA, Tracer::LEVEL2,
877 "Exception caught trying to get indication class (" +
878 indicationClassName.getString () + "): " +
879 exception.getMessage ());
|
880 kumpf 1.1 PEG_METHOD_EXIT ();
881 throw;
882 }
883
884 if (theClass.findQualifier (_QUALIFIER_INDICATION) != PEG_NOT_FOUND)
885 {
886 CIMQualifier theQual = theClass.getQualifier (theClass.findQualifier
887 (_QUALIFIER_INDICATION));
888 CIMValue theVal = theQual.getValue ();
889 if (!theVal.isNull ())
890 {
891 Boolean indicationClass;
892 theVal.get (indicationClass);
893 validClass = indicationClass;
894 }
895 }
896
897 PEG_METHOD_EXIT ();
898 return validClass;
899 }
900
901 kumpf 1.1 Array <CIMName> SubscriptionRepository::getIndicationSubclasses (
902 const CIMNamespaceName & nameSpace,
903 const CIMName & indicationClassName) const
904 {
905 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
906 "SubscriptionRepository::getIndicationSubclasses");
907
908 Array <CIMName> indicationSubclasses;
909
910 try
911 {
912 indicationSubclasses = _repository->enumerateClassNames
913 (nameSpace, indicationClassName, true);
914 }
|
915 david.dillard 1.5 catch (const Exception &)
|
916 kumpf 1.1 {
917 PEG_METHOD_EXIT ();
918 throw;
919 }
920
921 indicationSubclasses.append (indicationClassName);
922
923 PEG_METHOD_EXIT ();
924 return indicationSubclasses;
925 }
926
927 Boolean SubscriptionRepository::reconcileFatalError (
928 const CIMInstance subscription)
929 {
930 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
931 "SubscriptionRepository::reconcileFatalError");
932
933 Boolean removeOrDisable = false;
934
935 //
936 // Get the value of the On Fatal Error Policy property
937 kumpf 1.1 //
938 CIMValue errorPolicyValue;
939 Uint16 onFatalErrorPolicy;
|
940 david.dillard 1.5 errorPolicyValue = subscription.getProperty
941 (subscription.findProperty
|
942 kumpf 1.1 (_PROPERTY_ONFATALERRORPOLICY)).getValue ();
943 errorPolicyValue.get (onFatalErrorPolicy);
944
945 if (errorPolicyValue == _ERRORPOLICY_DISABLE)
946 {
947 //
|
948 david.dillard 1.5 // FUTURE: Failure Trigger Time Interval should be allowed to pass
|
949 kumpf 1.1 // before implementing On Fatal Error Policy
950 //
951 // Set the Subscription State to disabled
952 //
953 _disableSubscription (subscription);
954 removeOrDisable = true;
955 }
956 else if (errorPolicyValue == _ERRORPOLICY_REMOVE)
957 {
958 //
|
959 david.dillard 1.5 // FUTURE: Failure Trigger Time Interval should be allowed to pass
|
960 kumpf 1.1 // before implementing On Fatal Error Policy
961 //
962 // Delete the subscription
963 //
964 _deleteSubscription (subscription);
965 removeOrDisable = true;
966 }
967
968 PEG_METHOD_EXIT ();
969 return removeOrDisable;
970 }
971
972 CIMClass SubscriptionRepository::getClass (
973 const CIMNamespaceName & nameSpaceName,
974 const CIMName & className,
975 Boolean localOnly,
976 Boolean includeQualifiers,
977 Boolean includeClassOrigin,
978 const CIMPropertyList & propertyList) const
979 {
|
980 carolann.graves 1.8 try
981 {
982 return _repository->getClass (nameSpaceName, className, localOnly,
983 includeQualifiers, includeClassOrigin, propertyList);
984 }
985 catch (const Exception & exception)
986 {
987 PEG_TRACE_STRING (TRC_DISCARDED_DATA, Tracer::LEVEL2,
988 "Exception caught trying to get class (" +
989 className.getString () + "): " +
990 exception.getMessage ());
991 throw;
992 }
|
993 kumpf 1.1 }
994
995 CIMInstance SubscriptionRepository::getInstance (
996 const CIMNamespaceName & nameSpace,
997 const CIMObjectPath & instanceName,
998 Boolean localOnly,
999 Boolean includeQualifiers,
1000 Boolean includeClassOrigin,
1001 const CIMPropertyList & propertyList)
1002 {
|
1003 david.dillard 1.5 return _repository->getInstance (nameSpace, instanceName, localOnly,
|
1004 kumpf 1.1 includeQualifiers, includeClassOrigin, propertyList);
1005 }
1006
1007 void SubscriptionRepository::modifyInstance (
1008 const CIMNamespaceName & nameSpace,
1009 const CIMInstance & modifiedInstance,
1010 Boolean includeQualifiers,
1011 const CIMPropertyList & propertyList)
1012 {
1013 _repository->modifyInstance (nameSpace, modifiedInstance,
1014 includeQualifiers, propertyList);
1015 }
1016
1017 void SubscriptionRepository::deleteInstance (
1018 const CIMNamespaceName & nameSpace,
1019 const CIMObjectPath & instanceName)
1020 {
1021 _repository->deleteInstance (nameSpace, instanceName);
1022 }
1023
1024 Array <CIMInstance> SubscriptionRepository::enumerateInstancesForClass (
1025 kumpf 1.1 const CIMNamespaceName & nameSpace,
1026 const CIMName & className,
1027 Boolean localOnly,
1028 Boolean includeQualifiers,
1029 Boolean includeClassOrigin,
1030 const CIMPropertyList & propertyList)
1031 {
1032 return _repository->enumerateInstancesForClass (nameSpace, className,
|
1033 kumpf 1.13 localOnly, includeQualifiers, includeClassOrigin, propertyList);
|
1034 kumpf 1.1 }
1035
1036 Array <CIMObjectPath> SubscriptionRepository::enumerateInstanceNamesForClass (
1037 const CIMNamespaceName & nameSpace,
|
1038 kumpf 1.13 const CIMName & className)
|
1039 kumpf 1.1 {
|
1040 kumpf 1.13 return _repository->enumerateInstanceNamesForClass(nameSpace, className);
|
1041 kumpf 1.1 }
1042
1043 void SubscriptionRepository::_disableSubscription (
1044 CIMInstance subscription)
1045 {
1046 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
1047 "SubscriptionRepository::_disableSubscription");
1048
1049 //
1050 // Create property list
1051 //
1052 CIMPropertyList propertyList;
1053 Array <CIMName> properties;
|
1054 w.otsuka 1.14 properties.append (PEGASUS_PROPERTYNAME_SUBSCRIPTION_STATE);
|
1055 kumpf 1.1 propertyList = CIMPropertyList (properties);
1056
1057 //
1058 // Set Time of Last State Change to current date time
1059 //
1060 CIMInstance instance = subscription;
1061 CIMDateTime currentDateTime = CIMDateTime::getCurrentDateTime ();
1062 if (instance.findProperty (_PROPERTY_LASTCHANGE) == PEG_NOT_FOUND)
1063 {
|
1064 david.dillard 1.5 instance.addProperty
|
1065 kumpf 1.1 (CIMProperty (_PROPERTY_LASTCHANGE, currentDateTime));
1066 }
|
1067 david.dillard 1.5 else
|
1068 kumpf 1.1 {
|
1069 david.dillard 1.5 CIMProperty lastChange = instance.getProperty
|
1070 kumpf 1.1 (instance.findProperty (_PROPERTY_LASTCHANGE));
1071 lastChange.setValue (CIMValue (currentDateTime));
1072 }
1073
1074 //
1075 // Set Subscription State to Disabled
1076 //
|
1077 david.dillard 1.5 CIMProperty state = instance.getProperty (instance.findProperty
|
1078 w.otsuka 1.14 (PEGASUS_PROPERTYNAME_SUBSCRIPTION_STATE));
1079 state.setValue (CIMValue (STATE_DISABLED));
|
1080 kumpf 1.1
1081 //
1082 // Modify the instance in the repository
1083 //
1084 try
1085 {
|
1086 david.dillard 1.5 _repository->modifyInstance
|
1087 kumpf 1.1 (subscription.getPath ().getNameSpace (),
1088 subscription, false, propertyList);
1089 }
1090 catch (Exception & exception)
1091 {
|
1092 david.dillard 1.5 PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2,
|
1093 kumpf 1.1 "Exception caught in attempting to disable a subscription: " +
1094 exception.getMessage ());
1095 }
1096
1097 PEG_METHOD_EXIT ();
1098 }
1099
1100 void SubscriptionRepository::_deleteSubscription (
1101 const CIMInstance subscription)
1102 {
1103 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
1104 "SubscriptionRepository::_deleteSubscription");
1105
1106 //
1107 // Delete subscription instance from repository
1108 //
1109 try
1110 {
|
1111 david.dillard 1.5 _repository->deleteInstance
1112 (subscription.getPath ().getNameSpace (),
|
1113 kumpf 1.1 subscription.getPath ());
1114 }
1115 catch (Exception & exception)
1116 {
|
1117 david.dillard 1.5 PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2,
|
1118 kumpf 1.1 "Exception caught in attempting to delete a subscription: " +
1119 exception.getMessage ());
1120 }
1121
1122 PEG_METHOD_EXIT ();
1123 }
1124
1125 PEGASUS_NAMESPACE_END
|