Fixes #21265
This commit is contained in:
parent
952965d4a1
commit
a6e9347cbb
|
@ -2,6 +2,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
||||||
|
|
||||||
# Changelog for org.gcube.spatial.data.ws-thredds
|
# Changelog for org.gcube.spatial.data.ws-thredds
|
||||||
|
|
||||||
|
## [v0.2.5-SNAPSHOT]
|
||||||
|
Fixes #21265
|
||||||
|
|
||||||
|
|
||||||
## [v0.2.4]
|
## [v0.2.4]
|
||||||
Default validate flag= false
|
Default validate flag= false
|
||||||
From http to https
|
From http to https
|
||||||
|
|
47
pom.xml
47
pom.xml
|
@ -8,7 +8,7 @@
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>org.gcube.spatial.data</groupId>
|
<groupId>org.gcube.spatial.data</groupId>
|
||||||
<artifactId>ws-thredds</artifactId>
|
<artifactId>ws-thredds</artifactId>
|
||||||
<version>0.2.4</version>
|
<version>0.2.5-SNAPSHOT</version>
|
||||||
<name>ws-thredds</name>
|
<name>ws-thredds</name>
|
||||||
<description>prototype of WS integration with data-transfer for Thredds pubblication</description>
|
<description>prototype of WS integration with data-transfer for Thredds pubblication</description>
|
||||||
|
|
||||||
|
@ -41,33 +41,48 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.spatial.data</groupId>
|
<groupId>org.gcube.spatial.data</groupId>
|
||||||
<artifactId>sdi-library</artifactId>
|
<artifactId>sdi-library</artifactId>
|
||||||
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
|
<version>[1.0.0-SNAPSHOT,1.3.0-SNAPSHOT)</version>
|
||||||
<exclusions>
|
<!-- <exclusions> -->
|
||||||
<exclusion>
|
<!-- <exclusion> -->
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<!-- <groupId>com.fasterxml.jackson.core</groupId> -->
|
||||||
<artifactId>jackson-annotations</artifactId>
|
<!-- <artifactId>jackson-annotations</artifactId> -->
|
||||||
</exclusion>
|
<!-- </exclusion> -->
|
||||||
</exclusions>
|
<!-- </exclusions> -->
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.common</groupId>
|
||||||
|
<artifactId>storagehub-client-library</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.data.transfer</groupId>
|
<groupId>org.gcube.data.transfer</groupId>
|
||||||
<artifactId>data-transfer-library</artifactId>
|
<artifactId>data-transfer-library</artifactId>
|
||||||
<version>[1.2.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
|
<version>[1.2.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- OLD HL -->
|
<dependency>
|
||||||
<!-- <dependency> <groupId>org.gcube.common</groupId> <artifactId>home-library-jcr</artifactId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<version>[2.0.0-SNAPSHOT,3.0.0-SNAPSHOT)</version> </dependency> <dependency>
|
<artifactId>jackson-core</artifactId>
|
||||||
<groupId>org.gcube.common</groupId> <artifactId>home-library</artifactId>
|
<version>[2.8.4,)</version>
|
||||||
<version>[2.0.0-SNAPSHOT,3.0.0-SNAPSHOT)</version> </dependency> -->
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.common</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>storagehub-client-library</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
|
<version>[2.8.4,)</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- JSON paths -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.jayway.jsonpath</groupId>
|
||||||
|
<artifactId>json-path</artifactId>
|
||||||
|
<version>2.5.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-log4j12</artifactId>
|
<artifactId>slf4j-log4j12</artifactId>
|
||||||
|
|
|
@ -18,6 +18,7 @@ public class Constants {
|
||||||
|
|
||||||
|
|
||||||
public static final String SDI_THREDDS_BASE_URL="sdi-service/gcube/service/Thredds";
|
public static final String SDI_THREDDS_BASE_URL="sdi-service/gcube/service/Thredds";
|
||||||
|
public static final String SDI_CONFIG_PATH="sdi-service/gcube/service/SDI";
|
||||||
|
|
||||||
|
|
||||||
public static final String SIS_PLUGIN_ID="SIS/GEOTK";
|
public static final String SIS_PLUGIN_ID="SIS/GEOTK";
|
||||||
|
|
|
@ -9,6 +9,7 @@ import java.io.InputStream;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.ws.rs.client.Client;
|
import javax.ws.rs.client.Client;
|
||||||
|
@ -49,11 +50,23 @@ import org.gcube.usecases.ws.thredds.faults.UnableToLockException;
|
||||||
import org.glassfish.jersey.client.ClientConfig;
|
import org.glassfish.jersey.client.ClientConfig;
|
||||||
import org.glassfish.jersey.client.ClientProperties;
|
import org.glassfish.jersey.client.ClientProperties;
|
||||||
|
|
||||||
|
import com.jayway.jsonpath.Configuration;
|
||||||
|
import com.jayway.jsonpath.DocumentContext;
|
||||||
|
import com.jayway.jsonpath.JsonPath;
|
||||||
|
import com.jayway.jsonpath.Option;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class ThreddsController {
|
public class ThreddsController {
|
||||||
|
|
||||||
|
static Configuration JSON_PATH_ALWAYS_LIST_CONFIG= Configuration.builder().
|
||||||
|
options(Option.ALWAYS_RETURN_LIST,
|
||||||
|
Option.SUPPRESS_EXCEPTIONS,
|
||||||
|
Option.DEFAULT_PATH_LEAF_TO_NULL).build();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private String hostname;
|
private String hostname;
|
||||||
private String operatingPath;
|
private String operatingPath;
|
||||||
private String targetToken;
|
private String targetToken;
|
||||||
|
@ -61,10 +74,9 @@ public class ThreddsController {
|
||||||
public ThreddsController(String path,String targetToken) throws InternalException {
|
public ThreddsController(String path,String targetToken) throws InternalException {
|
||||||
operatingPath=path;
|
operatingPath=path;
|
||||||
this.targetToken=targetToken;
|
this.targetToken=targetToken;
|
||||||
setTargetToken();
|
|
||||||
hostname=getThreddsHost();
|
hostname=getThreddsHost();
|
||||||
if(hostname==null) throw new InternalException("Unable to find a thredds instance in target scope "+ScopeUtils.getCurrentScope());
|
if(hostname==null) throw new InternalException("Invalid hostnam in context "+ScopeUtils.getCurrentScope());
|
||||||
resetCallerToken();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String truncate(String toTruncate) {
|
private static final String truncate(String toTruncate) {
|
||||||
|
@ -292,8 +304,24 @@ public class ThreddsController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static String getThreddsHost(){
|
private String getThreddsHost() throws InternalException{
|
||||||
return getGCoreEndpointHostname(ServiceConstants.SERVICE_CLASS, "Thredds");
|
setTargetToken();
|
||||||
|
try{
|
||||||
|
String sdiUrl="https://"+getSDIServiceHost()+"/"+Constants.SDI_CONFIG_PATH;
|
||||||
|
log.info("checking sdI configuration at {}",sdiUrl);
|
||||||
|
Response resp=getWebClient().target(sdiUrl).request(MediaType.APPLICATION_JSON_TYPE).get();
|
||||||
|
String respString=resp.readEntity(String.class);
|
||||||
|
if(!(resp.getStatus()>=200&&resp.getStatus()<300))
|
||||||
|
throw new InternalException("Failed to contact SDI. Message "+respString);
|
||||||
|
|
||||||
|
DocumentContext sourceCtx=JsonPath.using(JSON_PATH_ALWAYS_LIST_CONFIG).parse(respString);
|
||||||
|
return new URL(((List<String>) sourceCtx.read("$.threddsConfiguration..baseEndpoint")).get(0)).getHost();
|
||||||
|
}catch(Throwable t) {
|
||||||
|
log.error("Unable to read SDI configuration",t);
|
||||||
|
throw new InternalException("Unable to gt configuration from SDI",t);
|
||||||
|
}finally {
|
||||||
|
resetCallerToken();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getGCoreEndpointHostname(String serviceClass,String serviceName) {
|
private static String getGCoreEndpointHostname(String serviceClass,String serviceName) {
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package org.gcube.usecases.ws.thredds;
|
||||||
|
|
||||||
|
import org.gcube.data.transfer.library.utils.ScopeUtils;
|
||||||
|
import org.gcube.usecases.ws.thredds.faults.InternalException;
|
||||||
|
|
||||||
|
public class GetTrhreddsInfoTest {
|
||||||
|
|
||||||
|
|
||||||
|
public static void main(String[] args) throws InternalException {
|
||||||
|
SyncEngine engine=SyncEngine.get();
|
||||||
|
// ROOT
|
||||||
|
System.out.println(engine.getAvailableCatalogsByToken("***REMOVED***"));
|
||||||
|
// MEI
|
||||||
|
System.out.println(engine.getAvailableCatalogsByToken("54f577de-d259-407e-b30d-29bf9e7c0dee-843339462"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package org.gcube.usecases.ws.thredds;
|
||||||
|
|
||||||
|
import org.gcube.spatial.data.sdi.utils.ScopeUtils;
|
||||||
|
import org.gcube.usecases.ws.thredds.faults.InternalException;
|
||||||
|
|
||||||
|
public class TestInit {
|
||||||
|
|
||||||
|
public static void main(String[] args) throws InternalException {
|
||||||
|
TokenSetter.set("/gcube/devsec/devVRE");
|
||||||
|
|
||||||
|
System.out.println("Context "+ScopeUtils.getCurrentScope()+" token "+ScopeUtils.getCurrentCaller());
|
||||||
|
final SyncEngine engine=SyncEngine.get();
|
||||||
|
|
||||||
|
|
||||||
|
// // TO BE INTRODUCED LATER
|
||||||
|
// engine.getAvailableCatalogsByToken(Security.getToken()).forEach((CatalogBean c)->{
|
||||||
|
//
|
||||||
|
// System.out.println(c);
|
||||||
|
//
|
||||||
|
// });
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package org.gcube.usecases.ws.thredds;
|
||||||
|
|
||||||
|
public class TokenCheck {
|
||||||
|
|
||||||
|
//
|
||||||
|
// public static void main (String[] args) {
|
||||||
|
// System.out.println(Security.getContext("8e74a17c-92f1-405a-b591-3a6090066248-98187548"));
|
||||||
|
// System.out.println(Security.getContext("0e2c7963-8d3e-4ea6-a56d-ffda530dd0fa-98187548"));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
}
|
Loading…
Reference in New Issue