public URI resolve ( final URI uri , final Sid accountSid ) { getHttpConnector ( ) ; String restcommAddress = null ; if ( accountSid != null && daoManager != null ) { Sid organizationSid = daoManager . getAccountsDao ( ) . getAccount ( accountSid ) . getOrganizationSid ( ) ; restcommAddress = daoManager . getOrganizationsDao ( ) . getOrganization ( organizationSid ) . getDomainName ( ) ; } if ( restcommAddress == null || restcommAddress . isEmpty ( ) ) { if ( useHostnameToResolve ) { restcommAddress = RestcommConfiguration . getInstance ( ) . getMain ( ) . getHostname ( ) ; if ( restcommAddress == null || restcommAddress . isEmpty ( ) ) { try { InetAddress addr = DNSUtils . getByName ( selectedConnector . getAddress ( ) ) ; restcommAddress = addr . getCanonicalHostName ( ) ; } catch ( UnknownHostException e ) { logger . error ( "Unable to resolveWithBase: " + selectedConnector + " to hostname: " + e ) ; restcommAddress = selectedConnector . getAddress ( ) ; } } } else { restcommAddress = selectedConnector . getAddress ( ) ; } } String base = selectedConnector . getScheme ( ) + "://" + restcommAddress + ":" + selectedConnector . getPort ( ) ; try { return resolveWithBase ( new URI ( base ) , uri ) ; } catch ( URISyntaxException e ) { throw new IllegalArgumentException ( "Badly formed URI: " + base , e ) ; } }
Use to resolve a relative URI using the domain name of the Organization that the provided AccountSid belongs