This is an automated email from the ASF dual-hosted git repository.
jkevan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/unomi.git
The following commit(s) were added to refs/heads/master by this push:
new 1ea547207 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)
1ea547207 is described below
commit 1ea54720744b1e87edcafde092c702520e35853c
Author: kevan Jahanshahi <[email protected]>
AuthorDate: Tue Aug 2 18:40:59 2022 +0200
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)
---
.../plugins/baseplugin/actions/SetPropertyAction.java | 16 ++++++++++++++--
.../unomi/services/impl/goals/GoalsServiceImpl.java | 8 ++++----
2 files changed, 18 insertions(+), 6 deletions(-)
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 fd833a5e8..25743b96b 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.Date;
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 @@ public class SetPropertyAction implements ActionExecutor {
}
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 f61db79bf..d7fe34fc0 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 @@ public class GoalsServiceImpl implements GoalsService,
SynchronousBundleListener
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 @@ public class GoalsServiceImpl implements GoalsService,
SynchronousBundleListener
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);