<commit_before>/*
 * 
 * 
 * Copyright (C) 2005 SIPfoundry Inc.
 * Licensed by SIPfoundry under the LGPL license.
 * 
 * Copyright (C) 2005 Pingtel Corp.
 * Licensed to SIPfoundry under a Contributor Agreement.
 * 
 * $
 */
package org.sipfoundry.sipxconfig.site.admin.commserver;

import org.apache.tapestry.IPage;
import org.apache.tapestry.annotations.Bean;
import org.apache.tapestry.annotations.InitialValue;
import org.apache.tapestry.annotations.InjectObject;
import org.apache.tapestry.annotations.InjectPage;
import org.apache.tapestry.annotations.Persist;
import org.apache.tapestry.event.PageBeginRenderListener;
import org.apache.tapestry.event.PageEvent;
import org.apache.tapestry.html.BasePage;
import org.sipfoundry.sipxconfig.admin.commserver.Server;
import org.sipfoundry.sipxconfig.components.SipxValidationDelegate;
import org.sipfoundry.sipxconfig.setting.Setting;

/**
 * Page presenting sipX server settings: in most cases obtained by reading values from
 * configuration files in /etc/sipxpbx directory
 */
public abstract class ServerSettings extends BasePage implements PageBeginRenderListener {
    public static final String PAGE = "ServerSettings";

    @InjectObject(value = "spring:sipxServer")
    public abstract Server getServer();

    @Bean
    public abstract SipxValidationDelegate getValidator();

    @Persist(value = "session")
    @InitialValue(value = "literal:voice-mail")
    public abstract String getParentSettingName();

    @InjectPage(value = RestartReminder.PAGE)
    public abstract RestartReminder getRestartReminderPage();

    public abstract void setParentSettingName(String name);

    public abstract Setting getParentSetting();

    public abstract void setParentSetting(Setting parent);

    public void pageBeginRender(PageEvent event_) {
        if (getParentSetting() != null) {
            return;
        }
        Server server = getServer();
        Setting root = server.getSettings();
        Setting parent = root.getSetting(getParentSettingName());
        setParentSetting(parent);
    }

    @SuppressWarnings("unused")
    public void editSettings(Integer serverId_, String settingPath) {
        setParentSettingName(settingPath);
    }

    public IPage apply() {
        RestartReminder restartPage = getRestartReminderPage();
        restartPage.setNextPage(PAGE);
        return restartPage;
    }

    public void cancel() {
        getServer().resetSettings();
    }
}
<commit_msg>XCF-1591 - Explicitly call save settings to save the configuration, bug was introduced in r9105 3/16/07 by some page refactoring<commit_after>/*
 * 
 * 
 * Copyright (C) 2005 SIPfoundry Inc.
 * Licensed by SIPfoundry under the LGPL license.
 * 
 * Copyright (C) 2005 Pingtel Corp.
 * Licensed to SIPfoundry under a Contributor Agreement.
 * 
 * $
 */
package org.sipfoundry.sipxconfig.site.admin.commserver;

import org.apache.tapestry.IPage;
import org.apache.tapestry.annotations.Bean;
import org.apache.tapestry.annotations.InitialValue;
import org.apache.tapestry.annotations.InjectObject;
import org.apache.tapestry.annotations.InjectPage;
import org.apache.tapestry.annotations.Persist;
import org.apache.tapestry.event.PageBeginRenderListener;
import org.apache.tapestry.event.PageEvent;
import org.apache.tapestry.html.BasePage;
import org.sipfoundry.sipxconfig.admin.commserver.Server;
import org.sipfoundry.sipxconfig.components.SipxValidationDelegate;
import org.sipfoundry.sipxconfig.setting.Setting;

/**
 * Page presenting sipX server settings: in most cases obtained by reading values from
 * configuration files in /etc/sipxpbx directory
 */
public abstract class ServerSettings extends BasePage implements PageBeginRenderListener {
    public static final String PAGE = "ServerSettings";

    @InjectObject(value = "spring:sipxServer")
    public abstract Server getServer();

    @Bean
    public abstract SipxValidationDelegate getValidator();

    @Persist(value = "session")
    @InitialValue(value = "literal:voice-mail")
    public abstract String getParentSettingName();

    @InjectPage(value = RestartReminder.PAGE)
    public abstract RestartReminder getRestartReminderPage();

    public abstract void setParentSettingName(String name);

    public abstract Setting getParentSetting();

    public abstract void setParentSetting(Setting parent);

    public void pageBeginRender(PageEvent event_) {
        if (getParentSetting() != null) {
            return;
        }
        Server server = getServer();
        Setting root = server.getSettings();
        Setting parent = root.getSetting(getParentSettingName());
        setParentSetting(parent);
    }

    @SuppressWarnings("unused")
    public void editSettings(Integer serverId_, String settingPath) {
        setParentSettingName(settingPath);
    }

    public IPage apply() {
        getServer().applySettings();
        RestartReminder restartPage = getRestartReminderPage();
        restartPage.setNextPage(PAGE);
        return restartPage;
    }

    public void cancel() {
        getServer().resetSettings();
    }
}

{'fraction_non_alphanumeric': 0.09003152088258472, 'fraction_numerical': 0.005713159968479117, 'mean_word_length': 4.056772908366534, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2281330', 'n_tokens_mistral': 1446, 'n_tokens_neox': 1390, 'n_words': 341}