1 23 package com.sun.enterprise.tools.verifier.tests.ejb.elements; 24 25 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest; 26 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck; 27 import java.util.*; 28 import com.sun.enterprise.deployment.*; 29 import com.sun.enterprise.tools.verifier.*; 30 import com.sun.enterprise.tools.verifier.tests.*; 31 32 import java.lang.reflect.*; 33 34 37 public class EjbMethodIntfElement extends EjbTest implements EjbCheck { 38 39 40 47 public Result check(EjbDescriptor descriptor) { 48 49 Result result = getInitializedResult(); 50 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 51 52 53 if (descriptor instanceof EjbMessageBeanDescriptor) { 55 result.addNaDetails(smh.getLocalString 56 ("tests.componentNameConstructor", 57 "For [ {0} ]", 58 new Object [] {compName.toString()})); 59 result.notApplicable(smh.getLocalString 60 (getClass().getName() + ".notApplicable", 61 "There are no <method-intf> elements within this bean [ {0} ]", 62 new Object [] {descriptor.getName()})); 63 return result; 64 } 65 66 try { 72 73 boolean na = false; 74 boolean na1 = false; 75 boolean oneFailed = false; 76 if (!descriptor.getMethodContainerTransactions().isEmpty()) { 77 for (Enumeration ee = descriptor.getMethodContainerTransactions().keys(); ee.hasMoreElements();) { 78 79 MethodDescriptor methodDescriptor = (MethodDescriptor) ee.nextElement(); 80 String methodIntf = null; 81 try { 82 methodIntf = methodDescriptor.getEjbClassSymbol(); 83 } catch ( Exception ex ) {} 84 if ( methodIntf == null ) { continue; 86 } 87 if (!( (methodIntf.equals(MethodDescriptor.EJB_REMOTE)) || 90 (methodIntf.equals(MethodDescriptor.EJB_HOME)) || 91 (methodIntf.equals(MethodDescriptor.EJB_LOCALHOME)) || 92 (methodIntf.equals(MethodDescriptor.EJB_LOCAL)) || 93 (methodIntf.equals(MethodDescriptor.EJB_WEB_SERVICE)) || 94 (methodIntf.length()==0))) { 95 oneFailed =true; 102 result.addErrorDetails(smh.getLocalString 103 ("tests.componentNameConstructor", 104 "For [ {0} ]", 105 new Object [] {compName.toString()})); 106 result.addErrorDetails 107 (smh.getLocalString 108 (getClass().getName() + ".failed", 109 "Error: Container transaction method [ {0} ] method-intf element [ {1} ] must be one of the following: [ {2} ] or [ {3} ] or [ {4} ] or [ {5} ] within bean [ {6} ]", 110 new Object [] {methodDescriptor.getName(),methodDescriptor.getEjbClassSymbol(), 111 MethodDescriptor.EJB_REMOTE.toString(), MethodDescriptor.EJB_HOME, 112 MethodDescriptor.EJB_LOCAL, MethodDescriptor.EJB_LOCALHOME, 113 descriptor.getName()})); 114 } else { 115 result.addGoodDetails(smh.getLocalString 116 ("tests.componentNameConstructor", 117 "For [ {0} ]", 118 new Object [] {compName.toString()})); 119 result.addGoodDetails 120 (smh.getLocalString 121 (getClass().getName() + ".passed", 122 "Container Transaction method [ {0} ] method-intf element [ {1} ] is one of the following: [ {2} ] or [ {3} ] or [ {4} ] or [ {5} ] within bean [ {6} ]", 123 new Object [] {methodDescriptor.getName(),methodDescriptor.getEjbClassSymbol(), 124 MethodDescriptor.EJB_REMOTE, MethodDescriptor.EJB_HOME, 125 MethodDescriptor.EJB_LOCAL, MethodDescriptor.EJB_LOCALHOME, 126 descriptor.getName()})); 127 } 128 } 129 } else { 130 na = true; 131 } 132 133 Map permissionedMethods = descriptor.getPermissionedMethodsByPermission(); 134 if (permissionedMethods.size() >0) { 135 for (Iterator e = permissionedMethods.keySet().iterator(); e.hasNext();) { 136 MethodPermission nextPermission = (MethodPermission) e.next(); 137 Set permissionedMethodsForRole = (HashSet) permissionedMethods.get(nextPermission); 138 139 if (permissionedMethodsForRole != null) { 140 Set convertedPermissionedMethods = new HashSet(); 141 for (Iterator itr = permissionedMethodsForRole.iterator(); itr.hasNext();) { 142 MethodDescriptor methodDescriptor = (MethodDescriptor) itr.next(); 143 144 String methodIntf = null; 145 try { 146 methodIntf = methodDescriptor.getEjbClassSymbol(); 147 } catch ( Exception ex ) {} 148 if ( methodIntf == null ) { continue; 150 } 151 if (!( (methodIntf.equals(MethodDescriptor.EJB_REMOTE)) || 154 (methodIntf.equals(MethodDescriptor.EJB_HOME)) || 155 (methodIntf.equals(MethodDescriptor.EJB_LOCALHOME)) || 156 (methodIntf.equals(MethodDescriptor.EJB_LOCAL)) || 157 (methodIntf.equals(MethodDescriptor.EJB_WEB_SERVICE)) || 158 (methodIntf.length()==0))) { 159 160 167 oneFailed =true; 168 result.addErrorDetails(smh.getLocalString 169 ("tests.componentNameConstructor", 170 "For [ {0} ]", 171 new Object [] {compName.toString()})); 172 result.addErrorDetails 173 (smh.getLocalString 174 (getClass().getName() + ".failed1", 175 "Error: Method permissions method [ {0} ] method-intf element [ {1} ] must be one of the interfaces of the bean [ {2} ]", 176 new Object [] {methodDescriptor.getName(), 177 methodDescriptor.getEjbClassSymbol(), 178 descriptor.getName()})); 179 } else { 180 result.addGoodDetails(smh.getLocalString 181 ("tests.componentNameConstructor", 182 "For [ {0} ]", 183 new Object [] {compName.toString()})); 184 result.addGoodDetails 185 (smh.getLocalString 186 (getClass().getName() + ".passed1", 187 "Method permissions method [ {0} ] method-intf element [ {1} ] is one of the interfaces of the bean [ {2} ]", 188 new Object [] {methodDescriptor.getName(),methodDescriptor.getEjbClassSymbol(), descriptor.getName()})); 189 } 190 } 191 } 192 } 193 } else { 194 na1 = true; 195 } 196 197 198 if (oneFailed) { 199 result.setStatus(Result.FAILED); 200 } else if (na && na1) { 201 result.addNaDetails(smh.getLocalString 202 ("tests.componentNameConstructor", 203 "For [ {0} ]", 204 new Object [] {compName.toString()})); 205 result.notApplicable(smh.getLocalString 206 (getClass().getName() + ".notApplicable", 207 "There are no <method-intf> elements within this bean [ {0} ]", 208 new Object [] {descriptor.getName()})); 209 } else { 210 result.setStatus(Result.PASSED); 211 } 212 return result; 213 } catch (Throwable t) { 214 result.addErrorDetails(smh.getLocalString 215 ("tests.componentNameConstructor", 216 "For [ {0} ]", 217 new Object [] {compName.toString()})); 218 result.failed(smh.getLocalString 219 (getClass().getName() + ".failedException", 220 "Error: [ {0} ] does not contain class [ {1} ] within bean [ {2} ]", 221 new Object [] {descriptor.getName(), t.getMessage(), descriptor.getName()})); 222 return result; 223 } 224 } 225 } 226 | Popular Tags |