Return-Path: Delivered-To: apmail-ws-axis-dev-archive@www.apache.org Received: (qmail 91428 invoked from network); 6 Jan 2005 07:27:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 6 Jan 2005 07:27:24 -0000 Received: (qmail 56704 invoked by uid 500); 6 Jan 2005 07:27:23 -0000 Delivered-To: apmail-ws-axis-dev-archive@ws.apache.org Received: (qmail 56649 invoked by uid 500); 6 Jan 2005 07:27:22 -0000 Mailing-List: contact axis-cvs-help@ws.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Delivered-To: mailing list axis-cvs@ws.apache.org Received: (qmail 56636 invoked by uid 99); 6 Jan 2005 07:27:22 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Wed, 05 Jan 2005 23:27:22 -0800 Received: (qmail 91395 invoked by uid 1700); 6 Jan 2005 07:27:20 -0000 Date: 6 Jan 2005 07:27:20 -0000 Message-ID: <20050106072720.91394.qmail@minotaur.apache.org> From: toshi@apache.org To: ws-axis-cvs@apache.org Subject: cvs commit: ws-axis/java/webapps/axis i18nLib.jsp index.jsp happyaxis.jsp X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N toshi 2005/01/05 23:27:20 Modified: java/webapps/axis happyaxis.jsp Added: java/webapps/axis i18nLib.jsp index.jsp Log: For i18n of Axis webapps. Revision Changes Path 1.19 +92 -128 ws-axis/java/webapps/axis/happyaxis.jsp Index: happyaxis.jsp =================================================================== RCS file: /home/cvs/ws-axis/java/webapps/axis/happyaxis.jsp,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- happyaxis.jsp 30 Dec 2004 02:01:19 -0000 1.18 +++ happyaxis.jsp 6 Jan 2005 07:27:20 -0000 1.19 @@ -1,13 +1,14 @@ -<%@ page import="java.io.InputStream, +<%@ page contentType="text/html; charset=utf-8" + import="java.io.InputStream, java.io.IOException, javax.xml.parsers.SAXParser, java.lang.reflect.*, javax.xml.parsers.SAXParserFactory" session="false" %> - <% - /* - * Copyright 2002,2004 The Apache Software Foundation. +<% +/* + * Copyright 2002,2004,2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,12 +23,8 @@ * limitations under the License. */ %> - -Axis Happiness Page - - -<%! +<%! /* * Happiness tests for axis. These look at the classpath and warn if things * are missing. Normally addng this much code in a JSP page is mad @@ -38,20 +35,6 @@ * @author Brian Ewins */ - - /** - * Get a string providing install information. - * TODO: make this platform aware and give specific hints - */ - public String getInstallHints(HttpServletRequest request) { - - String hint= - "Note: On Tomcat 4.x and Java1.4, you may need to put libraries that contain " - +"java.* or javax.* packages into CATALINA_HOME/common/lib" - +"
jaxrpc.jar and saaj.jar are two such libraries."; - return hint; - } - /** * test for a class existing * @param classname @@ -106,39 +89,28 @@ if(clazz == null) { String url=""; if(homePage!=null) { - url="
See "+homePage+""; + url=getMessage("seeHomepage",homePage,homePage); } - out.write("

"+category+": could not find class "+classname - +" from file "+jarFile - +"
"+errorText - +url - +"

"); + out.write(getMessage("couldNotFound",category,classname,jarFile,errorText,url)); return 1; } else { String location = getLocation(out, clazz); + if(location == null) { - out.write("Found "+ description + " (" + classname + ")
"); + out.write("

  • "+getMessage("foundClass00",description,classname)+"

  • "); } else { - out.write("Found "+ description + " (" + classname + ") at " + location + "
    "); + out.write("
  • "+getMessage("foundClass01",description,classname,location)+"

  • "); } return 0; } } catch(NoClassDefFoundError ncdfe) { String url=""; if(homePage!=null) { - url="
    See "+homePage+""; + url=getMessage("seeHomepage",homePage,homePage); } - out.write("

    "+category+": could not find a dependency" - +" of class "+classname - +" from file "+jarFile - +"
    "+errorText - +url - +"
    The root cause was: "+ncdfe.getMessage() - +"
    This can happen e.g. if "+classname+" is in" - +" the 'common' classpath, but a dependency like " - +" activation.jar is only in the webapp classpath." - +"

    "); + out.write(getMessage("couldNotFoundDep",category, classname, errorText, url)); + out.write(getMessage("theRootCause",ncdfe.getMessage(), classname)); return 1; } } @@ -168,7 +140,7 @@ } } catch (Throwable t){ } - return "an unknown location"; + return getMessage("classFoundError"); } /** @@ -188,7 +160,7 @@ String errorText, String homePage) throws IOException { return probeClass(out, - "Error", + ""+getMessage("error")+"", classname, jarFile, description, @@ -213,7 +185,7 @@ String errorText, String homePage) throws IOException { return probeClass(out, - "Warning", + ""+getMessage("warning")+"", classname, jarFile, description, @@ -222,28 +194,6 @@ } /** - * probe for a resource existing, - * @param out - * @param resource - * @param errorText - * @throws Exception - */ - int wantResource(JspWriter out, - String resource, - String errorText) throws Exception { - if(!resourceExists(resource)) { - out.write("

    Warning: could not find resource "+resource - +"
    " - +errorText); - return 0; - } else { - out.write("found "+resource+"
    "); - return 1; - } - } - - - /** * get servlet version string * */ @@ -255,8 +205,6 @@ return Integer.toString(major) + '.' + Integer.toString(minor); } - - /** * what parser are we using. * @return the classname of the parser @@ -264,7 +212,7 @@ private String getParserName() { SAXParser saxParser = getSAXParser(); if (saxParser == null) { - return "Could not create an XML Parser"; + return getMessage("couldNotCreateParser"); } // check to what is in the classname @@ -323,15 +271,32 @@ } return false; } - %> -Axis Happiness Page - -

    Axis Happiness Page

    -

    Examining webapp configuration

    -

    -

    Needed Components

    +<%@ include file="i18nLib.jsp" %> + +<% + // initialize a private HttpServletRequest + setRequest(request); +%> + + +<%= getMessage("pageTitle") %> + + + +<% + out.print("

    "+ getMessage("pageTitle") +"

    "); + out.print("

    "+ getMessage("pageRole") +"

    "); +%> + +<%= getLocaleChoice() %> + +<% + out.print("

    "+ getMessage("neededComponents") +"

    "); +%> + +
      <% int needed=0,wanted=0; @@ -347,44 +312,45 @@ needed = needClass(out, "javax.xml.soap.SOAPMessage", "saaj.jar", "SAAJ API", - "Axis will not work", + getMessage("criticalErrorMessage"), "http://ws.apache.org/axis/"); } else { String location = getLocation(out, clazz); - out.write("Error: Invalid version of SAAJ API found in " + - location + ". Make sure that Axis' saaj.jar " + - "precedes " + location + " in CLASSPATH.
      " + - "Axis will not work. See Axis installation instructions for more information
      "); + + out.print(getMessage("invalidSAAJ",location)); + out.print(getMessage("criticalErrorMessage")); + out.print(getMessage("seeHomepage","http://ws.apache.org/axis/java/install.html",getMessage("axisInstallation"))); + out.print("
      "); } needed+=needClass(out, "javax.xml.rpc.Service", "jaxrpc.jar", "JAX-RPC API", - "Axis will not work", + getMessage("criticalErrorMessage"), "http://ws.apache.org/axis/"); needed+=needClass(out, "org.apache.axis.transport.http.AxisServlet", "axis.jar", "Apache-Axis", - "Axis will not work", + getMessage("criticalErrorMessage"), "http://ws.apache.org/axis/"); needed+=needClass(out, "org.apache.commons.discovery.Resource", "commons-discovery.jar", "Jakarta-Commons Discovery", - "Axis will not work", + getMessage("criticalErrorMessage"), "http://jakarta.apache.org/commons/discovery/"); needed+=needClass(out, "org.apache.commons.logging.Log", "commons-logging.jar", "Jakarta-Commons Logging", - "Axis will not work", + getMessage("criticalErrorMessage"), "http://jakarta.apache.org/commons/logging/"); needed+=needClass(out, "org.apache.log4j.Layout", "log4j-1.2.8.jar", "Log4j", - "Axis may not work", + getMessage("uncertainErrorMessage"), "http://jakarta.apache.org/log4j"); //should we search for a javax.wsdl file here, to hint that it needs @@ -392,22 +358,26 @@ needed+=needClass(out, "com.ibm.wsdl.factory.WSDLFactoryImpl", "wsdl4j.jar", "IBM's WSDL4Java", - "Axis will not work", + getMessage("criticalErrorMessage"), null); needed+=needClass(out, "javax.xml.parsers.SAXParserFactory", "xerces.jar", "JAXP implementation", - "Axis will not work", + getMessage("criticalErrorMessage"), "http://xml.apache.org/xerces-j/"); needed+=needClass(out,"javax.activation.DataHandler", "activation.jar", "Activation API", - "Axis will not work", + getMessage("criticalErrorMessage"), "http://java.sun.com/products/javabeans/glasgow/jaf.html"); %> -

      Optional Components

      +
    +<% + out.print("

    "+ getMessage("optionalComponents") +"

    "); +%> +
      <% /* * now the stuff we can live without @@ -415,87 +385,81 @@ wanted+=wantClass(out,"javax.mail.internet.MimeMessage", "mail.jar", "Mail API", - "Attachments will not work", + getMessage("attachmentsError"), "http://java.sun.com/products/javamail/"); wanted+=wantClass(out,"org.apache.xml.security.Init", "xmlsec.jar", "XML Security API", - "XML Security is not supported", + getMessage("xmlSecurityError"), "http://xml.apache.org/security/"); wanted += wantClass(out, "javax.net.ssl.SSLSocketFactory", "jsse.jar or java1.4+ runtime", "Java Secure Socket Extension", - "https is not supported", + getMessage("httpsError"), "http://java.sun.com/products/jsse/"); /* * resources on the classpath path */ - /* broken; this is a file, not a resource - wantResource(out,"/server-config.wsdd", - "There is no server configuration file;" - +"run AdminClient to create one"); - */ /* add more libraries here */ +%> +
    +<% out.write("

    "); //is everythng we need here if(needed==0) { //yes, be happy - out.write("The core axis libraries are present. "); + out.write(getMessage("happyResult00")); } else { //no, be very unhappy response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); - out.write("" - +needed - +" core axis librar" - +(needed==1?"y is":"ies are") - +" missing"); + out.write(getMessage("unhappyResult00",Integer.toString(needed))); } //now look at wanted stuff if(wanted>0) { - out.write("" - +wanted - +" optional axis librar" - +(wanted==1?"y is":"ies are") - +" missing"); + out.write(getMessage("unhappyResult01",Integer.toString(wanted))); } else { - out.write("The optional components are present."); + out.write(getMessage("happyResult01")); } out.write("

    "); +%> +
      +<% + //hint if anything is missing if(needed>0 || wanted>0 ) { - out.write(getInstallHints(request)); + out.write(getMessage("hintString")); } - %> -

      - Note: Even if everything this page probes for is present, there is no guarantee your - web service will work, because there are many configuration options that we do - not check for. These tests are necessary but not sufficient -


      + out.write(getMessage("noteString")); +%> +
    -

    Examining Application Server

    +

    <%= getMessage("apsExamining") %>

    + +
      <% String servletVersion=getServletVersion(); String xmlParser=getParserName(); String xmlParserLocation = getParserLocation(out); - %> - +
      Servlet version<%= servletVersion %>
      XML Parser<%= xmlParser %>
      XML ParserLocation<%= xmlParserLocation %>
      +
    + <% if(xmlParser.indexOf("crimson")>=0) { %>

    - We recommend Xerces 2 - over Crimson as the XML parser for Axis + <%= getMessage("recommendedParser") %>

    <% } %> -

    Examining System Properties

    +

    <%= getMessage("sysExamining") %>

    +
      <% /** * Dump the system properties @@ -513,12 +477,12 @@ } out.write("

      "); } else { - out.write("System properties are not accessible

      "); + out.write(getMessage("sysPropError")); } %> +


    - Platform: <%= getServletConfig().getServletContext().getServerInfo() %> + <%= getMessage("apsPlatform") %>: + <%= getServletConfig().getServletContext().getServerInfo() %> - - 1.1 ws-axis/java/webapps/axis/i18nLib.jsp Index: i18nLib.jsp =================================================================== <%@ page contentType="text/html; charset=utf-8" import="java.util.*" %> <% /* * Copyright 2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ %> <%! /* * A library file to produce i18n web applications. This can be easily * reused from your jsp(s) - just include and call any methods. * @author toshi */ // private variable HttpServletRequest _req = null; /** * Set a HttpServletRequest to a private variable. * @param request HttpServletRequest */ void setRequest(HttpServletRequest request) { _req = request; } /** * Get a ResourceBundle object. * @return a ResourceBundle object */ ResourceBundle getRB() { String strLocale = _req.getParameter("locale"); ResourceBundle objRb = null; Locale objLcl = null; if (strLocale!=null) { objLcl=new Locale(strLocale,""); } else { objLcl=_req.getLocale(); } Locale.setDefault(objLcl); objRb = ResourceBundle.getBundle("i18n",objLcl); return objRb; } /** * Get a list of locale choice * @return a list of supported locales */ String getLocaleChoice() { String choice = getRB().getString("locales"); StringBuffer buf = new StringBuffer(); buf.append("
    \n"); buf.append(getRB().getString("language")); buf.append(": "); StringTokenizer st = new StringTokenizer(choice); String locale = null; while (st.hasMoreTokens()) { locale = st.nextToken(); buf.append("["+ locale +"] "); } buf.append("\n
    \n"); return buf.toString(); } /** * Get a message from i18n.properties with several arguments. * @param key The resource key * @return The formatted message */ String getMessage(String key) { return getMessage(key, null, null, null, null, null); } /** * Get a message from i18n.properties with several arguments. * @param key The resource key * @param arg0 The argument to place in variable {0} * @return The formatted message */ String getMessage(String key, String arg0) { return getMessage(key, arg0, null, null, null, null); } /** * Get a message from i18n.properties with several arguments. * @param key The resource key * @param arg0 The argument to place in variable {0} * @param arg1 The argument to place in variable {1} * @return The formatted message */ String getMessage(String key, String arg0, String arg1) { return getMessage(key, arg0, arg1, null, null, null); } /** * Get a message from i18n.properties with several arguments. * @param key The resource key * @param arg0 The argument to place in variable {0} * @param arg1 The argument to place in variable {1} * @param arg2 The argument to place in variable {2} * @return The formatted message */ String getMessage(String key, String arg0, String arg1, String arg2) { return getMessage(key, arg0, arg1, arg2, null, null); } /** * Get a message from i18n.properties with several arguments. * @param key The resource key * @param arg0 The argument to place in variable {0} * @param arg1 The argument to place in variable {1} * @param arg2 The argument to place in variable {2} * @param arg3 The argument to place in variable {3} * @return The formatted message */ String getMessage(String key, String arg0, String arg1, String arg2, String arg3) { return getMessage(key, arg0, arg1, arg2, arg3, null); } /** * Get a message from i18n.properties with several arguments. * @param key The resource key * @param arg0 The argument to place in variable {0} * @param arg1 The argument to place in variable {1} * @param arg2 The argument to place in variable {2} * @param arg3 The argument to place in variable {3} * @param arg4 The argument to place in variable {4} * @return The formatted message */ String getMessage(String key, String arg0, String arg1, String arg2, String arg3, String arg4) { String strPattern = getRB().getString(key); String [] params = { arg0, arg1, arg2, arg3, arg4 }; for (int i=0; i<5; i++) { if (params[i]!=null) params[i]=params[i].replaceAll("\\\\","\\\\\\\\"); if (params[i]!=null) params[i]=params[i].replaceAll("%20"," "); } if (arg0!=null) strPattern = strPattern.replaceAll("\\{0\\}",params[0]); if (arg1!=null) strPattern = strPattern.replaceAll("\\{1\\}",params[1]); if (arg2!=null) strPattern = strPattern.replaceAll("\\{2\\}",params[2]); if (arg3!=null) strPattern = strPattern.replaceAll("\\{3\\}",params[3]); if (arg4!=null) strPattern = strPattern.replaceAll("\\{4\\}",params[4]); return strPattern; } %> 1.1 ws-axis/java/webapps/axis/index.jsp Index: index.jsp =================================================================== <%@ page contentType="text/html; charset=utf-8" %> <% /* * Copyright 2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ %> <%@ include file="i18nLib.jsp" %> <% // initialize a private HttpServletRequest setRequest(request); %> Apache-Axis

    Apache-AXIS

    <%= getLocaleChoice() %> <% out.print(getMessage("welcomeMessage")+"

    "); out.print(getMessage("operationType")); %>

    <% out.print(getMessage("sideNote") +"

    "); %> <% out.print("

    "+ getMessage("validatingAxis") +"

    "); out.print(getMessage("validationNote00") +"

    "); out.print(getMessage("validationNote01")); %>