@@ -254,7 +254,8 @@ def create_user_provided(message)
254
254
255
255
def create_managed ( message , space :)
256
256
service_plan = ServicePlan . first ( guid : message . service_plan_guid )
257
- unprocessable_service_plan! unless service_plan_valid? ( service_plan )
257
+ service_plan_does_not_exist! unless service_plan
258
+ service_plan_not_visible_to_user! ( service_plan ) unless visible_to_current_user? ( plan : service_plan )
258
259
unavailable_service_plan! ( service_plan ) unless service_plan_active? ( service_plan )
259
260
service_plan_not_visible_in_space! ( service_plan , space ) unless service_plan_exists_in_space? ( service_plan , space )
260
261
@@ -396,11 +397,6 @@ def admin?
396
397
permission_queryer . can_write_globally?
397
398
end
398
399
399
- def service_plan_valid? ( service_plan )
400
- service_plan &&
401
- visible_to_current_user? ( plan : service_plan )
402
- end
403
-
404
400
def service_plan_active? ( service_plan )
405
401
service_plan . active?
406
402
end
@@ -413,7 +409,8 @@ def raise_if_invalid_service_plan!(service_instance, message)
413
409
return unless message . service_plan_guid
414
410
415
411
service_plan = ServicePlan . first ( guid : message . service_plan_guid )
416
- unprocessable_service_plan! unless service_plan_valid? ( service_plan )
412
+ service_plan_does_not_exist! unless service_plan
413
+ service_plan_not_visible_to_user! ( service_plan ) unless visible_to_current_user? ( plan : service_plan )
417
414
unavailable_service_plan! ( service_plan ) unless service_plan_active? ( service_plan )
418
415
service_plan_not_visible_in_space! ( service_plan , service_instance . space ) unless service_plan_exists_in_space? ( service_plan , service_instance . space )
419
416
invalid_service_plan_relation! unless service_plan . service == service_instance . service
@@ -431,7 +428,15 @@ def unprocessable_space!
431
428
unprocessable! ( 'Invalid space. Ensure that the space exists and you have access to it.' )
432
429
end
433
430
434
- def unprocessable_service_plan!
431
+ def service_plan_does_not_exist!
432
+ logger . info ( 'Service Plan does not exist.' )
433
+ unprocessable! ( 'Invalid service plan. Ensure that the service plan exists, is available, and you have access to it.' )
434
+ end
435
+
436
+ def service_plan_not_visible_to_user! ( service_plan )
437
+ user = VCAP ::CloudController ::SecurityContext . current_user
438
+ logger . info ( "Service Plan with guid '#{ service_plan . guid } ' and id '#{ service_plan . id } ' is not visible to user with guid '#{ user . guid } '." )
439
+
435
440
unprocessable! ( 'Invalid service plan. Ensure that the service plan exists, is available, and you have access to it.' )
436
441
end
437
442
@@ -458,4 +463,8 @@ def operation_in_progress!
458
463
def read_scope
459
464
%w[ show_permissions ] . include? ( action_name ) && roles . cloud_controller_service_permissions_reader? ? true : super
460
465
end
466
+
467
+ def logger
468
+ @logger ||= Steno . logger ( 'cc.api' )
469
+ end
461
470
end
0 commit comments