diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2012-11-19 18:04:49 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2012-11-19 18:05:27 +0100 |
commit | af92579129943acac73542f4e05e1c7faeda0994 (patch) | |
tree | efa76694deade25434fdfb359c130b278d6b608f /src/main/java/io/trygvis/esper/testing/Config.java | |
parent | 389b8373b7f04a5bdb039b9b690daa12a50fb144 (diff) | |
download | esper-testing-af92579129943acac73542f4e05e1c7faeda0994.tar.gz esper-testing-af92579129943acac73542f4e05e1c7faeda0994.tar.bz2 esper-testing-af92579129943acac73542f4e05e1c7faeda0994.tar.xz esper-testing-af92579129943acac73542f4e05e1c7faeda0994.zip |
o Adding logic to stop fetching pages when Gitorious returns non-XML response.
o Adding support for self-signed certificates with https.
o Moving client code to GitoriousClient.
o Adding Nexus client and an importer that fetches all artifacts.
o A nexus client that actually fetches the entire set of artifacts.
Diffstat (limited to 'src/main/java/io/trygvis/esper/testing/Config.java')
-rwxr-xr-x | src/main/java/io/trygvis/esper/testing/Config.java | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/main/java/io/trygvis/esper/testing/Config.java b/src/main/java/io/trygvis/esper/testing/Config.java new file mode 100755 index 0000000..d089511 --- /dev/null +++ b/src/main/java/io/trygvis/esper/testing/Config.java @@ -0,0 +1,48 @@ +package io.trygvis.esper.testing; + +import fj.data.*; +import org.apache.commons.httpclient.protocol.*; +import static org.apache.commons.lang.StringUtils.*; +import org.apache.log4j.*; + +import java.io.*; +import java.util.*; + +public class Config { + public final String gitoriousUrl; + public final Option<String> gitoriousSessionValue; + public final String nexusUrl; + + public Config(String gitoriousUrl, Option<String> gitoriousSessionValue, String nexusUrl) { + this.gitoriousUrl = gitoriousUrl; + this.gitoriousSessionValue = gitoriousSessionValue; + this.nexusUrl = nexusUrl; + } + + public static Config loadFromDisk() throws IOException { + configureLog4j(); + + Protocol.registerProtocol("https", new Protocol("https", (ProtocolSocketFactory) new EasySSLProtocolSocketFactory(), 443)); + + Properties properties = new Properties(); + try (FileInputStream inputStream = new FileInputStream("config.properties")) { + properties.load(inputStream); + } + + return new Config(trimToNull(properties.getProperty("gitorious.url")), + Option.fromNull(trimToNull(properties.getProperty("gitorious.sessionValue"))), + trimToNull(properties.getProperty("nexus.url"))); + } + + public static void configureLog4j() { + Properties properties = new Properties(); + properties.setProperty("log4j.rootLogger", "DEBUG, A1"); + properties.setProperty("log4j.logger.httpclient.wire.content", "INFO"); + properties.setProperty("log4j.logger.httpclient.wire.header", "INFO"); + properties.setProperty("log4j.logger.org.apache.commons.httpclient", "INFO"); + properties.setProperty("log4j.appender.A1", "org.apache.log4j.ConsoleAppender"); + properties.setProperty("log4j.appender.A1.layout", "org.apache.log4j.PatternLayout"); + properties.setProperty("log4j.appender.A1.layout.ConversionPattern", "%-4r [%t] %-5p %c %x - %m%n"); + PropertyConfigurator.configure(properties); + } +} |