public static void saveService ( final RegisteredService service , final ServicesManager servicesManager ) { servicesManager . load ( ) ; if ( servicesManager . findServiceBy ( registeredService -> registeredService instanceof SamlRegisteredService && registeredService . getServiceId ( ) . equals ( service . getServiceId ( ) ) ) . isEmpty ( ) ) { LOGGER . info ( "Service [{}] does not exist in the registry and will be added." , service . getServiceId ( ) ) ; servicesManager . save ( service ) ; servicesManager . load ( ) ; } else { LOGGER . info ( "Service [{}] exists in the registry and will not be added again." , service . getServiceId ( ) ) ; } }
Save service only if it s not already found in the registry .