improved handling of null values when mapping entities to json
This commit is contained in:
@@ -216,7 +216,12 @@ public class ProjectModule extends BaseHandler implements ProjectService {
|
||||
private boolean postProject(HttpExchange ex, UmbrellaUser user) throws IOException, UmbrellaException {
|
||||
var json = json(ex);
|
||||
if (!(json.has(NAME) && json.get(NAME) instanceof String name)) throw missingFieldException(NAME);
|
||||
var description = json.has(DESCRIPTION) && json.get(DESCRIPTION) instanceof String d ? d : null;
|
||||
String description = null;
|
||||
if (json.has(DESCRIPTION)){
|
||||
var desc = json.get(DESCRIPTION);
|
||||
if (desc instanceof String d) description = d;
|
||||
if (desc instanceof JSONObject nested && nested.has(SOURCE) && nested.get(SOURCE) instanceof String d) description = d;
|
||||
}
|
||||
Long companyId = null;
|
||||
if (json.has(COMPANY_ID) && json.get(COMPANY_ID) instanceof Number number){
|
||||
if (!companies.membership(number.longValue(), user.id())) throw forbidden("You are not a member of company {0}!",number);
|
||||
|
||||
Reference in New Issue
Block a user