<commit_before>/*
 * File   : $Source: /alkacon/cvs/opencms/src-modules/org/opencms/workplace/tools/scheduler/CmsEditScheduledJobInfoDialog.java,v $
 * Date   : $Date: 2005/05/20 11:58:45 $
 * Version: $Revision: 1.6 $
 *
 * This library is part of OpenCms -
 * the Open Source Content Mananagement System
 *
 * Copyright (C) 2002 - 2005 Alkacon Software (http://www.alkacon.com)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * For further information about Alkacon Software, please see the
 * company website: http://www.alkacon.com
 *
 * For further information about OpenCms, please see the
 * project website: http://www.opencms.org
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package org.opencms.workplace.tools.scheduler;

import org.opencms.configuration.CmsSystemConfiguration;
import org.opencms.jsp.CmsJspActionElement;
import org.opencms.main.CmsContextInfo;
import org.opencms.main.OpenCms;
import org.opencms.scheduler.CmsScheduledJobInfo;
import org.opencms.util.CmsStringUtil;
import org.opencms.widgets.CmsCheckboxWidget;
import org.opencms.widgets.CmsInputWidget;
import org.opencms.widgets.CmsVfsFileWidget;
import org.opencms.workplace.CmsDialog;
import org.opencms.workplace.CmsWidgetDialog;
import org.opencms.workplace.CmsWidgetDialogParameter;
import org.opencms.workplace.CmsWorkplaceSettings;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.PageContext;

/**
 * Dialog to edit new and existing scheduled jobs in the administration view.<p>
 * 
 * @author <NAME> (<EMAIL>)
 * 
 * @version $Revision: 1.6 $
 * @since 5.9.1
 */
public class CmsEditScheduledJobInfoDialog extends CmsWidgetDialog {
    
    /** The action to copy a job to edit. */
    public static final String DIALOG_COPYJOB = "copyjob";

    /** Defines which pages are valid for this dialog. */
    public static final String[] PAGES = {"page1", "page2"};  
    
    /** Request parameter name for the job id. */
    public static final String PARAM_JOBID = "jobid";
    
    /** Request parameter name for the job name. */
    public static final String PARAM_JOBNAME = "jobname";

    /** The job info object that is edited on this dialog. */
    private CmsScheduledJobInfo m_jobInfo;
    
    /** Stores the value of the request parameter for the job id. */
    private String m_paramJobid;
    
    /** Stores the value of the request parameter for the job name. */
    private String m_paramJobname;
    
    /**
     * Public constructor with JSP action element.<p>
     * 
     * @param jsp an initialized JSP action element
     */
    public CmsEditScheduledJobInfoDialog(CmsJspActionElement jsp) {

        super(jsp);
    }       

    /**
     * Public constructor with JSP variables.<p>
     * 
     * @param context the JSP page context
     * @param req the JSP request
     * @param res the JSP response
     */
    public CmsEditScheduledJobInfoDialog(PageContext context, HttpServletRequest req, HttpServletResponse res) {

        this(new CmsJspActionElement(context, req, res));
    }
    
    /**
     * Commits the edited scheduled job to the scheduler.<p>
     */
    public void actionCommit() {
        
        List errors = new ArrayList();
        
        CmsScheduledJobInfo jobCopy = null;
        if (m_jobInfo.getId() != null) {
            // get a copy of the valid job if id is present
            jobCopy = OpenCms.getScheduleManager().getJob(m_jobInfo.getId());
        }
        
        try {
            // schedule the edited job
            OpenCms.getScheduleManager().scheduleJob(getCms(), m_jobInfo);
            // update the XML configuration
            OpenCms.writeConfiguration(CmsSystemConfiguration.class);
        } catch (Throwable t) {
            errors.add(t);    
        }
        
        if (errors.size() > 0 && jobCopy != null) {
            // re-schedule copy of the valid job if an error scheduling a present job occurred
            try {
                OpenCms.getScheduleManager().scheduleJob(getCms(), jobCopy);    
            } catch (Throwable t) {
                errors.add(t);
            }
        }
        
        // set the list of errors to display when saving failed
        setCommitErrors(errors);<commit_msg>list refresh works again<commit_after>/*
 * File   : $Source: /alkacon/cvs/opencms/src-modules/org/opencms/workplace/tools/scheduler/CmsEditScheduledJobInfoDialog.java,v $
 * Date   : $Date: 2005/05/20 12:03:58 $
 * Version: $Revision: 1.7 $
 *
 * This library is part of OpenCms -
 * the Open Source Content Mananagement System
 *
 * Copyright (C) 2002 - 2005 Alkacon Software (http://www.alkacon.com)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * For further information about Alkacon Software, please see the
 * company website: http://www.alkacon.com
 *
 * For further information about OpenCms, please see the
 * project website: http://www.opencms.org
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package org.opencms.workplace.tools.scheduler;

import org.opencms.configuration.CmsSystemConfiguration;
import org.opencms.jsp.CmsJspActionElement;
import org.opencms.main.CmsContextInfo;
import org.opencms.main.OpenCms;
import org.opencms.scheduler.CmsScheduledJobInfo;
import org.opencms.util.CmsStringUtil;
import org.opencms.widgets.CmsCheckboxWidget;
import org.opencms.widgets.CmsInputWidget;
import org.opencms.widgets.CmsVfsFileWidget;
import org.opencms.workplace.CmsDialog;
import org.opencms.workplace.CmsWidgetDialog;
import org.opencms.workplace.CmsWidgetDialogParameter;
import org.opencms.workplace.CmsWorkplaceSettings;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.PageContext;

/**
 * Dialog to edit new and existing scheduled jobs in the administration view.<p>
 * 
 * @author <NAME> (<EMAIL>)
 * 
 * @version $Revision: 1.7 $
 * @since 5.9.1
 */
public class CmsEditScheduledJobInfoDialog extends CmsWidgetDialog {
    
    /** The action to copy a job to edit. */
    public static final String DIALOG_COPYJOB = "copyjob";

    /** Defines which pages are valid for this dialog. */
    public static final String[] PAGES = {"page1", "page2"};  
    
    /** Request parameter name for the job id. */
    public static final String PARAM_JOBID = "jobid";
    
    /** Request parameter name for the job name. */
    public static final String PARAM_JOBNAME = "jobname";

    /** The job info object that is edited on this dialog. */
    private CmsScheduledJobInfo m_jobInfo;
    
    /** Stores the value of the request parameter for the job id. */
    private String m_paramJobid;
    
    /** Stores the value of the request parameter for the job name. */
    private String m_paramJobname;
    
    /**
     * Public constructor with JSP action element.<p>
     * 
     * @param jsp an initialized JSP action element
     */
    public CmsEditScheduledJobInfoDialog(CmsJspActionElement jsp) {

        super(jsp);
    }       

    /**
     * Public constructor with JSP variables.<p>
     * 
     * @param context the JSP page context
     * @param req the JSP request
     * @param res the JSP response
     */
    public CmsEditScheduledJobInfoDialog(PageContext context, HttpServletRequest req, HttpServletResponse res) {

        this(new CmsJspActionElement(context, req, res));
    }
    
    /**
     * Commits the edited scheduled job to the scheduler.<p>
     */
    public void actionCommit() {
        
        List errors = new ArrayList();
        
        CmsScheduledJobInfo jobCopy = null;
        if (m_jobInfo.getId() != null) {
            // get a copy of the valid job if id is present
            jobCopy = OpenCms.getScheduleManager().getJob(m_jobInfo.getId());
        }
        
        try {
            // schedule the edited job
            OpenCms.getScheduleManager().scheduleJob(getCms(), m_jobInfo);
            // clear the HTML list to be up to date after editing
            getSettings().setHtmlList(null);
            // update the XML configuration
            OpenCms.writeConfiguration(CmsSystemConfiguration.class);
        } catch (Throwable t) {
            errors.add(t);    
        }
        
        if (errors.size() > 0 && jobCopy != null) {
            // re-schedule copy of the valid job if an error scheduling a present job occurred
            try {
                OpenCms.getScheduleManager().scheduleJob(getCms(), jobCopy);    
            } catch (Throwable t) {
                errors.add(t);
            }
        }
        
        // set the list of errors to display when saving failed
        setCommitErrors(errors);
{'fraction_non_alphanumeric': 0.08841645142062388, 'fraction_numerical': 0.009537055434134712, 'mean_word_length': 2.821943811693242, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, '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': '7664182', 'n_tokens_mistral': 2943, 'n_tokens_neox': 2844, 'n_words': 942}