gcore endpoint discovering fixed #11094

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/gcube-ckan-datacatalog@162981 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2018-02-06 15:56:42 +00:00
parent e2aeb45c25
commit d2f3d17da5
2 changed files with 8 additions and 12 deletions

View File

@ -7,6 +7,9 @@
<dependent-module archiveName="grsf-manage-widget-1.3.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/grsf-manage-widget/grsf-manage-widget"> <dependent-module archiveName="grsf-manage-widget-1.3.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/grsf-manage-widget/grsf-manage-widget">
<dependency-type>uses</dependency-type> <dependency-type>uses</dependency-type>
</dependent-module> </dependent-module>
<dependent-module archiveName="grsf-common-library-1.0.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/grsf-common-library/grsf-common-library">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="context-root" value="gcube-ckan-datacatalog"/> <property name="context-root" value="gcube-ckan-datacatalog"/>
<property name="java-output-path" value="/gcube-ckan-datacatalog/target/gcube-ckan-datacatalog-1.0.0-SNAPSHOT/WEB-INF/classes"/> <property name="java-output-path" value="/gcube-ckan-datacatalog/target/gcube-ckan-datacatalog-1.0.0-SNAPSHOT/WEB-INF/classes"/>
</wb-module> </wb-module>

View File

@ -29,9 +29,7 @@ public class GcoreEndpointReader implements Serializable{
private static final String ckanResource = "org.gcube.data.access.ckanconnector.CkanConnector"; private static final String ckanResource = "org.gcube.data.access.ckanconnector.CkanConnector";
private static final String serviceName = "CkanConnector"; private static final String serviceName = "CkanConnector";
private static final String serviceClass = "DataAccess"; private static final String serviceClass = "DataAccess";
private static final Log logger = LogFactoryUtil.getLog(GcoreEndpointReader.class); private static final Log logger = LogFactoryUtil.getLog(GcoreEndpointReader.class);
//private static Logger logger = LoggerFactory.getLogger(GcoreEndpointReader.class);
private String ckanResourceEntyName; private String ckanResourceEntyName;
/** /**
@ -52,14 +50,17 @@ public class GcoreEndpointReader implements Serializable{
query.addCondition(String.format("$resource/Profile/ServiceClass/text() eq '%s'",serviceClass)); query.addCondition(String.format("$resource/Profile/ServiceClass/text() eq '%s'",serviceClass));
query.addCondition("$resource/Profile/DeploymentData/Status/text() eq 'ready'"); query.addCondition("$resource/Profile/DeploymentData/Status/text() eq 'ready'");
query.addCondition(String.format("$resource/Profile/ServiceName/text() eq '%s'",serviceName)); query.addCondition(String.format("$resource/Profile/ServiceName/text() eq '%s'",serviceName));
query.addCondition(String.format("$resource/Scopes/Scope/text()[.='%s']", scope)); // i.e. check the resource contains among the scopes this one
query.setResult("$resource/Profile/AccessPoint/RunningInstanceInterfaces//Endpoint[@EntryName/string() eq \""+ckanResource+"\"]/text()"); query.setResult("$resource/Profile/AccessPoint/RunningInstanceInterfaces//Endpoint[@EntryName/string() eq \""+ckanResource+"\"]/text()");
logger.debug("submitting quey "+query.toString()); logger.debug("submitting quey "+query.toString());
DiscoveryClient<String> client = client(); DiscoveryClient<String> client = client();
List<String> endpoints = client.submit(query); List<String> endpoints = client.submit(query);
if (endpoints == null || endpoints.isEmpty()) throw new Exception("Cannot retrieve the GCoreEndpoint serviceName: "+serviceName +", serviceClass: " +serviceClass +", in scope: "+scope); if (endpoints == null || endpoints.isEmpty())
throw new Exception("Cannot retrieve the GCoreEndpoint serviceName: "+serviceName +", serviceClass: " +serviceClass +", in scope: "+scope);
logger.debug("Found " + endpoints.size() + " matching resources");
this.ckanResourceEntyName = endpoints.get(0); this.ckanResourceEntyName = endpoints.get(0);
if(ckanResourceEntyName==null) if(ckanResourceEntyName==null)
@ -67,15 +68,6 @@ public class GcoreEndpointReader implements Serializable{
logger.info("found entyname "+ckanResourceEntyName+" for ckanResource: "+ckanResource); logger.info("found entyname "+ckanResourceEntyName+" for ckanResource: "+ckanResource);
/*Group<Endpoint> accessPoints = se.profile().endpoints();
if(accessPoints.size()==0) throw new Exception("Endpoint in serviceName serviceName: "+serviceName +", serviceClass: " +serviceClass +", in scope: "+scope +" not found");
Endpoint ep = accessPoints.iterator().next();
String epName = ep.name();
System.out.println(epName);*/
}catch(Exception e){ }catch(Exception e){
String error = "An error occurred during GCoreEndpoint discovery, serviceName: "+serviceName +", serviceClass: " +serviceClass +", in scope: "+scope +"."; String error = "An error occurred during GCoreEndpoint discovery, serviceName: "+serviceName +", serviceClass: " +serviceClass +", in scope: "+scope +".";
logger.error(error, e); logger.error(error, e);
@ -93,4 +85,5 @@ public class GcoreEndpointReader implements Serializable{
return ckanResourceEntyName; return ckanResourceEntyName;
} }
} }