/*
Copyright (C) 2000-2010  Ministere de la culture et de la communication (France), AJLSM
See LICENCE file
 */
package fr.gouv.culture.sdx.utils.save;

import java.io.File;
import java.io.IOException;

import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
import org.xml.sax.SAXException;

import fr.gouv.culture.sdx.exception.SDXException;

/**
 * @author jlecren
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class SaveParametersBuilder extends DefaultConfigurationBuilder {

	/** Build a hierarchy of SaveParameters objects from backup file "info.xml"
	 * @see org.apache.avalon.framework.configuration.DefaultConfigurationBuilder#buildFromFile(java.lang.String)
	 */
	public Configuration buildFromFile(String baseDir, String fileName) throws SDXException{
		try{
			Configuration conf = super.buildFromFile(baseDir + File.separator + fileName);
			return new SaveParameters(conf,baseDir);
		}catch(IOException e)
		{
			throw new SDXException(e.getMessage(),e);
		}catch(ConfigurationException e)
		{
			throw new SDXException(e.getMessage(),e);
		}catch(SAXException e)
		{
			throw new SDXException(e.getMessage(),e);
		}
	}
}
