Difference between revisions of "DIS-HLS-Client"

From Gcube Wiki
Jump to: navigation, search
(How to adapt the existing xQuery to eXist 1.1)
 
(13 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 +
[[Category:TO BE REMOVED]]
 +
 
=== Introduction ===
 
=== Introduction ===
  
The DIS-HLSClient is a Java library that allows to query the DIS in order to retrieve any information handled there (i.e. WS-ResourceProperties and DILIGENT resource profiles). The latest version of the library is composed by a set of Managers, one per each logical section of the information your service wants to query. By requesting the appropriate Manager (like the ones for DHNs data or the WS-ResourceProperties), it is possible to query the a subset of the information available with better performances than the previous versions. However, a generic Manager is also available to perform queries on the whole information available on the DIS. It is of course less efficient w.r.t. the specialized ones since, of course, it queries a bigger set of data.
+
The IS-Client is a Java library that allows to query the IS in order to retrieve any information handled there.
 
+
Another thing to keep in mind when dealing with the DIS-HLSClient is the secure or non secure context. Each method of the library accepts two parameters (in addition to the others): a parameter instance of org.gridforum.jgss.ExtendedGSSCredential and a parameter instance of org.apache.axis.message.addressing.EndpointReferenceType. If a service is acting in a secure DL, then it has to pass to each method of the library the credentials it is actually using to contact other secure services. By analysing such credentials, the DIS-HLSClient is able to understand the DL in which the service is actually acting on and therefore appropriately filters the queries in order to retrieve only the information belonging to that DL. On the other hand, if a service is acting in a non secure DL, it has to pass its current EndPointReference from which the DIS-HLSClient understands the DL and, again, filters the queries by minding on the DL context.
+
 
+
=== Implentation Overview ===
+
  
The DISHLSClient is a static class that allows to instance a Manager for each type of DILIGENT resource. In addiction to the 11 DILIGENT resource Managers have been implemented a PropertiesManager, to query for WS-Resource Properties and a GeneralQueryManager that contains methods that apply to all type of Resource. Moreover a DISBrokerManager has been implemented: it contains method to contact the DIS-Broker instance for the VO and let the client subscribe to topics.
+
=== Implementation Overview ===
  
The Managers that have been implemented are :
+
The IS-Client implements a set of query to retrieve the GCube Resources.
 +
The implemented queries are separated in two category: Profile and WS-ResourceProperties.
 +
Query on profiles returns a
  
* '''CollectionManager'''
+
* '''GCUBECollectionQuery'''
 
*''' CSInstanceManager '''  
 
*''' CSInstanceManager '''  
 
* '''CSManager '''  
 
* '''CSManager '''  
Line 28: Line 28:
 
The Source Javadoc documentation can be found here  
 
The Source Javadoc documentation can be found here  
 
[[http://dlib-services.isti.cnr.it/DILIGENT/software/DIS-docs/dis-hlsclient/beta/doc/]]
 
[[http://dlib-services.isti.cnr.it/DILIGENT/software/DIS-docs/dis-hlsclient/beta/doc/]]
 
  
 
=== VO selection and DL context filtering ===
 
=== VO selection and DL context filtering ===
  
All DISHLSClient Query Managers has to be created a parameter instance of org.gridforum.jgss.ExtendedGSSCredential and a parameter instance of org.apache.axis.message.addressing.EndpointReferenceType. At Query Manager creation time, the ExtendedGSSCredential object is checked and using Authorization API the current VO and DL are extracted:
+
All DISHLSClient Query Managers has to be created a parameter instance of org.gridforum.jgss.ExtendedGSSCredential and a parameter instance of org.apache.axis.message.addressing.EndpointReferenceType. At Query Manager creation time, the ExtendedGSSCredential object is checked and using Authentication API the current VO and DL are extracted:
  
 
*  the VO is used to select the right VOMap to use (that contains the addresses of the DIS-IC instances to contact)  
 
*  the VO is used to select the right VOMap to use (that contains the addresses of the DIS-IC instances to contact)  
Line 45: Line 44:
 
The Filter over DL context is not applied queryng for a Service Profile ( that is not related to a particular DL).  
 
The Filter over DL context is not applied queryng for a Service Profile ( that is not related to a particular DL).  
  
An xQuery parsers has also been implemented to set automatically filters to Custom xQuery ( Queries created by developers  
+
An xQuery parsers has also been implemented to set automatically filters to Custom xQuery ( Queries created by developers
  
 
=== Dependencies ===
 
=== Dependencies ===
Line 61: Line 60:
 
=== Usage Examples ===
 
=== Usage Examples ===
  
In order to test DIS-HLS-Client without credentials and EPR, it'possible to create a manager with null parameters. By default the query will be sent to the diligent VO ( the DIS-IC deployed for it) without DL restrictions.
+
In order to test DIS-HLS-Client without credentials and EPR, it'possible to create a manager with null parameters. By default, the queries will be sent to the diligent VO (i.e. to the DIS-IC instance deployed with its scope) without any DL restriction.
  
  
Line 84: Line 83:
 
String test= null;
 
String test= null;
 
try {
 
try {
       riManager.getEPRsRIFromClassAndName("InformationSystem", "DIS-Registry", "dililigentproject/informationservice/disregistry/DISRegistryFactoryService", null,null);
+
       riManager.getEPRsRIFromClassAndName("InformationSystem", "DIS-Registry",  
 +
"dililigentproject/informationservice/disregistry/DISRegistryFactoryService", null,null);
 
       test= pMan.getAllPublishedEntries(cred, null);
 
       test= pMan.getAllPublishedEntries(cred, null);
 
} catch (DISHLSClientException e) {
 
} catch (DISHLSClientException e) {
Line 95: Line 95:
 
</pre>
 
</pre>
  
It's possible ( like the version alpha of the componet) prepare and execute a custom xQuery.  
+
It's possible (like the Alpha version of the component) to prepare and execute a custom xQuery.  
  
 
<pre>
 
<pre>
Line 134: Line 134:
 
reader = new VOMSAttributesReader(JaasSubject.getCurrentSubject(),MessageContext.getCurrentContext());
 
reader = new VOMSAttributesReader(JaasSubject.getCurrentSubject(),MessageContext.getCurrentContext());
 
} catch (DVOSException e) {
 
} catch (DVOSException e) {
// TODO Auto-generated catch block
 
 
e.printStackTrace();
 
e.printStackTrace();
 
} catch (IOException e) {
 
} catch (IOException e) {
// TODO Auto-generated catch block
 
 
e.printStackTrace();
 
e.printStackTrace();
 
}
 
}
Line 150: Line 148:
 
manager = DISHLSClient.getGeneralQueryManager(creds, null);
 
manager = DISHLSClient.getGeneralQueryManager(creds, null);
 
} catch (DISHLSClientException e) {
 
} catch (DISHLSClientException e) {
// TODO Auto-generated catch block
 
 
e.printStackTrace();
 
e.printStackTrace();
 
}
 
}
Line 157: Line 154:
 
result = manager.queryDISIC(customXquery, creds, null);
 
result = manager.queryDISIC(customXquery, creds, null);
 
} catch (DISHLSClientException e) {
 
} catch (DISHLSClientException e) {
// TODO Auto-generated catch block
 
 
e.printStackTrace();
 
e.printStackTrace();
 
} catch (DISHLSCredentialException e) {
 
} catch (DISHLSCredentialException e) {
// TODO Auto-generated catch block
 
 
e.printStackTrace();
 
e.printStackTrace();
 
}
 
}
Line 186: Line 181:
  
 
   [namespace-uri()="*NAMESPACE*"]  ==> [namespace-uri(.)="*NAMESPACE*"]
 
   [namespace-uri()="*NAMESPACE*"]  ==> [namespace-uri(.)="*NAMESPACE*"]
 +
 +
 
 +
*  to check value of a node
 +
 +
  where $doc/Profile[ServiceName ='Name']  ==> where $doc/Profile[ServiceName/string() eq 'Name']
 +
 +
* the contains function has also to include string() method
 +
 +
  contains($doc/Profile/Name,'Operator')==> contains($doc/Profile/Name/string(),'Operator')
  
 
--[[User:Andrea|Andrea]] 14:08, 19 March 2007 (EET)
 
--[[User:Andrea|Andrea]] 14:08, 19 March 2007 (EET)

Latest revision as of 18:55, 6 July 2016


Introduction

The IS-Client is a Java library that allows to query the IS in order to retrieve any information handled there.

Implementation Overview

The IS-Client implements a set of query to retrieve the GCube Resources. The implemented queries are separated in two category: Profile and WS-ResourceProperties. Query on profiles returns a

  • GCUBECollectionQuery
  • CSInstanceManager
  • CSManager
  • DHNManager
  • DISBrokerManager
  • ExternalRunningInstanceManager
  • GeneralQueryManager
  • GLiteManager
  • MetadataCollectionManager
  • PropertiesManager
  • RunningInstanceManager
  • ServiceManager
  • TransformationProgramManager


The Source Javadoc documentation can be found here [[1]]

VO selection and DL context filtering

All DISHLSClient Query Managers has to be created a parameter instance of org.gridforum.jgss.ExtendedGSSCredential and a parameter instance of org.apache.axis.message.addressing.EndpointReferenceType. At Query Manager creation time, the ExtendedGSSCredential object is checked and using Authentication API the current VO and DL are extracted:

  • the VO is used to select the right VOMap to use (that contains the addresses of the DIS-IC instances to contact)
  • the DL is used to filter queries towards DILIGENT Profiles and WS-Resources.

If the ExtendedGSSCredential object passed at Manager creation time is null, the EndpointReferenceType instance is checked to extract VO and DL information. The use of the EndpointReferenceType to check the Running Instance DL context, can be done only if the Running Instance is acting in only one DL.

These page show how to provide credentials to your service. Provide_your_service_with_credentials

In case of Credentials that contains roles related to a DL, a filter over the DILIGENT Resources and WS-Resource Properties queries is applied. This means checks if the DL the service is acting is contained inside the AuthorizationPolicies element of a Profile or a DLs WS-Resource-Properties ( added by the DILIGENTProvider) of a WS-Resource. The Filter over DL context is not applied queryng for a Service Profile ( that is not related to a particular DL).

An xQuery parsers has also been implemented to set automatically filters to Custom xQuery ( Queries created by developers

Dependencies

These are the dependencies of the Library :

  • DVOS Authentication API
  • DVOS Common
  • WS-core 4.0.4
  • DIS-IC Stubs
  • DIS-Broker Stubs
  • DIS util library
  • NAL library

Usage Examples

In order to test DIS-HLS-Client without credentials and EPR, it'possible to create a manager with null parameters. By default, the queries will be sent to the diligent VO (i.e. to the DIS-IC instance deployed with its scope) without any DL restriction.


ExtendedGSSCredential cred=null;
try {
       cred = ProxyUtil.loadProxyCredentials("certWithDLRoles");
} catch (IOException e) {
	e.printStackTrace();
} catch (GSSException e) {
	e.printStackTrace();
}
RunningInstanceManager riManager=null;
PropertiesManager pMan =null;
try {
	//null credential and null EPR
	riManager=DISHLSClient.getRunningInstanceManager(null, null);
        pMan= DISHLSClient.getPropertiesManager(cred, null);
} catch (DISHLSClientException e) {
       e.printStackTrace();
}
String test= null;
try {
       riManager.getEPRsRIFromClassAndName("InformationSystem", "DIS-Registry", 
"dililigentproject/informationservice/disregistry/DISRegistryFactoryService", null,null);
       test= pMan.getAllPublishedEntries(cred, null);
} catch (DISHLSClientException e) {
       e.printStackTrace();
} catch (DISHLSCredentialException e) {
       //community changed
       e.printStackTrace();
} 

It's possible (like the Alpha version of the component) to prepare and execute a custom xQuery.

import org.apache.axis.MessageContext;
import org.diligentproject.informationservice.dishlsclient.impl.DISHLSClient;
import org.diligentproject.informationservice.dishlsclient.impl.DISHLSClientException;
import org.diligentproject.informationservice.dishlsclient.impl.DISHLSCredentialException;
import org.diligentproject.informationservice.dishlsclient.impl.GeneralQueryManager;


import org.diligentproject.dvos.authentication.util.*;
import org.diligentproject.dvos.delegation.api.MultipleCredentialsListener;
import org.diligentproject.dvos.exception.DVOSException;
import org.gridforum.jgss.ExtendedGSSCredential;

import org.globus.gsi.jaas.JaasSubject;

.........

private MultipleCredentialsListener credentialsListener;
..........

this.credentialsListener = new MultipleCredentialsListener();

DelegationLocalInterface.registerCredentialsListener(this.credentialsListener);		

String customXquery = "declare namespace = dis=\'http://diligentproject.org/namespaces/informationservice/disregistry/DISRegistryService'; "+
	" for $resource in collection('/db/Profiles/RunningInstance')//Document/Data/dis:Profile/DILIGENTResource "+
	" where $resource/UniqueID/string() eq '*UNIQUEID*'"+ 
	" let $accessPoint := $resource/Profile/AccessPoint" +
	"return <RESULT>{$uniqueID}{$serviceName}{$serviceClass}{$dhnid}{$accessPoint}</RESULT>";
	
	 customXquery= customXquery.replace("*UNIQUEID*", "4242424234-4-23432");
		 
	//get DL from the caller
	VOMSAttributesReader reader = null;
	try {
		reader = new VOMSAttributesReader(JaasSubject.getCurrentSubject(),MessageContext.getCurrentContext());
	} catch (DVOSException e) {
		e.printStackTrace();
	} catch (IOException e) {
		e.printStackTrace();
	}
		
	String dlName = reader.getAbsoluteDLName();
		
		
	ExtendedGSSCredential creds = credentialsListener.getCredentials(dlName);
	
	GeneralQueryManager manager = null;
	try {
	 manager = DISHLSClient.getGeneralQueryManager(creds, null);
	} catch (DISHLSClientException e) {
		e.printStackTrace();
	}
	String result= "";
	try {
		 result = manager.queryDISIC(customXquery, creds, null);
	} catch (DISHLSClientException e) {
		e.printStackTrace();
	} catch (DISHLSCredentialException e) {
		e.printStackTrace();
	}
	System.out.println(result);

}
}

In order to use DISHLSClient Managers outside a WSRF Service ( i.e. inside a portlet, or in a client), is necessary to initialize the DISHLSClient static class with the DISQueries.xml file path. Despite the Alpha version of the component is necessary also deployed on the same node of a portal the new version of the DHN.

How to adapt the existing xQuery to eXist 1.1

In the following examples are shown the necessary modifications to xQueries in order to make them compatible with eXist 1.1

  • the function text() is not supported:
  .../DILIGENTResource/UniqueID/text() eq 'id' ==> .../DILIGENTResource/UniqueID/string() eq 'id'
  
  • to keep an attribute value it must use the function string()
  .../Endpoint[@EntryName="*ENTRYNAME*"]  ==>  ../Endpoint[string(@EntryName) eq "*ENTRYNAME*"] 
 
  • to check the namspace-uri of a node
  [namespace-uri()="*NAMESPACE*"]  ==> [namespace-uri(.)="*NAMESPACE*"]


  • to check value of a node
  where $doc/Profile[ServiceName ='Name']  ==> where $doc/Profile[ServiceName/string() eq 'Name']
  • the contains function has also to include string() method
  contains($doc/Profile/Name,'Operator')==> contains($doc/Profile/Name/string(),'Operator')

--Andrea 14:08, 19 March 2007 (EET)