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()); } }
@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); } } }