This commit is contained in:
Marcel 2021-12-19 19:35:20 +01:00
parent 9a2139036e
commit 3fb5bc40bc
3 changed files with 26 additions and 21 deletions

View File

@ -67,7 +67,7 @@ services:
- ./:/data/
environment:
mqtt.broker.uri: tcp://broker.hivemq.com:1883
discovery.endpoint.uri: http://tapas-auction-house.86-119-34-242.nip.io/
discovery.endpoint.uri: http://tapas-auction-house.86-119-34-242.nip.io
auction.house.uri: https://tapas-auction-house.86-119-35-40.nip.io
labels:
- "traefik.enable=true"

View File

@ -46,8 +46,6 @@ public class TapasAuctionHouseApplication {
* Discovers auction houses and subscribes to WebSub notifications
*/
private static void bootstrapMarketplaceWithWebSub() {
discoverAuctionHouseEndpoints();
WebSubSubscriber subscriber = new WebSubSubscriber(ENVIRONMENT.getProperty("auction.house.uri"));
try {
@ -57,6 +55,8 @@ public class TapasAuctionHouseApplication {
e.printStackTrace();
}
discoverAuctionHouseEndpoints();
// for (AuctionHouseDiscoveryInformation endpoint : AuctionHouseDiscovery.getInstance().getAuctionHouseDiscoveryList()) {
// System.out.println(endpoint.getWebSubUri().getValue());
// if (!endpoint.getWebSubUri().getValue().toString().equalsIgnoreCase("https://tapas-auction-house.86-119-35-40.nip.io/websub/auctions")) {

View File

@ -6,6 +6,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.http.HttpStatus;
import java.io.IOException;
import java.net.URI;
@ -30,27 +31,31 @@ public class AuctionHouseDiscoveryHttpAdapter implements AuctionHouseDiscoveryPo
.uri(auctionHouseURI)
.GET()
.build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
LOGGER.info(response.body());
var responseBody = new JSONObject(response.body());
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
LOGGER.info("Response status code: " + response.statusCode());
LOGGER.info("Response body:" + response.body());
if (response.statusCode() == HttpStatus.OK.value()) {
var responseBody = new JSONObject(response.body());
var arrayOfInformation = responseBody.getJSONArray("auctionHouseInfo");
var returnList = new LinkedList<AuctionHouseDiscoveryInformation>();
var arrayOfInformation = responseBody.getJSONArray("auctionHouseInfo");
var returnList = new LinkedList<AuctionHouseDiscoveryInformation>();
for(int i = 0; i < arrayOfInformation.length(); i++)
{
var informationJSON = arrayOfInformation.getJSONObject(i);
var information = new AuctionHouseDiscoveryInformation(
new AuctionHouseDiscoveryInformation.AuctionHouseUri(URI.create(informationJSON.getString("auctionHouseUri"))),
new AuctionHouseDiscoveryInformation.WebSubUri(URI.create(informationJSON.getString("webSubUri"))),
new AuctionHouseDiscoveryInformation.TaskTypes(getTaskTypes(informationJSON.getJSONArray("taskTypes"))),
new AuctionHouseDiscoveryInformation.TimeStamp(Timestamp.valueOf(informationJSON.getString("timeStamp"))),
new AuctionHouseDiscoveryInformation.GroupName(informationJSON.getString("groupName"))
);
returnList.add(information);
for(int i = 0; i < arrayOfInformation.length(); i++)
{
var informationJSON = arrayOfInformation.getJSONObject(i);
var information = new AuctionHouseDiscoveryInformation(
new AuctionHouseDiscoveryInformation.AuctionHouseUri(URI.create(informationJSON.getString("auctionHouseUri"))),
new AuctionHouseDiscoveryInformation.WebSubUri(URI.create(informationJSON.getString("webSubUri"))),
new AuctionHouseDiscoveryInformation.TaskTypes(getTaskTypes(informationJSON.getJSONArray("taskTypes"))),
new AuctionHouseDiscoveryInformation.TimeStamp(Timestamp.valueOf(informationJSON.getString("timeStamp"))),
new AuctionHouseDiscoveryInformation.GroupName(informationJSON.getString("groupName"))
);
returnList.add(information);
}
return returnList;
}
return returnList;
return Collections.<AuctionHouseDiscoveryInformation>emptyList();
} catch (IOException e) {
e.printStackTrace();