public StreamNegotiator selectStreamNegotiator ( FileTransferRequest request ) throws NotConnectedException , NoStreamMethodsOfferedException , NoAcceptableTransferMechanisms , InterruptedException { StreamInitiation si = request . getStreamInitiation ( ) ; FormField streamMethodField = getStreamMethodField ( si . getFeatureNegotiationForm ( ) ) ; if ( streamMethodField == null ) { String errorMessage = "No stream methods contained in stanza." ; StanzaError . Builder error = StanzaError . from ( StanzaError . Condition . bad_request , errorMessage ) ; IQ iqPacket = IQ . createErrorResponse ( si , error ) ; connection ( ) . sendStanza ( iqPacket ) ; throw new FileTransferException . NoStreamMethodsOfferedException ( ) ; } // select the appropriate protocol StreamNegotiator selectedStreamNegotiator ; try { selectedStreamNegotiator = getNegotiator ( streamMethodField ) ; } catch ( NoAcceptableTransferMechanisms e ) { IQ iqPacket = IQ . createErrorResponse ( si , StanzaError . from ( StanzaError . Condition . bad_request , "No acceptable transfer mechanism" ) ) ; connection ( ) . sendStanza ( iqPacket ) ; throw e ; } // return the appropriate negotiator return selectedStreamNegotiator ; }
Selects an appropriate stream negotiator after examining the incoming file transfer request .