Anyone know how to retrieve a contentStream from a DLFileEntry (http://docs.liferay.com/portal/6.0/javadocs/com/liferay/portlet/documentlibrary/model/DLFileEntry.html) using an httpservlet?
I tried using DLFileEntry.getContentStream() but it fails giving me the error
com.liferay.portal.security.auth.PrincipalException: PermissionChecker not initialized
I solved in part that problem setting hardcode my userId:
long userId=2
PrincipalThreadLocal.setName(userId);
User user = UserLocalServiceUtil.getUserById(userId);
PermissionChecker permissionChecker;
permissionChecker = PermissionCheckerFactoryUtil.create(user, false);
PermissionThreadLocal.setPermissionChecker(permissionChecker);
The problem of this solution is how to get the real userId, and how happen if the user is a guest?
I tried Long.parseLong(req.getRemoteUser()); but fail also.
If you're using Liferay 6.1 then the following code will get you a InputStream for the That DLFileEntry.
Howwever the error you're getting is seems to be due you not authenticating with Liferay before making this call to the server.
How are you calling this code?