fixes #20761 (from http to https)

This commit is contained in:
Fabio Sinibaldi 2021-03-25 15:37:38 +01:00
parent 73ca36949f
commit ff5f0b6494
3 changed files with 10 additions and 30 deletions

View File

@ -83,11 +83,11 @@ public class Commons {
public static DataTransferClient getDTClient(String threddsHostName) throws UnreachableNodeException, ServiceNotFoundException {
log.debug("Getting DT Client for {} ",threddsHostName);
return DataTransferClient.getInstanceByEndpoint("http://"+threddsHostName+":80");
return DataTransferClient.getInstanceByEndpoint("https://"+threddsHostName);
}
public static String readThreddsFile(String location) throws RemoteFileNotFoundException {
String urlString="http://"+getThreddsHost()+":80/"+Constants.THREDDS_DATA_TRANSFER_BASE_URL+location;
String urlString="https://"+getThreddsHost()+"/"+Constants.THREDDS_DATA_TRANSFER_BASE_URL+location;
log.info("Reading file at {} ",urlString);
try{
return getWebClient().target(urlString).request().get().readEntity(String.class);
@ -99,7 +99,7 @@ public class Commons {
public static void deleteThreddsFile(String location) throws RemoteFileNotFoundException {
String urlString="http://"+getThreddsHost()+":80/"+Constants.THREDDS_DATA_TRANSFER_BASE_URL+location;
String urlString="https://"+getThreddsHost()+"/"+Constants.THREDDS_DATA_TRANSFER_BASE_URL+location;
log.info("Reading file at {} ",urlString);
try{
getWebClient().target(urlString).request().delete();
@ -120,7 +120,7 @@ public class Commons {
}
private static String getThreddsInfoPath() {
return "https://"+getThreddsHost()+"/data-transfer-service/gcube/service/Capabilities/pluginInfo/REGISTER_CATALOG";
return "httpss://"+getThreddsHost()+"/data-transfer-service/gcube/service/Capabilities/pluginInfo/REGISTER_CATALOG";
}
public static void lockFolder(String folderPath,String processId) throws UnableToLockException {

View File

@ -143,7 +143,7 @@ public class ThreddsController {
public void deleteThreddsFile(String location) throws RemoteFileNotFoundException {
setTargetToken();
String urlString="http://"+hostname+":80/"+Constants.THREDDS_DATA_TRANSFER_BASE_URL+getPathFromStartingLocation(location);
String urlString="https://"+hostname+"/"+Constants.THREDDS_DATA_TRANSFER_BASE_URL+getPathFromStartingLocation(location);
log.info("Deleting file at {} ",urlString);
try{
getWebClient().target(urlString).request().delete();
@ -166,7 +166,7 @@ public class ThreddsController {
public String readThreddsFile(String location) throws RemoteFileNotFoundException {
setTargetToken();
String urlString="http://"+hostname+":80/"+Constants.THREDDS_DATA_TRANSFER_BASE_URL+getPathFromStartingLocation(location);
String urlString="https://"+hostname+"/"+Constants.THREDDS_DATA_TRANSFER_BASE_URL+getPathFromStartingLocation(location);
log.info("Reading file at {} ",urlString);
try{
return getWebClient().target(urlString).request().get().readEntity(String.class);
@ -212,7 +212,7 @@ public class ThreddsController {
try{
SecurityTokenProvider.instance.get();
log.info("Creating catalog with name {} for path {} ",name,operatingPath);
String sdiUrl="http://"+getSDIServiceHost()+"/"+Constants.SDI_THREDDS_BASE_URL;
String sdiUrl="https://"+getSDIServiceHost()+"/"+Constants.SDI_THREDDS_BASE_URL;
Response resp=getWebClient().target(sdiUrl).
queryParam("name", name).
queryParam("path", operatingPath).
@ -245,7 +245,7 @@ public class ThreddsController {
public RemoteFileDescriptor getFileDescriptor(String path) throws RemoteFileNotFoundException {
setTargetToken();
String urlString="http://"+hostname+":80/"+Constants.THREDDS_DATA_TRANSFER_BASE_URL+getPathFromStartingLocation(path);
String urlString="https://"+hostname+"/"+Constants.THREDDS_DATA_TRANSFER_BASE_URL+getPathFromStartingLocation(path);
log.info("Reading file at {} ",urlString);
try{
return getWebClient().target(urlString).queryParam("descriptor", true).request().get().readEntity(RemoteFileDescriptor.class);
@ -258,7 +258,7 @@ public class ThreddsController {
public InputStream getInputStream(String path) throws RemoteFileNotFoundException {
setTargetToken();
String urlString="http://"+hostname+":80/"+Constants.THREDDS_DATA_TRANSFER_BASE_URL+getPathFromStartingLocation(path);
String urlString="https://"+hostname+"/"+Constants.THREDDS_DATA_TRANSFER_BASE_URL+getPathFromStartingLocation(path);
log.info("Reading file at {} ",urlString);
try{
return getWebClient().target(urlString).request().get().readEntity(InputStream.class);
@ -316,6 +316,6 @@ public class ThreddsController {
private static DataTransferClient getDTClient(String threddsHostName) throws UnreachableNodeException, ServiceNotFoundException {
log.debug("Getting DT Client for {} ",threddsHostName);
return DataTransferClient.getInstanceByEndpoint("http://"+threddsHostName+":80");
return DataTransferClient.getInstanceByEndpoint("https://"+threddsHostName);
}
}

View File

@ -7,26 +7,6 @@ import org.gcube.usecases.ws.thredds.model.SynchFolderConfiguration;
public class DTTests {
public static void main(String[] args) throws Exception {
// TestCommons.setScope();
// String threddsHostname="thredds-d-d4s.d4science.org";
// DataTransferClient client=DataTransferClient.getInstanceByEndpoint("http://"+threddsHostname+":80");
// Destination toSetDestination=new Destination();
// toSetDestination.setCreateSubfolders(true);
// toSetDestination.setDestinationFileName("transferTest.tst");
// toSetDestination.setOnExistingFileName(DestinationClashPolicy.REWRITE);
// toSetDestination.setOnExistingSubFolder(DestinationClashPolicy.APPEND);
// toSetDestination.setPersistenceId("thredds");
//
// //NB ITEM IS SUPPOSED TO HAVE REMOTE PATH
// String fileLocation="WS-Tests/mySub";
// toSetDestination.setSubFolder(fileLocation);
//
// File temp=File.createTempFile("testTransfer", "tmp");
// IOUtils.copy(new URL("http://data-d.d4science.org/SUlDWjIxamdaUTdHcmpvdEFmcFFPOUcvbjF5VyswbXlHbWJQNStIS0N6Yz0").openStream(), new FileOutputStream(temp));
//
// System.out.println(client.localFile(temp,
// toSetDestination,Collections.singleton(new PluginInvocation(Constants.SIS_PLUGIN_ID))));
//
TokenSetter.set("/gcube/devNext");
// Workspace ws = HomeLibrary.getHomeManagerFactory().getHomeManager().getHome().getWorkspace();