1 dave.sudlik 1.1 //%2006////////////////////////////////////////////////////////////////////////
2 //
3 // 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 // IBM Corp.; EMC Corporation, The Open Group.
7 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
9 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
11 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
13 //
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 //
21 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
22 dave.sudlik 1.1 // 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 //%/////////////////////////////////////////////////////////////////////////////
33
34 #include <Pegasus/Common/CIMError.h>
35 #include "CMPI_Version.h"
36
37 #include "CMPI_Error.h"
38 #include "CMPI_Ftabs.h"
39 #include "CMPI_String.h"
40
41 PEGASUS_USING_STD;
42 PEGASUS_NAMESPACE_BEGIN
43 dave.sudlik 1.1
44 extern "C"
45 {
46
47 CMPIError *newCMPIError(
48 const char* owner, const char* msgID, const char * msg,
49 const CMPIErrorSeverity sev, const CMPIErrorProbableCause pc,
50 const CMPIrc cimStatusCode)
51 {
52 // CMPIErrorSeverity (incorrectly) does not skip '1'
53 int tmpSev = sev;
54 if (tmpSev>0)
55 {
56 tmpSev++;
57 }
58 CIMError::PerceivedSeverityEnum pgSev = (CIMError::PerceivedSeverityEnum)tmpSev;
59 CIMError::ProbableCauseEnum pgPc = (CIMError::ProbableCauseEnum)pc;
60 CIMError::CIMStatusCodeEnum pgSc = (CIMError::CIMStatusCodeEnum)cimStatusCode;
61
62
63 CIMError *cer=new CIMError(owner, msgID, msg, pgSev, pgPc, pgSc);
64 dave.sudlik 1.1 return reinterpret_cast<CMPIError*>(new CMPI_Object(cer));
65 }
66
67 static CMPIError* errClone(const CMPIError* eErr, CMPIStatus* rc)
68 {
69 CIMError* cer=(CIMError*)eErr->hdl;
70 if (!cer)
71 {
72 if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
73 return NULL;
74 }
75 CIMError* cErr=new CIMError(*cer);
76 CMPI_Object* obj=new CMPI_Object(cErr);
77 obj->unlink();
78 CMPIError* neErr=reinterpret_cast<CMPIError*>(obj);
79 if (rc) CMSetStatus(rc,CMPI_RC_OK);
80 return neErr;
81 }
82
83 static CMPIStatus errRelease(CMPIError* eErr)
84 {
85 dave.sudlik 1.1 CIMError* cer=(CIMError*)eErr->hdl;
86 if (cer)
87 {
88 delete cer;
89 (reinterpret_cast<CMPI_Object*>(eErr))->unlinkAndDelete();
90 }
91 CMReturn(CMPI_RC_OK);
92 }
93
94 static CMPIErrorType errGetErrorType(const CMPIError* eErr, CMPIStatus* rc)
95 {
96 CIMError* cer=(CIMError*)eErr->hdl;
97 if (!cer)
98 {
99 if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
100 return UnknownErrorType;
101 }
102
103 CMPIBoolean notNull;
104 CIMError::ErrorTypeEnum pgErrorType;
105
106 dave.sudlik 1.1 try
107 {
108 notNull = cer->getErrorType(pgErrorType);
109 if (!notNull)
110 {
111 if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
112 return UnknownErrorType;
113 }
114 }
115 catch (...)
116 {
117 if (rc) CMSetStatus(rc, CMPI_RC_ERR_FAILED);
118 return UnknownErrorType;
119 }
120
121 if (rc) CMSetStatus(rc,CMPI_RC_OK);
122 return (CMPIErrorType)pgErrorType;
123 }
124
125 static CMPIString* errGetOtherErrorType(const CMPIError* eErr, CMPIStatus* rc)
126 {
127 dave.sudlik 1.1 CIMError* cer=(CIMError*)eErr->hdl;
128 if (!cer)
129 {
130 if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
131 return NULL;
132 }
133
134 CMPIBoolean notNull;
135 String pgOtherErrorType;
136
137 try
138 {
139 notNull = cer->getOtherErrorType(pgOtherErrorType);
140 if (!notNull)
141 {
142 if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
143 return NULL;
144 }
145 }
146 catch (...)
147 {
148 dave.sudlik 1.1 if (rc) CMSetStatus(rc, CMPI_RC_ERR_FAILED);
149 return NULL;
150 }
151
152 if (rc) CMSetStatus(rc,CMPI_RC_OK);
153 return string2CMPIString(pgOtherErrorType);
154 }
155
156 static CMPIString* errGetOwningEntity(const CMPIError* eErr, CMPIStatus* rc)
157 {
158 CIMError* cer=(CIMError*)eErr->hdl;
159 if (!cer)
160 {
161 if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
162 return NULL;
163 }
164
165 CMPIBoolean notNull;
166 String pgOwningEntity;
167
168 try
169 dave.sudlik 1.1 {
170 notNull = cer->getOwningEntity(pgOwningEntity);
171 if (!notNull)
172 {
173 if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
174 return NULL;
175 }
176 }
177 catch (...)
178 {
179 if (rc) CMSetStatus(rc, CMPI_RC_ERR_FAILED);
180 return NULL;
181 }
182
183 if (rc) CMSetStatus(rc,CMPI_RC_OK);
184 return string2CMPIString(pgOwningEntity);
185 }
186
187 static CMPIString* errGetMessageID(const CMPIError* eErr, CMPIStatus* rc)
188 {
189 CIMError* cer=(CIMError*)eErr->hdl;
190 dave.sudlik 1.1 if (!cer)
191 {
192 if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
193 return NULL;
194 }
195
196 CMPIBoolean notNull;
197 String pgMessageID;
198
199 try
200 {
201 notNull = cer->getMessageID(pgMessageID);
202 if (!notNull)
203 {
204 if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
205 return NULL;
206 }
207 }
208 catch (...)
209 {
210 if (rc) CMSetStatus(rc, CMPI_RC_ERR_FAILED);
211 dave.sudlik 1.1 return NULL;
212 }
213
214 if (rc) CMSetStatus(rc,CMPI_RC_OK);
215 return string2CMPIString(pgMessageID);
216 }
217
218 static CMPIString* errGetMessage(const CMPIError* eErr, CMPIStatus* rc)
219 {
220 CIMError* cer=(CIMError*)eErr->hdl;
221 if (!cer)
222 {
223 if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
224 return NULL;
225 }
226
227 CMPIBoolean notNull;
228 String pgMessage;
229
230 try
231 {
232 dave.sudlik 1.1 notNull = cer->getMessage(pgMessage);
233 if (!notNull)
234 {
235 if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
236 return NULL;
237 }
238 }
239 catch (...)
240 {
241 if (rc) CMSetStatus(rc, CMPI_RC_ERR_FAILED);
242 return NULL;
243 }
244
245 if (rc) CMSetStatus(rc,CMPI_RC_OK);
246 return string2CMPIString(pgMessage);
247 }
248
249 static CMPIErrorSeverity errGetPerceivedSeverity(const CMPIError* eErr, CMPIStatus* rc)
250 {
251 CIMError* cer=(CIMError*)eErr->hdl;
252 if (!cer)
253 dave.sudlik 1.1 {
254 if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
255 return ErrorSevUnknown;
256 }
257
258 CMPIBoolean notNull;
259 CIMError::PerceivedSeverityEnum pgPerceivedSeverity;
260
261 try
262 {
263 notNull = cer->getPerceivedSeverity(pgPerceivedSeverity);
264 if (!notNull)
265 {
266 if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
267 return ErrorSevUnknown;
268 }
269 }
270 catch (...)
271 {
272 if (rc) CMSetStatus(rc, CMPI_RC_ERR_FAILED);
273 return ErrorSevUnknown;
274 dave.sudlik 1.1 }
275
276 if (rc) CMSetStatus(rc,CMPI_RC_OK);
277 // CMPIErrorSeverity (incorrectly) does not skip '1'
278 int tmpSev = pgPerceivedSeverity;
279 if (tmpSev>1)
280 {
281 tmpSev--;
282 }
283 return (CMPIErrorSeverity)tmpSev;
284 }
285
286 static CMPIErrorProbableCause errGetProbableCause(
287 const CMPIError* eErr, CMPIStatus* rc)
288 {
289 CIMError* cer=(CIMError*)eErr->hdl;
290 if (!cer)
291 {
292 if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
293 return ErrorProbCauseUnknown;
294 }
295 dave.sudlik 1.1
296 CMPIBoolean notNull;
297 CIMError::ProbableCauseEnum pgProbableCause;
298
299 try
300 {
301 notNull = cer->getProbableCause(pgProbableCause);
302 if (!notNull)
303 {
304 if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
305 return ErrorProbCauseUnknown;
306 }
307 }
308 catch (...)
309 {
310 if (rc) CMSetStatus(rc, CMPI_RC_ERR_FAILED);
311 return ErrorProbCauseUnknown;
312 }
313
314 if (rc) CMSetStatus(rc,CMPI_RC_OK);
315 return (CMPIErrorProbableCause)pgProbableCause;
316 dave.sudlik 1.1 }
317
318 static CMPIString* errGetProbableCauseDescription(
319 const CMPIError* eErr, CMPIStatus* rc)
320 {
321 CIMError* cer=(CIMError*)eErr->hdl;
322 if (!cer)
323 {
324 if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
325 return NULL;
326 }
327
328 CMPIBoolean notNull;
329 String pgProbCauseDesc;
330
331 try
332 {
333 notNull = cer->getProbableCauseDescription(pgProbCauseDesc);
334 if (!notNull)
335 {
336 if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
337 dave.sudlik 1.1 return NULL;
338 }
339 }
340 catch (...)
341 {
342 if (rc) CMSetStatus(rc, CMPI_RC_ERR_FAILED);
343 return NULL;
344 }
345
346 if (rc) CMSetStatus(rc,CMPI_RC_OK);
347 return string2CMPIString(pgProbCauseDesc);
348 }
349
350 static CMPIArray* errGetRecommendedActions(
351 const CMPIError* eErr, CMPIStatus* rc)
352 {
353 CIMError* cer=(CIMError*)eErr->hdl;
354 if (!cer)
355 {
356 if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
357 return NULL;
358 dave.sudlik 1.1 }
359
360 CMPIBoolean notNull;
361 Array<String> pgRecommendedActions;
362
363 try
364 {
365 notNull = cer->getRecommendedActions(pgRecommendedActions);
366 if (!notNull)
367 {
368 if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
369 return NULL;
370 }
371 }
372 catch (...)
373 {
374 if (rc) CMSetStatus(rc, CMPI_RC_ERR_FAILED);
375 return NULL;
376 }
377
378 CMPIUint32 arrSize = pgRecommendedActions.size();
379 dave.sudlik 1.1 CMPIData *dta=new CMPIData[arrSize+1];
380 // first element reserved for type and size
381 dta->type=CMPI_string;
382 dta->value.uint32=arrSize;
383 for (unsigned int i=1; i<=arrSize; i++) {
384 dta[i].type=CMPI_string;
385 dta[i].state=CMPI_goodValue;
386 String s = pgRecommendedActions[i-1];
387 dta[i].value.string=string2CMPIString(s);
388 }
389 if (rc) CMSetStatus(rc,CMPI_RC_OK);
390 return reinterpret_cast<CMPIArray*>(new CMPI_Object(dta));
391 }
392
393 static CMPIString* errGetErrorSource(const CMPIError* eErr, CMPIStatus* rc)
394 {
395 CIMError* cer=(CIMError*)eErr->hdl;
396 if (!cer)
397 {
398 if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
399 return NULL;
400 dave.sudlik 1.1 }
401
402 CMPIBoolean notNull;
403 String pgErrorSource;
404
405 try
406 {
407 notNull = cer->getErrorSource(pgErrorSource);
408 if (!notNull)
409 {
410 if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
411 return NULL;
412 }
413 }
414 catch (...)
415 {
416 if (rc) CMSetStatus(rc, CMPI_RC_ERR_FAILED);
417 return NULL;
418 }
419
420 if (rc) CMSetStatus(rc,CMPI_RC_OK);
421 dave.sudlik 1.1 return string2CMPIString(pgErrorSource);
422 }
423
424 static CMPIErrorSrcFormat errGetErrorSourceFormat(
425 const CMPIError* eErr, CMPIStatus* rc)
426 {
427 CIMError* cer=(CIMError*)eErr->hdl;
428 if (!cer)
429 {
430 if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
431 return CMPIErrSrcUnknown;
432 }
433
434 CMPIBoolean notNull;
435 CIMError::ErrorSourceFormatEnum pgErrorSourceFormat;
436
437 try
438 {
439 notNull = cer->getErrorSourceFormat(pgErrorSourceFormat);
440 if (!notNull)
441 {
442 dave.sudlik 1.1 if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
443 return CMPIErrSrcUnknown;
444 }
445 }
446 catch (...)
447 {
448 if (rc) CMSetStatus(rc, CMPI_RC_ERR_FAILED);
449 return CMPIErrSrcUnknown;
450 }
451
452 if (rc) CMSetStatus(rc,CMPI_RC_OK);
453 return (CMPIErrorSrcFormat)pgErrorSourceFormat;
454 }
455
456 static CMPIString* errGetOtherErrorSourceFormat(
457 const CMPIError* eErr, CMPIStatus* rc)
458 {
459 CIMError* cer=(CIMError*)eErr->hdl;
460 if (!cer)
461 {
462 if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
463 dave.sudlik 1.1 return NULL;
464 }
465
466 CMPIBoolean notNull;
467 String pgOtherErrorSourceFormat;
468
469 try
470 {
471 notNull = cer->getOtherErrorSourceFormat(pgOtherErrorSourceFormat);
472 if (!notNull)
473 {
474 if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
475 return NULL;
476 }
477 }
478 catch (...)
479 {
480 if (rc) CMSetStatus(rc, CMPI_RC_ERR_FAILED);
481 return NULL;
482 }
483
484 dave.sudlik 1.1 if (rc) CMSetStatus(rc,CMPI_RC_OK);
485 return string2CMPIString(pgOtherErrorSourceFormat);
486 }
487
488 static CMPIrc errGetCIMStatusCode(const CMPIError* eErr, CMPIStatus* rc)
489 {
490 CIMError* cer=(CIMError*)eErr->hdl;
491 if (!cer)
492 {
493 if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
494 return CMPI_RC_ERR_INVALID_PARAMETER;
495 }
496
497 CMPIBoolean notNull;
498 CIMError::CIMStatusCodeEnum pgCIMStatusCode;
499
500 try
501 {
502 notNull = cer->getCIMStatusCode(pgCIMStatusCode);
503 if (!notNull)
504 {
505 dave.sudlik 1.1 if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
506 return CMPI_RC_ERR_INVALID_PARAMETER;
507 }
508 }
509 catch (...)
510 {
511 if (rc) CMSetStatus(rc, CMPI_RC_ERR_FAILED);
512 return CMPI_RC_ERR_FAILED;
513 }
514
515 if (rc) CMSetStatus(rc,CMPI_RC_OK);
516 return (CMPIrc)pgCIMStatusCode;
517 }
518
519 static CMPIString* errGetCIMStatusCodeDescription(
520 const CMPIError* eErr, CMPIStatus* rc)
521 {
522 CIMError* cer=(CIMError*)eErr->hdl;
523 if (!cer)
524 {
525 if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
526 dave.sudlik 1.1 return NULL;
527 }
528
529 CMPIBoolean notNull;
530 String pgCIMStatusCodeDescription;
531
532 try
533 {
534 notNull = cer->getCIMStatusCodeDescription(
535 pgCIMStatusCodeDescription);
536 if (!notNull)
537 {
538 if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
539 return NULL;
540 }
541 }
542 catch (...)
543 {
544 if (rc) CMSetStatus(rc, CMPI_RC_ERR_FAILED);
545 return NULL;
546 }
547 dave.sudlik 1.1
548 if (rc) CMSetStatus(rc,CMPI_RC_OK);
549 return string2CMPIString(pgCIMStatusCodeDescription);
550 }
551
552 static CMPIArray* errGetMessageArguments(
553 const CMPIError* eErr, CMPIStatus* rc)
554 {
555 CIMError* cer=(CIMError*)eErr->hdl;
556 if (!cer)
557 {
558 if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
559 return NULL;
560 }
561
562 CMPIBoolean notNull;
563 Array<String> pgMessageArguments;
564
565 try
566 {
567 notNull = cer->getMessageArguments(pgMessageArguments);
568 dave.sudlik 1.1 if (!notNull)
569 {
570 if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
571 return NULL;
572 }
573 }
574 catch (...)
575 {
576 if (rc) CMSetStatus(rc, CMPI_RC_ERR_FAILED);
577 return NULL;
578 }
579
580 CMPIUint32 arrSize = pgMessageArguments.size();
581 CMPIData *dta=new CMPIData[arrSize+1];
582 // first element reserved for type and size
583 dta->type=CMPI_string;
584 dta->value.uint32=arrSize;
585 for (unsigned int i=1; i<=arrSize; i++) {
586 dta[i].type=CMPI_string;
587 dta[i].state=CMPI_goodValue;
588 String s = pgMessageArguments[i-1];
589 dave.sudlik 1.1 dta[i].value.string=string2CMPIString(s);
590 }
591 if (rc) CMSetStatus(rc,CMPI_RC_OK);
592 return reinterpret_cast<CMPIArray*>(new CMPI_Object(dta));
593 }
594
595 static CMPIStatus errSetErrorType(
596 CMPIError* eErr, const CMPIErrorType errorType)
597 {
598 CIMError* cer=(CIMError*)eErr->hdl;
599 if (!cer)
600 {
601 CMReturn(CMPI_RC_ERR_INVALID_PARAMETER);
602 }
603
604 CIMError::ErrorTypeEnum pgErrorType;
605 pgErrorType = (CIMError::ErrorTypeEnum)errorType;
606
607 try
608 {
609 cer->setErrorType(pgErrorType);
610 dave.sudlik 1.1 }
611 catch (...)
612 {
613 CMReturn(CMPI_RC_ERR_FAILED);
614 }
615
616 CMReturn(CMPI_RC_OK);
617 }
618
619 static CMPIStatus errSetOtherErrorType(
620 CMPIError* eErr, const char* otherErrorType)
621 {
622 CIMError* cer=(CIMError*)eErr->hdl;
623 if (!cer)
624 {
625 CMReturn(CMPI_RC_ERR_INVALID_PARAMETER);
626 }
627
628 String pgOtherErrorType(otherErrorType);
629
630 try
631 dave.sudlik 1.1 {
632 cer->setOtherErrorType(pgOtherErrorType);
633 }
634 catch (...)
635 {
636 CMReturn(CMPI_RC_ERR_FAILED);
637 }
638
639 CMReturn(CMPI_RC_OK);
640 }
641
642 static CMPIStatus errSetProbableCauseDescription(
643 CMPIError* eErr, const char* probableCauseDescription)
644 {
645 CIMError* cer=(CIMError*)eErr->hdl;
646 if (!cer)
647 {
648 CMReturn(CMPI_RC_ERR_INVALID_PARAMETER);
649 }
650
651 String pgProbableCauseDescription(probableCauseDescription);
652 dave.sudlik 1.1
653 try
654 {
655 cer->setProbableCauseDescription(pgProbableCauseDescription);
656 }
657 catch (...)
658 {
659 CMReturn(CMPI_RC_ERR_FAILED);
660 }
661
662 CMReturn(CMPI_RC_OK);
663 }
664
665 static CMPIStatus errSetRecommendedActions(
666 CMPIError* eErr, const CMPIArray* recommendedActions)
667 {
668 CIMError* cer=(CIMError*)eErr->hdl;
669 if (!cer)
670 {
671 CMReturn(CMPI_RC_ERR_INVALID_PARAMETER);
672 }
673 dave.sudlik 1.1
674 Array<String> pgRecommendedActions;
675
676 CMPIData* dta=(CMPIData*)recommendedActions->hdl;
677 if (!dta)
678 {
679 CMReturn(CMPI_RC_ERR_INVALID_PARAMETER);
680 }
681
682 try
683 {
684 for (unsigned int i=0; i<dta->value.uint32; i++)
685 {
686 CMPIData arrEl;
687 const char * arrElStr;
688 CMPIStatus rc = {CMPI_RC_OK,NULL};
689
690 if (dta[i].type!=CMPI_string)
691 {
692 CMReturn(CMPI_RC_ERR_INVALID_PARAMETER);
693 }
694 dave.sudlik 1.1
695 arrEl = CMGetArrayElementAt(recommendedActions, i, &rc);
696 if (rc.rc != CMPI_RC_OK)
697 {
698 return rc;
699 }
700
701 arrElStr = CMGetCharsPtr(arrEl.value.string, &rc);
702 if (rc.rc != CMPI_RC_OK)
703 {
704 return rc;
705 }
706
707 pgRecommendedActions.append(String(arrElStr));
708 if (rc.rc != CMPI_RC_OK)
709 {
710 return rc;
711 }
712 }
713
714 cer->setRecommendedActions(pgRecommendedActions);
715 dave.sudlik 1.1 }
716 catch (...)
717 {
718 CMReturn(CMPI_RC_ERR_FAILED);
719 }
720
721 CMReturn(CMPI_RC_OK);
722 }
723
724 static CMPIStatus errSetErrorSource(
725 CMPIError* eErr, const char* errorSource)
726 {
727 CIMError* cer=(CIMError*)eErr->hdl;
728 if (!cer)
729 {
730 CMReturn(CMPI_RC_ERR_INVALID_PARAMETER);
731 }
732
733 String pgErrorSource(errorSource);
734
735 try
736 dave.sudlik 1.1 {
737 cer->setErrorSource(pgErrorSource);
738 }
739 catch (...)
740 {
741 CMReturn(CMPI_RC_ERR_FAILED);
742 }
743
744 CMReturn(CMPI_RC_OK);
745 }
746
747 static CMPIStatus errSetErrorSourceFormat(
748 CMPIError* eErr, const CMPIErrorSrcFormat errorSrcFormat)
749 {
750 CIMError* cer=(CIMError*)eErr->hdl;
751 if (!cer)
752 {
753 CMReturn(CMPI_RC_ERR_INVALID_PARAMETER);
754 }
755
756 CIMError::ErrorSourceFormatEnum pgErrorSourceFormat;
757 dave.sudlik 1.1 pgErrorSourceFormat = (CIMError::ErrorSourceFormatEnum)errorSrcFormat;
758
759 try
760 {
761 cer->setErrorSourceFormat(pgErrorSourceFormat);
762 }
763 catch (...)
764 {
765 CMReturn(CMPI_RC_ERR_FAILED);
766 }
767
768 CMReturn(CMPI_RC_OK);
769 }
770
771 static CMPIStatus errSetOtherErrorSourceFormat(
772 CMPIError* eErr, const char* otherErrorSourceFormat)
773 {
774 CIMError* cer=(CIMError*)eErr->hdl;
775 if (!cer)
776 {
777 CMReturn(CMPI_RC_ERR_INVALID_PARAMETER);
778 dave.sudlik 1.1 }
779
780 String pgOtherErrorSourceFormat(otherErrorSourceFormat);
781
782 try
783 {
784 cer->setOtherErrorSourceFormat(pgOtherErrorSourceFormat);
785 }
786 catch (...)
787 {
788 CMReturn(CMPI_RC_ERR_FAILED);
789 }
790
791 CMReturn(CMPI_RC_OK);
792 }
793
794 static CMPIStatus errSetCIMStatusCode(
795 CMPIError* eErr, const CMPIrc cimStatusCode)
796 {
797 CIMError* cer=(CIMError*)eErr->hdl;
798 if (!cer)
799 dave.sudlik 1.1 {
800 CMReturn(CMPI_RC_ERR_INVALID_PARAMETER);
801 }
802
803 CIMError::CIMStatusCodeEnum pgCIMStatusCode;
804 pgCIMStatusCode = (CIMError::CIMStatusCodeEnum)cimStatusCode;
805
806 try
807 {
808 cer->setCIMStatusCode(pgCIMStatusCode);
809 }
810 catch (...)
811 {
812 CMReturn(CMPI_RC_ERR_FAILED);
813 }
814
815 CMReturn(CMPI_RC_OK);
816 }
817
818 static CMPIStatus errSetCIMStatusCodeDescription(
819 CMPIError* eErr, const char* cimStatusCodeDescription)
820 dave.sudlik 1.1 {
821 CIMError* cer=(CIMError*)eErr->hdl;
822 if (!cer)
823 {
824 CMReturn(CMPI_RC_ERR_INVALID_PARAMETER);
825 }
826
827 String pgCIMStatusCodeDescription(cimStatusCodeDescription);
828
829 try
830 {
831 cer->setCIMStatusCodeDescription(pgCIMStatusCodeDescription);
832 }
833 catch (...)
834 {
835 CMReturn(CMPI_RC_ERR_FAILED);
836 }
837
838 CMReturn(CMPI_RC_OK);
839 }
840
841 dave.sudlik 1.1 static CMPIStatus errSetMessageArguments(
842 CMPIError* eErr, CMPIArray* messageArguments)
843 {
844 CIMError* cer=(CIMError*)eErr->hdl;
845 if (!cer)
846 {
847 CMReturn(CMPI_RC_ERR_INVALID_PARAMETER);
848 }
849
850 Array<String> pgMessageArguments;
851
852 CMPIData* dta=(CMPIData*)messageArguments->hdl;
853 if (!dta)
854 {
855 CMReturn(CMPI_RC_ERR_INVALID_PARAMETER);
856 }
857
858 try
859 {
860 for (unsigned int i=0; i<dta->value.uint32; i++)
861 {
862 dave.sudlik 1.1 CMPIData arrEl;
863 const char * arrElStr;
864 CMPIStatus rc = {CMPI_RC_OK,NULL};
865
866 if (dta[i].type!=CMPI_string)
867 {
868 CMReturn(CMPI_RC_ERR_INVALID_PARAMETER);
869 }
870
871 arrEl = CMGetArrayElementAt(messageArguments, i, &rc);
872 if (rc.rc != CMPI_RC_OK)
873 {
874 return rc;
875 }
876
877 arrElStr = CMGetCharsPtr(arrEl.value.string, &rc);
878 if (rc.rc != CMPI_RC_OK)
879 {
880 return rc;
881 }
882
883 dave.sudlik 1.1 pgMessageArguments.append(String(arrElStr));
884 if (rc.rc != CMPI_RC_OK)
885 {
886 return rc;
887 }
888 }
889
890 cer->setMessageArguments(pgMessageArguments);
891 }
892 catch (...)
893 {
894 CMReturn(CMPI_RC_ERR_FAILED);
895 }
896
897 CMReturn(CMPI_RC_OK);
898 }
899
900 }
901
902 static CMPIErrorFT error_FT={
903 CMPICurrentVersion,
904 dave.sudlik 1.1 errClone,
905 errRelease,
906 errGetErrorType,
907 errGetOtherErrorType,
908 errGetOwningEntity,
909 errGetMessageID,
910 errGetMessage,
911 errGetPerceivedSeverity,
912 errGetProbableCause,
913 errGetProbableCauseDescription,
914 errGetRecommendedActions,
915 errGetErrorSource,
916 errGetErrorSourceFormat,
917 errGetOtherErrorSourceFormat,
918 errGetCIMStatusCode,
919 errGetCIMStatusCodeDescription,
920 errGetMessageArguments,
921 errSetErrorType,
922 errSetOtherErrorType,
923 errSetProbableCauseDescription,
924 errSetRecommendedActions,
925 dave.sudlik 1.1 errSetErrorSource,
926 errSetErrorSourceFormat,
927 errSetOtherErrorSourceFormat,
928 errSetCIMStatusCode,
929 errSetCIMStatusCodeDescription,
930 errSetMessageArguments,
931 };
932
933 CMPIErrorFT *CMPI_Error_Ftab=&error_FT;
934
935 PEGASUS_NAMESPACE_END
936
|