package Ġde . hav em ann . transformer . adapter Ċ Ċ import Ġde . hav em ann . transformer . base . Log gable Ċ import Ġde . hav em ann . transformer . base . logger Ċ import Ġde . hav em ann . transformer . domain . entries . Link Ċ import Ġde . hav em ann . transformer . domain . entries . Navigation Entries Transformer Ċ import Ġde . hav em ann . transformer . domain . service . Navigation Entries Service Ċ import Ġde . hav em ann . transformer . domain . sort key . Sort Key Ċ import Ġde . hav em ann . transformer . domain . sort key . Sort Key Parser Ċ import Ġorg . springframework . beans . factory . annotation . Autowired Ċ import Ġorg . springframework . http . HttpStatus Ċ import Ġorg . springframework . http . Response Entity Ċ import Ġorg . springframework . web . bind . annotation . GetMapping Ċ import Ġorg . springframework . web . bind . annotation . RequestParam Ċ import Ġorg . springframework . web . bind . annotation . ResponseStatus Ċ import Ġorg . springframework . web . bind . annotation . RestController Ċ import Ġreactor . core . publisher . Mono Ċ import Ġreactor . core . scheduler . Schedulers ĊĊ Ċ @ RestController Ċ class ĠLinks Adapter (@ Autowired Ġval Ġnavigation Entries Service : ĠNavigation Entries Service ) Ġ: ĠLog gable Ġ{ ĊĊĠĠĠ Ġ@ GetMapping (" links ") ĊĠĠĠ Ġfun Ġlinks ( ĊĠĠĠĠĠĠĠ Ġ@ RequestParam (" sort ") Ġsort Criteria : ĠString ?, ĊĠĠĠĠĠĠĠ Ġ@ RequestParam Ġparent : ĠString ? ĊĠĠĠ Ġ): ĠMono < Response Entity < List < Link >>> Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( logger (). isDebugEnabled ) Ġlogger (). debug (" received Ġrequest Ġwith Ġparent =${ parent } Ġand Ġsort =${ sort Criteria }") ĊĊĠĠĠĠĠĠĠ Ġval Ġsort er : ĠComparator < Link >? Ġ= Ġsort er ( sort Criteria ) ĊĠĠĠĠĠĠĠ Ġreturn Ġnavigation Entries Service ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. load () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. subscribe On ( Schedulers . bounded Elastic ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. map Ġ{ ĠNavigation Entries Transformer ( it . navigation Entries , Ġparent ). transform () Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. do On Next Ġ{ Ġif Ġ( it . isEmpty ()) Ġthrow ĠEmpty Navigation Entries Exception ( parent ) Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. map Ġ{ Ġif Ġ( sorter Ġ!= Ġnull ) Ġit . sorted With ( sorter ) Ġelse Ġit Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. map Ġ{ ĠResponseEntity ( it , ĠHttpStatus . OK ) Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. do OnError Ġ{ Ġlogger (). error (" error Ġduring Ġprocessing Ġrequest ", Ġit ) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġsort er ( sort Criteria : ĠString ?): ĠComparator < Link >? Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( sort Criteria Ġ== Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn Ġnull ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġreturn ĠSort Key . to Comparator ( Sort Key Parser . parse ( sort Criteria ), ĠLink . property To Getter ) ĊĠĠĠ Ġ} Ċ } Ċ Ċ @ ResponseStatus ( code Ġ= ĠHttpStatus . NOT _ FOUND ) Ċ class ĠEmpty Navigation Entries Exception ( parent : ĠString ?) Ġ: ĠThrowable ( parent Ġ?: Ġ" no Ġparent Ġprovided ") Ċ