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/nexus/NexusDao.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/nexus/NexusDao.java')
-rwxr-xr-x | src/main/java/io/trygvis/esper/testing/nexus/NexusDao.java | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/main/java/io/trygvis/esper/testing/nexus/NexusDao.java b/src/main/java/io/trygvis/esper/testing/nexus/NexusDao.java new file mode 100755 index 0000000..39d4233 --- /dev/null +++ b/src/main/java/io/trygvis/esper/testing/nexus/NexusDao.java @@ -0,0 +1,52 @@ +package io.trygvis.esper.testing.nexus; + +import fj.data.*; +import static fj.data.Option.*; +import io.trygvis.esper.testing.*; +import org.joda.time.*; + +import java.sql.*; + +public class NexusDao extends Dao { + protected NexusDao(Connection c) { + super(c); + } + + public void insertRepository(String repositoryId, LocalDateTime discoveryDate) throws SQLException { + PreparedStatement s = prepareStatement("INSERT INTO nexus_repository(id) VALUES(?)"); + s.setString(1, repositoryId); + s.executeUpdate(); + } + + public Option<NexusRepository> selectRepository(String repositoryId) throws SQLException { + PreparedStatement s = prepareStatement("SELECT id, discovery_date, last_update, last_successful_update FROM nexus_repository WHERE id=?"); + s.setString(1, repositoryId); + + try (ResultSet rs = s.executeQuery()) { + if (!rs.next()) { + return Option.none(); + } + + return some(new NexusRepository( + rs.getString(1), + fromNull(rs.getTimestamp(2)).map(timestampToLocalDateTime), + fromNull(rs.getTimestamp(3)).map(timestampToLocalDateTime), + fromNull(rs.getTimestamp(4)).map(timestampToLocalDateTime) + )); + } + } +} + +class NexusRepository { + public final String repositoryId; + public final Option<LocalDateTime> discoveryDate; + public final Option<LocalDateTime> lastUpdate; + public final Option<LocalDateTime> lastSuccessfulUpdate; + + NexusRepository(String repositoryId, Option<LocalDateTime> discoveryDate, Option<LocalDateTime> lastUpdate, Option<LocalDateTime> lastSuccessfulUpdate) { + this.repositoryId = repositoryId; + this.discoveryDate = discoveryDate; + this.lastUpdate = lastUpdate; + this.lastSuccessfulUpdate = lastSuccessfulUpdate; + } +} |