Bugfixes + Security fixes #72

Merged
Maece97 merged 5 commits from dev into main 2021-11-17 17:29:38 +00:00
Showing only changes of commit 9d8e6cf216 - Show all commits

View File

@ -2,10 +2,13 @@ package ch.unisg.tapas.auctionhouse.adapter.in.web;
import ch.unisg.tapas.auctionhouse.adapter.common.formats.AuctionJsonRepresentation; import ch.unisg.tapas.auctionhouse.adapter.common.formats.AuctionJsonRepresentation;
import ch.unisg.tapas.auctionhouse.adapter.common.formats.BidJsonRepresentation; import ch.unisg.tapas.auctionhouse.adapter.common.formats.BidJsonRepresentation;
import ch.unisg.tapas.auctionhouse.adapter.in.messaging.mqtt.BidReceivedEventListenerMqttAdapter;
import ch.unisg.tapas.auctionhouse.application.handler.BidReceivedHandler; import ch.unisg.tapas.auctionhouse.application.handler.BidReceivedHandler;
import ch.unisg.tapas.auctionhouse.application.port.in.BidReceivedEvent; import ch.unisg.tapas.auctionhouse.application.port.in.BidReceivedEvent;
import ch.unisg.tapas.auctionhouse.domain.Auction; import ch.unisg.tapas.auctionhouse.domain.Auction;
import ch.unisg.tapas.auctionhouse.domain.Bid; import ch.unisg.tapas.auctionhouse.domain.Bid;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
@ -18,6 +21,8 @@ import java.net.URI;
// TODO Fix structure due to MQTT // TODO Fix structure due to MQTT
@RestController @RestController
public class AddBidWebController { public class AddBidWebController {
private static final Logger LOGGER = LogManager.getLogger(AddBidWebController.class);
@PostMapping(path = "/bid", consumes = BidJsonRepresentation.MEDIA_TYPE) @PostMapping(path = "/bid", consumes = BidJsonRepresentation.MEDIA_TYPE)
public ResponseEntity<String> addBid(@RequestBody BidJsonRepresentation payload) { public ResponseEntity<String> addBid(@RequestBody BidJsonRepresentation payload) {
BidReceivedEvent bidReceivedEvent = new BidReceivedEvent(new Bid( BidReceivedEvent bidReceivedEvent = new BidReceivedEvent(new Bid(
@ -27,6 +32,8 @@ public class AddBidWebController {
new Bid.BidderTaskListUri(URI.create(payload.getBidderTaskListUri())) new Bid.BidderTaskListUri(URI.create(payload.getBidderTaskListUri()))
)); ));
LOGGER.info("Bid received", payload);
BidReceivedHandler bidReceivedHandler = new BidReceivedHandler(); BidReceivedHandler bidReceivedHandler = new BidReceivedHandler();
bidReceivedHandler.handleNewBidReceivedEvent(bidReceivedEvent); bidReceivedHandler.handleNewBidReceivedEvent(bidReceivedEvent);