Example #1
0
  @Override
  protected void doCheck(
      SSPHandler sspHandler, Elements elements, TestSolutionHandler testSolutionHandler) {
    SSP ssp = sspHandler.getSSP();

    // if the page doesn't have any doctype declaration, the test is
    // not applicable
    if (StringUtils.isBlank(ssp.getDoctype())) {
      testSolutionHandler.addTestSolution(TestSolution.NOT_APPLICABLE);
      return;
    }
    String sourcePage = ssp.getAdaptedContent();
    int indexOfDoctype = StringUtils.indexOfIgnoreCase(sourcePage, DOCTYPE_KEY);

    int indexOfHtmlTag = StringUtils.indexOfIgnoreCase(sourcePage, HTML_ELEMENT_KEY);

    if (indexOfHtmlTag < indexOfDoctype
        || StringUtils.indexOfIgnoreCase(sourcePage, DOCTYPE_KEY, indexOfHtmlTag) != -1) {

      testSolutionHandler.addTestSolution(getFailureSolution());
      addProcessRemark(getFailureSolution(), BAD_DOCTYPE_LOCATION_MSG);

    } else {

      testSolutionHandler.addTestSolution(getSuccessSolution());
    }
  }
 private String extractZETAISBN(String pageText) {
   int indexISBN = StringUtils.indexOfIgnoreCase(pageText, "ISBN");
   int indexOf = StringUtils.indexOf(pageText, " ", indexISBN + 15);
   if (indexOf > -1 && indexOf > indexISBN) {
     return StringUtils.substring(pageText, indexISBN, indexOf);
   }
   return "";
 }