59 lines
1.8 KiB
Java
59 lines
1.8 KiB
Java
import it.geosolutions.geonetwork.util.GNSearchRequest;
|
|
|
|
import org.gcube.common.scope.api.ScopeProvider;
|
|
import org.gcube.spatial.data.geonetwork.GeoNetwork;
|
|
import org.gcube.spatial.data.geonetwork.GeoNetworkReader;
|
|
import org.gcube.spatial.data.geonetwork.LoginLevel;
|
|
import org.junit.Test;
|
|
|
|
/**
|
|
*
|
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
|
* Aug 31, 2016
|
|
*/
|
|
public class GeonetworkQueryTest {
|
|
|
|
private String[] scopes = {"/gcube/devsec/devVRE"};
|
|
|
|
private String[] scopesProd = {"/d4science.research-infrastructures.eu"};
|
|
|
|
@Test
|
|
public void getCount() throws Exception{
|
|
try{
|
|
for(String scope:scopes){
|
|
ScopeProvider.instance.set(scope);
|
|
GeoNetworkReader reader=GeoNetwork.get();
|
|
final GNSearchRequest req=new GNSearchRequest();
|
|
// req.addParam("keyword", "Thredds");
|
|
req.addParam(GNSearchRequest.Param.any,"");
|
|
int publicCount=reader.query(req).getCount();
|
|
reader.login(LoginLevel.CKAN);
|
|
int totalCount=reader.query(req).getCount();
|
|
System.out.println("SCOPE "+scope+" found "+totalCount+" (public : "+publicCount+", private :"+(totalCount-publicCount)+")");
|
|
}
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
|
|
// @Test
|
|
public void getCountProd() throws Exception{
|
|
try{
|
|
for(String scope:scopesProd){
|
|
ScopeProvider.instance.set(scope);
|
|
GeoNetworkReader reader=GeoNetwork.get();
|
|
final GNSearchRequest req=new GNSearchRequest();
|
|
// req.addParam("keyword", "Thredds");
|
|
req.addParam(GNSearchRequest.Param.any,"Thredds");
|
|
int publicCount=reader.query(req).getCount();
|
|
reader.login(LoginLevel.SCOPE);
|
|
int totalCount=reader.query(req).getCount();
|
|
System.out.println("SCOPE "+scope+" found "+totalCount+" (public : "+publicCount+", private :"+(totalCount-publicCount)+")");
|
|
}
|
|
}catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|