This is an automated email from the ASF dual-hosted git repository.
jkevan pushed a commit to branch unomi-1.6.x
in repository https://gitbox.apache.org/repos/asf/unomi.git
The following commit(s) were added to refs/heads/unomi-1.6.x by this push:
new db495e625 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)
db495e625 is described below
commit db495e6250da56d4939ad8bc546dd7e18d3e3480
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 698f8229a..44d385cdb 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 de4f4da37..538fe5d1c 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
@@ -174,12 +174,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));
@@ -325,12 +325,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);