1 31 32 package org.opencms.setup.comptest; 33 34 import org.opencms.setup.CmsSetupBean; 35 36 import javax.servlet.ServletConfig ; 37 38 47 public class CmsSetupTestServletEngine implements I_CmsSetupTest { 48 49 50 public static final String TEST_NAME = "Servlet Engine"; 51 52 55 public String getName() { 56 57 return TEST_NAME; 58 } 59 60 63 public CmsSetupTestResult execute(CmsSetupBean setupBean) { 64 65 CmsSetupTestResult testResult = new CmsSetupTestResult(this); 66 67 String [] supportedEngines = {"Apache Tomcat/4.1", "Apache Tomcat/4.0", "Apache Tomcat/5.0", "Apache Tomcat/5.5"}; 68 69 String [] unsupportedEngines = {"Tomcat Web Server/3.2", "Tomcat Web Server/3.3", "Resin/2.0.b2"}; 70 71 String [] unsupportedServletEngineInfo = { 72 "Tomcat 3.2 is no longer supported. Please use Tomcat 4.x instead.", 73 "Tomcat 3.3 is no longer supported. Please use Tomcat 4.x instead.", 74 "The OpenCms JSP integration does currently not work with Resin. Please use Tomcat 4.x instead."}; 75 76 ServletConfig config = setupBean.getServletConfig(); 77 String servletEngine = config.getServletContext().getServerInfo(); 78 boolean supportedServletEngine = hasSupportedServletEngine(servletEngine, supportedEngines); 79 int unsupportedServletEngine = unsupportedServletEngine(servletEngine, unsupportedEngines); 80 81 testResult.setResult(servletEngine); 82 83 if (unsupportedServletEngine > -1) { 84 testResult.setRed(); 85 testResult.setInfo(unsupportedServletEngineInfo[unsupportedServletEngine]); 86 testResult.setHelp("This servlet engine does not work with OpenCms. Even though OpenCms is fully standards compliant, " 87 + "the standard leaves some 'grey' (i.e. undefined) areas. " 88 + "Please consider using another, supported engine."); 89 } else if (!supportedServletEngine) { 90 testResult.setYellow(); 91 testResult.setHelp("This servlet engine has not been tested with OpenCms. Please consider using another, supported engine."); 92 } else { 93 testResult.setGreen(); 94 } 95 return testResult; 96 } 97 98 106 private boolean hasSupportedServletEngine(String thisEngine, String [] supportedEngines) { 107 108 boolean supported = false; 109 engineCheck: for (int i = 0; i < supportedEngines.length; i++) { 110 if (thisEngine.indexOf(supportedEngines[i]) >= 0) { 111 supported = true; 112 break engineCheck; 113 } 114 } 115 return supported; 116 } 117 118 126 private int unsupportedServletEngine(String thisEngine, String [] unsupportedEngines) { 127 128 for (int i = 0; i < unsupportedEngines.length; i++) { 129 if (thisEngine.indexOf(unsupportedEngines[i]) >= 0) { 130 return i; 131 } 132 } 133 return -1; 134 } 135 } 136 | Popular Tags |