Difference between revisions of "URI Resolver"

From Gcube Wiki
Jump to: navigation, search
(Get a link via HTTP POST)
(Generic Resource for GisViewerApplication)
(35 intermediate revisions by the same user not shown)
Line 21: Line 21:
 
==== Runtime Resource ====
 
==== Runtime Resource ====
  
The address and the configuration information of the servlet are registered on the gCube Information System as Runtime Resource. This in an example of the Runtime Resource to configure:
+
The address and the configuration information of the servlet are registered on the gCube Information System as Runtime Resource (RR).
  
<pre>
+
You can see the configuration through Monitor service (https://services.d4science.org/infrastructure-monitor) searching in the root scope the RR with following:
<Profile>
+
       
+
      <Category>Service</Category>
+
       
+
      <Name>HTTP-URI-Resolver</Name>
+
       
+
      <Description>HTTP URI Resolver</Description>
+
       
+
      <Platform>
+
           
+
        <Name>tomcat</Name>
+
           
+
        <Version>6</Version>
+
           
+
        <MinorVersion>0</MinorVersion>
+
           
+
        <RevisionVersion>0</RevisionVersion>
+
           
+
        <BuildVersion>0</BuildVersion>
+
       
+
      </Platform>
+
       
+
      <RunTime>
+
           
+
        <HostedOn>dev.d4science.org</HostedOn>
+
           
+
        <GHN UniqueID="" />
+
           
+
        <Status>READY</Status>
+
       
+
      </RunTime>
+
       
+
      <AccessPoint>
+
           
+
        <Description>SMP URI Resolver</Description>
+
           
+
        <Interface>
+
               
+
            <Endpoint EntryName="smp">http://dev.d4science.org/uri-resolver/smp</Endpoint>
+
           
+
        </Interface>
+
           
+
        <AccessData>
+
               
+
            <Username />
+
               
+
            <Password>6vW1u92cpdgHzYAgIurn9w==</Password>
+
           
+
        </AccessData>
+
           
+
        <Properties>
+
               
+
            <Property>
+
                   
+
              <Name>SMP_URI_parameter</Name>
+
                   
+
              <Value encrypted="false">smp-uri</Value>
+
               
+
            </Property>
+
  
              <Property>
+
<pre>
                   
+
<Type>RuntimeResource</Type>
              <Name>fileName_parameter</Name>
+
<Category>Service</Category>
                   
+
<Name>HTTP-URI-Resolver</Name>
              <Value encrypted="false">fileName</Value>
+
               
+
            </Property>
+
 
+
            <Property>
+
                   
+
              <Name>contentType_parameter</Name>
+
                   
+
              <Value encrypted="false">contentType</Value>
+
               
+
            </Property>
+
           
+
        </Properties>
+
       
+
      </AccessPoint>
+
   
+
  </Profile>
+
 
</pre>
 
</pre>
 +
 +
You must copy such runtime resource in VRE scope if it is need to work at VRE level
  
 
==== Query ====
 
==== Query ====
Line 165: Line 91:
  
 
* ''gis-UUID'' : to specify the Metadata Universally Unique Identifier (UUID - used in iMarine Geonetwork). The UUID identifies the gis layer which you want to show in Gis Viewer Application
 
* ''gis-UUID'' : to specify the Metadata Universally Unique Identifier (UUID - used in iMarine Geonetwork). The UUID identifies the gis layer which you want to show in Gis Viewer Application
* ''scope'' : to specify the "scope" for discovering the iMarine Geonetowrk service (e.g. scope=/gcube/devsec/devVRE)
+
* ''scope'' : to specify the "scope" for discovering the iMarine GeoNetwork service (e.g. scope=/gcube/devsec/devVRE)
 +
 
 +
====== Runtime Resource ======
 +
 
 +
In order to work, it is necessary to copy from Root scope (/d4science.research-infrastructures.eu) to the VRE where Gis-Resolver must work, the runtime resource with following coordinates:
 +
 
 +
<pre>
 +
<Type>RuntimeResource</Type>
 +
<Category>Service</Category>
 +
<Name>Gis-Resolver</Name>
 +
</pre>
 +
 
 +
====== Generic Resource for Gis Viewer Application ======
 +
 
 +
It is necessary to edit the generic resource "Gis Viewer Application" in the Root scope (/d4science.research-infrastructures.eu) adding the VRE scope where the GisViewerApplication must work.
 +
 
 +
The Generic Resource "Gis Viewer Application" coordiantes are:
 +
 
 +
<pre>
 +
<Type>GenericResource</Type>
 +
<SecondaryType>ApplicationProfile</SecondaryType>
 +
<Name>Gis Viewer Application</Name>
 +
</pre>
  
 
=== SMP-ID Resolver ===
 
=== SMP-ID Resolver ===
Line 213: Line 161:
  
 
* gcube_scope as mandatory field. It is the gcube scope where to search the gCube Catalogue Portlet;
 
* gcube_scope as mandatory field. It is the gcube scope where to search the gCube Catalogue Portlet;
* entity_context as mandatory field. It can be: "dataset", "group", "organization";  
+
* entity_context as mandatory field. It can be: "dataset" or "product", "group", "organization";  
 
* entity_name as mandatory field. It is the entity name, that is its CKAN URL;
 
* entity_name as mandatory field. It is the entity name, that is its CKAN URL;
 
* clear_url as optional field. It can be: "true" or "false". If "true" the link returned is encrypted, no otherwise. When it is not present its default value is "false".
 
* clear_url as optional field. It can be: "true" or "false". If "true" the link returned is encrypted, no otherwise. When it is not present its default value is "false".
  
You must use the json format below to perform a valid Get Link:
+
===== Encrypted Link =====
 +
 
 +
You must pass the json format below as HTTP body to perform a valid request (the response returns an encrypted link):
  
 
<source lang='xml'>
 
<source lang='xml'>
Line 229: Line 179:
 
</source>
 
</source>
  
where an instance could be:
+
where an instance could be [ex. 1]:
  
 
<source lang='xml'>
 
<source lang='xml'>
Line 241: Line 191:
 
</source>
 
</source>
  
the response returns in the body an encrypted link:
+
'''Encrypted Link: ''' HTTP Response returned
 +
 
 +
Using the request of [ex. 1], HTTP response returns in the body an encrypted URL:
 
  http://data-d.d4science.org/uri-resolver/catalogue/Z0k1VmRUbVpTYURtcW83NnpHazhRRDJvN0xIdkFmKzlhaUZwM25lSGk3K283SUUxWnp2TjJOekgyTGlwcG5jcmZRb1FXdTZKWCtsVDNIZEpCVW9FQXZvUyt6VitaWmpSdDcwRi9aT2o3eUw5bVVzWHRRSEQzY2pCUVpVUVhJakM
 
  http://data-d.d4science.org/uri-resolver/catalogue/Z0k1VmRUbVpTYURtcW83NnpHazhRRDJvN0xIdkFmKzlhaUZwM25lSGk3K283SUUxWnp2TjJOekgyTGlwcG5jcmZRb1FXdTZKWCtsVDNIZEpCVW9FQXZvUyt6VitaWmpSdDcwRi9aT2o3eUw5bVVzWHRRSEQzY2pCUVpVUVhJakM
  
Using the json format following:
+
===== Clear/Direct Link =====
 +
 
 +
In order to get a direct link (not encrypted) you can add the 'clear_url' parameter to HTTP POST request.
 +
You must pass the json format below (in the HTTP body) to perform a valid request (the response returns a clear link)[CDL1]:
  
 
<source lang='xml'>
 
<source lang='xml'>
Line 254: Line 209:
 
"clear_url" : "true"
 
"clear_url" : "true"
 
}
 
}
 +
 +
NB. the json must contain the parameter 'clear_url' with "true" value
  
 
</source>
 
</source>
  
the response returns in the body an encrypted link:
+
where an instance could be [ex. 2]:
http://data-d.d4science.org/uri-resolver/catalogue/[VRE_NAME]/[entity_context value]/[entity_name value]
+
 
+
An instance could be:
+
  
 
<source lang='xml'>
 
<source lang='xml'>
Line 266: Line 220:
 
{
 
{
 
"gcube_scope" : "/gcube/devNext/NextNext",
 
"gcube_scope" : "/gcube/devNext/NextNext",
"entity_context" : "dataset",
+
"entity_context" : "product",
 
"entity_name" : "sarda-sarda"
 
"entity_name" : "sarda-sarda"
 
"clear_url" : "true"
 
"clear_url" : "true"
Line 273: Line 227:
 
</source>
 
</source>
  
the response returns in the body a clear URL:
+
 
  http://data-d.d4science.org/uri-resolver/catalogue/NextNext/dataset/sarda-sarda
+
'''Clear/Direct Link: ''' HTTP Response returned
 +
 
 +
''- v.2 returns a brief URL:''
 +
 
 +
Performing a clear/direct link POST request as shows [CDL1], the response returns in the body a "brief URL" in clear of kind:
 +
http://data.d4science.org/[ctlg-p|ctlg-d|ctlg-o|ctlg-g]/[VRE_NAME]/[entity_name value]
 +
 
 +
Where:
 +
 
 +
ctlg | ctlg-p | ctlg-d | ctlg-o | ctlg-g are codes to resolve the couple "catalogue"-"entity_context_value", in detail:
 +
 
 +
ctlg -> this one is default value to refer a 'product'|'dataset'
 +
 
 +
ctlg-p|d -> to refer respectively a 'product'|'dataset'
 +
 
 +
ctlg-o -> to refer an 'organization'
 +
 
 +
ctlg-g -> to refer a 'group'
 +
 
 +
For instance, using the request of [ex. 2], HTTP response returns in the body the URL:
 +
http://data-d.d4science.org/ctlg-p/NextNext/sarda-sarda
 +
 
 +
''- [dismissed] v.1 returns a complete URL :''
 +
 
 +
Performing a clear/direct link POST request as shows [CDL1] response returns in the body a "complete URL" in clear of kind:
 +
http://data-d.d4science.org/uri-resolver/catalogue/[VRE_NAME]/[entity_context value]/[entity_name value]
 +
 
 +
the response returns in the body the URL:
 +
  http://data-d.d4science.org/uri-resolver/catalogue/NextNext/product/sarda-sarda
  
 
==== Resolve a link via HTTP GET ====
 
==== Resolve a link via HTTP GET ====
  
The resolver provides HTTP GET operation to give HTTP resolution (as HTTP redirect) for displaying the 'entity_name' through an instance of "gCube Data Catalogue Portlet" (this last is resolved by the 'gcube_scope' used to generate the catalogue link)
+
The resolver provides HTTP GET operation to give HTTP resolution (as HTTP redirect) for displaying the 'entity_name' through an instance of "gCube Data Catalogue Portlet" (this last one is resolved by the 'gcube_scope' used to generate the catalogue link)
  
 
=== Uri Resolver Manager ===
 
=== Uri Resolver Manager ===
Line 290: Line 272:
 
The mandatory parameters to forward correctly the HTTP request to Resolver are dynamically read from Runtime Resource
 
The mandatory parameters to forward correctly the HTTP request to Resolver are dynamically read from Runtime Resource
  
==== Maven ====
+
===== Maven =====
 
The artifact is available on Nexus with the following coordinates:
 
The artifact is available on Nexus with the following coordinates:
  
Line 325: Line 307:
  
 
</source>
 
</source>
 +
 +
===== Generic Resource =====
 +
 +
In order to work, it is necessary to copy from Root scope (/d4science.research-infrastructures.eu) to the VRE where Uri Resolver Manager must work, the generic resource with following coordinates:
 +
 +
<pre>
 +
<Type>GenericResource</Type>
 +
<SecondaryType>UriResolverMap</SecondaryType>
 +
<Name>Uri-Resolver-Map</Name>
 +
</pre>

Revision as of 16:01, 16 June 2017

The URI Resolver is an HTTP URI resolver implemented as several HTTP servlets which give access trough HTTP to different protocols URIs (like SMP) and gCube Applications (like GisViewer)

Maven

The artifact is available on Nexus with the following coordinates:

  <groupId>org.gcube.data.transfer</groupId>
  <artifactId>uri-resolver</artifactId>
  <version>LATEST</version>
  <type>war</type>

Runtime Resource

The address and the configuration information of the servlet are registered on the gCube Information System as Runtime Resource (RR).

You can see the configuration through Monitor service (https://services.d4science.org/infrastructure-monitor) searching in the root scope the RR with following:

<Type>RuntimeResource</Type>
<Category>Service</Category>
<Name>HTTP-URI-Resolver</Name>

You must copy such runtime resource in VRE scope if it is need to work at VRE level

Query

The following code snippet can be used to retrieve from the gCube Information System the info to configure the resolver

 
        ScopeProvider.instance.set(<scope>);
 
	XQuery query = queryFor(ServiceEndpoint.class);
 
	query.addCondition("$resource/Profile/Name/text() eq 'HTTP-URI-Resolver'").setResult("$resource/Profile/AccessPoint");
 
	DiscoveryClient<AccessPoint> client = clientFor(AccessPoint.class);
 
	List<AccessPoint> endpoints = client.submit(query);
 
	if (endpoints.size() == 0)
		throw new Exception("No Resolver available");
 
	//Base Address
        System.out.println(endpoints.get(0).address());
        //Query URL parameter
	System.out.println(endpoints.get(0).propertyMap().get("SMP_URI_parameter").value());


SMP Resolver

The first version of the component is able to give HTTP resolution to SMP protocol URIs [1].

Once deployed in a servlet container as Tomcat, the servlet can be used to resolve SMP URIs as follows:

URL url = new URL("http://<hostname>:<port>/uri-resolver/smp?smp-uri=smp://.....);


The HTTP URI can be also used to retrieve files using wget or trough a Web Browser.. just click on the link :

http://data-d.d4science.org/uri-resolver/smp?smp-uri=[STORAGE_URI]&fileName=[FILENAME]&contentType=[CONTENT_TYPE]

Apart from the smp-uri mandatory parameter, two optional paramters can be used:

  • fileName : to specify the output file name ( default: fromStorageManager)
  • contentType : to specify the output file content-type ( default: unknown/unknown)

GIS Resolver

The first version of the component is able to give HTTP resolution (as redirect to Gis Viewer Application) to display and navigate on map the gis layers stored in iMarine Geonetwork #iMarine_GeoNetwork

The Gis Resolver can be used to resolve Gis Layer using a Web Browser link as follows:

http://data-d.d4science.org/uri-resolver/gis?gis-UUID=<UUID>&scope=<SCOPE>

The link must include two mandatory parameters:

  • gis-UUID : to specify the Metadata Universally Unique Identifier (UUID - used in iMarine Geonetwork). The UUID identifies the gis layer which you want to show in Gis Viewer Application
  • scope : to specify the "scope" for discovering the iMarine GeoNetwork service (e.g. scope=/gcube/devsec/devVRE)
Runtime Resource

In order to work, it is necessary to copy from Root scope (/d4science.research-infrastructures.eu) to the VRE where Gis-Resolver must work, the runtime resource with following coordinates:

<Type>RuntimeResource</Type>
<Category>Service</Category>
<Name>Gis-Resolver</Name>
Generic Resource for Gis Viewer Application

It is necessary to edit the generic resource "Gis Viewer Application" in the Root scope (/d4science.research-infrastructures.eu) adding the VRE scope where the GisViewerApplication must work.

The Generic Resource "Gis Viewer Application" coordiantes are:

<Type>GenericResource</Type>
<SecondaryType>ApplicationProfile</SecondaryType>
<Name>Gis Viewer Application</Name>

SMP-ID Resolver

The resolver is able to give HTTP resolution to storage resource by ID [2].

The HTTP URI can be also used to retrieve files using wget or trough a Web Browser.. just click on the link :

http://data-d.d4science.org/uri-resolver/id?smp-id=553f9265e4b0567b75021fce&fileName=dog&contentType=image%2Fjpg

Apart from the smp-id mandatory parameter, SMP-ID Resolver uses two optional parameters (in the query string):

  • fileName : to specify the output file name (default: fromStorageManager)
  • contentType : to specify the output file content-type (default: unknown/unknown)

The two default cases above will be used if and only if the file name and content-type (mime type) cannot be read from metadata of the file saved in the Storage.

Therefore, in this order:

- Either fileName is read from query string or is read from storage metadata otherwise is default: "fromStorageManager"

- Either contentype is read from query string or is read from storage metadata otherwise is default: "unknown/unknown"

STORAGE-ID Resolver

This works as #SMP-ID Resolver using links having format: http://data-d.d4science.org/[ID]

HEAD HTTP

STORAGE-ID Resolver implements the HTTP doHead operation. It performs a playload validation for resource ID required:

- if the payload exists: it returns status 200 the content-type and content-disposition of the file in the HTTP response;

- if the payload does not exist: it returns status 404 in the HTTP response.

CATALOGUE Resolver

This works as an HTTP Resolver to get/resolve a link to a "Catalogue Entity" stored in one of instances of gCube Data Catalogue

A Catalogue Entity is either a "group" or an "organization" or a "product" of gCube Data Catalogue.

Get a link via HTTP POST

The resolver provides HTTP POST operation to build a link to a "Catalogue Entity" stored into a specific gCube Data Catalogue.

In order to give a link via HTTP POST is need to pass:

  • gcube_scope as mandatory field. It is the gcube scope where to search the gCube Catalogue Portlet;
  • entity_context as mandatory field. It can be: "dataset" or "product", "group", "organization";
  • entity_name as mandatory field. It is the entity name, that is its CKAN URL;
  • clear_url as optional field. It can be: "true" or "false". If "true" the link returned is encrypted, no otherwise. When it is not present its default value is "false".
Encrypted Link

You must pass the json format below as HTTP body to perform a valid request (the response returns an encrypted link):

{
"gcube_scope" : "[gcube_scope value]",
"entity_context" : "[entity_context value]",
"entity_name" : "[entity_name value]"
}

where an instance could be [ex. 1]:

{
"gcube_scope" : "/gcube/devNext/NextNext",
"entity_context" : "dataset",
"entity_name" : "sarda-sarda"
}

Encrypted Link: HTTP Response returned

Using the request of [ex. 1], HTTP response returns in the body an encrypted URL:

http://data-d.d4science.org/uri-resolver/catalogue/Z0k1VmRUbVpTYURtcW83NnpHazhRRDJvN0xIdkFmKzlhaUZwM25lSGk3K283SUUxWnp2TjJOekgyTGlwcG5jcmZRb1FXdTZKWCtsVDNIZEpCVW9FQXZvUyt6VitaWmpSdDcwRi9aT2o3eUw5bVVzWHRRSEQzY2pCUVpVUVhJakM
Clear/Direct Link

In order to get a direct link (not encrypted) you can add the 'clear_url' parameter to HTTP POST request. You must pass the json format below (in the HTTP body) to perform a valid request (the response returns a clear link)[CDL1]:

{
"gcube_scope" : "[gcube_scope value]",
"entity_context" : "[entity_context value]",
"entity_name" : "[entity_name value]"
"clear_url" : "true"
}
 
NB. the json must contain the parameter 'clear_url' with "true" value

where an instance could be [ex. 2]:

{
"gcube_scope" : "/gcube/devNext/NextNext",
"entity_context" : "product",
"entity_name" : "sarda-sarda"
"clear_url" : "true"
}


Clear/Direct Link: HTTP Response returned

- v.2 returns a brief URL:

Performing a clear/direct link POST request as shows [CDL1], the response returns in the body a "brief URL" in clear of kind:

http://data.d4science.org/[ctlg-p|ctlg-d|ctlg-o|ctlg-g]/[VRE_NAME]/[entity_name value]

Where:

ctlg | ctlg-p | ctlg-d | ctlg-o | ctlg-g are codes to resolve the couple "catalogue"-"entity_context_value", in detail:

ctlg -> this one is default value to refer a 'product'|'dataset'

ctlg-p|d -> to refer respectively a 'product'|'dataset'

ctlg-o -> to refer an 'organization'

ctlg-g -> to refer a 'group'

For instance, using the request of [ex. 2], HTTP response returns in the body the URL:

http://data-d.d4science.org/ctlg-p/NextNext/sarda-sarda

- [dismissed] v.1 returns a complete URL :

Performing a clear/direct link POST request as shows [CDL1] response returns in the body a "complete URL" in clear of kind:

http://data-d.d4science.org/uri-resolver/catalogue/[VRE_NAME]/[entity_context value]/[entity_name value]

the response returns in the body the URL:

http://data-d.d4science.org/uri-resolver/catalogue/NextNext/product/sarda-sarda

Resolve a link via HTTP GET

The resolver provides HTTP GET operation to give HTTP resolution (as HTTP redirect) for displaying the 'entity_name' through an instance of "gCube Data Catalogue Portlet" (this last one is resolved by the 'gcube_scope' used to generate the catalogue link)

Uri Resolver Manager

The Uri Resolver Manager is a library to get a public link of a resource reachable from a (Gcube) Http Resolver

At moment, the resource types are GIS or SMP reachable from Uri-Resolver and Gis-Resolver.

The Uri Resolver Manager look up the (Generic Resource) "Uri-Resolver-Map" to read the mapping: Application Type -> (Runtime Resource of its) Resolver, e.g. GIS -> Gis-Resolver, SMP -> HTTP-URI-Resolver

The mandatory parameters to forward correctly the HTTP request to Resolver are dynamically read from Runtime Resource

Maven

The artifact is available on Nexus with the following coordinates:

   <groupId>org.gcube.portlets.user</groupId>
   <artifactId>uri-resolver-manager</artifactId>
   <version>LATEST</version>

A simple java How-to:

public static void main(String[] args) {
 
		try {
                        ScopeProvider.instance.set("/gcube/devsec/devVRE");
			UriResolverManager resolver = new UriResolverManager("GIS");
			Map<String, String> params = new HashMap<String, String>();
			params.put("gis-UUID", "eb1a1b63-f324-47ee-9522-b8f5803e19ec");
			params.put("scope", "/gcube/devsec/devVRE");
			String shortLink = resolver.getLink(params, true); //true, link is shorted otherwise none
			System.out.println(shortLink);
		} catch (UriResolverMapException e) {
			e.printStackTrace();
		} catch (IllegalArgumentException e) {
			e.printStackTrace();
		}catch (Exception e) {
			e.printStackTrace();
		}
	}
Generic Resource

In order to work, it is necessary to copy from Root scope (/d4science.research-infrastructures.eu) to the VRE where Uri Resolver Manager must work, the generic resource with following coordinates:

<Type>GenericResource</Type>
<SecondaryType>UriResolverMap</SecondaryType>
<Name>Uri-Resolver-Map</Name>