preparing to create new items
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -140,6 +140,7 @@ public class StockModule extends BaseHandler implements StockService {
|
||||
if (user.isEmpty()) return unauthorized(ex);
|
||||
var head = path.pop();
|
||||
return switch (head) {
|
||||
case ITEM -> postItem(user.get(), ex);
|
||||
case LOCATION -> postLocation(user.get(),ex);
|
||||
case PROPERTY -> postProperty(user.get(),ex);
|
||||
case null, default -> super.doPost(path,ex);
|
||||
@@ -262,6 +263,13 @@ public class StockModule extends BaseHandler implements StockService {
|
||||
return sendContent(ex,location);
|
||||
}
|
||||
|
||||
private boolean postItem(UmbrellaUser user, HttpExchange ex) throws IOException {
|
||||
var json = json(ex);
|
||||
if (!json.has(NAME) || !(json.get(NAME) instanceof String name)) throw missingFieldException(NAME);
|
||||
if (!json.has(CODE) || !(json.get(CODE) instanceof String code)) throw missingFieldException(CODE);
|
||||
|
||||
}
|
||||
|
||||
private boolean postLocation(UmbrellaUser user, HttpExchange ex) throws IOException {
|
||||
var json = json(ex);
|
||||
if (!(json.get(NAME) instanceof String name)) throw missingFieldException(NAME);
|
||||
|
||||
Reference in New Issue
Block a user