public static Function < RequestEnvelope , String > userId ( ) { return r -> Optional . ofNullable ( r ) . map ( RequestEnvelope :: getContext ) . map ( Context :: getSystem ) . map ( SystemState :: getUser ) . map ( User :: getUserId ) . orElseThrow ( ( ) -> new PersistenceException ( "Could not retrieve user ID from request envelope to generate persistence ID" ) ) ; }
Produces a partition key from the user ID contained in an incoming request .