001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.model.impl;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.language.LanguageUtil;
020    import com.liferay.portal.kernel.log.Log;
021    import com.liferay.portal.kernel.log.LogFactoryUtil;
022    import com.liferay.portal.kernel.staging.StagingConstants;
023    import com.liferay.portal.kernel.staging.StagingUtil;
024    import com.liferay.portal.kernel.util.GetterUtil;
025    import com.liferay.portal.kernel.util.HtmlUtil;
026    import com.liferay.portal.kernel.util.LocaleUtil;
027    import com.liferay.portal.kernel.util.StringBundler;
028    import com.liferay.portal.kernel.util.StringPool;
029    import com.liferay.portal.kernel.util.StringUtil;
030    import com.liferay.portal.kernel.util.UnicodeProperties;
031    import com.liferay.portal.kernel.util.Validator;
032    import com.liferay.portal.model.Company;
033    import com.liferay.portal.model.Group;
034    import com.liferay.portal.model.GroupConstants;
035    import com.liferay.portal.model.Layout;
036    import com.liferay.portal.model.LayoutConstants;
037    import com.liferay.portal.model.LayoutPrototype;
038    import com.liferay.portal.model.LayoutSet;
039    import com.liferay.portal.model.LayoutSetPrototype;
040    import com.liferay.portal.model.Organization;
041    import com.liferay.portal.model.Portlet;
042    import com.liferay.portal.model.PortletConstants;
043    import com.liferay.portal.model.RoleConstants;
044    import com.liferay.portal.model.User;
045    import com.liferay.portal.model.UserGroup;
046    import com.liferay.portal.model.UserPersonalSite;
047    import com.liferay.portal.security.permission.ActionKeys;
048    import com.liferay.portal.security.permission.PermissionChecker;
049    import com.liferay.portal.service.GroupLocalServiceUtil;
050    import com.liferay.portal.service.LayoutLocalServiceUtil;
051    import com.liferay.portal.service.LayoutSetLocalServiceUtil;
052    import com.liferay.portal.service.PortletLocalServiceUtil;
053    import com.liferay.portal.service.RoleLocalServiceUtil;
054    import com.liferay.portal.service.permission.LayoutPermissionUtil;
055    import com.liferay.portal.theme.ThemeDisplay;
056    import com.liferay.portal.util.PortalUtil;
057    import com.liferay.portal.util.PropsValues;
058    
059    import java.io.IOException;
060    
061    import java.util.ArrayList;
062    import java.util.List;
063    import java.util.Locale;
064    import java.util.Map;
065    
066    /**
067     * Represents either a site or a generic resource container.
068     *
069     * <p>
070     * Groups are most used in Liferay as a resource container for permissioning and
071     * content scoping purposes. For instance, an site is group, meaning that it can
072     * contain layouts, web content, wiki entries, etc. However, a single layout can
073     * also be a group containing its own unique set of resources. An example of
074     * this would be a site that has several distinct wikis on different layouts.
075     * Each of these layouts would have its own group, and all of the nodes in the
076     * wiki for a certain layout would be associated with that layout's group. This
077     * allows users to be given different permissions on each of the wikis, even
078     * though they are all within the same site. In addition to sites and layouts,
079     * users and organizations are also groups.
080     * </p>
081     *
082     * <p>
083     * Groups also have a second, partially conflicting purpose in Liferay. For
084     * legacy reasons, groups are also the model used to represent sites (known as
085     * communities before Liferay v6.1). Confusion may arise from the fact that a
086     * site group is both the resource container and the site itself, whereas a
087     * layout or organization would have both a primary model and an associated
088     * group.
089     * </p>
090     *
091     * @author Brian Wing Shun Chan
092     */
093    public class GroupImpl extends GroupBaseImpl {
094    
095            public GroupImpl() {
096            }
097    
098            @Override
099            public String buildTreePath() throws PortalException, SystemException {
100                    StringBundler sb = new StringBundler();
101    
102                    buildTreePath(sb, this);
103    
104                    return sb.toString();
105            }
106    
107            @Override
108            public List<Group> getAncestors() throws PortalException, SystemException {
109                    Group group = null;
110    
111                    if (isStagingGroup()) {
112                            group = getLiveGroup();
113                    }
114                    else {
115                            group = this;
116                    }
117    
118                    List<Group> groups = new ArrayList<Group>();
119    
120                    while (!group.isRoot()) {
121                            group = group.getParentGroup();
122    
123                            groups.add(group);
124                    }
125    
126                    return groups;
127            }
128    
129            @Override
130            public List<Group> getChildren(boolean site) throws SystemException {
131                    return GroupLocalServiceUtil.getGroups(
132                            getCompanyId(), getGroupId(), site);
133            }
134    
135            @Override
136            public List<Group> getChildrenWithLayouts(boolean site, int start, int end)
137                    throws SystemException {
138    
139                    return GroupLocalServiceUtil.getLayoutsGroups(
140                            getCompanyId(), getGroupId(), site, start, end);
141            }
142    
143            @Override
144            public int getChildrenWithLayoutsCount(boolean site)
145                    throws SystemException {
146    
147                    return GroupLocalServiceUtil.getLayoutsGroupsCount(
148                            getCompanyId(), getGroupId(), site);
149            }
150    
151            @Override
152            public long getDefaultPrivatePlid() {
153                    return getDefaultPlid(true);
154            }
155    
156            @Override
157            public long getDefaultPublicPlid() {
158                    return getDefaultPlid(false);
159            }
160    
161            @Override
162            public String getDescriptiveName() throws PortalException, SystemException {
163                    return getDescriptiveName(LocaleUtil.getDefault());
164            }
165    
166            @Override
167            public String getDescriptiveName(Locale locale)
168                    throws PortalException, SystemException {
169    
170                    return GroupLocalServiceUtil.getGroupDescriptiveName(this, locale);
171            }
172    
173            @Override
174            public String getIconURL(ThemeDisplay themeDisplay) {
175                    String iconURL = themeDisplay.getPathThemeImages() + "/common/";
176    
177                    if (isCompany()) {
178                            iconURL = iconURL.concat("global.png");
179                    }
180                    else if (isLayout()) {
181                            iconURL = iconURL.concat("page.png");
182                    }
183                    else if (isOrganization()) {
184                            iconURL = iconURL.concat("organization_icon.png");
185                    }
186                    else if (isUser()) {
187                            iconURL = iconURL.concat("user_icon.png");
188                    }
189                    else {
190                            iconURL = iconURL.concat("site_icon.png");
191                    }
192    
193                    return iconURL;
194            }
195    
196            @Override
197            public String getLayoutRootNodeName(boolean privateLayout, Locale locale) {
198                    String pagesName = null;
199    
200                    if (isLayoutPrototype() || isLayoutSetPrototype() || isUserGroup()) {
201                            pagesName = "pages";
202                    }
203                    else if (privateLayout) {
204                            if (isUser()) {
205                                    pagesName = "my-dashboard";
206                            }
207                            else {
208                                    pagesName = "private-pages";
209                            }
210                    }
211                    else {
212                            if (isUser()) {
213                                    pagesName = "my-profile";
214                            }
215                            else {
216                                    pagesName = "public-pages";
217                            }
218                    }
219    
220                    return LanguageUtil.get(locale, pagesName);
221            }
222    
223            @Override
224            public Group getLiveGroup() {
225                    if (!isStagingGroup()) {
226                            return null;
227                    }
228    
229                    try {
230                            if (_liveGroup == null) {
231                                    _liveGroup = GroupLocalServiceUtil.getGroup(getLiveGroupId());
232                            }
233    
234                            return _liveGroup;
235                    }
236                    catch (Exception e) {
237                            _log.error("Error getting live group for " + getLiveGroupId(), e);
238    
239                            return null;
240                    }
241            }
242    
243            @Override
244            public String getLiveParentTypeSettingsProperty(String key) {
245                    UnicodeProperties typeSettingsProperties =
246                            getParentLiveGroupTypeSettingsProperties();
247    
248                    return typeSettingsProperties.getProperty(key);
249            }
250    
251            @Override
252            public long getOrganizationId() {
253                    if (isOrganization()) {
254                            if (isStagingGroup()) {
255                                    Group liveGroup = getLiveGroup();
256    
257                                    return liveGroup.getClassPK();
258                            }
259                            else {
260                                    return getClassPK();
261                            }
262                    }
263    
264                    return 0;
265            }
266    
267            @Override
268            public Group getParentGroup() throws PortalException, SystemException {
269                    long parentGroupId = getParentGroupId();
270    
271                    if (parentGroupId <= 0) {
272                            return null;
273                    }
274    
275                    return GroupLocalServiceUtil.getGroup(parentGroupId);
276            }
277    
278            @Override
279            public UnicodeProperties getParentLiveGroupTypeSettingsProperties() {
280                    try {
281                            if (isLayout()) {
282                                    Group parentGroup = GroupLocalServiceUtil.getGroup(
283                                            getParentGroupId());
284    
285                                    return parentGroup.getParentLiveGroupTypeSettingsProperties();
286                            }
287    
288                            if (isStagingGroup()) {
289                                    Group liveGroup = getLiveGroup();
290    
291                                    return liveGroup.getTypeSettingsProperties();
292                            }
293                    }
294                    catch (Exception e) {
295                    }
296    
297                    return getTypeSettingsProperties();
298            }
299    
300            @Override
301            public String getPathFriendlyURL(
302                    boolean privateLayout, ThemeDisplay themeDisplay) {
303    
304                    if (privateLayout) {
305                            if (isUser()) {
306                                    return themeDisplay.getPathFriendlyURLPrivateUser();
307                            }
308                            else {
309                                    return themeDisplay.getPathFriendlyURLPrivateGroup();
310                            }
311                    }
312                    else {
313                            return themeDisplay.getPathFriendlyURLPublic();
314                    }
315            }
316    
317            @Override
318            public LayoutSet getPrivateLayoutSet() {
319                    LayoutSet layoutSet = null;
320    
321                    try {
322                            layoutSet = LayoutSetLocalServiceUtil.getLayoutSet(
323                                    getGroupId(), true);
324                    }
325                    catch (Exception e) {
326                            _log.error(e, e);
327                    }
328    
329                    return layoutSet;
330            }
331    
332            @Override
333            public int getPrivateLayoutsPageCount() {
334                    try {
335                            return LayoutLocalServiceUtil.getLayoutsCount(this, true);
336                    }
337                    catch (Exception e) {
338                            _log.error(e, e);
339                    }
340    
341                    return 0;
342            }
343    
344            @Override
345            public LayoutSet getPublicLayoutSet() {
346                    LayoutSet layoutSet = null;
347    
348                    try {
349                            layoutSet = LayoutSetLocalServiceUtil.getLayoutSet(
350                                    getGroupId(), false);
351                    }
352                    catch (Exception e) {
353                            _log.error(e, e);
354                    }
355    
356                    return layoutSet;
357            }
358    
359            @Override
360            public int getPublicLayoutsPageCount() {
361                    try {
362                            return LayoutLocalServiceUtil.getLayoutsCount(this, false);
363                    }
364                    catch (Exception e) {
365                            _log.error(e, e);
366                    }
367    
368                    return 0;
369            }
370    
371            @Override
372            public String getScopeDescriptiveName(ThemeDisplay themeDisplay)
373                    throws PortalException, SystemException {
374    
375                    if (getGroupId() == themeDisplay.getScopeGroupId()) {
376                            StringBundler sb = new StringBundler(5);
377    
378                            sb.append(themeDisplay.translate("current-site"));
379                            sb.append(StringPool.SPACE);
380                            sb.append(StringPool.OPEN_PARENTHESIS);
381                            sb.append(
382                                    HtmlUtil.escape(getDescriptiveName(themeDisplay.getLocale())));
383                            sb.append(StringPool.CLOSE_PARENTHESIS);
384    
385                            return sb.toString();
386                    }
387                    else if (isLayout() && (getClassPK() == themeDisplay.getPlid())) {
388                            StringBundler sb = new StringBundler(5);
389    
390                            sb.append(themeDisplay.translate("current-page"));
391                            sb.append(StringPool.SPACE);
392                            sb.append(StringPool.OPEN_PARENTHESIS);
393                            sb.append(
394                                    HtmlUtil.escape(getDescriptiveName(themeDisplay.getLocale())));
395                            sb.append(StringPool.CLOSE_PARENTHESIS);
396    
397                            return sb.toString();
398                    }
399                    else if (isLayoutPrototype()) {
400                            return themeDisplay.translate("default");
401                    }
402                    else {
403                            return HtmlUtil.escape(
404                                    getDescriptiveName(themeDisplay.getLocale()));
405                    }
406            }
407    
408            @Override
409            public String getScopeLabel(ThemeDisplay themeDisplay) {
410                    String label = "site";
411    
412                    if (getGroupId() == themeDisplay.getScopeGroupId()) {
413                            label = "current-site";
414                    }
415                    else if (getGroupId() == themeDisplay.getCompanyGroupId()) {
416                            label = "global";
417                    }
418                    else if (isLayout()) {
419                            label = "page";
420                    }
421                    else {
422                            Group scopeGroup = themeDisplay.getScopeGroup();
423    
424                            if (scopeGroup.hasAncestor(getGroupId())) {
425                                    label = "parent-site";
426                            }
427                            else if (hasAncestor(scopeGroup.getGroupId())) {
428                                    label = "child-site";
429                            }
430                    }
431    
432                    return label;
433            }
434    
435            @Override
436            public Group getStagingGroup() {
437                    if (isStagingGroup()) {
438                            return null;
439                    }
440    
441                    try {
442                            if (_stagingGroup == null) {
443                                    _stagingGroup = GroupLocalServiceUtil.getStagingGroup(
444                                            getGroupId());
445                            }
446    
447                            return _stagingGroup;
448                    }
449                    catch (Exception e) {
450                            _log.error("Error getting staging group for " + getGroupId(), e);
451    
452                            return null;
453                    }
454            }
455    
456            @Override
457            public String getTypeLabel() {
458                    return GroupConstants.getTypeLabel(getType());
459            }
460    
461            @Override
462            public String getTypeSettings() {
463                    if (_typeSettingsProperties == null) {
464                            return super.getTypeSettings();
465                    }
466                    else {
467                            return _typeSettingsProperties.toString();
468                    }
469            }
470    
471            @Override
472            public UnicodeProperties getTypeSettingsProperties() {
473                    if (_typeSettingsProperties == null) {
474                            _typeSettingsProperties = new UnicodeProperties(true);
475    
476                            try {
477                                    _typeSettingsProperties.load(super.getTypeSettings());
478                            }
479                            catch (IOException ioe) {
480                                    _log.error(ioe, ioe);
481                            }
482                    }
483    
484                    return _typeSettingsProperties;
485            }
486    
487            @Override
488            public String getTypeSettingsProperty(String key) {
489                    UnicodeProperties typeSettingsProperties = getTypeSettingsProperties();
490    
491                    return typeSettingsProperties.getProperty(key);
492            }
493    
494            @Override
495            public boolean hasAncestor(long groupId) {
496                    Group group = null;
497    
498                    if (isStagingGroup()) {
499                            group = getLiveGroup();
500                    }
501                    else {
502                            group = this;
503                    }
504    
505                    String treePath = group.getTreePath();
506    
507                    if ((groupId != group.getGroupId()) &&
508                            treePath.contains(StringPool.SLASH + groupId + StringPool.SLASH)) {
509    
510                            return true;
511                    }
512    
513                    return false;
514            }
515    
516            @Override
517            public boolean hasLocalOrRemoteStagingGroup() {
518                    if (hasStagingGroup() || (getRemoteStagingGroupCount() > 0)) {
519                            return true;
520                    }
521    
522                    return false;
523            }
524    
525            @Override
526            public boolean hasPrivateLayouts() {
527                    if (getPrivateLayoutsPageCount() > 0) {
528                            return true;
529                    }
530                    else {
531                            return false;
532                    }
533            }
534    
535            @Override
536            public boolean hasPublicLayouts() {
537                    if (getPublicLayoutsPageCount() > 0) {
538                            return true;
539                    }
540                    else {
541                            return false;
542                    }
543            }
544    
545            @Override
546            public boolean hasStagingGroup() {
547                    if (isStagingGroup()) {
548                            return false;
549                    }
550    
551                    if (_stagingGroup != null) {
552                            return true;
553                    }
554    
555                    try {
556                            return GroupLocalServiceUtil.hasStagingGroup(getGroupId());
557                    }
558                    catch (Exception e) {
559                            return false;
560                    }
561            }
562    
563            /**
564             * @deprecated As of 6.1.0, renamed to {@link #isRegularSite}
565             */
566            @Override
567            public boolean isCommunity() {
568                    return isRegularSite();
569            }
570    
571            @Override
572            public boolean isCompany() {
573                    return hasClassName(Company.class);
574            }
575    
576            @Override
577            public boolean isControlPanel() {
578                    String name = getName();
579    
580                    if (name.equals(GroupConstants.CONTROL_PANEL)) {
581                            return true;
582                    }
583                    else {
584                            return false;
585                    }
586            }
587    
588            @Override
589            public boolean isGuest() {
590                    String name = getName();
591    
592                    if (name.equals(GroupConstants.GUEST)) {
593                            return true;
594                    }
595                    else {
596                            return false;
597                    }
598            }
599    
600            @Override
601            public boolean isInStagingPortlet(String portletId) {
602                    Group liveGroup = getLiveGroup();
603    
604                    if (liveGroup == null) {
605                            return false;
606                    }
607    
608                    return liveGroup.isStagedPortlet(portletId);
609            }
610    
611            @Override
612            public boolean isLayout() {
613                    return hasClassName(Layout.class);
614            }
615    
616            @Override
617            public boolean isLayoutPrototype() {
618                    return hasClassName(LayoutPrototype.class);
619            }
620    
621            @Override
622            public boolean isLayoutSetPrototype() {
623                    return hasClassName(LayoutSetPrototype.class);
624            }
625    
626            @Override
627            public boolean isLimitedToParentSiteMembers() {
628                    if ((getParentGroupId() != GroupConstants.DEFAULT_PARENT_GROUP_ID) &&
629                            (getMembershipRestriction() ==
630                                    GroupConstants.MEMBERSHIP_RESTRICTION_TO_PARENT_SITE_MEMBERS)) {
631    
632                            return true;
633                    }
634    
635                    return false;
636            }
637    
638            @Override
639            public boolean isOrganization() {
640                    return hasClassName(Organization.class);
641            }
642    
643            @Override
644            public boolean isRegularSite() {
645                    return hasClassName(Group.class);
646            }
647    
648            @Override
649            public boolean isRoot() {
650                    if (getParentGroupId() ==
651                                    GroupConstants.DEFAULT_PARENT_GROUP_ID) {
652    
653                            return true;
654                    }
655    
656                    return false;
657            }
658    
659            @Override
660            public boolean isShowSite(
661                            PermissionChecker permissionChecker, boolean privateSite)
662                    throws PortalException, SystemException {
663    
664                    if (!isControlPanel() && !isSite() && !isUser()) {
665                            return false;
666                    }
667    
668                    boolean showSite = true;
669    
670                    Layout defaultLayout = null;
671    
672                    int siteLayoutsCount = LayoutLocalServiceUtil.getLayoutsCount(
673                            this, true);
674    
675                    if (siteLayoutsCount == 0) {
676                            boolean hasPowerUserRole = RoleLocalServiceUtil.hasUserRole(
677                                    permissionChecker.getUserId(), permissionChecker.getCompanyId(),
678                                    RoleConstants.POWER_USER, true);
679    
680                            if (isSite()) {
681                                    if (privateSite) {
682                                            showSite =
683                                                    PropsValues.MY_SITES_SHOW_PRIVATE_SITES_WITH_NO_LAYOUTS;
684                                    }
685                                    else {
686                                            showSite =
687                                                    PropsValues.MY_SITES_SHOW_PUBLIC_SITES_WITH_NO_LAYOUTS;
688                                    }
689                            }
690                            else if (isOrganization()) {
691                                    showSite = false;
692                            }
693                            else if (isUser()) {
694                                    if (privateSite) {
695                                            showSite =
696                                                    PropsValues.
697                                                            MY_SITES_SHOW_USER_PRIVATE_SITES_WITH_NO_LAYOUTS;
698    
699                                            if (PropsValues.
700                                                            LAYOUT_USER_PRIVATE_LAYOUTS_POWER_USER_REQUIRED &&
701                                                    !hasPowerUserRole) {
702    
703                                                    showSite = false;
704                                            }
705                                    }
706                                    else {
707                                            showSite =
708                                                    PropsValues.
709                                                            MY_SITES_SHOW_USER_PUBLIC_SITES_WITH_NO_LAYOUTS;
710    
711                                            if (PropsValues.
712                                                            LAYOUT_USER_PUBLIC_LAYOUTS_POWER_USER_REQUIRED &&
713                                                    !hasPowerUserRole) {
714    
715                                                    showSite = false;
716                                            }
717                                    }
718                            }
719                    }
720                    else {
721                            defaultLayout = LayoutLocalServiceUtil.fetchFirstLayout(
722                                    getGroupId(), privateSite,
723                                    LayoutConstants.DEFAULT_PARENT_LAYOUT_ID);
724    
725                            if ((defaultLayout != null ) &&
726                                    !LayoutPermissionUtil.contains(
727                                            permissionChecker, defaultLayout, true, ActionKeys.VIEW)) {
728    
729                                    showSite = false;
730                            }
731                            else if (isOrganization() && !isSite()) {
732                                    _log.error(
733                                            "Group " + getGroupId() +
734                                                    " is an organization site that does not have pages");
735                            }
736                    }
737    
738                    return showSite;
739            }
740    
741            @Override
742            public boolean isStaged() {
743                    return GetterUtil.getBoolean(
744                            getLiveParentTypeSettingsProperty("staged"));
745            }
746    
747            @Override
748            public boolean isStagedPortlet(String portletId) {
749                    UnicodeProperties typeSettingsProperties =
750                            getParentLiveGroupTypeSettingsProperties();
751    
752                    portletId = PortletConstants.getRootPortletId(portletId);
753    
754                    String typeSettingsProperty = typeSettingsProperties.getProperty(
755                            StagingUtil.getStagedPortletId(portletId));
756    
757                    if (Validator.isNotNull(typeSettingsProperty)) {
758                            return GetterUtil.getBoolean(typeSettingsProperty);
759                    }
760    
761                    try {
762                            Portlet portlet = PortletLocalServiceUtil.getPortletById(portletId);
763    
764                            String portletDataHandlerClass =
765                                    portlet.getPortletDataHandlerClass();
766    
767                            if (Validator.isNull(portletDataHandlerClass)) {
768                                    return true;
769                            }
770    
771                            for (Map.Entry<String, String> entry :
772                                            typeSettingsProperties.entrySet()) {
773    
774                                    String key = entry.getKey();
775    
776                                    if (!key.contains(StagingConstants.STAGED_PORTLET)) {
777                                            continue;
778                                    }
779    
780                                    String stagedPortletId = StringUtil.replace(
781                                            key, StagingConstants.STAGED_PORTLET, StringPool.BLANK);
782    
783                                    Portlet stagedPortlet = PortletLocalServiceUtil.getPortletById(
784                                            stagedPortletId);
785    
786                                    if (portletDataHandlerClass.equals(
787                                                    stagedPortlet.getPortletDataHandlerClass())) {
788    
789                                            return GetterUtil.getBoolean(entry.getValue());
790                                    }
791                            }
792                    }
793                    catch (Exception e) {
794                    }
795    
796                    return true;
797            }
798    
799            @Override
800            public boolean isStagedRemotely() {
801                    return GetterUtil.getBoolean(
802                            getLiveParentTypeSettingsProperty("stagedRemotely"));
803            }
804    
805            @Override
806            public boolean isStagingGroup() {
807                    if (getLiveGroupId() == GroupConstants.DEFAULT_LIVE_GROUP_ID) {
808                            return false;
809                    }
810                    else {
811                            return true;
812                    }
813            }
814    
815            @Override
816            public boolean isUser() {
817                    return hasClassName(User.class);
818            }
819    
820            @Override
821            public boolean isUserGroup() {
822                    return hasClassName(UserGroup.class);
823            }
824    
825            @Override
826            public boolean isUserPersonalSite() {
827                    return hasClassName(UserPersonalSite.class);
828            }
829    
830            @Override
831            public void setTypeSettings(String typeSettings) {
832                    _typeSettingsProperties = null;
833    
834                    super.setTypeSettings(typeSettings);
835            }
836    
837            @Override
838            public void setTypeSettingsProperties(
839                    UnicodeProperties typeSettingsProperties) {
840    
841                    _typeSettingsProperties = typeSettingsProperties;
842    
843                    super.setTypeSettings(_typeSettingsProperties.toString());
844            }
845    
846            protected void buildTreePath(StringBundler sb, Group group)
847                    throws PortalException, SystemException {
848    
849                    if (group == null) {
850                            sb.append(StringPool.SLASH);
851                    }
852                    else {
853                            buildTreePath(sb, group.getParentGroup());
854    
855                            sb.append(group.getGroupId());
856                            sb.append(StringPool.SLASH);
857                    }
858            }
859    
860            protected long getDefaultPlid(boolean privateLayout) {
861                    try {
862                            Layout firstLayout = LayoutLocalServiceUtil.fetchFirstLayout(
863                                    getGroupId(), privateLayout,
864                                    LayoutConstants.DEFAULT_PARENT_LAYOUT_ID);
865    
866                            if (firstLayout != null) {
867                                    return firstLayout.getPlid();
868                            }
869                    }
870                    catch (Exception e) {
871                            if (_log.isWarnEnabled()) {
872                                    _log.warn(e.getMessage());
873                            }
874                    }
875    
876                    return LayoutConstants.DEFAULT_PLID;
877            }
878    
879            protected boolean hasClassName(Class<?> clazz) {
880                    long classNameId = getClassNameId();
881    
882                    if (classNameId == PortalUtil.getClassNameId(clazz)) {
883                            return true;
884                    }
885                    else {
886                            return false;
887                    }
888            }
889    
890            private static Log _log = LogFactoryUtil.getLog(GroupImpl.class);
891    
892            private Group _liveGroup;
893            private Group _stagingGroup;
894            private UnicodeProperties _typeSettingsProperties;
895    
896    }