@Override public List<Replicable> getReplicables() { List<Location> locations = m_featureManager.getLocationsForEnabledFeature(FEATURE); if (locations.isEmpty()) { return Collections.emptyList(); } List<Replicable> replicables = new ArrayList<Replicable>(); replicables.add(getSettings()); return replicables; }
@Override public void replicate(ConfigManager manager, ConfigRequest request) throws IOException { if (!request.applies( DialPlanContext.FEATURE, Ivr.FEATURE, Mwi.FEATURE, RestServer.FEATURE, ImBot.FEATURE, FreeswitchFeature.FEATURE, AdminContext.FEATURE, ApacheManager.FEATURE, ImManager.FEATURE)) { return; } Set<Location> locations = request.locations(manager); FeatureManager featureManager = manager.getFeatureManager(); Address adminApi = manager.getAddressManager().getSingleAddress(AdminContext.HTTP_ADDRESS_AUTH); Address apacheApi = manager.getAddressManager().getSingleAddress(ApacheManager.HTTPS_ADDRESS); Address restApi = manager.getAddressManager().getSingleAddress(RestServer.HTTP_API); Address imApi = manager.getAddressManager().getSingleAddress(ImManager.XMLRPC_ADDRESS); Address imbotApi = manager.getAddressManager().getSingleAddress(ImBot.REST_API); Address fsEvent = manager.getAddressManager().getSingleAddress(FreeswitchFeature.EVENT_ADDRESS); IvrSettings settings = m_ivr.getSettings(); Domain domain = manager.getDomainManager().getDomain(); List<Location> mwiLocations = manager.getFeatureManager().getLocationsForEnabledFeature(Mwi.FEATURE); int mwiPort = m_mwi.getSettings().getHttpApiPort(); for (Location location : locations) { File dir = manager.getLocationDataDirectory(location); boolean enabled = featureManager.isFeatureEnabled(Ivr.FEATURE, location); ConfigUtils.enableCfengineClass(dir, "sipxivr.cfdat", enabled, "sipxivr"); if (!enabled) { continue; } File f = new File(dir, "sipxivr.properties.part"); Writer wtr = new FileWriter(f); Set<String> mwiAddresses = new LinkedHashSet<String>(); mwiAddresses.add(location.getAddress()); for (Location mwiLocation : mwiLocations) { mwiAddresses.add(mwiLocation.getAddress()); } try { write( wtr, settings, domain, location, StringUtils.join(mwiAddresses, ","), mwiPort, restApi, adminApi, apacheApi, imApi, imbotApi, fsEvent); } finally { IOUtils.closeQuietly(wtr); } } }