git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/branches/information-system/ic-client/1.0@139974 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
063db21917
commit
928c944f07
|
@ -25,16 +25,17 @@ public class Helper {
|
||||||
{
|
{
|
||||||
|
|
||||||
String scope = ScopeProvider.instance.get();
|
String scope = ScopeProvider.instance.get();
|
||||||
|
System.out.println("inside filter");
|
||||||
|
|
||||||
if (scope==null || !new ScopeBean(scope).is(VRE))
|
if (scope==null || !new ScopeBean(scope).is(VRE))
|
||||||
return expression;
|
return expression;
|
||||||
|
System.out.println("filtering");
|
||||||
|
|
||||||
int wherePathIndex=0;
|
int wherePathIndex=0;
|
||||||
int returnPathIndex=0;
|
int returnPathIndex=0;
|
||||||
int collIndexEnd=0;
|
int collIndexEnd=0;
|
||||||
int collIndexStart=0;
|
int collIndexStart=0;
|
||||||
boolean whereFinded=false;
|
boolean whereFound=false;
|
||||||
String forInsertFinal="";
|
String forInsertFinal="";
|
||||||
String whereInsertFinal="";
|
String whereInsertFinal="";
|
||||||
String temp="";
|
String temp="";
|
||||||
|
@ -44,8 +45,8 @@ 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=" (*VAR*/child::*[local-name()='Scope']/text() eq '"+scope+"' or *VAR*/child::*[local-name()='Scope']/text() eq '"+scope.substring(0,scope.lastIndexOf("/"))+"') ";
|
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=" (*VAR*//Scope/text() eq '"+scope+"') ";
|
String authStringNormal=" (functx:is-value-in-sequence('"+scope+"',*VAR*//Scope/text())) ";
|
||||||
|
|
||||||
String queryFiltered;
|
String queryFiltered;
|
||||||
List<Boolean> collInsert= new ArrayList<Boolean>();
|
List<Boolean> collInsert= new ArrayList<Boolean>();
|
||||||
|
@ -134,7 +135,7 @@ public class Helper {
|
||||||
Matcher returnMat=returnPattern.matcher(expression);
|
Matcher returnMat=returnPattern.matcher(expression);
|
||||||
whereMat.reset();
|
whereMat.reset();
|
||||||
returnMat.reset();
|
returnMat.reset();
|
||||||
whereFinded=whereMat.find();
|
whereFound=whereMat.find();
|
||||||
returnMat.find();
|
returnMat.find();
|
||||||
|
|
||||||
try{
|
try{
|
||||||
|
@ -148,7 +149,7 @@ public class Helper {
|
||||||
returnPathIndex=returnMat.start();
|
returnPathIndex=returnMat.start();
|
||||||
}catch(IllegalStateException e){ log.error("error parsing return statement"); throw new MalformedQueryException("error parsing return statement");}
|
}catch(IllegalStateException e){ log.error("error parsing return statement"); throw new MalformedQueryException("error parsing return statement");}
|
||||||
|
|
||||||
if (whereFinded)
|
if (whereFound)
|
||||||
queryFiltered=expression.substring(0,wherePathIndex)+"\nwhere "+whereInsertFinal
|
queryFiltered=expression.substring(0,wherePathIndex)+"\nwhere "+whereInsertFinal
|
||||||
+" and ("+expression.substring(wherePathIndex+5, returnPathIndex)+" ) \n"+expression.substring(returnPathIndex);
|
+" and ("+expression.substring(wherePathIndex+5, returnPathIndex)+" ) \n"+expression.substring(returnPathIndex);
|
||||||
else
|
else
|
||||||
|
@ -162,16 +163,22 @@ public class Helper {
|
||||||
whereMat.reset();
|
whereMat.reset();
|
||||||
whereMat.find();
|
whereMat.find();
|
||||||
|
|
||||||
boolean letFinded=letMat.find(collIndexStart);
|
boolean letFound=letMat.find(collIndexStart);
|
||||||
int letPathIndex=0;
|
int letPathIndex=0;
|
||||||
try{
|
try{
|
||||||
|
|
||||||
wherePathIndex=whereMat.start();
|
wherePathIndex=whereMat.start();
|
||||||
if (letFinded) letPathIndex=letMat.start();
|
if (letFound) letPathIndex=letMat.start();
|
||||||
}catch(IllegalStateException e){ log.error("error parsing let statement"); throw new MalformedQueryException("error parsing let statement");}
|
}catch(IllegalStateException e){ log.error("error parsing let statement"); throw new MalformedQueryException("error parsing let statement");}
|
||||||
|
|
||||||
|
int indexOfFor = queryFiltered.indexOf("for ");
|
||||||
|
|
||||||
if (!letFinded) {
|
String functionContainsDeclaration =" 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 } ; \n";
|
||||||
|
|
||||||
|
queryFiltered = queryFiltered.substring(0,indexOfFor)+functionContainsDeclaration+queryFiltered.substring(indexOfFor);
|
||||||
|
|
||||||
|
if (!letFound) {
|
||||||
queryFiltered=queryFiltered.substring(0,wherePathIndex)+forInsertFinal +queryFiltered.substring(wherePathIndex);
|
queryFiltered=queryFiltered.substring(0,wherePathIndex)+forInsertFinal +queryFiltered.substring(wherePathIndex);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -202,7 +209,7 @@ public class Helper {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
log.trace("submitting filtered query: {}",queryFiltered);
|
log.trace("submitting filtered query: {}",queryFiltered);
|
||||||
|
System.out.println("filtering "+queryFiltered);
|
||||||
return queryFiltered;
|
return queryFiltered;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,10 +9,14 @@ import java.net.URI;
|
||||||
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.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.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.icclient.Helper;
|
||||||
import org.gcube.resources.discovery.icclient.stubs.CollectorStub;
|
import org.gcube.resources.discovery.icclient.stubs.CollectorStub;
|
||||||
|
|
||||||
public class StubClient {
|
public class StubClient {
|
||||||
|
@ -23,18 +27,31 @@ public class StubClient {
|
||||||
//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/devsec");
|
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(ServiceEndpoint.class);
|
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);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
System.out.println(query.expression());
|
System.out.println(query.expression());
|
||||||
String response = proxy.execute(query.expression());
|
String response = proxy.execute(Helper.queryAddAuthenticationControl(query.expression()));
|
||||||
System.err.println(response);
|
System.err.println(response);
|
||||||
}
|
}
|
||||||
catch(SOAPFaultException e) {
|
catch(SOAPFaultException e) {
|
||||||
|
|
Loading…
Reference in New Issue