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