@@ -148,7 +148,7 @@ public Object createServiceAccount( @Validated(User.ValidationServiceAccount.cla
148
148
}
149
149
150
150
@ PostMapping (value = "/admin/users/{user}/roles" )
151
- public Object updateRoles ( @ PathVariable User user , @ RequestParam (required = false ) Set <Role > roles , RedirectAttributes redirectAttributes , Locale locale ) {
151
+ public Object updateRoles ( @ PathVariable User user , @ RequestParam (required = false ) @ Nullable Set <Role > roles , RedirectAttributes redirectAttributes , Locale locale ) {
152
152
if ( roles == null ) {
153
153
roles = Collections .emptySet ();
154
154
}
@@ -176,7 +176,7 @@ public Object updateRoles( @PathVariable User user, @RequestParam(required = fal
176
176
* Retrieve a user's details.
177
177
*/
178
178
@ GetMapping (value = "/admin/users/{user}" )
179
- public Object getUser ( @ PathVariable (required = false ) User user , @ SuppressWarnings ("unused" ) ConfirmEmailForm confirmEmailForm , Locale locale ) {
179
+ public Object getUser ( @ PathVariable (required = false ) @ Nullable User user , @ SuppressWarnings ("unused" ) ConfirmEmailForm confirmEmailForm , Locale locale ) {
180
180
if ( user == null ) {
181
181
return new ModelAndView ( "error/404" , HttpStatus .NOT_FOUND )
182
182
.addObject ( "message" , messageSource .getMessage ( "AdminController.userNotFoundById" , null , locale ) );
@@ -185,7 +185,7 @@ public Object getUser( @PathVariable(required = false) User user, @SuppressWarni
185
185
}
186
186
187
187
@ PostMapping (value = "/admin/users/{user}/create-access-token" )
188
- public Object createAccessTokenForUser ( @ PathVariable (required = false ) User user , RedirectAttributes redirectAttributes , Locale locale ) {
188
+ public Object createAccessTokenForUser ( @ PathVariable (required = false ) @ Nullable User user , RedirectAttributes redirectAttributes , Locale locale ) {
189
189
if ( user == null ) {
190
190
return new ModelAndView ( "error/404" , HttpStatus .NOT_FOUND )
191
191
.addObject ( "message" , messageSource .getMessage ( "AdminController.userNotFoundById" , null , locale ) );
@@ -196,7 +196,7 @@ public Object createAccessTokenForUser( @PathVariable(required = false) User use
196
196
}
197
197
198
198
@ PostMapping (value = "/admin/users/{user}/revoke-access-token/{accessToken}" )
199
- public Object revokeAccessTn ( @ PathVariable (required = false ) User user , @ PathVariable (required = false ) AccessToken accessToken , RedirectAttributes redirectAttributes , Locale locale ) {
199
+ public Object revokeAccessTn ( @ PathVariable (required = false ) @ Nullable User user , @ PathVariable (required = false ) @ Nullable AccessToken accessToken , RedirectAttributes redirectAttributes , Locale locale ) {
200
200
if ( user == null ) {
201
201
return new ModelAndView ( "error/404" , HttpStatus .NOT_FOUND )
202
202
.addObject ( "message" , messageSource .getMessage ( "AdminController.userNotFoundById" , null , locale ) );
@@ -218,7 +218,7 @@ public static class ConfirmEmailForm {
218
218
* Delete a given user.
219
219
*/
220
220
@ DeleteMapping (value = "/admin/users/{user}" )
221
- public Object deleteUser ( @ PathVariable (required = false ) User user ,
221
+ public Object deleteUser ( @ PathVariable (required = false ) @ Nullable User user ,
222
222
@ Valid ConfirmEmailForm confirmEmailForm , BindingResult bindingResult ,
223
223
Locale locale ) {
224
224
if ( user == null ) {
@@ -245,7 +245,7 @@ public ModelAndView getOntologies( @SuppressWarnings("unused") ImportOntologyFor
245
245
}
246
246
247
247
@ GetMapping ("/admin/ontologies/{ontology}" )
248
- public ModelAndView getOntology ( @ PathVariable (required = false ) Ontology ontology , Locale locale ) {
248
+ public ModelAndView getOntology ( @ PathVariable (required = false ) @ Nullable Ontology ontology , Locale locale ) {
249
249
if ( ontology == null ) {
250
250
return new ModelAndView ( "error/404" , HttpStatus .NOT_FOUND )
251
251
.addObject ( "message" , messageSource .getMessage ( "AdminController.ontologyNotFoundById" , null , locale ) );
@@ -293,15 +293,17 @@ public static UpdateOntologyForm fromOntology( Ontology ontology ) {
293
293
@ Size (min = 1 , max = Ontology .MAX_NAME_LENGTH )
294
294
private String name ;
295
295
296
+ @ Nullable
296
297
private String definition ;
297
298
299
+ @ Nullable
298
300
private URL ontologyUrl ;
299
301
300
302
private boolean availableForGeneSearch ;
301
303
}
302
304
303
305
@ PostMapping ("/admin/ontologies/{ontology}" )
304
- public ModelAndView updateOntology ( @ PathVariable (required = false ) Ontology ontology ,
306
+ public ModelAndView updateOntology ( @ PathVariable (required = false ) @ Nullable Ontology ontology ,
305
307
@ Valid UpdateOntologyForm updateOntologyForm , BindingResult bindingResult ,
306
308
Locale locale ) {
307
309
if ( ontology == null ) {
@@ -337,7 +339,7 @@ public ModelAndView updateOntology( @PathVariable(required = false) Ontology ont
337
339
}
338
340
339
341
@ DeleteMapping ("/admin/ontologies/{ontology}" )
340
- public Object deleteOntology ( @ PathVariable (required = false ) Ontology ontology ,
342
+ public Object deleteOntology ( @ PathVariable (required = false ) @ Nullable Ontology ontology ,
341
343
@ Valid DeleteOntologyForm deleteOntologyForm , BindingResult bindingResult ,
342
344
RedirectAttributes redirectAttributes ,
343
345
Locale locale ) {
@@ -395,7 +397,7 @@ public Object createSimpleOntology( @SuppressWarnings("unused") ImportOntologyFo
395
397
}
396
398
397
399
@ PostMapping ("/admin/ontologies/{ontology}/update-simple-ontology" )
398
- public Object updateSimpleOntology ( @ PathVariable (required = false ) Ontology ontology ,
400
+ public Object updateSimpleOntology ( @ PathVariable (required = false ) @ Nullable Ontology ontology ,
399
401
@ Valid SimpleOntologyForm simpleOntologyForm , BindingResult bindingResult ,
400
402
RedirectAttributes redirectAttributes , Locale locale ) {
401
403
if ( ontology == null ) {
@@ -483,6 +485,7 @@ public static SimpleOntologyTermForm emptyRow() {
483
485
/**
484
486
* Auto-generated if null or empty, which is why we allow zero as a size.
485
487
*/
488
+ @ Nullable
486
489
@ Size (max = OntologyTermInfo .MAX_TERM_ID_LENGTH , groups = RowNotEmpty .class )
487
490
private String termId ;
488
491
@ NotNull (groups = RowNotEmpty .class )
@@ -631,7 +634,7 @@ public void initBinding2( WebDataBinder webDataBinder ) {
631
634
}
632
635
633
636
@ PostMapping ("/admin/ontologies/{ontology}/update" )
634
- public Object updateOntology ( @ PathVariable (required = false ) Ontology ontology ,
637
+ public Object updateOntology ( @ PathVariable (required = false ) @ Nullable Ontology ontology ,
635
638
RedirectAttributes redirectAttributes ,
636
639
Locale locale ) {
637
640
if ( ontology == null ) {
@@ -716,7 +719,12 @@ public Object importReactomePathways( RedirectAttributes redirectAttributes ) {
716
719
@ PostMapping ("/admin/ontologies/{ontology}/update-reactome-pathways" )
717
720
public Object updateReactomePathways ( @ PathVariable (required = false ) @ Nullable Ontology ontology , RedirectAttributes redirectAttributes , Locale locale ) {
718
721
// null-check is not necessary, but can save a database call
719
- if ( ontology == null || !ontology .equals ( reactomeService .findPathwaysOntology () ) ) {
722
+ if ( ontology == null ) {
723
+ return new ModelAndView ( "error/404" , HttpStatus .NOT_FOUND )
724
+ .addObject ( "message" , messageSource .getMessage ( "AdminController.ontologyNotFoundById" , null , locale ) );
725
+ }
726
+ Ontology reactome = reactomeService .findPathwaysOntology ();
727
+ if ( reactome == null || !reactome .equals ( ontology ) ) {
720
728
return new ModelAndView ( "error/404" , HttpStatus .NOT_FOUND )
721
729
.addObject ( "message" , messageSource .getMessage ( "AdminController.ontologyNotFoundById" , null , locale ) );
722
730
}
@@ -821,7 +829,7 @@ public static class DeactivateOntologyForm extends ActivateOrDeactivateOntologyF
821
829
}
822
830
823
831
@ PostMapping ("/admin/ontologies/{ontology}/activate" )
824
- public Object activateOntology ( @ PathVariable (required = false ) Ontology ontology , ActivateOntologyForm activateOntologyForm , RedirectAttributes redirectAttributes , Locale locale ) {
832
+ public Object activateOntology ( @ PathVariable (required = false ) @ Nullable Ontology ontology , ActivateOntologyForm activateOntologyForm , RedirectAttributes redirectAttributes , Locale locale ) {
825
833
if ( ontology == null ) {
826
834
return new ModelAndView ( "error/404" , HttpStatus .NOT_FOUND )
827
835
.addObject ( "message" , messageSource .getMessage ( "AdminController.ontologyNotFoundById" , null , locale ) );
@@ -833,7 +841,7 @@ public Object activateOntology( @PathVariable(required = false) Ontology ontolog
833
841
}
834
842
835
843
@ PostMapping ("/admin/ontologies/{ontology}/deactivate" )
836
- public Object deactivateOntology ( @ PathVariable (required = false ) Ontology ontology , DeactivateOntologyForm deactivateOntologyForm , RedirectAttributes redirectAttributes , Locale locale ) {
844
+ public Object deactivateOntology ( @ PathVariable (required = false ) @ Nullable Ontology ontology , DeactivateOntologyForm deactivateOntologyForm , RedirectAttributes redirectAttributes , Locale locale ) {
837
845
if ( ontology == null ) {
838
846
return new ModelAndView ( "error/404" , HttpStatus .NOT_FOUND )
839
847
.addObject ( "message" , messageSource .getMessage ( "AdminController.ontologyNotFoundById" , null , locale ) );
@@ -890,7 +898,7 @@ public Object deactivateTerm( @PathVariable(required = false) Ontology ontology,
890
898
return activateOrDeactivateTerm ( ontology , deactivateTermForm , bindingResult , redirectAttributes , locale );
891
899
}
892
900
893
- private Object activateOrDeactivateTerm ( Ontology ontology ,
901
+ private Object activateOrDeactivateTerm ( @ Nullable Ontology ontology ,
894
902
ActivateOrDeactivateTermForm activateOrDeactivateTermForm , BindingResult bindingResult ,
895
903
RedirectAttributes redirectAttributes ,
896
904
Locale locale ) {
@@ -901,7 +909,7 @@ private Object activateOrDeactivateTerm( Ontology ontology,
901
909
OntologyTermInfo ontologyTermInfo = null ;
902
910
903
911
if ( !bindingResult .hasFieldErrors ( "ontologyTermInfoId" ) ) {
904
- ontologyTermInfo = ontologyService .findTermByTermIdAndOntology ( activateOrDeactivateTermForm .ontologyTermInfoId , ontology );
912
+ ontologyTermInfo = ontologyService .findTermByTermIdAndOntology ( activateOrDeactivateTermForm .ontologyTermInfoId , ontology ). orElse ( null ) ;
905
913
if ( ontologyTermInfo == null ) {
906
914
bindingResult .rejectValue ( "ontologyTermInfoId" , "AdminController.ActivateOrDeactivateTermForm.unknownTermInOntology" ,
907
915
new String []{ activateOrDeactivateTermForm .getOntologyTermInfoId (), messageSource .getMessage ( ontology .getResolvableTitle (), locale ) }, null );
@@ -953,7 +961,7 @@ private Object activateOrDeactivateTerm( Ontology ontology,
953
961
* Provides the ontology in OBO format.
954
962
*/
955
963
@ GetMapping (value = "/admin/ontologies/{ontology}/download" , produces = "text/plain" )
956
- public ResponseEntity <StreamingResponseBody > downloadOntology ( @ PathVariable (required = false ) Ontology ontology , TimeZone timeZone ) {
964
+ public ResponseEntity <StreamingResponseBody > downloadOntology ( @ PathVariable (required = false ) @ Nullable Ontology ontology , TimeZone timeZone ) {
957
965
if ( ontology == null ) {
958
966
return ResponseEntity .notFound ().build ();
959
967
}
@@ -969,7 +977,7 @@ public ResponseEntity<StreamingResponseBody> downloadOntology( @PathVariable(req
969
977
970
978
@ ResponseBody
971
979
@ GetMapping ("/admin/ontologies/{ontology}/autocomplete-terms" )
972
- public Object autocompleteOntologyTerms ( @ PathVariable (required = false ) Ontology ontology , @ RequestParam String query , Locale locale ) {
980
+ public Object autocompleteOntologyTerms ( @ PathVariable (required = false ) @ Nullable Ontology ontology , @ RequestParam String query , Locale locale ) {
973
981
if ( ontology == null ) {
974
982
return ResponseEntity .status ( HttpStatus .NOT_FOUND )
975
983
.body ( messageSource .getMessage ( "AdminController.ontologyNotFoundById" , null , locale ) );
@@ -993,7 +1001,7 @@ public ResponseEntity<String> refreshMessages() {
993
1001
}
994
1002
995
1003
@ PostMapping ("/admin/ontologies/{ontology}/move" )
996
- public Object move ( @ PathVariable (required = false ) Ontology ontology , @ RequestParam String direction ,
1004
+ public Object move ( @ PathVariable (required = false ) @ Nullable Ontology ontology , @ RequestParam String direction ,
997
1005
@ SuppressWarnings ("unused" ) ImportOntologyForm importOntologyForm ,
998
1006
Locale locale ) {
999
1007
if ( ontology == null ) {
0 commit comments