public void forwardNewSessionRequestAndUpdateRegistry ( TestSession session ) throws NewSessionException { try ( NewSessionPayload payload = NewSessionPayload . create ( ImmutableMap . of ( "desiredCapabilities" , session . getRequestedCapabilities ( ) ) ) ) { StringBuilder json = new StringBuilder ( ) ; payload . writeTo ( json ) ; request . setBody ( json . toString ( ) ) ; session . forward ( getRequest ( ) , getResponse ( ) , true ) ; } catch ( IOException e ) { //log.warning("Error forwarding the request " + e.getMessage()); throw new NewSessionException ( "Error forwarding the request " + e . getMessage ( ) , e ) ; } }
Forward the new session request to the TestSession that has been assigned and parse the response to extract and return the external key assigned by the remote .