/*
 * Copyright
 *   2007 axYus - www.axyus.com
 *   2007 C.Marchand - christophe.marchand@axyus.com
 *
 * This file is part of XEMELIOS.
 *
 * XEMELIOS 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 3 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 Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser 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 java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Properties;

import fr.gouv.finances.cp.xemelios.updater.AbstractConfigurator;

public class Core3110 extends AbstractConfigurator {
	//private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(Core3110.class);
	public static final String PROPERTY_TO_SET = "${"+Constants.SYS_PROP_DATE_FORMAT+"}";

	public Core3110() {
		super();
	}

	@Override
	public void run() throws Exception {
		System.out.println("doing configuration 3110");
		String ret = props.replace(PROPERTY_TO_SET);
		if(PROPERTY_TO_SET.equals(ret)) {
			Properties xemProps = new Properties();
			File xemPropsFile = new File(props.replace("${xemelios.prg}/root/xemelios.properties"));
			if(!xemPropsFile.exists()) {
			} else {
				xemProps.load(new FileInputStream(xemPropsFile));
				xemProps.put(Constants.SYS_PROP_DATE_FORMAT,"dd/MM/yyyy");
				xemProps.store(new FileOutputStream(xemPropsFile),"");
			}
		}
		setPreviousConfigurator(new Core3101());
	}

}
