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 14:13:16 +01:00
SimpleQuery query = queryFor ( GCoreEndpoint . class ) ;
/ *
String queryString = " declare namespace ic = 'http://gcube-system.org/namespaces/informationsystem/registry'; 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 } ; " ;
queryString + = " for $entry0ValueAuth in collection('/db/Profiles/RunningInstance')//Document/Data/ic:Profile/Resource/Scopes " +
" where functx:is-value-in-sequence('/gcube/devNext/NextNext',$entry0ValueAuth/child::*[local-name()='Scope']/text()) or functx:is-value-in-sequence('/gcube/devNext',$entry0ValueAuth/child::*[local-name()='Scope']/text()) and ( ($entry0ValueAuth/../Profile/ServiceClass/text() eq 'DataAccess') and ($entry0ValueAuth/../Profile/DeploymentData/Status/text() eq 'ready') and ($entry0ValueAuth/../Profile/ServiceName/text() eq 'CkanConnector') ) " +
" return $entry0ValueAuth/../Profile/AccessPoint/RunningInstanceInterfaces//Endpoint[@EntryName/string() eq \" org.gcube.data.access.ckanconnector.CkanConnector \" ]/text() " ;
* /
//Query query = new QueryBox(queryString);
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 ) ) ;
}
}
}