use of com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor in project Payara by payara.
the class ASWebEjbRef method check.
public Result check(WebBundleDescriptor descriptor) {
Result result = getInitializedResult();
ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
boolean oneFailed = false;
String refName;
Set<EjbReference> ejbRefs = descriptor.getEjbReferenceDescriptors();
if (ejbRefs != null && ejbRefs.size() > 0) {
for (EjbReference ejbRef : ejbRefs) {
refName = ejbRef.getName();
if (validEjbRefName(refName, descriptor)) {
addGoodDetails(result, compName);
result.passed(smh.getLocalString(getClass().getName() + ".passed", "PASSED [AS-WEB ejb-ref] ejb-ref-name [ {0} ] properly defined in the war file.", new Object[] { refName }));
} else {
oneFailed = true;
addErrorDetails(result, compName);
result.failed(smh.getLocalString(getClass().getName() + ".failed", "FAILED [AS-WEB ejb-ref] ejb-ref-name [ {0} ] is not valid, either empty or not defined in web.xml.", new Object[] { refName }));
}
}
} else {
addNaDetails(result, compName);
result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "NOT APPLICABLE [AS-WEB sun-web-app] ejb-ref element(s) not defined in the web archive [ {0} ].", new Object[] { descriptor.getName() }));
return result;
}
if (oneFailed) {
result.setStatus(Result.FAILED);
} else {
addGoodDetails(result, compName);
result.passed(smh.getLocalString(getClass().getName() + ".passed2", "PASSED [AS-WEB sun-web-app] ejb-ref element(s) defined are valid within the web archive [ {0} ].", new Object[] { descriptor.getName() }));
}
return result;
}
use of com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor in project Payara by payara.
the class HandlerChainClassCheck method check.
public Result check(WebServiceEndpoint descriptor) {
Result result = getInitializedResult();
ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
// Handler chains are applicable only in the context of JAX-WS 2.0. So
// version check for this test is not required.
List handlerChain = descriptor.getHandlerChain();
for (Iterator it = handlerChain.iterator(); it.hasNext(); ) {
List handlers = ((WebServiceHandlerChain) it.next()).getHandlers();
for (Iterator itr = handlers.iterator(); itr.hasNext(); ) {
String hClass = ((WebServiceHandler) itr.next()).getHandlerClass();
try {
Class cl = Class.forName(hClass, false, getVerifierContext().getClassLoader());
if (!((javax.xml.ws.handler.Handler.class).isAssignableFrom(cl))) {
addErrorDetails(result, compName);
result.failed(smh.getLocalString(getClass().getName() + ".failed", "Handler Class [{0}] does not implement " + "javax.xml.ws.handler.Handler Interface", new Object[] { hClass }));
}
} catch (ClassNotFoundException e) {
// result.fail, handler class not found
addErrorDetails(result, compName);
result.failed(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.webservices.clfailed", "The [{0}] Class [{1}] could not be Loaded", new Object[] { "Handler Class", hClass }));
}
}
}
if (result.getStatus() != Result.FAILED) {
addGoodDetails(result, compName);
result.passed(smh.getLocalString(getClass().getName() + ".passed1", "Handler chains, if any, are defined properly"));
}
return result;
}
use of com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor in project Payara by payara.
the class SEIEJBTxAttrChk method check.
/**
* @param descriptor the WebService deployment descriptor
* @return <code>Result</code> the results for this assertion
*/
public Result check(WebServiceEndpoint wsdescriptor) {
Result result = getInitializedResult();
ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
boolean pass = true;
if (wsdescriptor.implementedByEjbComponent()) {
EjbDescriptor descriptor = (EjbDescriptor) wsdescriptor.getEjbComponentImpl();
try {
ContainerTransaction ctx = descriptor.getContainerTransaction();
if ((ctx != null) && (ContainerTransaction.MANDATORY.equals(ctx.getTransactionAttribute()))) {
// Call result.failed here : All methods are having Mandatory TX
result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.failed(smh.getLocalString(getClass().getName() + ".failed", "[{0}] of this WebService [{1}] have Mandatory Transaction Attribute.", new Object[] { "All the methods", compName.toString() }));
return result;
}
Collection txMethDescs = descriptor.getTransactionMethodDescriptors();
// get hold of the SEI Class
String s = descriptor.getWebServiceEndpointInterfaceName();
if (s == null) {
// internal error, should never happen
result.addErrorDetails(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.webservices.Error", "Error: Unexpected error occurred [ {0} ]", new Object[] { "Service Endpoint Interface Class Name Null" }));
pass = false;
}
ClassLoader cl = getVerifierContext().getClassLoader();
Class sei = null;
try {
sei = Class.forName(s, false, cl);
} catch (ClassNotFoundException e) {
result.addErrorDetails(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.webservices.Error", "Error: Unexpected error occurred [ {0} ]", new Object[] { "Could not Load Service Endpoint Interface Class" }));
pass = false;
}
Iterator it = txMethDescs.iterator();
while (it.hasNext()) {
// need to check if this method is part of SEI
MethodDescriptor methdesc = (MethodDescriptor) it.next();
if (isSEIMethod(methdesc, descriptor, sei, cl)) {
ctx = descriptor.getContainerTransactionFor(methdesc);
if ((ctx != null) && (ContainerTransaction.MANDATORY.equals(ctx.getTransactionAttribute()))) {
// Call result.failed here with Method details here
result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.failed(smh.getLocalString(getClass().getName() + ".failed", "[{0}] of this WebService [{1}] have Mandatory Transaction Attribute.", new Object[] { methdesc.getName(), compName.toString() }));
pass = false;
}
}
}
} catch (Exception e) {
// Call result.addErrorDetails here with exception details
result.addErrorDetails(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.webservices.Error", "Error: Unexpected error occurred [ {0} ]", new Object[] { e.getMessage() }));
pass = false;
}
if (pass) {
result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.passed(smh.getLocalString(getClass().getName() + ".passed", "None of the methods of this WebService [{0}] have Mandatory Transaction Attribute.", new Object[] { compName.toString() }));
}
return result;
} else {
// call result.notapplicable
result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.notApplicable(smh.getLocalString(getClass().getName() + ".notapp", "Not applicable since this is not an EJB Service Endpoint."));
return result;
}
}
use of com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor in project Payara by payara.
the class WSWsdlPortComponentName method check.
/**
* @param descriptor the WebServices descriptor
* @return <code>Result</code> the results for this assertion
*/
public Result check(WebServiceEndpoint descriptor) {
Result result = getInitializedResult();
ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
boolean pass = true;
String portcomponentname = null;
try {
portcomponentname = descriptor.getEndpointName();
if (portcomponentname == null || portcomponentname.equals(""))
pass = false;
if (pass) {
result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.passed(smh.getLocalString(getClass().getName() + ".passed", "The webservices.xml file for [ {0} ] has the port-component-name element specified.", new Object[] { compName.toString() }));
} else {
result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.failed(smh.getLocalString(getClass().getName() + ".failed", "The webservices.xml file for [ {0} ] does not have the port-component-name element specified.", new Object[] { compName.toString() }));
}
} catch (Exception e) {
// result.fail
result.addErrorDetails(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.webservices.Error", "Error: Unexpected error occurred [ {0} ]", new Object[] { e.getMessage() }));
}
return result;
}
use of com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor in project Payara by payara.
the class EjbNameIsValidJavaIdentifier method check.
/**
* For an entity-bean the ejb-name must be a valid Java identifier.
* See ejb specification 2.1 section 10.3.13
* @param descriptor the Enterprise Java Bean deployment descriptor
* @return <code>Result</code> the results for this assertion
*/
public Result check(EjbDescriptor descriptor) {
Result result = getInitializedResult();
String ejbName = descriptor.getName();
ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
if (descriptor instanceof EjbEntityDescriptor) {
if (((EjbEntityDescriptor) descriptor).getPersistenceType().equals(EjbEntityDescriptor.CONTAINER_PERSISTENCE)) {
boolean isJavaIdentifier = true;
boolean startChar = Character.isJavaIdentifierStart(ejbName.charAt(0));
if (startChar) {
for (int i = 1; i < ejbName.length(); i++) if (!Character.isJavaIdentifierPart(ejbName.charAt(i))) {
isJavaIdentifier = false;
break;
}
} else {
isJavaIdentifier = false;
}
// valid JavaIdentifier
if (isJavaIdentifier) {
result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.passed(smh.getLocalString(getClass().getName() + ".passed", "ejb-name [ {0} ] within bean [ {1} ] is a valid java identifier", new Object[] { ejbName, descriptor.getName() }));
return result;
} else {
result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.failed(smh.getLocalString(getClass().getName() + ".failed", "ejb-name [ {0} ] within bean [ {1} ] is not a valid java identifier", new Object[] { ejbName, descriptor.getName() }));
return result;
}
}
}
result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "[ {0} ] expected {1} bean, with Container Managed Persistence.", new Object[] { getClass(), "Entity" }));
return result;
}
Aggregations