use of com.liferay.portal.kernel.repository.model.FileVersion in project liferay-ide by liferay.
the class DLPreviewableProcessor method importPreviewFromLAR.
protected void importPreviewFromLAR(PortletDataContext portletDataContext, FileEntry fileEntry, Element fileEntryElement, String binPathSuffix, String previewType, int fileIndex) throws Exception {
FileVersion fileVersion = fileEntry.getFileVersion();
String binPathSegment = null;
if (fileIndex < 0) {
binPathSegment = previewType;
} else {
binPathSegment = Integer.toString(fileIndex + 1);
}
StringBundler sb = new StringBundler(4);
sb.append("bin-path-preview-");
sb.append(binPathSegment);
sb.append("-");
sb.append(binPathSuffix);
String binPathName = sb.toString();
String binPath = fileEntryElement.attributeValue(binPathName);
InputStream is = null;
try {
is = portletDataContext.getZipEntryAsInputStream(binPath);
if (is == null) {
return;
}
String previewFilePath = null;
if (fileIndex < 0) {
previewFilePath = getPreviewFilePath(fileVersion, previewType);
} else {
previewFilePath = getPreviewFilePath(fileVersion, fileIndex + 1);
}
addFileToStore(portletDataContext.getCompanyId(), PREVIEW_PATH, previewFilePath, is);
} finally {
StreamUtil.cleanUp(is);
}
}
Aggregations