Skip to content

Commit

Permalink
Merge pull request #9 from qbicsoftware/feature/update-seek-node
Browse files Browse the repository at this point in the history
update existing seek nodes and fix stuff
  • Loading branch information
wow-such-code authored Oct 11, 2024
2 parents bd16a56 + 4ce251a commit b9a6f20
Show file tree
Hide file tree
Showing 26 changed files with 1,294 additions and 633 deletions.
16 changes: 15 additions & 1 deletion src/main/java/life/qbic/App.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package life.qbic;

import ch.ethz.sis.openbis.generic.OpenBIS;
import java.util.HashMap;
import java.util.Map;
import life.qbic.io.PropertyReader;
import life.qbic.io.commandline.CommandLineOptions;
import life.qbic.model.Configuration;
import life.qbic.model.download.AuthenticationException;
Expand All @@ -18,6 +21,7 @@
public class App {

private static final Logger LOG = LogManager.getLogger(App.class);
public static Map<String, String> configProperties = new HashMap<>();

public static void main(String[] args) {
LOG.debug("command line arguments: " + Arrays.deepToString(args));
Expand All @@ -26,6 +30,14 @@ public static void main(String[] args) {
System.exit(exitCode);
}

public static void readConfig() {
System.err.println("reading config");
String configPath = CommandLineOptions.getConfigPath();
if(configPath != null && !configPath.isEmpty()) {
configProperties = PropertyReader.getProperties(configPath);
}
}

/**
* checks if the commandline parameter for reading out the password from the environment variable
* is correctly provided
Expand Down Expand Up @@ -57,7 +69,9 @@ public static OpenBIS loginToOpenBIS(
char[] password, String user, String url, String dssUrl) {
setupLog();

OpenBIS authentication = new OpenBIS(url, dssUrl);
int generousTimeOut = 30*60*1000; //30 mins

OpenBIS authentication = new OpenBIS(url, dssUrl, generousTimeOut);

return tryLogin(authentication, user, password);
}
Expand Down
44 changes: 44 additions & 0 deletions src/main/java/life/qbic/io/PropertyReader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package life.qbic.io;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.TreeMap;

public class PropertyReader {

public static TreeMap<String, String> getProperties(String infile) {

TreeMap<String, String> properties = new TreeMap<>();
BufferedReader bfr = null;
try {
bfr = new BufferedReader(new FileReader(new File(infile)));
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}

String line;
while (true) {
try {
if ((line = bfr.readLine()) == null)
break;
} catch (IOException e) {
throw new RuntimeException(e);
}
if (!line.startsWith("#") && !line.isEmpty()) {
String[] property = line.trim().split("=");
properties.put(property[0].trim(), property[1].trim());
}
}

try {
bfr.close();
} catch (IOException e) {
throw new RuntimeException(e);
}

return(properties);
}
}
238 changes: 0 additions & 238 deletions src/main/java/life/qbic/io/commandline/AuthenticationOptions.java

This file was deleted.

23 changes: 15 additions & 8 deletions src/main/java/life/qbic/io/commandline/CommandLineOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,24 @@ public class CommandLineOptions {

private static final Logger LOG = LogManager.getLogger(CommandLineOptions.class);

@Option(names = {"-config", "--config_file"},
description = "Config file path to provide server and user information.",
scope = CommandLine.ScopeType.INHERIT)
static String configPath;

@Option(names = {"-V", "--version"},
versionHelp = true,
description = "print version information",
scope = CommandLine.ScopeType.INHERIT)
versionHelp = true,
description = "print version information",
scope = CommandLine.ScopeType.INHERIT)
boolean versionRequested = false;

@Option(
names = {"-h", "--help"},
usageHelp = true,
description = "display a help message and exit",
scope = CommandLine.ScopeType.INHERIT)
@Option(names = {"-h", "--help"},
usageHelp = true,
description = "display a help message and exit",
scope = CommandLine.ScopeType.INHERIT)
public boolean helpRequested = false;

public static String getConfigPath() {
return configPath;
}
}
Loading

0 comments on commit b9a6f20

Please sign in to comment.