UNOMI-624: avoid using deprecated setPropertyValue:now and add temporary handling to avoid log polution on this deprecated option (more suitable solution will be handled by UNOMI=630) (#470)

diff --git a/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/SetPropertyAction.java b/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/SetPropertyAction.java
index fd833a5..25743b9 100644
--- a/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/SetPropertyAction.java
+++ b/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/SetPropertyAction.java
@@ -30,11 +30,15 @@
 import java.util.HashMap;
 import java.util.Map;
 import java.util.TimeZone;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
 
 public class SetPropertyAction implements ActionExecutor {
     private static final Logger logger = LoggerFactory.getLogger(SetPropertyAction.class.getName());
 
     private EventService eventService;
+    // TODO Temporary solution that should be handle by: https://issues.apache.org/jira/browse/UNOMI-630 (Implement a global solution to avoid multiple same log pollution.)
+    private static final AtomicLong nowDeprecatedLogTimestamp = new AtomicLong();
 
     private boolean useEventToUpdateProfile = false;
 
@@ -118,8 +122,16 @@
         }
 
         if (propertyValue != null && propertyValue.equals("now")) {
-            logger.warn("SetPropertyAction with setPropertyValue: 'now' is deprecated, " +
-                    "please use 'setPropertyValueCurrentEventTimestamp' or 'setPropertyValueCurrentDate' instead of 'setPropertyValue'");
+            // TODO Temporary solution that should be handle by: https://issues.apache.org/jira/browse/UNOMI-630 (Implement a global solution to avoid multiple same log pollution.)
+            // warn every 6 hours to avoid log pollution
+            long timeStamp = nowDeprecatedLogTimestamp.get();
+            long currentTimeStamp = new Date().getTime();
+            if (timeStamp == 0 || (timeStamp + TimeUnit.HOURS.toMillis(6) < currentTimeStamp)) {
+                logger.warn("SetPropertyAction with setPropertyValue: 'now' is deprecated, " +
+                        "please use 'setPropertyValueCurrentEventTimestamp' or 'setPropertyValueCurrentDate' instead of 'setPropertyValue'");
+                nowDeprecatedLogTimestamp.set(currentTimeStamp);
+            }
+
             propertyValue = format.format(event.getTimeStamp());
         }
 
diff --git a/services/src/main/java/org/apache/unomi/services/impl/goals/GoalsServiceImpl.java b/services/src/main/java/org/apache/unomi/services/impl/goals/GoalsServiceImpl.java
index f61db79..d7fe34f 100644
--- a/services/src/main/java/org/apache/unomi/services/impl/goals/GoalsServiceImpl.java
+++ b/services/src/main/java/org/apache/unomi/services/impl/goals/GoalsServiceImpl.java
@@ -170,12 +170,12 @@
         action1.setActionType(definitionsService.getActionType("setPropertyAction"));
         String name = "systemProperties.goals." + goal.getMetadata().getId() + id + "Reached";
         action1.setParameter("setPropertyName", name);
-        action1.setParameter("setPropertyValue", "now");
+        action1.setParameter("setPropertyValueCurrentEventTimestamp", true);
         action1.setParameter("storeInSession", true);
         Action action2 = new Action();
         action2.setActionType(definitionsService.getActionType("setPropertyAction"));
         action2.setParameter("setPropertyName", name);
-        action2.setParameter("setPropertyValue", "script::profile.properties.?"+name+" != null ? (profile.properties."+name+") : 'now'");
+        action2.setParameter("setPropertyValueCurrentEventTimestamp", true);
         action2.setParameter("storeInSession", false);
         rule.setActions(Arrays.asList(action1, action2));
 
@@ -317,12 +317,12 @@
         action1.setActionType(definitionsService.getActionType("setPropertyAction"));
         String name = "systemProperties.campaigns." + campaign.getMetadata().getId() + "Engaged";
         action1.setParameter("setPropertyName", name);
-        action1.setParameter("setPropertyValue", "now");
+        action1.setParameter("setPropertyValueCurrentEventTimestamp", true);
         action1.setParameter("storeInSession", true);
         Action action2 = new Action();
         action2.setActionType(definitionsService.getActionType("setPropertyAction"));
         action2.setParameter("setPropertyName", name);
-        action2.setParameter("setPropertyValue", "script::profile.properties.?"+name+" != null ? (profile.properties."+name+") : 'now'");
+        action2.setParameter("setPropertyValueCurrentEventTimestamp", true);
         action2.setParameter("storeInSession", false);
         rule.setActions(Arrays.asList(action1,action2));
         rulesService.setRule(rule);