1 22 package org.jahia.services.sites; 23 24 import org.jahia.exceptions.JahiaException; 25 import org.jahia.params.ParamBean; 26 import org.jahia.registries.ServicesRegistry; 27 import org.jahia.services.acl.ACLResourceInterface; 28 import org.jahia.services.acl.JahiaACLException; 29 import org.jahia.services.acl.JahiaBaseACL; 30 import org.jahia.services.pages.ContentPage; 31 import org.jahia.services.pages.JahiaPage; 32 import org.jahia.services.pages.JahiaPageService; 33 import org.jahia.services.usermanager.JahiaUser; 34 import org.jahia.services.version.EntryLoadRequest; 35 import org.jahia.utils.LanguageCodeConverters; 36 import org.jahia.utils.xml.XMLSerializationOptions; 37 import org.jahia.utils.xml.XmlWriter; 38 import org.jahia.bin.Jahia; 39 40 import java.io.IOException ; 41 import java.io.Serializable ; 42 import java.text.Collator ; 43 import java.util.*; 44 45 46 53 public class JahiaSite implements ACLResourceInterface, Serializable { 54 55 private static org.apache.log4j.Logger logger = 56 org.apache.log4j.Logger.getLogger (JahiaSite.class); 57 58 59 60 private int mSiteID = -1; 61 62 63 private String mTitle = ""; 64 65 66 private String mSiteKey = ""; 67 68 69 private String mServerName = ""; 70 71 72 private boolean mIsActive = false; 73 74 75 private int mHomePageID = -1; 76 77 78 private String mDescr; 79 80 private JahiaBaseACL mACL; 81 82 private Properties mSettings = new Properties (); 83 84 public static final String LANGUAGES_PROP_SEPARATOR = ","; 85 86 private Boolean mixLanguagesActive; 87 88 92 public JahiaSite () { 93 } 94 95 98 public JahiaSite (int id, String title, String serverName, String siteKey, 99 boolean isActive, int homePageID, String descr, 100 JahiaBaseACL acl, Properties settings) { 101 mSiteID = id; 102 mTitle = title; 103 mServerName = serverName; 104 mSiteKey = siteKey; 105 mIsActive = isActive; 106 mHomePageID = homePageID; 107 108 if (descr == null) { 109 descr = "no desc"; 110 } 111 mDescr = descr; 112 113 mACL = acl; 114 115 if (settings != null) { 116 mSettings = settings; 117 } 118 119 } 120 121 122 public int getID () { 123 return mSiteID; 124 } 125 126 public void setID (int id) { 127 mSiteID = id; 128 } 129 130 public String getTitle () { 131 return mTitle; 132 } 133 134 public void setTitle (String value) { 135 mTitle = value; 136 } 137 138 141 public String getServerName () { 142 return mServerName; 143 } 144 145 146 149 public void setServerName (String name) { 150 mServerName = name; 151 } 152 153 156 public String getSiteKey () { 157 return mSiteKey; 158 } 159 160 161 164 private void setSiteKey (String siteKey) { 165 mSiteKey = siteKey; 166 } 167 168 169 public boolean isActive () { 170 return mIsActive; 171 } 172 173 public void setActive (boolean value) { 174 mIsActive = value; 175 } 176 177 public int getHomePageID () { 178 return mHomePageID; 179 } 180 181 184 public JahiaPage getHomePage () { 185 JahiaPage page = null; 186 JahiaPageService ps = ServicesRegistry.getInstance ().getJahiaPageService (); 187 if (ps == null) { 188 logger.error("Cannot find home page, null pageService"); 189 return null; 190 } 191 try { 192 page = ps.lookupPage (getHomePageID (), Jahia.getThreadParamBean().getEntryLoadRequest(), Jahia.getThreadParamBean().getUser(), true); 193 } catch (JahiaException je) { 194 logger.error("Cannot find home page, "+mHomePageID, je); 195 return null; 196 } 197 return page; 198 } 199 200 203 public JahiaPage getHomePage (EntryLoadRequest entryLoadRequest) { 204 JahiaPage page = null; 205 JahiaPageService ps = ServicesRegistry.getInstance ().getJahiaPageService (); 206 if (ps == null) { 207 return null; 208 } 209 try { 210 page = ps.lookupPage (getHomePageID (), entryLoadRequest); 211 } catch (JahiaException je) { 212 return null; 213 } 214 return page; 215 } 216 217 public ContentPage getHomeContentPage () { 218 ContentPage contentPage = null; 219 JahiaPageService ps = ServicesRegistry.getInstance ().getJahiaPageService (); 220 if (ps == null) { 221 return null; 222 } 223 try { 224 contentPage = ps.lookupContentPage (getHomePageID (), true); 225 } catch (JahiaException je) { 226 return null; 227 } 228 return contentPage; 229 } 230 231 232 public void setHomePageID (int id) { 233 mHomePageID = id; 234 } 235 236 public int getDefaultTemplateID () { 237 238 if (mSettings == null) { 239 return -1; 240 } 241 String id = mSettings.getProperty ("defaultTemplateID"); 242 if (id == null) { 243 return -1; 244 } 245 return Integer.parseInt (id); 246 } 247 248 public int getHtmlCleanup () { 249 250 252 if (mSettings == null) { 253 return 1; 254 } 255 String val = mSettings.getProperty (SitesSettings.HTML_CLEANUP_ENABLED); 256 if (val == null) { 257 return 1; 258 } 259 return Integer.parseInt (val); 260 } 261 262 public void setHtmlCleanup (int val) { 263 264 if (mSettings == null) { 265 mSettings = new Properties (); 266 } 267 268 mSettings.setProperty (SitesSettings.HTML_CLEANUP_ENABLED, String.valueOf (val)); 269 } 270 271 public int getHtmlMarkupFiltering () { 272 273 275 if (mSettings == null) { 276 return 1; 277 } 278 String val = mSettings.getProperty (SitesSettings.HTML_MARKUP_FILTERING_ENABLED); 279 if (val == null) { 280 return 1; 281 } 282 return Integer.parseInt (val); 283 } 284 285 public void setHtmlMarkupFiltering (int val) { 286 287 if (mSettings == null) { 288 mSettings = new Properties (); 289 } 290 291 mSettings.setProperty (SitesSettings.HTML_MARKUP_FILTERING_ENABLED, 292 String.valueOf (val)); 293 } 294 295 public void setDefaultTemplateID (int id) { 296 297 if (mSettings == null) { 298 mSettings = new Properties (); 299 } 300 301 mSettings.setProperty ("defaultTemplateID", Integer.toString (id)); 302 } 303 304 public boolean getTemplatesAutoDeployMode () { 305 306 if (mSettings == null) { 307 return false; 308 } 309 String val = mSettings.getProperty ("templatesAutoDeployMode"); 310 if (val == null) { 311 return false; 312 } 313 return (val.equals ("true")); 314 } 315 316 public void setTemplatesAutoDeployMode (boolean mode) { 317 318 if (mSettings == null) { 319 mSettings = new Properties (); 320 } 321 322 if (mode) { 323 mSettings.setProperty ("templatesAutoDeployMode", "true"); 324 } else { 325 mSettings.setProperty ("templatesAutoDeployMode", "false"); 326 } 327 } 328 329 public boolean getWebAppsAutoDeployMode () { 330 331 if (mSettings == null) { 332 return false; 333 } 334 String val = mSettings.getProperty ("webAppsAutoDeployMode"); 335 if (val == null) { 336 return false; 337 } 338 return (val.equals ("true")); 339 } 340 341 public void setWebAppsAutoDeployMode (boolean mode) { 342 343 if (mSettings == null) { 344 mSettings = new Properties (); 345 } 346 347 if (mode) { 348 mSettings.setProperty ("webAppsAutoDeployMode", "true"); 349 } else { 350 mSettings.setProperty ("webAppsAutoDeployMode", "false"); 351 } 352 } 353 354 355 public String getTemplateFolder () { 356 return mSiteKey; 357 } 358 359 360 public String getDescr () { 361 return mDescr; 362 } 363 364 public void setDescr (String descr) { 365 mDescr = descr; 366 } 367 368 369 381 382 383 384 387 388 private boolean checkAccess (JahiaUser user, int permission) { 389 if (user == null) { 390 return false; 391 } 392 393 boolean result = false; 395 try { 396 result = mACL.getPermission (user, permission); 397 } catch (JahiaACLException ex) { 398 } 400 401 if (!result) { 402 logger.debug ("Permission denied for user [" + 403 user.getName () + "] to page [" + getID () + 404 "] for access permission [" + permission + "]"); 405 } else { 406 logger.debug ("Permission granted for user [" + 407 user.getName () + "] to page [" + getID () + 408 "] for access permission [" + permission + "]"); 409 } 410 411 return result; 412 } 413 414 415 423 public final boolean checkAdminAccess (JahiaUser user) { 424 return checkAccess (user, JahiaBaseACL.ADMIN_RIGHTS); 425 } 426 427 435 public final boolean checkReadAccess (JahiaUser user) { 436 return checkAccess (user, JahiaBaseACL.READ_RIGHTS); 437 } 438 439 447 public final boolean checkWriteAccess (JahiaUser user) { 448 return checkAccess (user, JahiaBaseACL.WRITE_RIGHTS); 449 } 450 451 452 457 public final JahiaBaseACL getACL () { 458 return mACL; 459 } 460 461 466 public final int getAclID () { 467 int id = 0; 468 try { 469 id = mACL.getID (); 470 } catch (JahiaACLException ex) { 471 } 473 return id; 474 } 475 476 477 478 479 480 486 487 490 public boolean setUserDefaultHomepageDef (int id) { 491 492 try { 493 JahiaSitesPersistance.getInstance ().deleteProperty (getID (), 495 SitesSettings.USER_DEFAULT_HOMEPAGE_DEF); 496 497 JahiaSitesPersistance.getInstance ().addProperty (getID (), 498 SitesSettings.USER_DEFAULT_HOMEPAGE_DEF, 499 Integer.toString (id)); 500 } catch (Throwable t) { 501 t.printStackTrace (); 502 return false; 503 } 504 return true; 505 } 506 507 511 public int getUserDefaultHomepageDef () { 512 513 try { 514 String value = JahiaSitesPersistance 515 .getInstance ().getProperty (getID (), 516 SitesSettings.USER_DEFAULT_HOMEPAGE_DEF); 517 if (value == null || value.trim ().equals ("")) { 518 return -1; 519 } 520 return Integer.parseInt (value); 521 522 } catch (Throwable t) { 523 t.printStackTrace (); 524 } 525 return -1; 526 527 } 528 529 532 public boolean setGroupDefaultHomepageDef (int id) { 533 534 try { 535 JahiaSitesPersistance.getInstance ().deleteProperty (getID (), 537 SitesSettings.GROUP_DEFAULT_HOMEPAGE_DEF); 538 539 JahiaSitesPersistance.getInstance ().addProperty (getID (), 540 SitesSettings.GROUP_DEFAULT_HOMEPAGE_DEF, 541 Integer.toString (id)); 542 543 } catch (Throwable t) { 544 t.printStackTrace (); 545 return false; 546 } 547 return true; 548 549 } 550 551 554 public int getGroupDefaultHomepageDef () { 555 556 try { 557 String value = JahiaSitesPersistance 558 .getInstance ().getProperty (getID (), 559 SitesSettings.GROUP_DEFAULT_HOMEPAGE_DEF); 560 if (value == null || value.trim ().equals ("")) { 561 return -1; 562 } 563 return Integer.parseInt (value); 564 } catch (Throwable t) { 565 t.printStackTrace (); 566 } 567 return -1; 568 569 } 570 571 572 575 public boolean setUserDefaultHomepageDefActiveState (boolean active) { 576 577 try { 578 JahiaSitesPersistance.getInstance ().deleteProperty (getID (), 580 SitesSettings.USER_DEFAULT_HOMEPAGE_DEF_ACTIVE); 581 582 int value = 0; if (active) 584 value = 1; 585 586 JahiaSitesPersistance.getInstance ().addProperty (getID (), 587 SitesSettings.USER_DEFAULT_HOMEPAGE_DEF, 588 Integer.toString (value)); 589 } catch (Throwable t) { 590 t.printStackTrace (); 591 } 592 return true; 593 594 } 595 596 602 public int getUserDefaultHomepageDefActiveState () { 603 604 try { 605 String value = JahiaSitesPersistance 606 .getInstance ().getProperty (getID (), 607 SitesSettings.USER_DEFAULT_HOMEPAGE_DEF_ACTIVE); 608 if (value == null || value.trim ().equals ("")) { 609 return -1; 610 } 611 612 return Integer.parseInt (value); 613 614 } catch (Throwable t) { 615 t.printStackTrace (); 616 } 617 return -1; 618 619 } 620 621 622 625 public boolean setGroupDefaultHomepageDefActiveState (boolean active) { 626 627 try { 628 JahiaSitesPersistance.getInstance ().deleteProperty (getID (), 630 SitesSettings.GROUP_DEFAULT_HOMEPAGE_DEF_ACTIVE); 631 632 int value = 0; if (active) 634 value = 1; 635 636 JahiaSitesPersistance.getInstance ().addProperty (getID (), 637 SitesSettings.GROUP_DEFAULT_HOMEPAGE_DEF, 638 Integer.toString (value)); 639 640 } catch (Throwable t) { 641 t.printStackTrace (); 642 return false; 643 } 644 return true; 645 646 } 647 648 654 public int getGroupDefaultHomepageDefActiveState () { 655 656 try { 657 String value = JahiaSitesPersistance 658 .getInstance ().getProperty (getID (), 659 SitesSettings.GROUP_DEFAULT_HOMEPAGE_DEF_ACTIVE); 660 if (value == null || value.trim ().equals ("")) { 661 return -1; 662 } 663 664 return Integer.parseInt (value); 665 666 } catch (Throwable t) { 667 t.printStackTrace (); 668 } 669 return -1; 670 671 } 672 673 676 public boolean setUserDefaultHomepageDefAtCreationOnly (boolean active) { 677 678 try { 679 JahiaSitesPersistance.getInstance ().deleteProperty (getID (), 681 SitesSettings.USER_DEFAULT_HOMEPAGE_DEF_ATCREATION); 682 683 int value = 0; if (active) 685 value = 1; 686 687 JahiaSitesPersistance.getInstance ().addProperty (getID (), 688 SitesSettings.USER_DEFAULT_HOMEPAGE_DEF_ATCREATION, 689 Integer.toString (value)); 690 691 } catch (Throwable t) { 692 t.printStackTrace (); 693 return false; 694 } 695 return true; 696 697 } 698 699 705 public int getUserDefaultHomepageDefAtCreationOnly () { 706 707 try { 708 String value = JahiaSitesPersistance 709 .getInstance ().getProperty (getID (), 710 SitesSettings.USER_DEFAULT_HOMEPAGE_DEF_ATCREATION); 711 if (value == null || value.trim ().equals ("")) { 712 return -1; 713 } 714 715 return Integer.parseInt (value); 716 717 } catch (Throwable t) { 718 t.printStackTrace (); 719 } 720 return -1; 721 722 } 723 724 727 public boolean setGroupDefaultHomepageDefAtCreationOnly (boolean active) { 728 729 try { 730 JahiaSitesPersistance.getInstance ().deleteProperty (getID (), 732 SitesSettings.GROUP_DEFAULT_HOMEPAGE_DEF_ATCREATION); 733 734 int value = 0; if (active) 736 value = 1; 737 738 JahiaSitesPersistance.getInstance ().addProperty (getID (), 739 SitesSettings.GROUP_DEFAULT_HOMEPAGE_DEF_ATCREATION, 740 Integer.toString (value)); 741 742 } catch (Throwable t) { 743 t.printStackTrace (); 744 return false; 745 } 746 return true; 747 748 } 749 750 756 public int getGroupDefaultHomepageDefAtCreationOnly () { 757 758 try { 759 String value = JahiaSitesPersistance 760 .getInstance ().getProperty (getID (), 761 SitesSettings.GROUP_DEFAULT_HOMEPAGE_DEF_ATCREATION); 762 if (value == null || value.trim ().equals ("")) { 763 return -1; 764 } 765 766 return Integer.parseInt (value); 767 768 } catch (Throwable t) { 769 t.printStackTrace (); 770 } 771 return -1; 772 773 } 774 775 780 public boolean setVersioning (boolean status) { 781 synchronized (mSettings) { 782 try { 783 JahiaSitesPersistance.getInstance ().deleteProperty (getID (), 785 SitesSettings.VERSIONING_ENABLED); 786 int value = 0; if (status) 788 value = 1; 789 JahiaSitesPersistance.getInstance ().addProperty (getID (), 790 SitesSettings.VERSIONING_ENABLED, Integer.toString (value)); 791 792 mSettings.setProperty (SitesSettings.VERSIONING_ENABLED, 793 Integer.toString (value)); 794 } catch (Throwable t) { 795 t.printStackTrace (); 796 return false; 797 } 798 } 799 return true; 800 } 801 802 805 public boolean isVersioningEnabled () { 806 807 synchronized (mSettings) { 808 String prop = mSettings.getProperty (SitesSettings.VERSIONING_ENABLED); 809 try { 810 if (prop != null) { 811 return (Integer.parseInt (prop) == 1); 812 } else { 813 prop = 814 JahiaSitesPersistance 815 .getInstance ().getProperty (getID (), 816 SitesSettings.VERSIONING_ENABLED); 817 if (prop == null || prop.trim ().equals ("")) { 818 return false; 819 } else { 820 mSettings.setProperty (SitesSettings.VERSIONING_ENABLED, prop.trim ()); 821 } 822 return (Integer.parseInt (prop) == 1); 823 } 824 } catch (Throwable t) { 825 t.printStackTrace (); 826 } 827 } 828 return false; 829 } 830 831 836 public boolean setStaging (boolean status) { 837 synchronized (mSettings) { 838 try { 839 JahiaSitesPersistance.getInstance ().deleteProperty (getID (), 841 SitesSettings.STAGING_ENABLED); 842 int value = 0; if (status) 844 value = 1; 845 JahiaSitesPersistance.getInstance ().addProperty (getID (), 846 SitesSettings.STAGING_ENABLED, Integer.toString (value)); 847 848 mSettings.setProperty (SitesSettings.STAGING_ENABLED, Integer.toString (value)); 849 } catch (Throwable t) { 850 t.printStackTrace (); 851 return false; 852 } 853 } 854 return true; 855 } 856 857 860 public boolean isStagingEnabled () { 861 862 synchronized (mSettings) { 863 String prop = mSettings.getProperty (SitesSettings.STAGING_ENABLED); 864 try { 865 if (prop != null) { 866 return (Integer.parseInt (prop) == 1); 867 } else { 868 prop = 869 JahiaSitesPersistance 870 .getInstance ().getProperty (getID (), 871 SitesSettings.STAGING_ENABLED); 872 if (prop == null || prop.trim ().equals ("")) { 873 return false; 874 } else { 875 mSettings.setProperty (SitesSettings.STAGING_ENABLED, prop.trim ()); 876 } 877 return (Integer.parseInt (prop) == 1); 878 } 879 } catch (Throwable t) { 880 t.printStackTrace (); 881 } 882 } 883 return false; 884 } 885 886 887 896 public Vector getLanguageSettings () 897 throws JahiaException { 898 return getLanguageSettings (false); 899 } 900 901 911 public Vector getLanguageSettings (boolean activeOnly) 912 throws JahiaException { 913 Vector siteLanguageSettings = new Vector(); 914 Vector v = SiteLanguagesPersistance.getInstance ().getSiteLanguages ( 915 getID ()); 916 if ( !activeOnly ){ 917 if ( v != null ){ 918 return (Vector) v.clone(); 919 } 920 } else { 921 if (v != null) { 922 for (int i = 0; i < v.size (); i++) { 923 SiteLanguageSettings curSetting = (SiteLanguageSettings) 924 v.get (i); 925 if (curSetting.isActivated ()) { 926 siteLanguageSettings.add(curSetting); 927 } 928 } 929 } 930 } 931 return siteLanguageSettings; 932 } 933 934 945 public ArrayList getLanguageSettingsAsLocales (boolean activeOnly) 946 throws JahiaException { 947 Vector siteLanguageSettings = this.getLanguageSettings (); 948 ArrayList localeList = new ArrayList (); 949 if (siteLanguageSettings != null) { 950 for (int i = 0; i < siteLanguageSettings.size (); i++) { 951 SiteLanguageSettings curSetting = (SiteLanguageSettings) 952 siteLanguageSettings.get (i); 953 if (!activeOnly || curSetting.isActivated ()) { 954 Locale tempLocale = 955 LanguageCodeConverters.languageCodeToLocale (curSetting.getCode ()); 956 localeList.add (tempLocale); 957 } 958 } 959 } 960 return localeList; 961 } 962 963 964 972 public Vector getLanguageMappings () 973 throws JahiaException { 974 Vector siteLanguageMappings = SiteLanguageMappingPersistance.getInstance () 975 .getSiteLanguageMappings (getID ()); 976 return siteLanguageMappings; 977 } 978 979 988 public void setLanguageSettings (Vector siteLanguagesSettings) 989 throws JahiaException { 990 for (int i = 0; i < siteLanguagesSettings.size (); i++) { 991 Object curObject = siteLanguagesSettings.get (i); 992 if (curObject instanceof SiteLanguageSettings) { 993 SiteLanguageSettings curLanguageSettings = 994 (SiteLanguageSettings) siteLanguagesSettings.get (i); 995 if (curLanguageSettings.isInPersistantStorage ()) { 996 if (curLanguageSettings.isDataModified ()) { 997 SiteLanguagesPersistance.getInstance ().updateSiteLanguageSettings ( 998 curLanguageSettings); 999 } 1000 } else { 1001 SiteLanguagesPersistance.getInstance ().addSiteLanguageSettings ( 1002 curLanguageSettings); 1003 } 1004 } else { 1005 logger.debug ("Invalid object passed in vector : " + 1006 curObject.toString ()); 1007 } 1008 } 1009 } 1010 1011 1016 public void setMixLanguagesActive (boolean mixLanguagesActive) { 1017 try { 1018 JahiaSitesPersistance.getInstance ().deleteProperty (getID (), 1020 SitesSettings.MIX_LANGUAGES_ACTIVE); 1021 1022 1023 JahiaSitesPersistance.getInstance ().addProperty (getID (), 1024 SitesSettings.MIX_LANGUAGES_ACTIVE, 1025 new Boolean (mixLanguagesActive).toString ()); 1026 1027 } catch (Throwable t) { 1028 t.printStackTrace (); 1029 } 1030 this.mixLanguagesActive = new Boolean (mixLanguagesActive); 1031 } 1032 1033 public boolean isMixLanguagesActive () { 1034 1035 if (this.mixLanguagesActive != null) { 1036 return mixLanguagesActive.booleanValue (); 1037 } 1038 1039 try { 1040 String value = JahiaSitesPersistance 1041 .getInstance ().getProperty (getID (), 1042 SitesSettings.MIX_LANGUAGES_ACTIVE); 1043 if (value == null || value.trim ().equals ("")) { 1044 setMixLanguagesActive (false); 1045 return false; 1046 } 1047 Boolean mixLanguagesActive = Boolean.valueOf (value); 1048 1049 this.mixLanguagesActive = mixLanguagesActive; 1050 1051 return mixLanguagesActive.booleanValue (); 1052 1053 } catch (Throwable t) { 1054 t.printStackTrace (); 1055 } 1056 return false; 1057 } 1058 1059 1078 public synchronized void serializeToXML (XmlWriter xmlWriter, 1079 XMLSerializationOptions xmlSerializationOptions, 1080 ParamBean paramBean) throws IOException { 1081 try { 1082 ContentPage contentPage = ServicesRegistry.getInstance ().getJahiaPageService () 1083 .lookupContentPage (getHomePageID (), true); 1084 xmlWriter.writeEntity ("contentSite"). 1085 writeAttribute ("name", getSiteKey ()). 1086 writeAttribute ("title", getTitle ()); 1087 if (contentPage != null) { 1088 contentPage.serializeToXML (xmlWriter, new XMLSerializationOptions (), 1089 paramBean); 1090 } else { 1091 xmlWriter.writeEntityWithText ("error", 1092 "Page " + getHomePageID () + " not found"); 1093 } 1094 xmlWriter.endEntity (); 1095 } catch (JahiaException je) { 1096 logger.debug ("Error while serializing site " + getID () + " to XML", je); 1097 } 1098 } 1099 1100 1101 public void setSettings (Properties props) { 1102 this.mSettings = props; 1103 } 1104 1105 public Properties getSettings () { 1106 return this.mSettings; 1107 } 1108 1109 public static class TitleComparator implements Comparator { 1110 1111 private Collator collator = Collator.getInstance(); 1112 1113 public TitleComparator(Locale locale) { 1114 if (locale != null) { 1115 collator = Collator.getInstance(locale); 1116 } 1117 } 1118 1119 public TitleComparator() { 1120 } 1121 1122 public int compare(Object o1, 1123 Object o2) { 1124 JahiaSite site1 = (JahiaSite) o1; 1125 JahiaSite site2 = (JahiaSite) o2; 1126 return collator.compare(site1.getTitle(), site2.getTitle()); 1127 } 1128 1129 public boolean equals(Object obj) { 1130 if (obj instanceof TitleComparator) { 1131 return true; 1132 } else { 1133 return false; 1134 } 1135 } 1136 } 1137 1138 public static TitleComparator getTitleComparator() { 1139 return new TitleComparator(); 1140 } 1141 1142 public static TitleComparator getTitleComparator(Locale locale) { 1143 return new TitleComparator(locale); 1144 } 1145 1146} 1147 | Popular Tags |