From 8c12cbf66077acc36b141842545c9ad51a6e59fe Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Fri, 28 Aug 2015 12:21:19 +0000 Subject: [PATCH] Added targetScope on query and ICClient git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/vre-management/smart-executor@117729 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../persistence/SmartExecutorPersistenceConfiguration.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/org/gcube/vremanagement/executor/persistence/SmartExecutorPersistenceConfiguration.java b/src/main/java/org/gcube/vremanagement/executor/persistence/SmartExecutorPersistenceConfiguration.java index 0c4326e..0a17a1e 100644 --- a/src/main/java/org/gcube/vremanagement/executor/persistence/SmartExecutorPersistenceConfiguration.java +++ b/src/main/java/org/gcube/vremanagement/executor/persistence/SmartExecutorPersistenceConfiguration.java @@ -15,6 +15,7 @@ import org.gcube.common.resources.gcore.ServiceEndpoint; import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint; import org.gcube.common.resources.gcore.ServiceEndpoint.Property; import org.gcube.common.resources.gcore.utils.Group; +import org.gcube.common.scope.api.ScopeProvider; import org.gcube.resources.discovery.client.api.DiscoveryClient; import org.gcube.resources.discovery.client.queries.api.SimpleQuery; import org.gcube.resources.discovery.icclient.ICFactory; @@ -28,6 +29,7 @@ public class SmartExecutorPersistenceConfiguration { public final String SERVICE_ENDPOINT_NAME = "SmartExecutor"; protected static final String PERSISTENCE_CLASS_NAME = "persistenceClassName"; + protected static final String TARGET_SCOPE = "targetScope"; protected URI uri; protected String username; @@ -121,6 +123,11 @@ public class SmartExecutorPersistenceConfiguration { DiscoveryClient client = ICFactory.clientFor(ServiceEndpoint.class); List serviceEndpoints = client.submit(query); + if(serviceEndpoints.size()>1){ + query.addCondition(String.format("$resource/Profile/AccessPoint/Properties/Property/Name/text() eq '%s'", TARGET_SCOPE)); + query.addCondition(String.format("$resource/Profile/AccessPoint/Properties/Property/Value/text() eq '%s'", ScopeProvider.instance.get())); + serviceEndpoints = client.submit(query); + } return serviceEndpoints.get(0); }