changed the WekeoResolver
This commit is contained in:
parent
93434b1f0c
commit
78784473f6
|
@ -29,6 +29,7 @@ import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.datatransfer.resolver.requesthandler.RequestHandler;
|
import org.gcube.datatransfer.resolver.requesthandler.RequestHandler;
|
||||||
import org.gcube.datatransfer.resolver.services.error.ExceptionManager;
|
import org.gcube.datatransfer.resolver.services.error.ExceptionManager;
|
||||||
|
import org.gcube.datatransfer.resolver.util.Util;
|
||||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||||
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -61,9 +62,8 @@ public class WekeoResolver {
|
||||||
* @return the token
|
* @return the token
|
||||||
* @throws WebApplicationException the web application exception
|
* @throws WebApplicationException the web application exception
|
||||||
*/
|
*/
|
||||||
@POST
|
@GET
|
||||||
@Path("/gettoken")
|
@Path("/gettoken")
|
||||||
@Consumes(MediaType.TEXT_PLAIN)
|
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
public Response getToken(@Context HttpServletRequest req) throws WebApplicationException{
|
public Response getToken(@Context HttpServletRequest req) throws WebApplicationException{
|
||||||
|
|
||||||
|
@ -180,6 +180,23 @@ public class WekeoResolver {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("")
|
||||||
|
@Produces(MediaType.TEXT_HTML)
|
||||||
|
public Response getIndex(@Context HttpServletRequest req) {
|
||||||
|
logger.info(this.getClass().getSimpleName()+" getIndex starts...");
|
||||||
|
|
||||||
|
StringBuilder wekeoResponse = new StringBuilder();
|
||||||
|
wekeoResponse.append("<h1>Welcome to Wekeo Resolver</h1>");
|
||||||
|
wekeoResponse.append("<div>See documentation at: "+helpURI +"</div>");
|
||||||
|
String wekeoGetTokenURL = String.format("%s/%s", Util.getServerURL(req), "wekeo/gettoken");
|
||||||
|
wekeoResponse.append("<div>Go to <i>gettoken</i> request: "+wekeoGetTokenURL +"</div>");
|
||||||
|
|
||||||
|
String theResponse = wekeoResponse.toString();
|
||||||
|
logger.info("debug: \n"+theResponse);
|
||||||
|
return Response.ok(theResponse).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads the wekeo endpoint information from IS. {The SE name is: @link WekeoResolver#RUNTIME_WKEO_RESOURCE_NAME}
|
* Reads the wekeo endpoint information from IS. {The SE name is: @link WekeoResolver#RUNTIME_WKEO_RESOURCE_NAME}
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
<!-- EASTER EGG - TO BE REMOVED -->
|
|
||||||
<!DOCTYPE HTML>
|
|
||||||
<html lang="en-US">
|
|
||||||
<head>
|
|
||||||
<style type="text/css">
|
|
||||||
body {
|
|
||||||
background-color: #f8f6f2;
|
|
||||||
color: #225f97;
|
|
||||||
font-family: 'Droid Sans', arial, sans-serif;
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<div>
|
|
||||||
<img style="-webkit-user-select: none; cursor: zoom-out;"
|
|
||||||
src="https://www.sportmediaset.mediaset.it/binary/26.$plit/C_29_fotogallery_1024745__ImageGallery__imageGalleryItem_4_image.jpg"
|
|
||||||
width="2598" height="2074">
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
package org.gcube.datatransfer.test;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
import javax.ws.rs.core.Response.ResponseBuilder;
|
||||||
|
|
||||||
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||||
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
import org.gcube.common.storagehub.client.StreamDescriptor;
|
||||||
|
import org.gcube.common.storagehub.client.plugins.AbstractPlugin;
|
||||||
|
import org.gcube.common.storagehub.client.proxies.ItemManagerClient;
|
||||||
|
import org.gcube.datatransfer.resolver.catalogue.resource.CkanCatalogueConfigurationsReader;
|
||||||
|
import org.gcube.datatransfer.resolver.catalogue.resource.GatewayCKANCatalogueReference;
|
||||||
|
import org.gcube.datatransfer.resolver.init.UriResolverSmartGearManagerInit;
|
||||||
|
import org.gcube.datatransfer.resolver.services.CatalogueResolver;
|
||||||
|
import org.gcube.datatransfer.resolver.services.StorageHubResolver;
|
||||||
|
import org.gcube.datatransfer.resolver.services.error.ExceptionManager;
|
||||||
|
import org.gcube.datatransfer.resolver.shub.StorageHubMetadataResponseBuilder;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import com.itextpdf.text.log.SysoCounter;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class CatalogueResolverTest.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
|
*
|
||||||
|
* May 13, 2019
|
||||||
|
*/
|
||||||
|
public class StorageHubTest {
|
||||||
|
|
||||||
|
private static String entityName = "using_e-infrastructures_for_biodiversity_conservation";
|
||||||
|
private static String entityContext = "ctlg";
|
||||||
|
private static String vreName = "BlueBridgeProject";
|
||||||
|
|
||||||
|
private String rootContextScope = "/d4science.research-infrastructures.eu";
|
||||||
|
private String authorizationToken = "ea16e0fa-722a-4589-83b0-0a731d2d4039-843339462";
|
||||||
|
|
||||||
|
//@Before
|
||||||
|
public void init() {
|
||||||
|
|
||||||
|
UriResolverSmartGearManagerInit.setRootContextScope(rootContextScope);
|
||||||
|
}
|
||||||
|
|
||||||
|
//@Test
|
||||||
|
public void testStreamDescriptorInfo() {
|
||||||
|
System.out.println("testStreamDescriptorInfo starts...");
|
||||||
|
ScopeProvider.instance.set(rootContextScope);
|
||||||
|
SecurityTokenProvider.instance.set(authorizationToken);
|
||||||
|
String storageHubId = "E_NGJIUEYvU09sNG1YY0R2VGIyaStWdGhDSW9sSjRNdDRkdVI2RHRGb1BZMVBaVFlzMG1mOU5QUEtFM1hQeE9kbw==";
|
||||||
|
try{
|
||||||
|
|
||||||
|
ItemManagerClient client = AbstractPlugin.item().build();
|
||||||
|
StreamDescriptor descriptor = client.resolvePublicLink(storageHubId);
|
||||||
|
System.out.println("Descriptor: "+descriptor);
|
||||||
|
|
||||||
|
}catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -15,10 +15,19 @@ import java.nio.file.StandardCopyOption;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
import javax.ws.rs.core.Response.ResponseBuilder;
|
||||||
|
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.http.HttpStatus;
|
import org.apache.http.HttpStatus;
|
||||||
|
import org.gcube.common.storagehub.client.StreamDescriptor;
|
||||||
|
import org.gcube.common.storagehub.client.plugins.AbstractPlugin;
|
||||||
|
import org.gcube.common.storagehub.client.proxies.ItemManagerClient;
|
||||||
import org.gcube.datatransfer.resolver.applicationprofile.ApplicationProfileReader;
|
import org.gcube.datatransfer.resolver.applicationprofile.ApplicationProfileReader;
|
||||||
|
import org.gcube.datatransfer.resolver.services.StorageHubResolver;
|
||||||
|
import org.gcube.datatransfer.resolver.services.error.ExceptionManager;
|
||||||
|
import org.gcube.datatransfer.resolver.shub.StorageHubMetadataResponseBuilder;
|
||||||
import org.gcube.datatransfer.resolver.util.HTTPCallsUtils;
|
import org.gcube.datatransfer.resolver.util.HTTPCallsUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -81,7 +90,6 @@ public class TestResolvers {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Storage hub test.
|
* Storage hub test.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue