|
|
|
@ -140,6 +140,7 @@ public class StockModule extends BaseHandler implements StockService { |
|
|
|
if (user.isEmpty()) return unauthorized(ex); |
|
|
|
if (user.isEmpty()) return unauthorized(ex); |
|
|
|
var head = path.pop(); |
|
|
|
var head = path.pop(); |
|
|
|
return switch (head) { |
|
|
|
return switch (head) { |
|
|
|
|
|
|
|
case ITEM -> postItem(user.get(), ex); |
|
|
|
case LOCATION -> postLocation(user.get(),ex); |
|
|
|
case LOCATION -> postLocation(user.get(),ex); |
|
|
|
case PROPERTY -> postProperty(user.get(),ex); |
|
|
|
case PROPERTY -> postProperty(user.get(),ex); |
|
|
|
case null, default -> super.doPost(path,ex); |
|
|
|
case null, default -> super.doPost(path,ex); |
|
|
|
@ -262,6 +263,13 @@ public class StockModule extends BaseHandler implements StockService { |
|
|
|
return sendContent(ex,location); |
|
|
|
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 { |
|
|
|
private boolean postLocation(UmbrellaUser user, HttpExchange ex) throws IOException { |
|
|
|
var json = json(ex); |
|
|
|
var json = json(ex); |
|
|
|
if (!(json.get(NAME) instanceof String name)) throw missingFieldException(NAME); |
|
|
|
if (!(json.get(NAME) instanceof String name)) throw missingFieldException(NAME); |
|
|
|
|