1 23 package com.sun.enterprise.tools.verifier.tests.webservices; 24 25 import com.sun.enterprise.deployment.*; 26 import com.sun.enterprise.tools.verifier.*; 27 import java.util.*; 28 import com.sun.enterprise.tools.verifier.tests.*; 29 import java.lang.reflect.*; 30 31 35 36 43 public class HandlerPortNameCheck extends WSTest implements WSCheck { 44 45 49 public Result check (WebServiceEndpoint descriptor) { 50 51 Result result = getInitializedResult(); 52 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 53 54 boolean pass = true; 55 56 if (descriptor.hasHandlers()) { 57 Collection allPortNames = getAllPortNamesInService(descriptor); 58 List handlerChain = descriptor.getHandlerChain(); 59 for (Iterator it = handlerChain.iterator(); it.hasNext();) { 60 Collection c = ((WebServiceHandler)it.next()).getPortNames(); 61 Collection invalid = getInvalidHandlerPortNames(c,allPortNames); 62 if (invalid.size() > 0) { 63 result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor", 65 "For [ {0} ]", new Object [] {compName.toString()})); 66 result.failed(smh.getLocalString 67 ("com.sun.enterprise.tools.verifier.tests.webservices.failed", 68 "[{0}]", new Object [] {"The Port Name(s) in the Handler Chain are invalid"})); 69 70 pass = false; 71 } 72 else { 73 result.addGoodDetails(smh.getLocalString 75 ("tests.componentNameConstructor", 76 "For [ {0} ]", 77 new Object [] {compName.toString()})); 78 result.passed(smh.getLocalString ( 79 "com.sun.enterprise.tools.verifier.tests.webservices.passed", "[{0}]", 80 new Object [] {"Port Name(s) in the Handler-Chain are valid"})); 81 82 } 83 } 84 } 85 else { 86 result.addNaDetails(smh.getLocalString 88 ("tests.componentNameConstructor", "For [ {0} ]", 89 new Object [] {compName.toString()})); 90 result.notApplicable(smh.getLocalString 91 ("com.sun.enterprise.tools.verifier.tests.webservices.notapp", 92 "[{0}]", new Object [] {"Not Applicable since No handlers defined in this WebService"})); 93 94 } 95 96 return result; 97 } 98 99 private Collection getAllPortNamesInService(WebServiceEndpoint descriptor) { 100 101 Collection endPoints = descriptor.getWebService().getEndpoints(); 102 Vector<String > ret = new Vector<String >(); 103 for (Iterator it = endPoints.iterator(); it.hasNext();) { 104 ret.add(((WebServiceEndpoint)it.next()).getEndpointName()); 105 } 106 return ret; 107 } 108 109 private Collection getInvalidHandlerPortNames(Collection hpNames, Collection allPortNames) { 110 111 Vector<String > ret = new Vector<String >(); 112 for (Iterator it = hpNames.iterator(); it.hasNext();) { 113 String currName = (String )it.next(); 114 if (!allPortNames.contains(currName)) 115 ret.add(currName); 116 } 117 return ret; 118 } 119 } 120 121 | Popular Tags |