@@ -756,7 +756,8 @@ public GUIDocument getDocument(Session session, long docId)
756
756
757
757
if (session != null && folder != null ) {
758
758
FolderDAO fdao = (FolderDAO ) Context .get ().getBean (FolderDAO .class );
759
- Set <Permission > permissions = fdao .getEnabledPermissions (document .getFolder ().getId (), session .getUserId ());
759
+ Set <Permission > permissions = fdao .getEnabledPermissions (document .getFolder ().getId (),
760
+ session .getUserId ());
760
761
List <String > permissionsList = new ArrayList <>();
761
762
for (Permission permission : permissions )
762
763
permissionsList .add (permission .toString ());
@@ -2656,17 +2657,25 @@ public GUIDocument convert(long docId, String fileVersion, String format) throws
2656
2657
public GUIEmail extractEmail (long docId , String fileVersion ) throws ServerException {
2657
2658
Session session = validateSession ();
2658
2659
2659
- GUIDocument emailDocument = getById (docId );
2660
- if (!emailDocument .getFileName ().toLowerCase ().endsWith (".eml" )
2661
- && !emailDocument .getFileName ().toLowerCase ().endsWith (".msg" ))
2662
- throw new ServerException ("Not an email file" );
2660
+ DocumentDAO dao = (DocumentDAO ) Context .get ().getBean (DocumentDAO .class );
2661
+ Document emailDocument = null ;
2662
+ try {
2663
+ emailDocument = dao .findDocument (docId );
2664
+ if (!emailDocument .getFileName ().toLowerCase ().endsWith (".eml" )
2665
+ && !emailDocument .getFileName ().toLowerCase ().endsWith (".msg" ))
2666
+ throw new ServerException ("Not an email file" );
2667
+ } catch (PersistenceException e1 ) {
2668
+ return (GUIEmail ) throwServerException (session , log , e1 );
2669
+ }
2663
2670
2664
2671
Storer storer = (Storer ) Context .get ().getBean (Storer .class );
2665
2672
String resource = storer .getResourceName (docId , fileVersion , null );
2666
-
2673
+
2674
+ GUIDocument guiDocument = getById (docId );
2675
+
2667
2676
try (InputStream is = storer .getStream (emailDocument .getId (), resource )) {
2668
2677
GUIEmail guiMail = new GUIEmail ();
2669
- EMail email = readEmail (is , docId , emailDocument );
2678
+ EMail email = readEmail (is , emailDocument . getId (), guiDocument );
2670
2679
if (email != null ) {
2671
2680
if (email .getFrom () != null )
2672
2681
guiMail .setFrom (new GUIContact (email .getFrom ().getName (), null , email .getFrom ().getAddress ()));
@@ -2681,7 +2690,7 @@ public GUIEmail extractEmail(long docId, String fileVersion) throws ServerExcept
2681
2690
2682
2691
setEmailRecipients (email , guiMail );
2683
2692
2684
- setEmailAttachments (emailDocument , email , guiMail );
2693
+ setEmailAttachments (guiDocument , email , guiMail );
2685
2694
}
2686
2695
return guiMail ;
2687
2696
} catch (IOException e1 ) {
0 commit comments