replaced URL with URI

This commit is contained in:
Michele Artini 2023-05-29 09:38:04 +02:00
parent 60605f0ce9
commit d6d04a9358
2 changed files with 9 additions and 7 deletions

View File

@ -1,6 +1,6 @@
package eu.dnetlib.apps.oai2ftp.utils;
import java.net.URL;
import java.net.URI;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@ -9,7 +9,7 @@ import org.springframework.stereotype.Component;
public class StorageClientFactory {
@Value("${oai2ftp.conf.storage.url}")
private URL storageUrl;
private URI storageUrl;
@Value("${oai2ftp.conf.storage.user}")
private String storageUser;
@ -19,7 +19,7 @@ public class StorageClientFactory {
public StorageClient newClient() {
final String protocol = storageUrl.getProtocol();
final String protocol = storageUrl.getScheme();
final String host = storageUrl.getHost();
final int port = storageUrl.getPort();
final String path = storageUrl.getPath();
@ -32,7 +32,7 @@ public class StorageClientFactory {
} else if (protocol.equalsIgnoreCase("file")) {
client = new LocalStorage();
} else {
throw new RuntimeException("Invalid storage protocol: " + protocol);
throw new RuntimeException("Invalid storage protocol: " + protocol + " (valid protocol are: file, ftp and ftps)");
}
client.login(storageUser, storagePassword);
client.changeDir(path);

View File

@ -12,8 +12,10 @@ spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect
oai2ftp.conf.storage.url = file:///tmp/test_oai
oai2ftp.conf.storage.user =
oai2ftp.conf.storage.password =
# supported protocols: file, ftp and ftps
# oai2ftp.conf.storage.url = file:///tmp/test_oai
oai2ftp.conf.storage.url = ftp://localhost/oai_dumps
oai2ftp.conf.storage.user = test
oai2ftp.conf.storage.password = testPwd
oai2ftp.conf.execution.expirationTime = 12