protected String addBasicWebContentStructureAndTemplate(long companyId) throws Exception {

    initJournalDDMCompositeModelsResourceActions();

    Group group = _groupLocalService.getCompanyGroup(companyId);

    long defaultUserId = _userLocalService.getDefaultUserId(companyId);

    Class<?> clazz = getClass();

    _defaultDDMStructureHelper.addDDMStructures(
        defaultUserId,
        group.getGroupId(),
        PortalUtil.getClassNameId(JournalArticle.class),
        clazz.getClassLoader(),
        "com/liferay/journal/internal/upgrade/v1_0_0/dependencies"
            + "/basic-web-content-structure.xml",
        new ServiceContext());

    String defaultLanguageId = UpgradeProcessUtil.getDefaultLanguageId(companyId);

    Locale defaultLocale = LocaleUtil.fromLanguageId(defaultLanguageId);

    List<Element> structureElements = getDDMStructures(defaultLocale);

    Element structureElement = structureElements.get(0);

    return StringUtil.toUpperCase(structureElement.elementText("name"));
  }
  public void initPermissions(long companyId, List<Portlet> portlets) {
    Role powerUserRole = getPowerUserRole(companyId);

    if (powerUserRole == null) {
      return;
    }

    Group userPersonalSiteGroup = getUserPersonalSiteGroup(companyId);

    if (userPersonalSiteGroup == null) {
      return;
    }

    for (Portlet portlet : portlets) {
      try {
        initPermissions(
            companyId,
            powerUserRole.getRoleId(),
            portlet.getRootPortletId(),
            userPersonalSiteGroup.getGroupId());
      } catch (PortalException pe) {
        _log.error(
            "Unable to initialize user personal site permissions "
                + "for portlet "
                + portlet.getPortletId()
                + " in company "
                + companyId,
            pe);
      }
    }
  }
  @Override
  public String replaceImportContentReferences(
      PortletDataContext portletDataContext, StagedModel stagedModel, String content)
      throws Exception {

    JournalFeed feed = (JournalFeed) stagedModel;

    Group group = _groupLocalService.getGroup(portletDataContext.getScopeGroupId());

    String newGroupFriendlyURL = group.getFriendlyURL();

    newGroupFriendlyURL = newGroupFriendlyURL.substring(1);

    String[] friendlyURLParts = StringUtil.split(feed.getTargetLayoutFriendlyUrl(), '/');

    String oldGroupFriendlyURL = friendlyURLParts[2];

    if (oldGroupFriendlyURL.equals(DATA_HANDLER_GROUP_FRIENDLY_URL)) {
      feed.setTargetLayoutFriendlyUrl(
          StringUtil.replace(
              feed.getTargetLayoutFriendlyUrl(),
              DATA_HANDLER_GROUP_FRIENDLY_URL,
              newGroupFriendlyURL));
    }

    return content;
  }
  protected String getGroupURL(
      Group group, PortletRequest portletRequest, boolean includeStagingGroup) {

    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    String groupDisplayURL = group.getDisplayURL(themeDisplay, false);

    if (Validator.isNotNull(groupDisplayURL)) {
      return HttpUtil.removeParameter(groupDisplayURL, "p_p_id");
    }

    groupDisplayURL = group.getDisplayURL(themeDisplay, true);

    if (Validator.isNotNull(groupDisplayURL)) {
      return HttpUtil.removeParameter(groupDisplayURL, "p_p_id");
    }

    if (includeStagingGroup && group.hasStagingGroup()) {
      try {
        if (GroupPermissionUtil.contains(
            themeDisplay.getPermissionChecker(), group, ActionKeys.VIEW_STAGING)) {

          return getGroupURL(group.getStagingGroup(), portletRequest);
        }
      } catch (PortalException pe) {
        _log.error("Unable to check permission on group " + group.getGroupId(), pe);
      }
    }

    return getGroupAdministrationURL(group, portletRequest);
  }
  public void initPermissions(List<Company> companies, Portlet portlet) {
    String rootPortletId = portlet.getRootPortletId();

    for (Company company : companies) {
      long companyId = company.getCompanyId();

      Role powerUserRole = getPowerUserRole(companyId);

      if (powerUserRole == null) {
        continue;
      }

      Group userPersonalSiteGroup = getUserPersonalSiteGroup(companyId);

      if (userPersonalSiteGroup == null) {
        continue;
      }

      try {
        initPermissions(
            companyId,
            powerUserRole.getRoleId(),
            rootPortletId,
            userPersonalSiteGroup.getGroupId());
      } catch (PortalException pe) {
        _log.error(
            "Unable to initialize user personal site permissions "
                + "for portlet "
                + portlet.getPortletId()
                + " in company "
                + companyId,
            pe);
      }
    }
  }
  @Override
  public Collection<KaleoTaskAssignment> calculateTaskAssignments(
      KaleoTaskAssignment kaleoTaskAssignment, ExecutionContext executionContext)
      throws PortalException {

    KaleoInstanceToken kaleoInstanceToken = executionContext.getKaleoInstanceToken();

    Group group = null;

    long groupId = kaleoInstanceToken.getGroupId();

    if (groupId != WorkflowConstants.DEFAULT_GROUP_ID) {
      group = _groupLocalService.getGroup(groupId);

      if (group.isLayout()) {
        group = _groupLocalService.getGroup(group.getParentGroupId());
      }
    }

    List<KaleoTaskAssignment> calculatedKaleoTaskAssignments = new ArrayList<>();

    if (isValidAssignment(kaleoTaskAssignment, group)) {
      calculatedKaleoTaskAssignments.add(kaleoTaskAssignment);
    }

    return calculatedKaleoTaskAssignments;
  }
  public LinkedHashMap<String, Object> getGroupParams() throws PortalException {

    if (_groupParams != null) {
      return _groupParams;
    }

    long groupId = ParamUtil.getLong(_request, "groupId");
    boolean includeCurrentGroup = ParamUtil.getBoolean(_request, "includeCurrentGroup", true);

    String type = getType();

    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();
    User user = themeDisplay.getUser();

    boolean filterManageableGroups = true;

    if (permissionChecker.isCompanyAdmin()) {
      filterManageableGroups = false;
    }

    _groupParams = new LinkedHashMap<>();

    _groupParams.put("active", Boolean.TRUE);

    if (isManualMembership()) {
      _groupParams.put("manualMembership", Boolean.TRUE);
    }

    if (type.equals("child-sites")) {
      Group parentGroup = GroupLocalServiceUtil.getGroup(groupId);

      List<Group> parentGroups = new ArrayList<>();

      parentGroups.add(parentGroup);

      _groupParams.put("groupsTree", parentGroups);
    } else if (filterManageableGroups) {
      _groupParams.put("usersGroups", user.getUserId());
    }

    _groupParams.put("site", Boolean.TRUE);

    if (!includeCurrentGroup && (groupId > 0)) {
      List<Long> excludedGroupIds = new ArrayList<>();

      Group group = GroupLocalServiceUtil.getGroup(groupId);

      if (group.isStagingGroup()) {
        excludedGroupIds.add(group.getLiveGroupId());
      } else {
        excludedGroupIds.add(groupId);
      }

      _groupParams.put("excludedGroupIds", excludedGroupIds);
    }

    return _groupParams;
  }
  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 String[] getStaticPortletIds(String position) {
    Layout layout = getLayout();

    String selector1 = StringPool.BLANK;

    Group group = null;

    try {
      group = layout.getGroup();
    } catch (PortalException pe) {
      _log.error("Unable to get group " + layout.getGroupId());

      return new String[0];
    }

    if (group.isUser()) {
      selector1 = LayoutTypePortletConstants.STATIC_PORTLET_USER_SELECTOR;
    } else if (group.isOrganization()) {
      selector1 = LayoutTypePortletConstants.STATIC_PORTLET_ORGANIZATION_SELECTOR;
    } else if (group.isRegularSite()) {
      selector1 = LayoutTypePortletConstants.STATIC_PORTLET_REGULAR_SITE_SELECTOR;
    }

    String selector2 = layout.getFriendlyURL();

    String[] portletIds = PropsUtil.getArray(position, new Filter(selector1, selector2));

    for (int i = 0; i < portletIds.length; i++) {
      portletIds[i] = JS.getSafeName(portletIds[i]);
    }

    return portletIds;
  }
  @Override
  protected void validateImport(
      Map<String, List<StagedModel>> dependentStagedModelsMap, Group group) throws Exception {

    List<StagedModel> ddmStructureDependentStagedModels =
        dependentStagedModelsMap.get(DDMStructure.class.getSimpleName());

    Assert.assertEquals(1, ddmStructureDependentStagedModels.size());

    DDMStructure ddmStructure = (DDMStructure) ddmStructureDependentStagedModels.get(0);

    DDMStructureLocalServiceUtil.getDDMStructureByUuidAndGroupId(
        ddmStructure.getUuid(), group.getGroupId());

    List<StagedModel> ddmTemplateDependentStagedModels =
        dependentStagedModelsMap.get(DDMTemplate.class.getSimpleName());

    Assert.assertEquals(2, ddmTemplateDependentStagedModels.size());

    for (StagedModel ddmTemplateDependentStagedModel : ddmTemplateDependentStagedModels) {

      DDMTemplateLocalServiceUtil.getDDMTemplateByUuidAndGroupId(
          ddmTemplateDependentStagedModel.getUuid(), group.getGroupId());
    }
  }
  @Override
  protected Map<String, List<StagedModel>> addDependentStagedModelsMap(Group group)
      throws Exception {

    Map<String, List<StagedModel>> dependentStagedModelsMap = new LinkedHashMap<>();

    DDMStructure ddmStructure =
        DDMStructureTestUtil.addStructure(group.getGroupId(), DDLRecordSet.class.getName());

    DDMTemplate ddmTemplate1 =
        DDMTemplateTestUtil.addTemplate(
            group.getGroupId(),
            ddmStructure.getStructureId(),
            PortalUtil.getClassNameId(DDLRecordSet.class));

    addDependentStagedModel(dependentStagedModelsMap, DDMTemplate.class, ddmTemplate1);

    DDMTemplate ddmTemplate2 =
        DDMTemplateTestUtil.addTemplate(
            group.getGroupId(),
            ddmStructure.getStructureId(),
            PortalUtil.getClassNameId(DDLRecordSet.class));

    addDependentStagedModel(dependentStagedModelsMap, DDMTemplate.class, ddmTemplate2);

    addDependentStagedModel(dependentStagedModelsMap, DDMStructure.class, ddmStructure);

    return dependentStagedModelsMap;
  }
  @Override
  protected void doDispatch(RenderRequest renderRequest, RenderResponse renderResponse)
      throws IOException, PortletException {

    try {
      User user = PortalUtil.getUser(renderRequest);

      RenderRequestImpl renderRequestImpl = (RenderRequestImpl) renderRequest;

      DynamicServletRequest dynamicRequest =
          (DynamicServletRequest) renderRequestImpl.getHttpServletRequest();

      dynamicRequest.setParameter("p_u_i_d", String.valueOf(user.getUserId()));

      Group group = user.getGroup();

      dynamicRequest.setParameter("groupId", String.valueOf(group.getGroupId()));

      ActionUtil.getGroup(renderRequest);
    } catch (Exception e) {
      throw new PortletException(e);
    }

    super.doDispatch(renderRequest, renderResponse);
  }
  protected PortletDataContext getPortletDataContext(
      ExportImportConfiguration exportImportConfiguration) throws Exception {

    Map<String, Serializable> settingsMap = exportImportConfiguration.getSettingsMap();

    long sourceGroupId = MapUtil.getLong(settingsMap, "sourceGroupId");
    boolean privateLayout = MapUtil.getBoolean(settingsMap, "privateLayout");
    Map<String, String[]> parameterMap = (Map<String, String[]>) settingsMap.get("parameterMap");
    DateRange dateRange = ExportImportDateUtil.getDateRange(exportImportConfiguration);

    Group group = _groupLocalService.getGroup(sourceGroupId);
    ZipWriter zipWriter = ExportImportHelperUtil.getLayoutSetZipWriter(sourceGroupId);

    PortletDataContext portletDataContext =
        PortletDataContextFactoryUtil.createExportPortletDataContext(
            group.getCompanyId(),
            sourceGroupId,
            parameterMap,
            dateRange.getStartDate(),
            dateRange.getEndDate(),
            zipWriter);

    portletDataContext.setPrivateLayout(privateLayout);

    return portletDataContext;
  }
  @Override
  public void onAfterAddAssociation(
      Object classPK, String associationClassName, Object associationClassPK)
      throws ModelListenerException {

    try {
      User user = userLocalService.getUser((Long) classPK);

      if (associationClassName.equals(Group.class.getName())
          || associationClassName.equals(Organization.class.getName())
          || associationClassName.equals(UserGroup.class.getName())) {

        Role role =
            roleLocalService.fetchRole(user.getCompanyId(), RoleConstants.SOCIAL_OFFICE_USER);

        if (role == null) {
          return;
        }

        Group group = null;

        if (associationClassName.equals(Group.class.getName())) {
          group = groupLocalService.getGroup((Long) associationClassPK);
        } else if (associationClassName.equals(Organization.class.getName())) {

          group =
              groupLocalService.getOrganizationGroup(
                  user.getCompanyId(), (Long) associationClassPK);
        } else if (associationClassName.equals(UserGroup.class.getName())) {

          group =
              groupLocalService.getUserGroupGroup(user.getCompanyId(), (Long) associationClassPK);
        }

        if (groupLocalService.hasRoleGroup(role.getRoleId(), group.getGroupId())) {

          enableSocialOffice(user.getGroup());
        }
      } else if (associationClassName.equals(Role.class.getName())) {
        Role role = roleLocalService.getRole((Long) associationClassPK);

        String name = role.getName();

        if (name.equals(RoleConstants.SOCIAL_OFFICE_USER)) {
          enableSocialOffice(user.getGroup());
        }
      }
    } catch (NoSuchGroupException nsge) {

      // LPS-52675

      if (_log.isDebugEnabled()) {
        _log.debug(nsge, nsge);
      }
    } catch (Exception e) {
      throw new ModelListenerException(e);
    }
  }
  @Override
  public String replaceExportContentReferences(
      PortletDataContext portletDataContext,
      StagedModel stagedModel,
      String content,
      boolean exportReferencedContent,
      boolean escapeContent)
      throws Exception {

    JournalFeed feed = (JournalFeed) stagedModel;

    Group group = _groupLocalService.getGroup(portletDataContext.getScopeGroupId());

    String newGroupFriendlyURL = group.getFriendlyURL();

    newGroupFriendlyURL = newGroupFriendlyURL.substring(1);

    String[] friendlyURLParts =
        StringUtil.split(feed.getTargetLayoutFriendlyUrl(), StringPool.FORWARD_SLASH);

    String oldGroupFriendlyURL = friendlyURLParts[2];

    if (newGroupFriendlyURL.equals(oldGroupFriendlyURL)) {
      String targetLayoutFriendlyUrl =
          StringUtil.replaceFirst(
              feed.getTargetLayoutFriendlyUrl(),
              StringPool.SLASH + newGroupFriendlyURL + StringPool.SLASH,
              StringPool.SLASH + DATA_HANDLER_GROUP_FRIENDLY_URL + StringPool.SLASH);

      feed.setTargetLayoutFriendlyUrl(targetLayoutFriendlyUrl);
    }

    Group targetLayoutGroup =
        _groupLocalService.fetchFriendlyURLGroup(
            portletDataContext.getCompanyId(), StringPool.SLASH + oldGroupFriendlyURL);

    boolean privateLayout = false;

    if (!PropsValues.LAYOUT_FRIENDLY_URL_PUBLIC_SERVLET_MAPPING.equals(
        StringPool.SLASH + friendlyURLParts[1])) {

      privateLayout = true;
    }

    String targetLayoutFriendlyURL = StringPool.SLASH + friendlyURLParts[3];

    Layout targetLayout =
        _layoutLocalService.fetchLayoutByFriendlyURL(
            targetLayoutGroup.getGroupId(), privateLayout, targetLayoutFriendlyURL);

    Element feedElement = portletDataContext.getExportDataElement(feed);

    portletDataContext.addReferenceElement(
        feed, feedElement, targetLayout, PortletDataContext.REFERENCE_TYPE_DEPENDENCY, true);

    return content;
  }
  @Override
  public AssetRenderer<User> getAssetRenderer(long groupId, String urlTitle)
      throws PortalException {

    Group group = _groupLocalService.getGroup(groupId);

    User user = _userLocalService.getUserByScreenName(group.getCompanyId(), urlTitle);

    return new UserAssetRenderer(user);
  }
  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;
  }
  protected String deletePortletData(
      PortletDataContext portletDataContext, javax.portlet.PortletPreferences portletPreferences)
      throws Exception {

    Group group = _groupLocalService.getGroup(portletDataContext.getGroupId());

    if (!group.isStagedPortlet(portletDataContext.getPortletId())) {
      if (_log.isDebugEnabled()) {
        _log.debug(
            "Do not delete portlet data for "
                + portletDataContext.getPortletId()
                + " because the portlet is not staged");
      }

      return null;
    }

    PortletDataHandler portletDataHandler =
        _portletDataHandlerProvider.provide(
            portletDataContext.getCompanyId(), portletDataContext.getPortletId());

    if (portletDataHandler == null) {
      if (_log.isDebugEnabled()) {
        StringBundler sb = new StringBundler(4);

        sb.append("Do not delete portlet data for ");
        sb.append(portletDataContext.getPortletId());
        sb.append(" because the portlet does not have a ");
        sb.append("PortletDataHandler");

        _log.debug(sb.toString());
      }

      return null;
    }

    if (_log.isDebugEnabled()) {
      _log.debug("Deleting data for " + portletDataContext.getPortletId());
    }

    try {
      portletPreferences =
          portletDataHandler.deleteData(
              portletDataContext, portletDataContext.getPortletId(), portletPreferences);
    } finally {
      portletDataContext.setGroupId(portletDataContext.getScopeGroupId());
    }

    if (portletPreferences == null) {
      return null;
    }

    return PortletPreferencesFactoryUtil.toXML(portletPreferences);
  }
  @Override
  public void deleteStagedModel(String uuid, long groupId, String className, String extraData)
      throws PortalException {

    Group group = _groupLocalService.getGroup(groupId);

    UserGroup userGroup = fetchStagedModelByUuidAndGroupId(uuid, group.getCompanyId());

    if (userGroup != null) {
      deleteStagedModel(userGroup);
    }
  }
Example #20
0
  public static Tuple getElements(String xml, String className, int inactiveGroupsCount) {

    List<Element> resultRows = new ArrayList<>();
    int totalRows = 0;

    try {
      xml = XMLUtil.stripInvalidChars(xml);

      Document document = SAXReaderUtil.read(xml);

      Element rootElement = document.getRootElement();

      List<Element> elements = rootElement.elements("entry");

      totalRows =
          GetterUtil.getInteger(
              rootElement.elementText(
                  OpenSearchUtil.getQName("totalResults", OpenSearchUtil.OS_NAMESPACE)));

      for (Element element : elements) {
        try {
          long entryScopeGroupId =
              GetterUtil.getLong(
                  element.elementText(
                      OpenSearchUtil.getQName("scopeGroupId", OpenSearchUtil.LIFERAY_NAMESPACE)));

          if ((entryScopeGroupId != 0) && (inactiveGroupsCount > 0)) {
            Group entryGroup = GroupServiceUtil.getGroup(entryScopeGroupId);

            if (entryGroup.isLayout()) {
              entryGroup = GroupLocalServiceUtil.getGroup(entryGroup.getParentGroupId());
            }

            if (!entryGroup.isActive()) {
              totalRows--;

              continue;
            }
          }

          resultRows.add(element);
        } catch (Exception e) {
          _log.error("Unable to retrieve individual search result for " + className, e);

          totalRows--;
        }
      }
    } catch (Exception e) {
      _log.error("Unable to display content for " + className, e);
    }

    return new Tuple(resultRows, totalRows);
  }
  protected void updateMergePages(ActionRequest actionRequest, long liveGroupId) throws Exception {

    boolean mergeGuestPublicPages = ParamUtil.getBoolean(actionRequest, "mergeGuestPublicPages");

    Group liveGroup = groupLocalService.getGroup(liveGroupId);

    UnicodeProperties typeSettingsProperties = liveGroup.getTypeSettingsProperties();

    typeSettingsProperties.setProperty(
        "mergeGuestPublicPages", String.valueOf(mergeGuestPublicPages));

    groupService.updateGroup(liveGroupId, liveGroup.getTypeSettings());
  }
  @Override
  public void deleteStagedModel(String uuid, long groupId, String className, String extraData)
      throws PortalException {

    Group group = _groupLocalService.getGroup(groupId);

    LayoutSetPrototype layoutSetPrototype =
        fetchStagedModelByUuidAndGroupId(uuid, group.getCompanyId());

    if (layoutSetPrototype != null) {
      deleteStagedModel(layoutSetPrototype);
    }
  }
  @Override
  public void deleteStagedModel(String uuid, long groupId, String className, String extraData)
      throws PortalException {

    Group group = GroupLocalServiceUtil.getGroup(groupId);

    Gadget gadget =
        GadgetLocalServiceUtil.fetchGadgetByUuidAndCompanyId(uuid, group.getCompanyId());

    if (gadget != null) {
      deleteStagedModel(gadget);
    }
  }
  @Override
  public boolean isVisible(User user, Layout layout) {
    try {
      Group group = layout.getGroup();

      if (!group.isUser() && layout.isTypePortlet()) {
        return true;
      }
    } catch (PortalException pe) {
      _log.error("Unable to display form for customization settings", pe);
    }

    return false;
  }
  protected File[] exportLayouts(long userGroupId, Map<String, String[]> parameterMap)
      throws PortalException {

    File[] files = new File[2];

    UserGroup userGroup = userGroupPersistence.findByPrimaryKey(userGroupId);

    User user = userLocalService.getUser(GetterUtil.getLong(PrincipalThreadLocal.getName()));

    Group group = userGroup.getGroup();

    if (userGroup.hasPrivateLayouts()) {
      Map<String, Serializable> exportLayoutSettingsMap =
          ExportImportConfigurationSettingsMapFactory.buildExportLayoutSettingsMap(
              user,
              group.getGroupId(),
              true,
              ExportImportHelperUtil.getAllLayoutIds(group.getGroupId(), true),
              parameterMap);

      ExportImportConfiguration exportImportConfiguration =
          exportImportConfigurationLocalService.addDraftExportImportConfiguration(
              user.getUserId(),
              ExportImportConfigurationConstants.TYPE_EXPORT_LAYOUT,
              exportLayoutSettingsMap);

      files[0] = exportImportLocalService.exportLayoutsAsFile(exportImportConfiguration);
    }

    if (userGroup.hasPublicLayouts()) {
      Map<String, Serializable> exportLayoutSettingsMap =
          ExportImportConfigurationSettingsMapFactory.buildExportLayoutSettingsMap(
              user,
              group.getGroupId(),
              false,
              ExportImportHelperUtil.getAllLayoutIds(group.getGroupId(), false),
              parameterMap);

      ExportImportConfiguration exportImportConfiguration =
          exportImportConfigurationLocalService.addDraftExportImportConfiguration(
              user.getUserId(),
              ExportImportConfigurationConstants.TYPE_EXPORT_LAYOUT,
              exportLayoutSettingsMap);

      files[1] = exportImportLocalService.exportLayoutsAsFile(exportImportConfiguration);
    }

    return files;
  }
  protected boolean isLayoutSetPrototype() {
    try {
      Layout layout = getLayout();

      LayoutSet layoutSet = layout.getLayoutSet();

      Group group = layoutSet.getGroup();

      return group.isLayoutSetPrototype();
    } catch (Exception e) {
      _log.error(e, e);
    }

    return false;
  }
  public static List<BreadcrumbEntry> getLayoutBreadcrumbEntries(ThemeDisplay themeDisplay)
      throws Exception {

    List<BreadcrumbEntry> breadcrumbEntries = new ArrayList<>();

    Layout layout = themeDisplay.getLayout();

    Group group = layout.getGroup();

    if (!group.isLayoutPrototype()) {
      _addLayoutBreadcrumbEntries(breadcrumbEntries, themeDisplay, layout);
    }

    return breadcrumbEntries;
  }
  protected boolean isGroupFriendlyURL(
      Group group, Layout layout, String layoutURL, Locale locale) {

    if (Validator.isNull(layoutURL)) {
      return true;
    }

    int pos = layoutURL.lastIndexOf(CharPool.SLASH);

    String layoutURLLanguageId = layoutURL.substring(pos + 1);

    Locale layoutURLLocale = LocaleUtil.fromLanguageId(layoutURLLanguageId, true, false);

    if (layoutURLLocale != null) {
      return true;
    }

    if (PortalUtil.isGroupFriendlyURL(
        layoutURL, group.getFriendlyURL(), layout.getFriendlyURL(locale))) {

      return true;
    }

    return false;
  }
 @Override
 protected StagedModel getStagedModel(String uuid, Group group) {
   try {
     return DDLRecordSetLocalServiceUtil.getDDLRecordSetByUuidAndGroupId(uuid, group.getGroupId());
   } catch (Exception e) {
     return null;
   }
 }
  @Override
  protected Map<String, List<StagedModel>> addDependentStagedModelsMap(Group group)
      throws Exception {

    Map<String, List<StagedModel>> dependentStagedModelsMap = new HashMap<>();

    AssetVocabulary vocabulary = AssetTestUtil.addVocabulary(group.getGroupId());

    addDependentStagedModel(dependentStagedModelsMap, AssetVocabulary.class, vocabulary);

    AssetCategory category =
        AssetTestUtil.addCategory(group.getGroupId(), vocabulary.getVocabularyId());

    addDependentStagedModel(dependentStagedModelsMap, AssetCategory.class, category);

    return dependentStagedModelsMap;
  }