33import io .quarkus .logging .Log ;
44import io .quarkus .security .identity .SecurityIdentity ;
55import jakarta .inject .Inject ;
6+ import jakarta .validation .Valid ;
67import jakarta .ws .rs .*;
78import jakarta .ws .rs .core .Context ;
89import jakarta .ws .rs .core .MediaType ;
@@ -74,29 +75,22 @@ public Response getCustomBenefits(
7475 public Response createCustomBenefit (
7576 @ Context SecurityIdentity identity ,
7677 @ PathParam ("screenerId" ) String screenerId ,
77- CreateCustomBenefitRequest request
78+ @ Valid CreateCustomBenefitRequest request
7879 ) {
7980 String userId = AuthUtils .getUserId (identity );
8081
81- // Validate request
82- if (request .name == null || request .name .isBlank ()) {
83- return Response .status (Response .Status .BAD_REQUEST )
84- .entity (Map .of ("error" , "Name is required" ))
85- .build ();
86- }
87-
8882 // Create new Benefit with server-generated ID
8983 String newBenefitId = UUID .randomUUID ().toString ();
9084 Benefit newBenefit = new Benefit (
9185 newBenefitId ,
92- request .name ,
93- request .description ,
86+ request .name () ,
87+ request .description () ,
9488 userId ,
9589 Collections .emptyList ()
9690 );
9791
9892 // Create corresponding BenefitDetail
99- BenefitDetail benefitDetail = new BenefitDetail (newBenefitId , request .name , request .description );
93+ BenefitDetail benefitDetail = new BenefitDetail (newBenefitId , request .name () , request .description () );
10094
10195 try {
10296 // Check to make sure screener exists
@@ -159,7 +153,7 @@ public Response updateCustomBenefit(
159153 @ Context SecurityIdentity identity ,
160154 @ PathParam ("screenerId" ) String screenerId ,
161155 @ PathParam ("benefitId" ) String benefitId ,
162- UpdateCustomBenefitRequest request
156+ @ Valid UpdateCustomBenefitRequest request
163157 ) {
164158 String userId = AuthUtils .getUserId (identity );
165159
@@ -271,17 +265,10 @@ public Response addCheckToBenefit(
271265 @ Context SecurityIdentity identity ,
272266 @ PathParam ("screenerId" ) String screenerId ,
273267 @ PathParam ("benefitId" ) String benefitId ,
274- AddCheckRequest request
268+ @ Valid AddCheckRequest request
275269 ) {
276270 String userId = AuthUtils .getUserId (identity );
277271
278- // Validate request
279- if (request .checkId == null || request .checkId .isBlank ()) {
280- return Response .status (Response .Status .BAD_REQUEST )
281- .entity (Map .of ("error" , "checkId is required" ))
282- .build ();
283- }
284-
285272 if (!isUserAuthorizedForScreener (userId , screenerId )) {
286273 return Response .status (Response .Status .UNAUTHORIZED ).build ();
287274 }
@@ -296,9 +283,11 @@ public Response addCheckToBenefit(
296283 }
297284
298285 // Find the EligibilityCheck - first try user's custom checks, then library checks
299- Optional <EligibilityCheck > checkOpt = eligibilityCheckRepository .getPublishedCustomCheck (userId , request .checkId );
286+ Optional <EligibilityCheck > checkOpt = (
287+ eligibilityCheckRepository .getPublishedCustomCheck (userId , request .checkId ())
288+ );
300289 if (checkOpt .isEmpty ()) {
301- checkOpt = libraryApiMetadataService .getById (request .checkId );
290+ checkOpt = libraryApiMetadataService .getById (request .checkId () );
302291 }
303292
304293 if (checkOpt .isEmpty ()) {
@@ -440,7 +429,7 @@ public Response updateCheckParameters(
440429 List <CheckConfig > checkListAfterUpdate = new ArrayList <>();
441430 for (CheckConfig check : checks ) {
442431 if (check .getCheckId ().equals (checkId )) {
443- check .setParameters (request .parameters != null ? request .parameters : new HashMap <>());
432+ check .setParameters (request .parameters () != null ? request .parameters () : new HashMap <>());
444433 checkUpdated = true ;
445434 }
446435 checkListAfterUpdate .add (check );
0 commit comments