private void _queueGeneration(FileVersion sourceFileVersion, FileVersion destinationFileVersion) {

    if (_fileVersionIds.contains(destinationFileVersion.getFileVersionId())) {

      return;
    }

    boolean generateImages = false;

    String extension = destinationFileVersion.getExtension();

    if (extension.equals("pdf")) {
      generateImages = true;
    } else if (DocumentConversionUtil.isEnabled()) {
      String[] conversions = DocumentConversionUtil.getConversions(extension);

      for (String conversion : conversions) {
        if (conversion.equals("pdf")) {
          generateImages = true;

          break;
        }
      }
    }

    if (generateImages) {
      _fileVersionIds.add(destinationFileVersion.getFileVersionId());

      sendGenerationMessage(
          DestinationNames.DOCUMENT_LIBRARY_PDF_PROCESSOR,
          sourceFileVersion,
          destinationFileVersion);
    }
  }
  private void _generateImagesPB(FileVersion fileVersion, InputStream inputStream)
      throws Exception {

    boolean generatePreview = _isGeneratePreview(fileVersion);
    boolean generateThumbnail = _isGenerateThumbnail(fileVersion);

    PDDocument pdDocument = null;

    try {
      pdDocument = PDDocument.load(inputStream);

      PDDocumentCatalog pdDocumentCatalog = pdDocument.getDocumentCatalog();

      List<PDPage> pdPages = pdDocumentCatalog.getAllPages();

      for (int i = 0; i < pdPages.size(); i++) {
        PDPage pdPage = pdPages.get(i);

        if (generateThumbnail && (i == 0)) {
          _generateImagesPB(
              fileVersion,
              pdPage,
              PropsValues.DL_FILE_ENTRY_THUMBNAIL_DPI,
              PropsValues.DL_FILE_ENTRY_THUMBNAIL_HEIGHT,
              PropsValues.DL_FILE_ENTRY_THUMBNAIL_WIDTH,
              true,
              0);

          if (_log.isInfoEnabled()) {
            _log.info("PDFBox generated a thumbnail for " + fileVersion.getFileVersionId());
          }
        }

        if (!generatePreview) {
          break;
        }

        _generateImagesPB(
            fileVersion,
            pdPage,
            PropsValues.DL_FILE_ENTRY_PREVIEW_DOCUMENT_DPI,
            PropsValues.DL_FILE_ENTRY_PREVIEW_DOCUMENT_HEIGHT,
            PropsValues.DL_FILE_ENTRY_PREVIEW_DOCUMENT_WIDTH,
            false,
            i + 1);
      }

      if (_log.isInfoEnabled() && generatePreview) {
        _log.info(
            "PDFBox generated "
                + getPreviewFileCount(fileVersion)
                + " preview pages for "
                + fileVersion.getFileVersionId());
      }
    } finally {
      if (pdDocument != null) {
        pdDocument.close();
      }
    }
  }
  public FileEntry moveFileEntryFromTrash(
      long userId, FileEntry fileEntry, long newFolderId, ServiceContext serviceContext)
      throws PortalException, SystemException {

    // File entry

    List<DLFileVersion> dlFileVersions =
        dlFileVersionLocalService.getFileVersions(
            fileEntry.getFileEntryId(), WorkflowConstants.STATUS_ANY);

    dlFileVersions = ListUtil.sort(dlFileVersions, new FileVersionVersionComparator());

    FileVersion fileVersion = new LiferayFileVersion(dlFileVersions.get(0));

    dlFileEntryLocalService.updateStatus(
        userId,
        fileVersion.getFileVersionId(),
        fileVersion.getStatus(),
        new HashMap<String, Serializable>(),
        serviceContext);

    // File rank

    dlFileRankLocalService.enableFileRanks(fileEntry.getFileEntryId());

    // App helper

    return dlAppService.moveFileEntry(fileEntry.getFileEntryId(), newFolderId, serviceContext);
  }
  protected String getBody(String className, long classPK, ServiceContext serviceContext)
      throws Exception {

    StringBundler sb = new StringBundler(11);

    sb.append("<div class=\"activity-body document\">");
    sb.append("<span class=\"document-thumbnail\"><img src=\"");

    FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(classPK);

    FileVersion fileVersion = fileEntry.getFileVersion();

    String thumbnailSrc =
        DLUtil.getThumbnailSrc(fileEntry, fileVersion, null, serviceContext.getThemeDisplay());

    sb.append(thumbnailSrc);
    sb.append("\"></span>");
    sb.append("<div class=\"document-container\"><div class=\"title\">");
    sb.append(getPageTitle(className, classPK, serviceContext));
    sb.append("</div><div class=\"version\">");
    sb.append(serviceContext.translate("version-x", fileVersion.getVersion()));
    sb.append("</div><div class=\"document-content\">");

    AssetRenderer assetRenderer = getAssetRenderer(className, classPK);

    sb.append(StringUtil.shorten(assetRenderer.getSummary(serviceContext.getLocale()), 200));

    sb.append("</div></div></div>");

    return sb.toString();
  }
예제 #5
0
  protected int getPreviewTempFileCount(FileVersion fileVersion, String type) {

    String tempFileId =
        DLUtil.getTempFileId(fileVersion.getFileEntryId(), fileVersion.getVersion());

    StringBundler sb = new StringBundler(5);

    sb.append(tempFileId);
    sb.append(StringPool.DASH);
    sb.append("(.*)");
    sb.append(StringPool.PERIOD);
    sb.append(type);

    File dir = new File(PREVIEW_TMP_PATH);

    File[] files = dir.listFiles(new FileFilter(sb.toString()));

    if (_log.isDebugEnabled()) {
      for (File file : files) {
        _log.debug("Preview page for " + tempFileId + " " + file);
      }
    }

    return files.length;
  }
  @Override
  public boolean isVisible(long classPK, int status) throws Exception {
    FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(classPK);

    FileVersion fileVersion = fileEntry.getFileVersion();

    return isVisible(fileVersion.getStatus(), status);
  }
예제 #7
0
 public void deleteFiles(FileVersion fileVersion, String thumbnailType) {
   deleteFiles(
       fileVersion.getCompanyId(),
       fileVersion.getGroupId(),
       fileVersion.getFileEntryId(),
       fileVersion.getFileVersionId(),
       thumbnailType);
 }
예제 #8
0
  protected static String getPathSegment(FileVersion fileVersion, boolean preview) {

    return getPathSegment(
        fileVersion.getGroupId(),
        fileVersion.getFileEntryId(),
        fileVersion.getFileVersionId(),
        preview);
  }
  public void restoreFileEntryFromTrash(long userId, FileEntry fileEntry)
      throws PortalException, SystemException {

    // File entry

    DLFileEntry dlFileEntry = (DLFileEntry) fileEntry.getModel();

    dlFileEntry.setTitle(DLAppUtil.stripTrashNamespace(dlFileEntry.getTitle()));

    dlFileEntryPersistence.update(dlFileEntry, false);

    FileVersion fileVersion = new LiferayFileVersion(dlFileEntry.getLatestFileVersion(true));

    TrashEntry trashEntry =
        trashEntryLocalService.getEntry(
            DLFileEntryConstants.getClassName(), fileEntry.getFileEntryId());

    // File version

    Map<String, Serializable> workflowContext = new HashMap<String, Serializable>();

    List<TrashVersion> trashVersions = trashEntryLocalService.getVersions(trashEntry.getEntryId());

    workflowContext.put("trashVersions", (Serializable) trashVersions);

    dlFileEntryLocalService.updateStatus(
        userId,
        fileVersion.getFileVersionId(),
        trashEntry.getStatus(),
        workflowContext,
        new ServiceContext());

    // File shortcut

    dlFileShortcutLocalService.enableFileShortcuts(fileEntry.getFileEntryId());

    // File rank

    dlFileRankLocalService.enableFileRanks(fileEntry.getFileEntryId());

    // Social

    socialActivityCounterLocalService.enableActivityCounters(
        DLFileEntryConstants.getClassName(), fileEntry.getFileEntryId());

    socialActivityLocalService.addActivity(
        userId,
        fileEntry.getGroupId(),
        DLFileEntryConstants.getClassName(),
        fileEntry.getFileEntryId(),
        SocialActivityConstants.TYPE_RESTORE_FROM_TRASH,
        StringPool.BLANK,
        0);

    // Trash

    trashEntryLocalService.deleteEntry(trashEntry.getClassName(), trashEntry.getClassPK());
  }
예제 #10
0
  protected void copyThumbnails(FileVersion sourceFileVersion, FileVersion destinationFileVersion) {

    try {
      if (isThumbnailEnabled(THUMBNAIL_INDEX_DEFAULT)) {
        if (hasThumbnail(sourceFileVersion, THUMBNAIL_INDEX_DEFAULT)
            && !hasThumbnail(destinationFileVersion, THUMBNAIL_INDEX_DEFAULT)) {

          InputStream is = doGetThumbnailAsStream(sourceFileVersion, THUMBNAIL_INDEX_DEFAULT);

          String thumbnailFilePath =
              getThumbnailFilePath(
                  destinationFileVersion,
                  getThumbnailType(destinationFileVersion),
                  THUMBNAIL_INDEX_DEFAULT);

          addFileToStore(
              destinationFileVersion.getCompanyId(), THUMBNAIL_PATH, thumbnailFilePath, is);
        }
      }

      if (isThumbnailEnabled(THUMBNAIL_INDEX_CUSTOM_1)) {
        if (hasThumbnail(sourceFileVersion, THUMBNAIL_INDEX_CUSTOM_1)
            && !hasThumbnail(destinationFileVersion, THUMBNAIL_INDEX_CUSTOM_1)) {

          InputStream is = doGetThumbnailAsStream(sourceFileVersion, THUMBNAIL_INDEX_CUSTOM_1);

          String thumbnailFilePath =
              getThumbnailFilePath(
                  destinationFileVersion,
                  getThumbnailType(destinationFileVersion),
                  THUMBNAIL_INDEX_CUSTOM_1);

          addFileToStore(
              destinationFileVersion.getCompanyId(), THUMBNAIL_PATH, thumbnailFilePath, is);
        }
      }

      if (isThumbnailEnabled(THUMBNAIL_INDEX_CUSTOM_2)) {
        if (hasThumbnail(sourceFileVersion, THUMBNAIL_INDEX_CUSTOM_2)
            && !hasThumbnail(destinationFileVersion, THUMBNAIL_INDEX_CUSTOM_2)) {

          InputStream is = doGetThumbnailAsStream(sourceFileVersion, THUMBNAIL_INDEX_CUSTOM_2);

          String thumbnailFilePath =
              getThumbnailFilePath(
                  destinationFileVersion,
                  getThumbnailType(destinationFileVersion),
                  THUMBNAIL_INDEX_CUSTOM_2);

          addFileToStore(
              destinationFileVersion.getCompanyId(), THUMBNAIL_PATH, thumbnailFilePath, is);
        }
      }
    } catch (Exception e) {
      _log.error(e, e);
    }
  }
예제 #11
0
  public void copy(FileVersion sourceFileVersion, FileVersion destinationFileVersion) {

    if (sourceFileVersion.getFileVersionId() == destinationFileVersion.getFileVersionId()) {

      return;
    }

    copyPreviews(sourceFileVersion, destinationFileVersion);
    copyThumbnails(sourceFileVersion, destinationFileVersion);
  }
  private void _generateImagesPB(
      FileVersion fileVersion,
      PDPage pdPage,
      int dpi,
      int height,
      int width,
      boolean thumbnail,
      int index)
      throws Exception {

    // Generate images

    RenderedImage renderedImage =
        pdPage.convertToImage(BufferedImage.TYPE_INT_RGB, PropsValues.DL_FILE_ENTRY_THUMBNAIL_DPI);

    if (height != 0) {
      renderedImage = ImageProcessorUtil.scale(renderedImage, width, height);
    } else {
      renderedImage = ImageProcessorUtil.scale(renderedImage, width);
    }

    // Store images

    String tempFileId =
        DLUtil.getTempFileId(fileVersion.getFileEntryId(), fileVersion.getVersion());

    File thumbnailTempFile = null;

    try {
      if (thumbnail) {
        thumbnailTempFile = getThumbnailTempFile(tempFileId);

        thumbnailTempFile.createNewFile();

        ImageIO.write(renderedImage, THUMBNAIL_TYPE, new FileOutputStream(thumbnailTempFile));

        addFileToStore(
            fileVersion.getCompanyId(), THUMBNAIL_PATH,
            getThumbnailFilePath(fileVersion), thumbnailTempFile);
      } else {
        thumbnailTempFile = getPreviewTempFile(tempFileId, index);

        thumbnailTempFile.createNewFile();

        ImageIO.write(renderedImage, PREVIEW_TYPE, new FileOutputStream(thumbnailTempFile));

        addFileToStore(
            fileVersion.getCompanyId(), PREVIEW_PATH,
            getPreviewFilePath(fileVersion, index), thumbnailTempFile);
      }
    } finally {
      FileUtil.delete(thumbnailTempFile);
    }
  }
예제 #13
0
  public void trigger(FileVersion sourceFileVersion, FileVersion destinationFileVersion) {

    if (getFileVersionIds().contains(destinationFileVersion.getFileVersionId())) {

      String processIdentity = Long.toString(destinationFileVersion.getFileVersionId());

      destroyProcess(processIdentity);

      getFileVersionIds().remove(destinationFileVersion.getFileVersionId());
    }
  }
  @Override
  public InputStream getContentAsStream() throws WebDAVException {
    FileEntry fileEntry = getModel();

    try {
      FileVersion fileVersion = fileEntry.getLatestFileVersion();

      return fileVersion.getContentStream(true);
    } catch (Exception e) {
      throw new WebDAVException(e);
    }
  }
  @Override
  public String getContentType() {
    FileEntry fileEntry = getModel();

    try {
      FileVersion fileVersion = fileEntry.getLatestFileVersion();

      return fileVersion.getMimeType();
    } catch (Exception e) {
      return fileEntry.getMimeType();
    }
  }
  @Override
  public long getSize() {
    FileEntry fileEntry = getModel();

    try {
      FileVersion fileVersion = fileEntry.getLatestFileVersion();

      return fileVersion.getSize();
    } catch (Exception e) {
      return fileEntry.getSize();
    }
  }
  protected void compareVersions(RenderRequest renderRequest) throws Exception {

    long fileEntryId = ParamUtil.getLong(renderRequest, "fileEntryId");

    String sourceVersion = ParamUtil.getString(renderRequest, "sourceVersion");
    String targetVersion = ParamUtil.getString(renderRequest, "targetVersion");

    FileEntry fileEntry = DLAppServiceUtil.getFileEntry(fileEntryId);

    String extension = fileEntry.getExtension();

    FileVersion sourceFileVersion = fileEntry.getFileVersion(sourceVersion);

    String sourceTitle = sourceFileVersion.getTitle();

    FileVersion targetFileVersion = fileEntry.getFileVersion(targetVersion);

    String targetTitle = targetFileVersion.getTitle();

    InputStream sourceIs = fileEntry.getContentStream(sourceVersion);
    InputStream targetIs = fileEntry.getContentStream(targetVersion);

    if (extension.equals("htm") || extension.equals("html") || extension.equals("xml")) {

      String escapedSource = HtmlUtil.escape(StringUtil.read(sourceIs));
      String escapedTarget = HtmlUtil.escape(StringUtil.read(targetIs));

      sourceIs = new UnsyncByteArrayInputStream(escapedSource.getBytes(StringPool.UTF8));
      targetIs = new UnsyncByteArrayInputStream(escapedTarget.getBytes(StringPool.UTF8));
    }

    if (DocumentConversionUtil.isEnabled()
        && DocumentConversionUtil.isConvertBeforeCompare(extension)) {

      String sourceTempFileId = DLUtil.getTempFileId(fileEntryId, sourceVersion);
      String targetTempFileId = DLUtil.getTempFileId(fileEntryId, targetVersion);

      sourceIs =
          new FileInputStream(
              DocumentConversionUtil.convert(sourceTempFileId, sourceIs, extension, "txt"));
      targetIs =
          new FileInputStream(
              DocumentConversionUtil.convert(targetTempFileId, targetIs, extension, "txt"));
    }

    List<DiffResult>[] diffResults =
        DiffUtil.diff(new InputStreamReader(sourceIs), new InputStreamReader(targetIs));

    renderRequest.setAttribute(WebKeys.SOURCE_NAME, sourceTitle + StringPool.SPACE + sourceVersion);
    renderRequest.setAttribute(WebKeys.TARGET_NAME, targetTitle + StringPool.SPACE + targetVersion);
    renderRequest.setAttribute(WebKeys.DIFF_RESULTS, diffResults);
  }
  protected void exportMetaData(
      PortletDataContext portletDataContext, Element fileEntryElement, FileEntry fileEntry)
      throws Exception {

    LiferayFileEntry liferayFileEntry = (LiferayFileEntry) fileEntry;

    DLFileEntry dlFileEntry = liferayFileEntry.getDLFileEntry();

    long fileEntryTypeId = dlFileEntry.getFileEntryTypeId();

    DLFileEntryType dlFileEntryType =
        DLFileEntryTypeLocalServiceUtil.fetchFileEntryType(fileEntryTypeId);

    if ((dlFileEntryType == null) || !dlFileEntryType.isExportable()) {
      return;
    }

    StagedModelDataHandlerUtil.exportReferenceStagedModel(
        portletDataContext, fileEntry, dlFileEntryType, PortletDataContext.REFERENCE_TYPE_STRONG);

    List<DDMStructure> ddmStructures = dlFileEntryType.getDDMStructures();

    for (DDMStructure ddmStructure : ddmStructures) {
      FileVersion fileVersion = fileEntry.getFileVersion();

      DLFileEntryMetadata dlFileEntryMetadata =
          DLFileEntryMetadataLocalServiceUtil.fetchFileEntryMetadata(
              ddmStructure.getStructureId(), fileVersion.getFileVersionId());

      if (dlFileEntryMetadata == null) {
        continue;
      }

      Element structureFields = fileEntryElement.addElement("structure-fields");

      String path =
          ExportImportPathUtil.getModelPath(
              ddmStructure, String.valueOf(dlFileEntryMetadata.getDDMStorageId()));

      structureFields.addAttribute("path", path);

      structureFields.addAttribute("structureUuid", ddmStructure.getUuid());

      DDMFormValues ddmFormValues =
          StorageEngineUtil.getDDMFormValues(dlFileEntryMetadata.getDDMStorageId());

      portletDataContext.addZipEntry(path, ddmFormValues);
    }
  }
  protected void updateThumbnails(long fileEntryId) throws Exception {
    Connection con = null;
    PreparedStatement ps = null;
    ResultSet rs = null;

    try {
      con = DataAccess.getUpgradeOptimizedConnection();

      ps =
          con.prepareStatement(
              "select fileVersionId, userId, extension, mimeType, version "
                  + "from DLFileVersion where fileEntryId = "
                  + fileEntryId
                  + " order by version asc");

      rs = ps.executeQuery();

      while (rs.next()) {
        long fileVersionId = rs.getLong("fileVersionId");
        long userId = rs.getLong("userId");
        String extension = rs.getString("extension");
        String mimeType = rs.getString("mimeType");
        String version = rs.getString("version");

        if (_imageMimeTypes.contains(mimeType)) {
          DLFileVersion dlFileVersion = new DLFileVersionImpl();

          dlFileVersion.setFileVersionId(fileVersionId);
          dlFileVersion.setUserId(userId);
          dlFileVersion.setFileEntryId(fileEntryId);
          dlFileVersion.setExtension(extension);
          dlFileVersion.setMimeType(mimeType);
          dlFileVersion.setVersion(version);

          FileVersion fileVersion = new LiferayFileVersion(dlFileVersion);

          try {
            ImageProcessorUtil.generateImages(null, fileVersion);
          } catch (Exception e) {
            if (_log.isWarnEnabled()) {
              _log.warn("Unable to generate thumbnails for " + fileVersion.getFileVersionId(), e);
            }
          }
        }
      }
    } finally {
      DataAccess.cleanUp(con, ps, rs);
    }
  }
예제 #20
0
  private void _queueGeneration(FileVersion sourceFileVersion, FileVersion destinationFileVersion) {

    if (_fileVersionIds.contains(destinationFileVersion.getFileVersionId())
        || !isSupported(destinationFileVersion)) {

      return;
    }

    _fileVersionIds.add(destinationFileVersion.getFileVersionId());

    sendGenerationMessage(
        DestinationNames.DOCUMENT_LIBRARY_VIDEO_PROCESSOR,
        sourceFileVersion,
        destinationFileVersion);
  }
예제 #21
0
  /** @deprecated As of 6.2.0, replaced by {@link CMISFileVersion#getUserId()} */
  @Deprecated
  @Override
  public long getVersionUserId() {
    long versionUserId = 0;

    try {
      FileVersion fileVersion = getFileVersion();

      versionUserId = fileVersion.getUserId();
    } catch (Exception e) {
      _log.error(e, e);
    }

    return versionUserId;
  }
예제 #22
0
  /** @deprecated As of 6.2.0, replaced by {@link CMISFileVersion#getUserUuid()} */
  @Deprecated
  @Override
  public String getVersionUserUuid() {
    String versionUserUuid = StringPool.BLANK;

    try {
      FileVersion fileVersion = getFileVersion();

      versionUserUuid = fileVersion.getUserUuid();
    } catch (Exception e) {
      _log.error(e, e);
    }

    return versionUserUuid;
  }
예제 #23
0
  public boolean isSupported(FileVersion fileVersion) {
    if (fileVersion == null) {
      return false;
    }

    return isSupported(fileVersion.getMimeType());
  }
  @Override
  protected boolean hasPreview(FileVersion fileVersion, String type) throws Exception {

    String previewFilePath = getPreviewFilePath(fileVersion, 1);

    return DLStoreUtil.hasFile(fileVersion.getCompanyId(), REPOSITORY_ID, previewFilePath);
  }
  public void cancelCheckOut(
      long userId,
      FileEntry fileEntry,
      FileVersion sourceFileVersion,
      FileVersion destinationFileVersion,
      FileVersion draftFileVersion,
      ServiceContext serviceContext)
      throws PortalException, SystemException {

    updateFileEntry(userId, fileEntry, sourceFileVersion, destinationFileVersion, serviceContext);

    if (draftFileVersion == null) {
      return;
    }

    AssetEntry draftAssetEntry = null;

    try {
      draftAssetEntry =
          assetEntryLocalService.getEntry(
              DLFileEntryConstants.getClassName(), draftFileVersion.getPrimaryKey());

      assetEntryLocalService.deleteEntry(draftAssetEntry.getEntryId());
    } catch (NoSuchEntryException nsee) {
    }
  }
  @Override
  public IGViewFileVersionDisplayContext getIGViewFileVersionDisplayContext(
      IGViewFileVersionDisplayContext parentIGViewFileVersionDisplayContext,
      HttpServletRequest request,
      HttpServletResponse response,
      FileVersion fileVersion) {

    GoogleDocsMetadataHelper googleDocsMetadataHelper =
        new GoogleDocsMetadataHelper(
            _ddmStructureLocalService,
            (DLFileVersion) fileVersion.getModel(),
            _dlFileEntryMetadataLocalService,
            _storageEngine);

    if (googleDocsMetadataHelper.isGoogleDocs()) {
      return new GoogleDocsIGViewFileVersionDisplayContext(
          parentIGViewFileVersionDisplayContext,
          request,
          response,
          fileVersion,
          googleDocsMetadataHelper);
    }

    return parentIGViewFileVersionDisplayContext;
  }
예제 #27
0
  protected long doGetPreviewFileSize(FileVersion fileVersion, int index, String type)
      throws PortalException, SystemException {

    return DLStoreUtil.getFileSize(
        fileVersion.getCompanyId(),
        CompanyConstants.SYSTEM,
        getPreviewFilePath(fileVersion, index, type));
  }
예제 #28
0
  private void _generateVideoXuggler(
      FileVersion fileVersion, File sourceFile, File[] destinationFiles) {

    try {
      for (int i = 0; i < destinationFiles.length; i++) {
        _generateVideoXuggler(fileVersion, sourceFile, destinationFiles[i], _PREVIEW_TYPES[i]);
      }
    } catch (CancellationException ce) {
      if (_log.isInfoEnabled()) {
        _log.info(
            "Cancellation received for "
                + fileVersion.getFileVersionId()
                + " "
                + fileVersion.getTitle());
      }
    } catch (Exception e) {
      _log.error(e, e);
    }
  }
예제 #29
0
  protected long doGetThumbnailFileSize(FileVersion fileVersion, int index)
      throws PortalException, SystemException {

    String type = getThumbnailType(fileVersion);

    return DLStoreUtil.getFileSize(
        fileVersion.getCompanyId(),
        CompanyConstants.SYSTEM,
        getThumbnailFilePath(fileVersion, type, index));
  }
예제 #30
0
  private void _generateImagesGS(FileVersion fileVersion, File file) throws Exception {

    if (_isGeneratePreview(fileVersion)) {
      StopWatch stopWatch = null;

      if (_log.isInfoEnabled()) {
        stopWatch = new StopWatch();

        stopWatch.start();
      }

      _generateImagesGS(fileVersion, file, false);

      if (_log.isInfoEnabled()) {
        int previewFileCount = getPreviewFileCount(fileVersion);

        _log.info(
            "Ghostscript generated "
                + previewFileCount
                + " preview pages for "
                + fileVersion.getTitle()
                + " in "
                + stopWatch);
      }
    }

    if (_isGenerateThumbnail(fileVersion)) {
      StopWatch stopWatch = null;

      if (_log.isInfoEnabled()) {
        stopWatch = new StopWatch();

        stopWatch.start();
      }

      _generateImagesGS(fileVersion, file, true);

      if (_log.isInfoEnabled()) {
        _log.info(
            "Ghostscript generated a thumbnail for " + fileVersion.getTitle() + " in " + stopWatch);
      }
    }
  }