Affects Version/s: 7.0.X, Master
The UpgradeDocumentLibrary#updateFileEntryFileNames process selects every single DLFileEntry and populates their fileNames one by one. Moreover, the logic in this process is convoluted and doesn't even seem to make sense when closely analyzed. We should rewrite this method to require as few SQL statements as possible and to not risk exceptions such as a Constraint Violation Exception or a Max Length Exceeded exception, nor should we risk an infinite loop.
Steps to Reproduce
1. Start up Liferay 6.2 connected to a fresh database.
2. Log in as the admin user.
3. Run the attached groovy script.
4. Shut down Liferay.
5. Attempt to upgrade to Liferay 7.
6. Observe the length of time it takes to run the v7_0_0.UpgradeDocumentLibrary#updateFileEntryFileNames process.
Expected Result: The upgrade process completes within a few minutes.
Actual Result: The upgrade process takes roughly three hours to process the first 100001 documents. I believe that once it gets to the 100002nd document it would get stuck in an infinite loop, but I have not actually waited long enough to confirm that this is the case.