/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


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

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 Core33021 extends AbstractConfigurator {
    public static final transient String RESOURCE_PROPERTY = "xemelios.resources.location";
    public static final transient String SYS_RESOURCE_PROPERTY = "${"+RESOURCE_PROPERTY+"}";

    public Core33021() {
        super();
    }

    @Override
    public void run() throws Exception {
        String prop = props.replace(SYS_RESOURCE_PROPERTY);
        boolean propSet = SYS_RESOURCE_PROPERTY.equals(prop);
        if(!propSet) {
            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.setProperty(RESOURCE_PROPERTY, "${xemelios.prg}/root/resources");
                xemProps.store(new FileOutputStream(xemPropsFile),"");
            }
        }
        setPreviousConfigurator(new Core3200());
    }
    
    
}
