Lucio Lelii 2017-02-13 10:23:16 +00:00
parent 997eb495d0
commit cf66da32c7
6 changed files with 67 additions and 22 deletions

View File

@ -2,7 +2,10 @@
<Changeset component="ic-client-1.0.0" date="2013-01-11">
<Change>First Release</Change>
</Changeset>
<Changeset component="${build.finalName}" date="2013-06-05">
<Changeset component="ic-client-1.0.0" date="2013-06-05">
<Change>fixed defect #1825</Change>
</Changeset>
<Changeset component="${build.finalName}" date="2016-12-13">
<Change>fixed defect #1825</Change>
</Changeset>
</ReleaseNotes>

View File

@ -9,7 +9,7 @@
<groupId>org.gcube.resources.discovery</groupId>
<artifactId>ic-client</artifactId>
<version>1.0.2-SNAPSHOT</version>
<version>1.0.3-SNAPSHOT</version>
<name>Information Collector Client</name>
<description>Client API for the Information Collector service</description>

View File

@ -44,7 +44,7 @@ public class Helper {
String forPropertiesString="\n *VAR* in *COLLECTION*/Data \n"; ///child::*[local-name()='Scope']
String forString=" *VAR* in *COLLECTION*/Scopes \n";
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*//Scope/text())) ";
String authStringNormal=" (functx:is-value-in-sequence('"+scope+"',*VAR*/child::*[local-name()='Scope']/text())) ";
String queryFiltered;
List<Boolean> collInsert= new ArrayList<Boolean>();
@ -195,7 +195,11 @@ public class Helper {
} else
queryFiltered= functionContainsDeclaration +queryFiltered;
log.trace("submitting filtered query: {}",queryFiltered);
queryFiltered = queryFiltered.replaceAll("text() ne ","text() != ");
log.info("submitting filtered query: {}",queryFiltered);
return queryFiltered;
}

View File

@ -72,7 +72,7 @@ public class ICClient implements DiscoveryClient<String> {
//find endpoint address in service map currently in scope
String address = ServiceMap.instance.endpoint(localname);
log.info("connectinfg to "+address);
//obtain a JAXWS stub configured for gCube calls
return stubFor(collector).at(URI.create(address));
}

View File

@ -26,7 +26,7 @@ public class APIClient {
@BeforeClass
public static void setup() {
ScopeProvider.instance.set("/gcube/devNext/devVre");
ScopeProvider.instance.set("/gcube/devNext");
}

View File

@ -1,50 +1,57 @@
package org.acme;
import static org.gcube.common.clients.stubs.jaxws.StubFactory.*;
import static org.gcube.resources.discovery.icclient.ICFactory.*;
import static org.gcube.resources.discovery.icclient.stubs.CollectorConstants.*;
import static org.gcube.common.clients.stubs.jaxws.StubFactory.stubFor;
import static org.gcube.resources.discovery.icclient.stubs.CollectorConstants.collector;
import static org.gcube.resources.discovery.icclient.stubs.CollectorConstants.localname;
import java.net.URI;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementRef;
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.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.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.QueryBox;
import org.gcube.resources.discovery.icclient.Helper;
import org.gcube.resources.discovery.icclient.ICFactory;
import org.gcube.resources.discovery.icclient.stubs.CollectorStub;
import org.junit.Test;
public class StubClient {
public static void main(String[] args) throws Exception {
//when needed, setup tcpmon and decomment to see messages on the wire for debugging purposes
//StubFactory.setProxy("localhost", 8081);
ScopeProvider.instance.set("/gcube/devNext/NextNext");
String address = ServiceMap.instance.endpoint(localname);
CollectorStub proxy = stubFor(collector).at(URI.create(address));
//SimpleQuery query = queryFor(GCoreEndpoint.class);
String queryString ="declare namespace ic = 'http://gcube-system.org/namespaces/informationsystem/registry'; "+
"for $profiles in collection('/db/Profiles/GenericResource')//Document/Data/ic:Profile/Resource "+
" let $scopes := string-join( $profiles/Scopes//Scope/text(), ';') "+
" let $subtype := $profiles/Profile/SecondaryType/text() "+
" return $profiles";
"for $profiles in collection('/db/Profiles/GenericResource')//Document/Data/ic:Profile/Resource "+
" let $scopes := string-join( $profiles/Scopes//Scope/text(), ';') "+
" let $subtype := $profiles/Profile/SecondaryType/text() "+
" return $profiles";
Query query = new QueryBox(queryString);
try {
System.out.println(query.expression());
@ -56,4 +63,35 @@ public class StubClient {
}
}
@Test
public void accessPointQuery(){
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() != '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")
static class AccessPointResult {
@XmlElement(name = "id")
String id;
@XmlElementRef
AccessPoint ap;
@Override
public String toString() {
return "AccessPointResult [id=" + id + ", ap=" + ap + "]";
}
}
}