Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/main/java/org/entur/gbfs/GbfsLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public class GbfsLoader {

private final Map<String, String> httpHeaders;

private GBFS disoveryFileData;

/**
* Create a new GbfsLoader
*
Expand All @@ -57,15 +59,15 @@ public GbfsLoader(String url, Map<String, String> httpHeaders, String languageCo
}

// Fetch autoconfiguration file
GBFS data = fetchFeed(uri, httpHeaders, GBFS.class);
if (data == null) {
disoveryFileData = fetchFeed(uri, httpHeaders, GBFS.class);
if (disoveryFileData == null) {
throw new RuntimeException("Could not fetch the feed auto-configuration file from " + uri);
}

// Pick first language if none defined
GBFSFeeds feeds = languageCode == null
? data.getFeedsData().values().iterator().next()
: data.getFeedsData().get(languageCode);
? disoveryFileData.getFeedsData().values().iterator().next()
: disoveryFileData.getFeedsData().get(languageCode);
if (feeds == null) {
throw new RuntimeException("Language " + languageCode + " does not exist in feed " + uri);
}
Expand Down Expand Up @@ -104,6 +106,10 @@ public boolean update() {
return didUpdate;
}

public GBFS getDiscoveryFeed() {
return disoveryFileData;
}

/**
* Gets the most recent contents of the feed, which contains an object of type T.
*/
Expand Down