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