public HTTPClientConfiguration createHTTPClientConfiguration ( ConfigurationHolder configurationHolder ) { //get server values String hostName = configurationHolder . getConfigurationValue ( HTTPClientConfigurationConstants . HOST_NAME_PROPERTY_KEY ) ; if ( hostName == null ) { throw new FaxException ( "Host name not defined in property: " + HTTPClientConfigurationConstants . HOST_NAME_PROPERTY_KEY ) ; } String value = configurationHolder . getConfigurationValue ( HTTPClientConfigurationConstants . PORT_PROPERTY_KEY ) ; if ( value == null ) { value = String . valueOf ( - 1 ) ; } int port = Integer . parseInt ( value ) ; boolean ssl = Boolean . parseBoolean ( configurationHolder . getConfigurationValue ( HTTPClientConfigurationConstants . SSL_PROPERTY_KEY ) ) ; //create configuration CommonHTTPClientConfiguration configuration = new CommonHTTPClientConfiguration ( ) ; //set values configuration . setHostName ( hostName ) ; configuration . setPort ( port ) ; configuration . setSSL ( ssl ) ; //set methods Enum < ? > [ ] methodProperties = new Enum < ? > [ ] { HTTPClientConfigurationConstants . SUBMIT_HTTP_METHOD_PROPERTY_KEY , HTTPClientConfigurationConstants . SUSPEND_HTTP_METHOD_PROPERTY_KEY , HTTPClientConfigurationConstants . RESUME_HTTP_METHOD_PROPERTY_KEY , HTTPClientConfigurationConstants . CANCEL_HTTP_METHOD_PROPERTY_KEY , HTTPClientConfigurationConstants . GET_STATUS_HTTP_METHOD_PROPERTY_KEY } ; FaxActionType [ ] faxActionTypes = new FaxActionType [ ] { FaxActionType . SUBMIT_FAX_JOB , FaxActionType . SUSPEND_FAX_JOB , FaxActionType . RESUME_FAX_JOB , FaxActionType . CANCEL_FAX_JOB , FaxActionType . GET_FAX_JOB_STATUS } ; HTTPMethod httpMethod = null ; for ( int index = 0 ; index < methodProperties . length ; index ++ ) { //set next method value = configurationHolder . getConfigurationValue ( methodProperties [ index ] ) ; httpMethod = HTTPMethod . POST ; if ( value != null ) { httpMethod = HTTPMethod . valueOf ( value ) ; } configuration . setMethod ( faxActionTypes [ index ] , httpMethod ) ; } return configuration ; }
This function creates the HTTP client configuration to be used later on by this HTTP client type .