Difference between revisions of "URI Resolver"
(→SMP-ID Resolver) |
|||
Line 191: | Line 191: | ||
Therefore, in this order: | Therefore, in this order: | ||
+ | |||
- Either fileName is read from query string or is read from storage metadata otherwise is default: "fromStorageManager" | - 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" | - Either contentype is read from query string or is read from storage metadata otherwise is default: "unknown/unknown" | ||
Line 204: | Line 206: | ||
</source> | </source> | ||
− | |||
=== Uri Resolver Manager === | === Uri Resolver Manager === |
Revision as of 10:54, 24 September 2015
The URI Resolver is an HTTP URI resolver implemented as an HTTP servlet which gives access trough HTTP to different protocols URIs.
Contents
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://dev.d4science.org/uri-resolver/smp?smp-uri=smp://Wikipedia_logo_silver.png?5ezvFfBOLqaqBlwCEtAvz4ch5BUu1ag3yftpCvV+gayz9bAtSsnO1/sX6pemTKbDe0qbchLexXeWgGcJlskYE8td9QSDXSZj5VSl9kdN9SN0/LRYaWUZuP4Q1J7lEiwkU4GKPsiD6PDRVcT4QAqTEy5hSIbr6o4Y&fileName=wikipediaLogo&contentType=image/png
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)
The artifact is available on Nexus with the following coordinates:
<groupId>org.gcube.data.transfer</groupId> <artifactId>uri-resolver</artifactId> <version>1.1.0-SNAPSHOT</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. This in an example of the Runtime Resource to configure:
<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> <Name>fileName_parameter</Name> <Value encrypted="false">fileName</Value> </Property> <Property> <Name>contentType_parameter</Name> <Value encrypted="false">contentType</Value> </Property> </Properties> </AccessPoint> </Profile>
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());
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://dev.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 Geonetowrk service (e.g. scope=/gcube/devsec/devVRE)
The artifact is available on Nexus with the following coordinates:
<groupId>org.gcube.data.transfer</groupId> <artifactId>uri-resolver</artifactId> <version>1.2.0-SNAPSHOT</version> <type>war</type>
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://dev.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"
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>
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
The artifact is available on Nexus with the following coordinates:
<groupId>org.gcube.portlets.user</groupId> <artifactId>uri-resolver-manager</artifactId> <version>1.0.0-SNAPSHOT</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(); } }