From 7f190700c3636de6d6cb5ebea3a7f1253d3b491f Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Tue, 2 May 2023 17:58:13 +0200 Subject: [PATCH] Fixing bug which creates infinite number of EventFacet --- .../resourcemanager/EServiceManager.java | 13 +++++-------- .../resourcemanager/HostingNodeManager.java | 14 ++++++-------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/gcube/smartgears/connector/resourceregistry/resourcemanager/EServiceManager.java b/src/main/java/org/gcube/smartgears/connector/resourceregistry/resourcemanager/EServiceManager.java index c9baee5..c2ef5e7 100644 --- a/src/main/java/org/gcube/smartgears/connector/resourceregistry/resourcemanager/EServiceManager.java +++ b/src/main/java/org/gcube/smartgears/connector/resourceregistry/resourcemanager/EServiceManager.java @@ -320,16 +320,13 @@ public class EServiceManager { } if(c.getTarget() instanceof EventFacet) { - eventFacet = (EventFacet) c.getTarget(); - String value = eventFacet.getEvent(); + EventFacet foundEventFacet = (EventFacet) c.getTarget(); + String value = foundEventFacet.getEvent(); if(value.compareTo(getState())==0) { // This facet must be updated (the date must be updated) so it must not be removed from udpate - eventFacet.setDate(date); + foundEventFacet.setDate(date); + eventFacet = foundEventFacet; continue; - }else { - // This is not the event facet to be updated - // Setting the variable to null so it will be created if the event does not already exists. - eventFacet = null; } } @@ -341,7 +338,7 @@ public class EServiceManager { // Removing the ones that have not to be changed. consistsOfList.removeAll(consistsOfToRemove); - + /* The eventFacet for the event does not exists. Going to create it */ if(eventFacet == null) { eventFacet = getEventFacet(date); eService.addFacet(eventFacet); diff --git a/src/main/java/org/gcube/smartgears/connector/resourceregistry/resourcemanager/HostingNodeManager.java b/src/main/java/org/gcube/smartgears/connector/resourceregistry/resourcemanager/HostingNodeManager.java index 179b819..8e06e67 100644 --- a/src/main/java/org/gcube/smartgears/connector/resourceregistry/resourcemanager/HostingNodeManager.java +++ b/src/main/java/org/gcube/smartgears/connector/resourceregistry/resourcemanager/HostingNodeManager.java @@ -222,16 +222,13 @@ public class HostingNodeManager { } if(c.getTarget() instanceof EventFacet) { - eventFacet = (EventFacet) c.getTarget(); - String value = eventFacet.getEvent(); + EventFacet foundEventFacet = (EventFacet) c.getTarget(); + String value = foundEventFacet.getEvent(); if(value.compareTo(getState())==0) { - // This facet must be updated (the date must be updated) so it must not be removed from udpate - eventFacet.setDate(date); + // This facet must be updated (the date must be updated) so it must not be removed from update + foundEventFacet.setDate(date); + eventFacet = foundEventFacet; continue; - }else { - // This is not the event facet to be updated - // Setting the variable to null so it will be created if the event does not already exists. - eventFacet = null; } } @@ -243,6 +240,7 @@ public class HostingNodeManager { // Removing the ones that have not to be changed. consistsOfList.removeAll(consistsOfToRemove); + /* The eventFacet for the event does not exists. Going to create it */ if(eventFacet == null) { eventFacet = getEventFacet(date); hostingNode.addFacet(eventFacet);