removed unused variables + bugfixes

This commit is contained in:
Marcel 2021-12-22 21:48:49 +01:00
parent 2279ebb89c
commit e0a8aa5a14

View File

@ -49,7 +49,7 @@ public class AuctionStartedEventListenerWebSubAdapter {
@PostMapping(path = "/auction-started/74c72c7f-2739-4124-aa35-a3225171a97c") @PostMapping(path = "/auction-started/74c72c7f-2739-4124-aa35-a3225171a97c")
public ResponseEntity<Void> handleExecutorAddedEvent(@RequestBody String payload) throws URISyntaxException { public ResponseEntity<Void> handleExecutorAddedEvent(@RequestBody String payload) throws URISyntaxException {
System.out.println("new auctions :O"); System.out.println("new websub auctions");
System.out.println(payload); System.out.println(payload);
@ -57,28 +57,15 @@ public class AuctionStartedEventListenerWebSubAdapter {
if (auctions.length() > 0) { if (auctions.length() > 0) {
JSONObject auction = auctions.getJSONObject(0); JSONObject auction = auctions.getJSONObject(0);
System.out.print(auction); System.out.print(auction);
// try {
// System.out.println(auction.getString("deadline"));
// System.out.println(AuctionJsonRepresentation.deserialize(auction.toString()));
// auctionStartedHandler.handleAuctionStartedEvent(
// new AuctionStartedEvent(AuctionJsonRepresentation.deserialize(auction.toString())));
// } catch (JsonProcessingException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
String auctionHouseURI = "https://tapas-auction-house.86-119-35-40.nip.io/"; String auctionHouseURI = "https://tapas-auction-house.86-119-35-40.nip.io/";
String taskListURI = "https://tapas-tasks.86-119-35-40.nip.io"; String taskListURI = "https://tapas-tasks.86-119-35-40.nip.io";
// TODO Sanitize URIs // TODO Sanitize URIs
String auctionId = auction.getString("auctionId"); String auctionId = auction.getString("auctionId");
String auctionHouseUri = auction.getString("auctionHouseUri"); String auctionHouseUri = auction.getString("auctionHouseUri");
String taskUri = auction.getString("taskUri");
String taskType = auction.getString("taskType");
String deadline = auction.getString("deadline");
var bid = new Bid( var bid = new Bid(
new Auction.AuctionId(auctionId), new Auction.AuctionId(auctionId),
@ -87,10 +74,10 @@ public class AuctionStartedEventListenerWebSubAdapter {
new Bid.BidderTaskListUri(URI.create(taskListURI)) new Bid.BidderTaskListUri(URI.create(taskListURI))
); );
String body; String body;
try { try {
body = BidJsonRepresentation.serialize(bid); body = BidJsonRepresentation.serialize(bid);
//LOGGER.info(body); //LOGGER.info(body);
var postURI = URI.create(auctionHouseUri + "/bid"); var postURI = URI.create(auctionHouseUri + "/bid");
HttpRequest postRequest = HttpRequest.newBuilder() HttpRequest postRequest = HttpRequest.newBuilder()
.uri(postURI) .uri(postURI)
@ -98,34 +85,20 @@ public class AuctionStartedEventListenerWebSubAdapter {
.POST(HttpRequest.BodyPublishers.ofString(body)) .POST(HttpRequest.BodyPublishers.ofString(body))
.build(); .build();
HttpClient client = HttpClient.newHttpClient(); HttpClient client = HttpClient.newHttpClient();
var postResponse = client.send(postRequest, HttpResponse.BodyHandlers.ofString()); var postResponse = client.send(postRequest, HttpResponse.BodyHandlers.ofString());
} catch (JsonProcessingException e) { } catch (JsonProcessingException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} catch (InterruptedException e) { } catch (InterruptedException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
//LOGGER.info(postResponse.statusCode());
}; };
// for (JSONObject auction : auctions) {
// auctionStartedHandler.handleAuctionStartedEvent(
// new AuctionStartedEvent(
// new Auction(new AuctionId(auction.getAuctionId()),
// new AuctionHouseUri(new URI(auction.getAuctionHouseUri())),
// new AuctionedTaskUri(new URI(auction.getTaskUri())),
// new AuctionedTaskType(auction.getTaskType()),
// new AuctionDeadline(auction.getDeadline()))
// ));
// }
return new ResponseEntity<>(HttpStatus.OK); return new ResponseEntity<>(HttpStatus.OK);
} }
} }