@ -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" )