<%@ page
  language="java"
  contentType="text/html;charset=utf-8"
  import = "java.io.File"
  import = "org.objectweb.jonas_lib.version.Version"
  import = "org.objectweb.jonas.ear.EarServiceImpl"
  import = "org.objectweb.jonas.service.ServiceManager"
  import = "org.objectweb.jonas.web.AbsJWebContainerServiceImplMBean"
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  <head>
    <meta name="description" content="JOnAS Root Context"/>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
    <style type="text/css">
      @import "ow_jonas.css";
    </style>
    <title>
      <%
        String webContainer = "";
        boolean isJetty = false;
        boolean isTomcat = false;
        boolean useEarSample = false;
	boolean useOlstore = false;
        boolean isDocumentationAvailable = false;
        boolean isJavaDocAvailable = false;
        boolean isTomcatDocAvailable = false;
        boolean isJettyDocAvailable = false;
        boolean isEmbJavaDocAvailable = false;
        try {
            ServiceManager sm = ServiceManager.getInstance();
            if (sm != null) {
                AbsJWebContainerServiceImplMBean webServ = (AbsJWebContainerServiceImplMBean) sm.getWebContainerService();
                if (webServ != null) {
                    String servName = webServ.getServerName();
                    webContainer = servName + " v" + webServ.getServerVersion();
                    if (servName != null) {
                      if (servName.indexOf("omcat") != -1) {
                          isTomcat = true;
                      } else if (servName.indexOf("etty") != -1) {
                          isJetty = true;
                      }
                    }
                    isDocumentationAvailable = webServ.isWarLoaded("autoload" + File.separator + "jonas-doc-en") || webServ.isWarLoaded("jonas-doc-en");
                    isJavaDocAvailable = webServ.isWarLoaded("autoload" + File.separator + "jonas-javadoc") || webServ.isWarLoaded("jonas-javadoc");
                    isTomcatDocAvailable = webServ.isWarLoaded("autoload" + File.separator + "tomcat-docs.war") || webServ.isWarLoaded("tomcat-docs.war");
                    isJettyDocAvailable = webServ.isWarLoaded("autoload" + File.separator + "jetty.war") || webServ.isWarLoaded("jetty.war");
                    isEmbJavaDocAvailable = webServ.isWarLoaded("autoload" + File.separator + "jonas-emb-javadoc.war") || webServ.isWarLoaded("jonas-emb-javadoc.war");
                }
                EarServiceImpl earServ = (EarServiceImpl) sm.getEarService();
                if (earServ != null) {
                    useEarSample = earServ.isEarLoaded("autoload" + File.separator + "earsample.ear") || earServ.isEarLoaded("earsample.ear");
                }
                if (earServ != null) {
                    useOlstore = earServ.isEarLoaded("olstore.ear");
                }
            }
         } catch (Exception e) {
           //Cannot retrieve infos of web container
         }
      %>
      <%
        String title = "JOnAS v" + Version.NUMBER;
        if (webContainer != null) {
        	title += " / " + webContainer;
        }
        title += " Package";
        out.print(title);
      %>
      </title>
    </head>

    <body class="bodywelcome">

      <div class="logos">
        <% if (isTomcat) {
               out.print("<a href=\"http://jakarta.apache.org\"><img title=\"Jakarta Tomcat\" alt=\"Jakarta Tomcat\" src=\"tomcat.gif\" /></a>");
           }
           if (isJetty) {
               out.print("<a href=\"http://jetty.mortbay.org/jetty/\"><img title=\"Mortbay Jetty\" alt=\"Mortbay Jetty\" src=\"jetty.gif\" /></a>");
           }
        %>
        <a href="http://jonas.objectweb.org"><img title="JOnAS WebSite" alt="JOnAS WebSite" src="ow_jonas_logo.gif" /></a>
      </div>

      <div class="titlepage">
        <%
          out.print(title);
        %>
      </div>

      <div class="links">
      <ul>
        <%
          if (useEarSample) {
            out.println("<li>");
            out.println("<a href=\"/earsample\">Test the EAR example : earsample.</a>");
            out.println("Use the login/password jonas/jonas");
            out.println("</li>");
          }
        %>
	<%
          if (useOlstore) {
            out.println("<li>");
            out.println("<a href=\"/olstore\">Test the online store example : olstore.</a>");
            out.println("Use the help page in the olstore for more information.");
            out.println("</li>");
          }
        %>
        <li>
          <a href="/jonasAdmin">Go to the JOnAS administration web application.</a>
          Use the login/password jonas/jonas
        </li>
        <%
          if (isDocumentationAvailable) {
            out.println("<li>");
            out.println("<a href=\"/jonas-doc-en\">Browse JOnAS documentation</a>");
            out.println("(Up-to-date documentation can be found on <a href=\"http://jonas.objectweb.org/current/doc/index.html\">JOnAS Web Site</a>)");
            out.println("</li>");
          }
          if (isJavaDocAvailable) {
            out.println("<li>");
            out.println("<a href=\"/jonas-javadoc\">Browse JOnAS Javadoc</a>");
            out.println("</li>");
          }
          if (isTomcatDocAvailable) {
            out.println("<li>");
            out.println("<a href=\"/tomcat-docs\">Browse Tomcat documentation</a>");
            out.println("</li>");
          }
          if (isJettyDocAvailable) {
            out.println("<li>");
            out.println("<a href=\"/jetty\">Browse Jetty documentation</a>");
            out.println("</li>");
          }
          if (isEmbJavaDocAvailable) {
              out.println("<li>");
              out.println("<a href=\"/jonas-emb-javadoc\">Browse Enterprise Media Beans Javadoc</a>");
              out.println("</li>");
          }
        %>
      </ul>
    </div>

    <div class="footer">
      <p>
        <a href="http://validator.w3.org/check/referer"><img
           src="valid-xhtml11.png"
           alt="Valid XHTML 1.1!" title="Valid XHTML 1.1!" height="31" width="88" />
        </a>
        <a href="http://jigsaw.w3.org/css-validator/"><img
           style="border:0;width:88px;height:31px" src="vcss.png" title="Valid CSS!" alt="Valid CSS!" />
        </a>
      </p>
    </div>
  </body>
</html>
