Example usage for com.liferay.portal.kernel.util FileUtil createTempFileName

List of usage examples for com.liferay.portal.kernel.util FileUtil createTempFileName

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util FileUtil createTempFileName.

Prototype

public static String createTempFileName() 

Source Link

Usage

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

License:Open Source License

private void _generateVideoXuggler(FileVersion fileVersion, File srcFile, File destFile, String containerType)
        throws Exception {

    if (!_isGeneratePreview(fileVersion, containerType)) {
        return;//w  ww  .  j a  v a 2 s .c  om
    }

    StopWatch stopWatch = null;

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

        stopWatch.start();
    }

    if (PropsValues.DL_FILE_ENTRY_PREVIEW_FORK_PROCESS_ENABLED) {
        ProcessCallable<String> processCallable = new LiferayVideoProcessCallable(ServerDetector.getServerId(),
                PropsUtil.get(PropsKeys.LIFERAY_HOME), Log4JUtil.getCustomLogSettings(),
                srcFile.getCanonicalPath(), destFile.getCanonicalPath(), FileUtil.createTempFileName(),
                PropsUtil.getProperties(PropsKeys.DL_FILE_ENTRY_PREVIEW_VIDEO, false),
                PropsUtil.getProperties(PropsKeys.XUGGLER_FFPRESET, true));

        ProcessExecutor.execute(processCallable, ClassPathUtil.getPortalClassPath());
    } else {
        LiferayConverter liferayConverter = new LiferayVideoConverter(srcFile.getCanonicalPath(),
                destFile.getCanonicalPath(), FileUtil.createTempFileName(),
                PropsUtil.getProperties(PropsKeys.DL_FILE_ENTRY_PREVIEW_VIDEO, false),
                PropsUtil.getProperties(PropsKeys.XUGGLER_FFPRESET, true));

        liferayConverter.convert();
    }

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

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