shuber      2005/05/31 16:13:57 CEST

  Modified files:
    core/src/java/org/jahia/bin JahiaConfigurationWizard.java 
  Log:
  Added code to support Tomcat 5.5. We now check the version of Tomcat when 
looking for the context descriptor jahia.xml as it may change place between 
version 4 and 5 of Tomcat.
  
  Revision  Changes    Path
  1.10      +44 -7     
jahia/core/src/java/org/jahia/bin/JahiaConfigurationWizard.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/bin/JahiaConfigurationWizard.java.diff?r1=1.9&r2=1.10&f=h
  
  
  
  Index: JahiaConfigurationWizard.java
  ===================================================================
  RCS file: 
/home/cvs/repository/jahia/core/src/java/org/jahia/bin/JahiaConfigurationWizard.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- JahiaConfigurationWizard.java     23 Feb 2005 15:30:17 -0000      1.9
  +++ JahiaConfigurationWizard.java     31 May 2005 14:13:56 -0000      1.10
  @@ -1,4 +1,4 @@
  -// $Id: JahiaConfigurationWizard.java,v 1.9 2005/02/23 15:30:17 shuber Exp $
  +// $Id: JahiaConfigurationWizard.java,v 1.10 2005/05/31 14:13:56 shuber Exp $
   //
   //                                   ____.
   //                       __/\ ______|    |__/\.     _______
  @@ -101,6 +101,7 @@
   
   import org.apache.jetspeed.tools.pamanager.PortletApplicationManager;
   import java.util.Map;
  +import org.jahia.utils.Version;
   
   
   /**
  @@ -1231,12 +1232,48 @@
               // store jahia.properties file...
               properties.storeProperties( Jahia.getJahiaPropertiesFileName() );
   
  -            // update the XML file configuration
  -            JetspeedDataSourceConfigurator configurator = new 
JetspeedDataSourceConfigurator();
  -
  -            // TODO: the jahia.xml file is located in different location for 
Tomcat5
  -            String jahiaXml = 
context.getRealPath("/.."+request.getContextPath() +".xml");
  -            configurator.updateDataSourceConfiguration(jahiaXml, jahiaXml, 
values);
  +            // Update Tomcat specific context descritor that contains
  +            // database configuration.
  +            String serverInfo = context.getServerInfo();
  +            if (serverInfo.indexOf(JahiaConstants.SERVER_TOMCAT) != -1) {
  +
  +                // we assume in the following code that Tomcat follows the
  +                // servlet API convention for serverInfo format. If it does
  +                // not the code will fail.
  +                int separatorPos = serverInfo.indexOf("/");
  +                int parenPos = serverInfo.indexOf("(", separatorPos);
  +                String versionStr = null;
  +                if (parenPos != -1) {
  +                    versionStr = serverInfo.substring(separatorPos +1, 
parenPos);
  +                } else {
  +                    versionStr = serverInfo.substring(separatorPos +1);
  +                }
  +                versionStr = versionStr.trim();
  +                Version currentTomcatVersion = new Version(versionStr);
  +                Version tomcatVersion5 = new Version("5.0");
  +
  +                // update the XML file configuration
  +                JetspeedDataSourceConfigurator configurator = new 
JetspeedDataSourceConfigurator();
  +
  +                // TODO: the jahia.xml file is located in different location 
for Tomcat5
  +                String jahiaXml = context.getRealPath("/.." +
  +                                                      
request.getContextPath() + ".xml");
  +                if (currentTomcatVersion.compareTo(tomcatVersion5) >= 0) {
  +                    String contextName = request.getContextPath();
  +                    if (contextName.startsWith("/")) {
  +                        // let's remove initial slash
  +                        contextName = contextName.substring(1);
  +                    }
  +                    jahiaXml = properties.getProperty("serverHomeDiskPath") +
  +                               "conf" +
  +                               File.separator + "Catalina" +
  +                               File.separator + "localhost" +
  +                               File.separator + contextName +
  +                               ".xml";
  +                }
  +                configurator.updateDataSourceConfiguration(jahiaXml,
  +                    jahiaXml, values);
  +            }
   
               // okay, everthing is okay... set error to false
               error = false;
  

Reply via email to