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) || isCompanyStagingGroup();
574            }
575    
576            @Override
577            public boolean isCompanyStagingGroup() {
578                    Group liveGroup = getLiveGroup();
579    
580                    if (liveGroup == null) {
581                            return false;
582                    }
583    
584                    return liveGroup.isCompany();
585            }
586    
587            @Override
588            public boolean isControlPanel() {
589                    String name = getName();
590    
591                    if (name.equals(GroupConstants.CONTROL_PANEL)) {
592                            return true;
593                    }
594                    else {
595                            return false;
596                    }
597            }
598    
599            @Override
600            public boolean isGuest() {
601                    String name = getName();
602    
603                    if (name.equals(GroupConstants.GUEST)) {
604                            return true;
605                    }
606                    else {
607                            return false;
608                    }
609            }
610    
611            @Override
612            public boolean isInStagingPortlet(String portletId) {
613                    Group liveGroup = getLiveGroup();
614    
615                    if (liveGroup == null) {
616                            return false;
617                    }
618    
619                    return liveGroup.isStagedPortlet(portletId);
620            }
621    
622            @Override
623            public boolean isLayout() {
624                    return hasClassName(Layout.class);
625            }
626    
627            @Override
628            public boolean isLayoutPrototype() {
629                    return hasClassName(LayoutPrototype.class);
630            }
631    
632            @Override
633            public boolean isLayoutSetPrototype() {
634                    return hasClassName(LayoutSetPrototype.class);
635            }
636    
637            @Override
638            public boolean isLimitedToParentSiteMembers() {
639                    if ((getParentGroupId() != GroupConstants.DEFAULT_PARENT_GROUP_ID) &&
640                            (getMembershipRestriction() ==
641                                    GroupConstants.MEMBERSHIP_RESTRICTION_TO_PARENT_SITE_MEMBERS)) {
642    
643                            return true;
644                    }
645    
646                    return false;
647            }
648    
649            @Override
650            public boolean isOrganization() {
651                    return hasClassName(Organization.class);
652            }
653    
654            @Override
655            public boolean isRegularSite() {
656                    return hasClassName(Group.class);
657            }
658    
659            @Override
660            public boolean isRoot() {
661                    if (getParentGroupId() ==
662                                    GroupConstants.DEFAULT_PARENT_GROUP_ID) {
663    
664                            return true;
665                    }
666    
667                    return false;
668            }
669    
670            @Override
671            public boolean isShowSite(
672                            PermissionChecker permissionChecker, boolean privateSite)
673                    throws PortalException, SystemException {
674    
675                    if (!isControlPanel() && !isSite() && !isUser()) {
676                            return false;
677                    }
678    
679                    boolean showSite = true;
680    
681                    Layout defaultLayout = null;
682    
683                    int siteLayoutsCount = LayoutLocalServiceUtil.getLayoutsCount(
684                            this, true);
685    
686                    if (siteLayoutsCount == 0) {
687                            boolean hasPowerUserRole = RoleLocalServiceUtil.hasUserRole(
688                                    permissionChecker.getUserId(), permissionChecker.getCompanyId(),
689                                    RoleConstants.POWER_USER, true);
690    
691                            if (isSite()) {
692                                    if (privateSite) {
693                                            showSite =
694                                                    PropsValues.MY_SITES_SHOW_PRIVATE_SITES_WITH_NO_LAYOUTS;
695                                    }
696                                    else {
697                                            showSite =
698                                                    PropsValues.MY_SITES_SHOW_PUBLIC_SITES_WITH_NO_LAYOUTS;
699                                    }
700                            }
701                            else if (isOrganization()) {
702                                    showSite = false;
703                            }
704                            else if (isUser()) {
705                                    if (privateSite) {
706                                            showSite =
707                                                    PropsValues.
708                                                            MY_SITES_SHOW_USER_PRIVATE_SITES_WITH_NO_LAYOUTS;
709    
710                                            if (PropsValues.
711                                                            LAYOUT_USER_PRIVATE_LAYOUTS_POWER_USER_REQUIRED &&
712                                                    !hasPowerUserRole) {
713    
714                                                    showSite = false;
715                                            }
716                                    }
717                                    else {
718                                            showSite =
719                                                    PropsValues.
720                                                            MY_SITES_SHOW_USER_PUBLIC_SITES_WITH_NO_LAYOUTS;
721    
722                                            if (PropsValues.
723                                                            LAYOUT_USER_PUBLIC_LAYOUTS_POWER_USER_REQUIRED &&
724                                                    !hasPowerUserRole) {
725    
726                                                    showSite = false;
727                                            }
728                                    }
729                            }
730                    }
731                    else {
732                            defaultLayout = LayoutLocalServiceUtil.fetchFirstLayout(
733                                    getGroupId(), privateSite,
734                                    LayoutConstants.DEFAULT_PARENT_LAYOUT_ID);
735    
736                            if ((defaultLayout != null ) &&
737                                    !LayoutPermissionUtil.contains(
738                                            permissionChecker, defaultLayout, true, ActionKeys.VIEW)) {
739    
740                                    showSite = false;
741                            }
742                            else if (isOrganization() && !isSite()) {
743                                    _log.error(
744                                            "Group " + getGroupId() +
745                                                    " is an organization site that does not have pages");
746                            }
747                    }
748    
749                    return showSite;
750            }
751    
752            @Override
753            public boolean isStaged() {
754                    return GetterUtil.getBoolean(
755                            getLiveParentTypeSettingsProperty("staged"));
756            }
757    
758            @Override
759            public boolean isStagedPortlet(String portletId) {
760                    UnicodeProperties typeSettingsProperties =
761                            getParentLiveGroupTypeSettingsProperties();
762    
763                    portletId = PortletConstants.getRootPortletId(portletId);
764    
765                    String typeSettingsProperty = typeSettingsProperties.getProperty(
766                            StagingUtil.getStagedPortletId(portletId));
767    
768                    if (Validator.isNotNull(typeSettingsProperty)) {
769                            return GetterUtil.getBoolean(typeSettingsProperty);
770                    }
771    
772                    try {
773                            Portlet portlet = PortletLocalServiceUtil.getPortletById(portletId);
774    
775                            String portletDataHandlerClass =
776                                    portlet.getPortletDataHandlerClass();
777    
778                            if (Validator.isNull(portletDataHandlerClass)) {
779                                    return true;
780                            }
781    
782                            for (Map.Entry<String, String> entry :
783                                            typeSettingsProperties.entrySet()) {
784    
785                                    String key = entry.getKey();
786    
787                                    if (!key.contains(StagingConstants.STAGED_PORTLET)) {
788                                            continue;
789                                    }
790    
791                                    String stagedPortletId = StringUtil.replace(
792                                            key, StagingConstants.STAGED_PORTLET, StringPool.BLANK);
793    
794                                    Portlet stagedPortlet = PortletLocalServiceUtil.getPortletById(
795                                            stagedPortletId);
796    
797                                    if (portletDataHandlerClass.equals(
798                                                    stagedPortlet.getPortletDataHandlerClass())) {
799    
800                                            return GetterUtil.getBoolean(entry.getValue());
801                                    }
802                            }
803                    }
804                    catch (Exception e) {
805                    }
806    
807                    return true;
808            }
809    
810            @Override
811            public boolean isStagedRemotely() {
812                    return GetterUtil.getBoolean(
813                            getLiveParentTypeSettingsProperty("stagedRemotely"));
814            }
815    
816            @Override
817            public boolean isStagingGroup() {
818                    if (getLiveGroupId() == GroupConstants.DEFAULT_LIVE_GROUP_ID) {
819                            return false;
820                    }
821                    else {
822                            return true;
823                    }
824            }
825    
826            @Override
827            public boolean isUser() {
828                    return hasClassName(User.class);
829            }
830    
831            @Override
832            public boolean isUserGroup() {
833                    return hasClassName(UserGroup.class);
834            }
835    
836            @Override
837            public boolean isUserPersonalSite() {
838                    return hasClassName(UserPersonalSite.class);
839            }
840    
841            @Override
842            public void setTypeSettings(String typeSettings) {
843                    _typeSettingsProperties = null;
844    
845                    super.setTypeSettings(typeSettings);
846            }
847    
848            @Override
849            public void setTypeSettingsProperties(
850                    UnicodeProperties typeSettingsProperties) {
851    
852                    _typeSettingsProperties = typeSettingsProperties;
853    
854                    super.setTypeSettings(_typeSettingsProperties.toString());
855            }
856    
857            protected void buildTreePath(StringBundler sb, Group group)
858                    throws PortalException, SystemException {
859    
860                    if (group == null) {
861                            sb.append(StringPool.SLASH);
862                    }
863                    else {
864                            buildTreePath(sb, group.getParentGroup());
865    
866                            sb.append(group.getGroupId());
867                            sb.append(StringPool.SLASH);
868                    }
869            }
870    
871            protected long getDefaultPlid(boolean privateLayout) {
872                    try {
873                            Layout firstLayout = LayoutLocalServiceUtil.fetchFirstLayout(
874                                    getGroupId(), privateLayout,
875                                    LayoutConstants.DEFAULT_PARENT_LAYOUT_ID);
876    
877                            if (firstLayout != null) {
878                                    return firstLayout.getPlid();
879                            }
880                    }
881                    catch (Exception e) {
882                            if (_log.isWarnEnabled()) {
883                                    _log.warn(e.getMessage());
884                            }
885                    }
886    
887                    return LayoutConstants.DEFAULT_PLID;
888            }
889    
890            protected boolean hasClassName(Class<?> clazz) {
891                    long classNameId = getClassNameId();
892    
893                    if (classNameId == PortalUtil.getClassNameId(clazz)) {
894                            return true;
895                    }
896                    else {
897                            return false;
898                    }
899            }
900    
901            private static Log _log = LogFactoryUtil.getLog(GroupImpl.class);
902    
903            private Group _liveGroup;
904            private Group _stagingGroup;
905            private UnicodeProperties _typeSettingsProperties;
906    
907    }