/*
 * Copyright 
 *   2005 axYus - www.axyus.com
 *   2005 L.Meckert - lmeckert@club-internet.fr
 * 
 * This file is part of XEMELIOS.
 * 
 * XEMELIOS is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * XEMELIOS 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 General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with XEMELIOS; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package fr.gouv.finances.cp.xemelios.patches;

import fr.gouv.finances.cp.xemelios.common.Constants;
import fr.gouv.finances.cp.xemelios.updater.AbstractConfigurator;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Properties;

/**
 *
 * @author chm
 */
public class Core3316 extends AbstractConfigurator {
    
    public Core3316() {
        super();
    }

    @Override
    public void run() throws Exception {
        Properties xemProps = new Properties();
        File xemPropsFile = new File(props.replace("${xemelios.prg}/root/xemelios.properties"));
        if(!xemPropsFile.exists()) {
        } else {
            xemProps.load(new FileInputStream(xemPropsFile));
            if(!xemProps.getProperty(Constants.SYSPROP_UPDATE_SOURCE).contains("xemelios.org")) {
                xemProps.setProperty(Constants.SYSPROP_UPDATE_SOURCE, "http://xemelios.org/updates33/update.xml");
            }
            if(!xemProps.containsKey(Constants.SYS_PROP_XEMELIOS_EXPORTER_CLASS)) {
                xemProps.setProperty(Constants.SYS_PROP_XEMELIOS_EXPORTER_CLASS, "fr.gouv.finances.cp.xemelios.export.JxlExporter");
            }
            xemProps.store(new FileOutputStream(xemPropsFile),"");
        }
        setPreviousConfigurator(new Core33027());
    }

}
