/*
 * 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 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 Core3101 extends AbstractConfigurator {
//	private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(Core3101.class);
	public static final String PROPERTY_TO_SET = "${xemelios.lib}";

	public Core3101() {
		super();
	}

	@Override
	public void run() throws Exception {
		System.out.println("doing configuration 3101");
		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("xemelios.lib","${xemelios.prg}/root/lib");
				xemProps.store(new FileOutputStream(xemPropsFile),"");
			}
		}
	}

}
