use of com.sun.enterprise.tools.verifier.web.TagDescriptor in project Payara by payara.
the class TagClassExtendsValidInterface method check.
public Result check(WebBundleDescriptor descriptor) {
ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
VerifierTestContext context = getVerifierContext();
Result result = loadWarFile(descriptor);
TagLibDescriptor[] tlds = context.getTagLibDescriptors();
boolean failed = false;
boolean oneFailed = false;
if (tlds == null) {
addGoodDetails(result, compName);
result.passed(smh.getLocalString(getClass().getName() + ".passed", "No tag lib files are specified"));
return result;
}
for (TagLibDescriptor tld : tlds) {
TagDescriptor[] tagDesc = tld.getTagDescriptors();
for (TagDescriptor td : tagDesc) {
String tagclass = td.getTagClass();
Class c = loadClass(result, tagclass);
if (c != null) {
if (tld.getSpecVersion().trim().equalsIgnoreCase("2.0")) {
failed = !javax.servlet.jsp.tagext.JspTag.class.isAssignableFrom(c);
} else {
failed = !javax.servlet.jsp.tagext.Tag.class.isAssignableFrom(c);
}
if (failed) {
oneFailed = true;
addErrorDetails(result, compName);
result.addErrorDetails(smh.getLocalString(getClass().getName() + ".failed", "Error: tag class [ {0} ] in [ {1} ] does not implements valid interface", new Object[] { c.getName(), tld.getUri() }));
} else {
addGoodDetails(result, compName);
result.addGoodDetails(smh.getLocalString(getClass().getName() + ".passed1", "tag class [ {0} ] in [ {1} ] implements valid interface", new Object[] { c.getName(), tld.getUri() }));
}
}
}
// for
}
if (oneFailed)
result.setStatus(Result.FAILED);
else
result.setStatus(Result.PASSED);
return result;
}
use of com.sun.enterprise.tools.verifier.web.TagDescriptor in project Payara by payara.
the class TagNameIsUnique method check.
public Result check(WebBundleDescriptor descriptor) {
ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
VerifierTestContext context = getVerifierContext();
Result result = loadWarFile(descriptor);
TagLibDescriptor[] tlds = context.getTagLibDescriptors();
if (tlds == null) {
addGoodDetails(result, compName);
result.passed(smh.getLocalString(getClass().getName() + ".passed", "No tag lib files are specified"));
return result;
}
for (TagLibDescriptor tld : tlds) {
TagDescriptor[] tagDesc = tld.getTagDescriptors();
List<String> name = new ArrayList<String>();
for (TagDescriptor td : tagDesc) {
name.add(td.getTagName());
}
if (name != null) {
String[] names = (String[]) name.toArray(new String[0]);
if (!checkForDuplicateNames(result, compName, names, tld)) {
addGoodDetails(result, compName);
result.addGoodDetails(smh.getLocalString(getClass().getName() + ".passed1", "All 'name' elements are defined properly under tag element of [ {0} ]", new Object[] { tld.getUri() }));
}
}
}
if (oneFailed) {
result.setStatus(Result.FAILED);
} else {
result.setStatus(Result.PASSED);
}
return result;
}
use of com.sun.enterprise.tools.verifier.web.TagDescriptor in project Payara by payara.
the class TagLibDescriptor method getTagDescriptors.
/**
* for each tag in the tag lib descriptor create a TagDescriptor and return
* the array of TagDescriptors present in the tag lib.
* @return
*/
public TagDescriptor[] getTagDescriptors() {
NodeList nl = doc.getElementsByTagName(TAG);
TagDescriptor[] tagdescriptor = null;
if (nl != null) {
int size = nl.getLength();
tagdescriptor = new TagDescriptor[size];
for (int i = 0; i < size; i++) {
tagdescriptor[i] = new TagDescriptor(nl.item(i));
}
}
return tagdescriptor;
}
use of com.sun.enterprise.tools.verifier.web.TagDescriptor in project Payara by payara.
the class TagClassImplementsValidInterface method check.
public Result check(WebBundleDescriptor descriptor) {
ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
VerifierTestContext context = getVerifierContext();
Result result = getInitializedResult();
ClassLoader cl = context.getClassLoader();
TagLibDescriptor[] tlds = context.getTagLibDescriptors();
if (tlds == null) {
addGoodDetails(result, compName);
result.passed(smh.getLocalString(getClass().getName() + ".passed", "No tag lib files are specified"));
return result;
}
for (TagLibDescriptor tld : tlds) {
if (tld.getSpecVersion().compareTo("2.0") >= 0) {
for (TagDescriptor tagdesc : tld.getTagDescriptors()) {
Class c = null;
try {
c = Class.forName(tagdesc.getTagClass(), false, cl);
} catch (ClassNotFoundException e) {
// do nothing
}
if (tagdesc.getDynamicAttributes().equalsIgnoreCase("true") && !javax.servlet.jsp.tagext.DynamicAttributes.class.isAssignableFrom(c)) {
addErrorDetails(result, compName);
result.failed(smh.getLocalString(getClass().getName() + ".failed", "Error: tag class [ {0} ] in [ {1} ] does not " + "implements interface " + "javax.servlet.jsp.tagext.DynamicAttributes", new Object[] { c.getName(), tld.getUri() }));
}
}
}
}
if (result.getStatus() != Result.FAILED) {
addGoodDetails(result, compName);
result.passed(smh.getLocalString(getClass().getName() + ".passed1", "All tag-class defined in the tag lib descriptor" + " files implement valid interface"));
}
return result;
}
Aggregations