protected void reindexFolders(long companyId) throws Exception {
    DynamicQuery dynamicQuery =
        DynamicQueryFactoryUtil.forClass(
            BookmarksFolder.class, PortalClassLoaderUtil.getClassLoader());

    Projection minFolderIdProjection = ProjectionFactoryUtil.min("folderId");
    Projection maxFolderIdProjection = ProjectionFactoryUtil.max("folderId");

    ProjectionList projectionList = ProjectionFactoryUtil.projectionList();

    projectionList.add(minFolderIdProjection);
    projectionList.add(maxFolderIdProjection);

    dynamicQuery.setProjection(projectionList);

    addReindexCriteria(dynamicQuery, companyId);

    List<Object[]> results = BookmarksFolderLocalServiceUtil.dynamicQuery(dynamicQuery);

    Object[] minAndMaxFolderIds = results.get(0);

    if ((minAndMaxFolderIds[0] == null) || (minAndMaxFolderIds[1] == null)) {

      return;
    }

    long minFolderId = (Long) minAndMaxFolderIds[0];
    long maxFolderId = (Long) minAndMaxFolderIds[1];

    long startFolderId = minFolderId;
    long endFolderId = startFolderId + DEFAULT_INTERVAL;

    while (startFolderId <= maxFolderId) {
      reindexFolders(companyId, startFolderId, endFolderId);

      startFolderId = endFolderId;
      endFolderId += DEFAULT_INTERVAL;
    }
  }
  protected void reindexArticles(long companyId) throws Exception {
    DynamicQuery dynamicQuery =
        DynamicQueryFactoryUtil.forClass(
            JournalArticle.class, PACLClassLoaderUtil.getPortalClassLoader());

    Projection minIdProjection = ProjectionFactoryUtil.min("id");
    Projection maxIdProjection = ProjectionFactoryUtil.max("id");

    ProjectionList projectionList = ProjectionFactoryUtil.projectionList();

    projectionList.add(minIdProjection);
    projectionList.add(maxIdProjection);

    dynamicQuery.setProjection(projectionList);

    addReindexCriteria(dynamicQuery, companyId, WorkflowConstants.STATUS_APPROVED);

    List<Object[]> results = JournalArticleLocalServiceUtil.dynamicQuery(dynamicQuery);

    Object[] minAndMaxIds = results.get(0);

    if ((minAndMaxIds[0] == null) || (minAndMaxIds[1] == null)) {
      return;
    }

    long minId = (Long) minAndMaxIds[0];
    long maxId = (Long) minAndMaxIds[1];

    long startId = minId;
    long endId = startId + DEFAULT_INTERVAL;

    while (startId <= maxId) {
      reindexArticles(companyId, startId, endId);

      startId = endId;
      endId += DEFAULT_INTERVAL;
    }
  }