liferay/liferay-portal — pull request #409 by LeandroCannizzaro (2013-07-30 14:37:27+00:00)
Title: First sorry for my english i hope that is understandable. The problem is that the pdf viewers of FF and IE use the last component of the url as filename instead the filename property of the inline header.

Then when you click save, the filename retrieved by ff/ie is the uuid of the file (the last component of the path).

Now seeing to liferay internal i see that:
The apis above use groupId/uuid of file entry for get the real path of the file.
The process of conversion of a file entry virtual url to the real file name require a path segments array as the following:
groupId
folderId
FileName
UUid
See: WebServerServlet.sendFile and WebServerServlet.getFileEntry

So any other component added to the path not change the ability of liferay of retrieve the correct stream and send it to the client.

My idea for solve quickly the bug without affect a lot the system is to add another filename part to the url in the function
DLUtil.getPreviewURL
Only if the mime type is application/pdf

As in this code fragment:
sb.append("/documents/");
sb.append(fileEntry.getRepositoryId());
sb.append(StringPool.SLASH);
sb.append(fileEntry.getFolderId());
sb.append(StringPool.SLASH);
sb.append(HttpUtil.encodeURL(HtmlUtil.unescape(fileEntry.getTitle())));
sb.append(StringPool.SLASH);
sb.append(fileEntry.getUuid());
//Here add an additional filename to path so the pdf viewer of ie/ff find a correct filename
//The FileEntry Resolution of Liferay remain unaffected because see only in the first 4 path components of the url
if (fileEntry.getMimeType().equalsIgnoreCase("application/pdf"))
{
sb.append(StringPool.SLASH);
sb.append(HttpUtil.encodeURL(HtmlUtil.unescape(fileEntry.getTitle())));
}

With this addition all work correctly.

Is clear that is also possible to modify the url scheme of fileentry virtual url to the following:
groupId
folderId
UUid
FileName
Also in this case the correct filename is handled.

I not have done this because may be that have more impact on the system. but if you want i can apply this solution.

Regards
Leandro Cannizzaro
e-mail: leandro.cannizzaro@gmail.com
skype: leandro.cannizzaro1