Fixed handlers

This commit is contained in:
Luca Frosini 2022-06-10 18:32:14 +02:00
parent 16da31d117
commit ada756fb04
2 changed files with 24 additions and 7 deletions

View File

@ -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);
}

View File

@ -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<HostingNode, EService> 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);