Update of /var/cvs/src/org/mmbase/datatypes/processors
In directory james.mmbase.org:/tmp/cvs-serv17616

Modified Files:
      Tag: MMBase-1_8
        LastModified.java LastModifier.java 
Log Message:
MMB-1737


See also: http://cvs.mmbase.org/viewcvs/src/org/mmbase/datatypes/processors
See also: http://www.mmbase.org/jira/browse/MMB-1737


Index: LastModified.java
===================================================================
RCS file: /var/cvs/src/org/mmbase/datatypes/processors/LastModified.java,v
retrieving revision 1.4.2.1
retrieving revision 1.4.2.2
diff -u -b -r1.4.2.1 -r1.4.2.2
--- LastModified.java   15 Jul 2008 10:10:14 -0000      1.4.2.1
+++ LastModified.java   4 Nov 2008 16:48:24 -0000       1.4.2.2
@@ -11,23 +11,34 @@
 
 import org.mmbase.bridge.*;
 import java.util.Date;
+import org.mmbase.util.logging.*;
 
 /**
  * This processor can be used as a 'commit' processor on a (datetime) field. 
The field will then be set
  * to the current time when the node is committed.
  *
  * @author Michiel Meeuwissen
- * @version $Id: LastModified.java,v 1.4.2.1 2008/07/15 10:10:14 michiel Exp $
+ * @version $Id: LastModified.java,v 1.4.2.2 2008/11/04 16:48:24 michiel Exp $
  * @since MMBase-1.8
  * @see   LastModifier
  */
 
 public class LastModified implements CommitProcessor {
 
+    private static final Logger log = 
Logging.getLoggerInstance(LastModified.class);
     private static final long serialVersionUID = 1L;
 
+    private boolean setIfNotChanged = false;
+
+    /**
+     * @since MMBase-1.9.1
+     */
+    public void setIfNotChanged(boolean b) {
+        setIfNotChanged = b;
+    }
+
     public void commit(Node node, Field field) {
-        if (node.mayWrite()) {
+        if (node.mayWrite() && (setIfNotChanged || node.getChanged().size() > 
0)) {
             node.setValueWithoutProcess(field.getName(), new Date());
         }
     }


Index: LastModifier.java
===================================================================
RCS file: /var/cvs/src/org/mmbase/datatypes/processors/LastModifier.java,v
retrieving revision 1.4.2.1
retrieving revision 1.4.2.2
diff -u -b -r1.4.2.1 -r1.4.2.2
--- LastModifier.java   15 Jul 2008 10:10:14 -0000      1.4.2.1
+++ LastModifier.java   4 Nov 2008 16:48:24 -0000       1.4.2.2
@@ -16,7 +16,7 @@
  * to the current user id when the node is committed.
  *
  * @author Michiel Meeuwissen
- * @version $Id: LastModifier.java,v 1.4.2.1 2008/07/15 10:10:14 michiel Exp $
+ * @version $Id: LastModifier.java,v 1.4.2.2 2008/11/04 16:48:24 michiel Exp $
  * @since MMBase-1.8
  * @see   LastModified
  * @see   Creator
@@ -27,8 +27,20 @@
 
     private static final long serialVersionUID = 1L;
 
+
+    private boolean setIfNotChanged = false;
+    /**
+     * On default the field is not changed if no other fields were changed. 
You can override this
+     * using this property.
+     *
+     * @since MMBase-1.9.1
+     */
+    public void setIfNotChanged(boolean b) {
+        setIfNotChanged = b;
+    }
+
     public void commit(Node node, Field field) {
-        if (node.mayWrite()) {
+        if (node.mayWrite() && (setIfNotChanged || node.getChanged().size() > 
0)) {
             
node.setValueWithoutProcess(field.getName(),node.getCloud().getUser().getIdentifier());
         }
     }
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to