Created
December 20, 2016 12:04
-
-
Save SergioLarios/fc8e933ade08911ad74b9f9b86c1831d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static long getFileId(LegacyIncorporaGroup lig, long parentFolderId, LegacyFile legacyFile) { | |
if (parentFolderId < 0) { return -1; } | |
try { | |
File tmpFile = File.createTempFile(legacyFile.getTitle(), legacyFile.getExtension()); | |
String downloadUrl = String.format(DOWNLOAD_FILE_URL, legacyFile.getGroupId(), | |
legacyFile.getFileEntryId(), legacyFile.getUuid(), legacyFile.getVersion()); | |
FileUtils.copyURLToFile(new URL(downloadUrl), tmpFile); | |
ServiceContext ctx = new ServiceContext(); | |
FileEntry file = null; | |
try { | |
file = DLAppServiceUtil.getFileEntry(lig.getCurrentGroupId(), parentFolderId, legacyFile.getTitle()); | |
file = DLAppServiceUtil.updateFileEntry(file.getFileEntryId(), file.getTitle(), file.getMimeType(), | |
file.getTitle(), file.getDescription(), StringPool.BLANK, false, tmpFile, ctx); | |
} catch (Exception e) { | |
file = DLAppServiceUtil.addFileEntry(lig.getCurrentGroupId(), parentFolderId, legacyFile.getTitle(), | |
legacyFile.getMimeType(), legacyFile.getTitle(), StringPool.BLANK, StringPool.BLANK, tmpFile, ctx); | |
} | |
return file.getFileEntryId(); | |
} catch (Exception e) { | |
_log.error(e); | |
return -1; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment