Example usage for org.apache.commons.configuration Configuration getBoolean

List of usage examples for org.apache.commons.configuration Configuration getBoolean

Introduction

In this page you can find the example usage for org.apache.commons.configuration Configuration getBoolean.

Prototype

Boolean getBoolean(String key, Boolean defaultValue);

Source Link

Document

Get a Boolean associated with the given configuration key.

Usage

From source file:org.csource.fastdfs.ClientGlobal.java

/**
* load global variables/*  w w  w  . j a v a2  s . c  o m*/
* @param conf_filename config filename
 * @throws ConfigurationException 
*/
public static void init(String conf_filename)
        throws FileNotFoundException, IOException, MyException, ConfigurationException {
    Configuration config;
    config = new PropertiesConfiguration(conf_filename);

    g_connect_timeout = config.getInt("connect_timeout", DEFAULT_CONNECT_TIMEOUT);
    if (g_connect_timeout < 0) {
        g_connect_timeout = DEFAULT_CONNECT_TIMEOUT;
    }
    g_connect_timeout *= 1000; //millisecond

    g_network_timeout = config.getInt("network_timeout", DEFAULT_NETWORK_TIMEOUT);
    if (g_network_timeout < 0) {
        g_network_timeout = DEFAULT_NETWORK_TIMEOUT;
    }
    g_network_timeout *= 1000; //millisecond

    g_charset = config.getString("charset");
    if (g_charset == null || g_charset.length() == 0) {
        g_charset = "ISO8859-1";
    }

    List<Object> trackerServers = config.getList("tracker_server");
    InetSocketAddress[] tracker_servers = new InetSocketAddress[trackerServers.size()];
    String[] parts;

    for (int i = 0; i < trackerServers.size(); i++) {
        parts = ((String) trackerServers.get(i)).split("\\:", 2);
        if (parts.length != 2) {
            throw new MyException(
                    "the value of item \"tracker_server\" is invalid, the correct format is host:port");
        }

        tracker_servers[i] = new InetSocketAddress(parts[0].trim(), Integer.parseInt(parts[1].trim()));
    }
    g_tracker_group = new TrackerGroup(tracker_servers);

    g_tracker_http_port = config.getInt("http.tracker_http_port", 80);
    g_anti_steal_token = config.getBoolean("http.anti_steal_token", false);
    if (g_anti_steal_token) {
        g_secret_key = config.getString("http.secret_key");
    }
    if (trackerServers.size() == 0) {
        throw new MyException("item \"tracker_server\" in " + conf_filename + " not found");
    }

    /*        IniFileReader iniReader;
            String[] szTrackerServers;
             String[] parts;
                     
            iniReader = new IniFileReader(conf_filename);
            
             g_connect_timeout = iniReader.getIntValue("connect_timeout", DEFAULT_CONNECT_TIMEOUT);
            if (g_connect_timeout < 0)
            {
               g_connect_timeout = DEFAULT_CONNECT_TIMEOUT;
            }
            g_connect_timeout *= 1000; //millisecond
                    
            g_network_timeout = iniReader.getIntValue("network_timeout", DEFAULT_NETWORK_TIMEOUT);
            if (g_network_timeout < 0)
            {
               g_network_timeout = DEFAULT_NETWORK_TIMEOUT;
            }
            g_network_timeout *= 1000; //millisecond
            
            g_charset = iniReader.getStrValue("charset");
            if (g_charset == null || g_charset.length() == 0)
            {
               g_charset = "ISO8859-1";
            }
                    
            szTrackerServers = iniReader.getValues("tracker_server");
            if (szTrackerServers == null)
            {
               throw new MyException("item \"tracker_server\" in " + conf_filename + " not found");
            }
                    
            InetSocketAddress[] tracker_servers = new InetSocketAddress[szTrackerServers.length];
            for (int i=0; i<szTrackerServers.length; i++)
            {
               parts = szTrackerServers[i].split("\\:", 2);
               if (parts.length != 2)
               {
      throw new MyException("the value of item \"tracker_server\" is invalid, the correct format is host:port");
               }
                       
               tracker_servers[i] = new InetSocketAddress(parts[0].trim(), Integer.parseInt(parts[1].trim()));
            }
            g_tracker_group = new TrackerGroup(tracker_servers);
                    
            g_tracker_http_port = iniReader.getIntValue("http.tracker_http_port", 80);
            g_anti_steal_token = iniReader.getBoolValue("http.anti_steal_token", false);
            if (g_anti_steal_token)
            {
               g_secret_key = iniReader.getStrValue("http.secret_key");
            }*/

}

From source file:org.hawkular.inventory.impl.tinkerpop.sql.impl.SqlGraph.java

public SqlGraph(DataSource dataSource, Configuration configuration) throws Exception {
    this(dataSource, configuration.getString("sql.verticesTable"), configuration.getString("sql.edgesTable"),
            configuration.getString("sql.vertexPropertiesTable"),
            configuration.getString("sql.edgePropertiesTable"),
            configuration.getBoolean("sql.loadPropertiesEagerly", null),
            configuration.getBoolean("sql.closeConnectionOnTransactionEnd", null),
            configuration.getBoolean("sql.cacheStatements", null));
}

From source file:org.j2free.invoker.InvokerFilter.java

/**
 *
 * @param fc/*from  w w  w .ja va2 s  . c om*/
 */
public void init(javax.servlet.FilterConfig fc) {
    try {
        write.lock();

        Configuration config = (Configuration) Global.get(CONTEXT_ATTR_CONFIG);
        if (config != null)
            configure(config);

        // Use a custom exception handler, if there is one
        UncaughtServletExceptionHandler ueh = (UncaughtServletExceptionHandler) Global
                .get(CONTEXT_ATTR_UNCAUGHT_EXCEPTION_HANDLER);
        if (ueh != null)
            uncaughtExceptionHandler = ueh;

        // Use a custom request examiner, if there is one
        RequestExaminer reqex = (RequestExaminer) Global.get(CONTEXT_ATTR_REQUEST_EXAMINER);
        if (reqex != null)
            requestExaminer = reqex;

        ServletContext context = fc.getServletContext();
        load(context);

        // StaticJspServlet
        if (config.getBoolean(PROP_STATICJSP_ON, false)) {
            String staticJspDir = config == null ? DEFAULT_STATICJSP_DIR
                    : config.getString(PROP_STATICJSP_DIR, DEFAULT_STATICJSP_DIR);
            String staticJspPath = config == null ? DEFAULT_STATICJSP_PATH
                    : config.getString(PROP_STATICJSP_PATH, DEFAULT_STATICJSP_PATH);

            StaticJspServlet.directory.set(staticJspDir);

            Set<String> staticJsps = context.getResourcePaths(staticJspDir);
            if (staticJsps != null && !staticJsps.isEmpty()) {
                for (String jsp : staticJsps) {
                    if (jsp.endsWith(".jsp")) {
                        jsp = staticJspPath + jsp.replace(staticJspDir, EMPTY).replaceAll("\\.jsp$", EMPTY);
                        addServletMapping(jsp, StaticJspServlet.class);
                    }
                }
            }
        }

        // LogoutServlet
        if (config.getBoolean(PROP_SERVLET_LOGOUT_ON, false))
            addServletMapping(config, PROP_SERVLET_LOGOUT_PATH, DEFAULT_LOGOUT_PATH, LogoutServlet.class);

        // ProxyServlet
        if (config.getBoolean(PROP_SERVLET_PROXY_ON, false))
            addServletMapping(config, PROP_SERVLET_PROXY_PATH, DEFAULT_PROXY_PATH, ProxyServlet.class);

        // Admin Servlet
        if (config.getBoolean(PROP_SERVLET_ADMIN_ON, false))
            addServletMapping(config, PROP_SERVLET_ADMIN_PATH, DEFAULT_ADMIN_PATH, EntityAdminServlet.class);
    } finally {
        write.unlock();
    }
}

From source file:org.j2free.invoker.InvokerFilter.java

/**
 * Configures the InvokerFilter, locking to prevent request processing
 * while configuration is set./* ww w  .  java  2s .  com*/
 */
private void configure(Configuration config) {
    try {
        write.lock();

        // In case the user has let us know about paths that are guaranteed static
        bypassPath = config.getString(Property.BYPASS_PATH, EMPTY);

        // Can enable benchmarking globally
        benchmark = config.getBoolean(Property.BENCHMARK_REQS, false);

        // Set the SSL redirect port
        int val = config.getInt(Constants.PROP_LOCALPORT_SSL, -1);
        if (val > 0)
            sslRedirectPort = val;

        // Set the SSL redirect port
        val = config.getInt(Constants.PROP_LOCALPORT, -1);
        if (val > 0)
            nonSslRedirectPort = val;

        // Set the reload threshold for servlets
        maxServletUses = config.getInt(Property.MAX_SERVLET_USES, 1000);

        // The default SSL option
        String defSSLStr = config.getString(Property.DEFAULT_SSL_OPT, null);
        if (defSSLStr != null) {
            try {
                defaultSSLOption = SSLOption.valueOf(defSSLStr);
            } catch (Exception e) {
                log.error("Error setting default SSLOption for value: " + defSSLStr);
            }
        }
    } finally {
        write.unlock(); // ALWAYS unlock
    }
}

From source file:org.lockss.servlet.LockssOiosamlSpFilter.java

public void init(FilterConfig filterConfig) throws ServletException {
    conf = SAMLConfigurationFactory.getConfiguration();

    if (conf.isConfigured()) {
        try {/*from  www  . ja  va2  s . c om*/
            Configuration conf = SAMLConfigurationFactory.getConfiguration().getSystemConfiguration();
            if (conf.getBoolean(Constants.PROP_DEVEL_MODE, false)) {
                develMode = new DevelModeImpl();
                setConfiguration(conf);
                setFilterInitialized(true);
                return;
            }
            setRuntimeConfiguration(conf);
            setFilterInitialized(true);
            return;
        } catch (IllegalStateException e) {
            log.error("Unable to configure", e);
        }
    }
    setFilterInitialized(false);
}

From source file:org.mobicents.servlet.restcomm.provisioning.number.bandwidth.BandwidthNumberProvisioningManager.java

@Override
public void init(org.apache.commons.configuration.Configuration phoneNumberProvisioningConfiguration,
        org.apache.commons.configuration.Configuration telestaxProxyConfiguration,
        ContainerConfiguration containerConfiguration) {
    this.containerConfiguration = containerConfiguration;
    telestaxProxyEnabled = telestaxProxyConfiguration.getBoolean("enabled", false);
    if (telestaxProxyEnabled) {
        uri = telestaxProxyConfiguration.getString("uri");
        username = telestaxProxyConfiguration.getString("login");
        password = telestaxProxyConfiguration.getString("password");
        accountId = telestaxProxyConfiguration.getString("endpoint");
        siteId = telestaxProxyConfiguration.getString("siteId");
        activeConfiguration = telestaxProxyConfiguration;
    } else {/* ww w  .  java  2  s  . c  o m*/
        Configuration bandwidthConfiguration = phoneNumberProvisioningConfiguration.subset("bandwidth");
        uri = bandwidthConfiguration.getString("uri");
        username = bandwidthConfiguration.getString("username");
        password = bandwidthConfiguration.getString("password");
        accountId = bandwidthConfiguration.getString("accountId");
        siteId = bandwidthConfiguration.getString("siteId");
        activeConfiguration = bandwidthConfiguration;
    }
    httpClient = new DefaultHttpClient();
    Credentials credentials = new UsernamePasswordCredentials(username, password);
    httpClient.getCredentialsProvider().setCredentials(AuthScope.ANY, credentials);
}

From source file:org.mobicents.servlet.restcomm.provisioning.number.nexmo.NexmoPhoneNumberProvisioningManager.java

@Override
public void init(Configuration phoneNumberProvisioningConfiguration, Configuration telestaxProxyConfiguration,
        ContainerConfiguration containerConfiguration) {
    this.containerConfiguration = containerConfiguration;
    telestaxProxyEnabled = telestaxProxyConfiguration.getBoolean("enabled", false);
    if (telestaxProxyEnabled) {
        uri = telestaxProxyConfiguration.getString("uri");
        apiKey = telestaxProxyConfiguration.getString("api-key");
        apiSecret = telestaxProxyConfiguration.getString("api-secret");
        smppSystemType = telestaxProxyConfiguration.getString("smpp-system-type", "inbound");
        activeConfiguration = telestaxProxyConfiguration;
    } else {//from  ww  w. j a  v  a 2 s  .  c o m
        Configuration nexmoConfiguration = phoneNumberProvisioningConfiguration.subset("nexmo");
        uri = nexmoConfiguration.getString("uri");
        apiKey = nexmoConfiguration.getString("api-key");
        apiSecret = nexmoConfiguration.getString("api-secret");
        smppSystemType = nexmoConfiguration.getString("smpp-system-type", "inbound");
        activeConfiguration = nexmoConfiguration;
    }
    searchURI = uri + "/number/search/" + apiKey + "/" + apiSecret + "/";
    buyURI = uri + "/number/buy/" + apiKey + "/" + apiSecret + "/";
    updateURI = uri + "/number/update/" + apiKey + "/" + apiSecret + "/";
    cancelURI = uri + "/number/cancel/" + apiKey + "/" + apiSecret + "/";
}

From source file:org.mobicents.servlet.restcomm.provisioning.number.vi.VoIPInnovationsNumberProvisioningManager.java

@Override
public void init(Configuration phoneNumberProvisioningConfiguration, Configuration telestaxProxyConfiguration,
        ContainerConfiguration containerConfiguration) {
    this.containerConfiguration = containerConfiguration;
    telestaxProxyEnabled = telestaxProxyConfiguration.getBoolean("enabled", false);
    if (telestaxProxyEnabled) {
        uri = telestaxProxyConfiguration.getString("uri");
        username = telestaxProxyConfiguration.getString("login");
        password = telestaxProxyConfiguration.getString("password");
        endpoint = telestaxProxyConfiguration.getString("endpoint");
        activeConfiguration = telestaxProxyConfiguration;
    } else {/*from   www.  ja  va 2  s  .  c  o m*/
        Configuration viConf = phoneNumberProvisioningConfiguration.subset("voip-innovations");
        uri = viConf.getString("uri");
        username = viConf.getString("login");
        password = viConf.getString("password");
        endpoint = viConf.getString("endpoint");
        activeConfiguration = viConf;
    }

    this.header = header(username, password);
    xstream = new XStream();
    xstream.alias("response", VoipInnovationsResponse.class);
    xstream.alias("header", VoipInnovationsHeader.class);
    xstream.alias("body", VoipInnovationsBody.class);
    xstream.alias("lata", LATAConverter.class);
    xstream.alias("npa", NPAConverter.class);
    xstream.alias("nxx", NXXConverter.class);
    xstream.alias("rate_center", RateCenterConverter.class);
    xstream.alias("state", StateConverter.class);
    xstream.alias("tn", TNConverter.class);
    xstream.registerConverter(new VoipInnovationsResponseConverter());
    xstream.registerConverter(new VoipInnovationsHeaderConverter());
    xstream.registerConverter(new VoipInnovationsBodyConverter());
    xstream.registerConverter(new GetDIDListResponseConverter());
    xstream.registerConverter(new LATAConverter());
    xstream.registerConverter(new NPAConverter());
    xstream.registerConverter(new NXXConverter());
    xstream.registerConverter(new RateCenterConverter());
    xstream.registerConverter(new StateConverter());
    xstream.registerConverter(new TNConverter());
}

From source file:org.mobicents.servlet.restcomm.provisioning.number.voxbone.VoxbonePhoneNumberProvisioningManager.java

@Override
public void init(Configuration phoneNumberProvisioningConfiguration, Configuration telestaxProxyConfiguration,
        ContainerConfiguration containerConfiguration) {
    this.containerConfiguration = containerConfiguration;
    telestaxProxyEnabled = telestaxProxyConfiguration.getBoolean("enabled", false);
    if (telestaxProxyEnabled) {
        uri = telestaxProxyConfiguration.getString("uri");
        username = telestaxProxyConfiguration.getString("username");
        password = telestaxProxyConfiguration.getString("password");
        activeConfiguration = telestaxProxyConfiguration;
    } else {/*from  w w  w .j  a v a  2s.  co m*/
        Configuration voxboneConfiguration = phoneNumberProvisioningConfiguration.subset("voxbone");
        uri = voxboneConfiguration.getString("uri");
        username = voxboneConfiguration.getString("username");
        password = voxboneConfiguration.getString("password");
        activeConfiguration = voxboneConfiguration;
    }
    searchURI = uri + "/inventory/didgroup";
    createCartURI = uri + "/ordering/cart";
    voiceURI = uri + "/configuration/voiceuri";
    updateURI = uri + "/configuration/configuration";
    cancelURI = uri + "/ordering/cancel";
    countriesURI = uri + "/inventory/country";
    listDidsURI = uri + "/inventory/did";

    Configuration callbackUrlsConfiguration = phoneNumberProvisioningConfiguration.subset("callback-urls");
    Client jerseyClient = Client.create();
    jerseyClient.addFilter(new HTTPBasicAuthFilter(username, password));

    WebResource webResource = jerseyClient.resource(voiceURI);
    String body = "{\"voiceUri\":{\"voiceUriProtocol\":\"SIP\",\"uri\":\""
            + callbackUrlsConfiguration.getString("voice[@url]") + "\"}}";
    ClientResponse clientResponse = webResource.accept(CONTENT_TYPE).type(CONTENT_TYPE)
            .put(ClientResponse.class, body);

    String voiceURIResponse = clientResponse.getEntity(String.class);
    if (logger.isDebugEnabled())
        logger.debug("response " + voiceURIResponse);

    JsonParser parser = new JsonParser();
    JsonObject jsonVoiceURIResponse = parser.parse(voiceURIResponse).getAsJsonObject();

    if (clientResponse.getClientResponseStatus() == Status.OK) {
        JsonObject voxVoiceURI = jsonVoiceURIResponse.get("voiceUri").getAsJsonObject();
        voiceUriId = voxVoiceURI.get("voiceUriId").getAsString();
    } else if (clientResponse.getClientResponseStatus() == Status.UNAUTHORIZED) {
        JsonObject error = jsonVoiceURIResponse.get("errors").getAsJsonArray().get(0).getAsJsonObject();
        throw new IllegalArgumentException(error.get("apiErrorMessage").getAsString());
    } else {
        webResource = jerseyClient.resource(voiceURI);
        clientResponse = webResource.queryParam(PAGE_NUMBER, "0").queryParam(PAGE_SIZE, "300")
                .accept(CONTENT_TYPE).type(CONTENT_TYPE).get(ClientResponse.class);

        String listVoiceURIResponse = clientResponse.getEntity(String.class);
        if (logger.isDebugEnabled())
            logger.debug("response " + listVoiceURIResponse);

        JsonObject jsonListVoiceURIResponse = parser.parse(listVoiceURIResponse).getAsJsonObject();
        // TODO go through the list of voiceURI id and check which one is matching
        JsonObject voxVoiceURI = jsonListVoiceURIResponse.get("voiceUris").getAsJsonArray().get(0)
                .getAsJsonObject();
        voiceUriId = voxVoiceURI.get("voiceUriId").getAsString();
    }
}

From source file:org.mobicents.servlet.restcomm.telephony.CallManager.java

private void invite(final Object message) throws IOException, NumberParseException, ServletParseException {
    final ActorRef self = self();
    final SipServletRequest request = (SipServletRequest) message;
    // Make sure we handle re-invites properly.
    if (!request.isInitial()) {
        final SipServletResponse okay = request.createResponse(SC_OK);
        okay.send();//  w w  w  .j  a v  a2s  .  c  o  m
        return;
    }
    //Run proInboundAction Extensions here
    // If it's a new invite lets try to handle it.
    final AccountsDao accounts = storage.getAccountsDao();
    final ApplicationsDao applications = storage.getApplicationsDao();
    // Try to find an application defined for the client.
    final SipURI fromUri = (SipURI) request.getFrom().getURI();
    String fromUser = fromUri.getUser();
    final ClientsDao clients = storage.getClientsDao();
    final Client client = clients.getClient(fromUser);
    if (client != null) {
        // Make sure we force clients to authenticate.
        if (!authenticateUsers // https://github.com/Mobicents/RestComm/issues/29 Allow disabling of SIP authentication
                || CallControlHelper.checkAuthentication(request, storage)) {
            // if the client has authenticated, try to redirect to the Client VoiceURL app
            // otherwise continue trying to process the Client invite
            if (redirectToClientVoiceApp(self, request, accounts, applications, client)) {
                return;
            } // else continue trying other ways to handle the request
        } else {
            // Since the client failed to authenticate, we will take no further action at this time.
            return;
        }
    }
    // TODO Enforce some kind of security check for requests coming from outside SIP UAs such as ITSPs that are not
    // registered

    final String toUser = CallControlHelper.getUserSipId(request, useTo);
    final String ruri = ((SipURI) request.getRequestURI()).getHost();
    final String toHost = ((SipURI) request.getTo().getURI()).getHost();
    final String toHostIpAddress = InetAddress.getByName(toHost).getHostAddress();
    final String toPort = String.valueOf(((SipURI) request.getTo().getURI()).getPort()).equalsIgnoreCase("-1")
            ? "5060"
            : String.valueOf(((SipURI) request.getTo().getURI()).getHost());
    final String transport = ((SipURI) request.getTo().getURI()).getTransportParam() == null ? "udp"
            : ((SipURI) request.getTo().getURI()).getTransportParam();
    SipURI outboundIntf = outboundInterface(transport);

    if (logger.isInfoEnabled()) {
        logger.info("ToHost: " + toHost);
        logger.info("ruri: " + ruri);
        logger.info("myHostIp: " + myHostIp);
        logger.info("mediaExternalIp: " + mediaExternalIp);
        logger.info("proxyIp: " + proxyIp);
    }

    if (client != null) { // make sure the caller is a registered client and not some external SIP agent that we have little control over
        Client toClient = clients.getClient(toUser);
        if (toClient != null) { // looks like its a p2p attempt between two valid registered clients, lets redirect to the b2bua
            if (logger.isInfoEnabled()) {
                logger.info("Client is not null: " + client.getLogin() + " will try to proxy to client: "
                        + toClient);
            }
            if (B2BUAHelper.redirectToB2BUA(request, client, toClient, storage, sipFactory,
                    patchForNatB2BUASessions)) {
                if (logger.isInfoEnabled()) {
                    logger.info("Call to CLIENT.  myHostIp: " + myHostIp + " mediaExternalIp: "
                            + mediaExternalIp + " toHost: " + toHost + " fromClient: " + client.getUri()
                            + " toClient: " + toClient.getUri());
                }
                // if all goes well with proxying the invitation on to the next client
                // then we can end further processing of this INVITE
                return;
            } else {

                String errMsg = "Cannot Connect to Client: " + toClient.getFriendlyName()
                        + " : Make sure the Client exist or is registered with Restcomm";
                sendNotification(errMsg, 11001, "warning", true);

            }
        } else {
            // toClient is null or we couldn't make the b2bua call to another client. check if this call is for a registered
            // DID (application)
            if (redirectToHostedVoiceApp(self, request, accounts, applications, toUser)) {
                // This is a call to a registered DID (application)
                return;
            }
            // This call is not a registered DID (application). Try to proxy out this call.
            // log to console and to notification engine
            String errMsg = "A Restcomm Client is trying to call a Number/DID that is not registered with Restcomm";
            sendNotification(errMsg, 11002, "info", true);

            if (isWebRTC(request)) {
                //This is a WebRTC client that dials out
                proxyThroughMediaServer(request, client, toUser);
                return;
            }

            // https://telestax.atlassian.net/browse/RESTCOMM-335
            final String proxyURI = activeProxy;
            final String proxyUsername = activeProxyUsername;
            final String proxyPassword = activeProxyPassword;
            SipURI from = null;
            SipURI to = null;
            boolean callToSipUri = false;
            // proxy DID or number if the outbound proxy fields are not empty in the restcomm.xml
            if (proxyURI != null && !proxyURI.isEmpty()) {
                final Configuration runtime = configuration.subset("runtime-settings");
                final boolean useLocalAddressAtFromHeader = runtime.getBoolean("use-local-address", false);
                final boolean outboudproxyUserAtFromHeader = runtime.subset("outbound-proxy")
                        .getBoolean("outboudproxy-user-at-from-header", true);
                if ((myHostIp.equalsIgnoreCase(toHost) || mediaExternalIp.equalsIgnoreCase(toHost))
                        || (myHostIp.equalsIgnoreCase(toHostIpAddress)
                                || mediaExternalIp.equalsIgnoreCase(toHostIpAddress))) {
                    if (logger.isInfoEnabled()) {
                        logger.info("Call to NUMBER.  myHostIp: " + myHostIp + " mediaExternalIp: "
                                + mediaExternalIp + " toHost: " + toHost + " proxyUri: " + proxyURI);
                    }
                    try {
                        if (useLocalAddressAtFromHeader) {
                            if (outboudproxyUserAtFromHeader) {
                                from = (SipURI) sipFactory.createSipURI(proxyUsername,
                                        mediaExternalIp + ":" + outboundIntf.getPort());
                            } else {
                                from = sipFactory.createSipURI(((SipURI) request.getFrom().getURI()).getUser(),
                                        mediaExternalIp + ":" + outboundIntf.getPort());
                            }
                        } else {
                            if (outboudproxyUserAtFromHeader) {
                                // https://telestax.atlassian.net/browse/RESTCOMM-633. Use the outbound proxy username as
                                // the userpart of the sip uri for the From header
                                from = (SipURI) sipFactory.createSipURI(proxyUsername, proxyURI);
                            } else {
                                from = sipFactory.createSipURI(((SipURI) request.getFrom().getURI()).getUser(),
                                        proxyURI);
                            }
                        }
                        to = sipFactory.createSipURI(((SipURI) request.getTo().getURI()).getUser(), proxyURI);
                    } catch (Exception exception) {
                        if (logger.isInfoEnabled()) {
                            logger.info("Exception: " + exception);
                        }
                    }
                } else {
                    if (logger.isInfoEnabled()) {
                        logger.info("Call to SIP URI. myHostIp: " + myHostIp + " mediaExternalIp: "
                                + mediaExternalIp + " toHost: " + toHost + " proxyUri: " + proxyURI);
                    }
                    from = sipFactory.createSipURI(((SipURI) request.getFrom().getURI()).getUser(),
                            outboundIntf.getHost() + ":" + outboundIntf.getPort());
                    to = sipFactory.createSipURI(toUser, toHost + ":" + toPort);
                    callToSipUri = true;
                }
                if (B2BUAHelper.redirectToB2BUA(request, client, from, to, proxyUsername, proxyPassword,
                        storage, sipFactory, callToSipUri, patchForNatB2BUASessions)) {
                    return;
                }
            } else {
                String msg = "Restcomm tried to proxy this call to an outbound party but it seems the outbound proxy is not configured.";
                sendNotification(errMsg, 11004, "warning", true);
            }
        }
    } else {
        // Client is null, check if this call is for a registered DID (application)
        if (redirectToHostedVoiceApp(self, request, accounts, applications, toUser)) {
            // This is a call to a registered DID (application)
            return;
        }
    }
    final SipServletResponse response = request.createResponse(SC_NOT_FOUND);
    response.send();
    // We didn't find anyway to handle the call.
    String errMsg = "Restcomm cannot process this call because the destination number " + toUser
            + "cannot be found or there is application attached to that";
    sendNotification(errMsg, 11005, "error", true);

}