001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com) 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * For further information about Alkacon Software GmbH & Co. KG, please see the 018 * company website: http://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: http://www.opencms.org 022 * 023 * You should have received a copy of the GNU Lesser General Public 024 * License along with this library; if not, write to the Free Software 025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 026 */ 027 028package org.opencms.setup.comptest; 029 030import org.opencms.setup.CmsSetupBean; 031 032/** 033 * Tests the servlet container.<p> 034 * 035 * @since 6.1.8 036 */ 037public class CmsSetupTestServletContainer implements I_CmsSetupTest { 038 039 /** The test name. */ 040 public static final String TEST_NAME = "Servlet Container"; 041 042 /** 043 * @see org.opencms.setup.comptest.I_CmsSetupTest#execute(org.opencms.setup.CmsSetupBean) 044 */ 045 public CmsSetupTestResult execute(CmsSetupBean setupBean) { 046 047 CmsSetupTestResult testResult = new CmsSetupTestResult(this); 048 049 String[][] supportedContainers = { 050 {"Apache Tomcat/4.1", null}, 051 {"Apache Tomcat/5", null}, 052 {"Apache Tomcat/6", null}, 053 {"Apache Tomcat/7", null}, 054 {"Apache Tomcat/8", null}, 055 {"Apache Tomcat/9", null}, 056 {"WebLogic Server 9", null}, 057 { 058 "Resin/3", 059 "Please be sure that during the Setup Wizard, the web application auto-redeployment feature is deactivated. One way to achieve this, is to set the '<code>dependency-check-interval</code>' option in your <code>resin.conf</code> configuration file to <code>-1</code> or something big like <code>2000s</code>."}, 060 { 061 "IBM WebSphere Application Server/6", 062 "The only limitation found so far, is that when using the <code>sendRedirect</code> method you have always to use an absolute path."}, 063 {"Sun GlassFish Enterprise Server v2.1", null}, 064 { 065 "GlassFish/v3", 066 "GlassFish/v3 is not a stable release and subject to major changes. Please prefer a stable release."}, 067 {"JBoss Web/2.1.3.GA", null}}; 068 069 String[][] unsupportedContainers = { 070 {"Tomcat Web Server/3", "Tomcat 3.x is no longer supported. Please use at least Tomcat 4.1 instead."}, 071 {"Apache Tomcat/4.0", "Tomcat 4.0.x is no longer supported. Please use at least Tomcat 4.1 instead."}, 072 {"Resin/2", "The OpenCms JSP integration does not work with Resin 2.x. Please use Resin 3 instead."}, 073 { 074 "IBM WebSphere Application Server/5", 075 "OpenCms has problems with the way Websphere handles the <code>sendRedirect</code> method. Please use at least WebSphere 6 instead."}}; 076 077 String servletContainer = setupBean.getServletConfig().getServletContext().getServerInfo(); 078 testResult.setResult(servletContainer); 079 080 int supportedServletContainer = hasSupportedServletContainer(servletContainer, supportedContainers); 081 int unsupportedServletContainer = unsupportedServletContainer(servletContainer, unsupportedContainers); 082 083 if (unsupportedServletContainer > -1) { 084 testResult.setRed(); 085 testResult.setInfo(unsupportedContainers[unsupportedServletContainer][1]); 086 testResult.setHelp( 087 "This servlet container does not work with OpenCms. Even though OpenCms is fully standards compliant, " 088 + "the standard leaves some 'grey' (i.e. undefined) areas. " 089 + "Please consider using another, supported servlet container."); 090 } else if (supportedServletContainer < 0) { 091 testResult.setYellow(); 092 testResult.setHelp( 093 "This servlet container has not been tested with OpenCms. Please consider using another, supported servlet container."); 094 } else if (supportedContainers[supportedServletContainer][1] != null) { 095 // set additional info for supported servlet containers 096 testResult.setInfo(supportedContainers[supportedServletContainer][1]); 097 } else { 098 testResult.setGreen(); 099 } 100 return testResult; 101 } 102 103 /** 104 * @see org.opencms.setup.comptest.I_CmsSetupTest#getName() 105 */ 106 public String getName() { 107 108 return TEST_NAME; 109 } 110 111 /** 112 * Checks if the used servlet container is part of the servlet containers OpenCms supports.<p> 113 * 114 * @param thisContainer The servlet container in use 115 * @param supportedContainers All known servlet containers OpenCms supports 116 * 117 * @return true if this container is supported, false if it was not found in the list 118 */ 119 private int hasSupportedServletContainer(String thisContainer, String[][] supportedContainers) { 120 121 for (int i = 0; i < supportedContainers.length; i++) { 122 if (thisContainer.indexOf(supportedContainers[i][0]) >= 0) { 123 return i; 124 } 125 } 126 return -1; 127 } 128 129 /** 130 * Checks if the used servlet container is part of the servlet containers OpenCms 131 * does NOT support.<p> 132 * 133 * @param thisContainer the servlet container in use 134 * @param unsupportedContainers all known servlet containers OpenCms does NOT support 135 * 136 * @return the container id or -1 if the container is not supported 137 */ 138 private int unsupportedServletContainer(String thisContainer, String[][] unsupportedContainers) { 139 140 for (int i = 0; i < unsupportedContainers.length; i++) { 141 if (thisContainer.indexOf(unsupportedContainers[i][0]) >= 0) { 142 return i; 143 } 144 } 145 return -1; 146 } 147}