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