Author: jflesch
Date: 2007-08-16 11:00:58 +0000 (Thu, 16 Aug 2007)
New Revision: 14718

Modified:
   trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessage.java
Log:
Fix an issue with the securities on the message parsing : Author and date must 
not be always forced on the last message

Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessage.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessage.java 
2007-08-16 10:31:12 UTC (rev 14717)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessage.java 
2007-08-16 11:00:58 UTC (rev 14718)
@@ -402,6 +402,31 @@
        }


+       private void setAuthorAndDate(Vector subMsgs, KSKAuthor author,
+                                     java.util.Date date) {
+
+               // we browse the vector by starting with the last element
+               // so we can't use an iterator
+               // the goal is to find the corresponding KSKAuthor
+               // and replace it by ours (ours has its identity set)
+               for (int i = subMsgs.size()-1; i >= 0 ; i--) {
+                       KSKSubMessage sub = (KSKSubMessage)subMsgs.get(i);
+
+                       if 
(author.toString().equals(sub.getAuthor().toString())) {
+                               sub.setAuthor(author);
+                               sub.setDate(date);
+                               return;
+                       }
+               }
+
+               // we didn't find it, so we force it on the last message
+               Logger.notice(this, "KSKAuthor forced on the last 
sub-messages");
+               KSKSubMessage lastMsg = 
(KSKSubMessage)subMsgs.get(subMsgs.size()-1);
+               lastMsg.setAuthor(author);
+               lastMsg.setDate(date);
+       }
+
+
        /** no caching */
        public Vector getSubMessages() {

@@ -439,14 +464,10 @@
                try {
                        v = parseMessage(content);

-                       int size;
-
-                       if (v == null || (size = v.size()) <= 0) {
+                       if (v == null || (v.size()) <= 0) {
                                parsed = false;
                        } else {
-                               KSKSubMessage lastMsg = 
(KSKSubMessage)v.get(size-1);
-                               lastMsg.setAuthor((KSKAuthor)getSender());
-                               lastMsg.setDate(getDate());
+                               setAuthorAndDate(v, ((KSKAuthor)getSender()), 
getDate());
                        }

                } catch(Exception e) { /* dirty, but should work */


Reply via email to