1 package org.enhydra.server; 2 3 4 import org.enhydra.util.ConfigFileInterface; 5 6 import com.lutris.util.Config; 7 import com.lutris.util.ConfigException; 8 import com.lutris.util.KeywordValueException; 9 10 18 19 public class SessionEdit { 20 21 private String sessionLifetimeMax; 22 private String sessionIdleTimeMax; 23 private String sessionNoUserIdleTimeMax; 24 private String idleScanInterval; 25 private String randomizerIntervals[]; 26 private String memoryPersistence; 27 private String mode; 28 private String maxSessions; 29 private String pageThreshold; 30 private String pageTimeThreshold; 31 private String pageWait; 32 private String saveOnRestart; 33 private String pageDir; 34 private String databaseName; 35 private String dBTableName; 36 private String sessionHomeClass; 37 private String sessionUserTableClass; 38 39 private String sessionEncodeUrlState; 40 private String sessionEncodeFirstUrl; 41 43 private String sessionLifetimeMaxDefault = "0"; 44 private String sessionIdleTimeMaxDefault = "30"; 45 private String sessionNoUserIdleTimeMaxDefault = "30"; 46 private String idleScanIntervalDefault = "30"; 47 private String randomizerIntervalsDefault[] = {"301","1001","5003"}; 48 private String memoryPersistenceDefault = "false"; 49 private String modeDefault = "BASIC"; 50 private String maxSessionsDefault = "-1"; 51 private String pageThresholdDefault = "-1"; 52 private String pageTimeThresholdDefault = "-1"; 53 private String pageWaitDefault = "60000"; 54 private String saveOnRestartDefault = "false"; 55 private String pageDirDefault = ""; 56 private String databaseNameDefault = ""; 57 private String dBTableNameDefault = "PersistentSession"; 58 private String sessionHomeClassDefault = ""; 59 private String sessionUserTableClassDefault = ""; 60 61 private String sessionEncodeUrlStateDefault = "Auto"; 62 private String sessionEncodeFirstUrlDefault = "false"; 63 64 65 Config config; 66 67 private SessionEdit() { 68 } 69 76 public SessionEdit(Config appConfig) throws ConfigException, KeywordValueException { 77 config = appConfig; 78 String temp; 79 if (config == null) throw new ConfigException("Exception in SessionEdit(), config == null"); 80 if(config.containsKey("SessionManager.Lifetime")){ setSessionLifetimeMax(config.getString("SessionManager.Lifetime")); config.remove("SessionManager.Lifetime"); }else sessionLifetimeMax = config.getString("SessionManager.SessionLifetimeMax",sessionLifetimeMaxDefault); 85 86 if(config.containsKey("SessionManager.MaxIdleTime")){ setSessionIdleTimeMax(config.getString("SessionManager.MaxIdleTime")); config.remove("SessionManager.MaxIdleTime"); }else sessionIdleTimeMax = config.getString("SessionManager.SessionIdleTimeMax",sessionIdleTimeMaxDefault); 90 91 if(config.containsKey("SessionManager.MaxNoUserIdleTime")){ setSessionNoUserIdleTimeMax(config.getString("SessionManager.MaxNoUserIdleTime")); config.remove("SessionManager.MaxNoUserIdleTime"); }else sessionNoUserIdleTimeMax = config.getString("SessionManager.SessionNoUserIdleTimeMax",sessionNoUserIdleTimeMaxDefault); 95 96 idleScanInterval = config.getString("SessionManager.IdleScanInterval",idleScanIntervalDefault); 97 98 randomizerIntervals = config.getStrings("SessionManager.RandomizerIntervals",randomizerIntervalsDefault); 99 memoryPersistence = config.getString("SessionManager.MemoryPersistence",memoryPersistenceDefault); 100 101 if(config.containsKey("SessionManager.EncodeUrlState")){ setSessionEncodeUrlState(config.getString("SessionManager.EncodeUrlState")); config.remove("SessionManager.EncodeUrlState"); }else sessionEncodeUrlState = config.getString("SessionManager.SessionEncodeUrlState",sessionEncodeUrlStateDefault); 105 106 sessionEncodeFirstUrl = config.getString("SessionManager.SessionEncodeFirstUrl",sessionEncodeFirstUrlDefault); 107 108 mode = config.getString("SessionManager.SessionHome.Mode",modeDefault); 110 maxSessions = config.getString("SessionManager.SessionHome.MaxSessions",maxSessionsDefault); 111 pageThreshold = config.getString("SessionManager.SessionHome.PageThreshold",pageThresholdDefault); 112 pageTimeThreshold = config.getString("SessionManager.SessionHome.PageTimeThreshold",pageTimeThreshold); 113 pageWait = config.getString("SessionManager.SessionHome.PageWait",pageWaitDefault); 114 saveOnRestart = config.getString("SessionManager.SessionHome.SaveOnRestart",saveOnRestartDefault); 115 pageDir = config.getString("SessionManager.SessionHome.PageDir",pageDirDefault); 116 databaseName = config.getString("SessionManager.SessionHome.DatabaseName",databaseNameDefault); 117 dBTableName = config.getString("SessionManager.SessionHome.DBTableName",dBTableNameDefault); 118 119 120 sessionHomeClass = config.getString("SessionManager.SessionHome.Class",sessionHomeClassDefault); 121 sessionUserTableClass = config.getString("SessionManager.SessionUserTable.Class",sessionUserTableClassDefault); 122 123 } 124 125 126 public String getSessionLifetimeMax() { 127 return sessionLifetimeMax; 128 } 129 public void setSessionLifetimeMax(String lifetimeMax) throws KeywordValueException{ 130 this.sessionLifetimeMax = lifetimeMax; 131 config.set("SessionManager.SessionLifetimeMax",lifetimeMax); 132 } 133 134 public String getSessionIdleTimeMax() { 135 return sessionIdleTimeMax; 136 } 137 138 public void setSessionIdleTimeMax(String idleTimeMax) throws KeywordValueException{ 139 this.sessionIdleTimeMax = idleTimeMax; 140 config.set("SessionManager.SessionIdleTimeMax",idleTimeMax); 141 } 142 143 public String getSessionNoUserIdleTimeMax() { 144 return sessionNoUserIdleTimeMax; 145 } 146 147 public void setSessionNoUserIdleTimeMax(String noUserIdleTimeMax) throws KeywordValueException{ 148 this.sessionNoUserIdleTimeMax = noUserIdleTimeMax; 149 config.set("SessionManager.SessionNoUserIdleTimeMax",noUserIdleTimeMax); 150 } 151 152 public String getIdleScanInterval() { 153 return idleScanInterval; 154 } 155 156 public void setIdleScanInterval(String idleScanInterval) throws KeywordValueException{ 157 this.idleScanInterval = idleScanInterval; 158 config.set("SessionManager.IdleScanInterval",idleScanInterval); 159 } 160 161 public String [] getRandomizerIntervals() { 162 return randomizerIntervals; 163 } 164 165 public void setRandomizerIntervals(String [] randomizerIntervals) throws KeywordValueException{ 166 this.randomizerIntervals = randomizerIntervals; 167 config.set("SessionManager.RandomizerIntervals",randomizerIntervals); 168 } 169 170 public String getMemoryPersistence() { 171 return memoryPersistence; 172 } 173 174 public void setMemoryPersistence(String memoryPersistence) throws KeywordValueException{ 175 this.memoryPersistence = memoryPersistence; 176 config.set("SessionManager.MemoryPersistence",memoryPersistence); 177 } 178 179 public String getSessionEncodeUrlState(){ 180 return sessionEncodeUrlState; 181 } 182 183 public void setSessionEncodeUrlState(String sessionEncodeUrlState) throws KeywordValueException{ 184 this.sessionEncodeUrlState = sessionEncodeUrlState; 185 config.set("SessionManager.SessionEncodeUrlState",sessionEncodeUrlState); 186 } 187 188 public String getSessionEncodeFirstUrl(){ 189 return sessionEncodeFirstUrl; 190 } 191 192 public void setSessionEncodeFirstUrl(String sessionEncodeFirstUrl) throws KeywordValueException{ 193 this.sessionEncodeFirstUrl = sessionEncodeFirstUrl; 194 config.set("SessionManager.SessionEncodeFirstUrl",sessionEncodeFirstUrl); 195 } 196 197 public String getMode() { 198 return mode; 199 } 200 201 public void setMode(String mode) throws KeywordValueException{ 202 this.mode = mode; 203 config.set("SessionManager.SessionHome.Mode",mode); 204 } 205 206 public String getMaxSessions() { 207 return maxSessions; 208 } 209 210 public void setMaxSessions(String maxSessions) throws KeywordValueException{ 211 this.maxSessions = maxSessions; 212 config.set("SessionManager.SessionHome.MaxSessions",maxSessions); 213 } 214 215 public String getPageThreshold() { 216 return pageThreshold; 217 } 218 219 public void setPageThreshold(String pageThreshold) throws KeywordValueException{ 220 this.pageThreshold = pageThreshold; 221 config.set("SessionManager.SessionHome.PageThreshold",pageThreshold); 222 } 223 224 public String getPageTimeThreshold() { 225 return pageTimeThreshold; 226 } 227 228 public void setPageTimeThreshold(String pageTimeThreshold) throws KeywordValueException{ 229 this.pageTimeThreshold = pageTimeThreshold; 230 config.set("SessionManager.SessionHome.PageTimeThreshold",pageTimeThreshold); 231 } 232 233 public String getPageWait() { 234 return pageWait; 235 } 236 237 public void setPageWait(String pageWait) throws KeywordValueException{ 238 this.pageWait = pageWait; 239 config.set("SessionManager.SessionHome.PageWait",pageWait); 240 } 241 242 public String getSaveOnRestart() { 243 return saveOnRestart; 244 } 245 246 public void setSaveOnRestart(String saveOnRestart) throws KeywordValueException{ 247 this.saveOnRestart = saveOnRestart; 248 config.set("SessionManager.SessionHome.SaveOnRestart",saveOnRestart); 249 } 250 251 public String getPageDir() { 252 return pageDir; 253 } 254 255 public void setPageDir(String pageDir) throws KeywordValueException{ 256 this.pageDir = pageDir; 257 config.set("SessionManager.SessionHome.PageDir",pageDir); 258 } 259 260 public String getDatabaseName() { 261 return databaseName; 262 } 263 264 public void setDatabaseName(String databaseName) throws KeywordValueException{ 265 this.databaseName = databaseName; 266 config.set("SessionManager.SessionHome.DatabaseName",databaseName); 267 } 268 269 public String getDBTableName() { 270 return dBTableName; 271 } 272 273 public void setDBTableName(String dBTableName) throws KeywordValueException{ 274 this.dBTableName = dBTableName; 275 config.set("SessionManager.SessionHome.DBTableName",dBTableName); 276 } 277 278 public String getSessionHomeClass() { 279 return sessionHomeClass; 280 } 281 282 public void setSessionHomeClass(String sessionHomeClass) throws KeywordValueException{ 283 this.sessionHomeClass = sessionHomeClass; 284 config.set("SessionManager.SessionHome.Class",sessionHomeClass); 285 } 286 287 public String getSessionUserTableClass() { 288 return sessionUserTableClass; 289 } 290 291 public void setSessionUserTableClass(String sessionUserTableClass) throws KeywordValueException{ 292 this.sessionUserTableClass = sessionUserTableClass; 293 config.set("SessionManager.SessionUserTable.Class",sessionUserTableClass); 294 } 295 296 300 301 public boolean saveState(){ 302 try{ 303 ConfigFileInterface confFile = config.getConfigFile(); 304 confFile.write(); 305 }catch(Exception e){ return false; 307 } 308 return true; 309 } 310 } 311 312 313 314 315 316 | Popular Tags |