diff --git a/pom.xml b/pom.xml
index bb55df83..82714bdb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
org.springframework.boot
spring-boot-starter-parent
- 3.3.5
+ 3.3.6
@@ -23,11 +23,11 @@
21
- 3.4.1
+ 3.5.0
5.13.0
3.5.3
3.8.4
- 8.4.2
+ 8.5.0
diff --git a/srv/admin-service.cds b/srv/admin-service.cds
index 0f0e1a9b..ec1deef9 100644
--- a/srv/admin-service.cds
+++ b/srv/admin-service.cds
@@ -32,6 +32,12 @@ annotate AdminService.Books with @cds.search : {
title
};
+annotate AdminService.OrderItems with {
+ @mandatory
+ @assert.range: [(0), _]
+ quantity
+};
+
// Enable Fiori Draft for Orders
annotate AdminService.Orders with @odata.draft.enabled;
annotate AdminService.Books with @odata.draft.enabled;
diff --git a/srv/src/main/java/my/bookshop/MessageKeys.java b/srv/src/main/java/my/bookshop/MessageKeys.java
index 9f217eb9..70e7de3d 100644
--- a/srv/src/main/java/my/bookshop/MessageKeys.java
+++ b/srv/src/main/java/my/bookshop/MessageKeys.java
@@ -2,7 +2,6 @@
public class MessageKeys {
- public static final String QUANTITY_REQUIRE_MINIMUM = "quantity.require.minimum";
public static final String BOOK_REQUIRE_STOCK = "book.require.stock";
public static final String BOOK_ADDED_ORDER = "book.added.order";
public static final String BOOK_MISSING = "book.missing";
diff --git a/srv/src/main/java/my/bookshop/handlers/AdminServiceHandler.java b/srv/src/main/java/my/bookshop/handlers/AdminServiceHandler.java
index b80844d7..cbe21c57 100644
--- a/srv/src/main/java/my/bookshop/handlers/AdminServiceHandler.java
+++ b/srv/src/main/java/my/bookshop/handlers/AdminServiceHandler.java
@@ -94,14 +94,6 @@ public void beforeCreateOrder(Stream orders, EventContext context) {
order.getItems().forEach(orderItem -> {
// validation of the Order creation request
Integer quantity = orderItem.getQuantity();
- if (quantity == null || quantity <= 0) {
- // errors with localized messages from property files
- // exceptions abort the request and set an error http status code
- // messages in contrast allow to collect multiple errors
- messages.error(MessageKeys.QUANTITY_REQUIRE_MINIMUM)
- .target("in", ORDERS, o -> o.Items(i -> i.ID().eq(orderItem.getId()).and(i.IsActiveEntity().eq(orderItem.getIsActiveEntity()))).quantity());
- }
-
String bookId = orderItem.getBookId();
if(quantity == null || quantity <= 0 || bookId == null) {
diff --git a/srv/src/main/resources/messages.properties b/srv/src/main/resources/messages.properties
index b0e769b8..4eae0b84 100644
--- a/srv/src/main/resources/messages.properties
+++ b/srv/src/main/resources/messages.properties
@@ -1,4 +1,3 @@
-quantity.require.minimum = The specified quantity is smaller than 1
book.require.stock = Not enough books on stock (only {0} left)
book.added.order = Book successfully added to order
book.missing = Book does not exist
diff --git a/srv/src/main/resources/messages_de.properties b/srv/src/main/resources/messages_de.properties
index f498bbe0..bc7c1718 100644
--- a/srv/src/main/resources/messages_de.properties
+++ b/srv/src/main/resources/messages_de.properties
@@ -1,4 +1,3 @@
-quantity.require.minimum = Die eingetragene Anzahl ist kleiner als 1
book.require.stock = Nicht genügend Bücher auf Vorrat (nur {0} übrig)
book.added.order = Das Buch wurde der Bestellung erfolgreich hinzugefügt
book.missing = Das Buch existiert nicht