title: Liferay from fileentry to java file object
body: <p>Anyone know how to retrieve a contentStream from a <code>DLFileEntry</code> (http://docs.liferay.com/portal/6.0/javadocs/com/liferay/portlet/documentlibrary/model/DLFileEntry.html) using an httpservlet?</p>
  
  <p>I tried using <code>DLFileEntry.getContentStream()</code> but it fails giving me the error</p>
  
  <pre><code>com.liferay.portal.security.auth.PrincipalException: PermissionChecker not initialized
  </code></pre>
  
  <p>I solved in part that problem setting hardcode my userId:</p>
  
  <pre><code>long userId=2
  
              PrincipalThreadLocal.setName(userId);
  
              User user = UserLocalServiceUtil.getUserById(userId);
  
              PermissionChecker permissionChecker;
  
                  permissionChecker = PermissionCheckerFactoryUtil.create(user, false);
  
              PermissionThreadLocal.setPermissionChecker(permissionChecker);
  </code></pre>
  
  <p><strong>The problem of this solution is how to get the real userId, and how happen if the user is a guest?</strong></p>
  
  <p>I tried Long.parseLong(req.getRemoteUser()); but fail also.</p>