if (!gatewayInfo.isOverwriteUserInfo()) {  for (User user : users) { UserCallerAliasInfo info = new UserCallerAliasInfo(user); if (info.hasExternalNumber()) { String externalNumber = info.getExternalNumber(m_anonymousAlias); String callerAliasUri = SipUri.format(user.getDisplayName(), externalNumber, sipDomain); String identity = AliasMapping.createUri(user.getUserName(), sipDomain); addItem(items, gatewayAddr, callerAliasUri, identity); }
if (gatewayInfo.isIgnoreUserInfo()) { continue; }  for (User user : users) { UserCallerAliasInfo info = new UserCallerAliasInfo(user); String externalNumber = getExternalNumber(gatewayInfo, info, user); if (externalNumber != null) { String callerAliasUri = SipUri.format(user.getDisplayName(), externalNumber, sipDomain); String identity = AliasMapping.createUri(user.getUserName(), sipDomain); addItem(items, gatewayAddr, callerAliasUri, identity);
    protected void addItems(Element items) {        // FIXME: use only gateways that are used in dialplan...        List<Gateway> gateways = m_gatewayContext.getGateways();        List<User> users = getCoreContext().loadUsers();        String sipDomain = getSipDomain();        for (Gateway gateway : gateways) {            String gatewayAddr = gateway.getAddress();            // add default entry for the gateway            GatewayCallerAliasInfo gatewayInfo = gateway.getCallerAliasInfo();            String defaultCallerAlias = gatewayInfo.getDefaultCallerAlias();            if (StringUtils.isNotEmpty(defaultCallerAlias)) {                String callerAliasUri = SipUri.format(defaultCallerAlias, sipDomain, false);                addItem(items, gatewayAddr, callerAliasUri);            }            // only add user aliases is overwrite is not set            if (!gatewayInfo.isOverwriteUserInfo()) {                // add per-user entries                for (User user : users) {                    UserCallerAliasInfo info = new UserCallerAliasInfo(user);                    if (info.hasExternalNumber()) {                        String externalNumber = info.getExternalNumber(m_anonymousAlias);                        String callerAliasUri = SipUri.format(user.getDisplayName(),                                externalNumber, sipDomain);                        String identity = AliasMapping.createUri(user.getUserName(), sipDomain);                        addItem(items, gatewayAddr, callerAliasUri, identity);                    }                }            }        }    }