mnu_start.jsp 4.08 KB
Newer Older
CED SA's avatar
CED SA committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
<?xml version = '1.0' encoding = 'utf-8'?>
<%@ page import="java.util.Enumeration" %>
<%@ page import="java.net.URL" %>

<%
  String href="\"/client/web/mnu_start.jsp?";
  Enumeration enum=request.getParameterNames();
  while(enum.hasMoreElements())
  {
    String name=(String)enum.nextElement();
    href+=name+"="+request.getParameter(name);
    if (enum.hasMoreElements())
      href+="&";
  }
  href+="\"";
  // in questa parte faccio la verifica dei parametri e nel caso cartauz tiro un cartauz
  String appType=request.getParameter("appServerType");
  
  String port = request.getParameter("port");
  String j2eeUser = request.getParameter("j2eeUser");
  String j2eePassword=request.getParameter("j2eePassword");
  String user=request.getParameter("user"),
         password=request.getParameter("password"),
         specJnlp=null,
         serverType=null;
  String rmiPort = null;
         
  if (appType == null) appType = "jboss";
  
  if (port == null) port = String.valueOf(request.getServerPort());
  if (j2eeUser == null) 
  {
    String db = request.getParameter("db");
    if (db != null)
    {
      String[] tt = db.split(":");
      if (tt.length > 0) j2eeUser = tt[0];
      if (tt.length > 1) rmiPort  = tt[1];
    }
  }
    
  String appUrl = appType+":"+request.getServerName()+":"+port;
  if (rmiPort != null) appUrl += ":"+rmiPort;
  
  String args = request.getParameter("args"); 
  if (args != null)
  {
    String[] aa = args.split(";");
    appUrl = aa[0];
    j2eeUser = aa[1];
    j2eePassword = aa[2];
    if (aa.length>3) user = aa[3];
    if (aa.length>4) password = aa[4];
  
    String[] token = appUrl.split(":");
    appType = token[0];
    //port = token[2];
    port = token[2];
  }
           
  if (appType==null || appType.equalsIgnoreCase("jboss"))
  {
    serverType="jboss";
    specJnlp="jboss-client.jnlp";
  }
  else
    if ("OC4J".equalsIgnoreCase(appType))
    {
      serverType="oc4j";
      specJnlp="orion-client.jnlp";
    }
    else
      response.sendError(500,"il parametro appServerType deve valere \"JBOSS\" o \"OC4J\" (default = JBOSS)");
      
  
  if (j2eeUser==null)
    response.sendError(500,"il parametro j2eeUser deve essere valorizzato");
  
  // se non scrivo la password la imposto allo user
  if (j2eePassword==null)
    j2eePassword=j2eeUser;

  // dalle ultime versioni per ovviare al bug jnlp della 1.6
  // il setup cambai il nome al sicraweb-resources
  // questo algoritmo trova il nome giusto
  URL url=null;
  int i=0;
  String resourcePath=null;
  while(url==null)
  {
    String res="/sicraweb-resources"+(i==0 ? "" : "-ver"+i)+".jnlp";
    url=config.getServletContext().getResource(res);
    i++;
    if (url!=null)
    {
      resourcePath=url.getFile();
      resourcePath=resourcePath.substring(resourcePath.indexOf("/client"));
    }
  }
  %>


<jnlp spec="1.0+" 
      codebase=<%="\"http://"+request.getServerName()+":"+port+"\""%>
      href=<%=href%>>
  <information>
    <title>SicraWeb</title>
    <vendor>Saga S.p.A.</vendor>
    <homepage href="Sicraweb.html"/>
    <description>SicraWeb Menu</description>
  </information>
  <security>
    <all-permissions/>
  </security>

  <resources>
  <j2se version="1.5.0_12" href="http://java.sun.com/products/autodl/j2se" max-heap-size="512M"/>
  <jar href="/client/signed-jars/it.saga.pubblici.menu.client.jar" main="true" download="eager"/>
  <extension name="sicraweb-resources" href=<%="\""+resourcePath+"\""%>/>
  <extension name="actalis-siacapi"    href="/client/actalis-siacapi.jnlp"/>
  <extension name="gnome-javatwain"    href="/client/gnome-javatwain.jnlp"/>
  <extension name=<%="\""+specJnlp+"\""%>        href=<%="\"/client/"+specJnlp+"\""%>/>
  </resources>

  <application-desc main-class="it.saga.pubblici.menu.MnuCFGMain">
  <argument><%=appUrl%></argument>
  <argument><%=j2eeUser%></argument>
  <argument><%=j2eePassword%></argument>
  <%
    if (request.getParameter("user")!=null && request.getParameter("password")!=null)
    {%>
      <argument><%=user%></argument>
      <argument><%=password%></argument>
  <%}%>
  </application-desc>
  <% response.setContentType("application/x-java-jnlp-file"); %>
</jnlp>