1 package org.roller.pojos; 2 3 import java.io.File ; 4 import java.lang.reflect.AccessibleObject ; 5 import java.lang.reflect.Field ; 6 import java.math.BigDecimal ; 7 import java.util.Arrays ; 8 import java.util.List ; 9 10 import org.apache.commons.lang.StringUtils; 11 import org.roller.RollerException; 12 import org.roller.model.Roller; 13 import org.roller.model.RollerFactory; 14 import org.roller.util.PojoUtil; 15 16 28 public class RollerConfigData 29 extends org.roller.pojos.PersistentObject 30 implements java.io.Serializable 31 { 32 static final long serialVersionUID = -6354583200913127875L; 33 34 protected java.lang.String id = null; 35 36 39 protected String mDatabaseVersion = "995"; 41 44 protected String mAbsoluteURL = null; 45 46 49 protected Boolean mRssUseCache = Boolean.FALSE; 50 51 54 protected Integer mRssCacheTime = new Integer (3000); 55 56 59 protected Boolean mNewUserAllowed = Boolean.TRUE; 60 61 64 protected String mAdminUsers = "admin"; 65 66 69 protected String mUserThemes = "/themes"; 70 71 75 protected String mEditorPages = 76 "editor-text.jsp,editor-text-js.jsp,editor-rte.jsp,editor-dhtml.jsp,editor-ekit.jsp,editor-wiki-js.jsp"; 77 78 81 protected Boolean mEnableAggregator = Boolean.FALSE; 82 83 86 protected Boolean mUploadEnabled = Boolean.TRUE; 87 88 91 protected BigDecimal mUploadMaxDirMB = new BigDecimal ("2"); 92 93 96 protected BigDecimal mUploadMaxFileMB = new BigDecimal (".5"); 97 98 103 protected String mUploadAllow = ""; 104 105 110 protected String mUploadForbid = ""; 111 112 119 protected String mUploadDir = ""; 120 121 125 protected String uploadPath = "/resources"; 126 127 protected Boolean mMemDebug = Boolean.FALSE; 128 129 133 protected Boolean mAutoformatComments = Boolean.FALSE; 134 135 138 protected Boolean mEscapeCommentHtml = Boolean.FALSE; 139 140 143 protected Boolean mEmailComments = Boolean.FALSE; 144 145 148 protected Boolean mEnableLinkback = Boolean.FALSE; 149 150 153 protected String mSiteName = "Roller-based Site"; 154 155 158 protected String mSiteDescription = "Roller-based Site"; 159 160 163 protected String mEmailAddress = ""; 164 165 168 protected String mIndexDir = "${user.home}" + File.separator 169 + "roller-index"; 170 171 174 protected Boolean mEncryptPasswords = Boolean.FALSE; 175 176 protected String mAlgorithm = "SHA"; 177 178 181 protected String mRefererSpamWords = ""; 182 183 185 193 public String getId() { 194 return this.id; 195 } 196 197 198 public void setId(String id) { 199 this.id = id; 200 } 201 202 206 public String getAbsoluteURL() 207 { 208 return mAbsoluteURL; 209 } 210 211 public void setAbsoluteURL(String string) 212 { 213 mAbsoluteURL = string; 214 } 215 216 220 public Boolean getRssUseCache() 221 { 222 return mRssUseCache; 223 } 224 225 public void setRssUseCache(Boolean use) 226 { 227 mRssUseCache = use; 228 } 229 230 234 public Integer getRssCacheTime() 235 { 236 return mRssCacheTime; 237 } 238 239 public void setRssCacheTime(Integer cacheTime) 240 { 241 mRssCacheTime = cacheTime; 242 } 243 244 248 public Boolean getNewUserAllowed() 249 { 250 return mNewUserAllowed; 251 } 252 253 public void setNewUserAllowed(Boolean use) 254 { 255 mNewUserAllowed = use; 256 } 257 258 261 public String getAdminUsers() 262 { 263 return mAdminUsers; 264 } 265 268 public void setAdminUsers(String _adminUsers) 269 { 270 mAdminUsers = _adminUsers; 271 } 272 273 277 public String getUserThemes() 278 { 279 return mUserThemes; 280 } 281 282 public void setUserThemes(String str) 283 { 284 mUserThemes = str; 285 } 286 287 291 public String getEditorPages() 292 { 293 return mEditorPages; 294 } 295 296 public void setEditorPages(String _editorPages) 297 { 298 mEditorPages = _editorPages; 299 } 300 301 305 public Boolean getEnableAggregator() 306 { 307 return mEnableAggregator; 308 } 309 310 public void setEnableAggregator(Boolean use) 311 { 312 mEnableAggregator = use; 313 } 314 315 319 public Boolean getUploadEnabled() 320 { 321 return mUploadEnabled; 322 } 323 324 public void setUploadEnabled(Boolean use) 325 { 326 mUploadEnabled = use; 327 } 328 329 334 public BigDecimal getUploadMaxDirMB() 335 { 336 return mUploadMaxDirMB; 337 } 338 339 public void setUploadMaxDirMB(BigDecimal use) 340 { 341 mUploadMaxDirMB = use; 342 } 343 344 349 public BigDecimal getUploadMaxFileMB() 350 { 351 return mUploadMaxFileMB; 352 } 353 354 public void setUploadMaxFileMB(BigDecimal use) 355 { 356 mUploadMaxFileMB = use; 357 } 358 359 363 public String getUploadAllow() 364 { 365 return mUploadAllow; 366 } 367 368 public void setUploadAllow(String _uploadAllow) 369 { 370 mUploadAllow = _uploadAllow; 371 } 372 373 377 public String getUploadForbid() 378 { 379 return mUploadForbid; 380 } 381 382 public void setUploadForbid(String _uploadForbid) 383 { 384 mUploadForbid = _uploadForbid; 385 } 386 387 391 public String getUploadDir() 392 { 393 return mUploadDir; 394 } 395 396 public void setUploadDir(String str) 397 { 398 mUploadDir = str; 399 } 400 401 405 public String getUploadPath() 406 { 407 return uploadPath; 408 } 409 410 public void setUploadPath(String str) 411 { 412 uploadPath = str; 413 } 414 415 419 public Boolean getMemDebug() { return mMemDebug; } 420 421 426 public void setMemDebug(Boolean memDebug) 427 { 428 mMemDebug = memDebug; 429 } 430 431 435 public Boolean getAutoformatComments() 436 { 437 return mAutoformatComments; 438 } 439 440 public void setAutoformatComments(Boolean value) 441 { 442 mAutoformatComments = value; 443 } 444 445 449 public Boolean getEscapeCommentHtml() 450 { 451 return mEscapeCommentHtml; 452 } 453 454 public void setEscapeCommentHtml(Boolean value) 455 { 456 mEscapeCommentHtml = value; 457 } 458 459 465 public Boolean getEmailComments() 466 { 467 return mEmailComments; 468 } 469 470 473 public void setEmailComments(Boolean emailComments) 474 { 475 this.mEmailComments = emailComments; 476 } 477 478 483 public Boolean getEnableLinkback() 484 { 485 return mEnableLinkback; 486 } 487 488 492 public void setEnableLinkback(Boolean b) 493 { 494 mEnableLinkback = b; 495 } 496 497 498 502 public String getSiteDescription() 503 { 504 return mSiteDescription; 505 } 506 507 511 public void setSiteDescription(String string) 512 { 513 mSiteDescription = string; 514 } 515 516 520 public String getSiteName() 521 { 522 return mSiteName; 523 } 524 525 529 public void setSiteName(String string) 530 { 531 mSiteName = string; 532 } 533 534 538 public String getEmailAddress() 539 { 540 return mEmailAddress; 541 } 542 543 547 public void setEmailAddress(String emailAddress) 548 { 549 mEmailAddress = emailAddress; 550 } 551 552 556 public String getIndexDir() { 557 558 return mIndexDir; 559 } 560 561 565 public void setIndexDir(String indexDir) 566 { 567 mIndexDir = indexDir; 568 } 569 570 574 public Boolean getEncryptPasswords() 575 { 576 return mEncryptPasswords; 577 } 578 579 public void setEncryptPasswords(Boolean value) 580 { 581 mEncryptPasswords = value; 582 } 583 584 588 public String getAlgorithm() { 589 590 return mAlgorithm; 591 } 592 593 597 public void setAlgorithm(String algorithm) 598 { 599 mAlgorithm = algorithm; 600 } 601 602 606 public String getDatabaseVersion() { 607 return mDatabaseVersion; 608 } 609 613 public void setDatabaseVersion(String databaseVersion) { 614 mDatabaseVersion = databaseVersion; 615 } 616 617 621 public String getRefererSpamWords() 622 { 623 return this.mRefererSpamWords; 624 } 625 629 public void setRefererSpamWords(String refererSpamWords) 630 { 631 this.mRefererSpamWords = refererSpamWords; 632 } 633 634 636 639 public String [] adminUsersArray() 640 { 641 return StringUtils.split(StringUtils.deleteWhitespace(mAdminUsers), ","); 642 } 643 644 647 public List getEditorPagesList() 648 { 649 return Arrays.asList( 650 StringUtils.split(StringUtils.deleteWhitespace(mEditorPages), ",")); 651 } 652 653 656 public String [] uploadAllowArray() 657 { 658 return StringUtils.split(StringUtils.deleteWhitespace(mUploadAllow), ","); 659 } 660 661 664 public String [] uploadForbidArray() 665 { 666 return StringUtils.split(StringUtils.deleteWhitespace(mUploadForbid), ","); 667 } 668 669 672 public String [] refererSpamWordsArray() 673 { 674 return StringUtils.split(StringUtils.deleteWhitespace(mRefererSpamWords), ","); 675 } 676 677 public void updateValues( RollerConfigData child ) 678 { 679 this.mAbsoluteURL = child.getAbsoluteURL(); 680 this.mRssUseCache = child.getRssUseCache(); 681 this.mRssCacheTime = child.getRssCacheTime(); 682 this.mNewUserAllowed = child.getNewUserAllowed(); 683 this.mAdminUsers = child.getAdminUsers(); 684 this.mDatabaseVersion = child.getDatabaseVersion(); 685 this.mUserThemes = child.getUserThemes(); 686 this.mEditorPages = child.getEditorPages(); 687 this.mEnableAggregator = child.getEnableAggregator(); 688 this.mUploadEnabled = child.getUploadEnabled(); 689 this.mUploadMaxDirMB = child.getUploadMaxDirMB(); 690 this.mUploadMaxFileMB = child.getUploadMaxFileMB(); 691 this.mUploadAllow = child.getUploadAllow(); 692 this.mUploadForbid = child.getUploadForbid(); 693 this.mUploadDir = child.getUploadDir(); 694 this.uploadPath = child.getUploadPath(); 695 this.mMemDebug = child.getMemDebug(); 696 this.mAutoformatComments = child.getAutoformatComments(); 697 this.mEscapeCommentHtml = child.getEscapeCommentHtml(); 698 this.mEmailComments = child.getEmailComments(); 699 this.mEnableLinkback = child.getEnableLinkback(); 700 this.mSiteName = child.getSiteName(); 701 this.mSiteDescription = child.getSiteDescription(); 702 this.mEmailAddress = child.getEmailAddress(); 703 this.mIndexDir = child.getIndexDir(); 704 this.mEncryptPasswords = child.getEncryptPasswords(); 705 this.mAlgorithm = child.getAlgorithm(); 706 this.mRefererSpamWords = child.getRefererSpamWords(); 707 } 708 709 710 public String toString() 711 { 712 StringBuffer buf = new StringBuffer (); 713 buf.append("RollerConfig \n"); 714 Class clazz = getClass(); 715 Field [] fields = clazz.getDeclaredFields(); 716 717 try { 718 AccessibleObject.setAccessible(fields, true); 719 for (int i = 0; i < fields.length; i++) { 720 buf.append( 721 "\t[" 722 + fields[i].getName() 723 + "=" 724 + fields[i].get(this) 725 + "], \n"); 726 } 727 } catch (Exception e) { 728 } 730 731 return buf.toString(); 732 } 733 734 735 public void setData(PersistentObject vo) { 736 if (vo instanceof RollerConfigData) { 737 this.id = ((RollerConfigData)vo).id; 738 updateValues((RollerConfigData)vo); 739 } 740 } 741 742 public boolean equals(Object pOther) 743 { 744 if (pOther instanceof WebsiteData) 745 { 746 RollerConfigData lTest = (RollerConfigData) pOther; 747 boolean lEquals = true; 748 749 lEquals = PojoUtil.equals(lEquals, this.id, lTest.id); 750 lEquals = PojoUtil.equals(lEquals, this.mAbsoluteURL, lTest.getAbsoluteURL()); 751 lEquals = PojoUtil.equals(lEquals, this.mRssUseCache, lTest.getRssUseCache()); 752 lEquals = PojoUtil.equals(lEquals, this.mRssCacheTime, lTest.getRssCacheTime()); 753 lEquals = PojoUtil.equals(lEquals, this.mNewUserAllowed, lTest.getNewUserAllowed()); 754 lEquals = PojoUtil.equals(lEquals, this.mAdminUsers, lTest.getAdminUsers()); 755 lEquals = PojoUtil.equals(lEquals, this.mUserThemes, lTest.getUserThemes()); 756 lEquals = PojoUtil.equals(lEquals, this.mEditorPages, lTest.getEditorPages()); 757 lEquals = PojoUtil.equals(lEquals, this.mEnableAggregator, lTest.getEnableAggregator()); 758 lEquals = PojoUtil.equals(lEquals, this.mUploadEnabled, lTest.getUploadEnabled()); 759 lEquals = PojoUtil.equals(lEquals, this.mUploadMaxDirMB, lTest.getUploadMaxDirMB()); 760 lEquals = PojoUtil.equals(lEquals, this.mUploadMaxFileMB, lTest.getUploadMaxFileMB()); 761 lEquals = PojoUtil.equals(lEquals, this.mUploadAllow, lTest.getUploadAllow()); 762 lEquals = PojoUtil.equals(lEquals, this.mUploadForbid, lTest.getUploadForbid()); 763 lEquals = PojoUtil.equals(lEquals, this.mUploadDir, lTest.getUploadDir()); 764 lEquals = PojoUtil.equals(lEquals, this.uploadPath, lTest.getUploadPath()); 765 lEquals = PojoUtil.equals(lEquals, this.mMemDebug, lTest.getMemDebug()); 766 lEquals = PojoUtil.equals(lEquals, this.mAutoformatComments, lTest.getAutoformatComments()); 767 lEquals = PojoUtil.equals(lEquals, this.mEscapeCommentHtml, lTest.getEscapeCommentHtml()); 768 lEquals = PojoUtil.equals(lEquals, this.mEmailComments, lTest.getEmailComments()); 769 lEquals = PojoUtil.equals(lEquals, this.mEnableLinkback, lTest.getEnableLinkback()); 770 lEquals = PojoUtil.equals(lEquals, this.mSiteName, lTest.getSiteName()); 771 lEquals = PojoUtil.equals(lEquals, this.mSiteDescription, lTest.getSiteDescription()); 772 lEquals = PojoUtil.equals(lEquals, this.mEmailAddress, lTest.getEmailAddress()); 773 lEquals = PojoUtil.equals(lEquals, this.mIndexDir, lTest.getIndexDir()); 774 lEquals = PojoUtil.equals(lEquals, this.mEncryptPasswords, lTest.getEncryptPasswords()); 775 lEquals = PojoUtil.equals(lEquals, this.mAlgorithm, lTest.getAlgorithm()); 776 lEquals = PojoUtil.equals(lEquals, this.mRefererSpamWords, lTest.getRefererSpamWords()); 777 778 return lEquals; 779 } 780 else 781 { 782 return false; 783 } 784 } 785 786 public int hashCode() 787 { 788 return super.hashCode(); 789 } 790 791 public boolean canSave() throws RollerException 792 { 793 Roller roller = RollerFactory.getRoller(); 794 if (roller.getUser().equals(UserData.SYSTEM_USER)) 795 { 796 return true; 797 } 798 if (roller.getUser().hasRole("admin")) 799 { 800 return true; 801 } 802 return false; 803 } 804 } 805 | Popular Tags |