Merge pull request #72 from SCS-ASSE-FS21-Group1/dev
Bugfixes + Security fixes
This commit is contained in:
commit
1e917ec3e8
|
@ -95,6 +95,9 @@ services:
|
|||
- roster
|
||||
volumes:
|
||||
- ./:/data/
|
||||
environment:
|
||||
- executor_pool_uri: "executor-pool.86-119-35-40.nip.io"
|
||||
- roster_uri: "roster.86-119-35-40.nip.io"
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.routers.executor-computation.rule=Host(`executor-computation.${PUB_IP}.nip.io`)"
|
||||
|
@ -103,7 +106,6 @@ services:
|
|||
- "traefik.http.routers.executor-computation.tls=true"
|
||||
- "traefik.http.routers.executor-computation.entryPoints=web,websecure"
|
||||
- "traefik.http.routers.executor-computation.tls.certresolver=le"
|
||||
|
||||
executor-robot:
|
||||
image: openjdk
|
||||
command: "java -jar /data/executor-robot-0.0.1-SNAPSHOT.jar"
|
||||
|
@ -113,6 +115,9 @@ services:
|
|||
- roster
|
||||
volumes:
|
||||
- ./:/data/
|
||||
environment:
|
||||
- executor_pool_uri: "executor-pool.86-119-35-40.nip.io"
|
||||
- roster_uri: "roster.86-119-35-40.nip.io"
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.routers.executor-robot.rule=Host(`executor-robot.${PUB_IP}.nip.io`)"
|
||||
|
|
|
@ -9,16 +9,15 @@ import java.util.logging.Level;
|
|||
import java.util.logging.Logger;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
import ch.unisg.executorbase.executor.application.port.out.ExecutionFinishedEventPort;
|
||||
import ch.unisg.executorbase.executor.domain.ExecutionFinishedEvent;
|
||||
|
||||
public class ExecutionFinishedEventAdapter implements ExecutionFinishedEventPort {
|
||||
|
||||
// TODO url doesn't get mapped bc no autowiring
|
||||
@Value("${roster.url}")
|
||||
String server = "http://localhost:8082";
|
||||
String server = System.getenv("roster_uri") == null ?
|
||||
"http://localhost:8082" : System.getenv("roster_uri");
|
||||
|
||||
|
||||
Logger logger = Logger.getLogger(ExecutionFinishedEventAdapter.class.getName());
|
||||
|
||||
|
|
|
@ -23,9 +23,8 @@ import org.json.JSONObject;
|
|||
@Primary
|
||||
public class GetAssignmentAdapter implements GetAssignmentPort {
|
||||
|
||||
// TODO Not working for now bc it doesn't get autowired
|
||||
@Value("${roster.url}")
|
||||
String server = "http://127.0.0.1:8082";
|
||||
String server = System.getenv("roster_uri") == null ?
|
||||
"http://localhost:8082" : System.getenv("roster_uri");
|
||||
|
||||
Logger logger = Logger.getLogger(GetAssignmentAdapter.class.getName());
|
||||
|
||||
|
|
|
@ -22,9 +22,8 @@ import ch.unisg.executorbase.executor.domain.ExecutorType;
|
|||
@Primary
|
||||
public class NotifyExecutorPoolAdapter implements NotifyExecutorPoolPort {
|
||||
|
||||
// TODO Not working for now bc it doesn't get autowired
|
||||
@Value("${executor.pool.url}")
|
||||
String server = "http://127.0.0.1:8083";
|
||||
String server = System.getenv("executor_pool_uri") == null ?
|
||||
"http://localhost:8083" : System.getenv("executor_pool_uri");
|
||||
|
||||
Logger logger = Logger.getLogger(NotifyExecutorPoolAdapter.class.getName());
|
||||
|
||||
|
@ -35,6 +34,8 @@ public class NotifyExecutorPoolAdapter implements NotifyExecutorPoolPort {
|
|||
@Override
|
||||
public boolean notifyExecutorPool(ExecutorURI executorURI, ExecutorType executorType) {
|
||||
|
||||
System.out.println(server);
|
||||
|
||||
String body = new JSONObject()
|
||||
.put("executorTaskType", executorType)
|
||||
.put("executorUri", executorURI.getValue())
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
<dependency>
|
||||
<groupId>org.eclipse.paho</groupId>
|
||||
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||
<version>1.2.0</version>
|
||||
<version>1.2.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.transaction</groupId>
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
|
@ -23,20 +24,19 @@ import java.util.List;
|
|||
public class TapasAuctionHouseApplication {
|
||||
private static final Logger LOGGER = LogManager.getLogger(TapasAuctionHouseApplication.class);
|
||||
|
||||
@Autowired
|
||||
private ConfigProperties config;
|
||||
|
||||
public static String RESOURCE_DIRECTORY = "https://api.interactions.ics.unisg.ch/auction-houses/";
|
||||
public static String MQTT_BROKER = "tcp://broker.hivemq.com:1883";
|
||||
public static String DEFAULT_MQTT_BROKER = "tcp://broker.hivemq.com:1883";
|
||||
|
||||
private static ConfigurableEnvironment ENVIRONMENT;
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication tapasAuctioneerApp = new SpringApplication(TapasAuctionHouseApplication.class);
|
||||
ENVIRONMENT = tapasAuctioneerApp.run(args).getEnvironment();
|
||||
|
||||
// TODO Set start up of message services with config
|
||||
// We will use these bootstrap methods in Week 6:
|
||||
bootstrapMarketplaceWithWebSub();
|
||||
// bootstrapMarketplaceWithWebSub();
|
||||
bootstrapMarketplaceWithMqtt();
|
||||
|
||||
tapasAuctioneerApp.run(args);
|
||||
}
|
||||
/**
|
||||
* Discovers auction houses and subscribes to WebSub notifications
|
||||
|
@ -57,8 +57,16 @@ public class TapasAuctionHouseApplication {
|
|||
*/
|
||||
private static void bootstrapMarketplaceWithMqtt() {
|
||||
try {
|
||||
String broker = ENVIRONMENT.getProperty("mqtt.broker.uri");
|
||||
|
||||
if (broker == null) {
|
||||
broker = DEFAULT_MQTT_BROKER;
|
||||
LOGGER.info("No MQTT broker was set in application.propreties, going with default: "
|
||||
+ DEFAULT_MQTT_BROKER);
|
||||
}
|
||||
|
||||
AuctionEventsMqttDispatcher dispatcher = new AuctionEventsMqttDispatcher();
|
||||
TapasMqttClient client = TapasMqttClient.getInstance(MQTT_BROKER, dispatcher);
|
||||
TapasMqttClient client = TapasMqttClient.getInstance(broker, dispatcher);
|
||||
client.startReceivingMessages();
|
||||
} catch (MqttException e) {
|
||||
LOGGER.error(e.getMessage(), e);
|
||||
|
|
|
@ -38,6 +38,7 @@ public class ExternalAuctionStartedEventListenerMqttAdapter extends AuctionEvent
|
|||
// representation that makes sense in the context of your application.
|
||||
JsonNode data = new ObjectMapper().readTree(payload);
|
||||
|
||||
// TODO Sanitize URIs
|
||||
String auctionId = data.get("auctionId").asText();
|
||||
String auctionHouseUri = data.get("auctionHouseUri").asText();
|
||||
String taskUri = data.get("taskUri").asText();
|
||||
|
@ -72,8 +73,12 @@ public class ExternalAuctionStartedEventListenerMqttAdapter extends AuctionEvent
|
|||
LOGGER.error(e.getMessage(), e);
|
||||
return false;
|
||||
} catch (IOException e) {
|
||||
|
||||
LOGGER.error(e.getMessage(), e);
|
||||
e.printStackTrace();
|
||||
} catch (InterruptedException e) {
|
||||
|
||||
LOGGER.error(e.getMessage(), e);
|
||||
e.printStackTrace();
|
||||
} catch (Exception e){
|
||||
LOGGER.error(e.getMessage(), e);
|
||||
|
|
|
@ -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.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.port.in.BidReceivedEvent;
|
||||
import ch.unisg.tapas.auctionhouse.domain.Auction;
|
||||
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.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
@ -18,6 +21,8 @@ import java.net.URI;
|
|||
// TODO Fix structure due to MQTT
|
||||
@RestController
|
||||
public class AddBidWebController {
|
||||
private static final Logger LOGGER = LogManager.getLogger(AddBidWebController.class);
|
||||
|
||||
@PostMapping(path = "/bid", consumes = BidJsonRepresentation.MEDIA_TYPE)
|
||||
public ResponseEntity<String> addBid(@RequestBody BidJsonRepresentation payload) {
|
||||
BidReceivedEvent bidReceivedEvent = new BidReceivedEvent(new Bid(
|
||||
|
@ -27,6 +32,8 @@ public class AddBidWebController {
|
|||
new Bid.BidderTaskListUri(URI.create(payload.getBidderTaskListUri()))
|
||||
));
|
||||
|
||||
LOGGER.info("Bid received", payload);
|
||||
|
||||
BidReceivedHandler bidReceivedHandler = new BidReceivedHandler();
|
||||
bidReceivedHandler.handleNewBidReceivedEvent(bidReceivedEvent);
|
||||
|
||||
|
|
|
@ -10,4 +10,4 @@ tasks.list.uri=http://localhost:8081
|
|||
application.environment=development
|
||||
auctionhouse.uri=http://localhost:8086
|
||||
websub.hub.uri=http://localhost:3000
|
||||
mqtt.broker.uri=tcp://localhost:1883
|
||||
mqtt.broker.uri=tcp://broker.hivemq.com:1883
|
||||
|
|
|
@ -75,7 +75,7 @@
|
|||
<dependency>
|
||||
<groupId>org.eclipse.paho</groupId>
|
||||
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||
<version>1.2.0</version>
|
||||
<version>1.2.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
|
Loading…
Reference in New Issue
Block a user