<%@ page contentType="text/html;charset=UTF-8" %> <%@ page import="java.io.File,java.io.InputStream,java.io.FileInputStream,java.util.Properties" %> <% String versionFile = "jnlp.properties" ; String jnlpPrev ="eas" ; String jnlpExt = ".jnlp" ; //String configDir = System.getProperty("portal.config"); String configDir = System.getProperty("EAS_HOME") + "/server/properties/" ; //jnlp move out if(configDir == null){ throw new RuntimeException("cann't find the portalConfig file!"); } File configFile = new File(configDir); if(configFile.exists()){ configDir = configFile.getAbsolutePath()+"/"; //dir should be under properties }else{ throw new RuntimeException("cann't find the config file!"); } //get file from jnlp.properties String localDir = configDir;//getServletConfig().getServletContext().getRealPath("/"); //System.out.println(localDir); String jnlpFileName = ""; //no portal,deploy stand-alone boolean standAlone = false ; //support Eas multi client switch from one to another version,for example 5.0->5.1 boolean enableVerSwitch = false ; //allow to backup eas client max cout. int maxVerCopyCount = 2 ; String jnlpVersion = "5.1.0.0" ; String silentJnlp = "false"; String enableCache = "true"; //only read once after system start //added by linhh on 2006.7.31 String refreshCache= request.getParameter("refreshCache"); if(refreshCache == null ) { refreshCache = "false"; } if(jnlpConfigCache == null || jnlpConfigCache.size()==0 || "true".equalsIgnoreCase(refreshCache)) { File versionFileHandler = new File(localDir,versionFile); if(versionFileHandler.exists()){ try{ InputStream is = new FileInputStream(versionFileHandler); Properties prop = new Properties(); prop.load(is); jnlpVersion = prop.getProperty("version"); standAlone = new Boolean(prop.getProperty("stand_alone")).booleanValue(); enableVerSwitch = new Boolean(prop.getProperty("enableVerSwitch")).booleanValue(); silentJnlp = prop.getProperty("silentJnlp"); enableCache = prop.getProperty("enableCache"); try { maxVerCopyCount = Integer.parseInt(prop.getProperty("maxVerCopyCount")); } catch(NumberFormatException e) { maxVerCopyCount = 1 ; } if(jnlpVersion != null && !"".equals(jnlpVersion)) { String version = jnlpVersion.replace('.','_'); jnlpFileName = jnlpPrev + "_" + version + jnlpExt ; } else { jnlpFileName = jnlpPrev + jnlpExt ; } is.close() ; //added by linhh on 2006.7.31 jnlpConfigCache.put("version",(jnlpVersion==null?"5.1.0.0":jnlpVersion)); jnlpConfigCache.put("stand_alone",new Boolean(standAlone).toString()); jnlpConfigCache.put("enableVerSwitch",new Boolean(enableVerSwitch).toString()); jnlpConfigCache.put("maxVerCopyCount",new Integer(maxVerCopyCount).toString()); jnlpConfigCache.put("silentJnlp",silentJnlp); jnlpConfigCache.put("enableCache",enableCache); }catch(Exception e){ e.printStackTrace(); jnlpFileName = jnlpPrev + jnlpExt ; } } else { //System.out.println("no version"); jnlpFileName = jnlpPrev + jnlpExt ; } } else { //added by linhh on 2006.7.31 System.out.println("get jnlp config from cache."); Properties prop = jnlpConfigCache; jnlpVersion = prop.getProperty("version"); standAlone = new Boolean(prop.getProperty("stand_alone")).booleanValue(); enableVerSwitch = new Boolean(prop.getProperty("enableVerSwitch")).booleanValue(); silentJnlp = prop.getProperty("silentJnlp"); enableCache = prop.getProperty("enableCache"); try { maxVerCopyCount = Integer.parseInt(prop.getProperty("maxVerCopyCount")); } catch(NumberFormatException e) { maxVerCopyCount = 1 ; } if(jnlpVersion != null && !"".equals(jnlpVersion)) { String version = jnlpVersion.replace('.','_'); jnlpFileName = jnlpPrev + "_" + version + jnlpExt ; } else { jnlpFileName = jnlpPrev + jnlpExt ; } } String jnlpFileNameParam = request.getParameter("jnlpFileName") ; if(jnlpFileNameParam != null && !"null".equalsIgnoreCase(jnlpFileNameParam)) { //request param highest prior. jnlpFileName = jnlpFileNameParam ; } String switchCreateJnlpFile = "switch"; if(standAlone) { switchCreateJnlpFile +="_noPortal.jsp"; } else { switchCreateJnlpFile +=".jsp"; } localDir = System.getProperty("portal.config"); File localFile = new File(localDir); if(localFile.exists()) { localDir = localFile.getParentFile().getAbsolutePath()+"/"; }else { throw new RuntimeException("cann't find the config file!"); } %>