From eda2459b13785c94ad5cfbd88ae5ea44b5b0a530 Mon Sep 17 00:00:00 2001 From: lolo101 Date: Mon, 1 Apr 2024 19:46:00 +0200 Subject: [PATCH] conversion Message -> MSG moved to msgparser --- .../MSGViewer/factory/MessageSaver.java | 2 +- .../factory/msg/lib/MSTimeConvert.java | 26 +--- .../factory/msg/properties/PropPtypTime.java | 24 --- .../src/test/resources/issue129/test.eml | 142 ------------------ msgparser/pom.xml | 12 ++ .../java/com/auxilii/msgparser/Message.java | 14 -- .../com/auxilii/msgparser}/MsgContainer.java | 13 +- .../com/auxilii/msgparser}/MsgWriter.java | 3 +- .../msgparser}/entries/BinaryEntry.java | 6 +- .../msgparser}/entries/BodyHtmlEntry.java | 2 +- .../msgparser}/entries/BodyTextEntry.java | 2 +- .../entries/CompressedRTFEntry.java | 2 +- .../msgparser}/entries/EntryStreamEntry.java | 2 +- .../msgparser}/entries/GuidStreamEntry.java | 2 +- .../msgparser}/entries/HeadersEntry.java | 2 +- .../msgparser}/entries/MessageClassEntry.java | 4 +- .../msgparser}/entries/StringStreamEntry.java | 2 +- .../entries/StringUTF16SubstgEntry.java | 6 +- .../msgparser}/entries/SubStorageEntry.java | 4 +- .../msgparser}/entries/SubjectEntry.java | 2 +- .../properties/PropPtypByteArray.java | 2 +- .../properties/PropPtypInteger32.java | 2 +- .../msgparser}/properties/PropPtypString.java | 2 +- .../msgparser/properties/PropPtypTime.java | 42 ++++++ .../msgparser}/properties/PropType.java | 2 +- .../com/auxilii/msgparser}/MsgWriterTest.java | 38 ++--- 26 files changed, 100 insertions(+), 260 deletions(-) delete mode 100644 MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/properties/PropPtypTime.java delete mode 100644 MSGViewer/src/test/resources/issue129/test.eml rename {MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg => msgparser/src/main/java/com/auxilii/msgparser}/MsgContainer.java (96%) rename {MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg => msgparser/src/main/java/com/auxilii/msgparser}/MsgWriter.java (87%) rename {MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg => msgparser/src/main/java/com/auxilii/msgparser}/entries/BinaryEntry.java (75%) rename {MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg => msgparser/src/main/java/com/auxilii/msgparser}/entries/BodyHtmlEntry.java (77%) rename {MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg => msgparser/src/main/java/com/auxilii/msgparser}/entries/BodyTextEntry.java (78%) rename {MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg => msgparser/src/main/java/com/auxilii/msgparser}/entries/CompressedRTFEntry.java (80%) rename {MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg => msgparser/src/main/java/com/auxilii/msgparser}/entries/EntryStreamEntry.java (79%) rename {MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg => msgparser/src/main/java/com/auxilii/msgparser}/entries/GuidStreamEntry.java (78%) rename {MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg => msgparser/src/main/java/com/auxilii/msgparser}/entries/HeadersEntry.java (81%) rename {MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg => msgparser/src/main/java/com/auxilii/msgparser}/entries/MessageClassEntry.java (66%) rename {MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg => msgparser/src/main/java/com/auxilii/msgparser}/entries/StringStreamEntry.java (79%) rename {MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg => msgparser/src/main/java/com/auxilii/msgparser}/entries/StringUTF16SubstgEntry.java (83%) rename {MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg => msgparser/src/main/java/com/auxilii/msgparser}/entries/SubStorageEntry.java (86%) rename {MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg => msgparser/src/main/java/com/auxilii/msgparser}/entries/SubjectEntry.java (78%) rename {MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg => msgparser/src/main/java/com/auxilii/msgparser}/properties/PropPtypByteArray.java (86%) rename {MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg => msgparser/src/main/java/com/auxilii/msgparser}/properties/PropPtypInteger32.java (86%) rename {MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg => msgparser/src/main/java/com/auxilii/msgparser}/properties/PropPtypString.java (86%) create mode 100644 msgparser/src/main/java/com/auxilii/msgparser/properties/PropPtypTime.java rename {MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg => msgparser/src/main/java/com/auxilii/msgparser}/properties/PropType.java (92%) rename {MSGViewer/src/test/java/net/sourceforge/MSGViewer/factory/msg => msgparser/src/test/java/com/auxilii/msgparser}/MsgWriterTest.java (55%) diff --git a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/MessageSaver.java b/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/MessageSaver.java index 5205d44e..82405a46 100644 --- a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/MessageSaver.java +++ b/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/MessageSaver.java @@ -1,10 +1,10 @@ package net.sourceforge.MSGViewer.factory; import com.auxilii.msgparser.Message; +import com.auxilii.msgparser.MsgWriter; import net.sourceforge.MSGViewer.AttachmentRepository; import net.sourceforge.MSGViewer.factory.mbox.EMLWriterViaJavaMail; import net.sourceforge.MSGViewer.factory.mbox.MBoxWriterViaJavaMail; -import net.sourceforge.MSGViewer.factory.msg.MsgWriter; import java.io.IOException; import java.io.OutputStream; diff --git a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/lib/MSTimeConvert.java b/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/lib/MSTimeConvert.java index f080bebd..39c7caa5 100644 --- a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/lib/MSTimeConvert.java +++ b/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/lib/MSTimeConvert.java @@ -3,39 +3,23 @@ public class MSTimeConvert { /** - * difference between 1-1-1601 and 1-1-1970 in millisecond + * difference between 1-1-1601 and 1-1-1970 in milliseconds */ public static final long MS_EPOCH_OFFSET = 11644473600000L; /** - * convert a 64 bit Integer value to a normal time field. - * MS hat here nanoseconds since 1601 + * convert a 64-bit Integer value to a normal time field. + * MS time counts hundreds of nanoseconds since 1601. * * @return the time in millis since 1970 same as System.currentTime() does * this is the value in UTC timezone! */ public static long PtypeTime2Millis(long time) { - time /= 10L; // micro - time /= 1000L; // milli + time /= 10L; // micros + time /= 1000L; // millis time -= MS_EPOCH_OFFSET; // offset since 1601 return time; } - - - /** - * convert a 64 bit Integer value to a normal time field. - * MS hat here nanoseconds since 1601 - * - * @return returns the time in nabos since 1.1.1601 - */ - public static long Millis2PtypeTime(long time) { - time += MS_EPOCH_OFFSET; // offset since 1601 - - time *= 10L; // micro - time *= 1000L; // milli - - return time; - } } diff --git a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/properties/PropPtypTime.java b/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/properties/PropPtypTime.java deleted file mode 100644 index 3ddcbe58..00000000 --- a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/properties/PropPtypTime.java +++ /dev/null @@ -1,24 +0,0 @@ -package net.sourceforge.MSGViewer.factory.msg.properties; - -import com.auxilii.msgparser.Pid; -import net.sourceforge.MSGViewer.factory.msg.lib.MSTimeConvert; - -import static com.auxilii.msgparser.Ptyp.PtypTime; - -public class PropPtypTime extends PropType { - private final long value; - - /** - * @param id id of the property - * @param value in milliseconds since 1.1.1970 - */ - public PropPtypTime(Pid id, long value) { - super(id, PtypTime); - this.value = MSTimeConvert.Millis2PtypeTime(value); - } - - @Override - protected long getPropertiesContent() { - return value; - } -} diff --git a/MSGViewer/src/test/resources/issue129/test.eml b/MSGViewer/src/test/resources/issue129/test.eml deleted file mode 100644 index dca8b85f..00000000 --- a/MSGViewer/src/test/resources/issue129/test.eml +++ /dev/null @@ -1,142 +0,0 @@ -X-Mozilla-Status: 0001 -X-Mozilla-Status2: 00000000 -X-Mozilla-Keys: -X-Mozilla-Status: 0001 -X-Mozilla-Status2: 00000000 -Message-Id: -Date: Sun, 4 Sep 2022 17:50:19 +0200 -Mime-Version: 1.0 -User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 - Thunderbird/102.2.0 -Content-Language: fr-FR -To: lbroquet -From: =?UTF-8?Q?Lo=c3=afc_Broquet?= -X-Enigmail-Draft-Status: N00201 -X-Mozilla-Draft-Info: internal/draft; vcard=0; receipt=0; DSN=0; uuencode=0; - attachmentreminder=0; deliveryformat=0 -X-Identity-Key: id1 -Fcc: mailbox://lbroquet@pop.sfr.fr/Sent -Subject: test127 -Content-Type: multipart/mixed; boundary="------------3EjuttzkEubrckLt8973XLoZ" -References: <41e56d31-9ce0-a484-ac0e-3922bdf960fe@neuf.fr> - ---------------3EjuttzkEubrckLt8973XLoZ -Content-Type: multipart/mixed; boundary="------------RzZrRuhmKtyPWjzdEcFTEj3w"; - protected-headers="v1" -Subject: test127 -From: =?UTF-8?Q?Lo=c3=afc_Broquet?= -To: lbroquet -Message-ID: <41e56d31-9ce0-a484-ac0e-3922bdf960fe@neuf.fr> - ---------------RzZrRuhmKtyPWjzdEcFTEj3w -Content-Type: multipart/related; - boundary="------------QGtU7DJaJN0liDSiSzu0P1Ib" - ---------------QGtU7DJaJN0liDSiSzu0P1Ib -Content-Type: text/html; charset=UTF-8 -Content-Transfer-Encoding: 7bit - - - - - - test127 - - -

Embedded image

-

Tokien smoking
-        pipe

-
- - ---------------QGtU7DJaJN0liDSiSzu0P1Ib -Content-Type: image/gif; name="tolk.gif" -Content-Disposition: inline; filename="tolk.gif" -Content-Id: -Content-Transfer-Encoding: base64 - -R0lGODlhVQBVAPcAAAAAAAEBAQICAgMDAwQEBAUFBQYGBgcHBwgICAkJCQoKCgsLCwwMDA0N -DQ4ODg8PDxAQEBERERISEhMTExQUFBUVFRYWFhcXFxgYGBkZ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oD -0QIXccEqYGoGWQifU6qcv8SKDDCfCgqZfUmJPgmcdyktdDocLKWiaBqWWcmGVYClMgqiC8qT -4iictuQojNKns1mgyMmhITFZQlkahwzqm3KakhxAK40SNncKdr5Ib7fJVLH0BYYgg1JKm2fq -nnlqqt8pmsKJfQEBADs= - ---------------QGtU7DJaJN0liDSiSzu0P1Ib-- - ---------------RzZrRuhmKtyPWjzdEcFTEj3w-- - ---------------3EjuttzkEubrckLt8973XLoZ-- diff --git a/msgparser/pom.xml b/msgparser/pom.xml index ee99cfe6..900ba709 100644 --- a/msgparser/pom.xml +++ b/msgparser/pom.xml @@ -36,5 +36,17 @@ 5.10.3 test + + com.google.jimfs + jimfs + 1.3.0 + test + + + org.assertj + assertj-core + 3.25.3 + test + diff --git a/msgparser/src/main/java/com/auxilii/msgparser/Message.java b/msgparser/src/main/java/com/auxilii/msgparser/Message.java index 56377c17..1dcfdffc 100644 --- a/msgparser/src/main/java/com/auxilii/msgparser/Message.java +++ b/msgparser/src/main/java/com/auxilii/msgparser/Message.java @@ -58,10 +58,6 @@ public class Message { private static final String DATE_HEADER_KEY = "date:"; public static final DateTimeFormatter DATE_TIME_FORMATTER = new DateTimeFormatterBuilder().appendPattern("[EEE, ]d MMM y HH:mm[:ss] Z").toFormatter(Locale.US); - /** - * The message class as defined in the .msg file. - */ - private String messageClass = "IPM.Note"; /** * The message Id. */ @@ -143,9 +139,6 @@ public void addRecipient(RecipientEntry recipient) { void setProperty(Property property) { this.properties.add(property); switch (property.getPid()) { - case PidTagMessageClass: - this.setMessageClass((String) property.getValue()); - break; case PidTagInternetMessageId: this.setMessageId((String) property.getValue()); break; @@ -362,13 +355,6 @@ private void setDisplayBcc(String displayBcc) { this.displayBcc = displayBcc; } - /** - * @param messageClass the messageClass to set - */ - private void setMessageClass(String messageClass) { - this.messageClass = messageClass; - } - /** * @return the messageId */ diff --git a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/MsgContainer.java b/msgparser/src/main/java/com/auxilii/msgparser/MsgContainer.java similarity index 96% rename from MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/MsgContainer.java rename to msgparser/src/main/java/com/auxilii/msgparser/MsgContainer.java index e208beaf..a598c9af 100644 --- a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/MsgContainer.java +++ b/msgparser/src/main/java/com/auxilii/msgparser/MsgContainer.java @@ -1,15 +1,12 @@ -package net.sourceforge.MSGViewer.factory.msg; +package com.auxilii.msgparser; -import com.auxilii.msgparser.Message; -import com.auxilii.msgparser.Ptyp; -import com.auxilii.msgparser.RecipientEntry; import com.auxilii.msgparser.attachment.Attachment; import com.auxilii.msgparser.attachment.FileAttachment; import com.auxilii.msgparser.attachment.MsgAttachment; -import net.sourceforge.MSGViewer.factory.msg.entries.*; -import net.sourceforge.MSGViewer.factory.msg.properties.PropPtypInteger32; -import net.sourceforge.MSGViewer.factory.msg.properties.PropPtypTime; -import net.sourceforge.MSGViewer.factory.msg.properties.PropType; +import com.auxilii.msgparser.entries.*; +import com.auxilii.msgparser.properties.PropPtypInteger32; +import com.auxilii.msgparser.properties.PropPtypTime; +import com.auxilii.msgparser.properties.PropType; import org.apache.poi.poifs.filesystem.DirectoryEntry; import java.io.ByteArrayInputStream; diff --git a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/MsgWriter.java b/msgparser/src/main/java/com/auxilii/msgparser/MsgWriter.java similarity index 87% rename from MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/MsgWriter.java rename to msgparser/src/main/java/com/auxilii/msgparser/MsgWriter.java index 078b136f..c1ba170c 100644 --- a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/MsgWriter.java +++ b/msgparser/src/main/java/com/auxilii/msgparser/MsgWriter.java @@ -1,6 +1,5 @@ -package net.sourceforge.MSGViewer.factory.msg; +package com.auxilii.msgparser; -import com.auxilii.msgparser.Message; import org.apache.poi.poifs.filesystem.DirectoryNode; import org.apache.poi.poifs.filesystem.POIFSFileSystem; diff --git a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/entries/BinaryEntry.java b/msgparser/src/main/java/com/auxilii/msgparser/entries/BinaryEntry.java similarity index 75% rename from MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/entries/BinaryEntry.java rename to msgparser/src/main/java/com/auxilii/msgparser/entries/BinaryEntry.java index ca3dc568..2f19e8f5 100644 --- a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/entries/BinaryEntry.java +++ b/msgparser/src/main/java/com/auxilii/msgparser/entries/BinaryEntry.java @@ -1,8 +1,8 @@ -package net.sourceforge.MSGViewer.factory.msg.entries; +package com.auxilii.msgparser.entries; import com.auxilii.msgparser.Pid; -import net.sourceforge.MSGViewer.factory.msg.properties.PropPtypByteArray; -import net.sourceforge.MSGViewer.factory.msg.properties.PropType; +import com.auxilii.msgparser.properties.PropPtypByteArray; +import com.auxilii.msgparser.properties.PropType; import java.io.ByteArrayInputStream; import java.io.InputStream; diff --git a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/entries/BodyHtmlEntry.java b/msgparser/src/main/java/com/auxilii/msgparser/entries/BodyHtmlEntry.java similarity index 77% rename from MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/entries/BodyHtmlEntry.java rename to msgparser/src/main/java/com/auxilii/msgparser/entries/BodyHtmlEntry.java index bc16f478..e2df67d2 100644 --- a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/entries/BodyHtmlEntry.java +++ b/msgparser/src/main/java/com/auxilii/msgparser/entries/BodyHtmlEntry.java @@ -1,4 +1,4 @@ -package net.sourceforge.MSGViewer.factory.msg.entries; +package com.auxilii.msgparser.entries; import static com.auxilii.msgparser.Pid.PidTagHtml; diff --git a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/entries/BodyTextEntry.java b/msgparser/src/main/java/com/auxilii/msgparser/entries/BodyTextEntry.java similarity index 78% rename from MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/entries/BodyTextEntry.java rename to msgparser/src/main/java/com/auxilii/msgparser/entries/BodyTextEntry.java index 21776bab..cbfd0e90 100644 --- a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/entries/BodyTextEntry.java +++ b/msgparser/src/main/java/com/auxilii/msgparser/entries/BodyTextEntry.java @@ -1,4 +1,4 @@ -package net.sourceforge.MSGViewer.factory.msg.entries; +package com.auxilii.msgparser.entries; import static com.auxilii.msgparser.Pid.PidTagBody; diff --git a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/entries/CompressedRTFEntry.java b/msgparser/src/main/java/com/auxilii/msgparser/entries/CompressedRTFEntry.java similarity index 80% rename from MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/entries/CompressedRTFEntry.java rename to msgparser/src/main/java/com/auxilii/msgparser/entries/CompressedRTFEntry.java index c88e30e8..2f7d63f7 100644 --- a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/entries/CompressedRTFEntry.java +++ b/msgparser/src/main/java/com/auxilii/msgparser/entries/CompressedRTFEntry.java @@ -1,4 +1,4 @@ -package net.sourceforge.MSGViewer.factory.msg.entries; +package com.auxilii.msgparser.entries; import static com.auxilii.msgparser.Pid.PidTagRtfCompressed; diff --git a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/entries/EntryStreamEntry.java b/msgparser/src/main/java/com/auxilii/msgparser/entries/EntryStreamEntry.java similarity index 79% rename from MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/entries/EntryStreamEntry.java rename to msgparser/src/main/java/com/auxilii/msgparser/entries/EntryStreamEntry.java index a9e241d4..013278c2 100644 --- a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/entries/EntryStreamEntry.java +++ b/msgparser/src/main/java/com/auxilii/msgparser/entries/EntryStreamEntry.java @@ -1,4 +1,4 @@ -package net.sourceforge.MSGViewer.factory.msg.entries; +package com.auxilii.msgparser.entries; import static com.auxilii.msgparser.Pid.PidTagEntryStream; diff --git a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/entries/GuidStreamEntry.java b/msgparser/src/main/java/com/auxilii/msgparser/entries/GuidStreamEntry.java similarity index 78% rename from MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/entries/GuidStreamEntry.java rename to msgparser/src/main/java/com/auxilii/msgparser/entries/GuidStreamEntry.java index 178eec9b..95d6e0b2 100644 --- a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/entries/GuidStreamEntry.java +++ b/msgparser/src/main/java/com/auxilii/msgparser/entries/GuidStreamEntry.java @@ -1,4 +1,4 @@ -package net.sourceforge.MSGViewer.factory.msg.entries; +package com.auxilii.msgparser.entries; import static com.auxilii.msgparser.Pid.PidTagGuidStream; diff --git a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/entries/HeadersEntry.java b/msgparser/src/main/java/com/auxilii/msgparser/entries/HeadersEntry.java similarity index 81% rename from MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/entries/HeadersEntry.java rename to msgparser/src/main/java/com/auxilii/msgparser/entries/HeadersEntry.java index cc345c55..0b30aedd 100644 --- a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/entries/HeadersEntry.java +++ b/msgparser/src/main/java/com/auxilii/msgparser/entries/HeadersEntry.java @@ -1,4 +1,4 @@ -package net.sourceforge.MSGViewer.factory.msg.entries; +package com.auxilii.msgparser.entries; import static com.auxilii.msgparser.Pid.PidTagTransportMessageHeaders; diff --git a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/entries/MessageClassEntry.java b/msgparser/src/main/java/com/auxilii/msgparser/entries/MessageClassEntry.java similarity index 66% rename from MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/entries/MessageClassEntry.java rename to msgparser/src/main/java/com/auxilii/msgparser/entries/MessageClassEntry.java index 8e515b7c..347b5052 100644 --- a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/entries/MessageClassEntry.java +++ b/msgparser/src/main/java/com/auxilii/msgparser/entries/MessageClassEntry.java @@ -1,9 +1,9 @@ -package net.sourceforge.MSGViewer.factory.msg.entries; +package com.auxilii.msgparser.entries; import static com.auxilii.msgparser.Pid.PidTagMessageClass; public class MessageClassEntry extends StringUTF16SubstgEntry { - public static final String IPM_NOTE = "IPM.Note"; + private static final String IPM_NOTE = "IPM.Note"; public MessageClassEntry() { super(PidTagMessageClass, IPM_NOTE); diff --git a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/entries/StringStreamEntry.java b/msgparser/src/main/java/com/auxilii/msgparser/entries/StringStreamEntry.java similarity index 79% rename from MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/entries/StringStreamEntry.java rename to msgparser/src/main/java/com/auxilii/msgparser/entries/StringStreamEntry.java index 2c6f0a80..b0a8e25f 100644 --- a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/entries/StringStreamEntry.java +++ b/msgparser/src/main/java/com/auxilii/msgparser/entries/StringStreamEntry.java @@ -1,4 +1,4 @@ -package net.sourceforge.MSGViewer.factory.msg.entries; +package com.auxilii.msgparser.entries; import static com.auxilii.msgparser.Pid.PidTagStringStream; diff --git a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/entries/StringUTF16SubstgEntry.java b/msgparser/src/main/java/com/auxilii/msgparser/entries/StringUTF16SubstgEntry.java similarity index 83% rename from MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/entries/StringUTF16SubstgEntry.java rename to msgparser/src/main/java/com/auxilii/msgparser/entries/StringUTF16SubstgEntry.java index fce8566c..602c7c0a 100644 --- a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/entries/StringUTF16SubstgEntry.java +++ b/msgparser/src/main/java/com/auxilii/msgparser/entries/StringUTF16SubstgEntry.java @@ -1,8 +1,8 @@ -package net.sourceforge.MSGViewer.factory.msg.entries; +package com.auxilii.msgparser.entries; import com.auxilii.msgparser.Pid; -import net.sourceforge.MSGViewer.factory.msg.properties.PropPtypString; -import net.sourceforge.MSGViewer.factory.msg.properties.PropType; +import com.auxilii.msgparser.properties.PropPtypString; +import com.auxilii.msgparser.properties.PropType; import java.io.ByteArrayInputStream; import java.io.InputStream; diff --git a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/entries/SubStorageEntry.java b/msgparser/src/main/java/com/auxilii/msgparser/entries/SubStorageEntry.java similarity index 86% rename from MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/entries/SubStorageEntry.java rename to msgparser/src/main/java/com/auxilii/msgparser/entries/SubStorageEntry.java index 9cc5e7e1..0822323e 100644 --- a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/entries/SubStorageEntry.java +++ b/msgparser/src/main/java/com/auxilii/msgparser/entries/SubStorageEntry.java @@ -1,8 +1,8 @@ -package net.sourceforge.MSGViewer.factory.msg.entries; +package com.auxilii.msgparser.entries; import com.auxilii.msgparser.Pid; import com.auxilii.msgparser.Ptyp; -import net.sourceforge.MSGViewer.factory.msg.properties.PropType; +import com.auxilii.msgparser.properties.PropType; import org.apache.poi.poifs.filesystem.DirectoryEntry; import java.io.IOException; diff --git a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/entries/SubjectEntry.java b/msgparser/src/main/java/com/auxilii/msgparser/entries/SubjectEntry.java similarity index 78% rename from MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/entries/SubjectEntry.java rename to msgparser/src/main/java/com/auxilii/msgparser/entries/SubjectEntry.java index a0d8e63c..d088500c 100644 --- a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/entries/SubjectEntry.java +++ b/msgparser/src/main/java/com/auxilii/msgparser/entries/SubjectEntry.java @@ -1,4 +1,4 @@ -package net.sourceforge.MSGViewer.factory.msg.entries; +package com.auxilii.msgparser.entries; import static com.auxilii.msgparser.Pid.PidTagSubject; diff --git a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/properties/PropPtypByteArray.java b/msgparser/src/main/java/com/auxilii/msgparser/properties/PropPtypByteArray.java similarity index 86% rename from MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/properties/PropPtypByteArray.java rename to msgparser/src/main/java/com/auxilii/msgparser/properties/PropPtypByteArray.java index 0564a2e1..f816940f 100644 --- a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/properties/PropPtypByteArray.java +++ b/msgparser/src/main/java/com/auxilii/msgparser/properties/PropPtypByteArray.java @@ -1,4 +1,4 @@ -package net.sourceforge.MSGViewer.factory.msg.properties; +package com.auxilii.msgparser.properties; import com.auxilii.msgparser.Pid; diff --git a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/properties/PropPtypInteger32.java b/msgparser/src/main/java/com/auxilii/msgparser/properties/PropPtypInteger32.java similarity index 86% rename from MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/properties/PropPtypInteger32.java rename to msgparser/src/main/java/com/auxilii/msgparser/properties/PropPtypInteger32.java index 62ab948f..cccc9fe8 100644 --- a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/properties/PropPtypInteger32.java +++ b/msgparser/src/main/java/com/auxilii/msgparser/properties/PropPtypInteger32.java @@ -1,4 +1,4 @@ -package net.sourceforge.MSGViewer.factory.msg.properties; +package com.auxilii.msgparser.properties; import com.auxilii.msgparser.Pid; diff --git a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/properties/PropPtypString.java b/msgparser/src/main/java/com/auxilii/msgparser/properties/PropPtypString.java similarity index 86% rename from MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/properties/PropPtypString.java rename to msgparser/src/main/java/com/auxilii/msgparser/properties/PropPtypString.java index d756d69f..e83d5162 100644 --- a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/properties/PropPtypString.java +++ b/msgparser/src/main/java/com/auxilii/msgparser/properties/PropPtypString.java @@ -1,4 +1,4 @@ -package net.sourceforge.MSGViewer.factory.msg.properties; +package com.auxilii.msgparser.properties; import com.auxilii.msgparser.Pid; diff --git a/msgparser/src/main/java/com/auxilii/msgparser/properties/PropPtypTime.java b/msgparser/src/main/java/com/auxilii/msgparser/properties/PropPtypTime.java new file mode 100644 index 00000000..60e03cf4 --- /dev/null +++ b/msgparser/src/main/java/com/auxilii/msgparser/properties/PropPtypTime.java @@ -0,0 +1,42 @@ +package com.auxilii.msgparser.properties; + +import com.auxilii.msgparser.Pid; + +import static com.auxilii.msgparser.Ptyp.PtypTime; + +public class PropPtypTime extends PropType { + /** + * difference between 1-1-1601 and 1-1-1970 in milliseconds + */ + private static final long MS_EPOCH_OFFSET = 11644473600000L; + private final long value; + + /** + * @param id id of the property + * @param value in milliseconds since 1.1.1970 + */ + public PropPtypTime(Pid id, long value) { + super(id, PtypTime); + this.value = millis2PtypTime(value); + } + + @Override + protected long getPropertiesContent() { + return value; + } + + /** + * convert a 64-bit Integer value to an MS time field. + * MS time counts hundreds of nanoseconds since 1601. + * + * @return returns the time in 100 nanos since 1.1.1601 + */ + private static long millis2PtypTime(long time) { + time += MS_EPOCH_OFFSET; // offset since 1601 in millis + + time *= 1000L; // micros + time *= 10L; // 100 nanos + + return time; + } +} diff --git a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/properties/PropType.java b/msgparser/src/main/java/com/auxilii/msgparser/properties/PropType.java similarity index 92% rename from MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/properties/PropType.java rename to msgparser/src/main/java/com/auxilii/msgparser/properties/PropType.java index 5051a072..ac1dd3e1 100644 --- a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/msg/properties/PropType.java +++ b/msgparser/src/main/java/com/auxilii/msgparser/properties/PropType.java @@ -1,4 +1,4 @@ -package net.sourceforge.MSGViewer.factory.msg.properties; +package com.auxilii.msgparser.properties; import com.auxilii.msgparser.Pid; import com.auxilii.msgparser.Ptyp; diff --git a/MSGViewer/src/test/java/net/sourceforge/MSGViewer/factory/msg/MsgWriterTest.java b/msgparser/src/test/java/com/auxilii/msgparser/MsgWriterTest.java similarity index 55% rename from MSGViewer/src/test/java/net/sourceforge/MSGViewer/factory/msg/MsgWriterTest.java rename to msgparser/src/test/java/com/auxilii/msgparser/MsgWriterTest.java index f4d95de1..0115cde6 100644 --- a/MSGViewer/src/test/java/net/sourceforge/MSGViewer/factory/msg/MsgWriterTest.java +++ b/msgparser/src/test/java/com/auxilii/msgparser/MsgWriterTest.java @@ -1,9 +1,7 @@ -package net.sourceforge.MSGViewer.factory.msg; +package com.auxilii.msgparser; -import com.auxilii.msgparser.Message; +import com.auxilii.msgparser.attachment.FileAttachment; import com.google.common.jimfs.Jimfs; -import net.sourceforge.MSGViewer.ModuleLauncher; -import net.sourceforge.MSGViewer.factory.MessageParser; import org.apache.poi.poifs.filesystem.DirectoryNode; import org.apache.poi.poifs.filesystem.DocumentEntry; import org.apache.poi.poifs.filesystem.DocumentInputStream; @@ -11,39 +9,23 @@ import org.junit.jupiter.api.Test; import java.io.OutputStream; -import java.net.URI; import java.nio.charset.StandardCharsets; import java.nio.file.FileSystem; import java.nio.file.Files; import java.nio.file.Path; -import java.util.Objects; import static org.assertj.core.api.Assertions.assertThat; class MsgWriterTest { - @Test - void testWrite() throws Exception { - ModuleLauncher.BaseConfigureLogging(); - - try (FileSystem fileSystem = Jimfs.newFileSystem()) { - Path testOut = fileSystem.getPath("test_out.msg"); - try (OutputStream outputStream = Files.newOutputStream(testOut)) { - Message msg = givenMessage("/danke.msg"); - new MsgWriter(msg).write(outputStream); - } - assertThat(Files.isRegularFile(testOut)).isTrue(); - } - } + private static final String CONTENT_ID = "part1.HRgTI02d.mjRZp5Gh@neuf.fr"; @Test void issue129() throws Exception { - ModuleLauncher.BaseConfigureLogging(); - try (FileSystem fileSystem = Jimfs.newFileSystem()) { Path testOut = fileSystem.getPath("test_out.msg"); try (OutputStream outputStream = Files.newOutputStream(testOut)) { - Message msg = givenMessage("/issue129/test.eml"); + Message msg = givenMessage(); new MsgWriter(msg).write(outputStream); } @@ -53,14 +35,18 @@ void issue129() throws Exception { DocumentEntry contentId = (DocumentEntry) attachment.getEntry("__substg1.0_3712001F"); try (DocumentInputStream stream = new DocumentInputStream(contentId)) { String contentIdValue = new String(stream.readAllBytes(), StandardCharsets.UTF_16LE); - assertThat(contentIdValue).isEqualTo("part1.HRgTI02d.mjRZp5Gh@neuf.fr"); + assertThat(contentIdValue).isEqualTo(CONTENT_ID); } } } } - private static Message givenMessage(String name) throws Exception { - URI uri = Objects.requireNonNull(MsgWriterTest.class.getResource(name)).toURI(); - return new MessageParser(Path.of(uri)).parseMessage(); + private static Message givenMessage() { + Message message = new Message(); + FileAttachment attachment = new FileAttachment(); + attachment.setContentId(CONTENT_ID); + attachment.setData(new byte[0]); + message.addAttachment(attachment); + return message; } }