@@ -173,8 +173,8 @@ public String ping(HttpServletRequest req, HttpServletResponse res) {
173173 }
174174
175175 @ PostMapping ("/posts" )
176- public Map <String , Object > createPost (HttpServletRequest req , HttpServletResponse res ) {
177- Map <String , Object > entity = readEntity (req );
176+ public Map <String , Object > createPost (Map < String , Object > override , HttpServletRequest req , HttpServletResponse res ) {
177+ Map <String , Object > entity = readEntity (override , req );
178178 if (!entity .containsKey (Config ._TYPE )) {
179179 entity .put (Config ._TYPE , POST_TYPES [0 ]);
180180 } else if (!Strings .CI .equalsAny ((CharSequence ) entity .get (Config ._TYPE ), POST_TYPES )) {
@@ -255,8 +255,9 @@ public Map<String, Object> getPost(@PathVariable String id, @RequestParam(requir
255255 }
256256
257257 @ PatchMapping ("/posts/{id}" )
258- public Post updatePost (@ PathVariable String id , HttpServletRequest req , HttpServletResponse res ) {
259- Map <String , Object > entity = readEntity (req );
258+ public Post updatePost (@ PathVariable String id , Map <String , Object > override ,
259+ HttpServletRequest req , HttpServletResponse res ) {
260+ Map <String , Object > entity = readEntity (override , req );
260261 if (entity .isEmpty ()) {
261262 badReq ("Missing or invalid request body." );
262263 }
@@ -295,10 +296,10 @@ public void deletePost(@PathVariable String id, HttpServletRequest req, HttpServ
295296 }
296297
297298 @ PatchMapping ("/posts/{id}/tags" )
298- public Post updatePostTags (@ PathVariable String id , @ RequestParam ( required = false ) String sortby ,
299+ public Post updatePostTags (@ PathVariable String id , Map < String , Object > override ,
299300 HttpServletRequest req , HttpServletResponse res ) {
300301 Model model = new ExtendedModelMap ();
301- Map <String , Object > entity = readEntity (req );
302+ Map <String , Object > entity = readEntity (override , req );
302303 if (entity .isEmpty ()) {
303304 badReq ("Missing or invalid request body." );
304305 }
@@ -309,7 +310,7 @@ public Post updatePostTags(@PathVariable String id, @RequestParam(required = fal
309310 req .setAttribute (AUTH_USER_ATTRIBUTE , authUser );
310311 }
311312 }
312- questionController .get (id , "" , sortby , req , res , model );
313+ questionController .get (id , "" , "" , req , res , model );
313314 Post post = (Post ) model .getAttribute ("showPost" );
314315 if (post == null ) {
315316 res .setStatus (HttpStatus .NOT_FOUND .value ());
@@ -427,8 +428,8 @@ public List<Map<String, Object>> getPostRevisions(@PathVariable String id,
427428 }
428429
429430 @ PostMapping ("/users" )
430- public Map <String , Object > createUser (HttpServletRequest req , HttpServletResponse res ) {
431- Map <String , Object > entity = readEntity (req );
431+ public Map <String , Object > createUser (Map < String , Object > override , HttpServletRequest req , HttpServletResponse res ) {
432+ Map <String , Object > entity = readEntity (override , req );
432433 if (entity .isEmpty ()) {
433434 badReq ("Missing or invalid request body." );
434435 }
@@ -528,8 +529,9 @@ public Map<String, Object> getUser(@PathVariable String id, HttpServletRequest r
528529
529530 @ PatchMapping ("/users/{id}" )
530531 @ SuppressWarnings ("unchecked" )
531- public Profile updateUser (@ PathVariable String id , HttpServletRequest req , HttpServletResponse res ) {
532- Map <String , Object > entity = readEntity (req );
532+ public Profile updateUser (@ PathVariable String id , Map <String , Object > override ,
533+ HttpServletRequest req , HttpServletResponse res ) {
534+ Map <String , Object > entity = readEntity (override , req );
533535 if (entity .isEmpty ()) {
534536 badReq ("Missing or invalid request body." );
535537 }
@@ -657,8 +659,8 @@ public void banUser(@PathVariable String id,
657659 }
658660
659661 @ PutMapping ("/users/spaces" )
660- public void bulkEditSpaces (HttpServletRequest req , HttpServletResponse res ) {
661- Map <String , Object > entity = readEntity (req );
662+ public void bulkEditSpaces (Map < String , Object > override , HttpServletRequest req , HttpServletResponse res ) {
663+ Map <String , Object > entity = readEntity (override , req );
662664 if (entity .isEmpty ()) {
663665 badReq ("Missing or invalid request body." );
664666 }
@@ -674,8 +676,8 @@ public void bulkEditSpaces(HttpServletRequest req, HttpServletResponse res) {
674676 }
675677
676678 @ PostMapping ("/tags" )
677- public Tag createTag (HttpServletRequest req , HttpServletResponse res ) {
678- Map <String , Object > entity = readEntity (req );
679+ public Tag createTag (Map < String , Object > override , HttpServletRequest req , HttpServletResponse res ) {
680+ Map <String , Object > entity = readEntity (override , req );
679681 if (entity .isEmpty ()) {
680682 badReq ("Missing or invalid request body." );
681683 }
@@ -711,8 +713,9 @@ public Tag getTag(@PathVariable String id, HttpServletRequest req, HttpServletRe
711713 }
712714
713715 @ PatchMapping ("/tags/{id}" )
714- public Tag updateTag (@ PathVariable String id , HttpServletRequest req , HttpServletResponse res ) {
715- Map <String , Object > entity = readEntity (req );
716+ public Tag updateTag (@ PathVariable String id , Map <String , Object > override ,
717+ HttpServletRequest req , HttpServletResponse res ) {
718+ Map <String , Object > entity = readEntity (override , req );
716719 if (entity .isEmpty ()) {
717720 badReq ("Missing or invalid request body." );
718721 }
@@ -743,8 +746,8 @@ public List<Map<String, Object>> listTaggedQuestions(@PathVariable String id,
743746 }
744747
745748 @ PostMapping ("/comments" )
746- public Comment createComment (HttpServletRequest req , HttpServletResponse res ) {
747- Map <String , Object > entity = readEntity (req );
749+ public Comment createComment (Map < String , Object > override , HttpServletRequest req , HttpServletResponse res ) {
750+ Map <String , Object > entity = readEntity (override , req );
748751 if (entity .isEmpty ()) {
749752 badReq ("Missing or invalid request body." );
750753 }
@@ -789,8 +792,8 @@ public void deleteComment(@PathVariable String id, HttpServletRequest req, HttpS
789792 }
790793
791794 @ PostMapping ("/reports" )
792- public Report createReport (HttpServletRequest req , HttpServletResponse res ) {
793- Map <String , Object > entity = readEntity (req );
795+ public Report createReport (Map < String , Object > override , HttpServletRequest req , HttpServletResponse res ) {
796+ Map <String , Object > entity = readEntity (override , req );
794797 if (entity .isEmpty ()) {
795798 badReq ("Missing or invalid request body." );
796799 }
@@ -833,16 +836,17 @@ public void deleteReport(@PathVariable String id, HttpServletRequest req, HttpSe
833836 }
834837
835838 @ PutMapping ("/reports/{id}/close" )
836- public void closeReport (@ PathVariable String id , HttpServletRequest req , HttpServletResponse res ) {
837- Map <String , Object > entity = readEntity (req );
838- String solution = (String ) entity .getOrDefault ("solution" , "Closed via API." );
839- reportsController .close (id , solution , req , res );
839+ public void closeReport (@ PathVariable String id ,
840+ @ RequestParam (required = false , defaultValue = "Closed via API." ) String solution ,
841+ HttpServletRequest req , HttpServletResponse res ) {
842+ Map <String , Object > entity = readEntity (null , req );
843+ reportsController .close (id , (String ) entity .getOrDefault ("solution" , solution ), req , res );
840844 }
841845
842846 @ PostMapping ("/spaces" )
843847 public Sysprop createSpace (@ RequestParam (required = false , defaultValue = "false" ) Boolean assigntoall ,
844- HttpServletRequest req , HttpServletResponse res ) {
845- Map <String , Object > entity = readEntity (req );
848+ Map < String , Object > override , HttpServletRequest req , HttpServletResponse res ) {
849+ Map <String , Object > entity = readEntity (override , req );
846850 if (entity .isEmpty ()) {
847851 badReq ("Missing or invalid request body." );
848852 }
@@ -867,8 +871,8 @@ public Sysprop createSpace(@RequestParam(required = false, defaultValue = "false
867871 public void updateSpace (@ PathVariable String id ,
868872 @ RequestParam (required = false , defaultValue = "false" ) Boolean assigntoall ,
869873 @ RequestParam (required = false , defaultValue = "false" ) Boolean needsapproval ,
870- HttpServletRequest req , HttpServletResponse res ) {
871- Map <String , Object > entity = readEntity (req );
874+ Map < String , Object > override , HttpServletRequest req , HttpServletResponse res ) {
875+ Map <String , Object > entity = readEntity (override , req );
872876 if (entity .isEmpty ()) {
873877 badReq ("Missing or invalid request body." );
874878 }
@@ -907,12 +911,12 @@ public void deleteSpace(@PathVariable String id, HttpServletRequest req, HttpSer
907911 }
908912
909913 @ PostMapping ("/webhooks" )
910- public Webhook createWebhook (HttpServletRequest req , HttpServletResponse res ) {
914+ public Webhook createWebhook (Map < String , Object > override , HttpServletRequest req , HttpServletResponse res ) {
911915 if (!utils .isWebhooksEnabled ()) {
912916 res .setStatus (HttpStatus .FORBIDDEN .value ());
913917 return null ;
914918 }
915- Map <String , Object > entity = readEntity (req );
919+ Map <String , Object > entity = readEntity (override , req );
916920 if (entity .isEmpty ()) {
917921 badReq ("Missing or invalid request body." );
918922 return null ;
@@ -962,7 +966,8 @@ public Webhook getWebhook(@PathVariable String id, HttpServletRequest req, HttpS
962966 }
963967
964968 @ PatchMapping ("/webhooks/{id}" )
965- public Webhook updateWebhook (@ PathVariable String id , HttpServletRequest req , HttpServletResponse res ) {
969+ public Webhook updateWebhook (@ PathVariable String id , Map <String , Object > override ,
970+ HttpServletRequest req , HttpServletResponse res ) {
966971 if (!utils .isWebhooksEnabled ()) {
967972 res .setStatus (HttpStatus .FORBIDDEN .value ());
968973 return null ;
@@ -972,7 +977,7 @@ public Webhook updateWebhook(@PathVariable String id, HttpServletRequest req, Ht
972977 res .setStatus (HttpStatus .NOT_FOUND .value ());
973978 return null ;
974979 }
975- Map <String , Object > entity = readEntity (req );
980+ Map <String , Object > entity = readEntity (override , req );
976981 return pc .update (ParaObjectUtils .setAnnotatedFields (webhook , entity , Locked .class ));
977982 }
978983
@@ -1108,7 +1113,7 @@ public String config(@RequestParam(required = false, defaultValue = "json") Stri
11081113 }
11091114
11101115 @ PutMapping ("/config" )
1111- public String configSet (HttpServletRequest req , HttpServletResponse res ) {
1116+ public String configSet (Map < String , Object > override , HttpServletRequest req , HttpServletResponse res ) {
11121117 com .typesafe .config .Config modifiedConf = com .typesafe .config .ConfigFactory .empty ();
11131118 String format ;
11141119 if ("application/hocon" .equals (req .getContentType ())) {
@@ -1124,7 +1129,7 @@ public String configSet(HttpServletRequest req, HttpServletResponse res) {
11241129 }
11251130 } else {
11261131 format = "json" ;
1127- Map <String , Object > entity = readEntity (req );
1132+ Map <String , Object > entity = readEntity (override , req );
11281133 if (entity .isEmpty ()) {
11291134 badReq ("Missing or invalid request body." );
11301135 }
@@ -1151,8 +1156,9 @@ public Map<String, Object> configGet(@PathVariable String key, HttpServletReques
11511156 }
11521157
11531158 @ PutMapping ("/config/set/{key}" )
1154- public void configSet (@ PathVariable String key , HttpServletRequest req , HttpServletResponse res ) {
1155- Map <String , Object > entity = readEntity (req );
1159+ public void configSet (@ PathVariable String key , Map <String , Object > override ,
1160+ HttpServletRequest req , HttpServletResponse res ) {
1161+ Map <String , Object > entity = readEntity (override , req );
11561162 if (entity .isEmpty ()) {
11571163 badReq ("Missing or invalid request body." );
11581164 }
@@ -1265,10 +1271,14 @@ private Map<String, Object> healthCheck() {
12651271 return healthObj ;
12661272 }
12671273
1268- private Map <String , Object > readEntity (HttpServletRequest req ) {
1274+ private Map <String , Object > readEntity (Map < String , Object > override , HttpServletRequest req ) {
12691275 try {
1270- Map <String , Object > entity = ParaObjectUtils .getJsonReader (Map .class ).readValue (req .getInputStream ());
1276+ Map <String , Object > entity = new HashMap <>(ParaObjectUtils .getJsonReader (Map .class ).
1277+ readValue (req .getInputStream ()));
12711278 req .setAttribute (REST_ENTITY_ATTRIBUTE , entity );
1279+ if (override != null && !override .isEmpty ()) {
1280+ entity .putAll (override );
1281+ }
12721282 return entity ;
12731283 } catch (IOException ex ) {
12741284 badReq ("Expected 'application/json' body but got '" + req .getContentType () + "' in request body." );
0 commit comments