james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [06/12] james-project git commit: JAMES-2560 Add a file name if none
Date Fri, 12 Oct 2018 08:28:57 GMT
JAMES-2560 Add a file name if none


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/09b41659
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/09b41659
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/09b41659

Branch: refs/heads/master
Commit: 09b416599741859aa8c9686f21c1f3a80686919b
Parents: ac82719
Author: Benoit Tellier <btellier@linagora.com>
Authored: Thu Oct 11 12:22:26 2018 +0700
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Fri Oct 12 15:26:53 2018 +0700

----------------------------------------------------------------------
 .../org/apache/james/transport/mailets/ICSSanitizer.java     | 8 ++++++++
 1 file changed, 8 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/09b41659/mailet/icalendar/src/main/java/org/apache/james/transport/mailets/ICSSanitizer.java
----------------------------------------------------------------------
diff --git a/mailet/icalendar/src/main/java/org/apache/james/transport/mailets/ICSSanitizer.java
b/mailet/icalendar/src/main/java/org/apache/james/transport/mailets/ICSSanitizer.java
index a2b268d..bdbdb2b 100644
--- a/mailet/icalendar/src/main/java/org/apache/james/transport/mailets/ICSSanitizer.java
+++ b/mailet/icalendar/src/main/java/org/apache/james/transport/mailets/ICSSanitizer.java
@@ -43,6 +43,7 @@ import com.github.fge.lambdas.Throwing;
 public class ICSSanitizer extends GenericMailet {
     private static final Logger LOGGER = LoggerFactory.getLogger(ICSSanitizer.class);
     private static final int TEXT_PREFIX_SIZE = 5;
+    public static final String DEFAULT_FILENAME = "event.ics";
 
     @Override
     public void service(Mail mail) {
@@ -87,11 +88,18 @@ public class ICSSanitizer extends GenericMailet {
                     computeBodyFromOriginalCalendar(bodyPart),
                     StandardCharsets.UTF_8.name(),
                     bodyPart.getContentType().substring(TEXT_PREFIX_SIZE));
+                setFileNameIfNeeded(mimeBodyPart);
             }
         }
         return bodyPart;
     }
 
+    private void setFileNameIfNeeded(MimeBodyPart mimeBodyPart) throws MessagingException
{
+        if (mimeBodyPart.getFileName() == null) {
+            mimeBodyPart.setFileName(DEFAULT_FILENAME);
+        }
+    }
+
     private String computeBodyFromOriginalCalendar(BodyPart bodyPart) throws MessagingException
{
         return headerStream(bodyPart)
             .map(header -> header.getName() + ": " + header.getValue())


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message