Update of /var/cvs/applications/email/src/org/mmbase/applications/email
In directory 
james.mmbase.org:/tmp/cvs-serv29340/src/org/mmbase/applications/email

Modified Files:
        EmailBuilder.java SendMail.java 
Log Message:
fixed some details with field names which were obviously not correct (due to 
differences with didactor from which some things were ported)


See also: 
http://cvs.mmbase.org/viewcvs/applications/email/src/org/mmbase/applications/email


Index: EmailBuilder.java
===================================================================
RCS file: 
/var/cvs/applications/email/src/org/mmbase/applications/email/EmailBuilder.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -b -r1.32 -r1.33
--- EmailBuilder.java   14 Oct 2008 11:04:32 -0000      1.32
+++ EmailBuilder.java   27 Nov 2008 12:26:37 -0000      1.33
@@ -28,7 +28,7 @@
  *
  * @author Daniel Ockeloen
  * @author Michiel Meeuwissen
- * @version $Id: EmailBuilder.java,v 1.32 2008/10/14 11:04:32 michiel Exp $
+ * @version $Id: EmailBuilder.java,v 1.33 2008/11/27 12:26:37 michiel Exp $
  */
 public class EmailBuilder extends MMObjectBuilder {
 
@@ -42,7 +42,7 @@
     public final static Parameter[] STARTMAIL_PARAMETERS = MAIL_PARAMETERS;
     public final static Parameter[] SETTYPE_PARAMETERS   = MAIL_PARAMETERS;
 
-    // defined values for state ( node field "mailstatus" )
+    // defined values for state (field "mailstatus" )
     public final static int STATE_UNKNOWN   = -1; // unknown
     public final static int STATE_WAITING   = 0; // waiting
     public final static int STATE_DELIVERED = 1; // delivered
@@ -51,11 +51,15 @@
     public final static int STATE_QUEUED    = 4; // queued
 
 
-    // defined values for state ( node field "mailtype" )
+    // defined values for type (field "mailtype" )
+    public final static int TYPE_STATIC      = 0; // A normal email object, 
which just represents an email object, and nothing more
     public final static int TYPE_ONESHOT     = 1; // Email will be sent and 
removed after sending.
-    // public final static int TYPE_REPEATMAIL  = 2; // Email will be sent and 
scheduled after sending for a next time (does not work?)
+    public final static int TYPE_RECEIVED    = 2; // Email which is received.
     public final static int TYPE_ONESHOTKEEP = 3; // Email will be sent and 
will not be removed.
 
+    // public final static int TYPE_REPEATMAIL  = 4; // Email will be sent and 
scheduled after sending for a next time (does not work?)
+
+
 
     static String usersBuilder;
     static String usersEmailField;
@@ -194,6 +198,13 @@
         return (SendMail) Module.getModule("sendmail");
     }
 
+    static String getTypeField() {
+        SendMail sm = getSendMail();
+        if (sm != null) return sm.getTypeField();
+        return "mailtype";
+    }
+
+
     /**
      * Set the mailtype based on the first argument in the list.
      *
@@ -202,14 +213,15 @@
      */
     private static void setType(Node node, Parameters parameters) {
         String type = (String) parameters.get("type");
+        String typeField = getTypeField();
         if ("oneshot".equals(type)) {
-            node.setValue("mailtype", TYPE_ONESHOT);
+            node.setValue(typeField, TYPE_ONESHOT);
             log.debug("Setting mailtype to: " + TYPE_ONESHOT);
         } else if ("oneshotkeep".equals(type)) {
-            node.setValue("mailtype", TYPE_ONESHOTKEEP);
+            node.setValue(typeField, TYPE_ONESHOTKEEP);
             log.debug("Setting mailtype to " + TYPE_ONESHOTKEEP);
         } else {
-            node.setValue("mailtype", TYPE_ONESHOT);
+            node.setValue(typeField, TYPE_ONESHOT);
             log.debug("Setting mailtype to: " + TYPE_ONESHOT);
         }
     }
@@ -231,7 +243,7 @@
         BasicCompositeConstraint cons = new 
BasicCompositeConstraint(CompositeConstraint.LOGICAL_AND);
 
         cons.addChild(new 
BasicFieldValueConstraint(query.getField(getField("mailstatus")), 
STATE_DELIVERED));
-        cons.addChild(new 
BasicFieldValueConstraint(query.getField(getField("mailtype")),   
TYPE_ONESHOT));
+        cons.addChild(new 
BasicFieldValueConstraint(query.getField(getField(getTypeField())),   
TYPE_ONESHOT));
         cons.addChild(new 
BasicFieldValueConstraint(query.getField(getField("mailedtime")), new 
java.util.Date(age)).setOperator(FieldCompareConstraint.LESS));
         query.setConstraint(cons);
         try {


Index: SendMail.java
===================================================================
RCS file: 
/var/cvs/applications/email/src/org/mmbase/applications/email/SendMail.java,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -b -r1.55 -r1.56
--- SendMail.java       27 Nov 2008 10:26:28 -0000      1.55
+++ SendMail.java       27 Nov 2008 12:26:37 -0000      1.56
@@ -32,7 +32,7 @@
  * @author Daniel Ockeloen
  * @author Johannes Verelst <[EMAIL PROTECTED]>
  * @since  MMBase-1.6
- * @version $Id: SendMail.java,v 1.55 2008/11/27 10:26:28 michiel Exp $
+ * @version $Id: SendMail.java,v 1.56 2008/11/27 12:26:37 michiel Exp $
  */
 public class SendMail extends AbstractSendMail {
     private static final Logger log = 
Logging.getLoggerInstance(SendMail.class);
@@ -119,7 +119,7 @@
             NodeList mailboxes = person.getRelatedNodes("mailboxes");
             for (int j = 0; j < mailboxes.size(); j++) {
                 Node mailbox = mailboxes.getNode(j);
-                if (mailbox.getIntValue(typeField) == 0) {
+                if (mailbox.getIntValue(typeField) == 
EmailBuilder.TYPE_STATIC) {
                     log.debug("Found mailbox, adding mail now");
                     Node emailNode = emailManager.createNode();
                     emailNode.setValue("to", n.getValue("to"));
@@ -129,12 +129,14 @@
                         emailNode.setValue("bcc", n.getValue("bcc"));
                     }
                     emailNode.setValue("subject", n.getValue("subject"));
+                    if (emailNode.getNodeManager().hasField("date")) {
                     emailNode.setValue("date", n.getValue("date"));
+                    }
                     emailNode.setValue("body", n.getValue("body"));
                     if (emailNode.getNodeManager().hasField("mimetype")) {
                         emailNode.setValue("mimetype", n.getValue("mimetype"));
                     }
-                    emailNode.setIntValue(typeField, 2);
+                    emailNode.setIntValue(typeField, 
EmailBuilder.TYPE_RECEIVED);
                     emailNode.commit();
                     log.debug("Appending " + emailNode + " to " + 
mailbox.getNumber());
                     mailbox.createRelation(emailNode, relatedManager).commit();
@@ -152,7 +154,9 @@
                         newAttachment.setValue("filename", 
oldAttachment.getValue("filename"));
                         newAttachment.setValue("size", 
oldAttachment.getValue("size"));
                         newAttachment.setValue("handle", 
oldAttachment.getValue("handle"));
+                        if (newAttachment.getNodeManager().hasField("date")) {
                         newAttachment.setValue("date", 
oldAttachment.getValue("date"));
+                        }
                         newAttachment.setValue("showtitle", 
oldAttachment.getValue("showtitle"));
                         newAttachment.commit();
                         emailNode.createRelation(newAttachment, 
relatedManager).commit();
@@ -201,7 +205,7 @@
                     if (emailManager.hasField("mimetype")) {
                         error.setValue("mimetype", "text/plain");
                     }
-                    error.setIntValue(typeField, 1);
+                    error.setIntValue(typeField, EmailBuilder.TYPE_ONESHOT);
                     error.commit();
                     log.debug("Ready sending error mail about " + failedUsers);
                 } catch (Exception e) {
@@ -685,7 +689,7 @@
                 errorNode.setStringValue("to", n.getStringValue("from"));
                 errorNode.setStringValue("from", n.getStringValue("from"));
                 errorNode.setStringValue("subject", "****");
-                errorNode.setIntValue(typeField, 1);
+                errorNode.setIntValue(typeField, EmailBuilder.TYPE_ONESHOT);
                 errorNode.setStringValue("body", errors.toString());
                 errorNode.commit();
                 log.service("Sent node " + errorNode.getNumber());
@@ -813,6 +817,10 @@
         return session;
     }
 
+    public String getTypeField() {
+        return typeField;
+    }
+
     {
         addFunction(new AbstractFunction("verifyEmail", new Parameter[] { new 
Parameter("signature", String.class, true), Parameter.CLOUD }, ReturnType.NODE) 
{
                 public Node getFunctionValue(Parameters parameters) {
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to