1 7 8 package fops; 9 10 import com.lutris.appserver.server.*; 11 import com.lutris.appserver.server.httpPresentation.*; 12 import com.lutris.appserver.server.session.*; 13 import com.lutris.logging.Logger; 14 import com.lutris.util.*; 15 16 import java.io.*; 17 18 19 24 public class Fopes extends StandardApplication { 25 26 File userConfigFile; 27 28 protected String DEFAULT_FILE = "userconfig.xml"; 29 protected String FOP_BASE_DIR = "Config"; 30 31 String fopBaseDir; 32 36 public void startup(Config appConfig) throws ApplicationException { 37 super.startup(appConfig); 38 39 if (logChannel != null) { 40 logChannel.write(Logger.INFO, 41 "Welcome to FopApplet Enhydra Application!"); 42 } 43 44 47 String tempString = null; 48 String file = null; 49 File tempFile=null; 50 51 53 try{ 54 fopBaseDir = appConfig.getString("FopBaseDir"); 55 tempFile = new File(fopBaseDir+File.separator+FOP_BASE_DIR); 56 if (!tempFile.exists()||!tempFile.isDirectory()){ 57 tempString = appConfig.getConfigFile().getFile().getParent(); 59 fopBaseDir = tempString+File.separator+fopBaseDir; 60 tempFile = new File(fopBaseDir+File.separator+FOP_BASE_DIR); 61 62 if (!tempFile.exists()||!tempFile.isDirectory()){ 63 fopBaseDir = null; 64 if (logChannel != null) { 65 logChannel.write(Logger.INFO, 66 "FopBaseDir application parameter not initialized - will be red from UserConfigFile!"); 67 } 68 } 69 } 70 } catch (ConfigException e) { 71 fopBaseDir = null; 72 if (logChannel != null) { 73 logChannel.write(Logger.INFO, 74 "FopBaseDir application parameter not initialized - will be red from UserConfigFile!"); 75 } 76 } 77 78 80 try{ 81 file = appConfig.getString("UserConfigFilePath"); 82 userConfigFile = new File(file); 83 84 if (!userConfigFile.exists()){ 85 tempString = appConfig.getConfigFile().getFile().getParent(); 87 file = tempString+File.separator+file; 88 userConfigFile = new File(file); 89 90 if (!userConfigFile.exists()){ 91 try{ 92 tempString = this.getClass().getClassLoader().getResource(DEFAULT_FILE).getPath(); 93 file = tempString; 94 userConfigFile = new File(file); 95 } catch (NullPointerException exc){ 96 file = DEFAULT_FILE; 97 userConfigFile = new File(file); 98 if (logChannel != null) { 99 logChannel.write(Logger.INFO, 100 "UserConfigFilePath application parameter isn't properly initialized!"); 101 } 102 } 103 } 104 } 105 } catch (ConfigException e) { 106 try{ 107 tempString = this.getClass().getClassLoader().getResource(DEFAULT_FILE).getPath(); 108 file = tempString; 109 userConfigFile = new File(file); 110 } catch (NullPointerException exc){ 111 file = DEFAULT_FILE; 112 userConfigFile = new File(file); 113 if (logChannel != null) { 114 logChannel.write(Logger.INFO, 115 "UserConfigFilePath application parameter isn't properly initialized!"); 116 } 117 } 118 } 119 120 } 121 122 public boolean requestPreprocessor(HttpPresentationComms comms) 123 throws Exception { 124 return super.requestPreprocessor(comms); 125 } 126 127 135 public String toHtml() { 136 return "This is <I>fopes</I>"; 137 } 138 139 public File getUserConfigFile () { 140 return userConfigFile; 141 } 142 143 public String getFopBaseDir () { 144 return fopBaseDir; 145 } 146 } 147 148 | Popular Tags |