Fixing pubblication
This commit is contained in:
parent
9a282c4a7f
commit
90512acf7b
|
@ -16,11 +16,15 @@ import org.gcube.informationsystem.resourceregistry.publisher.ResourceRegistryPu
|
|||
import org.gcube.resourcemanagement.model.impl.entities.facets.SimplePropertyFacetImpl;
|
||||
import org.gcube.resourcemanagement.model.impl.entities.facets.SoftwareFacetImpl;
|
||||
import org.gcube.resourcemanagement.model.impl.entities.resources.RunningPluginImpl;
|
||||
import org.gcube.resourcemanagement.model.impl.relations.isrelatedto.EnablesImpl;
|
||||
import org.gcube.resourcemanagement.model.impl.relations.isrelatedto.UsesImpl;
|
||||
import org.gcube.resourcemanagement.model.reference.entities.facets.SimplePropertyFacet;
|
||||
import org.gcube.resourcemanagement.model.reference.entities.facets.SoftwareFacet;
|
||||
import org.gcube.resourcemanagement.model.reference.entities.resources.EService;
|
||||
import org.gcube.resourcemanagement.model.reference.entities.resources.RunningPlugin;
|
||||
import org.gcube.resourcemanagement.model.reference.entities.resources.Service;
|
||||
import org.gcube.resourcemanagement.model.reference.entities.resources.Software;
|
||||
import org.gcube.resourcemanagement.model.reference.relations.isrelatedto.Enables;
|
||||
import org.gcube.resourcemanagement.model.reference.relations.isrelatedto.Uses;
|
||||
import org.gcube.smartgears.context.application.ApplicationContext;
|
||||
import org.gcube.vremanagement.executor.plugin.Plugin;
|
||||
|
@ -44,15 +48,13 @@ public class RestISPublisher extends ISPublisher {
|
|||
ResourceRegistryClient resourceRegistryClient = ResourceRegistryClientFactory.create();
|
||||
ResourceRegistryPublisher resourceRegistryPublisher = ResourceRegistryPublisherFactory.create();
|
||||
|
||||
EService smartExecutorEService = resourceRegistryClient.getInstance(EService.class, eServiceUUID);
|
||||
|
||||
for(String pluginName : availablePlugins.keySet()) {
|
||||
Plugin plugin = PluginManager.getPlugin(pluginName);
|
||||
|
||||
RunningPlugin runningPlugin = new RunningPluginImpl();
|
||||
|
||||
SoftwareFacet softwareFacet = new SoftwareFacetImpl();
|
||||
softwareFacet.setGroup("SmartExecutorPlugin");
|
||||
softwareFacet.setGroup(plugin.getGroup());
|
||||
softwareFacet.setName(pluginName);
|
||||
softwareFacet.setVersion(plugin.getVersion());
|
||||
softwareFacet.setDescription(plugin.getDescription());
|
||||
|
@ -66,11 +68,13 @@ public class RestISPublisher extends ISPublisher {
|
|||
runningPlugin.addFacet(simplePropertyFacet);
|
||||
}
|
||||
|
||||
PropagationConstraint propagationConstraint = new PropagationConstraintImpl();
|
||||
propagationConstraint.setAddConstraint(AddConstraint.propagate);
|
||||
propagationConstraint.setRemoveConstraint(RemoveConstraint.cascade);
|
||||
|
||||
Uses<EService, EService> uses = new UsesImpl<EService, EService>(smartExecutorEService, runningPlugin, propagationConstraint);
|
||||
EService smartExecutorEService = resourceRegistryClient.getInstance(EService.class, eServiceUUID);
|
||||
PropagationConstraint usesPropagationConstraint = new PropagationConstraintImpl();
|
||||
usesPropagationConstraint.setAddConstraint(AddConstraint.propagate);
|
||||
usesPropagationConstraint.setRemoveConstraint(RemoveConstraint.cascade);
|
||||
|
||||
Uses<EService, EService> uses = new UsesImpl<EService, EService>(smartExecutorEService, runningPlugin, usesPropagationConstraint);
|
||||
try {
|
||||
resourceRegistryPublisher.createIsRelatedTo(uses);
|
||||
} catch (ResourceRegistryException e) {
|
||||
|
@ -78,6 +82,20 @@ public class RestISPublisher extends ISPublisher {
|
|||
throw e;
|
||||
}
|
||||
|
||||
org.gcube.resourcemanagement.model.reference.entities.resources.Plugin pluginResource = null;
|
||||
if(pluginResource!=null) { // The if allows not commenting the following code in the meanwhile the pluginResource retrieving is properly coded
|
||||
PropagationConstraint enablesPropagationConstraint = new PropagationConstraintImpl();
|
||||
enablesPropagationConstraint.setAddConstraint(AddConstraint.propagate);
|
||||
enablesPropagationConstraint.setRemoveConstraint(RemoveConstraint.keep);
|
||||
Enables<Service, Software> enables = new EnablesImpl<Service, Software>(runningPlugin, pluginResource, enablesPropagationConstraint);
|
||||
try {
|
||||
resourceRegistryPublisher.createIsRelatedTo(enables);
|
||||
} catch (ResourceRegistryException e) {
|
||||
logger.error("Unable to publish %s instace %s for plugin %s. I'm going to stop the service.", Resource.NAME, RunningPlugin.NAME, pluginName);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue