@Override
  public List<Long> getSubcategoryIds(List<Long> categoryIds, long groupId, long categoryId) {

    List<MBCategory> categories = mbCategoryPersistence.filterFindByG_P(groupId, categoryId);

    for (MBCategory category : categories) {
      if (category.isInTrash()) {
        continue;
      }

      categoryIds.add(category.getCategoryId());

      getSubcategoryIds(categoryIds, category.getGroupId(), category.getCategoryId());
    }

    return categoryIds;
  }
  public static void addPortletBreadcrumbEntries(
      MBCategory category, HttpServletRequest request, RenderResponse renderResponse)
      throws Exception {

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

    String mvcRenderCommandName = ParamUtil.getString(request, "mvcRenderCommandName");

    PortletURL portletURL = renderResponse.createRenderURL();

    if (mvcRenderCommandName.equals("/message_boards/select_category")) {
      portletURL.setParameter("mvcRenderCommandName", "/message_boards/select_category");
      portletURL.setWindowState(LiferayWindowState.POP_UP);

      PortalUtil.addPortletBreadcrumbEntry(
          request, themeDisplay.translate("categories"), portletURL.toString());
    } else {
      portletURL.setParameter("mvcRenderCommandName", "/message_boards/view");
    }

    PortalUtil.addPortletBreadcrumbEntry(
        request, themeDisplay.translate("home"), portletURL.toString());

    if (category == null) {
      return;
    }

    if (!mvcRenderCommandName.equals("/message_boards/select_category")) {
      portletURL.setParameter("mvcRenderCommandName", "/message_boards/view_category");
    }

    List<MBCategory> ancestorCategories = category.getAncestors();

    Collections.reverse(ancestorCategories);

    for (MBCategory curCategory : ancestorCategories) {
      portletURL.setParameter("mbCategoryId", String.valueOf(curCategory.getCategoryId()));

      PortalUtil.addPortletBreadcrumbEntry(request, curCategory.getName(), portletURL.toString());
    }

    portletURL.setParameter("mbCategoryId", String.valueOf(category.getCategoryId()));

    PortalUtil.addPortletBreadcrumbEntry(request, category.getName(), portletURL.toString());
  }
  protected long getCategoryId(MBCategory category) {
    long categoryId = MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID;

    if (category != null) {
      categoryId = category.getCategoryId();
    }

    return categoryId;
  }
  @Override
  protected long addContainerModel(long userId, long containerModelId) throws Exception {

    ServiceContext serviceContext =
        ServiceContextTestUtil.getServiceContext(group.getGroupId(), userId);

    MBCategory category =
        MBCategoryServiceUtil.addCategory(
            userId,
            containerModelId,
            RandomTestUtil.randomString(),
            RandomTestUtil.randomString(),
            serviceContext);

    return category.getCategoryId();
  }
  @Override
  protected BaseModel<?> addBaseModelWithWorkflow(
      BaseModel<?> parentBaseModel,
      boolean approved,
      String keywords,
      ServiceContext serviceContext)
      throws Exception {

    MBCategory category = (MBCategory) parentBaseModel;

    return MBTestUtil.addMessageWithWorkflow(
        serviceContext.getUserId(),
        category.getGroupId(),
        category.getCategoryId(),
        RandomTestUtil.randomString(),
        keywords,
        approved,
        serviceContext);
  }
  @Override
  protected StagedModel addStagedModel(
      Group group, Map<String, List<StagedModel>> dependentStagedModelsMap) throws Exception {

    List<StagedModel> dependentStagedModels =
        dependentStagedModelsMap.get(MBCategory.class.getSimpleName());

    MBCategory category = (MBCategory) dependentStagedModels.get(0);

    ServiceContext serviceContext =
        ServiceContextTestUtil.getServiceContext(group.getGroupId(), TestPropsValues.getUserId());

    return MBCategoryServiceUtil.addCategory(
        TestPropsValues.getUserId(),
        category.getCategoryId(),
        RandomTestUtil.randomString(),
        StringPool.BLANK,
        serviceContext);
  }