Author: jflesch
Date: 2007-12-03 23:13:04 +0000 (Mon, 03 Dec 2007)
New Revision: 16247

Modified:
   trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties
   trunk/apps/Thaw/src/thaw/i18n/thaw.properties
   trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
   trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessageParser.java
Log:
MiniFrost : If it can't parse a message, it will store an error messsage 
instead in the database to not download it again

Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties     2007-12-03 
21:43:56 UTC (rev 16246)
+++ trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties     2007-12-03 
23:13:04 UTC (rev 16247)
@@ -640,6 +640,7 @@
 thaw.plugin.miniFrost.draft=Brouillon
 thaw.plugin.miniFrost.encrypted=Crypt?
 thaw.plugin.miniFrost.encryptedBody=Crypt? pour 'X'
+thaw.plugin.miniFrost.invalidMessage=Message invalide

 thaw.plugin.miniFrost.regexpBlacklistLongDesc=Archiver imm?diatement les 
messages correspondant aux expressions suivantes (une par line):
 thaw.plugin.miniFrost.seeSunManual=(Voir X)

Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw.properties       2007-12-03 21:43:56 UTC 
(rev 16246)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties       2007-12-03 23:13:04 UTC 
(rev 16247)
@@ -655,6 +655,7 @@
 thaw.plugin.miniFrost.encrypted=Encrypted
 thaw.plugin.miniFrost.encryptedFor=[Encrypted for 'X']
 thaw.plugin.miniFrost.encryptedBody=Encrypted for 'X'
+thaw.plugin.miniFrost.invalidMessage=Invalid message

 thaw.plugin.miniFrost.regexpBlacklistLongDesc=Archivate immediatly the 
messages matching the following expressions (one per line):
 thaw.plugin.miniFrost.seeSunManual=(See X)

Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties    2007-12-03 21:43:56 UTC 
(rev 16246)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties    2007-12-03 23:13:04 UTC 
(rev 16247)
@@ -640,6 +640,7 @@
 thaw.plugin.miniFrost.draft=Brouillon
 thaw.plugin.miniFrost.encrypted=Crypt\u00e9
 thaw.plugin.miniFrost.encryptedBody=Crypt\u00e9 pour 'X'
+thaw.plugin.miniFrost.invalidMessage=Message invalide

 thaw.plugin.miniFrost.regexpBlacklistLongDesc=Archiver imm\u00e9diatement les 
messages correspondant aux expressions suivantes (une par line):
 thaw.plugin.miniFrost.seeSunManual=(Voir X)

Modified: 
trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessageParser.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessageParser.java   
2007-12-03 21:43:56 UTC (rev 16246)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessageParser.java   
2007-12-03 23:13:04 UTC (rev 16247)
@@ -532,8 +532,47 @@
                /* because we have date to store: */
                return true;
        }
+       
+       private boolean invalidMessage(String reason) {
+               /* Invalid message -> Will use default value */
+               /* the goal is to not download this message again */
+               
+               inReplyTo = null;
+               from = 
"["+I18n.getMessage("thaw.plugin.miniFrost.invalidMessage")+"]";
+               subject = 
"["+I18n.getMessage("thaw.plugin.miniFrost.invalidMessage")+"]";

+               String[] date = gmtFormat.format(new Date()).toString().split(" 
");
+               this.date = date[0];
+               this.time = date[1];

+               /* not really used */
+               this.recipient = null;
+
+               /* will be ignored by the checks */
+               this.board = null;
+
+               this.body = 
I18n.getMessage("thaw.plugin.miniFrost.invalidMessage")+
+                       ((reason != null) ? "\n"+reason : "");
+
+               this.publicKey = null;
+               this.signature = null;
+               this.idLinePos = "0";
+               this.idLineLen = "0";
+               attachments = null;
+
+               identity = null;
+
+               if (frostCrypt == null)
+                       frostCrypt = new FrostCrypt();
+               this.messageId = frostCrypt.computeChecksumSHA256(date[0] + 
date[1]);
+
+               read = true;
+               archived = true;
+               
+               return true;
+       }
+       
+
        /**
         * This function has been imported from FROST.
         * Parses the XML file and passes the FrostMessage element to XMLize 
load method.
@@ -546,14 +585,14 @@
                                doc = XMLTools.parseXmlFile(file, false);
                        } catch(Exception ex) {  // xml format error
                                Logger.notice(this, "Invalid Xml");
-                               return false;
+                               return invalidMessage("XML parser 
error:\n"+ex.toString());
                        }

                        if( doc == null ) {
                                Logger.notice(this,
                                               "Error: couldn't parse XML 
Document - " +
                                               "File name: '" + file.getName() 
+ "'");
-                               return false;
+                               return invalidMessage("Nothing parsed ?!");
                        }

                        Element rootNode = doc.getDocumentElement();
@@ -574,7 +613,7 @@
                        /* XMLTools throws runtime exception sometimes ... */
                        Logger.notice(this, "Unable to parse XML message 
because : "+e.toString());
                        e.printStackTrace();
-                       return false;
+                       return invalidMessage("Unable to parse XML message 
because : "+e.toString());
                }
        }



Reply via email to