From ada756fb041a86d59a4cecb848966dd5a5e85971 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Fri, 10 Jun 2022 18:32:14 +0200 Subject: [PATCH] Fixed handlers --- .../resourceregistry/EServiceHandler.java | 12 ++++++++---- .../resourcemanager/EServiceManager.java | 19 ++++++++++++++++--- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/gcube/smartgears/handler/resourceregistry/EServiceHandler.java b/src/main/java/org/gcube/smartgears/handler/resourceregistry/EServiceHandler.java index fefa77f..1a091df 100644 --- a/src/main/java/org/gcube/smartgears/handler/resourceregistry/EServiceHandler.java +++ b/src/main/java/org/gcube/smartgears/handler/resourceregistry/EServiceHandler.java @@ -236,11 +236,15 @@ public class EServiceHandler extends ApplicationLifecycleHandler { } }; -// periodicUpdates = Utils.scheduledServicePool.scheduleAtFixedRate(updateTask, -// Constants.application_republish_frequency_in_minutes, -// Constants.application_republish_frequency_in_minutes, TimeUnit.MINUTES); + periodicUpdates = Utils.scheduledServicePool.scheduleAtFixedRate(updateTask, + Constants.application_republish_frequency_in_minutes, + Constants.application_republish_frequency_in_minutes, TimeUnit.MINUTES); - periodicUpdates = Utils.scheduledServicePool.scheduleAtFixedRate(updateTask, 120, 120, TimeUnit.SECONDS); + /* + * The following line is used for testing purposes during development. + * If you uncomment this, you need to comment the line above + */ +// periodicUpdates = Utils.scheduledServicePool.scheduleAtFixedRate(updateTask, 120, 120, TimeUnit.SECONDS); } diff --git a/src/main/java/org/gcube/smartgears/handler/resourceregistry/resourcemanager/EServiceManager.java b/src/main/java/org/gcube/smartgears/handler/resourceregistry/resourcemanager/EServiceManager.java index 6a83a18..0e45143 100644 --- a/src/main/java/org/gcube/smartgears/handler/resourceregistry/resourcemanager/EServiceManager.java +++ b/src/main/java/org/gcube/smartgears/handler/resourceregistry/resourcemanager/EServiceManager.java @@ -32,6 +32,7 @@ import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClien import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClientFactory; import org.gcube.informationsystem.resourceregistry.publisher.ResourceRegistryPublisher; import org.gcube.informationsystem.resourceregistry.publisher.ResourceRegistryPublisherFactory; +import org.gcube.informationsystem.utils.ElementMapper; import org.gcube.resourcemanagement.model.impl.entities.facets.AccessPointFacetImpl; import org.gcube.resourcemanagement.model.impl.entities.facets.EventFacetImpl; import org.gcube.resourcemanagement.model.impl.entities.facets.SoftwareFacetImpl; @@ -280,7 +281,7 @@ public class EServiceManager { updateFacets(); } catch (NotFoundException e) { eService = instantiateEService(); - createActivatesRelation(eService); + eService = createActivatesRelation(eService).getTarget(); } catch (AvailableInAnotherContextException e) { addHostingNodeToCurrentContext(); try { @@ -292,7 +293,7 @@ public class EServiceManager { // If the EService is still not available we need to create activates // relation because does not exists otherwise the EService should // already be in the context due to propagation constraint. - createActivatesRelation(eService); + eService = createActivatesRelation(eService).getTarget(); } updateFacets(); } catch (ResourceRegistryException e) { @@ -347,10 +348,16 @@ public class EServiceManager { eService.addFacet(eventFacet); } + try { + logger.trace("Updating {} for {} : {}", EService.NAME, applicationContext.configuration().name(), ElementMapper.marshal(eService)); + }catch (Exception e) { + + } + try { eService = resourceRegistryPublisher.updateResource(eService); }catch (ResourceRegistryException e) { - logger.error("error trying to publish hosting node", e); + logger.error("Error trying to publish hosting node", e); } return eService; @@ -366,6 +373,12 @@ public class EServiceManager { propagationConstraint.setAddConstraint(AddConstraint.propagate); Activates activates = new ActivatesImpl<>(hostingNode, eService, propagationConstraint); + try { + logger.trace("Going to create {} and {} for application {} : {}", Activates.NAME, EService.NAME, applicationContext.configuration().name(), ElementMapper.marshal(activates)); + }catch (Exception e) { + + } + try { activates = resourceRegistryPublisher.createIsRelatedTo(activates); hostingNode.attachResource(activates);