@Override
  protected void doReindex(Object obj) throws Exception {
    DLFileEntry dlFileEntry = (DLFileEntry) obj;

    DLFileVersion dlFileVersion = dlFileEntry.getFileVersion();

    if (!dlFileVersion.isApproved() && !dlFileVersion.isInTrash()) {
      return;
    }

    Document document = getDocument(dlFileEntry);

    if (document != null) {
      SearchEngineUtil.updateDocument(getSearchEngineId(), dlFileEntry.getCompanyId(), document);
    }
  }
  @Override
  protected Document doGetDocument(Object obj) throws Exception {
    DLFileEntry dlFileEntry = (DLFileEntry) obj;

    if (_log.isDebugEnabled()) {
      _log.debug("Indexing document " + dlFileEntry);
    }

    boolean indexContent = true;

    InputStream is = null;

    try {
      if (PropsValues.DL_FILE_INDEXING_MAX_SIZE == 0) {
        indexContent = false;
      } else if (PropsValues.DL_FILE_INDEXING_MAX_SIZE != -1) {
        if (dlFileEntry.getSize() > PropsValues.DL_FILE_INDEXING_MAX_SIZE) {

          indexContent = false;
        }
      }

      if (indexContent) {
        String[] ignoreExtensions =
            PrefsPropsUtil.getStringArray(
                PropsKeys.DL_FILE_INDEXING_IGNORE_EXTENSIONS, StringPool.COMMA);

        if (ArrayUtil.contains(ignoreExtensions, StringPool.PERIOD + dlFileEntry.getExtension())) {

          indexContent = false;
        }
      }

      if (indexContent) {
        is = dlFileEntry.getFileVersion().getContentStream(false);
      }
    } catch (Exception e) {
    }

    DLFileVersion dlFileVersion = dlFileEntry.getFileVersion();

    try {
      Document document = getBaseModelDocument(PORTLET_ID, dlFileEntry, dlFileVersion);

      if (indexContent) {
        if (is != null) {
          try {
            document.addFile(Field.CONTENT, is, dlFileEntry.getTitle());
          } catch (IOException ioe) {
            throw new SearchException("Cannot extract text from file" + dlFileEntry);
          }
        } else if (_log.isDebugEnabled()) {
          _log.debug("Document " + dlFileEntry + " does not have any content");
        }
      }

      document.addKeyword(Field.CLASS_TYPE_ID, dlFileEntry.getFileEntryTypeId());
      document.addText(Field.DESCRIPTION, dlFileEntry.getDescription());
      document.addKeyword(Field.FOLDER_ID, dlFileEntry.getFolderId());
      document.addKeyword(Field.HIDDEN, dlFileEntry.isInHiddenFolder());
      document.addText(Field.PROPERTIES, dlFileEntry.getLuceneProperties());
      document.addText(Field.TITLE, dlFileEntry.getTitle());

      document.addKeyword("dataRepositoryId", dlFileEntry.getDataRepositoryId());
      document.addKeyword("extension", dlFileEntry.getExtension());
      document.addKeyword("fileEntryTypeId", dlFileEntry.getFileEntryTypeId());
      document.addKeyword(
          "mimeType",
          StringUtil.replace(
              dlFileEntry.getMimeType(), CharPool.FORWARD_SLASH, CharPool.UNDERLINE));
      document.addKeyword("path", dlFileEntry.getTitle());
      document.addKeyword("readCount", dlFileEntry.getReadCount());
      document.addKeyword("size", dlFileEntry.getSize());

      ExpandoBridge expandoBridge =
          ExpandoBridgeFactoryUtil.getExpandoBridge(
              dlFileEntry.getCompanyId(),
              DLFileEntry.class.getName(),
              dlFileVersion.getFileVersionId());

      ExpandoBridgeIndexerUtil.addAttributes(document, expandoBridge);

      addFileEntryTypeAttributes(document, dlFileVersion);

      if (dlFileEntry.isInHiddenFolder()) {
        try {
          Repository repository =
              RepositoryLocalServiceUtil.getRepository(dlFileEntry.getRepositoryId());

          String portletId = repository.getPortletId();

          for (Indexer indexer : IndexerRegistryUtil.getIndexers()) {
            if (portletId.equals(indexer.getPortletId())) {
              indexer.addRelatedEntryFields(document, obj);
            }
          }
        } catch (Exception e) {
        }
      }

      if (!dlFileVersion.isInTrash() && dlFileVersion.isInTrashContainer()) {

        DLFolder folder = dlFileVersion.getTrashContainer();

        addTrashFields(
            document,
            DLFolder.class.getName(),
            folder.getFolderId(),
            null,
            null,
            DLFileEntryAssetRendererFactory.TYPE);

        document.addKeyword(Field.ROOT_ENTRY_CLASS_NAME, DLFolder.class.getName());
        document.addKeyword(Field.ROOT_ENTRY_CLASS_PK, folder.getFolderId());
        document.addKeyword(Field.STATUS, WorkflowConstants.STATUS_IN_TRASH);
      }

      if (_log.isDebugEnabled()) {
        _log.debug("Document " + dlFileEntry + " indexed successfully");
      }

      return document;
    } finally {
      if (is != null) {
        try {
          is.close();
        } catch (IOException ioe) {
        }
      }
    }
  }