1 23 package com.sun.enterprise.tools.verifier.tests.dd; 24 25 import com.sun.enterprise.deployment.*; 26 import tools.com.sun.enterprise.util.XMLValidationHandler; 27 import com.sun.enterprise.tools.verifier.*; 28 import com.sun.enterprise.tools.verifier.tests.*; 29 30 import java.io.*; 31 32 import javax.xml.parsers.*; 33 import org.w3c.dom.*; 34 import org.xml.sax.*; 35 36 import java.util.logging.Level ; 37 import java.util.logging.Logger ; 38 import com.sun.enterprise.logging.LogDomains; 39 40 41 50 51 public class ParseDD extends VerifierTest { 52 DocumentBuilder builder = null; 53 Result result; 54 private com.sun.enterprise.util.LocalStringManagerImpl smh; 55 boolean oneFailed = false; 56 private static String EJB = "EJB Deployment Descriptor"; 57 private static String APPCLIENT = "App Client Deployment Descriptor"; 58 private static String CONNECTOR = "Connector Deployment Descriptor"; 59 private static String WEB = "Web Deployment Descriptor"; 60 61 private static Logger logger = LogDomains.getLogger(LogDomains.AVK_VERIFIER_LOGGER); 63 64 65 71 72 public ParseDD () { 73 result = getInitializedResult(); 74 smh = StringManagerHelper.getLocalStringsManager(); 75 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 76 try { 77 factory.setAttribute("http://apache.org/xml/features/allow-java-encodings", new Boolean (true)); 78 builder = factory.newDocumentBuilder(); 79 EntityResolver dh = new XMLValidationHandler(false); 80 builder.setEntityResolver(dh); 81 } catch (ParserConfigurationException e) { 82 logger.log(Level.SEVERE, getClass().getName() + ".Exception", 83 new Object [] {e.toString()}); 84 result.failed(smh.getLocalString 85 (getClass().getName() + ".Exception", 86 "Exception : {0}", 87 new Object [] {e.toString()})); 88 }catch (Exception e) { 89 logger.log(Level.SEVERE,getClass().getName() + ".Exception", 90 new Object [] {e.toString()}); 91 result.failed(smh.getLocalString 92 (getClass().getName() + ".Exception", 93 "Exception : {0}", 94 new Object [] {e.toString()})); 95 } 96 } 97 98 99 105 public Result validateConnectorDescriptor(InputStream source) 106 { 107 Document document = null; 108 result = getInitializedResult(); 109 result.setComponentName(EJB); 110 NodeList nodeList = null; 111 try { 112 if (source == null) { 113 logger.log(Level.SEVERE,getClass().getName() + ".srcnull"); 114 result.failed 115 (smh.getLocalString 116 (getClass().getName() + ".NoIO", 117 "no InputStream found", 118 new Object [] {})); 119 return result; 120 } 121 else { 122 document = builder.parse(source); 123 124 nodeList = document.getElementsByTagName("license-required"); 126 if (nodeList != null) { 127 for (int i = 0; i < nodeList.getLength(); i++) { 128 String value = ((Text)nodeList.item(i).getFirstChild()).getNodeValue(); 129 if (!value.equals("true") 130 && !value.equals("false")) { 131 result.failed 132 (smh.getLocalString 133 (getClass().getName() + ".failedLicense", 134 "[Connector] license-required cannot be {0}. It has to be either true or false.", 135 new Object [] {value})); 136 oneFailed = true; 137 } 138 else { 139 result.addGoodDetails 140 (smh.getLocalString 141 (getClass().getName() + ".passedLicense", 142 "PASSED[Connector] : license-required is {0}.", 143 new Object [] {value})); 144 } 145 } 146 } 147 148 nodeList = document.getElementsByTagName("reauthentication-support"); 150 if (nodeList != null) { 151 for (int i = 0; i < nodeList.getLength(); i++) { 152 String value = ((Text)nodeList.item(i).getFirstChild()).getNodeValue(); 153 if (!value.equals("true") 154 && !value.equals("false")) { 155 result.failed 156 (smh.getLocalString 157 (getClass().getName() + ".failedReauthenticationSupport", 158 "[Connector] reauthentication-support cannot be {0}. It has to be either true or false.", 159 new Object [] {value})); 160 oneFailed = true; 161 } 162 else { 163 result.addGoodDetails 164 (smh.getLocalString 165 (getClass().getName() + ".passedReauthenticationSupport", 166 "PASSED [Connector] : reauthentication-support is {0}.", 167 new Object [] {value})); 168 } 169 } 170 } 171 172 nodeList = document.getElementsByTagName("transaction-support"); 174 if (nodeList != null) { 175 for (int i = 0; i < nodeList.getLength(); i++) { 176 String value = ((Text)nodeList.item(i).getFirstChild()).getNodeValue(); 177 if (!value.equals("NoTransaction") 178 && !value.equals("LocalTransaction") 179 && !value.equals("XATransaction")) { 180 result.failed 181 (smh.getLocalString 182 (getClass().getName() + ".failedTransactionSupport", 183 "[Connector]transaction-support cannot be {0}. It has to be either NoTransaction or LocalTransaction or XATransaction.", 184 new Object [] {value})); 185 oneFailed = true; 186 } 187 else { 188 result.addGoodDetails 189 (smh.getLocalString 190 (getClass().getName() + ".passedTransactionSupport", 191 "PASSED [Connector] : transaction-support is {0}.", 192 new Object [] {value})); 193 } 194 } 195 } 196 if (result.getStatus() != Result.FAILED) { 197 result.setStatus(Result.PASSED); 198 } 199 return result; 200 } 201 } catch (IOException e) { 202 logger.log(Level.SEVERE,getClass().getName() + ".Exception", 203 new Object [] {e.toString()}); 204 result.failed 205 (smh.getLocalString 206 (getClass().getName() + ".Exception", 207 "Exception : {0}", 208 new Object [] {e.toString()})); 209 return result; 210 } catch (SAXException e) { 211 logger.log(Level.SEVERE,getClass().getName() + ".Exception", 212 new Object [] {e.toString()}); 213 result.failed 214 (smh.getLocalString 215 (getClass().getName() + ".Exception", 216 "Exception : {0}", 217 new Object [] {e.toString()})); 218 return result; 219 } catch (Exception e) { 220 logger.log(Level.SEVERE,getClass().getName() + ".Exception", 221 new Object [] {e.toString()}); 222 result.failed 223 (smh.getLocalString 224 (getClass().getName() + ".Exception", 225 "Exception : {0}", 226 new Object [] {e.toString()})); 227 return result; 228 } 229 } 230 231 237 public Result validateAppClientDescriptor(InputStream source) 238 { 239 Document document = null; 240 result = getInitializedResult(); 241 result.setComponentName(EJB); 242 NodeList nodeList = null; 243 try { 244 if (source == null) { 245 logger.log(Level.SEVERE,getClass().getName() + ".srcnull"); 246 result.failed 247 (smh.getLocalString 248 (getClass().getName() + ".NoIO", 249 "no InputStream found", 250 new Object [] {})); 251 return result; 252 } 253 else { 254 document = builder.parse(source); 255 256 nodeList = document.getElementsByTagName("ejb-ref-type"); 258 if (nodeList != null) { 259 for (int i = 0; i < nodeList.getLength(); i++) { 260 String ejbRefTypeValue = ((Text)nodeList.item(i).getFirstChild()).getNodeValue(); 261 if (!ejbRefTypeValue.equals(EjbSessionDescriptor.TYPE) 262 && !ejbRefTypeValue.equals(EjbEntityDescriptor.TYPE)) { 263 result.failed 264 (smh.getLocalString 265 (getClass().getName() + ".failedAppClientEjbRefType", 266 "[App Client] ejb-ref-type cannot be {0}. It has to be either Entity or Session.", 267 new Object [] {ejbRefTypeValue})); 268 oneFailed = true; 269 } 270 else { 271 result.addGoodDetails 272 (smh.getLocalString 273 (getClass().getName() + ".passedAppClientEjbRefType", 274 "PASSED [App Client] : ejb-ref-type is {0}.", 275 new Object [] {ejbRefTypeValue})); 276 } 277 } 278 } 279 280 nodeList = document.getElementsByTagName("res-auth"); 282 if (nodeList != null) { 283 for (int i = 0; i < nodeList.getLength(); i++) { 284 String value = ((Text)nodeList.item(i).getFirstChild()).getNodeValue(); 285 if (!value.equals("Application") 286 && !value.equals("Container")) { 287 result.failed 288 (smh.getLocalString 289 (getClass().getName() + ".failedAppClientResAuth", 290 "[App Client] res-auth cannot be {0}. It has to be either Application or Container", 291 new Object [] {value})); 292 oneFailed = true; 293 } 294 else { 295 result.addGoodDetails 296 (smh.getLocalString 297 (getClass().getName() + ".passedAppClientResAuth", 298 "PASSED [App Client] : res-auth is {0}.", 299 new Object [] {value})); 300 } 301 } 302 } 303 304 nodeList = document.getElementsByTagName("res-sharing-scope"); 306 if (nodeList != null) { 307 for (int i = 0; i < nodeList.getLength(); i++) { 308 String value = ((Text)nodeList.item(i).getFirstChild()).getNodeValue(); 309 if (!value.equals("Shareable") 310 && !value.equals("Unshareable")) { 311 result.failed 312 (smh.getLocalString 313 (getClass().getName() + ".failedAppClientResSharingScope", 314 "[App Client] res-sharing-scope cannot be {0}. It has to be either Shareable or Unshareable", 315 new Object [] {value})); 316 oneFailed = true; 317 } 318 else { 319 result.addGoodDetails 320 (smh.getLocalString 321 (getClass().getName() + ".passedAppClientResSharingScope", 322 "PASSED [App Client] : res-sharing-scope is {0}.", 323 new Object [] {value})); 324 } 325 } 326 } 327 328 if (result.getStatus() != Result.FAILED) { 329 result.setStatus(Result.PASSED); 330 } 331 return result; 332 } 333 } catch (IOException e) { 334 logger.log(Level.SEVERE, getClass().getName() + ".Exception", 335 new Object [] {e.toString()}); 336 result.failed 337 (smh.getLocalString 338 (getClass().getName() + ".Exception", 339 "Exception : {0}", 340 new Object [] {e.toString()})); 341 return result; 342 } catch (SAXException e) { 343 logger.log(Level.SEVERE,getClass().getName() + ".Exception", 344 new Object [] {e.toString()}); 345 result.failed 346 (smh.getLocalString 347 (getClass().getName() + ".Exception", 348 "Exception : {0}", 349 new Object [] {e.toString()})); 350 return result; 351 } catch (Exception e) { 352 logger.log(Level.SEVERE,getClass().getName() + ".Exception", 353 new Object [] {e.toString()}); 354 result.failed 355 (smh.getLocalString 356 (getClass().getName() + ".Exception", 357 "Exception : {0}", 358 new Object [] {e.toString()})); 359 return result; 360 } 361 } 362 363 369 public Result validateWebDescriptor(InputStream source) 370 { 371 Document document = null; 372 result = getInitializedResult(); 373 result.setComponentName(EJB); 374 NodeList nodeList = null; 375 try { 376 if (source == null) { 377 logger.log(Level.SEVERE,getClass().getName() + ".srcnull"); 378 result.failed 379 (smh.getLocalString 380 (getClass().getName() + ".NoIO", 381 "no InputStream found", 382 new Object [] {})); 383 return result; 384 } 385 else { 386 document = builder.parse(source); 387 388 nodeList = document.getElementsByTagName("ejb-ref-type"); 390 if (nodeList != null) { 391 for (int i = 0; i < nodeList.getLength(); i++) { 392 String ejbRefTypeValue = ((Text)nodeList.item(i).getFirstChild()).getNodeValue(); 393 if (!ejbRefTypeValue.equals(EjbSessionDescriptor.TYPE) 394 && !ejbRefTypeValue.equals(EjbEntityDescriptor.TYPE)) { 395 result.failed 396 (smh.getLocalString 397 (getClass().getName() + ".failedWebEjbRefType", 398 "[Web] ejb-ref-type cannot be {0}. It has to be either Entity or Session.", 399 new Object [] {ejbRefTypeValue})); 400 oneFailed = true; 401 } 402 else { 403 result.addGoodDetails 404 (smh.getLocalString 405 (getClass().getName() + ".passedWebEjbRefType", 406 "PASSED [Web] : ejb-ref-type is {0}.", 407 new Object [] {ejbRefTypeValue})); 408 } 409 } 410 } 411 412 nodeList = document.getElementsByTagName("res-auth"); 414 if (nodeList != null) { 415 for (int i = 0; i < nodeList.getLength(); i++) { 416 String value = ((Text)nodeList.item(i).getFirstChild()).getNodeValue(); 417 if (!value.equals("Application") 418 && !value.equals("Container")) { 419 result.failed 420 (smh.getLocalString 421 (getClass().getName() + ".failedWebResAuth", 422 "[Web] res-auth cannot be {0}. It has to be either Application or Container", 423 new Object [] {value})); 424 oneFailed = true; 425 } 426 else { 427 result.addGoodDetails 428 (smh.getLocalString 429 (getClass().getName() + ".passedWebResAuth", 430 "PASSED[Web] : res-auth is {0}.", 431 new Object [] {value})); 432 } 433 } 434 } 435 436 nodeList = document.getElementsByTagName("res-sharing-scope"); 438 if (nodeList != null) { 439 for (int i = 0; i < nodeList.getLength(); i++) { 440 String value = ((Text)nodeList.item(i).getFirstChild()).getNodeValue(); 441 if (!value.equals("Shareable") 442 && !value.equals("Unshareable")) { 443 result.failed 444 (smh.getLocalString 445 (getClass().getName() + ".failedWebResSharingScope", 446 "[Web] res-sharing-scope cannot be {0}. It has to be either Shareable or Unshareable", 447 new Object [] {value})); 448 oneFailed = true; 449 } 450 else { 451 result.addGoodDetails 452 (smh.getLocalString 453 (getClass().getName() + ".passedWebResSharingScope", 454 "PASSED [Web] : res-sharing-scope is {0}.", 455 new Object [] {value})); 456 } 457 } 458 } 459 460 if (result.getStatus() != Result.FAILED) { 461 result.setStatus(Result.PASSED); 462 } 463 return result; 464 } 465 } catch (IOException e) { 466 logger.log(Level.SEVERE, getClass().getName() + ".Exception", 467 new Object [] {e.toString()}); 468 result.failed 469 (smh.getLocalString 470 (getClass().getName() + ".Exception", 471 "Exception : {0}", 472 new Object [] {e.toString()})); 473 return result; 474 } catch (SAXException e) { 475 logger.log(Level.SEVERE, getClass().getName() + ".Exception", 476 new Object [] {e.toString()}); 477 result.failed 478 (smh.getLocalString 479 (getClass().getName() + ".Exception", 480 "Exception : {0}", 481 new Object [] {e.toString()})); 482 return result; 483 } catch (Exception e) { 484 logger.log(Level.SEVERE, getClass().getName() + ".Exception", 485 new Object [] {e.toString()}); 486 result.failed 487 (smh.getLocalString 488 (getClass().getName() + ".Exception", 489 "Exception : {0}", 490 new Object [] {e.toString()})); 491 return result; 492 } 493 } 494 495 496 502 public Result validateEJBDescriptor(InputStream source) 503 { 504 Document document = null; 505 result = getInitializedResult(); 506 result.setComponentName(EJB); 507 NodeList nodeList = null; 508 try { 509 if (source == null) { 510 logger.log(Level.SEVERE, getClass().getName() + ".srcnull"); 511 result.failed 512 (smh.getLocalString 513 (getClass().getName() + ".NoIO", 514 "no InputStream found", 515 new Object [] {})); 516 return result; 517 } 518 else { 519 document = builder.parse(source); 520 521 checkInterfacePairs(document, "remote", "home"); 522 checkInterfacePairs(document, "local", "local-home"); 523 524 nodeList = document.getElementsByTagName("session-type"); 526 if (nodeList != null) { 527 for (int i = 0; i < nodeList.getLength(); i++) { 528 String sessionTypeValue = ((Text)nodeList.item(i).getFirstChild()).getNodeValue(); 529 if (!sessionTypeValue.equals(EjbSessionDescriptor.STATELESS) 530 && !sessionTypeValue.equals(EjbSessionDescriptor.STATEFUL)) { 531 result.failed 532 (smh.getLocalString 533 (getClass().getName() + ".failedSession", 534 "session-type cannot be {0}. It has to be either Stateless or Stateful.", 535 new Object [] {sessionTypeValue})); 536 oneFailed = true; 537 } 538 else { 539 result.addGoodDetails 540 (smh.getLocalString 541 (getClass().getName() + ".passedSession", 542 "PASSED : session-type is {0}.", 543 new Object [] {sessionTypeValue})); 544 } 545 546 } 547 } 548 549 nodeList = document.getElementsByTagName("ejb-ref-type"); 551 if (nodeList != null) { 552 for (int i = 0; i < nodeList.getLength(); i++) { 553 String ejbRefTypeValue = ((Text)nodeList.item(i).getFirstChild()).getNodeValue(); 554 if (!ejbRefTypeValue.equals(EjbSessionDescriptor.TYPE) 555 && !ejbRefTypeValue.equals(EjbEntityDescriptor.TYPE)) { 556 result.failed 557 (smh.getLocalString 558 (getClass().getName() + ".failedEjbRefType", 559 "[EJB] ejb-ref-type cannot be {0}. It has to be either Entity or Session.", 560 new Object [] {ejbRefTypeValue})); 561 oneFailed = true; 562 } 563 else { 564 result.addGoodDetails 565 (smh.getLocalString 566 (getClass().getName() + ".passedEjbRefType", 567 "PASSED [EJB] : ejb-ref-type is {0}.", 568 new Object [] {ejbRefTypeValue})); 569 } 570 571 } 572 } 573 574 nodeList = document.getElementsByTagName("multiplicity"); 576 if (nodeList != null) { 577 for (int i = 0; i < nodeList.getLength(); i++) { 578 String multiplicityValue = ((Text)nodeList.item(i).getFirstChild()).getNodeValue(); 579 if (!multiplicityValue.equals("One") 580 && !multiplicityValue.equals("Many")) { 581 result.failed 582 (smh.getLocalString 583 (getClass().getName() + ".failedMultiplicity", 584 "[EJB] multiplicity cannot be {0}. It has to be either One or Many", 585 new Object [] {multiplicityValue})); 586 oneFailed = true; 587 } 588 else { 589 result.addGoodDetails 590 (smh.getLocalString 591 (getClass().getName() + ".passedMultiplicity", 592 "PASSED [EJB] : multiplicity is {0}.", 593 new Object [] {multiplicityValue})); 594 } 595 596 } 597 } 598 599 nodeList = document.getElementsByTagName("cmp-version"); 601 if (nodeList != null) { 602 for (int i = 0; i < nodeList.getLength(); i++) { 603 String value = ((Text)nodeList.item(i).getFirstChild()).getNodeValue(); 604 if (!value.equals("1.x") 605 && !value.equals("2.x")) { 606 result.failed 607 (smh.getLocalString 608 (getClass().getName() + ".failedVersion", 609 "[EJB] version cannot be {0}. It has to be either 1.x or 2.x", 610 new Object [] {value})); 611 oneFailed = true; 612 } 613 else { 614 result.addGoodDetails 615 (smh.getLocalString 616 (getClass().getName() + ".passedVersion", 617 "PASSED [EJB] : version is {0}.", 618 new Object [] {value})); 619 } 620 621 } 622 } 623 624 nodeList = document.getElementsByTagName("destination-type"); 626 if (nodeList != null) { 627 for (int i = 0; i < nodeList.getLength(); i++) { 628 String value = ((Text)nodeList.item(i).getFirstChild()).getNodeValue(); 629 if (!value.equals("javax.jms.Queue") 630 && !value.equals("javax.jms.Topic")) { 631 result.failed 632 (smh.getLocalString 633 (getClass().getName() + ".failedDestinationType", 634 "[EJB] destination-type cannot be {0}. It has to be either javax.jms.Topic or javax.jms.Queue", 635 new Object [] {value})); 636 oneFailed = true; 637 } 638 else { 639 result.addGoodDetails 640 (smh.getLocalString 641 (getClass().getName() + ".passedDestinationType", 642 "PASSED [EJB] : destination-type is {0}.", 643 new Object [] {value})); 644 } 645 } 646 } 647 nodeList = document.getElementsByTagName("method-intf"); 649 if (nodeList != null) { 650 for (int i = 0; i < nodeList.getLength(); i++) { 651 String value = ((Text)nodeList.item(i).getFirstChild()).getNodeValue(); 652 if (!value.equals("Home") 653 && !value.equals("Remote") 654 && !value.equals("LocalHome") 655 && !value.equals("Local") 656 && !value.equals("ServiceEndpoint")) { 657 result.failed 658 (smh.getLocalString 659 (getClass().getName() + ".failedMethodIntf", 660 "[EJB] method-intf cannot be [ {0} ]. It has to be either Local, Remote, LocalHome or Home or ServiceEndpoint", 661 new Object [] {value})); 662 oneFailed = true; 663 } 664 else { 665 result.addGoodDetails 666 (smh.getLocalString 667 (getClass().getName() + ".passedMethodIntf", 668 "PASSED [EJB] : method-intf is {0}.", 669 new Object [] {value})); 670 } 671 } 672 } 673 nodeList = document.getElementsByTagName("persistence-type"); 675 if (nodeList != null) { 676 for (int i = 0; i < nodeList.getLength(); i++) { 677 String value = ((Text)nodeList.item(i).getFirstChild()).getNodeValue(); 678 if (!value.equals("Bean") 679 && !value.equals("Container")) { 680 result.failed 681 (smh.getLocalString 682 (getClass().getName() + ".failedPersistenceType", 683 "[EJB] persistence-type cannot be {0}. It has to be either Bean or Container", 684 new Object [] {value})); 685 oneFailed = true; 686 } 687 else { 688 result.addGoodDetails 689 (smh.getLocalString 690 (getClass().getName() + ".passedPersistenceType", 691 "PASSED [EJB] : persistence-type is {0}.", 692 new Object [] {value})); 693 } 694 } 695 } 696 697 nodeList = document.getElementsByTagName("reentrant"); 699 if (nodeList != null) { 700 for (int i = 0; i < nodeList.getLength(); i++) { 701 String value = ((Text)nodeList.item(i).getFirstChild()).getNodeValue(); 702 if (!value.equals("True") 703 && !value.equals("False")) { 704 result.failed 705 (smh.getLocalString 706 (getClass().getName() + ".failedReentrant", 707 "[EJB] reentrant cannot be {0}. It has to be either True or False", 708 new Object [] {value})); 709 oneFailed = true; 710 } 711 else { 712 result.addGoodDetails 713 (smh.getLocalString 714 (getClass().getName() + ".passedReentrant", 715 "PASSED [EJB] : reentrant is {0}.", 716 new Object [] {value})); 717 } 718 } 719 } 720 721 nodeList = document.getElementsByTagName("res-auth"); 723 if (nodeList != null) { 724 for (int i = 0; i < nodeList.getLength(); i++) { 725 String value = ((Text)nodeList.item(i).getFirstChild()).getNodeValue(); 726 if (!value.equals("Application") 727 && !value.equals("Container")) { 728 result.failed 729 (smh.getLocalString 730 (getClass().getName() + ".failedEjbResAuth", 731 "[EJB] res-auth cannot be {0}. It has to be either Application or Container", 732 new Object [] {value})); 733 oneFailed = true; 734 } 735 else { 736 result.addGoodDetails 737 (smh.getLocalString 738 (getClass().getName() + ".passedEjbResAuth", 739 "PASSED [EJB] : res-auth is {0}.", 740 new Object [] {value})); 741 } 742 } 743 } 744 745 nodeList = document.getElementsByTagName("result-type-mapping"); 747 if (nodeList != null) { 748 for (int i = 0; i < nodeList.getLength(); i++) { 749 String value = ((Text)nodeList.item(i).getFirstChild()).getNodeValue(); 750 if (!value.equals("Local") 751 && !value.equals("Remote")) { 752 result.failed 753 (smh.getLocalString 754 (getClass().getName() + ".failedResultTypeMapping", 755 "[EJB] result-type-mapping cannot be {0}. It has to be either Remote or Local", 756 new Object [] {value})); 757 oneFailed = true; 758 } 759 else { 760 result.addGoodDetails 761 (smh.getLocalString 762 (getClass().getName() + ".passedResultTypeMapping", 763 "PASSED [EJB] : result-type-mapping is {0}.", 764 new Object [] {value})); 765 } 766 } 767 } 768 769 nodeList = document.getElementsByTagName("subscription-durability"); 771 if (nodeList != null) { 772 for (int i = 0; i < nodeList.getLength(); i++) { 773 String value = ((Text)nodeList.item(i).getFirstChild()).getNodeValue(); 774 if (!value.equals("Durable") 775 && !value.equals("NonDurable")) { 776 result.failed 777 (smh.getLocalString 778 (getClass().getName() + ".failedSubscriptionDurability", 779 "[EJB] subscription-durability cannot be {0}. It has to be either Durable or NonDurable", 780 new Object [] {value})); 781 oneFailed = true; 782 } 783 else { 784 result.addGoodDetails 785 (smh.getLocalString 786 (getClass().getName() + ".passedSubscriptionDurability", 787 "PASSED [EJB] : subscription-durability is {0}.", 788 new Object [] {value})); 789 } 790 } 791 } 792 nodeList = document.getElementsByTagName("trans-attribute"); 794 if (nodeList != null) { 795 for (int i = 0; i < nodeList.getLength(); i++) { 796 String value = ((Text)nodeList.item(i).getFirstChild()).getNodeValue(); 797 if (!value.equals("NotSupported") 798 && !value.equals("Supports") 799 && !value.equals("Required") 800 && !value.equals("RequiresNew") 801 && !value.equals("Mandatory") 802 && !value.equals("Never")) { 803 result.failed 804 (smh.getLocalString 805 (getClass().getName() + ".failedTransAttribute", 806 "[EJB] trans-attribute cannot be {0}. It has to be either NotSupported or Supports or Required or RequiresNew or Mandatory or Never.", 807 new Object [] {value})); 808 oneFailed = true; 809 } 810 else { 811 result.addGoodDetails 812 (smh.getLocalString 813 (getClass().getName() + ".passedTransAttribute", 814 "PASSED [EJB]: trans-attribute is {0}.", 815 new Object [] {value})); 816 } 817 } 818 } 819 820 nodeList = document.getElementsByTagName("transaction-type"); 822 if (nodeList != null) { 823 for (int i = 0; i < nodeList.getLength(); i++) { 824 String value = ((Text)nodeList.item(i).getFirstChild()).getNodeValue(); 825 if (!value.equals("Bean") 826 && !value.equals("Container")) { 827 result.failed 828 (smh.getLocalString 829 (getClass().getName() + ".failedTransactionType", 830 "[EJB] transaction-type cannot be {0}. It has to be either Bean or Container", 831 new Object [] {value})); 832 oneFailed = true; 833 } 834 else { 835 result.addGoodDetails 836 (smh.getLocalString 837 (getClass().getName() + ".passedTransactionType", 838 "PASSED [EJB]: transaction-type is {0}.", 839 new Object [] {value})); 840 } 841 } 842 } 843 844 nodeList = document.getElementsByTagName("acknowledge-mode"); 846 if (nodeList != null) { 847 for (int i = 0; i < nodeList.getLength(); i++) { 848 String value = ((Text)nodeList.item(i).getFirstChild()).getNodeValue(); 849 if (!value.equals("Auto-acknowledge") 850 && !value.equals("Dups-ok-acknowledge")) { 851 result.failed 852 (smh.getLocalString 853 (getClass().getName() + ".failedAcknowledgeMode", 854 "[EJB] acknowledge-mode cannot be {0}. It has to be either True or False", 855 new Object [] {value})); 856 oneFailed = true; 857 } 858 else { 859 result.addGoodDetails 860 (smh.getLocalString 861 (getClass().getName() + ".passedAcknowledgeMode", 862 "PASSED [EJB]: acknowledge-mode is {0}.", 863 new Object [] {value})); 864 } 865 } 866 } 867 868 nodeList = document.getElementsByTagName("res-sharing-scope"); 870 if (nodeList != null) { 871 for (int i = 0; i < nodeList.getLength(); i++) { 872 String value = ((Text)nodeList.item(i).getFirstChild()).getNodeValue(); 873 if (!value.equals("Shareable") 874 && !value.equals("Unshareable")) { 875 result.failed 876 (smh.getLocalString 877 (getClass().getName() + ".failedEjbResSharingScope", 878 "[EJB] res-sharing-scope cannot be {0}. It has to be either Shareable or Unshareable", 879 new Object [] {value})); 880 oneFailed = true; 881 } 882 else { 883 result.addGoodDetails 884 (smh.getLocalString 885 (getClass().getName() + ".passedEjbResSharingScope", 886 "PASSED [EJB] : res-sharing-scope is {0}.", 887 new Object [] {value})); 888 } 889 } 890 } 891 892 893 if (result.getStatus() != Result.FAILED) { 894 result.setStatus(Result.PASSED); 895 } 896 return result; 897 } 898 } catch (IOException e) { 899 logger.log(Level.SEVERE, getClass().getName() + ".Exception", 900 new Object [] {e.toString()}); 901 result.failed 902 (smh.getLocalString 903 (getClass().getName() + ".Exception", 904 "Exception : {0}", 905 new Object [] {e.toString()})); 906 return result; 907 } catch (SAXException e) { 908 logger.log(Level.SEVERE,getClass().getName() + ".Exception", 909 new Object [] {e.toString()}); 910 result.failed 911 (smh.getLocalString 912 (getClass().getName() + ".Exception", 913 "Exception : {0}", 914 new Object [] {e.toString()})); 915 return result; 916 } catch (Exception e) { 917 logger.log(Level.SEVERE, getClass().getName() + ".Exception", 918 new Object [] {e.toString()}); 919 result.failed 920 (smh.getLocalString 921 (getClass().getName() + ".Exception", 922 "Exception : {0}", 923 new Object [] {e.toString()})); 924 return result; 925 } 926 } 927 928 public void checkInterfacePairs(Document document, String intf1, String intf2) { 929 932 int length1 = 0; 933 int length2 = 0; 934 NodeList nodeList = document.getElementsByTagName(intf1.trim()); 935 if (nodeList != null) { 936 length1 = nodeList.getLength(); 937 938 } 939 nodeList = document.getElementsByTagName(intf2.trim()); 940 if (nodeList != null) { 941 length2 = nodeList.getLength(); 942 943 } 944 945 if (length1 == length2) { 946 if (length1 != 0) { 947 result.addGoodDetails 948 (smh.getLocalString 949 (getClass().getName() + ".passedPairs", 950 "PASSED [EJB] : [ {0} ] and [ {1} ] tags present.", 951 new Object [] {intf1, intf2})); 952 } 953 } else { 954 result.failed 955 (smh.getLocalString 956 (getClass().getName() + ".failedPairs", 957 "FAILED [EJB] : Either one of the [ {0} ] : [ {1} ] tag pair is not present.", 958 new Object [] {intf1, intf2})); 959 } 960 961 } 962 963 } 964 | Popular Tags |