Compare commits
No commits in common. "9787584d970007763a18783d00f0350bcd754cfd" and "6010208e3396790ac3b3d0ddd52107408a64aec0" have entirely different histories.
9787584d97
...
6010208e33
12 changed files with 22 additions and 85 deletions
|
|
@ -118,18 +118,6 @@
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.slf4j</groupId>
|
|
||||||
<artifactId>jul-to-slf4j</artifactId>
|
|
||||||
<version>2.0.17</version> <!-- use matching version for your SLF4J -->
|
|
||||||
</dependency>
|
|
||||||
<!-- Logback Classic logger implementation -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>ch.qos.logback</groupId>
|
|
||||||
<artifactId>logback-classic</artifactId>
|
|
||||||
<version>1.5.20</version> <!-- or latest compatible version -->
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
||||||
|
|
@ -15,17 +15,8 @@
|
||||||
*/
|
*/
|
||||||
package client;
|
package client;
|
||||||
|
|
||||||
import org.slf4j.bridge.SLF4JBridgeHandler;
|
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
static {
|
|
||||||
// Choose SLF4J Logger (Spring Boot) for JavaFX.
|
|
||||||
SLF4JBridgeHandler.removeHandlersForRootLogger();
|
|
||||||
SLF4JBridgeHandler.install();
|
|
||||||
}
|
|
||||||
public static void main(String[] args){
|
public static void main(String[] args){
|
||||||
|
|
||||||
|
|
||||||
UI.launch(UI.class, args);
|
UI.launch(UI.class, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -6,7 +6,6 @@ import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.logging.Logger;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import client.exception.InvalidModificationException;
|
import client.exception.InvalidModificationException;
|
||||||
|
|
@ -46,7 +45,7 @@ public class FoodpalApplicationCtrl implements LocaleAware {
|
||||||
private final WebSocketUtils webSocketUtils;
|
private final WebSocketUtils webSocketUtils;
|
||||||
private final LocaleManager localeManager;
|
private final LocaleManager localeManager;
|
||||||
private final WebSocketDataService<Long, Recipe> dataService;
|
private final WebSocketDataService<Long, Recipe> dataService;
|
||||||
private final Logger logger = Logger.getLogger(FoodpalApplicationCtrl.class.getName());
|
|
||||||
@FXML
|
@FXML
|
||||||
private RecipeDetailCtrl recipeDetailController;
|
private RecipeDetailCtrl recipeDetailController;
|
||||||
|
|
||||||
|
|
@ -94,31 +93,24 @@ public class FoodpalApplicationCtrl implements LocaleAware {
|
||||||
this.configService = configService;
|
this.configService = configService;
|
||||||
this.dataService = recipeDataService;
|
this.dataService = recipeDataService;
|
||||||
setupDataService();
|
setupDataService();
|
||||||
logger.info("WebSocket processor initialized.");
|
|
||||||
initializeWebSocket();
|
initializeWebSocket();
|
||||||
logger.info("WebSocket connection handler initialized.");
|
|
||||||
logger.info("Main application controller initialized.");
|
|
||||||
}
|
}
|
||||||
private void setupDataService() {
|
private void setupDataService() {
|
||||||
dataService.setMessageParser((msg) -> switch (msg) {
|
dataService.setMessageParser((msg) -> switch (msg) {
|
||||||
case CreateRecipeMessage _ -> (m) -> {
|
case CreateRecipeMessage _ -> (m) -> {
|
||||||
CreateRecipeMessage crm = (CreateRecipeMessage) m;
|
CreateRecipeMessage crm = (CreateRecipeMessage) m;
|
||||||
logger.info("Server informs us of creation of recipe: " + crm.getRecipe());
|
|
||||||
return handleCreateRecipeMessage(crm);
|
return handleCreateRecipeMessage(crm);
|
||||||
};
|
};
|
||||||
case UpdateRecipeMessage _ -> (m) -> {
|
case UpdateRecipeMessage _ -> (m) -> {
|
||||||
UpdateRecipeMessage urm = (UpdateRecipeMessage) m;
|
UpdateRecipeMessage urm = (UpdateRecipeMessage) m;
|
||||||
logger.info("Server informs us of update for recipe: " + urm.getRecipe());
|
|
||||||
return handleUpdateRecipeMessage(urm);
|
return handleUpdateRecipeMessage(urm);
|
||||||
};
|
};
|
||||||
case DeleteRecipeMessage _ -> (m) -> {
|
case DeleteRecipeMessage _ -> (m) -> {
|
||||||
DeleteRecipeMessage drm = (DeleteRecipeMessage) m;
|
DeleteRecipeMessage drm = (DeleteRecipeMessage) m;
|
||||||
logger.info("Server informs us of the deletion of recipe with ID: " + drm.getRecipeId());
|
|
||||||
return handleDeleteRecipeMessage(drm);
|
return handleDeleteRecipeMessage(drm);
|
||||||
};
|
};
|
||||||
case FavouriteRecipeMessage _ -> (m) -> {
|
case FavouriteRecipeMessage _ -> (m) -> {
|
||||||
FavouriteRecipeMessage frm = (FavouriteRecipeMessage) m;
|
FavouriteRecipeMessage frm = (FavouriteRecipeMessage) m;
|
||||||
logger.info("Server informs us of a favourite recipe being deleted: " + frm.getRecipeId());
|
|
||||||
return handleFavouriteRecipeMessage(frm);
|
return handleFavouriteRecipeMessage(frm);
|
||||||
};
|
};
|
||||||
default -> throw new IllegalStateException("Unexpected value: " + msg);
|
default -> throw new IllegalStateException("Unexpected value: " + msg);
|
||||||
|
|
@ -193,7 +185,7 @@ public class FoodpalApplicationCtrl implements LocaleAware {
|
||||||
|
|
||||||
this.recipeList.getItems().setAll(recipes);
|
this.recipeList.getItems().setAll(recipes);
|
||||||
|
|
||||||
logger.info("Search returned " + recipes.size() + " recipes.");
|
System.out.println("Search returned " + recipes.size() + " recipes.");
|
||||||
|
|
||||||
// Restore selection, if possible
|
// Restore selection, if possible
|
||||||
if (newIndex != -1) {
|
if (newIndex != -1) {
|
||||||
|
|
@ -271,9 +263,7 @@ public class FoodpalApplicationCtrl implements LocaleAware {
|
||||||
recipes = server.getRecipesFiltered(searchBarController.getFilter());
|
recipes = server.getRecipesFiltered(searchBarController.getFilter());
|
||||||
} catch (IOException | InterruptedException e) {
|
} catch (IOException | InterruptedException e) {
|
||||||
recipes = Collections.emptyList();
|
recipes = Collections.emptyList();
|
||||||
String msg = "Failed to load recipes: " + e.getMessage();
|
System.err.println("Failed to load recipes: " + e.getMessage());
|
||||||
logger.severe(msg);
|
|
||||||
printError(msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
allRecipes = new ArrayList<>(recipes);
|
allRecipes = new ArrayList<>(recipes);
|
||||||
|
|
@ -305,10 +295,7 @@ public class FoodpalApplicationCtrl implements LocaleAware {
|
||||||
dataService.add(newRecipe.getId(), recipe -> {
|
dataService.add(newRecipe.getId(), recipe -> {
|
||||||
this.recipeList.getSelectionModel().select(recipe);
|
this.recipeList.getSelectionModel().select(recipe);
|
||||||
openSelectedRecipe();
|
openSelectedRecipe();
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> this.recipeDetailController.editRecipeTitle());
|
||||||
logger.info("Focused recipe title edit box.");
|
|
||||||
this.recipeDetailController.editRecipeTitle();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
recipeList.refresh();
|
recipeList.refresh();
|
||||||
} catch (IOException | InterruptedException e) {
|
} catch (IOException | InterruptedException e) {
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ import javafx.util.StringConverter;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The language selection menu controller.
|
* The language selection menu controller.
|
||||||
|
|
@ -23,7 +22,6 @@ import java.util.logging.Logger;
|
||||||
* <code>getLocaleString(String)</code> function is available.
|
* <code>getLocaleString(String)</code> function is available.
|
||||||
*/
|
*/
|
||||||
public class LangSelectMenuCtrl implements LocaleAware {
|
public class LangSelectMenuCtrl implements LocaleAware {
|
||||||
private final Logger logger = Logger.getLogger(LangSelectMenuCtrl.class.getName());
|
|
||||||
public ComboBox<String> langSelectMenu;
|
public ComboBox<String> langSelectMenu;
|
||||||
private final LocaleManager manager;
|
private final LocaleManager manager;
|
||||||
|
|
||||||
|
|
@ -39,7 +37,6 @@ public class LangSelectMenuCtrl implements LocaleAware {
|
||||||
@FXML
|
@FXML
|
||||||
private void switchLocale(ActionEvent event) {
|
private void switchLocale(ActionEvent event) {
|
||||||
String lang = langSelectMenu.getSelectionModel().getSelectedItem();
|
String lang = langSelectMenu.getSelectionModel().getSelectedItem();
|
||||||
logger.info("Switching locale to " + lang);
|
|
||||||
manager.setLocale(Locale.of(lang));
|
manager.setLocale(Locale.of(lang));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -207,7 +207,7 @@ public class RecipeDetailCtrl implements LocaleAware {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
server.updateRecipe(this.recipe);
|
server.updateRecipe(this.recipe);
|
||||||
// this.refresh();
|
this.refresh();
|
||||||
} catch (IOException | InterruptedException e) {
|
} catch (IOException | InterruptedException e) {
|
||||||
// throw a nice blanket UpdateException
|
// throw a nice blanket UpdateException
|
||||||
throw new UpdateException("Error occurred when updating recipe name!");
|
throw new UpdateException("Error occurred when updating recipe name!");
|
||||||
|
|
|
||||||
|
|
@ -7,12 +7,10 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
public class ConfigService {
|
public class ConfigService {
|
||||||
private final Path configPath;
|
private final Path configPath;
|
||||||
private final ObjectMapper mapper = new ObjectMapper();
|
private final ObjectMapper mapper = new ObjectMapper();
|
||||||
private final Logger logger = Logger.getLogger(ConfigService.class.getName());
|
|
||||||
private Config config;
|
private Config config;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -72,10 +70,9 @@ public class ConfigService {
|
||||||
try {
|
try {
|
||||||
File file = configPath.toFile(); // file is the config file here
|
File file = configPath.toFile(); // file is the config file here
|
||||||
mapper.writeValue(file, config); // here we edit the value of the file using config
|
mapper.writeValue(file, config); // here we edit the value of the file using config
|
||||||
logger.info("Config saved to " + file.getAbsolutePath());
|
|
||||||
}
|
}
|
||||||
catch (Exception e){
|
catch (Exception e){
|
||||||
logger.severe("Something bad happened while saving the config: " + e.getMessage());
|
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,14 +18,12 @@ import java.net.http.HttpRequest;
|
||||||
import java.net.http.HttpResponse;
|
import java.net.http.HttpResponse;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import static jakarta.ws.rs.core.MediaType.APPLICATION_JSON;
|
import static jakarta.ws.rs.core.MediaType.APPLICATION_JSON;
|
||||||
|
|
||||||
|
|
||||||
public class ServerUtils {
|
public class ServerUtils {
|
||||||
private static final String SERVER = "http://localhost:8080/api";
|
private static final String SERVER = "http://localhost:8080/api";
|
||||||
private Logger logger = Logger.getLogger(ServerUtils.class.getName());
|
|
||||||
private final HttpClient client;
|
private final HttpClient client;
|
||||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||||
private final int statusOK = 200;
|
private final int statusOK = 200;
|
||||||
|
|
@ -50,10 +48,9 @@ public class ServerUtils {
|
||||||
throw new IOException("No recipe to get. Server responds with " + response.body());
|
throw new IOException("No recipe to get. Server responds with " + response.body());
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Recipe> list = objectMapper.readValue(response.body(), new TypeReference<List<Recipe>>() {
|
|
||||||
});
|
return objectMapper.readValue(response.body(), new TypeReference<List<Recipe>>() {
|
||||||
logger.info("Received response from server: " + list);
|
});// JSON string-> List<Recipe> (Jackson)
|
||||||
return list; // JSON string-> List<Recipe> (Jackson)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Recipe> getRecipesFiltered(String filter) throws IOException, InterruptedException {
|
public List<Recipe> getRecipesFiltered(String filter) throws IOException, InterruptedException {
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,8 @@ import java.util.Map;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
public class WebSocketDataService<ID, Value> {
|
public class WebSocketDataService<ID, Value> {
|
||||||
private Logger logger = Logger.getLogger(WebSocketDataService.class.getName());
|
|
||||||
public WebSocketDataService() {
|
public WebSocketDataService() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -51,11 +49,7 @@ public class WebSocketDataService<ID, Value> {
|
||||||
*/
|
*/
|
||||||
public boolean add(ID id, Consumer<Value> onComplete) {
|
public boolean add(ID id, Consumer<Value> onComplete) {
|
||||||
CompletableFuture<Value> future = new CompletableFuture<>();
|
CompletableFuture<Value> future = new CompletableFuture<>();
|
||||||
future.thenAccept(onComplete.andThen(_ -> {
|
future.thenAccept(onComplete.andThen(_ -> pendingRegister.remove(id)));
|
||||||
logger.info("Item " + id + " resolved. Removing from pending register.");
|
|
||||||
pendingRegister.remove(id);
|
|
||||||
}));
|
|
||||||
logger.info("Item " + id + " pending propagation. Adding to pending register.");
|
|
||||||
return pendingRegister.putIfAbsent(id, future) == null;
|
return pendingRegister.putIfAbsent(id, future) == null;
|
||||||
}
|
}
|
||||||
public boolean add(ID id) {
|
public boolean add(ID id) {
|
||||||
|
|
|
||||||
|
|
@ -14,13 +14,11 @@ import java.lang.reflect.Type;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
public class WebSocketUtils {
|
public class WebSocketUtils {
|
||||||
private static final String WS_URL = "ws://localhost:8080/updates";
|
private static final String WS_URL = "ws://localhost:8080/updates";
|
||||||
private WebSocketStompClient stompClient;
|
private WebSocketStompClient stompClient;
|
||||||
private StompSession stompSession;
|
private StompSession stompSession;
|
||||||
private Logger logger = Logger.getLogger(WebSocketUtils.class.getName());
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connect to the websocket server.
|
* Connect to the websocket server.
|
||||||
|
|
@ -38,19 +36,21 @@ public class WebSocketUtils {
|
||||||
@Override
|
@Override
|
||||||
public void afterConnected(StompSession session, StompHeaders connectedHeaders) {
|
public void afterConnected(StompSession session, StompHeaders connectedHeaders) {
|
||||||
stompSession = session;
|
stompSession = session;
|
||||||
logger.info("WebSocket connected with session ID: " + session.getSessionId());
|
System.out.println("WebSocket connected: " + session.getSessionId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleException(StompSession session, @Nullable StompCommand command,
|
public void handleException(StompSession session, @Nullable StompCommand command,
|
||||||
StompHeaders headers, byte[] payload,
|
StompHeaders headers, byte[] payload,
|
||||||
Throwable exception) {
|
Throwable exception) {
|
||||||
logger.severe("STOMP error: " + exception.getMessage());
|
System.err.println("STOMP error: " + exception.getMessage());
|
||||||
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleTransportError(StompSession session, Throwable exception) {
|
public void handleTransportError(StompSession session, Throwable exception) {
|
||||||
logger.severe("STOMP transport error: " + exception.getMessage());
|
System.err.println("STOMP transport error: " + exception.getMessage());
|
||||||
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -103,14 +103,6 @@ public class Ingredient {
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(id, name, proteinPer100g, fatPer100g, carbsPer100g);
|
return Objects.hash(id, name, proteinPer100g, fatPer100g, carbsPer100g);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Ingredient " + id + " - " + name +
|
|
||||||
"= P:" + proteinPer100g +
|
|
||||||
"/F:" + fatPer100g +
|
|
||||||
"/C:" + carbsPer100g + " per 100g";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -157,10 +157,12 @@ public class Recipe {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Recipe " + id +
|
return "Recipe{" +
|
||||||
" - " + name +
|
"id=" + id +
|
||||||
": " + ingredients.size() + " ingredients / " +
|
", name='" + name + '\'' +
|
||||||
preparationSteps.size() + " steps";
|
", ingredientsCount=" + ingredients.size() +
|
||||||
|
", preparationStepsCount=" + preparationSteps.size() +
|
||||||
|
"}";
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
|
|
||||||
|
|
@ -24,19 +24,16 @@ import server.service.RecipeService;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api")
|
@RequestMapping("/api")
|
||||||
public class RecipeController {
|
public class RecipeController {
|
||||||
private static final Logger logger = Logger.getLogger(RecipeController.class.getName());
|
|
||||||
private final SimpMessagingTemplate messagingTemplate;
|
private final SimpMessagingTemplate messagingTemplate;
|
||||||
private final RecipeService recipeService;
|
private final RecipeService recipeService;
|
||||||
|
|
||||||
public RecipeController(RecipeService recipeService, SimpMessagingTemplate messagingTemplate) {
|
public RecipeController(RecipeService recipeService, SimpMessagingTemplate messagingTemplate) {
|
||||||
this.recipeService = recipeService;
|
this.recipeService = recipeService;
|
||||||
this.messagingTemplate = messagingTemplate;
|
this.messagingTemplate = messagingTemplate;
|
||||||
logger.info("Initialized controller.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -49,7 +46,6 @@ public class RecipeController {
|
||||||
*/
|
*/
|
||||||
@GetMapping("/recipe/{id}")
|
@GetMapping("/recipe/{id}")
|
||||||
public ResponseEntity<Recipe> getRecipe(@PathVariable Long id) {
|
public ResponseEntity<Recipe> getRecipe(@PathVariable Long id) {
|
||||||
logger.info("GET /recipe/" + id + " called.");
|
|
||||||
return recipeService.findById(id)
|
return recipeService.findById(id)
|
||||||
.map(ResponseEntity::ok)
|
.map(ResponseEntity::ok)
|
||||||
.orElseGet(() -> ResponseEntity.notFound().build());
|
.orElseGet(() -> ResponseEntity.notFound().build());
|
||||||
|
|
@ -64,7 +60,6 @@ public class RecipeController {
|
||||||
*/
|
*/
|
||||||
@GetMapping("/recipes")
|
@GetMapping("/recipes")
|
||||||
public ResponseEntity<List<Recipe>> getRecipes(@RequestParam Optional<Integer> limit) {
|
public ResponseEntity<List<Recipe>> getRecipes(@RequestParam Optional<Integer> limit) {
|
||||||
logger.info("GET /recipes called.");
|
|
||||||
return ResponseEntity.ok(
|
return ResponseEntity.ok(
|
||||||
// Choose the right overload. One has a limit, other doesn't.
|
// Choose the right overload. One has a limit, other doesn't.
|
||||||
limit.map(recipeService::findAll).orElseGet(recipeService::findAll)
|
limit.map(recipeService::findAll).orElseGet(recipeService::findAll)
|
||||||
|
|
@ -81,7 +76,6 @@ public class RecipeController {
|
||||||
*/
|
*/
|
||||||
@PostMapping("/recipe/{id}")
|
@PostMapping("/recipe/{id}")
|
||||||
public ResponseEntity<Recipe> updateRecipe(@PathVariable Long id, @RequestBody Recipe recipe) {
|
public ResponseEntity<Recipe> updateRecipe(@PathVariable Long id, @RequestBody Recipe recipe) {
|
||||||
logger.info("POST /recipe/" + id + " called.");
|
|
||||||
return recipeService.update(id, recipe)
|
return recipeService.update(id, recipe)
|
||||||
.map(saved -> {
|
.map(saved -> {
|
||||||
messagingTemplate.convertAndSend(Topics.RECIPES, new UpdateRecipeMessage(saved)); // Send to WS.
|
messagingTemplate.convertAndSend(Topics.RECIPES, new UpdateRecipeMessage(saved)); // Send to WS.
|
||||||
|
|
@ -102,7 +96,6 @@ public class RecipeController {
|
||||||
*/
|
*/
|
||||||
@PutMapping("/recipe/new")
|
@PutMapping("/recipe/new")
|
||||||
public ResponseEntity<Recipe> createRecipe(@RequestBody Recipe recipe) {
|
public ResponseEntity<Recipe> createRecipe(@RequestBody Recipe recipe) {
|
||||||
logger.info("POST /recipe/new called.");
|
|
||||||
return recipeService.create(recipe)
|
return recipeService.create(recipe)
|
||||||
.map(saved -> {
|
.map(saved -> {
|
||||||
messagingTemplate.convertAndSend(Topics.RECIPES, new CreateRecipeMessage(saved)); // Send to WS.
|
messagingTemplate.convertAndSend(Topics.RECIPES, new CreateRecipeMessage(saved)); // Send to WS.
|
||||||
|
|
@ -121,7 +114,6 @@ public class RecipeController {
|
||||||
*/
|
*/
|
||||||
@DeleteMapping("/recipe/{id}")
|
@DeleteMapping("/recipe/{id}")
|
||||||
public ResponseEntity<Boolean> deleteRecipe(@PathVariable Long id) {
|
public ResponseEntity<Boolean> deleteRecipe(@PathVariable Long id) {
|
||||||
logger.info("DELETE /recipe/" + id + " called.");
|
|
||||||
if (!recipeService.delete(id)) {
|
if (!recipeService.delete(id)) {
|
||||||
return ResponseEntity.badRequest().build();
|
return ResponseEntity.badRequest().build();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue