@Override protected Metadata extractMetadata(String extension, String mimeType, InputStream inputStream) { Metadata metadata = super.extractMetadata(extension, mimeType, inputStream); boolean forkProcess = false; if (PropsValues.TEXT_EXTRACTION_FORK_PROCESS_ENABLED) { if (ArrayUtil.contains(PropsValues.TEXT_EXTRACTION_FORK_PROCESS_MIME_TYPES, mimeType)) { forkProcess = true; } } if (forkProcess) { File file = FileUtil.createTempFile(); try { FileUtil.write(file, inputStream); ExtractMetadataProcessCallable extractMetadataProcessCallable = new ExtractMetadataProcessCallable(file, metadata, _parser); Future<Metadata> future = ProcessExecutor.execute( ClassPathUtil.getPortalProcessConfig(), extractMetadataProcessCallable); return future.get(); } catch (Exception e) { throw new SystemException(e); } finally { file.delete(); } } try { return extractMetadata(inputStream, metadata, _parser); } catch (IOException ioe) { throw new SystemException(ioe); } }
private void _generateVideoXuggler( FileVersion fileVersion, File sourceFile, File destinationFile, String containerType) throws Exception { if (hasPreview(fileVersion, containerType)) { return; } StopWatch 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(), sourceFile, destinationFile, containerType, PropsUtil.getProperties(PropsKeys.DL_FILE_ENTRY_PREVIEW_VIDEO, false), PropsUtil.getProperties(PropsKeys.XUGGLER_FFPRESET, true)); ProcessChannel<String> processChannel = ProcessExecutorUtil.execute(ClassPathUtil.getPortalProcessConfig(), processCallable); Future<String> future = processChannel.getProcessNoticeableFuture(); String processIdentity = String.valueOf(fileVersion.getFileVersionId()); futures.put(processIdentity, future); future.get(); } else { LiferayConverter liferayConverter = new LiferayVideoConverter( sourceFile.getCanonicalPath(), destinationFile.getCanonicalPath(), containerType, 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), destinationFile); if (_log.isInfoEnabled()) { _log.info( "Xuggler generated a " + containerType + " preview video for " + fileVersion.getTitle() + " in " + stopWatch.getTime() + " ms"); } }
private void _generateThumbnailXuggler(FileVersion fileVersion, File file, int height, int width) throws Exception { StopWatch stopWatch = new StopWatch(); stopWatch.start(); String tempFileId = DLUtil.getTempFileId(fileVersion.getFileEntryId(), fileVersion.getVersion()); File thumbnailTempFile = getThumbnailTempFile(tempFileId); try { try { if (PropsValues.DL_FILE_ENTRY_PREVIEW_FORK_PROCESS_ENABLED) { ProcessCallable<String> processCallable = new LiferayVideoThumbnailProcessCallable( ServerDetector.getServerId(), PropsUtil.get(PropsKeys.LIFERAY_HOME), Log4JUtil.getCustomLogSettings(), file, thumbnailTempFile, THUMBNAIL_TYPE, height, width, PropsValues.DL_FILE_ENTRY_THUMBNAIL_VIDEO_FRAME_PERCENTAGE); ProcessChannel<String> processChannel = ProcessExecutorUtil.execute(ClassPathUtil.getPortalProcessConfig(), processCallable); Future<String> future = processChannel.getProcessNoticeableFuture(); String processIdentity = String.valueOf(fileVersion.getFileVersionId()); futures.put(processIdentity, future); future.get(); } else { LiferayConverter liferayConverter = new LiferayVideoThumbnailConverter( file.getCanonicalPath(), thumbnailTempFile, THUMBNAIL_TYPE, height, width, PropsValues.DL_FILE_ENTRY_THUMBNAIL_VIDEO_FRAME_PERCENTAGE); liferayConverter.convert(); } } catch (CancellationException ce) { if (_log.isInfoEnabled()) { _log.info( "Cancellation received for " + fileVersion.getFileVersionId() + " " + fileVersion.getTitle()); } } catch (Exception e) { _log.error(e, e); } storeThumbnailImages(fileVersion, thumbnailTempFile); if (_log.isInfoEnabled()) { _log.info( "Xuggler generated a thumbnail for " + fileVersion.getTitle() + " in " + stopWatch.getTime() + " ms"); } } catch (Exception e) { throw new SystemException(e); } finally { FileUtil.delete(thumbnailTempFile); } }