1 22 23 package org.meshcms.core; 24 25 import java.io.*; 26 27 30 public class Configuration implements Serializable { 31 34 public static final long LENGTH_OF_HOUR = 60 * 60 * 1000; 35 36 39 public static final long LENGTH_OF_DAY = 24 * LENGTH_OF_HOUR; 40 41 44 public static final String [] DEFAULT_VISUAL_EXTENSIONS = {"html", "htm"}; 45 46 49 public static final int NO_CACHE = 0; 50 51 54 public static final int IN_MEMORY_CACHE = 1; 55 56 59 public static final int ON_DISK_CACHE = 2; 60 61 private boolean useAdminTheme; 62 private boolean preventHotlinking; 63 private boolean alwaysRedirectWelcomes; 64 private boolean alwaysDenyDirectoryListings; 65 private boolean hideExceptions; 66 private boolean editorModulesCollapsed; 67 private boolean highQualityThumbnails; 68 private boolean exportCheckDates; 69 private boolean searchMovedPages; 70 private int backupLife; 71 private int statsLength; 72 private int updateInterval; 73 private int cacheType; 74 private String mailServer; 75 private String smtpUsername; 76 private String smtpPassword; 77 private String siteName; 78 private String siteHost; 79 private String siteDescription; 80 private String siteKeywords; 81 private String siteAuthor; 82 private String siteAuthorURL; 83 private String exportBaseURL; 84 private String exportDir; 85 private String exportCommand; 86 private String [] visualExtensions; 87 88 private Configuration() { 89 setUseAdminTheme(true); 90 setPreventHotlinking(false); 91 setAlwaysRedirectWelcomes(true); 92 setAlwaysDenyDirectoryListings(true); 93 setHideExceptions(true); 94 setEditorModulesCollapsed(false); 95 setHighQualityThumbnails(false); 96 setExportCheckDates(true); 97 setSearchMovedPages(false); 98 99 setBackupLife(90); 100 setStatsLength(3); 101 setUpdateInterval(4); 102 setCacheType(ON_DISK_CACHE); 103 104 setMailServer("localhost"); 105 setSmtpUsername(""); 106 setSmtpPassword(""); 107 setSiteAuthor("Luciano Vernaschi"); 108 setSiteAuthorURL("http://www.cromoteca.com/"); 109 setSiteDescription("MeshCMS is a Content Management System designed to be" + 110 " easy to use. It doesn't require a database and offers easy" + 111 " deployment, management of multiple sites, wysiwyg editing, file" + 112 " manager, themes, modules and a custom tag library."); 113 setSiteHost("www.meshcms.org"); 114 setSiteKeywords("meshcms, cms, java, jsp, servlet, content management system"); 115 setSiteName("MeshCMS - Open Source Content Management System"); 116 setExportBaseURL(""); 117 setExportDir(""); 118 setExportCommand(""); 119 120 setVisualExtensions(DEFAULT_VISUAL_EXTENSIONS); 121 } 122 123 127 public boolean isUseAdminTheme() { 128 return useAdminTheme; 129 } 130 131 135 public void setUseAdminTheme(boolean useAdminTheme) { 136 this.useAdminTheme = useAdminTheme; 137 } 138 139 142 public boolean isPreventHotlinking() { 143 return preventHotlinking; 144 } 145 146 149 public void setPreventHotlinking(boolean preventHotlinking) { 150 this.preventHotlinking = preventHotlinking; 151 } 152 153 157 public int getBackupLife() { 158 return backupLife; 159 } 160 161 165 public void setBackupLife(int backupLife) { 166 this.backupLife = Math.max(backupLife, 0); 167 } 168 169 172 public int getStatsLength() { 173 return statsLength; 174 } 175 176 182 public void setStatsLength(int statsLength) { 183 this.statsLength = Math.max(statsLength, 1); 184 } 185 186 190 public int getUpdateInterval() { 191 return updateInterval; 192 } 193 194 198 public void setUpdateInterval(int updateInterval) { 199 this.updateInterval = Math.max(updateInterval, 1); 200 } 201 202 207 public int getCacheType() { 208 return cacheType; 209 } 210 211 215 public void setCacheType(int cacheType) { 216 this.cacheType = cacheType; 217 } 218 219 222 public String getMailServer() { 223 return mailServer; 224 } 225 226 229 public void setMailServer(String mailServer) { 230 this.mailServer = mailServer; 231 } 232 233 236 public String getSmtpUsername() { 237 return smtpUsername; 238 } 239 240 243 public void setSmtpUsername(String smtpUsername) { 244 this.smtpUsername = smtpUsername; 245 } 246 247 250 public String getSmtpPassword() { 251 return smtpPassword; 252 } 253 254 257 public void setSmtpPassword(String smtpPassword) { 258 this.smtpPassword = smtpPassword; 259 } 260 261 265 public static Configuration load(WebSite webSite) { 266 Configuration c = null; 267 268 try { 269 c = (Configuration) webSite.loadFromXML(webSite.getConfigFilePath()); 270 } catch (Exception ex) {} 271 272 if (c == null) { 273 c = new Configuration(); 274 } 275 276 return c; 277 } 278 279 282 public boolean store(WebSite webSite) { 283 return webSite.storeToXML(this, webSite.getConfigFilePath()); 284 } 285 286 290 public long getUpdateIntervalMillis() { 291 return getUpdateInterval() * LENGTH_OF_HOUR; 292 } 293 294 298 public long getBackupLifeMillis() { 299 return getBackupLife() * LENGTH_OF_DAY; 300 } 301 302 306 public String [] getVisualExtensions() { 307 return visualExtensions; 308 } 309 310 314 public void setVisualExtensions(String [] visualExtensions) { 315 this.visualExtensions = visualExtensions; 316 } 317 318 321 public boolean isAlwaysRedirectWelcomes() { 322 return alwaysRedirectWelcomes; 323 } 324 325 328 public void setAlwaysRedirectWelcomes(boolean alwaysRedirectWelcomes) { 329 this.alwaysRedirectWelcomes = alwaysRedirectWelcomes; 330 } 331 332 335 public boolean isAlwaysDenyDirectoryListings() { 336 return alwaysDenyDirectoryListings; 337 } 338 339 342 public void setAlwaysDenyDirectoryListings(boolean alwaysDenyDirectoryListings) { 343 this.alwaysDenyDirectoryListings = alwaysDenyDirectoryListings; 344 } 345 346 349 public String getSiteHost() { 350 return siteHost; 351 } 352 353 356 public void setSiteHost(String siteHost) { 357 this.siteHost = siteHost; 358 } 359 360 363 public String getSiteDescription() { 364 return siteDescription; 365 } 366 367 370 public void setSiteDescription(String siteDescription) { 371 this.siteDescription = siteDescription; 372 } 373 374 377 public String getSiteKeywords() { 378 return siteKeywords; 379 } 380 381 384 public void setSiteKeywords(String siteKeywords) { 385 this.siteKeywords = siteKeywords; 386 } 387 388 391 public String getSiteAuthor() { 392 return siteAuthor; 393 } 394 395 398 public void setSiteAuthor(String siteAuthor) { 399 this.siteAuthor = siteAuthor; 400 } 401 402 405 public String getSiteName() { 406 return siteName; 407 } 408 409 412 public void setSiteName(String siteName) { 413 this.siteName = siteName; 414 } 415 416 419 public String getSiteAuthorURL() { 420 return siteAuthorURL; 421 } 422 423 427 public void setSiteAuthorURL(String siteAuthorURL) { 428 this.siteAuthorURL = siteAuthorURL; 429 } 430 431 434 public boolean isHideExceptions() { 435 return hideExceptions; 436 } 437 438 442 public void setHideExceptions(boolean hideExceptions) { 443 this.hideExceptions = hideExceptions; 444 } 445 446 449 public boolean isEditorModulesCollapsed() { 450 return editorModulesCollapsed; 451 } 452 453 456 public void setEditorModulesCollapsed(boolean editorModulesCollapsed) { 457 this.editorModulesCollapsed = editorModulesCollapsed; 458 } 459 460 public boolean isHighQualityThumbnails() { 461 return highQualityThumbnails; 462 } 463 464 public void setHighQualityThumbnails(boolean highQualityThumbnails) { 465 this.highQualityThumbnails = highQualityThumbnails; 466 } 467 468 public boolean isExportCheckDates() { 469 return exportCheckDates; 470 } 471 472 public void setExportCheckDates(boolean exportCheckDates) { 473 this.exportCheckDates = exportCheckDates; 474 } 475 476 public String getExportBaseURL() { 477 return exportBaseURL; 478 } 479 480 public void setExportBaseURL(String exportBaseURL) { 481 this.exportBaseURL = exportBaseURL; 482 } 483 484 public String getExportDir() { 485 return exportDir; 486 } 487 488 public void setExportDir(String exportDir) { 489 this.exportDir = exportDir; 490 } 491 492 public String getExportCommand() { 493 return exportCommand; 494 } 495 496 public void setExportCommand(String exportCommand) { 497 this.exportCommand = exportCommand; 498 } 499 500 public boolean isSearchMovedPages() { 501 return searchMovedPages; 502 } 503 504 public void setSearchMovedPages(boolean searchMovedPages) { 505 this.searchMovedPages = searchMovedPages; 506 } 507 } 508 | Popular Tags |