KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > dd > ParseDD


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

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 JavaDoc;
37 import java.util.logging.Logger JavaDoc;
38 import com.sun.enterprise.logging.LogDomains;
39
40
41 /**
42  * <p>
43  * This test parses the deployment descriptor using a SAX parser to
44  * avoid the dependency on the DOL
45  * <p>
46  *
47  * @author Sheetal Vartak
48  * @version
49  */

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 JavaDoc EJB = "EJB Deployment Descriptor";
57     private static String JavaDoc APPCLIENT = "App Client Deployment Descriptor";
58     private static String JavaDoc CONNECTOR = "Connector Deployment Descriptor";
59     private static String JavaDoc WEB = "Web Deployment Descriptor";
60
61     // Logger to log messages
62
private static Logger JavaDoc logger = LogDomains.getLogger(LogDomains.AVK_VERIFIER_LOGGER);
63
64
65     /**
66       * <p>
67       * This test parses the deployment descriptor using a SAX parser to
68       * avoid the dependency on the DOL
69       * <p>
70       */

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 JavaDoc(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 JavaDoc[] {e.toString()});
84         result.failed(smh.getLocalString
85               (getClass().getName() + ".Exception",
86                "Exception : {0}",
87                new Object JavaDoc[] {e.toString()}));
88     }catch (Exception JavaDoc e) {
89             logger.log(Level.SEVERE,getClass().getName() + ".Exception",
90                 new Object JavaDoc[] {e.toString()});
91         result.failed(smh.getLocalString
92               (getClass().getName() + ".Exception",
93                "Exception : {0}",
94                new Object JavaDoc[] {e.toString()}));
95     }
96     }
97
98
99     /**
100      * Parse validate the XML file
101      *
102      * @param source Input XML to be checked
103      *
104      */

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 JavaDoc[] {}));
119         return result;
120         }
121         else {
122         document = builder.parse(source);
123
124         //license-required
125
nodeList = document.getElementsByTagName("license-required");
126         if (nodeList != null) {
127             for (int i = 0; i < nodeList.getLength(); i++) {
128             String JavaDoc 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 JavaDoc[] {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 JavaDoc[] {value}));
144             }
145             }
146         }
147
148         //reauthentication-support
149
nodeList = document.getElementsByTagName("reauthentication-support");
150         if (nodeList != null) {
151             for (int i = 0; i < nodeList.getLength(); i++) {
152             String JavaDoc 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 JavaDoc[] {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 JavaDoc[] {value}));
168             }
169             }
170         }
171
172         //transaction-support
173
nodeList = document.getElementsByTagName("transaction-support");
174         if (nodeList != null) {
175             for (int i = 0; i < nodeList.getLength(); i++) {
176             String JavaDoc 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 JavaDoc[] {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 JavaDoc[] {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 JavaDoc[] {e.toString()});
204         result.failed
205         (smh.getLocalString
206          (getClass().getName() + ".Exception",
207           "Exception : {0}",
208           new Object JavaDoc[] {e.toString()}));
209         return result;
210     } catch (SAXException e) {
211             logger.log(Level.SEVERE,getClass().getName() + ".Exception",
212                 new Object JavaDoc[] {e.toString()});
213         result.failed
214         (smh.getLocalString
215          (getClass().getName() + ".Exception",
216           "Exception : {0}",
217           new Object JavaDoc[] {e.toString()}));
218         return result;
219     } catch (Exception JavaDoc e) {
220            logger.log(Level.SEVERE,getClass().getName() + ".Exception",
221                 new Object JavaDoc[] {e.toString()});
222         result.failed
223         (smh.getLocalString
224          (getClass().getName() + ".Exception",
225           "Exception : {0}",
226           new Object JavaDoc[] {e.toString()}));
227         return result;
228     }
229     }
230
231     /**
232      * Parse validate the XML file
233      *
234      * @param source Input XML to be checked
235      *
236      */

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 JavaDoc[] {}));
251         return result;
252         }
253         else {
254         document = builder.parse(source);
255
256         //ejb-ref-type
257
nodeList = document.getElementsByTagName("ejb-ref-type");
258         if (nodeList != null) {
259             for (int i = 0; i < nodeList.getLength(); i++) {
260             String JavaDoc 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 JavaDoc[] {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 JavaDoc[] {ejbRefTypeValue}));
276             }
277             }
278         }
279
280         //res-auth
281
nodeList = document.getElementsByTagName("res-auth");
282         if (nodeList != null) {
283             for (int i = 0; i < nodeList.getLength(); i++) {
284             String JavaDoc 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 JavaDoc[] {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 JavaDoc[] {value}));
300             }
301             }
302         }
303
304         //res-sharing-scope
305
nodeList = document.getElementsByTagName("res-sharing-scope");
306         if (nodeList != null) {
307             for (int i = 0; i < nodeList.getLength(); i++) {
308             String JavaDoc 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 JavaDoc[] {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 JavaDoc[] {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 JavaDoc[] {e.toString()});
336         result.failed
337         (smh.getLocalString
338          (getClass().getName() + ".Exception",
339           "Exception : {0}",
340           new Object JavaDoc[] {e.toString()}));
341         return result;
342     } catch (SAXException e) {
343            logger.log(Level.SEVERE,getClass().getName() + ".Exception",
344                 new Object JavaDoc[] {e.toString()});
345         result.failed
346         (smh.getLocalString
347          (getClass().getName() + ".Exception",
348           "Exception : {0}",
349           new Object JavaDoc[] {e.toString()}));
350         return result;
351     } catch (Exception JavaDoc e) {
352            logger.log(Level.SEVERE,getClass().getName() + ".Exception",
353                 new Object JavaDoc[] {e.toString()});
354         result.failed
355         (smh.getLocalString
356          (getClass().getName() + ".Exception",
357           "Exception : {0}",
358           new Object JavaDoc[] {e.toString()}));
359         return result;
360     }
361     }
362
363     /**
364      * Parse validate the XML file
365      *
366      * @param source Input XML to be checked
367      *
368      */

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 JavaDoc[] {}));
383         return result;
384         }
385         else {
386         document = builder.parse(source);
387
388         //ejb-ref-type
389
nodeList = document.getElementsByTagName("ejb-ref-type");
390         if (nodeList != null) {
391             for (int i = 0; i < nodeList.getLength(); i++) {
392             String JavaDoc 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 JavaDoc[] {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 JavaDoc[] {ejbRefTypeValue}));
408             }
409             }
410         }
411
412         //res-auth
413
nodeList = document.getElementsByTagName("res-auth");
414         if (nodeList != null) {
415             for (int i = 0; i < nodeList.getLength(); i++) {
416             String JavaDoc 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 JavaDoc[] {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 JavaDoc[] {value}));
432             }
433             }
434         }
435
436         //res-sharing-scope
437
nodeList = document.getElementsByTagName("res-sharing-scope");
438         if (nodeList != null) {
439             for (int i = 0; i < nodeList.getLength(); i++) {
440             String JavaDoc 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 JavaDoc[] {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 JavaDoc[] {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 JavaDoc[] {e.toString()});
468         result.failed
469         (smh.getLocalString
470          (getClass().getName() + ".Exception",
471           "Exception : {0}",
472           new Object JavaDoc[] {e.toString()}));
473         return result;
474     } catch (SAXException e) {
475         logger.log(Level.SEVERE, getClass().getName() + ".Exception",
476                 new Object JavaDoc[] {e.toString()});
477         result.failed
478         (smh.getLocalString
479          (getClass().getName() + ".Exception",
480           "Exception : {0}",
481           new Object JavaDoc[] {e.toString()}));
482         return result;
483     } catch (Exception JavaDoc e) {
484         logger.log(Level.SEVERE, getClass().getName() + ".Exception",
485                 new Object JavaDoc[] {e.toString()});
486         result.failed
487         (smh.getLocalString
488          (getClass().getName() + ".Exception",
489           "Exception : {0}",
490           new Object JavaDoc[] {e.toString()}));
491         return result;
492     }
493     }
494
495
496     /**
497      * Parse validate the XML file
498      *
499      * @param source Input XML to be checked
500      *
501      */

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 JavaDoc[] {}));
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         //session-type
525
nodeList = document.getElementsByTagName("session-type");
526         if (nodeList != null) {
527             for (int i = 0; i < nodeList.getLength(); i++) {
528             String JavaDoc 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 JavaDoc[] {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 JavaDoc[] {sessionTypeValue}));
544             }
545
546             }
547         }
548
549         //ejb-ref-type
550
nodeList = document.getElementsByTagName("ejb-ref-type");
551         if (nodeList != null) {
552             for (int i = 0; i < nodeList.getLength(); i++) {
553             String JavaDoc 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 JavaDoc[] {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 JavaDoc[] {ejbRefTypeValue}));
569             }
570
571             }
572         }
573
574         //multiplicity
575
nodeList = document.getElementsByTagName("multiplicity");
576         if (nodeList != null) {
577             for (int i = 0; i < nodeList.getLength(); i++) {
578             String JavaDoc 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 JavaDoc[] {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 JavaDoc[] {multiplicityValue}));
594             }
595
596             }
597         }
598
599         //cmp-version
600
nodeList = document.getElementsByTagName("cmp-version");
601         if (nodeList != null) {
602             for (int i = 0; i < nodeList.getLength(); i++) {
603             String JavaDoc 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 JavaDoc[] {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 JavaDoc[] {value}));
619             }
620
621             }
622         }
623
624         //destination-type
625
nodeList = document.getElementsByTagName("destination-type");
626         if (nodeList != null) {
627             for (int i = 0; i < nodeList.getLength(); i++) {
628             String JavaDoc 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 JavaDoc[] {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 JavaDoc[] {value}));
644             }
645             }
646         }
647         //method-intf
648
nodeList = document.getElementsByTagName("method-intf");
649         if (nodeList != null) {
650             for (int i = 0; i < nodeList.getLength(); i++) {
651             String JavaDoc 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 JavaDoc[] {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 JavaDoc[] {value}));
670             }
671             }
672         }
673         //persistence-type
674
nodeList = document.getElementsByTagName("persistence-type");
675         if (nodeList != null) {
676             for (int i = 0; i < nodeList.getLength(); i++) {
677             String JavaDoc 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 JavaDoc[] {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 JavaDoc[] {value}));
693             }
694             }
695         }
696
697         //reentrant
698
nodeList = document.getElementsByTagName("reentrant");
699         if (nodeList != null) {
700             for (int i = 0; i < nodeList.getLength(); i++) {
701             String JavaDoc 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 JavaDoc[] {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 JavaDoc[] {value}));
717             }
718             }
719         }
720
721         //res-auth
722
nodeList = document.getElementsByTagName("res-auth");
723         if (nodeList != null) {
724             for (int i = 0; i < nodeList.getLength(); i++) {
725             String JavaDoc 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 JavaDoc[] {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 JavaDoc[] {value}));
741             }
742             }
743         }
744
745         //result-type-mapping
746
nodeList = document.getElementsByTagName("result-type-mapping");
747         if (nodeList != null) {
748             for (int i = 0; i < nodeList.getLength(); i++) {
749             String JavaDoc 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 JavaDoc[] {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 JavaDoc[] {value}));
765             }
766             }
767         }
768
769         //subscription-durability
770
nodeList = document.getElementsByTagName("subscription-durability");
771         if (nodeList != null) {
772             for (int i = 0; i < nodeList.getLength(); i++) {
773             String JavaDoc 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 JavaDoc[] {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 JavaDoc[] {value}));
789             }
790             }
791         }
792         //trans-attribute
793
nodeList = document.getElementsByTagName("trans-attribute");
794         if (nodeList != null) {
795             for (int i = 0; i < nodeList.getLength(); i++) {
796             String JavaDoc 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 JavaDoc[] {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 JavaDoc[] {value}));
816             }
817             }
818         }
819
820         //transaction-type
821
nodeList = document.getElementsByTagName("transaction-type");
822         if (nodeList != null) {
823             for (int i = 0; i < nodeList.getLength(); i++) {
824             String JavaDoc 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 JavaDoc[] {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 JavaDoc[] {value}));
840             }
841             }
842         }
843
844         //acknowledge-mode
845
nodeList = document.getElementsByTagName("acknowledge-mode");
846         if (nodeList != null) {
847             for (int i = 0; i < nodeList.getLength(); i++) {
848             String JavaDoc 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 JavaDoc[] {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 JavaDoc[] {value}));
864             }
865             }
866         }
867
868         //res-sharing-scope
869
nodeList = document.getElementsByTagName("res-sharing-scope");
870         if (nodeList != null) {
871             for (int i = 0; i < nodeList.getLength(); i++) {
872             String JavaDoc 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 JavaDoc[] {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 JavaDoc[] {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 JavaDoc[] {e.toString()});
901         result.failed
902         (smh.getLocalString
903          (getClass().getName() + ".Exception",
904           "Exception : {0}",
905           new Object JavaDoc[] {e.toString()}));
906         return result;
907     } catch (SAXException e) {
908         logger.log(Level.SEVERE,getClass().getName() + ".Exception",
909                 new Object JavaDoc[] {e.toString()});
910         result.failed
911         (smh.getLocalString
912          (getClass().getName() + ".Exception",
913           "Exception : {0}",
914           new Object JavaDoc[] {e.toString()}));
915         return result;
916     } catch (Exception JavaDoc e) {
917         logger.log(Level.SEVERE, getClass().getName() + ".Exception",
918                 new Object JavaDoc[] {e.toString()});
919         result.failed
920         (smh.getLocalString
921          (getClass().getName() + ".Exception",
922           "Exception : {0}",
923           new Object JavaDoc[] {e.toString()}));
924         return result;
925     }
926     }
927
928     public void checkInterfacePairs(Document document, String JavaDoc intf1, String JavaDoc intf2) {
929         //check if "local" and "local-home" are both present
930
//similarly for "remote" and "remote-home"
931

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 JavaDoc[] {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 JavaDoc[] {intf1, intf2}));
959     }
960     
961     }
962
963 }
964
Popular Tags