Lucio Lelii 6 years ago
parent da3f38ed9b
commit bb7c69e897

@ -22,12 +22,12 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>

@ -6,10 +6,10 @@
<artifactId>maven-parent</artifactId>
<version>1.0.0</version>
</parent>
<groupId>org.gcube.resources.discovery</groupId>
<artifactId>ic-client</artifactId>
<version>1.0.3-SNAPSHOT</version>
<version>1.0.4-SNAPSHOT</version>
<name>Information Collector Client</name>
<description>Client API for the Information Collector service</description>
@ -27,23 +27,29 @@
<dependencies>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-scope</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
<groupId>org.gcube.core</groupId>
<artifactId>common-scope</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.resources</groupId>
<artifactId>registry-publisher</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT]</version>
</dependency>
<dependency>
<groupId>org.gcube.resources.discovery</groupId>
<artifactId>discovery-client</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
<groupId>org.gcube.resources.discovery</groupId>
<artifactId>discovery-client</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.resources</groupId>
<artifactId>common-gcore-resources</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-gcore-stubs</artifactId>
@ -62,7 +68,7 @@
<version>1.6.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>

@ -41,8 +41,8 @@ public class Helper {
HashMap<String, String> varReplacementMap = new HashMap<String, String>();
String forPropertiesString="\n *VAR* in *COLLECTION*/Data \n"; ///child::*[local-name()='Scope']
String forString=" *VAR* in *COLLECTION*/Scopes \n";
String forPropertiesString=" *VAR* in *COLLECTION*/Data "; ///child::*[local-name()='Scope']
String forString=" *VAR* in *COLLECTION*/Scopes ";
String authString=" (functx:is-value-in-sequence('"+scope+"',*VAR*/child::*[local-name()='Scope']/text()) or functx:is-value-in-sequence('"+scope.substring(0,scope.lastIndexOf("/"))+"',*VAR*/child::*[local-name()='Scope']/text())) ";
String authStringNormal=" (functx:is-value-in-sequence('"+scope+"',*VAR*/child::*[local-name()='Scope']/text())) ";
@ -148,10 +148,10 @@ public class Helper {
}catch(IllegalStateException e){ log.error("error parsing return statement"); throw new MalformedQueryException("error parsing return statement");}
if (whereFound)
queryFiltered=expression.substring(0,wherePathIndex)+"\nwhere "+whereInsertFinal
+" and ("+expression.substring(wherePathIndex+5, returnPathIndex)+" ) \n"+expression.substring(returnPathIndex);
queryFiltered=expression.substring(0,wherePathIndex)+" where "+whereInsertFinal
+" and ("+expression.substring(wherePathIndex+5, returnPathIndex)+" ) "+expression.substring(returnPathIndex);
else
queryFiltered=expression.substring(0,returnPathIndex)+ "\nwhere "+whereInsertFinal+" \n "+expression.substring(returnPathIndex);
queryFiltered=expression.substring(0,returnPathIndex)+ " where "+whereInsertFinal+" "+expression.substring(returnPathIndex);
//logger.trace("queryFiltered to match: " + queryFiltered);
@ -182,7 +182,7 @@ public class Helper {
String functionContainsDeclaration =" declare namespace functx = \"http://www.functx.com\"; declare function functx:is-value-in-sequence "+
" ( $value as xs:anyAtomicType? , $seq as xs:anyAtomicType* ) as xs:boolean { $value = $seq } ; \n";
" ( $value as xs:anyAtomicType? , $seq as xs:anyAtomicType* ) as xs:boolean { $value = $seq } ; ";
Pattern declarePattern=Pattern.compile("(\\s*declare namespace[^;]*;)*");
Matcher declareMat=declarePattern.matcher(queryFiltered);

@ -11,13 +11,16 @@ import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlRootElement;
import org.gcube.common.resources.gcore.GCoreEndpoint;
import org.gcube.common.resources.gcore.GenericResource;
import org.gcube.common.resources.gcore.ServiceEndpoint;
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
import org.gcube.common.resources.gcore.ServiceInstance;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.Query;
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
import org.gcube.resources.discovery.client.queries.impl.XQuery;
import org.gcube.resources.discovery.icclient.ICFactory;
import org.junit.BeforeClass;
import org.junit.Test;
@ -47,6 +50,22 @@ public class APIClient {
}
@Test
public void testThredds() throws Exception{
ScopeProvider.instance.set("/gcube/devNext/NextNext");
SimpleQuery query = queryFor(GCoreEndpoint.class);
query.addCondition("$resource/Profile/ServiceClass/string() eq 'DataAccess' ");
query.setResult("$resource/Profile/ServiceName/text()");
DiscoveryClient<String> client = client();
List<String> resources = client.submit(query);
if (resources==null || resources.size()==0){
throw new Exception("No resource named StatisticalManagerAlgorithm available in scope ");
}
System.out.println("found resources "+resources.size());
}
@Test
public void someServiceEndpoints() {

@ -5,6 +5,9 @@ import static org.gcube.resources.discovery.icclient.stubs.CollectorConstants.co
import static org.gcube.resources.discovery.icclient.stubs.CollectorConstants.localname;
import java.net.URI;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
@ -13,10 +16,17 @@ import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.ws.soap.SOAPFaultException;
import org.gcube.common.clients.stubs.jaxws.JAXWSUtils;
import org.gcube.common.resources.gcore.GCoreEndpoint;
import org.gcube.common.resources.gcore.GenericResource;
import org.gcube.common.resources.gcore.Resource;
import org.gcube.common.resources.gcore.ServiceEndpoint;
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.common.scope.api.ServiceMap;
import org.gcube.common.scope.impl.ScopeBean;
import org.gcube.common.scope.impl.ScopeBean.Type;
import org.gcube.informationsystem.publisher.RegistryPublisher;
import org.gcube.informationsystem.publisher.RegistryPublisherFactory;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.Query;
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
@ -28,6 +38,9 @@ import org.junit.Test;
public class StubClient {
final static List<String> voDevScopes = Arrays.asList("/gcube","/gcube/devsec","/gcube/devNext","/gcube/preprod");
final static List<String> voProdScopes = Arrays.asList("/d4science.research-infrastructures.eu","/d4science.research-infrastructures.eu/SoBigData", "/d4science.research-infrastructures.eu/FARM","/d4science.research-infrastructures.eu/gCubeApps", "/d4science.research-infrastructures.eu/D4Research",
"/d4science.research-infrastructures.eu/OpenAIRE","/d4science.research-infrastructures.eu/SmartArea");
public static void main(String[] args) throws Exception {
@ -63,22 +76,52 @@ public class StubClient {
}
}
@Test
public void accessPointQuery(){
public void synchResourceOnAllScopes(){
accessPointQuery(voProdScopes, "00502ca0-f9b4-11e2-ae96-bc1961394f34", ServiceEndpoint.class);
}
private <T extends Resource> void accessPointQuery(List<String> voScopes, String resourceID, Class<T> resourceType){
String currentScope = voScopes.get(0);
ScopeProvider.instance.set(currentScope);
SimpleQuery query = ICFactory.queryFor(resourceType);
DiscoveryClient<T> client = ICFactory.clientFor(resourceType);
query.addCondition("$resource/ID/text() = '"+resourceID+"'");
T resource = client.submit(query).get(0);
HashSet<String> scopeSet = new HashSet<String>();
SimpleQuery queryVRE = ICFactory.queryFor(GenericResource.class);
queryVRE.addCondition("$resource/Profile/SecondaryType/text() = 'VRE'");
queryVRE.setResult("$resource/Profile/Body/Scope/string()");
DiscoveryClient<String> vREScopeClient = ICFactory.client();
scopeSet.addAll(voScopes);
for (String scope: voScopes){
ScopeProvider.instance.set(scope);
List<String> vresscope = vREScopeClient.submit(queryVRE);
System.out.println("vres found "+vresscope.size()+ " in "+scope);
scopeSet.addAll(vresscope);
}
ScopeProvider.instance.set(currentScope);
resource.scopes().asCollection().retainAll(Collections.emptyList());
resource.scopes().asCollection().addAll(scopeSet);
ScopeProvider.instance.set(currentScope);
RegistryPublisher pub = RegistryPublisherFactory.create();
pub.vosUpdate(resource);
ScopeProvider.instance.set("/d4science.research-infrastructures.eu/gCubeApps/ForkysVRE");
SimpleQuery query = ICFactory.queryFor(ServiceEndpoint.class);
query.addCondition("$resource/Profile/Name/text() eq 'DataMiner'");
query.addCondition("$resource/Profile/AccessPoint/Description/text() ne 'GetCapabilities'");
query.setResult("<accesspoint>{$resource/Profile}</accesspoint>");
System.out.println(query.toString());
DiscoveryClient<String> client = ICFactory.client();
//this should return at least one AccessPoint, but it doesn't anymore
List<String> results = client.submit(query);
for (String ap: results)
System.out.println(ap.toString());
}
@XmlRootElement(name = "accesspoint")

Loading…
Cancel
Save