Example usage for com.liferay.portal.kernel.repository.model FileVersion getTitle

List of usage examples for com.liferay.portal.kernel.repository.model FileVersion getTitle

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.repository.model FileVersion getTitle.

Prototype

public String getTitle();

Source Link

Usage

From source file:com.liferay.document.library.internal.exportimport.data.handler.test.FileEntryStagedModelDataHandlerTest.java

License:Open Source License

@Override
protected void validateImportedStagedModel(StagedModel stagedModel, StagedModel importedStagedModel)
        throws Exception {

    Assert.assertTrue(/*  w  w w .  jav a  2 s. c  o m*/
            String.valueOf(stagedModel.getCreateDate()) + StringPool.SPACE
                    + importedStagedModel.getCreateDate(),
            DateUtil.equals(stagedModel.getCreateDate(), importedStagedModel.getCreateDate()));

    Assert.assertEquals(stagedModel.getUuid(), importedStagedModel.getUuid());

    FileEntry fileEntry = (FileEntry) stagedModel;
    FileEntry importedFileEntry = (FileEntry) importedStagedModel;

    Assert.assertEquals(fileEntry.getFileName(), importedFileEntry.getFileName());
    Assert.assertEquals(fileEntry.getExtension(), importedFileEntry.getExtension());
    Assert.assertEquals(fileEntry.getMimeType(), importedFileEntry.getMimeType());
    Assert.assertEquals(fileEntry.getTitle(), importedFileEntry.getTitle());
    Assert.assertEquals(fileEntry.getDescription(), importedFileEntry.getDescription());
    Assert.assertEquals(fileEntry.getSize(), importedFileEntry.getSize());

    FileVersion latestFileVersion = fileEntry.getLatestFileVersion();
    FileVersion importedLatestFileVersion = importedFileEntry.getLatestFileVersion();

    Assert.assertEquals(latestFileVersion.getUuid(), importedLatestFileVersion.getUuid());
    Assert.assertEquals(latestFileVersion.getFileName(), importedLatestFileVersion.getFileName());
    Assert.assertEquals(latestFileVersion.getExtension(), importedLatestFileVersion.getExtension());
    Assert.assertEquals(latestFileVersion.getMimeType(), importedLatestFileVersion.getMimeType());
    Assert.assertEquals(latestFileVersion.getTitle(), importedLatestFileVersion.getTitle());
    Assert.assertEquals(latestFileVersion.getDescription(), importedLatestFileVersion.getDescription());
    Assert.assertEquals(latestFileVersion.getSize(), importedLatestFileVersion.getSize());
    Assert.assertEquals(latestFileVersion.getStatus(), importedLatestFileVersion.getStatus());
}

From source file:com.liferay.document.library.internal.service.SubscriptionDLAppHelperLocalServiceWrapper.java

License:Open Source License

protected void notifySubscribers(long userId, FileVersion fileVersion, String entryURL,
        ServiceContext serviceContext) throws PortalException {

    if (!fileVersion.isApproved() || Validator.isNull(entryURL)) {
        return;//from w w w  .j av  a  2s.  c  o  m
    }

    DLGroupServiceSettings dlGroupServiceSettings = DLGroupServiceSettings
            .getInstance(fileVersion.getGroupId());

    boolean commandUpdate = false;

    if (serviceContext.isCommandUpdate() || Constants.CHECKIN.equals(serviceContext.getCommand())) {

        commandUpdate = true;
    }

    if (serviceContext.isCommandAdd() && dlGroupServiceSettings.isEmailFileEntryAddedEnabled()) {
    } else if (commandUpdate && dlGroupServiceSettings.isEmailFileEntryUpdatedEnabled()) {
    } else {
        return;
    }

    String entryTitle = fileVersion.getTitle();

    String fromName = dlGroupServiceSettings.getEmailFromName();
    String fromAddress = dlGroupServiceSettings.getEmailFromAddress();

    LocalizedValuesMap subjectLocalizedValuesMap = null;
    LocalizedValuesMap bodyLocalizedValuesMap = null;

    if (commandUpdate) {
        subjectLocalizedValuesMap = dlGroupServiceSettings.getEmailFileEntryUpdatedSubject();
        bodyLocalizedValuesMap = dlGroupServiceSettings.getEmailFileEntryUpdatedBody();
    } else {
        subjectLocalizedValuesMap = dlGroupServiceSettings.getEmailFileEntryAddedSubject();
        bodyLocalizedValuesMap = dlGroupServiceSettings.getEmailFileEntryAddedBody();
    }

    FileEntry fileEntry = fileVersion.getFileEntry();

    Folder folder = null;

    long folderId = fileEntry.getFolderId();

    if (folderId != DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
        folder = _dlAppLocalService.getFolder(folderId);
    }

    SubscriptionSender subscriptionSender = new GroupSubscriptionCheckSubscriptionSender(
            DLPermission.RESOURCE_NAME);

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

    DLFileEntryType dlFileEntryType = _dlFileEntryTypeLocalService
            .getDLFileEntryType(dlFileEntry.getFileEntryTypeId());

    subscriptionSender.setClassPK(fileVersion.getFileEntryId());
    subscriptionSender.setClassName(DLFileEntryConstants.getClassName());
    subscriptionSender.setCompanyId(fileVersion.getCompanyId());

    if (folder != null) {
        subscriptionSender.setContextAttribute("[$FOLDER_NAME$]", folder.getName(), true);
    } else {
        subscriptionSender.setLocalizedContextAttribute("[$FOLDER_NAME$]",
                new EscapableLocalizableFunction(locale -> LanguageUtil.get(locale, "home")));
    }

    subscriptionSender.setContextAttributes("[$DOCUMENT_STATUS_BY_USER_NAME$]",
            fileVersion.getStatusByUserName(), "[$DOCUMENT_TITLE$]", entryTitle, "[$DOCUMENT_URL$]", entryURL);
    subscriptionSender.setContextCreatorUserPrefix("DOCUMENT");
    subscriptionSender.setCreatorUserId(fileVersion.getUserId());
    subscriptionSender.setCurrentUserId(userId);
    subscriptionSender.setEntryTitle(entryTitle);
    subscriptionSender.setEntryURL(entryURL);
    subscriptionSender.setFrom(fromAddress, fromName);
    subscriptionSender.setHtmlFormat(true);
    subscriptionSender.setLocalizedBodyMap(LocalizationUtil.getMap(bodyLocalizedValuesMap));
    subscriptionSender.setLocalizedContextAttribute("[$DOCUMENT_TYPE$]",
            new EscapableLocalizableFunction(locale -> dlFileEntryType.getName(locale)));
    subscriptionSender.setLocalizedSubjectMap(LocalizationUtil.getMap(subjectLocalizedValuesMap));
    subscriptionSender.setMailId("file_entry", fileVersion.getFileEntryId());

    int notificationType = UserNotificationDefinition.NOTIFICATION_TYPE_ADD_ENTRY;

    if (commandUpdate) {
        notificationType = UserNotificationDefinition.NOTIFICATION_TYPE_UPDATE_ENTRY;
    }

    subscriptionSender.setNotificationType(notificationType);

    String portletId = PortletProviderUtil.getPortletId(FileEntry.class.getName(), PortletProvider.Action.VIEW);

    subscriptionSender.setPortletId(portletId);

    subscriptionSender.setReplyToAddress(fromAddress);
    subscriptionSender.setScopeGroupId(fileVersion.getGroupId());
    subscriptionSender.setServiceContext(serviceContext);

    subscriptionSender.addPersistedSubscribers(DLFolder.class.getName(), fileVersion.getGroupId());

    if (folder != null) {
        subscriptionSender.addPersistedSubscribers(DLFolder.class.getName(), folder.getFolderId());

        for (Long ancestorFolderId : folder.getAncestorFolderIds()) {
            subscriptionSender.addPersistedSubscribers(DLFolder.class.getName(), ancestorFolderId);
        }
    }

    if (dlFileEntryType.getFileEntryTypeId() == DLFileEntryTypeConstants.FILE_ENTRY_TYPE_ID_BASIC_DOCUMENT) {

        subscriptionSender.addPersistedSubscribers(DLFileEntryType.class.getName(), fileVersion.getGroupId());
    } else {
        subscriptionSender.addPersistedSubscribers(DLFileEntryType.class.getName(),
                dlFileEntryType.getFileEntryTypeId());
    }

    subscriptionSender.addPersistedSubscribers(DLFileEntry.class.getName(), fileEntry.getFileEntryId());

    subscriptionSender.flushNotificationsAsync();
}

From source file:com.liferay.document.library.web.internal.portlet.action.CompareVersionsMVCRenderCommand.java

License:Open Source License

protected void compareVersions(RenderRequest renderRequest) throws Exception {

    long sourceFileVersionId = ParamUtil.getLong(renderRequest, "sourceFileVersionId");
    long targetFileVersionId = ParamUtil.getLong(renderRequest, "targetFileVersionId");

    FileVersion sourceFileVersion = _dlAppService.getFileVersion(sourceFileVersionId);

    InputStream sourceIs = sourceFileVersion.getContentStream(false);

    String sourceExtension = sourceFileVersion.getExtension();

    if (sourceExtension.equals("css") || sourceExtension.equals("htm") || sourceExtension.equals("html")
            || sourceExtension.equals("js") || sourceExtension.equals("txt") || sourceExtension.equals("xml")) {

        String sourceContent = HtmlUtil.escape(StringUtil.read(sourceIs));

        sourceIs = new UnsyncByteArrayInputStream(sourceContent.getBytes(StringPool.UTF8));
    }/*from  www.ja v a  2 s  .  c om*/

    FileVersion targetFileVersion = _dlAppLocalService.getFileVersion(targetFileVersionId);

    InputStream targetIs = targetFileVersion.getContentStream(false);

    String targetExtension = targetFileVersion.getExtension();

    if (targetExtension.equals("css") || targetExtension.equals("htm") || targetExtension.equals("html")
            || targetExtension.equals("js") || targetExtension.equals("txt") || targetExtension.equals("xml")) {

        String targetContent = HtmlUtil.escape(StringUtil.read(targetIs));

        targetIs = new UnsyncByteArrayInputStream(targetContent.getBytes(StringPool.UTF8));
    }

    if (DocumentConversionUtil.isEnabled()) {
        if (DocumentConversionUtil.isConvertBeforeCompare(sourceExtension)) {

            String sourceTempFileId = DLUtil.getTempFileId(sourceFileVersion.getFileEntryId(),
                    sourceFileVersion.getVersion());

            sourceIs = new FileInputStream(
                    DocumentConversionUtil.convert(sourceTempFileId, sourceIs, sourceExtension, "txt"));
        }

        if (DocumentConversionUtil.isConvertBeforeCompare(targetExtension)) {

            String targetTempFileId = DLUtil.getTempFileId(targetFileVersion.getFileEntryId(),
                    targetFileVersion.getVersion());

            targetIs = new FileInputStream(
                    DocumentConversionUtil.convert(targetTempFileId, targetIs, targetExtension, "txt"));
        }
    }

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

    renderRequest.setAttribute(WebKeys.DIFF_RESULTS, diffResults);

    renderRequest.setAttribute(WebKeys.SOURCE_NAME,
            sourceFileVersion.getTitle() + StringPool.SPACE + sourceFileVersion.getVersion());
    renderRequest.setAttribute(WebKeys.TARGET_NAME,
            targetFileVersion.getTitle() + StringPool.SPACE + targetFileVersion.getVersion());
}

From source file:com.liferay.document.library.web.internal.portlet.action.GetFileActionHelper.java

License:Open Source License

protected void getFile(long fileEntryId, long folderId, String name, String title, String version,
        long fileShortcutId, String uuid, long groupId, String targetExtension, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    if (name.startsWith("DLFE-")) {
        name = name.substring(5);/*from  w w  w .j a v a  2 s.  co  m*/
    }

    name = FileUtil.stripExtension(name);

    FileEntry fileEntry = null;

    if (Validator.isNotNull(uuid) && (groupId > 0)) {
        fileEntry = DLAppServiceUtil.getFileEntryByUuidAndGroupId(uuid, groupId);

        folderId = fileEntry.getFolderId();
    }

    if (fileEntryId > 0) {
        fileEntry = DLAppServiceUtil.getFileEntry(fileEntryId);
    } else if (fileShortcutId <= 0) {
        if (Validator.isNotNull(title)) {
            fileEntry = DLAppServiceUtil.getFileEntry(groupId, folderId, title);
        } else if (Validator.isNotNull(name)) {
            DLFileEntry dlFileEntry = DLFileEntryLocalServiceUtil.fetchFileEntryByName(groupId, folderId, name);

            if (dlFileEntry == null) {

                // LPS-30374

                List<DLFileEntry> dlFileEntries = DLFileEntryLocalServiceUtil.getFileEntries(folderId, name);

                if (!dlFileEntries.isEmpty()) {
                    dlFileEntry = dlFileEntries.get(0);
                }
            }

            if (dlFileEntry != null) {
                ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

                PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

                DLFileEntryPermission.check(permissionChecker, dlFileEntry, ActionKeys.VIEW);

                fileEntry = new LiferayFileEntry(dlFileEntry);
            }
        }
    } else {
        FileShortcut fileShortcut = DLAppServiceUtil.getFileShortcut(fileShortcutId);

        fileEntryId = fileShortcut.getToFileEntryId();

        fileEntry = DLAppServiceUtil.getFileEntry(fileEntryId);
    }

    if (Validator.isNull(version)) {
        if ((fileEntry != null) && Validator.isNotNull(fileEntry.getVersion())) {

            version = fileEntry.getVersion();
        } else {
            throw new NoSuchFileEntryException("{fileEntryId=" + fileEntryId + "}");
        }
    }

    FileVersion fileVersion = fileEntry.getFileVersion(version);

    InputStream is = fileVersion.getContentStream(true);

    String fileName = fileVersion.getTitle();

    String sourceExtension = fileVersion.getExtension();

    if (Validator.isNotNull(sourceExtension) && !fileName.endsWith(StringPool.PERIOD + sourceExtension)) {

        fileName += StringPool.PERIOD + sourceExtension;
    }

    long contentLength = fileVersion.getSize();
    String contentType = fileVersion.getMimeType();

    if (Validator.isNotNull(targetExtension)) {
        String id = DLUtil.getTempFileId(fileEntry.getFileEntryId(), version);

        File convertedFile = DocumentConversionUtil.convert(id, is, sourceExtension, targetExtension);

        if (convertedFile != null) {
            fileName = FileUtil.stripExtension(fileName).concat(StringPool.PERIOD).concat(targetExtension);
            is = new FileInputStream(convertedFile);
            contentLength = convertedFile.length();
            contentType = MimeTypesUtil.getContentType(fileName);
        }
    }

    FlashMagicBytesUtil.Result flashMagicBytesUtilResult = FlashMagicBytesUtil.check(is);

    if (flashMagicBytesUtilResult.isFlash()) {
        fileName = FileUtil.stripExtension(fileName) + ".swf";
    }

    is = flashMagicBytesUtilResult.getInputStream();

    ServletResponseUtil.sendFile(request, response, fileName, is, contentLength, contentType);
}

From source file:com.liferay.portlet.documentlibrary.action.CompareVersionsAction.java

License:Open Source License

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));
    }/*from  w ww.  j a v  a 2  s .c  o  m*/

    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);
}

From source file:com.liferay.portlet.documentlibrary.action.GetFileAction.java

License:Open Source License

protected void getFile(long fileEntryId, long folderId, String title, String version, long fileShortcutId,
        String uuid, long groupId, String targetExtension, ThemeDisplay themeDisplay,
        HttpServletRequest request, HttpServletResponse response) throws Exception {

    FileEntry fileEntry = null;/*from ww  w .  ja v  a 2 s.co m*/

    if (Validator.isNotNull(uuid) && (groupId > 0)) {
        fileEntry = DLAppServiceUtil.getFileEntryByUuidAndGroupId(uuid, groupId);

        folderId = fileEntry.getFolderId();
    }

    if (fileEntryId > 0) {
        fileEntry = DLAppServiceUtil.getFileEntry(fileEntryId);
    } else if (fileShortcutId <= 0) {
        if (Validator.isNotNull(title)) {
            fileEntry = DLAppServiceUtil.getFileEntry(groupId, folderId, title);
        }
    } else {
        DLFileShortcut fileShortcut = DLAppServiceUtil.getFileShortcut(fileShortcutId);

        fileEntryId = fileShortcut.getToFileEntryId();

        fileEntry = DLAppServiceUtil.getFileEntry(fileEntryId);
    }

    if (Validator.isNull(version)) {
        if (Validator.isNotNull(fileEntry.getVersion())) {
            version = fileEntry.getVersion();
        } else {
            throw new NoSuchFileEntryException();
        }
    }

    FileVersion fileVersion = fileEntry.getFileVersion(version);

    InputStream is = fileVersion.getContentStream(true);
    String fileName = fileVersion.getTitle();
    long contentLength = fileVersion.getSize();
    String contentType = fileVersion.getMimeType();

    if (Validator.isNotNull(targetExtension)) {
        String id = DLUtil.getTempFileId(fileEntry.getFileEntryId(), version);

        String sourceExtension = fileVersion.getExtension();

        if (!fileName.endsWith(StringPool.PERIOD + sourceExtension)) {
            fileName += StringPool.PERIOD + sourceExtension;
        }

        File convertedFile = DocumentConversionUtil.convert(id, is, sourceExtension, targetExtension);

        if (convertedFile != null) {
            fileName = FileUtil.stripExtension(fileName).concat(StringPool.PERIOD).concat(targetExtension);
            is = new FileInputStream(convertedFile);
            contentLength = convertedFile.length();
            contentType = MimeTypesUtil.getContentType(fileName);
        }
    }

    ServletResponseUtil.sendFile(request, response, fileName, is, contentLength, contentType);
}

From source file:com.liferay.portlet.documentlibrary.service.impl.DLAppLocalServiceImpl.java

License:Open Source License

protected FileEntry copyFileEntry(long userId, LocalRepository toLocalRepository, FileEntry fileEntry,
        long newFolderId, ServiceContext serviceContext) throws PortalException, SystemException {

    List<FileVersion> fileVersions = fileEntry.getFileVersions(WorkflowConstants.STATUS_ANY);

    FileVersion latestFileVersion = fileVersions.get(fileVersions.size() - 1);

    FileEntry destinationFileEntry = toLocalRepository.addFileEntry(userId, newFolderId, fileEntry.getTitle(),
            latestFileVersion.getMimeType(), latestFileVersion.getTitle(), latestFileVersion.getDescription(),
            StringPool.BLANK, latestFileVersion.getContentStream(false), latestFileVersion.getSize(),
            serviceContext);// w w w.  j ava 2 s .c  o m

    for (int i = fileVersions.size() - 2; i >= 0; i--) {
        FileVersion fileVersion = fileVersions.get(i);

        FileVersion previousFileVersion = fileVersions.get(i + 1);

        try {
            destinationFileEntry = toLocalRepository.updateFileEntry(userId,
                    destinationFileEntry.getFileEntryId(), fileEntry.getTitle(),
                    destinationFileEntry.getMimeType(), destinationFileEntry.getTitle(),
                    destinationFileEntry.getDescription(), StringPool.BLANK,
                    isMajorVersion(fileVersion, previousFileVersion), fileVersion.getContentStream(false),
                    fileVersion.getSize(), serviceContext);
        } catch (PortalException pe) {
            toLocalRepository.deleteFileEntry(destinationFileEntry.getFileEntryId());

            throw pe;
        }
    }

    dlAppHelperLocalService.addFileEntry(userId, destinationFileEntry, destinationFileEntry.getFileVersion(),
            serviceContext);

    return destinationFileEntry;
}

From source file:com.liferay.portlet.documentlibrary.service.impl.DLAppServiceImpl.java

License:Open Source License

protected FileEntry copyFileEntry(Repository toRepository, FileEntry fileEntry, long newFolderId,
        ServiceContext serviceContext) throws PortalException, SystemException {

    List<FileVersion> fileVersions = fileEntry.getFileVersions(WorkflowConstants.STATUS_ANY);

    FileVersion latestFileVersion = fileVersions.get(fileVersions.size() - 1);

    FileEntry destinationFileEntry = toRepository.addFileEntry(newFolderId, fileEntry.getTitle(),
            latestFileVersion.getMimeType(), latestFileVersion.getTitle(), latestFileVersion.getDescription(),
            StringPool.BLANK, latestFileVersion.getContentStream(false), latestFileVersion.getSize(),
            serviceContext);//from   w w  w .  j a v a2 s  .  c  om

    for (int i = fileVersions.size() - 2; i >= 0; i--) {
        FileVersion fileVersion = fileVersions.get(i);

        FileVersion previousFileVersion = fileVersions.get(i + 1);

        try {
            destinationFileEntry = toRepository.updateFileEntry(destinationFileEntry.getFileEntryId(),
                    fileEntry.getTitle(), destinationFileEntry.getMimeType(), destinationFileEntry.getTitle(),
                    destinationFileEntry.getDescription(), StringPool.BLANK,
                    isMajorVersion(previousFileVersion, fileVersion), fileVersion.getContentStream(false),
                    fileVersion.getSize(), serviceContext);
        } catch (PortalException pe) {
            toRepository.deleteFileEntry(destinationFileEntry.getFileEntryId());

            throw pe;
        }
    }

    dlAppHelperLocalService.addFileEntry(getUserId(), destinationFileEntry,
            destinationFileEntry.getFileVersion(), serviceContext);

    return destinationFileEntry;
}

From source file:com.liferay.portlet.documentlibrary.util.AudioProcessorImpl.java

License:Open Source License

private void _generateAudioXuggler(FileVersion fileVersion, File srcFile, File destFile) throws Exception {

    StopWatch stopWatch = null;/*from  w  w w  . j a v a2  s  . co m*/

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

        stopWatch.start();
    }

    try {
        if (PropsValues.DL_FILE_ENTRY_PREVIEW_FORK_PROCESS_ENABLED) {
            ProcessCallable<String> processCallable = new LiferayAudioProcessCallable(
                    ServerDetector.getServerId(), PropsUtil.get(PropsKeys.LIFERAY_HOME),
                    Log4JUtil.getCustomLogSettings(), srcFile.getCanonicalPath(), destFile.getCanonicalPath());

            ProcessExecutor.execute(processCallable, ClassPathUtil.getPortalClassPath());
        } else {
            LiferayConverter liferayConverter = new LiferayAudioConverter(srcFile.getCanonicalPath(),
                    destFile.getCanonicalPath());

            liferayConverter.convert();
        }
    } catch (Exception e) {
        _log.error(e, e);
    }

    addFileToStore(fileVersion.getCompanyId(), PREVIEW_PATH, getPreviewFilePath(fileVersion), destFile);

    if (_log.isInfoEnabled()) {
        _log.info("Xuggler generated a preview audio for " + fileVersion.getTitle() + " in " + stopWatch);
    }
}

From source file:com.liferay.portlet.documentlibrary.util.PDFProcessorImpl.java

License:Open Source License

private void _generateImagesIM(FileVersion fileVersion, File file) throws Exception {

    if (_isGeneratePreview(fileVersion)) {
        StopWatch stopWatch = null;/* w w w.ja v a 2 s . com*/

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

            stopWatch.start();
        }

        _generateImagesIM(fileVersion, file, false);

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

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

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

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

            stopWatch.start();
        }

        _generateImagesIM(fileVersion, file, true);

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