001
014
015 package com.liferay.portal.model.impl;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.language.LanguageUtil;
019 import com.liferay.portal.kernel.log.Log;
020 import com.liferay.portal.kernel.log.LogFactoryUtil;
021 import com.liferay.portal.kernel.util.GetterUtil;
022 import com.liferay.portal.kernel.util.HtmlUtil;
023 import com.liferay.portal.kernel.util.LocaleUtil;
024 import com.liferay.portal.kernel.util.OrderByComparator;
025 import com.liferay.portal.kernel.util.StringBundler;
026 import com.liferay.portal.kernel.util.StringPool;
027 import com.liferay.portal.kernel.util.StringUtil;
028 import com.liferay.portal.kernel.util.UnicodeProperties;
029 import com.liferay.portal.kernel.util.Validator;
030 import com.liferay.portal.model.Account;
031 import com.liferay.portal.model.Company;
032 import com.liferay.portal.model.Group;
033 import com.liferay.portal.model.GroupConstants;
034 import com.liferay.portal.model.GroupWrapper;
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.CompanyLocalServiceUtil;
050 import com.liferay.portal.service.GroupLocalServiceUtil;
051 import com.liferay.portal.service.LayoutLocalServiceUtil;
052 import com.liferay.portal.service.LayoutPrototypeLocalServiceUtil;
053 import com.liferay.portal.service.LayoutSetLocalServiceUtil;
054 import com.liferay.portal.service.LayoutSetPrototypeLocalServiceUtil;
055 import com.liferay.portal.service.OrganizationLocalServiceUtil;
056 import com.liferay.portal.service.PortletLocalServiceUtil;
057 import com.liferay.portal.service.RoleLocalServiceUtil;
058 import com.liferay.portal.service.UserGroupLocalServiceUtil;
059 import com.liferay.portal.service.UserLocalServiceUtil;
060 import com.liferay.portal.service.permission.LayoutPermissionUtil;
061 import com.liferay.portal.theme.ThemeDisplay;
062 import com.liferay.portal.util.PortalUtil;
063 import com.liferay.portal.util.PropsValues;
064 import com.liferay.portlet.exportimport.staging.StagingConstants;
065 import com.liferay.portlet.exportimport.staging.StagingUtil;
066
067 import java.io.IOException;
068
069 import java.util.ArrayList;
070 import java.util.LinkedHashSet;
071 import java.util.List;
072 import java.util.Locale;
073 import java.util.Map;
074 import java.util.Set;
075
076
103 public class GroupImpl extends GroupBaseImpl {
104
105 @Override
106 public void clearStagingGroup() {
107 _stagingGroup = null;
108 }
109
110 @Override
111 public List<Group> getAncestors() throws PortalException {
112 Group group = null;
113
114 if (isStagingGroup()) {
115 group = getLiveGroup();
116 }
117 else {
118 group = this;
119 }
120
121 List<Group> groups = new ArrayList<>();
122
123 while (!group.isRoot()) {
124 group = group.getParentGroup();
125
126 groups.add(group);
127 }
128
129 return groups;
130 }
131
132 @Override
133 public List<Group> getChildren(boolean site) {
134 return GroupLocalServiceUtil.getGroups(
135 getCompanyId(), getGroupId(), site);
136 }
137
138
143 @Deprecated
144 @Override
145 public List<Group> getChildrenWithLayouts(
146 boolean site, int start, int end) {
147
148 return getChildrenWithLayouts(site, start, end, null);
149 }
150
151 @Override
152 public List<Group> getChildrenWithLayouts(
153 boolean site, int start, int end, OrderByComparator<Group> obc) {
154
155 return GroupLocalServiceUtil.getLayoutsGroups(
156 getCompanyId(), getGroupId(), site, start, end, obc);
157 }
158
159 @Override
160 public int getChildrenWithLayoutsCount(boolean site) {
161 return GroupLocalServiceUtil.getLayoutsGroupsCount(
162 getCompanyId(), getGroupId(), site);
163 }
164
165 @Override
166 public long getDefaultPrivatePlid() {
167 return getDefaultPlid(true);
168 }
169
170 @Override
171 public long getDefaultPublicPlid() {
172 return getDefaultPlid(false);
173 }
174
175 @Override
176 public List<Group> getDescendants(boolean site) {
177 Set<Group> descendants = new LinkedHashSet<>();
178
179 for (Group group : getChildren(site)) {
180 descendants.add(group);
181 descendants.addAll(group.getDescendants(site));
182 }
183
184 return new ArrayList<>(descendants);
185 }
186
187 @Override
188 public String getDescriptiveName() throws PortalException {
189 return getDescriptiveName(LocaleUtil.getMostRelevantLocale());
190 }
191
192 @Override
193 public String getDescriptiveName(Locale locale) throws PortalException {
194 Group curGroup = this;
195
196 String name = getName(locale);
197
198 if (isCompany() && !isCompanyStagingGroup()) {
199 name = LanguageUtil.get(locale, "global");
200 }
201 else if (isControlPanel()) {
202 name = LanguageUtil.get(locale, "control-panel");
203 }
204 else if (isGuest()) {
205 Company company = CompanyLocalServiceUtil.getCompany(
206 getCompanyId());
207
208 Account account = company.getAccount();
209
210 name = account.getName();
211 }
212 else if (isLayout()) {
213 Layout layout = LayoutLocalServiceUtil.getLayout(getClassPK());
214
215 name = layout.getName(locale);
216 }
217 else if (isLayoutPrototype()) {
218 LayoutPrototype layoutPrototype =
219 LayoutPrototypeLocalServiceUtil.getLayoutPrototype(
220 getClassPK());
221
222 name = layoutPrototype.getName(locale);
223 }
224 else if (isLayoutSetPrototype()) {
225 LayoutSetPrototype layoutSetPrototype =
226 LayoutSetPrototypeLocalServiceUtil.getLayoutSetPrototype(
227 getClassPK());
228
229 name = layoutSetPrototype.getName(locale);
230 }
231 else if (isOrganization()) {
232 long organizationId = getOrganizationId();
233
234 Organization organization =
235 OrganizationLocalServiceUtil.getOrganization(organizationId);
236
237 name = organization.getName();
238
239 curGroup = organization.getGroup();
240 }
241 else if (isUser()) {
242 long userId = getClassPK();
243
244 User user = UserLocalServiceUtil.getUser(userId);
245
246 name = user.getFullName();
247 }
248 else if (isUserGroup()) {
249 long userGroupId = getClassPK();
250
251 UserGroup userGroup = UserGroupLocalServiceUtil.getUserGroup(
252 userGroupId);
253
254 name = userGroup.getName();
255 }
256 else if (isUserPersonalSite()) {
257 name = LanguageUtil.get(locale, "user-personal-site");
258 }
259
260 if (curGroup.isStaged() && !curGroup.isStagedRemotely() &&
261 curGroup.isStagingGroup()) {
262
263 Group liveGroup = getLiveGroup();
264
265 name = liveGroup.getDescriptiveName(locale);
266 }
267
268 return name;
269 }
270
271 @Override
272 public String getDisplayURL(ThemeDisplay themeDisplay) {
273 return getDisplayURL(themeDisplay, false);
274 }
275
276 @Override
277 public String getDisplayURL(
278 ThemeDisplay themeDisplay, boolean privateLayout) {
279
280 if (!privateLayout && (getPublicLayoutsPageCount() > 0)) {
281 try {
282 String groupFriendlyURL = PortalUtil.getGroupFriendlyURL(
283 getPublicLayoutSet(), themeDisplay);
284
285 return PortalUtil.addPreservedParameters(
286 themeDisplay, groupFriendlyURL);
287 }
288 catch (PortalException pe) {
289 }
290 }
291 else if (privateLayout && (getPrivateLayoutsPageCount() > 0)) {
292 try {
293 String groupFriendlyURL = PortalUtil.getGroupFriendlyURL(
294 getPrivateLayoutSet(), themeDisplay);
295
296 return PortalUtil.addPreservedParameters(
297 themeDisplay, groupFriendlyURL);
298 }
299 catch (PortalException pe) {
300 }
301 }
302
303 return StringPool.BLANK;
304 }
305
306 @Override
307 public String getIconCssClass() {
308 String iconCss = "icon-globe";
309
310 if (isCompany()) {
311 iconCss = "icon-globe";
312 }
313 else if (isLayout()) {
314 iconCss = "icon-file";
315 }
316 else if (isOrganization()) {
317 iconCss = "icon-globe";
318 }
319 else if (isUser()) {
320 iconCss = "icon-user";
321 }
322
323 return iconCss;
324 }
325
326 @Override
327 public String getIconURL(ThemeDisplay themeDisplay) {
328 String iconURL = StringPool.BLANK;
329
330 if (isCompany()) {
331 iconURL = "../aui/globe";
332 }
333 else if (isLayout()) {
334 iconURL = "../aui/file";
335 }
336 else if (isOrganization()) {
337 iconURL = "../aui/globe";
338 }
339 else if (isUser()) {
340 iconURL = "../aui/user";
341 }
342 else {
343 iconURL = "../aui/globe";
344 }
345
346 return iconURL;
347 }
348
349 @Override
350 public String getLayoutRootNodeName(boolean privateLayout, Locale locale) {
351 String pagesName = null;
352
353 if (isLayoutPrototype() || isLayoutSetPrototype() || isUserGroup()) {
354 pagesName = "pages";
355 }
356 else if (privateLayout) {
357 if (isUser()) {
358 pagesName = "my-dashboard";
359 }
360 else {
361 pagesName = "private-pages";
362 }
363 }
364 else {
365 if (isUser()) {
366 pagesName = "my-profile";
367 }
368 else {
369 pagesName = "public-pages";
370 }
371 }
372
373 return LanguageUtil.get(locale, pagesName);
374 }
375
376 @Override
377 public Group getLiveGroup() {
378 if (!isStagingGroup()) {
379 return null;
380 }
381
382 try {
383 if (_liveGroup == null) {
384 _liveGroup = GroupLocalServiceUtil.getGroup(getLiveGroupId());
385
386 if (_liveGroup instanceof GroupImpl) {
387 GroupImpl groupImpl = (GroupImpl)_liveGroup;
388
389 groupImpl._stagingGroup = this;
390 }
391 else {
392 _liveGroup = new GroupWrapper(_liveGroup) {
393
394 @Override
395 public Group getStagingGroup() {
396 return GroupImpl.this;
397 }
398
399 };
400 }
401 }
402
403 return _liveGroup;
404 }
405 catch (Exception e) {
406 _log.error("Error getting live group for " + getLiveGroupId(), e);
407
408 return null;
409 }
410 }
411
412 @Override
413 public String getLiveParentTypeSettingsProperty(String key) {
414 UnicodeProperties typeSettingsProperties =
415 getParentLiveGroupTypeSettingsProperties();
416
417 return typeSettingsProperties.getProperty(key);
418 }
419
420 @Override
421 public long getOrganizationId() {
422 if (isOrganization()) {
423 if (isStagingGroup()) {
424 Group liveGroup = getLiveGroup();
425
426 return liveGroup.getClassPK();
427 }
428 else {
429 return getClassPK();
430 }
431 }
432
433 return 0;
434 }
435
436 @Override
437 public Group getParentGroup() throws PortalException {
438 long parentGroupId = getParentGroupId();
439
440 if (parentGroupId <= 0) {
441 return null;
442 }
443
444 return GroupLocalServiceUtil.getGroup(parentGroupId);
445 }
446
447 @Override
448 public UnicodeProperties getParentLiveGroupTypeSettingsProperties() {
449 try {
450 if (isLayout()) {
451 Group parentGroup = GroupLocalServiceUtil.getGroup(
452 getParentGroupId());
453
454 return parentGroup.getParentLiveGroupTypeSettingsProperties();
455 }
456
457 if (isStagingGroup()) {
458 Group liveGroup = getLiveGroup();
459
460 return liveGroup.getTypeSettingsProperties();
461 }
462 }
463 catch (Exception e) {
464 }
465
466 return getTypeSettingsProperties();
467 }
468
469 @Override
470 public String getPathFriendlyURL(
471 boolean privateLayout, ThemeDisplay themeDisplay) {
472
473 if (privateLayout) {
474 if (isUser()) {
475 return themeDisplay.getPathFriendlyURLPrivateUser();
476 }
477 else {
478 return themeDisplay.getPathFriendlyURLPrivateGroup();
479 }
480 }
481 else {
482 return themeDisplay.getPathFriendlyURLPublic();
483 }
484 }
485
486 @Override
487 public LayoutSet getPrivateLayoutSet() {
488 LayoutSet layoutSet = null;
489
490 try {
491 layoutSet = LayoutSetLocalServiceUtil.getLayoutSet(
492 getGroupId(), true);
493 }
494 catch (Exception e) {
495 _log.error(e, e);
496 }
497
498 return layoutSet;
499 }
500
501 @Override
502 public int getPrivateLayoutsPageCount() {
503 try {
504 return LayoutLocalServiceUtil.getLayoutsCount(this, true);
505 }
506 catch (Exception e) {
507 _log.error(e, e);
508 }
509
510 return 0;
511 }
512
513 @Override
514 public LayoutSet getPublicLayoutSet() {
515 LayoutSet layoutSet = null;
516
517 try {
518 layoutSet = LayoutSetLocalServiceUtil.getLayoutSet(
519 getGroupId(), false);
520 }
521 catch (Exception e) {
522 _log.error(e, e);
523 }
524
525 return layoutSet;
526 }
527
528 @Override
529 public int getPublicLayoutsPageCount() {
530 try {
531 return LayoutLocalServiceUtil.getLayoutsCount(this, false);
532 }
533 catch (Exception e) {
534 _log.error(e, e);
535 }
536
537 return 0;
538 }
539
540 @Override
541 public long getRemoteLiveGroupId() {
542 if (!isStagedRemotely()) {
543 return GroupConstants.DEFAULT_LIVE_GROUP_ID;
544 }
545
546 return GetterUtil.getLong(getTypeSettingsProperty("remoteGroupId"));
547 }
548
549 @Override
550 public String getScopeDescriptiveName(ThemeDisplay themeDisplay)
551 throws PortalException {
552
553 if (getGroupId() == themeDisplay.getScopeGroupId()) {
554 StringBundler sb = new StringBundler(5);
555
556 sb.append(themeDisplay.translate("current-site"));
557 sb.append(StringPool.SPACE);
558 sb.append(StringPool.OPEN_PARENTHESIS);
559 sb.append(
560 HtmlUtil.escape(getDescriptiveName(themeDisplay.getLocale())));
561 sb.append(StringPool.CLOSE_PARENTHESIS);
562
563 return sb.toString();
564 }
565 else if (isLayout() && (getClassPK() == themeDisplay.getPlid())) {
566 StringBundler sb = new StringBundler(5);
567
568 sb.append(themeDisplay.translate("current-page"));
569 sb.append(StringPool.SPACE);
570 sb.append(StringPool.OPEN_PARENTHESIS);
571 sb.append(
572 HtmlUtil.escape(getDescriptiveName(themeDisplay.getLocale())));
573 sb.append(StringPool.CLOSE_PARENTHESIS);
574
575 return sb.toString();
576 }
577 else if (isLayoutPrototype()) {
578 return themeDisplay.translate("default");
579 }
580 else {
581 return HtmlUtil.escape(
582 getDescriptiveName(themeDisplay.getLocale()));
583 }
584 }
585
586 @Override
587 public String getScopeLabel(ThemeDisplay themeDisplay) {
588 String label = "site";
589
590 if (getGroupId() == themeDisplay.getScopeGroupId()) {
591 label = "current-site";
592 }
593 else if (getGroupId() == themeDisplay.getCompanyGroupId()) {
594 label = "global";
595 }
596 else if (isLayout()) {
597 label = "page";
598 }
599 else {
600 Group scopeGroup = themeDisplay.getScopeGroup();
601
602 if (scopeGroup.hasAncestor(getGroupId())) {
603 label = "parent-site";
604 }
605 else if (hasAncestor(scopeGroup.getGroupId())) {
606 label = "child-site";
607 }
608 }
609
610 return label;
611 }
612
613 @Override
614 public Group getStagingGroup() {
615 if (isStagingGroup()) {
616 return null;
617 }
618
619 try {
620 if (_stagingGroup == null) {
621 _stagingGroup = GroupLocalServiceUtil.getStagingGroup(
622 getGroupId());
623
624 if (_stagingGroup instanceof GroupImpl) {
625 GroupImpl groupImpl = (GroupImpl)_stagingGroup;
626
627 groupImpl._liveGroup = this;
628 }
629 else {
630 _stagingGroup = new GroupWrapper(_stagingGroup) {
631
632 @Override
633 public Group getLiveGroup() {
634 return GroupImpl.this;
635 }
636
637 };
638 }
639 }
640
641 return _stagingGroup;
642 }
643 catch (Exception e) {
644 _log.error("Error getting staging group for " + getGroupId(), e);
645
646 return null;
647 }
648 }
649
650 @Override
651 public String getTypeLabel() {
652 return GroupConstants.getTypeLabel(getType());
653 }
654
655 @Override
656 public String getTypeSettings() {
657 if (_typeSettingsProperties == null) {
658 return super.getTypeSettings();
659 }
660 else {
661 return _typeSettingsProperties.toString();
662 }
663 }
664
665 @Override
666 public UnicodeProperties getTypeSettingsProperties() {
667 if (_typeSettingsProperties == null) {
668 _typeSettingsProperties = new UnicodeProperties(true);
669
670 try {
671 _typeSettingsProperties.load(super.getTypeSettings());
672 }
673 catch (IOException ioe) {
674 _log.error(ioe, ioe);
675 }
676 }
677
678 return _typeSettingsProperties;
679 }
680
681 @Override
682 public String getTypeSettingsProperty(String key) {
683 UnicodeProperties typeSettingsProperties = getTypeSettingsProperties();
684
685 return typeSettingsProperties.getProperty(key);
686 }
687
688 @Override
689 public String getUnambiguousName(String name, Locale locale) {
690 try {
691 StringBundler sb = new StringBundler(5);
692
693 sb.append(name);
694 sb.append(StringPool.SPACE);
695 sb.append(StringPool.OPEN_PARENTHESIS);
696 sb.append(getDescriptiveName(locale));
697 sb.append(StringPool.CLOSE_PARENTHESIS);
698
699 return sb.toString();
700 }
701 catch (Exception e) {
702 return name;
703 }
704 }
705
706 @Override
707 public boolean hasAncestor(long groupId) {
708 Group group = null;
709
710 if (isStagingGroup()) {
711 group = getLiveGroup();
712 }
713 else {
714 group = this;
715 }
716
717 String treePath = group.getTreePath();
718
719 if ((groupId != group.getGroupId()) &&
720 treePath.contains(StringPool.SLASH + groupId + StringPool.SLASH)) {
721
722 return true;
723 }
724
725 return false;
726 }
727
728 @Override
729 public boolean hasLocalOrRemoteStagingGroup() {
730 if (hasRemoteStagingGroup() || hasStagingGroup()) {
731 return true;
732 }
733
734 return false;
735 }
736
737 @Override
738 public boolean hasPrivateLayouts() {
739 if (getPrivateLayoutsPageCount() > 0) {
740 return true;
741 }
742 else {
743 return false;
744 }
745 }
746
747 @Override
748 public boolean hasPublicLayouts() {
749 if (getPublicLayoutsPageCount() > 0) {
750 return true;
751 }
752 else {
753 return false;
754 }
755 }
756
757 @Override
758 public boolean hasRemoteStagingGroup() {
759 if (getRemoteStagingGroupCount() > 0) {
760 return true;
761 }
762
763 return false;
764 }
765
766 @Override
767 public boolean hasStagingGroup() {
768 if (isStagingGroup()) {
769 return false;
770 }
771
772 if (_stagingGroup != null) {
773 return true;
774 }
775
776 try {
777 return GroupLocalServiceUtil.hasStagingGroup(getGroupId());
778 }
779 catch (Exception e) {
780 return false;
781 }
782 }
783
784
787 @Deprecated
788 @Override
789 public boolean isChild(long groupId) {
790 return hasAncestor(groupId);
791 }
792
793
796 @Deprecated
797 @Override
798 public boolean isCommunity() {
799 return isRegularSite();
800 }
801
802 @Override
803 public boolean isCompany() {
804 return hasClassName(Company.class) || isCompanyStagingGroup();
805 }
806
807 @Override
808 public boolean isCompanyStagingGroup() {
809 Group liveGroup = getLiveGroup();
810
811 if (liveGroup == null) {
812 return false;
813 }
814
815 return liveGroup.isCompany();
816 }
817
818 @Override
819 public boolean isControlPanel() {
820 String groupKey = getGroupKey();
821
822 if (groupKey.equals(GroupConstants.CONTROL_PANEL)) {
823 return true;
824 }
825 else {
826 return false;
827 }
828 }
829
830 @Override
831 public boolean isGuest() {
832 String groupKey = getGroupKey();
833
834 if (groupKey.equals(GroupConstants.GUEST)) {
835 return true;
836 }
837 else {
838 return false;
839 }
840 }
841
842 @Override
843 public boolean isInStagingPortlet(String portletId) {
844 Group liveGroup = getLiveGroup();
845
846 if (liveGroup == null) {
847 return false;
848 }
849
850 return liveGroup.isStagedPortlet(portletId);
851 }
852
853 @Override
854 public boolean isLayout() {
855 return hasClassName(Layout.class);
856 }
857
858 @Override
859 public boolean isLayoutPrototype() {
860 return hasClassName(LayoutPrototype.class);
861 }
862
863 @Override
864 public boolean isLayoutSetPrototype() {
865 return hasClassName(LayoutSetPrototype.class);
866 }
867
868 @Override
869 public boolean isLimitedToParentSiteMembers() {
870 if ((getParentGroupId() != GroupConstants.DEFAULT_PARENT_GROUP_ID) &&
871 (getMembershipRestriction() ==
872 GroupConstants.MEMBERSHIP_RESTRICTION_TO_PARENT_SITE_MEMBERS)) {
873
874 return true;
875 }
876
877 return false;
878 }
879
880 @Override
881 public boolean isOrganization() {
882 return hasClassName(Organization.class);
883 }
884
885 @Override
886 public boolean isRegularSite() {
887 return hasClassName(Group.class);
888 }
889
890 @Override
891 public boolean isRoot() {
892 if (getParentGroupId() == GroupConstants.DEFAULT_PARENT_GROUP_ID) {
893 return true;
894 }
895
896 return false;
897 }
898
899 @Override
900 public boolean isShowSite(
901 PermissionChecker permissionChecker, boolean privateSite)
902 throws PortalException {
903
904 if (!isControlPanel() && !isSite() && !isUser() &&
905 !isUserPersonalPanel()) {
906
907 return false;
908 }
909
910 boolean showSite = true;
911
912 Layout defaultLayout = null;
913
914 int siteLayoutsCount = LayoutLocalServiceUtil.getLayoutsCount(
915 this, privateSite);
916
917 if (siteLayoutsCount == 0) {
918 boolean hasPowerUserRole = RoleLocalServiceUtil.hasUserRole(
919 permissionChecker.getUserId(), permissionChecker.getCompanyId(),
920 RoleConstants.POWER_USER, true);
921
922 if (isSite()) {
923 if (privateSite) {
924 showSite =
925 PropsValues.MY_SITES_SHOW_PRIVATE_SITES_WITH_NO_LAYOUTS;
926 }
927 else {
928 showSite =
929 PropsValues.MY_SITES_SHOW_PUBLIC_SITES_WITH_NO_LAYOUTS;
930 }
931 }
932 else if (isOrganization()) {
933 showSite = false;
934 }
935 else if (isUser()) {
936 if (privateSite) {
937 showSite =
938 PropsValues.
939 MY_SITES_SHOW_USER_PRIVATE_SITES_WITH_NO_LAYOUTS;
940
941 if (PropsValues.
942 LAYOUT_USER_PRIVATE_LAYOUTS_POWER_USER_REQUIRED &&
943 !hasPowerUserRole) {
944
945 showSite = false;
946 }
947 }
948 else {
949 showSite =
950 PropsValues.
951 MY_SITES_SHOW_USER_PUBLIC_SITES_WITH_NO_LAYOUTS;
952
953 if (PropsValues.
954 LAYOUT_USER_PUBLIC_LAYOUTS_POWER_USER_REQUIRED &&
955 !hasPowerUserRole) {
956
957 showSite = false;
958 }
959 }
960 }
961 }
962 else {
963 defaultLayout = LayoutLocalServiceUtil.fetchFirstLayout(
964 getGroupId(), privateSite,
965 LayoutConstants.DEFAULT_PARENT_LAYOUT_ID);
966
967 if ((defaultLayout != null ) &&
968 !LayoutPermissionUtil.contains(
969 permissionChecker, defaultLayout, true, ActionKeys.VIEW)) {
970
971 showSite = false;
972 }
973 else if (isOrganization() && !isSite()) {
974 _log.error(
975 "Group " + getGroupId() +
976 " is an organization site that does not have pages");
977 }
978 }
979
980 return showSite;
981 }
982
983 @Override
984 public boolean isStaged() {
985 return GetterUtil.getBoolean(
986 getLiveParentTypeSettingsProperty("staged"));
987 }
988
989 @Override
990 public boolean isStagedPortlet(String portletId) {
991 UnicodeProperties typeSettingsProperties =
992 getParentLiveGroupTypeSettingsProperties();
993
994 portletId = PortletConstants.getRootPortletId(portletId);
995
996 String typeSettingsProperty = typeSettingsProperties.getProperty(
997 StagingUtil.getStagedPortletId(portletId));
998
999 if (Validator.isNotNull(typeSettingsProperty)) {
1000 return GetterUtil.getBoolean(typeSettingsProperty);
1001 }
1002
1003 try {
1004 Portlet portlet = PortletLocalServiceUtil.getPortletById(portletId);
1005
1006 String portletDataHandlerClass =
1007 portlet.getPortletDataHandlerClass();
1008
1009 for (Map.Entry<String, String> entry :
1010 typeSettingsProperties.entrySet()) {
1011
1012 String key = entry.getKey();
1013
1014 if (!key.contains(StagingConstants.STAGED_PORTLET)) {
1015 continue;
1016 }
1017
1018 String stagedPortletId = StringUtil.replace(
1019 key, StagingConstants.STAGED_PORTLET, StringPool.BLANK);
1020
1021 Portlet stagedPortlet = PortletLocalServiceUtil.getPortletById(
1022 stagedPortletId);
1023
1024 if (portletDataHandlerClass.equals(
1025 stagedPortlet.getPortletDataHandlerClass())) {
1026
1027 return GetterUtil.getBoolean(entry.getValue());
1028 }
1029 }
1030 }
1031 catch (Exception e) {
1032 }
1033
1034 return true;
1035 }
1036
1037 @Override
1038 public boolean isStagedRemotely() {
1039 return GetterUtil.getBoolean(
1040 getLiveParentTypeSettingsProperty("stagedRemotely"));
1041 }
1042
1043 @Override
1044 public boolean isStagingGroup() {
1045 if (getLiveGroupId() == GroupConstants.DEFAULT_LIVE_GROUP_ID) {
1046 return false;
1047 }
1048 else {
1049 return true;
1050 }
1051 }
1052
1053 @Override
1054 public boolean isUser() {
1055 return hasClassName(User.class);
1056 }
1057
1058 @Override
1059 public boolean isUserGroup() {
1060 return hasClassName(UserGroup.class);
1061 }
1062
1063 @Override
1064 public boolean isUserPersonalPanel() {
1065 String groupKey = getGroupKey();
1066
1067 if (groupKey.equals(GroupConstants.USER_PERSONAL_PANEL)) {
1068 return true;
1069 }
1070 else {
1071 return false;
1072 }
1073 }
1074
1075 @Override
1076 public boolean isUserPersonalSite() {
1077 return hasClassName(UserPersonalSite.class);
1078 }
1079
1080 @Override
1081 public void setTypeSettings(String typeSettings) {
1082 _typeSettingsProperties = null;
1083
1084 super.setTypeSettings(typeSettings);
1085 }
1086
1087 @Override
1088 public void setTypeSettingsProperties(
1089 UnicodeProperties typeSettingsProperties) {
1090
1091 _typeSettingsProperties = typeSettingsProperties;
1092
1093 super.setTypeSettings(_typeSettingsProperties.toString());
1094 }
1095
1096 protected long getDefaultPlid(boolean privateLayout) {
1097 try {
1098 Layout firstLayout = LayoutLocalServiceUtil.fetchFirstLayout(
1099 getGroupId(), privateLayout,
1100 LayoutConstants.DEFAULT_PARENT_LAYOUT_ID);
1101
1102 if (firstLayout != null) {
1103 return firstLayout.getPlid();
1104 }
1105 }
1106 catch (Exception e) {
1107 if (_log.isWarnEnabled()) {
1108 _log.warn(e.getMessage());
1109 }
1110 }
1111
1112 return LayoutConstants.DEFAULT_PLID;
1113 }
1114
1115 protected boolean hasClassName(Class<?> clazz) {
1116 long classNameId = getClassNameId();
1117
1118 if (classNameId == PortalUtil.getClassNameId(clazz)) {
1119 return true;
1120 }
1121 else {
1122 return false;
1123 }
1124 }
1125
1126 private static final Log _log = LogFactoryUtil.getLog(GroupImpl.class);
1127
1128 private Group _liveGroup;
1129 private Group _stagingGroup;
1130 private UnicodeProperties _typeSettingsProperties;
1131
1132 }