@Override public Address getSingleAddress( AddressType t, Collection<Address> addresses, Location whoIsAsking) { if (addresses == null || addresses.size() == 0) { return null; } for (DnsProvider p : getProviders()) { Address rewrite = p.getAddress(this, t, addresses, whoIsAsking); if (rewrite != null) { return rewrite; } } Iterator<Address> i = addresses.iterator(); Address first = i.next(); if (addresses.size() == 1 || whoIsAsking == null) { return first; } // return the address local to who is asking if available Address a = first; while (a != null) { if (a.getAddress().equals(whoIsAsking.getAddress())) { return a; } a = (i.hasNext() ? i.next() : null); } // first is as good as any other return first; }
@Override public void replicate(ConfigManager manager, ConfigRequest request) throws IOException { if (!request.applies(AuthCodes.FEATURE)) { return; } if (!m_authCodes.isEnabled()) { return; } Set<Location> locations = request.locations(manager); Address fs = manager.getAddressManager().getSingleAddress(FreeswitchFeature.ACC_EVENT_ADDRESS); Domain domain = manager.getDomainManager().getDomain(); for (Location location : locations) { AuthCodeSettings settings = m_authCodes.getSettings(); File dir = manager.getLocationDataDirectory(location); boolean enabled = manager.getFeatureManager().isFeatureEnabled(AuthCodes.FEATURE); ConfigUtils.enableCfengineClass(dir, "sipxacccode.cfdat", enabled, "sipxacccode"); Writer flat = new FileWriter(new File(dir, "sipxacccode.properties.part")); try { writeConfig(flat, settings, domain, fs.getPort()); } finally { IOUtils.closeQuietly(flat); } } }
public boolean requestToAddMyAssistantToRoster(String userName) { Address imbotRestAddress = m_addressManager.getSingleAddress(ImBot.REST_API); try { m_restTemplate.put(ADD_TO_ROSTER_URL, null, imbotRestAddress.toString(), userName); } catch (RestClientException ex) { return false; } return true; }
/** * Music on hold implementation requires that ~~mh~u calls are forwarded to Media Server. We are * adding the rule here. */ public List<DialingRule> getDialingRules(Location location) { MohAddressFactory factory = getAddressFactory(); Address mediaAddress = factory.getMediaAddress(location); if (mediaAddress == null) { return Collections.emptyList(); } DialingRule rule = new MohRule(mediaAddress.getAddress(), factory.getFilesMohUser()); return Collections.singletonList(rule); }
void write( Writer wtr, IvrSettings settings, Domain domain, Location location, String mwiAddresses, int mwiPort, Address restApi, Address adminApi, Address apacheApi, Address imApi, Address imbotApi, Address fsEvent) throws IOException { KeyValueConfiguration config = KeyValueConfiguration.equalsSeparated(wtr); config.writeSettings(settings.getSettings()); config.write("freeswitch.eventSocketPort", fsEvent.getPort()); // potential bug: name "operator" could be changed by admin. this should be configurable // and linked with vm dialing rule config.write("ivr.operatorAddr", "sip:operator@" + domain.getName()); // required services if (mwiAddresses == null) { throw new ConfigException("MWI feature needs to be enabled. No addresses found."); } config.write("ivr.mwiAddresses", mwiAddresses); config.write("ivr.mwiPort", mwiPort); if (adminApi == null) { throw new ConfigException("Admin feature needs to be enabled. No addresses found."); } config.write("ivr.configUrl", adminApi.toString()); if (apacheApi != null) { config.write("ivr.emailAddressUrl", apacheApi.toString()); } // optional services if (restApi != null) { config.write("ivr.3pccSecureUrl", restApi.toString()); config.write("ivr.callHistoryUrl", restApi.toString() + "/cdr/"); } if (imApi != null) { config.write("ivr.openfireHost", imApi.getAddress()); config.write("ivr.openfireXmlRpcPort", imApi.getPort()); } if (imbotApi != null) { config.write("ivr.sendIMUrl", imbotApi.toString()); } }