git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/branches/information-system/ic-client/1.0@142489 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
997eb495d0
commit
cf66da32c7
|
@ -2,7 +2,10 @@
|
||||||
<Changeset component="ic-client-1.0.0" date="2013-01-11">
|
<Changeset component="ic-client-1.0.0" date="2013-01-11">
|
||||||
<Change>First Release</Change>
|
<Change>First Release</Change>
|
||||||
</Changeset>
|
</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>
|
<Change>fixed defect #1825</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
</ReleaseNotes>
|
</ReleaseNotes>
|
2
pom.xml
2
pom.xml
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
<groupId>org.gcube.resources.discovery</groupId>
|
<groupId>org.gcube.resources.discovery</groupId>
|
||||||
<artifactId>ic-client</artifactId>
|
<artifactId>ic-client</artifactId>
|
||||||
<version>1.0.2-SNAPSHOT</version>
|
<version>1.0.3-SNAPSHOT</version>
|
||||||
<name>Information Collector Client</name>
|
<name>Information Collector Client</name>
|
||||||
<description>Client API for the Information Collector service</description>
|
<description>Client API for the Information Collector service</description>
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class Helper {
|
||||||
String forPropertiesString="\n *VAR* in *COLLECTION*/Data \n"; ///child::*[local-name()='Scope']
|
String forPropertiesString="\n *VAR* in *COLLECTION*/Data \n"; ///child::*[local-name()='Scope']
|
||||||
String forString=" *VAR* in *COLLECTION*/Scopes \n";
|
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 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;
|
String queryFiltered;
|
||||||
List<Boolean> collInsert= new ArrayList<Boolean>();
|
List<Boolean> collInsert= new ArrayList<Boolean>();
|
||||||
|
@ -195,7 +195,11 @@ public class Helper {
|
||||||
} else
|
} else
|
||||||
queryFiltered= functionContainsDeclaration +queryFiltered;
|
queryFiltered= functionContainsDeclaration +queryFiltered;
|
||||||
|
|
||||||
log.trace("submitting filtered query: {}",queryFiltered);
|
queryFiltered = queryFiltered.replaceAll("text() ne ","text() != ");
|
||||||
|
|
||||||
|
log.info("submitting filtered query: {}",queryFiltered);
|
||||||
|
|
||||||
|
|
||||||
return queryFiltered;
|
return queryFiltered;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class ICClient implements DiscoveryClient<String> {
|
||||||
|
|
||||||
//find endpoint address in service map currently in scope
|
//find endpoint address in service map currently in scope
|
||||||
String address = ServiceMap.instance.endpoint(localname);
|
String address = ServiceMap.instance.endpoint(localname);
|
||||||
|
log.info("connectinfg to "+address);
|
||||||
//obtain a JAXWS stub configured for gCube calls
|
//obtain a JAXWS stub configured for gCube calls
|
||||||
return stubFor(collector).at(URI.create(address));
|
return stubFor(collector).at(URI.create(address));
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class APIClient {
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setup() {
|
public static void setup() {
|
||||||
|
|
||||||
ScopeProvider.instance.set("/gcube/devNext/devVre");
|
ScopeProvider.instance.set("/gcube/devNext");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,50 +1,57 @@
|
||||||
package org.acme;
|
package org.acme;
|
||||||
|
|
||||||
import static org.gcube.common.clients.stubs.jaxws.StubFactory.*;
|
import static org.gcube.common.clients.stubs.jaxws.StubFactory.stubFor;
|
||||||
import static org.gcube.resources.discovery.icclient.ICFactory.*;
|
import static org.gcube.resources.discovery.icclient.stubs.CollectorConstants.collector;
|
||||||
import static org.gcube.resources.discovery.icclient.stubs.CollectorConstants.*;
|
import static org.gcube.resources.discovery.icclient.stubs.CollectorConstants.localname;
|
||||||
|
|
||||||
import java.net.URI;
|
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 javax.xml.ws.soap.SOAPFaultException;
|
||||||
|
|
||||||
import org.gcube.common.clients.stubs.jaxws.JAXWSUtils;
|
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;
|
||||||
|
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.common.scope.api.ServiceMap;
|
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.Query;
|
||||||
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||||||
import org.gcube.resources.discovery.client.queries.impl.QueryBox;
|
import org.gcube.resources.discovery.client.queries.impl.QueryBox;
|
||||||
import org.gcube.resources.discovery.icclient.Helper;
|
import org.gcube.resources.discovery.icclient.Helper;
|
||||||
|
import org.gcube.resources.discovery.icclient.ICFactory;
|
||||||
import org.gcube.resources.discovery.icclient.stubs.CollectorStub;
|
import org.gcube.resources.discovery.icclient.stubs.CollectorStub;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
public class StubClient {
|
public class StubClient {
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
|
||||||
//when needed, setup tcpmon and decomment to see messages on the wire for debugging purposes
|
//when needed, setup tcpmon and decomment to see messages on the wire for debugging purposes
|
||||||
//StubFactory.setProxy("localhost", 8081);
|
//StubFactory.setProxy("localhost", 8081);
|
||||||
|
|
||||||
ScopeProvider.instance.set("/gcube/devNext/NextNext");
|
ScopeProvider.instance.set("/gcube/devNext/NextNext");
|
||||||
|
|
||||||
String address = ServiceMap.instance.endpoint(localname);
|
String address = ServiceMap.instance.endpoint(localname);
|
||||||
|
|
||||||
CollectorStub proxy = stubFor(collector).at(URI.create(address));
|
CollectorStub proxy = stubFor(collector).at(URI.create(address));
|
||||||
|
|
||||||
//SimpleQuery query = queryFor(GCoreEndpoint.class);
|
//SimpleQuery query = queryFor(GCoreEndpoint.class);
|
||||||
|
|
||||||
String queryString ="declare namespace ic = 'http://gcube-system.org/namespaces/informationsystem/registry'; "+
|
String queryString ="declare namespace ic = 'http://gcube-system.org/namespaces/informationsystem/registry'; "+
|
||||||
"for $profiles in collection('/db/Profiles/GenericResource')//Document/Data/ic:Profile/Resource "+
|
"for $profiles in collection('/db/Profiles/GenericResource')//Document/Data/ic:Profile/Resource "+
|
||||||
" let $scopes := string-join( $profiles/Scopes//Scope/text(), ';') "+
|
" let $scopes := string-join( $profiles/Scopes//Scope/text(), ';') "+
|
||||||
" let $subtype := $profiles/Profile/SecondaryType/text() "+
|
" let $subtype := $profiles/Profile/SecondaryType/text() "+
|
||||||
" return $profiles";
|
" return $profiles";
|
||||||
|
|
||||||
Query query = new QueryBox(queryString);
|
Query query = new QueryBox(queryString);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
System.out.println(query.expression());
|
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 + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue