//--------------------------------------------------------------------------
private int configImport(Element params, ServiceContext context, File configFile) throws Exception
{
GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
DataManager dm = gc.getBean(DataManager.class);
ImportConfig config = new ImportConfig(configFile, context);
String dir = Util.getParam(params, Params.DIR);
String group = Util.getParam(params, Params.GROUP);
String style = Util.getParam(params, Params.STYLESHEET);
boolean validate = Util.getParam(params, Params.VALIDATE, "off").equals("on");
File sites[] = new File(dir).listFiles(filter);
if (sites == null)
throw new Exception("Directory not found : " + dir);
int counter = 0;
ArrayList<ImportInfo> alImport = new ArrayList<ImportInfo>();
for(int i=0; i<sites.length; i++)
{
if(context.isDebugEnabled())
context.debug("Scanning site : "+sites[i]);
File categs[] = sites[i].listFiles(filter);
if (categs == null)
throw new Exception("Cannot scan categories in : " + sites[i].getPath());
for(int j=0; j<categs.length; j++)
{
if(context.isDebugEnabled())
context.debug(" Scanning category : "+categs[j]);
String catDir = categs[j].getName();
File files[] = categs[j].listFiles(new BatchImportFilenameFilter());
if (files == null)
throw new Exception("Cannot scan files in : " + categs[j].getPath());
for(int k=0; k<files.length; k++)
{
Element xml = Xml.loadFile(files[k]);
if (!style.equals("_none_"))
xml = Xml.transform(xml, stylePath +"/"+ style);
String category = config.mapCategory(catDir);
String schema = config.mapSchema(catDir);
if (validate)
dm.validate(schema, xml);
alImport.add(new ImportInfo(schema, category, xml));
counter++;
}
}