Exemplo n.º 1
0
  private static LayoutSet _getParentLayoutSet(LayoutSet layoutSet) throws Exception {

    Group group = layoutSet.getGroup();

    if (group.isSite()) {
      Group parentGroup = group.getParentGroup();

      if (parentGroup != null) {
        return LayoutSetLocalServiceUtil.getLayoutSet(
            parentGroup.getGroupId(), layoutSet.isPrivateLayout());
      }
    } else if (group.isUser()) {
      User user = UserLocalServiceUtil.getUser(group.getClassPK());

      List<Organization> organizations =
          OrganizationLocalServiceUtil.getUserOrganizations(user.getUserId());

      if (!organizations.isEmpty()) {
        Organization organization = organizations.get(0);

        Group parentGroup = organization.getGroup();

        return LayoutSetLocalServiceUtil.getLayoutSet(
            parentGroup.getGroupId(), layoutSet.isPrivateLayout());
      }
    }

    return null;
  }
Exemplo n.º 2
0
  public static BreadcrumbEntry getGuestGroupBreadcrumbEntry(ThemeDisplay themeDisplay)
      throws Exception {

    Group group = GroupLocalServiceUtil.getGroup(themeDisplay.getCompanyId(), GroupConstants.GUEST);

    if (group.getPublicLayoutsPageCount() == 0) {
      return null;
    }

    LayoutSet layoutSet = LayoutSetLocalServiceUtil.getLayoutSet(group.getGroupId(), false);

    BreadcrumbEntry breadcrumbEntry = new BreadcrumbEntry();

    Account account = themeDisplay.getAccount();

    breadcrumbEntry.setTitle(account.getName());

    String layoutSetFriendlyURL = PortalUtil.getLayoutSetFriendlyURL(layoutSet, themeDisplay);

    if (themeDisplay.isAddSessionIdToURL()) {
      layoutSetFriendlyURL =
          PortalUtil.getURLWithSessionId(layoutSetFriendlyURL, themeDisplay.getSessionId());
    }

    breadcrumbEntry.setURL(layoutSetFriendlyURL);

    return breadcrumbEntry;
  }
  protected void updateLayoutSetPrototype(Layout layout, Date modifiedDate) {
    if (layout == null) {
      return;
    }

    Group group = null;

    try {
      group = layout.getGroup();

      if (!group.isLayoutSetPrototype()) {
        return;
      }
    } catch (PortalException pe) {
      return;
    }

    try {
      LayoutSetPrototype layoutSetPrototype =
          LayoutSetPrototypeLocalServiceUtil.getLayoutSetPrototype(group.getClassPK());

      layoutSetPrototype.setModifiedDate(modifiedDate);

      LayoutSetPrototypeLocalServiceUtil.updateLayoutSetPrototype(layoutSetPrototype);

      LayoutSet layoutSet = layoutSetPrototype.getLayoutSet();

      layoutSet.setModifiedDate(layout.getModifiedDate());

      UnicodeProperties settingsProperties = layoutSet.getSettingsProperties();

      settingsProperties.remove(Sites.MERGE_FAIL_COUNT);

      LayoutSetLocalServiceUtil.updateLayoutSet(layoutSet);
    } catch (Exception e) {
      _log.error(e, e);
    }
  }