protected static boolean isExcluded(
      List<String> exclusions, String absolutePath, int lineCount, String javaTermName) {

    if (ListUtil.isEmpty(exclusions)) {
      return false;
    }

    String absolutePathWithJavaTermName = null;

    if (Validator.isNotNull(javaTermName)) {
      absolutePathWithJavaTermName = absolutePath + StringPool.AT + javaTermName;
    }

    String absolutePathWithLineCount = null;

    if (lineCount > 0) {
      absolutePathWithLineCount = absolutePath + StringPool.AT + lineCount;
    }

    for (String exclusion : exclusions) {
      if (absolutePath.endsWith(exclusion)
          || ((absolutePathWithJavaTermName != null)
              && absolutePathWithJavaTermName.endsWith(exclusion))
          || ((absolutePathWithLineCount != null)
              && absolutePathWithLineCount.endsWith(exclusion))) {

        return true;
      }
    }

    return false;
  }
  protected Layout fetchMissingReference(String uuid, long groupId, boolean privateLayout) {

    // Try to fetch the existing layout from the importing group

    Layout layout = _layoutLocalService.fetchLayoutByUuidAndGroupId(uuid, groupId, privateLayout);

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

    try {

      // Try to fetch the existing layout from the parent sites

      Group originalGroup = _groupLocalService.getGroup(groupId);

      Group group = originalGroup.getParentGroup();

      while (group != null) {
        layout =
            _layoutLocalService.fetchLayoutByUuidAndGroupId(
                uuid, group.getGroupId(), privateLayout);

        if (layout != null) {
          break;
        }

        group = group.getParentGroup();
      }

      if (layout == null) {
        List<Layout> layouts =
            fetchStagedModelsByUuidAndCompanyId(uuid, originalGroup.getCompanyId());

        if (ListUtil.isEmpty(layouts)) {
          return null;
        }

        layout = layouts.get(0);
      }

      return layout;
    } catch (Exception e) {
      if (_log.isDebugEnabled()) {
        _log.debug(e, e);
      } else if (_log.isWarnEnabled()) {
        _log.warn("Unable to fetch missing reference layout from group " + groupId);
      }

      return null;
    }
  }
  @Override
  public LayoutFriendlyURL fetchStagedModelByUuidAndCompanyId(String uuid, long companyId) {

    List<LayoutFriendlyURL> friendlyURLs =
        LayoutFriendlyURLLocalServiceUtil.getLayoutFriendlyURLsByUuidAndCompanyId(
            uuid,
            companyId,
            QueryUtil.ALL_POS,
            QueryUtil.ALL_POS,
            new StagedModelModifiedDateComparator<LayoutFriendlyURL>());

    if (ListUtil.isEmpty(friendlyURLs)) {
      return null;
    }

    return friendlyURLs.get(0);
  }
  @Override
  public MDRRuleGroup fetchStagedModelByUuidAndCompanyId(String uuid, long companyId) {

    List<MDRRuleGroup> ruleGroups =
        MDRRuleGroupLocalServiceUtil.getMDRRuleGroupsByUuidAndCompanyId(
            uuid,
            companyId,
            QueryUtil.ALL_POS,
            QueryUtil.ALL_POS,
            new StagedModelModifiedDateComparator<MDRRuleGroup>());

    if (ListUtil.isEmpty(ruleGroups)) {
      return null;
    }

    return ruleGroups.get(0);
  }
  @Override
  public RepositoryEntry fetchStagedModelByUuidAndCompanyId(String uuid, long companyId) {

    List<RepositoryEntry> entries =
        RepositoryEntryLocalServiceUtil.getRepositoryEntriesByUuidAndCompanyId(
            uuid,
            companyId,
            QueryUtil.ALL_POS,
            QueryUtil.ALL_POS,
            new StagedModelModifiedDateComparator<RepositoryEntry>());

    if (ListUtil.isEmpty(entries)) {
      return null;
    }

    return entries.get(0);
  }
  @Override
  public List<Menu> getPortletTitleMenus(PortletRequest portletRequest) {
    List<MenuItem> portletTitleMenuItems = getPortletTitleMenuItems(portletRequest);

    if (ListUtil.isEmpty(portletTitleMenuItems)) {
      return Collections.emptyList();
    }

    List<Menu> menus = new ArrayList<>();

    Menu menu = new Menu();

    menu.setDirection("down");
    menu.setExtended(false);
    menu.setIcon("../aui/plus-sign-2");
    menu.setMenuItems(portletTitleMenuItems);
    menu.setShowArrow(false);
    menu.setShowWhenSingleIcon(true);

    menus.add(menu);

    return menus;
  }