2013-01-08 09:15:10 +01:00
|
|
|
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 java.net.URI;
|
|
|
|
|
|
|
|
import javax.xml.ws.soap.SOAPFaultException;
|
|
|
|
|
|
|
|
import org.gcube.common.clients.stubs.jaxws.JAXWSUtils;
|
2016-12-13 14:13:16 +01:00
|
|
|
import org.gcube.common.resources.gcore.GCoreEndpoint;
|
2013-01-08 09:15:10 +01:00
|
|
|
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
|
|
|
import org.gcube.common.scope.api.ScopeProvider;
|
|
|
|
import org.gcube.common.scope.api.ServiceMap;
|
2016-12-13 14:13:16 +01:00
|
|
|
import org.gcube.resources.discovery.client.queries.api.Query;
|
2013-01-08 09:15:10 +01:00
|
|
|
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
2016-12-13 14:13:16 +01:00
|
|
|
import org.gcube.resources.discovery.client.queries.impl.QueryBox;
|
|
|
|
import org.gcube.resources.discovery.icclient.Helper;
|
2013-01-08 09:15:10 +01:00
|
|
|
import org.gcube.resources.discovery.icclient.stubs.CollectorStub;
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2016-12-13 14:13:16 +01:00
|
|
|
ScopeProvider.instance.set("/gcube/devNext/NextNext");
|
2013-01-08 09:15:10 +01:00
|
|
|
|
|
|
|
String address = ServiceMap.instance.endpoint(localname);
|
|
|
|
|
|
|
|
CollectorStub proxy = stubFor(collector).at(URI.create(address));
|
|
|
|
|
2016-12-13 20:03:00 +01:00
|
|
|
//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";
|
2016-12-13 14:13:16 +01:00
|
|
|
|
2016-12-13 20:03:00 +01:00
|
|
|
Query query = new QueryBox(queryString);
|
2016-12-13 14:13:16 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2013-01-08 09:15:10 +01:00
|
|
|
try {
|
|
|
|
|
|
|
|
System.out.println(query.expression());
|
2016-12-13 14:13:16 +01:00
|
|
|
String response = proxy.execute(Helper.queryAddAuthenticationControl(query.expression()));
|
2013-01-08 09:15:10 +01:00
|
|
|
System.err.println(response);
|
|
|
|
}
|
|
|
|
catch(SOAPFaultException e) {
|
|
|
|
throw new RuntimeException(JAXWSUtils.remoteCause(e));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|