[lsc-changes] r484 - in lsc/trunk/src/main/java/org/lsc: . beans jndi persistence service utils

jclarke at lsc-project.org jclarke at lsc-project.org
Sun Nov 29 19:25:47 CET 2009


Author: jclarke
Date: 2009-11-29 19:25:47 +0100 (Sun, 29 Nov 2009)
New Revision: 484

Removed:
   lsc/trunk/src/main/java/org/lsc/AbstractGenerator.java
   lsc/trunk/src/main/java/org/lsc/Generator.java
   lsc/trunk/src/main/java/org/lsc/beans/BeanGenerator.java
   lsc/trunk/src/main/java/org/lsc/jndi/JndiDstObjectGenerator.java
   lsc/trunk/src/main/java/org/lsc/jndi/JndiSrcObjectGenerator.java
   lsc/trunk/src/main/java/org/lsc/persistence/SqlMapXmlFileGenerator.java
   lsc/trunk/src/main/java/org/lsc/service/JdbcSrcServiceObjectGenerator.java
   lsc/trunk/src/main/java/org/lsc/utils/Csv2SqlObjectGenerator.java
   lsc/trunk/src/main/java/org/lsc/utils/PropertiesGenerator.java
Modified:
   lsc/trunk/src/main/java/org/lsc/service/JndiDataSchemaProvider.java
Log:
References #22. Remove all generators.

Deleted: lsc/trunk/src/main/java/org/lsc/AbstractGenerator.java
===================================================================
--- lsc/trunk/src/main/java/org/lsc/AbstractGenerator.java	2009-11-29 18:14:44 UTC (rev 483)
+++ lsc/trunk/src/main/java/org/lsc/AbstractGenerator.java	2009-11-29 18:25:47 UTC (rev 484)
@@ -1,427 +0,0 @@
-/*
- ****************************************************************************
- * Ldap Synchronization Connector provides tools to synchronize
- * electronic identities from a list of data sources including
- * any database with a JDBC connector, another LDAP directory,
- * flat files...
- *
- *                  ==LICENSE NOTICE==
- * 
- * Copyright (c) 2008, LSC Project 
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
-
- *    * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *     * Neither the name of the LSC Project nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *                  ==LICENSE NOTICE==
- *
- *               (c) 2008 - 2009 LSC Project
- *         Sebastien Bahloul <seb at lsc-project.org>
- *         Thomas Chemineau <thomas at lsc-project.org>
- *         Jonathan Clarke <jon at lsc-project.org>
- *         Remy-Christophe Schermesser <rcs at lsc-project.org>
- ****************************************************************************
- */
-package org.lsc;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.naming.NamingException;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.lsc.jndi.JndiServices;
-
-
-/**
- * Contains meta generator methods.
- *
- * @author Thomas Chemineau &lt;tchemineau at linagora.com&gt;
- */
-public abstract class AbstractGenerator {
-    /** This is the local logger. */
-    public static final Logger LOGGER = 
-        LoggerFactory.getLogger(AbstractGenerator.class);
-
-    /** Where to store generated classes. */
-    private String destination;
-
-    /** This is the LDAP objectclass name on which the generator is working. */
-    private String className;
-
-    /**
-     * This is the package name to use to identify the local path
-     * where to store the generated file.
-     */
-    private String packageName;
-
-    /**
-     * This is the file path separator taken from
-     * System.getProperty("file.separator").
-     */
-    private String separator;
-
-    /** This is the list of object classes available in the directory. */
-    private List<String> objectClasses;
-
-    /** This is the list of attribute types available in the directory. */
-    private List<String> attributeTypes;
-
-    /** This generator apply to source (or destination) directory ? */
-	private boolean fromSource;
-
-    /**
-     * Create a new AbstractGenerator for a new object from a basic class
-     * name.
-     */
-    public AbstractGenerator() {
-        this.separator = Configuration.getSeparator();
-    }
-
-    /**
-     * Generate file.
-     *
-     * @param objectClassName the target object class name
-     *
-     * @return the generation status
-     *
-     * @throws NamingException thrown if an exception is encountered during
-     *         generation
-     */
-    protected abstract boolean generate(String objectClassName) throws NamingException;
-
-    /**
-     * Return class name for latest generated file.
-     *
-     * @return Class name for latest generated file.
-     */
-    public final String getClassName() {
-        return className;
-    }
-
-    /**
-     * Return a generic file name for latest generated file.
-     *
-     * @return A java generic file name.
-     */
-    public abstract String getFileName();
-
-    /**
-     * Is this generator applying to source directory (false = target) ?
-     * @return applied to source ?
-     */
-    public boolean isFromSource() {
-    	return fromSource;
-    }
-    
-    /**
-     * Get the default standard filename.
-     *
-     * @return the filename.
-     */
-    public final String getStandardFileName() {
-        return getPackagePath() + separator + getClassName() + ".java";
-    }
-
-    /**
-     * Return a generic package name.
-     *
-     * @return A generic package name.
-     */
-    protected abstract String getGenericPackageName();
-
-    /**
-     * Return package name for latest generated bean.
-     *
-     * @return A bean package name.
-     */
-    public final String getPackageName() {
-        return packageName;
-    }
-
-    /**
-     * Return package path for generated file.
-     *
-     * @return A package source path.
-     */
-    public final String getPackagePath() {
-        String mainLocation = null;
-
-        if (destination != null) {
-            mainLocation = destination;
-        } else {
-            mainLocation = System.getProperty("user.dir") + separator + "src"
-            + separator + "main" + separator + "java";
-        }
-
-        return mainLocation + separator
-                + packageName.replaceAll("\\.", "\\" + separator);
-    }
-
-    /**
-     * Prepare data, so we just get informations from LDAP directory.
-     * This method could be called one first time before any generations.
-     *
-     * @return the initialization status
-     *
-     * @throws NamingException thrown when an directory related exception is
-     *         encountered while initializing the generator
-     *
-     * @deprecated
-     */
-    public final boolean init() throws NamingException {
-        return init(false);
-    }
-
-    /**
-     * Initialize the generator fields.
-     *
-     * @param fromSource the generated object is based on the source directory
-     *        (otherwise on the destination)
-     *
-     * @return the initialization status
-     *
-     * @throws NamingException thrown when a directory related exception is
-     *         encountered while initializing this generator
-     */
-    public final boolean init(final boolean fromSource)
-    throws NamingException {
-        JndiServices js = null;
-
-        this.fromSource = fromSource;
-        
-        if (fromSource) {
-            js = JndiServices.getSrcInstance();
-        } else {
-            js = JndiServices.getDstInstance();
-        }
-
-        Map<String, List<String>> ocsTemp = js.getSchema(new String[] {
-                "objectclasses"
-        });
-        Map<String, List<String>> atsTemp = js.getSchema(new String[] {
-                "attributetypes"
-        });
-
-        if ((ocsTemp == null) || (ocsTemp.keySet().size() == 0)
-                || (atsTemp == null) || (atsTemp.keySet().size() == 0)) {
-            LOGGER.error("Unable to read objectclasses or attributetypes in ldap schema! Exiting...");
-            return false;
-        }
-
-        objectClasses = filterNames(ocsTemp.values().iterator().next());
-        attributeTypes = filterNames(atsTemp.values().iterator().next());
-
-        return true;
-    }
-
-    /**
-     * Filter the attribute and object classes names
-     * @param names List of names
-     * @return list of filtered names
-     */
-    private List<String> filterNames(List<String> names) {
-    	List<String> filteredNames = new ArrayList<String>();
-    	Iterator<String> namesIter = names.iterator();
-    	while(namesIter.hasNext()) {
-    		String name = namesIter.next();
-    		String filteredName = filterName(name);
-    		if(filteredName != null) {
-    			filteredNames.add(filteredName);
-    		} else {
-    			LOGGER.error("Name invalid: {}. Attributes or object class not generated !!!", name);
-    		}
-    	}
-    	return filteredNames;
-    	
-	}
-
-    /**
-     * Filter name according to attribute or object class 
-     * @param name the originale name
-     * @return the filtered name or null if not matching
-     */
-	public String filterName(String name) {
-		String REGEX = "^\\p{Alpha}[\\w]*$";
-		Pattern p = Pattern.compile(REGEX);
-		Matcher m = p.matcher(name);
-		if(m.matches()) {
-			return null;
-		} else {
-			return name;
-		}
-	}
-
-	/**
-     * Default setter for the package name.
-     *
-     * @param lpackageName the package name to use in this generator
-     */
-    public final void setPackageName(final String lpackageName) {
-        packageName = lpackageName;
-    }
-
-    // Protected methods
-    /**
-     * Generate java content.
-     *
-     * @return Content within string representation.
-     */
-    protected abstract String generateContent();
-
-    /**
-     * Write java content in a particular file.
-     *
-     * @param content the content to write
-     *
-     * @return True if the operation succeeded.
-     */
-    protected final boolean writeContent(final String content) {
-        return writeContent(content, false);
-    }
-    /**
-     * Write java content in a particular file.
-     *
-     * @param content the content to write
-     * @param overwrite overwrite the file if exists
-     * @return true if the operation succeeded.
-     */
-    protected final boolean writeContent(final String content, 
-            final boolean overwrite) {
-        String fileName = getFileName();
-        File file = new File(fileName);
-
-        LOGGER.info("Creating file ({}) ...", fileName);
-				LOGGER.debug("\n---------------\n{}---------------\n", content);
-
-        try {
-            if (file.exists() && !overwrite) {
-                LOGGER.warn("File generation failed: file ({}) already exists.", fileName);
-            } else if (file.createNewFile() || overwrite) {
-                FileOutputStream os = new FileOutputStream(file);
-                os.write(content.getBytes());
-                return true;
-            } else {
-                LOGGER.error("File generation failed: file ({}) could not be created (probably a rights issue).",
-												fileName);
-            }
-        } catch (FileNotFoundException fnfe) {
-            LOGGER.error("{} ({})", fnfe, fileName);
-						LOGGER.debug(fnfe.toString(), fnfe);
-        } catch (IOException e) {
-            LOGGER.error("{} ({})", e, fileName);
-						LOGGER.debug(e.toString(), e);
-        }
-
-        return false;
-    }
-
-    /**
-     * Default setter for destination.
-     *
-     * @param ldestination destination name to set
-     */
-    public final void setDestination(final String ldestination) {
-        this.destination = ldestination;
-    }
-
-    /**
-     * Default getter for attribute types string data.
-     *
-     * @return the attribute types
-     */
-    public final List<String> getAttrs() {
-        return attributeTypes;
-    }
-
-    /**
-     * Default object classes getter.
-     *
-     * @return the object classes list
-     */
-    public final List<String> getOcs() {
-        return objectClasses;
-    }
-
-    /**
-     * Default separator getter.
-     *
-     * @return the separator
-     */
-    public final String getSeparator() {
-        return separator;
-    }
-
-    /**
-     * Default destination getter.
-     *
-     * @return the destination
-     */
-    public final String getDestination() {
-        return destination;
-    }
-
-    /**
-     * Default class name setter.
-     *
-     * @param lclassName the class name
-     */
-    public final void setClassName(final String lclassName) {
-        className = lclassName;
-    }
-
-    static Map<Integer, String> wtCache = new HashMap<Integer, String>();
-    
-    /**
-     * Generate white space with a length of the specified number of
-     * tabulation number.
-     *
-     * @param tabNumber tabulation number
-     *
-     * @return the string composed of the required white spaces
-     */
-    protected static final String wt(final int tabNumber) {
-        if (!wtCache.containsKey(tabNumber)) {
-            StringBuffer sb = new StringBuffer(tabNumber);
-
-            for (int i = 0; i < tabNumber; i++) {
-                sb.append("\t");
-            }
-
-            wtCache.put(tabNumber, sb.toString());
-        }
-
-        return wtCache.get(tabNumber);
-    }
-}

Deleted: lsc/trunk/src/main/java/org/lsc/Generator.java
===================================================================
--- lsc/trunk/src/main/java/org/lsc/Generator.java	2009-11-29 18:14:44 UTC (rev 483)
+++ lsc/trunk/src/main/java/org/lsc/Generator.java	2009-11-29 18:25:47 UTC (rev 484)
@@ -1,285 +0,0 @@
-/*
- ****************************************************************************
- * Ldap Synchronization Connector provides tools to synchronize
- * electronic identities from a list of data sources including
- * any database with a JDBC connector, another LDAP directory,
- * flat files...
- *
- *                  ==LICENSE NOTICE==
- * 
- * Copyright (c) 2008, LSC Project 
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
-
- *    * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *     * Neither the name of the LSC Project nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *                  ==LICENSE NOTICE==
- *
- *               (c) 2008 - 2009 LSC Project
- *         Sebastien Bahloul <seb at lsc-project.org>
- *         Thomas Chemineau <thomas at lsc-project.org>
- *         Jonathan Clarke <jon at lsc-project.org>
- *         Remy-Christophe Schermesser <rcs at lsc-project.org>
- ****************************************************************************
- */
-package org.lsc;
-
-import javax.naming.NamingException;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.CommandLineParser;
-import org.apache.commons.cli.GnuParser;
-import org.apache.commons.cli.MissingOptionException;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.OptionGroup;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.ParseException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.lsc.persistence.SqlMapXmlFileGenerator;
-import org.lsc.service.JdbcSrcServiceObjectGenerator;
-import org.lsc.utils.Csv2SqlObjectGenerator;
-import org.lsc.utils.PropertiesGenerator;
-
-/**
- * Main generation class.
- *
- * @author Sebastien Bahloul &lt;seb at lsc-project.org&gt;
- */
-public final class Generator {
-
-	private static final Logger LOGGER = LoggerFactory.getLogger(Generator.class);
-
-	/** When the CSV separator is rounded by ' or ", just remove them. */
-	private static final int CSV_SEPARATOR_ROUNDED = 3;
-
-	/**
-	 * This is the source Directory Object class name which is the
-	 * generator base.
-	 */
-	private String srcClassName;
-
-	/**
-	 * This is the Destination Directory Object class name which is
-	 * the generator base.
-	 */
-	private String dstClassName;
-
-	/** This is the location where generated classes must be stored. */
-	private String destination;
-
-	/** Generation type for this particular launch time. */
-	private GEN_TYPE genType;
-
-	/** The CSV separator (if needed or null). */
-	private String csvSeparator;
-
-	/** The CSV filename (if needed or null). */
-	private String csvFilename;
-
-	/** The task name */
-	private String taskName;
-
-	/**
-	 * Private constructor.
-	 */
-	private Generator() {
-	}
-
-	/**
-	 * Generate synchronization engine skeleton.
-	 *
-	 * @throws NamingException thrown if a directory exception is encountered
-	 */
-	private void launch() throws NamingException {
-		String srcServiceClassName = null;
-		String xmlFilename = null;
-
-		LOGGER.info("Generating bean for class \"{}\" from target directory...", dstClassName);
-
-		if (genType != GEN_TYPE.LDAP2LDAP) {
-			// Generating a JndiSrcService is no longer necessary - use SimpleJndiSrcService instead
-			JdbcSrcServiceObjectGenerator jssoGenerator = new JdbcSrcServiceObjectGenerator();
-			srcServiceClassName = jssoGenerator.run(dstClassName, destination);
-			xmlFilename = jssoGenerator.getMyXMLFileName();
-			SqlMapXmlFileGenerator.run(xmlFilename, destination);
-		}
-
-		if (genType == GEN_TYPE.CSV2LDAP) {
-			Csv2SqlObjectGenerator.run(dstClassName, destination, csvFilename, csvSeparator);
-		}
-
-		LOGGER.info("Writing properties file...");
-		PropertiesGenerator.run(taskName, destination, genType, srcServiceClassName);
-	}
-
-	/**
-	 * DOCUMENT ME!
-	 *
-	 * @param args command line parameters
-	 *
-	 * @throws NamingException DOCUMENT ME!
-	 */
-	public static void main(final String[] args) throws NamingException {
-		Generator instance = new Generator();
-
-		if (instance.parseArgs(args) == 0) {
-			instance.launch();
-		}
-	}
-
-	/**
-	 * Print the general usage through Ant.
-	 * @param options the options
-	 */
-	private static void printHelp(final Options options) {
-		System.err.println("Usage:");
-		String cmn = "\tant -Dgenerator.parameters=\"-dir ../../src/impl/java -doc 'localObjectClass' -name MyTask ";
-		System.err.println(cmn + "-db2ldap\" lsc::generator\n");
-		System.err.println(cmn + "-csv2ldap " + "-csvf ../../sample/csvtosql/sample.csv " + "-csvsep ';'\" lsc::generator\n");
-		System.err.println(cmn + "-ldap2ldap -soc 'sourceObjectClass'\" lsc::generator\n");
-	}
-
-	/**
-	 * Manage command line options.
-	 * @param args command line
-	 * @return the status code (0: OK, >=1 : failed)
-	 */
-	private int parseArgs(final String[] args) {
-		Options options = new Options();
-
-		options.addOption("soc", "sourceOcName", true,
-						"Specify the source object class name");
-		options.addOption("doc", "destOcName", true,
-						"Specify the destination object class name");
-		options.addOption("dir", "directory", true,
-						"Specify the destination directory");
-		options.addOption("csvsep", "csvseparator", true,
-						"Specify the csv separator");
-		options.addOption("csvf", "csvfilename", true,
-						"Specify the csv filename");
-		options.addOption("name", "taskName", true, "Specify the task name");
-		options.addOption("f", "cfg", true, "Specify configuration directory");
-
-		OptionGroup genTypeOption = new OptionGroup();
-		genTypeOption.setRequired(true);
-		genTypeOption.addOption(new Option("ldap2ldap", "ld", false,
-						"Generate a LDAP to LDAP engine skeleton"));
-		genTypeOption.addOption(new Option("db2ldap", "db", false,
-						"Generate a database to LDAP engine skeleton"));
-		genTypeOption.addOption(new Option("csv2ldap", "csv", false,
-						"Generate a CSV to LDAP engine skeleton"));
-		options.addOptionGroup(genTypeOption);
-
-		CommandLineParser parser = new GnuParser();
-
-		try {
-			CommandLine cmdLine = parser.parse(options, args);
-
-			if (cmdLine.getOptions().length > 0) {
-				if (cmdLine.hasOption("soc")) {
-					srcClassName = cmdLine.getOptionValue("soc");
-				}
-
-				if (cmdLine.hasOption("doc")) {
-					dstClassName = cmdLine.getOptionValue("doc");
-				}
-
-				if (cmdLine.hasOption("dir")) {
-					destination = cmdLine.getOptionValue("dir");
-				}
-
-				if (cmdLine.hasOption("csvsep")) {
-					csvSeparator = cmdLine.getOptionValue("csvsep");
-					if (csvSeparator.length() == CSV_SEPARATOR_ROUNDED) {
-						csvSeparator = "" + csvSeparator.charAt(1);
-					}
-				}
-
-				if (cmdLine.hasOption("csvf")) {
-					csvFilename = cmdLine.getOptionValue("csvf");
-				}
-
-				if (cmdLine.hasOption("name")) {
-					taskName = cmdLine.getOptionValue("name");
-				}
-
-				if (cmdLine.hasOption("f")) {
-					// if a configuration directory was set on command line, use it to set up Configuration
-					Configuration.setUp(cmdLine.getOptionValue("f"));
-				}
-
-				if (cmdLine.hasOption("ldap2ldap")) {
-					genType = GEN_TYPE.LDAP2LDAP;
-				} else if (cmdLine.hasOption("db2ldap")) {
-					genType = GEN_TYPE.DATABASE2LDAP;
-				} else if (cmdLine.hasOption("csv2ldap")) {
-					genType = GEN_TYPE.CSV2LDAP;
-				} else {
-					genType = GEN_TYPE.UNKNOWN;
-				}
-
-				if ((dstClassName == null) || (genType == GEN_TYPE.UNKNOWN) || ((genType == GEN_TYPE.LDAP2LDAP) && (srcClassName == null))) {
-					printHelp(options);
-
-					return 1;
-				}
-
-				if ((genType == GEN_TYPE.CSV2LDAP) && ((csvSeparator == null) || (csvFilename == null))) {
-					printHelp(options);
-
-					return 1;
-				}
-			} else {
-				printHelp(options);
-
-				return 1;
-			}
-		} catch (MissingOptionException e) {
-			printHelp(options);
-
-			return 1;
-		} catch (ParseException e) {
-			LOGGER.error("Unable to parse options : {} ({})", args, e);
-			printHelp(options);
-
-			return 1;
-		}
-
-		return 0;
-	}
-
-	/** This is the list of the available generation type. */
-	public static enum GEN_TYPE {
-
-		/** CSV to Database to directory generation type. */
-		CSV2LDAP,
-		/** Directory to directory generation type. */
-		LDAP2LDAP,
-		/** Database to directory generation type. */
-		DATABASE2LDAP,
-		/** Unknown. */
-		UNKNOWN;
-	}
-}

Deleted: lsc/trunk/src/main/java/org/lsc/beans/BeanGenerator.java
===================================================================
--- lsc/trunk/src/main/java/org/lsc/beans/BeanGenerator.java	2009-11-29 18:14:44 UTC (rev 483)
+++ lsc/trunk/src/main/java/org/lsc/beans/BeanGenerator.java	2009-11-29 18:25:47 UTC (rev 484)
@@ -1,314 +0,0 @@
-/*
- ****************************************************************************
- * Ldap Synchronization Connector provides tools to synchronize
- * electronic identities from a list of data sources including
- * any database with a JDBC connector, another LDAP directory,
- * flat files...
- *
- *                  ==LICENSE NOTICE==
- * 
- * Copyright (c) 2008, LSC Project 
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
-
- *    * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *     * Neither the name of the LSC Project nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *                  ==LICENSE NOTICE==
- *
- *               (c) 2008 - 2009 LSC Project
- *         Sebastien Bahloul <seb at lsc-project.org>
- *         Thomas Chemineau <thomas at lsc-project.org>
- *         Jonathan Clarke <jon at lsc-project.org>
- *         Remy-Christophe Schermesser <rcs at lsc-project.org>
- ****************************************************************************
- */
-package org.lsc.beans;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.naming.NamingException;
-
-import org.lsc.AbstractGenerator;
-import org.lsc.jndi.parser.LdapAttributeType;
-import org.lsc.jndi.parser.LdapObjectClass;
-
-/**
- * In order to get the right stuff for synchronization from the enhanced schema
- * this class is fine to generate the corresponding bean. Then this bean have to
- * be complete.
- * 
- * @author Sebastien Bahloul &lt;seb at lsc-project.org&gt;
- */
-public class BeanGenerator extends AbstractGenerator {
-
-    /** This is the bean related class name. */
-    private String initialName;
-
-    /** This it the mono valued attributes in list bean related class name. */
-    private List<String> monoAttrs;
-
-    /** This is the multi valued attributes list in bean related class name. */
-    private List<String> multiAttrs;
-
-    /**
-     * Generate bean file.
-     * 
-     * @param className
-     *                the classname related generating operation
-     * @return the generation status
-     * @throws NamingException
-     *                 thrown if an directory exception is encountered while
-     *                 generating the new bean
-     */
-    protected final boolean generate(final String className)
-    throws NamingException {
-
-        if (!(getOcs() != null && getOcs().size() > 0 
-                && getAttrs() != null && getAttrs()
-                .size() > 0)) {
-            LOGGER.error("Generator have to be initialized");
-            return false;
-        }
-
-        // Could loop on this method to do batch generation
-
-        initialName = className;
-        setClassName(className + "Bean");
-        setPackageName(getGenericPackageName());
-
-        // Get ldap object class of corresponding new bean
-
-        Map<String, LdapAttributeType> ats = 
-            new HashMap<String, LdapAttributeType>();
-        Iterator<String> atIter = getAttrs().iterator();
-        while (atIter.hasNext()) {
-            String atStr = atIter.next();
-            LdapAttributeType lat = LdapAttributeType.parse(atStr);
-            if (lat != null) {
-                ats.put(lat.getName(), lat);
-            }
-        }
-
-        LdapObjectClass myLoc = null;
-        Iterator<String> ocIter = getOcs().iterator();
-        while (ocIter.hasNext() && myLoc == null) {
-            String ocStr = ocIter.next();
-            LdapObjectClass loc = LdapObjectClass.parse(ocStr, ats);
-            if (loc != null
-                    && loc.getName().compareToIgnoreCase(initialName) == 0) {
-                myLoc = loc;
-            }
-        }
-
-        // Try to generate bean class file
-
-        if (myLoc != null) {
-            this.monoAttrs = myLoc.getMonoAttrs();
-            this.multiAttrs = myLoc.getMultiAttrs();
-            if (this.writeContent(generateContent())) {
-                LOGGER.info("Bean generation successed for {}", this.getFileName());
-                return true;
-            }
-        } else {
-            LOGGER.error("Bean generation failed : LDAP objectClass ({}) could not be found in LDAP directory.",
-                    this.initialName);
-        }
-
-        return false;
-    }
-
-    /**
-     * Return a generic package name.
-     * 
-     * @return A generic package name
-     */
-    protected final String getGenericPackageName() {
-        return this.getClass().getPackage().getName();
-    }
-
-    /**
-     * Generate java content.
-     * 
-     * @return Content within string representation.
-     */
-    protected final String generateContent() {
-
-        String beanClassName = super.getClassName();
-        String initialClassName = this.initialName;
-        String content = "";
-
-        content += "/*\n * Generated - please do not edit manually\n */\n";
-        content += "package " + this.getPackageName() + ";\n\n";
-        content += "import java.lang.reflect.InvocationTargetException;\n"
-            + "import java.lang.reflect.Method;\n"
-            + "import java.util.HashMap;\n";
-
-        // if (multiAttrs.size() > 0) {
-        // content += "import java.util.List;\n";
-        // }
-
-        // + "import org.lsc.Configuration;\n"
-        content += "import javax.naming.NamingException;\n\n"
-            + "import org.lsc.jndi.JndiModifications;\n"
-            + "import org.lsc.objects." + initialClassName + ";\n"
-            + "import org.lsc.objects.top;\n\n";
-
-        content += "public class " + beanClassName
-        + " extends AbstractBean implements IBean {\n\n";
-
-        content += "	public static " + beanClassName + " getInstance("
-        + "top myclass) throws IllegalArgumentException, "
-        + "IllegalAccessException, InvocationTargetException, "
-        + "NamingException {\n" + wt(2) + beanClassName
-        + " bean = new " + beanClassName + "() ;\n" + wt(2)
-        + "AbstractBean.mapper(" + beanClassName
-        + ".class, bean, myclass);\n" + wt(2)
-        + "bean.generateDn();\n" + wt(2) + "return bean;\n" + wt(1)
-        + "}\n\n";
-
-        content += wt(1) + "public " + beanClassName + "() {\n" + wt(2)
-        + "super();\n" + wt(1) + "}\n\n";
-
-        Iterator<String> monoAttrsIter = monoAttrs.iterator();
-        while (monoAttrsIter.hasNext()) {
-            String attribute = monoAttrsIter.next();
-            String attributeName = attribute.substring(0, 1).toUpperCase()
-            + attribute.substring(1);
-
-            content += "    //public static void map"
-                + attributeName
-                + "("
-                + initialClassName
-                + " soc, IBean doc, String value) throws NamingException {\n"
-                + wt(2)
-                + "// Do nothing because it is generated through other map "
-                + "methods !\n"
-                + wt(2)
-                + "//if (value != null && value.trim().length() > 0) {\n"
-                + wt(2) + "//	mapString(doc, \"" + attribute
-                + "\", Filters.filterString(value));\n" + "		//	generate"
-                + attributeName + "(soc, doc);\n" + "		//}\n" + "	//}\n\n";
-
-            content += "	public static void generate" + attributeName + "("
-            + initialClassName
-            + " soc, IBean doc) throws NamingException {\n"
-            + "		// to be completed\n" + "		//String value = \"\";\n"
-            + "		//Attribute attr = new BasicAttribute(\"" + attribute
-            + "\");\n" + "		//attr.add(value);\n"
-            + "		//doc.setAttribute(attr);\n" + "	}\n\n";
-        }
-
-        Iterator<String> multiAttrsIter = multiAttrs.iterator();
-        while (multiAttrsIter.hasNext()) {
-            String attribute = multiAttrsIter.next();
-            String attributeName = attribute.substring(0, 1).toUpperCase()
-            + attribute.substring(1);
-
-            content += wt(1)
-            + "//public static void map"
-            + attributeName
-            + "("
-            + initialClassName
-            + " soc, IBean doc, List values) throws NamingException {\n"
-            + wt(2)
-            + "// Do nothing because it is generated through other map "
-            + "methods !\n"
-            + "		//if (values != null && values.size() > 0) {\n"
-            + "		//	Vector<String> v = new Vector<String>();\n"
-            + "		//	Iterator valuesIter = values.iterator();\n"
-            + "		//	while (valuesIter.hasNext()) {\n"
-            + "		//		String value = (String) valuesIter.next();\n"
-            + "		//		if (value != null && value.trim().length() > 0) {\n"
-            + "		//			mapString(doc, \"" + attribute
-            + "\", Filters.filterString(value));\n"
-            + "		//			generate"
-            + attributeName + "(soc, doc);\n" + "		//		}\n"
-            + "		//	}\n" + "		//}\n" + "	//}\n\n";
-
-            content += "	//public static void generate" + attributeName + "("
-            + initialClassName
-            + " soc, IBean doc) throws NamingException {\n"
-            + "		// to be completed\n" + "		//String value = \"\";\n"
-            + "		//Attribute attr = new BasicAttribute(\"" + attribute
-            + "\");\n" + "		//attr.add(value);\n"
-            + "		//doc.setAttribute(attr);\n" + "	//}\n\n";
-        }
-
-        content += "	public JndiModifications[] checkDependenciesWith"
-            + initialClassName + "(" + initialClassName
-            + " soc, JndiModifications jm) {\n" + "		// to be completed\n"
-            + "		return new JndiModifications[] {};\n" + "	}\n\n";
-
-        content += wt(1)
-        + "//public void generateDn() throws NamingException {\n"
-        + wt(2)
-        + "//setDistinguishName(\"uid=\" + getAttributeById(\"uid\")."
-        + "get() + \",\" + Configuration.DN_PEOPLE);\n"
-        + wt(2)
-        + "//throw new UnsupportedOperationException(\"Complete this to make"
-        + " it available !\");\n"
-        + wt(1) + "//}\n\n";
-        
-        // close class definition
-        content += "}\n";
-
-        return content;
-    }
-
-    /**
-     * Launch the whole bean generation process.
-     * @param className
-     *                the bean related class name
-     * @param destination
-     *                the destination directory
-     * @param fromSource
-     *                the generated bean is related to source directory (or
-     *                destination)
-     * @return the bean name
-     * @throws NamingException
-     *                 thrown if an directory exception is encountered while
-     *                 generating the new bean
-     */
-    public static final String run(final String className,
-            final String destination, final boolean fromSource)
-    throws NamingException {
-        BeanGenerator beanGenerator = new BeanGenerator();
-        beanGenerator.init(fromSource);
-        beanGenerator.setDestination(destination);
-        beanGenerator.generate(className);
-        return beanGenerator.getPackageName() + "."
-        + beanGenerator.getClassName();
-    }
-
-    /**
-     * Return a generic file name for latest generated file.
-     * @return A java generic file name.
-     */
-    public final String getFileName() {
-        return getStandardFileName();
-    }
-}

Deleted: lsc/trunk/src/main/java/org/lsc/jndi/JndiDstObjectGenerator.java
===================================================================
--- lsc/trunk/src/main/java/org/lsc/jndi/JndiDstObjectGenerator.java	2009-11-29 18:14:44 UTC (rev 483)
+++ lsc/trunk/src/main/java/org/lsc/jndi/JndiDstObjectGenerator.java	2009-11-29 18:25:47 UTC (rev 484)
@@ -1,228 +0,0 @@
-/*
- ****************************************************************************
- * Ldap Synchronization Connector provides tools to synchronize
- * electronic identities from a list of data sources including
- * any database with a JDBC connector, another LDAP directory,
- * flat files...
- *
- *                  ==LICENSE NOTICE==
- * 
- * Copyright (c) 2008, LSC Project 
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
-
- *    * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *     * Neither the name of the LSC Project nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *                  ==LICENSE NOTICE==
- *
- *               (c) 2008 - 2009 LSC Project
- *         Sebastien Bahloul <seb at lsc-project.org>
- *         Thomas Chemineau <thomas at lsc-project.org>
- *         Jonathan Clarke <jon at lsc-project.org>
- *         Remy-Christophe Schermesser <rcs at lsc-project.org>
- ****************************************************************************
- */
-package org.lsc.jndi;
-
-import org.lsc.AbstractGenerator;
-import org.lsc.jndi.parser.LdapAttributeType;
-import org.lsc.jndi.parser.LdapObjectClass;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.naming.NamingException;
-
-
-/**
- * In order to get the right stuff for synchronization from the enhanced
- * schema this class is fine to generate the corresponding JNDI source
- * object. Then this object have to be complete.
- *
- * @author Thomas Chemineau &lt;tchemineau at linagora.com&gt;
- */
-public class JndiDstObjectGenerator extends AbstractGenerator {
-    /** This is the bean related class name. */
-    private String initialName;
-
-    /**
-     * Generate bean file.
-     *
-     * @param className the classname related generating operation
-     *
-     * @return the generation status
-     *
-     * @throws NamingException thrown if an directory exception is encountered
-     *         while generating the new bean
-     */
-    public final boolean generate(final String className)
-                           throws NamingException {
-        if (!((getOcs() != null) && (getOcs().size() > 0)
-                && (getAttrs() != null) && (getAttrs().size() > 0))) {
-            LOGGER.error("Generator have to be initialized");
-
-            return false;
-        }
-
-        // Could loop on this method to do batch generation
-        this.initialName = className;
-        setClassName(className.substring(0, 1).toUpperCase()
-                     + className.substring(1) + "JndiService");
-        setPackageName(getGenericPackageName());
-
-        // Get ldap object class of corresponding new bean
-        Map<String, LdapAttributeType> ats = 
-            new HashMap<String, LdapAttributeType>();
-        Iterator<String> atIter = getAttrs().iterator();
-
-        while (atIter.hasNext()) {
-            String atStr = (String) atIter.next();
-            LdapAttributeType lat = LdapAttributeType.parse(atStr);
-
-            if (lat != null) {
-                ats.put(lat.getName(), lat);
-            }
-        }
-
-        LdapObjectClass myLoc = null;
-        Iterator<String> ocIter = getOcs().iterator();
-
-        while (ocIter.hasNext() && (myLoc == null)) {
-            String ocStr = ocIter.next();
-            LdapObjectClass loc = LdapObjectClass.parse(ocStr, ats);
-
-            if ((loc != null) && (loc.getName().
-        	    compareToIgnoreCase(this.initialName) == 0)) {
-                myLoc = loc;
-            }
-        }
-
-        // Try to generate bean class file
-        if (myLoc != null) {
-            String content = generateContent();
-
-            if (writeContent(content)) {
-                LOGGER.info("JndiObject generation successed for {}", this.getFileName());
-                return true;
-            }
-        } else {
-            LOGGER.error("JndiObject generation failed : LDAP objectClass ({}) could not be found in LDAP directory.",
-										this.initialName);
-        }
-
-        return false;
-    }
-
-    /**
-     * Return a generic package name.
-     *
-     * @return A generic package name
-     */
-    public final String getGenericPackageName() {
-        return this.getClass().getPackage().getName();
-    }
-
-    /**
-     * Generate java content.
-     *
-     * @return Content within string representation.
-     */
-    protected final String generateContent() {
-        String beanClassName = this.initialName + "Bean";
-        String jndiClassName = super.getClassName();
-        String content = "";
-
-        content += "/*\n * Generated - please do not edit manually\n */\n";
-        content += ("package " + this.getPackageName() + ";\n\n");
-        content += ("import java.util.Iterator;\n\n"
-                   + "import javax.naming.NamingException;\n\n"
-                   + "import javax.naming.directory.SearchControls;\n"
-                   + "import org.lsc.Configuration;\n"
-                   + "import org.lsc.beans.AbstractBean;\n"
-                   + "import org.lsc.beans." + beanClassName
-                   + ";\n\n");
-        // + "import org.lsc.objects.top;\n\n";
-        content += ("public class " + jndiClassName
-                   + " implements IJndiDstService {\n\n");
-        content += ("	public AbstractBean getBean(String id) throws "
-                   + "NamingException {\n"
-                   + "		//@TODO: Please refactor to find the correct "
-                   + "entry\n\t\t//return (" + beanClassName + ") "
-                   + beanClassName
-                   + ".getInstance(JndiServices.getInstance().getEntry("
-                   + "Configuration.DN_PEOPLE, \"uid=\" + id), "
-                   + "Configuration.DN_PEOPLE, "
-                   + beanClassName + ".class);\n" + wt(2) 
-                   + "return null;\n" + wt(1)
-                   + "}\n\n");
-
-        content += ("	public Iterator<String> getIdsList() throws "
-        	   + "NamingException {\n"
-                   + "		//@TODO: Please refactor to find the "
-                   + "correct entry\n\t\t//return JndiServices.getInstance()"
-                   + ".getAttrList(Configuration.DN_PEOPLE, \"objectClass="
-                   + initialName
-                   + "\", SearchControls.SUBTREE_SCOPE, \"uid\").values()."
-                   + "iterator();\n"
-                   + "		return null;\n" + "	}\n\n");
-
-        content += "}";
-
-        return content;
-    }
-
-    // Static methods
-    /**
-     * Launch the whole bean generation process.
-     *
-     * @param className the bean related class name
-     * @param destination the destination directory
-     *
-     * @return the generated object name or null if failed
-     *
-     * @throws NamingException thrown if an directory exception is encountered
-     *         while generating the new bean
-     */
-    public static String run(final String className, final String destination)
-                      throws NamingException {
-        JndiDstObjectGenerator jndiGenerator = new JndiDstObjectGenerator();
-        jndiGenerator.init(false);
-        jndiGenerator.setDestination(destination);
-
-        if (jndiGenerator.generate(className)) {
-            return jndiGenerator.getClassName();
-        } else {
-            return null;
-        }
-    }
-
-    /**
-     * Return a generic file name for latest generated file.
-     * @return A java generic file name.
-     */
-    public final String getFileName() {
-	return getStandardFileName();
-    }
-}

Deleted: lsc/trunk/src/main/java/org/lsc/jndi/JndiSrcObjectGenerator.java
===================================================================
--- lsc/trunk/src/main/java/org/lsc/jndi/JndiSrcObjectGenerator.java	2009-11-29 18:14:44 UTC (rev 483)
+++ lsc/trunk/src/main/java/org/lsc/jndi/JndiSrcObjectGenerator.java	2009-11-29 18:25:47 UTC (rev 484)
@@ -1,231 +0,0 @@
-/*
- ****************************************************************************
- * Ldap Synchronization Connector provides tools to synchronize
- * electronic identities from a list of data sources including
- * any database with a JDBC connector, another LDAP directory,
- * flat files...
- *
- *                  ==LICENSE NOTICE==
- * 
- * Copyright (c) 2008, LSC Project 
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
-
- *    * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *     * Neither the name of the LSC Project nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *                  ==LICENSE NOTICE==
- *
- *               (c) 2008 - 2009 LSC Project
- *         Sebastien Bahloul <seb at lsc-project.org>
- *         Thomas Chemineau <thomas at lsc-project.org>
- *         Jonathan Clarke <jon at lsc-project.org>
- *         Remy-Christophe Schermesser <rcs at lsc-project.org>
- ****************************************************************************
- */
-package org.lsc.jndi;
-
-import org.lsc.AbstractGenerator;
-import org.lsc.jndi.parser.LdapAttributeType;
-import org.lsc.jndi.parser.LdapObjectClass;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.naming.NamingException;
-
-
-/**
- * In order to get the right stuff for synchronization from the enhanced
- * schema this class is fine to generate the corresponding JNDI source
- * object. Then this object have to be complete.
- *
- * @author Thomas Chemineau &lt;tchemineau at linagora.com&gt;
- */
-public class JndiSrcObjectGenerator extends AbstractGenerator {
-    /** This is the unique static instance. */
-    private static JndiSrcObjectGenerator jndiGenerator = null;
-
-    /** This is the object related jndi source service. */
-    private String initialName;
-
-    // Public methods
-    /**
-     * Generate bean file.
-     *
-     * @param className the classname related generating operation
-     *
-     * @return the generation status
-     *
-     * @throws NamingException thrown if an directory exception is encountered
-     *         while generating the new bean
-     */
-    public final boolean generate(final String className)
-                           throws NamingException {
-        if (!((getOcs() != null) && (getOcs().size() > 0)
-                && (getAttrs() != null) && (getAttrs().size() > 0))) {
-            LOGGER.error("Generator have to be initialized");
-
-            return false;
-        }
-
-        // Could loop on this method to do batch generation
-        this.initialName = className;
-        setClassName(className.substring(0, 1).toUpperCase()
-                     + className.substring(1) + "JndiService");
-        setPackageName(getGenericPackageName());
-
-        // Get ldap object class of corresponding new bean
-        Map<String, LdapAttributeType> ats = 
-            new HashMap<String, LdapAttributeType>();
-        Iterator<String> atIter = getAttrs().iterator();
-
-        while (atIter.hasNext()) {
-            String atStr = (String) atIter.next();
-            LdapAttributeType lat = LdapAttributeType.parse(atStr);
-
-            if (lat != null) {
-                ats.put(lat.getName(), lat);
-            }
-        }
-
-        LdapObjectClass myLoc = null;
-        Iterator<String> ocIter = getOcs().iterator();
-
-        while (ocIter.hasNext() && (myLoc == null)) {
-            String ocStr = ocIter.next();
-            LdapObjectClass loc = LdapObjectClass.parse(ocStr, ats);
-
-            if (loc != null) {
-                if ((loc.getName().compareToIgnoreCase(initialName) == 0)) {
-                    myLoc = loc;
-                }
-            }
-        }
-
-        // Try to generate bean class file
-        if (myLoc != null) {
-            String content = generateContent();
-
-            if (writeContent(content)) {
-                LOGGER.info("JndiObject generation successed for "
-                            + this.getFileName());
-
-                return true;
-            }
-        } else {
-            LOGGER.error("JndiObject generation failed : LDAP objectClass ({})) could not be found in LDAP directory.",
-										this.initialName);
-        }
-
-        return false;
-    }
-
-    /**
-     * Return a generic package name.
-     *
-     * @return A generic package name
-     */
-    public final String getGenericPackageName() {
-        return this.getClass().getPackage().getName();
-    }
-
-    /**
-     * Generate java content.
-     *
-     * @return Content within string representation.
-     */
-    protected final String generateContent() {
-        String beanClassName = this.initialName + "Bean";
-        String jndiClassName = super.getClassName();
-        String content = "";
-
-        content += "/*\n * Generated - please do not edit manually\n */\n";
-        content += ("package " + this.getPackageName() + ";\n\n");
-        content += ("import java.util.Iterator;\n\n"
-                   + "import javax.naming.NamingException;\n\n"
-                   + "import javax.naming.directory.SearchControls;\n"
-                   + "import org.lsc.Configuration;\n"
-                   + "import org.lsc.objects.top;\n\n");
-
-        content += ("public class " + jndiClassName
-                   + " implements IJndiSrcService {\n\n");
-        content += ("" + "	public top getObject(String id) throws "
-                   + "NamingException {\n"
-                   + "		//@TODO: Please refactor to find the correct "
-                   + "entry\n\t\t//return (" + beanClassName + ") "
-                   + beanClassName
-                   + ".getInstance(JndiServices.getInstance().getEntry("
-                   + "Configuration.DN_PEOPLE, \"uid=\" + id), "
-                   + "Configuration.DN_PEOPLE, " + beanClassName
-                   + ".class);\n" + "		return null;\n" + "	}\n\n");
-
-        content += ("	public Iterator<String> getIdsList() throws "
-                   + "NamingException {\n"
-                   + "		//@TODO: Please refactor to find the correct "
-                   + "entry\n\t\t//return JndiServices.getInstance()."
-                   + "getAttrList(Configuration.DN_PEOPLE, \"objectClass="
-                   + initialName
-                   + "\", SearchControls.SUBTREE_SCOPE, \"uid\").values()."
-                   + "iterator();\n" + "		return null;\n" + "	}\n\n");
-
-        content += "}";
-
-        return content;
-    }
-
-    /**
-     * Launch the whole bean generation process.
-     *
-     * @param className the bean related class name
-     * @param destination the destination directory
-     *
-     * @return the generated object name or null if failed
-     *
-     * @throws NamingException thrown if an directory exception is encountered
-     *         while generating the new bean
-     */
-    public static final String run(final String className,
-                                   final String destination)
-                            throws NamingException {
-        if (jndiGenerator == null) {
-            jndiGenerator = new JndiSrcObjectGenerator();
-        }
-
-        jndiGenerator.init(true);
-        jndiGenerator.setDestination(destination);
-
-        jndiGenerator.generate(className);
-        return jndiGenerator.getPackageName() + "."
-               + jndiGenerator.getClassName();
-    }
-
-    /**
-     * Return a generic file name for latest generated file.
-     * @return A java generic file name.
-     */
-    public final String getFileName() {
-	return getStandardFileName();
-    }
-}

Deleted: lsc/trunk/src/main/java/org/lsc/persistence/SqlMapXmlFileGenerator.java
===================================================================
--- lsc/trunk/src/main/java/org/lsc/persistence/SqlMapXmlFileGenerator.java	2009-11-29 18:14:44 UTC (rev 483)
+++ lsc/trunk/src/main/java/org/lsc/persistence/SqlMapXmlFileGenerator.java	2009-11-29 18:25:47 UTC (rev 484)
@@ -1,284 +0,0 @@
-/*
- ****************************************************************************
- * Ldap Synchronization Connector provides tools to synchronize
- * electronic identities from a list of data sources including
- * any database with a JDBC connector, another LDAP directory,
- * flat files...
- *
- *                  ==LICENSE NOTICE==
- * 
- * Copyright (c) 2008, LSC Project 
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
-
- *    * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *     * Neither the name of the LSC Project nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *                  ==LICENSE NOTICE==
- *
- *               (c) 2008 - 2009 LSC Project
- *         Sebastien Bahloul <seb at lsc-project.org>
- *         Thomas Chemineau <thomas at lsc-project.org>
- *         Jonathan Clarke <jon at lsc-project.org>
- *         Remy-Christophe Schermesser <rcs at lsc-project.org>
- ****************************************************************************
- */
-package org.lsc.persistence;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.net.MalformedURLException;
-
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.TransformerFactoryConfigurationError;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.xerces.parsers.DOMParser;
-import org.lsc.AbstractGenerator;
-import org.lsc.Configuration;
-import org.w3c.dom.Attr;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Document;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.xml.sax.SAXException;
-
-/**
- * In order to complete the generation process, the sql-map-config.xml file used
- * by iBatis must contains the new XML file synchronization reference. This
- * class is responsible to add it.
- * 
- * @author Sebastien Bahloul &lt;seb at lsc-project.org&gt;
- */
-public class SqlMapXmlFileGenerator extends AbstractGenerator {
-	private static final Logger LOGGER = LoggerFactory.getLogger(SqlMapXmlFileGenerator.class);
-
-	/**  */
-	private static final String SQL_MAP_CONFIG_FILENAME = "org/lsc/persistence/xml/sql-map-config.xml";
-
-	/** The full filename (with destination prefix if needed). */
-	private String sqlMapConfigFullFilename;
-
-	/** The xml file resource to add to sql Map. */
-	private String xmlFilename;
-
-	/**
-	 * Initialize class parameters.
-	 * 
-	 * @param filename
-	 *                the xml filen resource to add
-	 */
-	protected final void init(final String filename) {
-		xmlFilename = filename;
-	}
-
-	/**
-	 * This method launch the xml map generation.
-	 * 
-	 * @param unused
-	 *                not used
-	 * @return the generation status
-	 */
-	protected final boolean generate(final String unused) {
-		
-		// Test if we have a IBATIS_SQLMAP_CONFIGURATION_FILENAME file in the global config dir.
-		// This test is for backwards compatibility since the IBATIS_SQLMAP_CONFIGURATION_FILENAME
-		// file always used to be in a JAR file. It should be removed in the future.
-		try
-		{
-			File configFile = new File(Configuration.getConfigurationDirectory() + DaoConfig.IBATIS_SQLMAP_CONFIGURATION_FILENAME);
-			if (configFile.exists())
-			{
-				// set sql-map-config.xml file path
-				sqlMapConfigFullFilename = configFile.toURI().toURL().getPath();
-				
-				// adapt the generated .xml file name to be relative to the config dir
-				xmlFilename = xmlFilename.substring(Configuration.getConfigurationDirectory().length());
-			} else {
-				// revert back to old behavior - this should be removed soon!
-				LOGGER.warn("Falling back to old-style configuration files");
-
-				if (getDestination() != null && getDestination().length() > 0) {
-					sqlMapConfigFullFilename = getDestination() + getSeparator()
-					+ SQL_MAP_CONFIG_FILENAME;
-					// Then remove the destination from the filename
-					if(xmlFilename.indexOf(getDestination()) == 0) {
-						xmlFilename = xmlFilename.substring(getDestination().length()+1);
-					}
-				} else {
-					sqlMapConfigFullFilename = SQL_MAP_CONFIG_FILENAME;
-				}
-			}
-		}
-		catch (MalformedURLException e)
-		{
-			throw new ExceptionInInitializerError("Error reading the IBatis SQLMap configuration file");
-		}
-
-		String content = generateContent();
-
-		if (content != null) {
-			return writeContent(content, true);
-		}
-
-		return false;
-	}
-
-	/**
-	 * Generate the file content.
-	 * 
-	 * @return the generated content
-	 */
-	protected final String generateContent() {
-
-		DOMParser parser = new DOMParser();
-
-		// initialize StreamResult with File object to save to file
-		StreamResult result = new StreamResult(new StringWriter());
-
-		try {
-			File sqlMapConfigFile = new File(sqlMapConfigFullFilename);
-			if (!(sqlMapConfigFile.exists())) {
-				throw new RuntimeException(
-						sqlMapConfigFullFilename
-						+ " missing ! Please copy the default file structure before launching generation.");
-			}
-
-			// Setting the external DTD/Xschema location
-			//	    parser.setFeature("http://xml.org/sax/features/validation", false);
-			parser.setFeature(
-					"http://apache.org/xml/features/nonvalidating/load-external-dtd",
-					false);
-
-			// make sure any special characters are encoded in URI format
-			parser.parse(sqlMapConfigFile.toURI().toASCIIString());
-			Document doc = parser.getDocument();
-			// docBuilder.parse();
-
-			// Get the last node
-			Node last = doc.getLastChild();
-
-			// Create a new sqlMap entry
-			Node newSqlMapEntry = doc.createElement("sqlMap");
-
-			// Create the new sqlMap object attributes
-			NamedNodeMap newSqlMapAttributes = newSqlMapEntry.getAttributes();
-
-			// Create a new resource attribute ...
-			Attr url = doc.createAttribute("url");
-			// ... with the xml ibatis description filename as value
-			url.setValue("file://${lsc.config}/" + xmlFilename);
-			// Set the attribute in the new object attributes
-			newSqlMapAttributes.setNamedItem(url);
-			// Append the new node as the new last node
-			try {
-				last.appendChild(newSqlMapEntry);
-			} catch (DOMException e) {
-				LOGGER.error("Please check your xerces version. Consider upgrading to Java 6 or to Xerces 2.0 ! ({})", e.toString());
-				return null;
-			}
-
-			Transformer transformer = TransformerFactory.newInstance()
-			.newTransformer();
-			transformer.setOutputProperty(OutputKeys.INDENT, "yes");
-			transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
-			transformer.setOutputProperty(OutputKeys.METHOD, "xml");
-			transformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, "-//ibatis.apache.org//DTD SQL Map 2.0//EN");
-			transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, "http://ibatis.apache.org/dtd/sql-map-2.dtd");
-			DOMSource source = new DOMSource(doc);
-			transformer.transform(source, result);
-		} catch (SAXException e) {
-			LOGGER.error("Failed to parse XML file : {}", e.toString());
-			LOGGER.debug(e.toString(), e);
-			return null;
-		} catch (IOException e) {
-			LOGGER.error("Failed to read XML file : {}", e.toString());
-			LOGGER.debug(e.toString(), e);
-			return null;
-		} catch (TransformerConfigurationException e) {
-			LOGGER.error("Failed to read XML transformation configuration : {}", e.toString());
-			LOGGER.debug(e.toString(), e);
-			return null;
-		} catch (TransformerFactoryConfigurationError e) {
-			LOGGER.error("Failed to read XML transformation configuration : {}", e.toString());
-			LOGGER.debug(e.toString(), e);
-			return null;
-		} catch (TransformerException e) {
-			LOGGER.error("Failed to transform XML structure : {}", e.toString());
-			LOGGER.debug(e.toString(), e);
-			e.printStackTrace();
-		}
-
-		return result.getWriter().toString();
-	}
-
-	/**
-	 * Default filename getter.
-	 * 
-	 * @return the filename
-	 */
-	@Override
-	public final String getFileName() {
-		return sqlMapConfigFullFilename;
-	}
-
-	/**
-	 * Unused.
-	 * 
-	 * @return the package name - unused
-	 */
-	@Override
-	protected final String getGenericPackageName() {
-		return null;
-	}
-
-	/**
-	 * Run the sql map completion.
-	 * 
-	 * @param xmlDatasourceDescriptionFilename
-	 *                the xml ibatis resource to reference
-	 * @param destination
-	 *                the base location
-	 * @return the file name that has been updated
-	 */
-	public static String run(final String xmlDatasourceDescriptionFilename,
-			final String destination) {
-		SqlMapXmlFileGenerator generator = new SqlMapXmlFileGenerator();
-		generator.setDestination(destination);
-		generator.init(xmlDatasourceDescriptionFilename);
-
-		if (generator.generate(null)) {
-			return generator.getFileName();
-		} else {
-			return null;
-		}
-	}
-}

Deleted: lsc/trunk/src/main/java/org/lsc/service/JdbcSrcServiceObjectGenerator.java
===================================================================
--- lsc/trunk/src/main/java/org/lsc/service/JdbcSrcServiceObjectGenerator.java	2009-11-29 18:14:44 UTC (rev 483)
+++ lsc/trunk/src/main/java/org/lsc/service/JdbcSrcServiceObjectGenerator.java	2009-11-29 18:25:47 UTC (rev 484)
@@ -1,448 +0,0 @@
-/*
- ****************************************************************************
- * Ldap Synchronization Connector provides tools to synchronize
- * electronic identities from a list of data sources including
- * any database with a JDBC connector, another LDAP directory,
- * flat files...
- *
- *                  ==LICENSE NOTICE==
- * 
- * Copyright (c) 2008, LSC Project 
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
-
- *    * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *     * Neither the name of the LSC Project nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *                  ==LICENSE NOTICE==
- *
- *               (c) 2008 - 2009 LSC Project
- *         Sebastien Bahloul <seb at lsc-project.org>
- *         Thomas Chemineau <thomas at lsc-project.org>
- *         Jonathan Clarke <jon at lsc-project.org>
- *         Remy-Christophe Schermesser <rcs at lsc-project.org>
- ****************************************************************************
- */
-package org.lsc.service;
-
-import org.lsc.Configuration;
-import org.lsc.persistence.DaoConfig;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
-
-import javax.naming.NamingException;
-
-import org.lsc.AbstractGenerator;
-import org.lsc.jndi.parser.LdapAttributeType;
-import org.lsc.jndi.parser.LdapObjectClass;
-
-
-/**
- * This class containts the JDBC Source Service generator.  In order to
- * get the right stuff for synchronization from the enhanced schema this
- * class is fine to generate the corresponding JDBC Service. Then this object
- * have to be complete.
- *
- * @author Thomas Chemineau &lt;tchemineau at linagora.com&gt;
- */
-public class JdbcSrcServiceObjectGenerator extends AbstractGenerator {
-    //    /** This is the bean related class name. */
-    //    private String initialName;
-    /** This it the mono valued attributes in list bean related class name. */
-    private List<String> monoAttrs;
-
-    /** This is the multi valued attributes list in bean related class name. */
-    private List<String> multiAttrs;
-
-    /** This is the objectname. */
-    private String objectName;
-
-    /** This is the flat objectname. */
-    private String flatName;
-
-    /** This is the local objectclass representation. */
-    private LdapObjectClass objectClass;
-
-    /**
-     * Generate bean file.
-     *
-     * @param className the related class name
-     *
-     * @return the generation status
-     *
-     * @throws NamingException thrown if an directory exception is encountered
-     *         while generating the new bean
-     */
-    public final boolean generate(final String className)
-                           throws NamingException {
-        setClassName(className);
-
-        if (!((getOcs() != null) && (getOcs().size() > 0)
-                && (getAttrs() != null) && (getAttrs().size() > 0))) {
-            LOGGER.error("Generator have to be initialized");
-
-            return false;
-        }
-
-        objectName = className.substring(0, 1).toUpperCase()
-                     + className.substring(1);
-        flatName = "f" + className.substring(0, 1).toUpperCase()
-                   + className.substring(1);
-
-        setClassName(className.substring(0, 1).toUpperCase()
-                     + className.substring(1) + "JDBCService");
-        setPackageName(getGenericPackageName());
-
-        // Get ldap object class of corresponding new Service bean
-        final Map<String, LdapAttributeType> ats = 
-            new HashMap<String, LdapAttributeType>();
-        final Iterator<String> atIter = getAttrs().iterator();
-
-        while (atIter.hasNext()) {
-            final String atStr = atIter.next();
-            final LdapAttributeType lat = LdapAttributeType.parse(atStr);
-
-            if (lat != null) {
-                ats.put(lat.getName(), lat);
-            }
-        }
-
-        final Iterator<String> ocIter = getOcs().iterator();
-
-        while (ocIter.hasNext() && (objectClass == null)) {
-            final String ocStr = ocIter.next();
-            final LdapObjectClass loc = LdapObjectClass.parse(ocStr, ats);
-
-            if ((loc != null)
-                    && (loc.getName().compareToIgnoreCase(className) == 0)) {
-                objectClass = loc;
-            }
-        }
-
-        // Try to generate files
-        boolean ret = true;
-
-        if (objectClass != null) {
-            this.monoAttrs = objectClass.getMonoAttrs();
-            this.multiAttrs = objectClass.getMultiAttrs();
-
-            // Generate Class content
-            if (!writeContent(generateContent())) {
-                LOGGER.info("JndiObject generation failed for {}", this.getFileName());
-                ret &= false;
-            } else {
-                LOGGER.info("JndiObject generation successed for {}", this.getFileName());
-                ret &= true;
-            }
-
-            // OK -> Generate XML file
-            String myFlatPackage = this.getClass().getPackage().getName();
-            myFlatPackage = myFlatPackage.substring(0,
-        	    myFlatPackage.lastIndexOf(".")) + ".objects.flat";
-
-            final String inheritFrom = myFlatPackage + ".f"
-                                       + objectClass.getInheritFrom()
-                                                    .substring(0, 1)
-                                                    .toUpperCase()
-                                       + objectClass.getInheritFrom()
-                                                    .substring(1);
-            final String myXMLFilename = getMyXMLFileName();
-
-            if (!writeXMLContent(myXMLFilename,
-                             generateAssociatedXMLContent(inheritFrom))) {
-                LOGGER.info("Associated XML file generation failed for {}", myXMLFilename);
-                ret &= false;
-            } else {
-                LOGGER.info("Associated XML file generation successed for {}", myXMLFilename);
-                ret &= true;
-            }
-        } else {
-            LOGGER.error("JndiObject generation failed : LDAP objectClass ({}) could not be found in LDAP directory.",
-										className);
-            ret &= false;
-        }
-
-        return ret;
-    }
-
-    /**
-     * Generate the xml persistence filename according to environment
-     * and destination, if set.
-     *
-     * @return the xml persistence filename
-     */
-    public final String getMyXMLFileName() {
-    	
-		// Test if we have a IBATIS_SQLMAP_CONFIGURATION_FILENAME file in the global config dir.
-		// This test is for backwards compatibility since the IBATIS_SQLMAP_CONFIGURATION_FILENAME
-		// file always used to be in a JAR file. It should be removed in the future.
-		File configFile = new File(Configuration.getConfigurationDirectory() + DaoConfig.IBATIS_SQLMAP_CONFIGURATION_FILENAME);
-		if (configFile.exists())
-		{
-			String xmlFileName = Configuration.getConfigurationDirectory() + DaoConfig.IBATIS_SQLMAP_FILES_DIRNAME + Configuration.getSeparator() + this.objectName + ".xml";
-			return xmlFileName;
-		} else {
-			// revert back to old behavior - this should be removed soon!
-			LOGGER.warn("Falling back to old-style configuration files");
-			
-			String myXMLPackage = this.getClass().getPackage().getName();
-			myXMLPackage = myXMLPackage.substring(0, myXMLPackage.lastIndexOf(".")) + ".persistence.xml";
-			
-			String mainLocation = null;
-			
-			if (getDestination() != null) {
-			    mainLocation = getDestination();
-			} else {
-			    mainLocation = System.getProperty("user.dir") + getSeparator()
-			                   + "src" + getSeparator() + "main" + getSeparator()
-			                   + "java";
-			}
-			
-			return mainLocation + getSeparator()
-			       + myXMLPackage.replaceAll("\\.", getSeparator())
-			       + getSeparator() + this.objectName + ".xml";
-		}
-    }
-
-    /**
-     * Generate java content.
-     *
-     * @return Content within string representation.
-     */
-    protected final String generateContent() {
-        String serviceClassName = super.getClassName();
-        String ctn = "";
-
-        // Content
-        ctn += ("package " + this.getPackageName() + ";\n\n");
-
-        ctn += ("public class " + serviceClassName
-               + " extends AbstractJdbcService {\n\n");
-
-        ctn += ("	@Override\n"
-        	   + "	public String getRequestNameForList() {\n"
-        	   + "		return \"get" + this.objectName + "List\";\n" + "	}\n\n");
-        	   
-        ctn += ("	@Override\n"
-         	   + "	public String getRequestNameForObject() {\n"
-         	   + "		return \"get" + this.objectName + "\";\n" + "	}\n\n");
-         	   
-        ctn += "}";
-
-        return ctn;
-    }
-
-    /**
-     * Generate the XML persistant map file.
-     *
-     * @param inheritFrom Full class name from inherited class.
-     *
-     * @return Content within String representation.
-     */
-    protected final String generateAssociatedXMLContent(final String inheritFrom) {
-        Vector<String> allInheritAttrs = new Vector<String>();
-
-        String xml = "";
-
-        // Init XML document.
-        xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n";
-        xml += "<!DOCTYPE sqlMap";
-        xml += "    PUBLIC \"-//ibatis.apache.org//DTD SQL Map 2.0//EN\"";
-        xml += "    \"http://ibatis.apache.org/dtd/sql-map-2.dtd\">";
-        xml += "\n\n";
-        xml += ("<sqlMap namespace=\"" + getClassName() + "\">\n\n");
-        xml += ("\t<typeAlias alias=\"" + objectName
-               + "\" type=\"org.lsc.beans.SimpleBean\" />\n\n");
-
-        // Fixe resultMap :
-        if ((multiAttrs.size() != 0) || (monoAttrs.size() != 0)) {
-            xml += ("\t<resultMap id=\"" + this.objectName
-                   + "Result\" class=\"" + this.objectName + "\">\n");
-
-            // Get all inherit attributes
-            // Stop when superclass is "Object".
-            String superClass = inheritFrom;
-
-            while ((superClass != null)
-                       && (superClass.substring(superClass.lastIndexOf(".")
-                                                    + 1)
-                                         .compareToIgnoreCase("Object") != 0)) {
-                LOGGER.debug("Get inherited attributes from {}", superClass);
-
-                try {
-                    Class<?> superClassObj = Class.forName(superClass);
-                    Field[] superAttrs = superClassObj.getDeclaredFields();
-
-                    for (int i = 0; i < superAttrs.length; i++) {
-                        String attr = superAttrs[i].getName();
-
-                        if (!allInheritAttrs.contains(attr)
-                                && !attr.equalsIgnoreCase("logger")) {
-                            allInheritAttrs.add(attr);
-                        }
-                    }
-
-                    if(superClassObj.getSuperclass() != null) {
-                    	superClass = superClassObj.getSuperclass().getCanonicalName();
-                    }
-                } catch (Exception e) {
-                    LOGGER.error("Reflective Exception : {}", e.toString());
-										LOGGER.debug(e.toString(), e);
-                    superClass = null;
-                }
-            }
-
-            Iterator<String> monoAttrsIter = monoAttrs.iterator();
-
-            while (monoAttrsIter.hasNext()) {
-                String attribute = monoAttrsIter.next();
-
-                if (!allInheritAttrs.contains(attribute)) {
-                    allInheritAttrs.add(attribute);
-                }
-            }
-
-            Iterator<String> multiAttrsIter = multiAttrs.iterator();
-
-            while (multiAttrsIter.hasNext()) {
-                String attribute = multiAttrsIter.next();
-
-                if (!allInheritAttrs.contains(attribute)) {
-                    allInheritAttrs.add(attribute);
-                }
-            }
-
-            Iterator<String> allInheritAttrsIter = allInheritAttrs.iterator();
-
-            while (allInheritAttrsIter.hasNext()) {
-                String attr = allInheritAttrsIter.next();
-                xml += ("\t\t<result property=\"attribute\" column=\""
-                       + attr + "\"/>\n");
-            }
-
-            xml += "\t</resultMap>\n\n";
-        }
-
-        // Fixe select :
-        xml += ("\t<select id=\"get" + this.objectName + "\" resultMap=\""
-               + this.objectName + "Result\" parameterClass=\"java.util.Map\">\n");
-        xml += "\t\t<!-- FILL IT, BE CAREFULL AT SPECIAL CHARACTER REPRESENTATION -->\n";
-        xml += "\t\tSelect\n";
-
-        Iterator<String> allInheritAttrsIter = allInheritAttrs.iterator();
-
-        while (allInheritAttrsIter.hasNext()) {
-            String attr = allInheritAttrsIter.next();
-            xml += ("\t\t\t" + attr + ",\n");
-        }
-
-        xml += "\t\t\t...\n";
-        xml += "\t\tFROM ...\n\t\t\tWHERE ... = #value#\n\t</select>\n\n";
-        xml += ("\t<select id=\"get" + this.objectName
-               + "List\" resultClass=\"java.util.HashMap\">\n");
-        xml += "\t\t<!-- FILL IT, BE CAREFULL AT SPECIAL CHARACTER REPRESENTATION -->\n";
-        xml += "\t\tSelect ...\n\t\tFROM ...\n\t\t\tWHERE ...\n\t</select>\n\n</sqlMap>";
-
-        return xml;
-    }
-
-    /**
-     * Return a generic package name.
-     *
-     * @return A generic package name.
-     */
-    public final String getGenericPackageName() {
-        return this.getClass().getPackage().getName();
-    }
-
-    /**
-     * Write XML content in a particular file.
-     *
-     * @param fileName XML Filename ;
-     * @param content XML content.
-     *
-     * @return True if the operation successed.
-     */
-    protected final boolean writeXMLContent(final String fileName,
-                                            final String content) {
-        File file = new File(fileName);
-
-        LOGGER.info("Creating file ({}) ...", fileName);
-
-				LOGGER.debug("\n---------------\n{}---------------\n", content);
-
-        try {
-            if (file.exists()) {
-                LOGGER.warn("XML File generation failed: file ({}) already exists.", fileName);
-            } else if (file.createNewFile()) {
-                FileOutputStream os = new FileOutputStream(file);
-                os.write(content.getBytes());
-
-                return true;
-            } else {
-                LOGGER.error("XML File generation failed: file ({}) could not be created (probably a rights issue).",
-												fileName);
-            }
-        } catch (FileNotFoundException fnfe) {
-					LOGGER.error(fnfe.toString());
-					LOGGER.debug(fnfe.toString(), fnfe);
-        } catch (IOException e) {
-					LOGGER.error("{} ({})", e, fileName);
-        }
-
-        return false;
-    }
-
-    /**
-     * Launch the whole bean generation process.
-     * @param className the bean related class name
-     * @param destination the destination directory
-     * @return the generated jdbc source service status
-     * @throws NamingException thrown if an directory exception is encountered
-     *         while generating the new bean
-     */
-    public final String run(final String className, final String destination)
-                      throws NamingException {
-        init(false);
-        setDestination(destination);
-        generate(className);
-        return getPackageName() + "." + getClassName();
-    }
-
-    /**
-     * Return a generic file name for latest generated file.
-     * @return A java generic file name.
-     */
-    public final String getFileName() {
-			return getStandardFileName();
-    }
-}

Modified: lsc/trunk/src/main/java/org/lsc/service/JndiDataSchemaProvider.java
===================================================================
--- lsc/trunk/src/main/java/org/lsc/service/JndiDataSchemaProvider.java	2009-11-29 18:14:44 UTC (rev 483)
+++ lsc/trunk/src/main/java/org/lsc/service/JndiDataSchemaProvider.java	2009-11-29 18:25:47 UTC (rev 484)
@@ -59,7 +59,6 @@
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.lsc.AbstractGenerator;
 import org.lsc.jndi.JndiServices;
 import org.lsc.jndi.parser.LdapAttributeType;
 import org.lsc.jndi.parser.LdapObjectClass;
@@ -72,7 +71,7 @@
 
     /** This is the local logger. */
     public static final Logger LOGGER = 
-        LoggerFactory.getLogger(AbstractGenerator.class);
+        LoggerFactory.getLogger(JndiDataSchemaProvider.class);
 
     /** This is the list of object classes available in the directory. */
     private List<String> objectClasses;

Deleted: lsc/trunk/src/main/java/org/lsc/utils/Csv2SqlObjectGenerator.java
===================================================================
--- lsc/trunk/src/main/java/org/lsc/utils/Csv2SqlObjectGenerator.java	2009-11-29 18:14:44 UTC (rev 483)
+++ lsc/trunk/src/main/java/org/lsc/utils/Csv2SqlObjectGenerator.java	2009-11-29 18:25:47 UTC (rev 484)
@@ -1,279 +0,0 @@
-/*
- ****************************************************************************
- * Ldap Synchronization Connector provides tools to synchronize
- * electronic identities from a list of data sources including
- * any database with a JDBC connector, another LDAP directory,
- * flat files...
- *
- *                  ==LICENSE NOTICE==
- * 
- * Copyright (c) 2008, LSC Project 
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
-
- *    * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *     * Neither the name of the LSC Project nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *                  ==LICENSE NOTICE==
- *
- *               (c) 2008 - 2009 LSC Project
- *         Sebastien Bahloul <seb at lsc-project.org>
- *         Thomas Chemineau <thomas at lsc-project.org>
- *         Jonathan Clarke <jon at lsc-project.org>
- *         Remy-Christophe Schermesser <rcs at lsc-project.org>
- ****************************************************************************
- */
-package org.lsc.utils;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.StringTokenizer;
-
-import javax.naming.NamingException;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.lsc.AbstractGenerator;
-
-
-/**
- * To generate the right skeleton, this class dump the csv2sql
- * configuration file.
- *
- * @author Sebastien Bahloul &lt;seb at lsc-project.org&gt;
- */
-public class Csv2SqlObjectGenerator extends AbstractGenerator {
-    /** This is the maximum first line length read in the CSV file. */
-    private static final int MAX_LINE_LENGTH = 3000;
-
-    private static final Logger LOGGER = LoggerFactory.getLogger(Csv2SqlObjectGenerator.class);
-
-    /** This is the CSV filename. */
-    private String csvFilename;
-
-    /** This is the CSV file separator. */
-    private String csvSeparator;
-
-    /**
-     * Run the whole CSV2SQL generator.
-     *
-     * @param className the classname related generating operation
-     * @param destination the generated file destination directory
-     * @param csvFile the csv filename
-     * @param csvSeparator the csv fields separator
-     *
-     * @throws NamingException thrown if an directory exception is encountered
-     *         while generating the new bean
-     */
-    public static final void run(final String className,
-                                 final String destination,
-                                 final String csvFile,
-                                 final String csvSeparator)
-                          throws NamingException {
-        Csv2SqlObjectGenerator csog = new Csv2SqlObjectGenerator();
-        csog.init(csvFile, csvSeparator);
-        csog.setDestination(destination);
-        csog.generate(className);
-    }
-
-    /**
-     * Initialize the generator fields.
-     *
-     * @param lcsvFile the csv filename
-     * @param lcsvSeparator the csv fields separator
-     */
-    private void init(final String lcsvFile, final String lcsvSeparator) {
-        csvFilename = lcsvFile;
-        csvSeparator = lcsvSeparator;
-        setPackageName(getGenericPackageName());
-    }
-
-    /**
-     * Generate bean file.
-     *
-     * @param className the classname related generating operation
-     *
-     * @return the generation status
-     *
-     * @throws NamingException thrown if an directory exception is encountered
-     *         while generating the new bean
-     */
-    public final boolean generate(final String className)
-                           throws NamingException {
-        InputStream is;
-
-        try {
-            is = new FileInputStream(new File(csvFilename));
-        } catch (FileNotFoundException e) {
-            LOGGER.error(I18n.getMessage(null,
-                             "org.lsc.messages.SYNC_ERROR",
-                             new Object[] { e.getMessage() }), e);
-
-            return false;
-        }
-
-        byte[] bytes = new byte[MAX_LINE_LENGTH];
-
-        try {
-            is.read(bytes);
-        } catch (IOException e) {
-            LOGGER.error(I18n.getMessage(null,
-                             "org.lsc.messages.SYNC_ERROR",
-                             new Object[] { e.getMessage() }), e);
-
-            return false;
-        }
-
-        String[] lines = new String(bytes).split("\n");
-        StringTokenizer sTok = new StringTokenizer(lines[0], csvSeparator);
-
-        if (sTok.countTokens() <= 0) {
-            return false;
-        }
-
-        String[] cols = new String[sTok.countTokens()];
-
-        for (int i = 0; sTok.hasMoreTokens();) {
-            cols[i++] = sTok.nextToken();
-        }
-
-        writeContent(generateXml(className, cols));
-
-        return true;
-    }
-
-    /**
-     * Generate the XML content.
-     *
-     * @param className the related class name
-     * @param cols columns array
-     *
-     * @return the XML generated content
-     */
-    private String generateXml(final String className, final String[] cols) {
-        StringBuffer sb = new StringBuffer();
-        sb.append(getXmlStartStructure());
-
-        for (int i = 0; i < cols.length; i++) {
-            if (cols[i].startsWith("\"") && cols[i].endsWith("\"")) {
-                cols[i] = cols[i].substring(1, cols[i].length() - 1);
-            }
-
-            sb.append("\t\t\t<field name=\"").append(cols[i])
-              .append("\" type=\"VARCHAR\"/>\n");
-        }
-
-        return sb.append(getXmlEndStructure()).toString();
-    }
-
-    /**
-     * Generate the XML start content.
-     *
-     * @return the XML start content
-     */
-    private String getXmlStartStructure() {
-        return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
-               + "<root>\n\t<!-- CONFIGURATOR DATA -->\n"
-               + "\t<descriptor version=\"3\"/>\n"
-               + "\t\t<!-- DEFINE HERE TABLE STRUCTURE -->\n"
-               + "\t\t<structure tablename=\"" + getClassName() + "\">\n";
-    }
-
-    /**
-     * Generate the XML start content.
-     *
-     * @return the XML start content
-     */
-    private String getXmlEndStructure() {
-        String utf8CsvFilename = 
-            csvFilename.substring(csvFilename.lastIndexOf(getSeparator()) + 1,
-                                  csvFilename.lastIndexOf(".")) + "-utf8.csv";
-
-        return "\t\t</structure>\n\n" + "\t\t<!-- WHAT GRAMMAR USE -->\n"
-               + "\t\t<grammar "
-               + "class=\"net.sf.csv2sql.grammars.standard.GrammarFactory\"/>"
-               + "\n\n\t\t<!-- TEMPORARY STORAGE -->\n"
-               + "\t\t<storage class=\"net.sf.csv2sql.storage.Memory\"/>\n\n"
-               + "\t\t<!-- RENDERER CONFIGURATION -->\n"
-               + "\t\t<render "
-               + "class=\"net.sf.csv2sql.renders.SqlInsertRenderer\">\n\n"
-               + "\t\t<param name=\"inputfile\" value=\"" + utf8CsvFilename
-               + "\"/>\n" + "\t\t<param name=\"separator\" value=\""
-               + csvSeparator + "\"/>\n" + "\t\t<!--optional-->\n"
-               + "\t\t<param name=\"trimdata\"           value=\"true\"/>\n"
-               + "\t\t<param name=\"suppressheader\"     value=\"true\"/>\n"
-               + "\t\t<param name=\"removedoublequotes\" value=\"true\"/>\n"
-               + "\t</render>\n\n" + "\t<!-- WRITER CONFIGURATION -->\n"
-               + "\t<output>\n\n" + "\t\t<writerAppender active=\"true\" "
-               + "class=\"net.sf.csv2sql.writers.JdbcWriter\">\n"
-               + "\t\t<param name=\"driver\"   "
-               + "value=\"org.hsqldb.jdbcDriver\"/>\n"
-               + "\t\t<param name=\"url\"      "
-               + "value=\"jdbc:hsqldb:file:target/hsqldb/lsc\"/>\n"
-               + "\t\t<param name=\"username\" " + "value=\"sa\"/>\n"
-               + "\t\t<param name=\"password\" " + "value=\"\"/>\n\n"
-               + "\t\t<!--optional-->\n"
-               + "\t\t<!--if false commit every statement.-->\n"
-               + "\t\t<param name=\"commit\"   value=\"false\"/>\n"
-               + "\t\t<param name=\"commitbatchcount\"   value=\"0\"/>\n"
-               + "\t\t<!-- decomment to select path of "
-               + "jdbcdriver (only if is out of classpath)-->\n"
-               + "\t\t<!-- <param name=\"jdbcjar\"  "
-               + "value=\"sample/myJdbcDriver.jar\"/> -->\n"
-               + "\t</writerAppender>\n\n" + "\t</output>\n" + "</root>\n";
-    }
-
-    /**
-     * Unused.
-     * @return the content
-     */
-    @Override
-    protected final String generateContent() {
-        throw new RuntimeException("Must never be there !");
-    }
-
-    /**
-     * Unused.
-     * @return the generic package name
-     */
-    @Override
-    public final String getGenericPackageName() {
-        return "";
-    }
-
-    /**
-     * Return the Csv2Sql XML filename.
-     * @return the csv2sql "xml" filename
-     */
-    public final String getFileName() {
-        File csvFileObj = new File(csvFilename);
-
-        return csvFileObj.getParent() + getSeparator()
-               + csvFileObj.getName()
-                           .substring(0, csvFileObj.getName().lastIndexOf("."))
-               + ".xml";
-    }
-}

Deleted: lsc/trunk/src/main/java/org/lsc/utils/PropertiesGenerator.java
===================================================================
--- lsc/trunk/src/main/java/org/lsc/utils/PropertiesGenerator.java	2009-11-29 18:14:44 UTC (rev 483)
+++ lsc/trunk/src/main/java/org/lsc/utils/PropertiesGenerator.java	2009-11-29 18:25:47 UTC (rev 484)
@@ -1,258 +0,0 @@
-/*
- ****************************************************************************
- * Ldap Synchronization Connector provides tools to synchronize
- * electronic identities from a list of data sources including
- * any database with a JDBC connector, another LDAP directory,
- * flat files...
- *
- *                  ==LICENSE NOTICE==
- * 
- * Copyright (c) 2008, LSC Project 
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
-
- *    * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *     * Neither the name of the LSC Project nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *                  ==LICENSE NOTICE==
- *
- *               (c) 2008 - 2009 LSC Project
- *         Sebastien Bahloul <seb at lsc-project.org>
- *         Thomas Chemineau <thomas at lsc-project.org>
- *         Jonathan Clarke <jon at lsc-project.org>
- *         Remy-Christophe Schermesser <rcs at lsc-project.org>
- ****************************************************************************
- */
-package org.lsc.utils;
-
-import java.util.Properties;
-
-import javax.naming.NamingException;
-
-import org.apache.commons.configuration.ConfigurationException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.lsc.AbstractGenerator;
-import org.lsc.Configuration;
-import org.lsc.Generator;
-
-/**
- * Append properties on lsc.properties file.
- * 
- * @author Sebastien Bahloul &lt;seb at lsc-project.org&gt;
- */
-public class PropertiesGenerator extends AbstractGenerator {
-
-	private static final Logger LOGGER = LoggerFactory.getLogger(PropertiesGenerator.class);
-
-	/** The generator type. */
-	private Generator.GEN_TYPE genType;
-
-	/** This property contains the jdbc source service class name. */
-	private String jdbcSrcServiceClassName;
-
-	/**
-	 * Generate the file.
-	 * 
-	 * @param taskName the task name
-	 * @return the generation status
-	 * @throws NamingException
-	 *                 thrown if an directory exception is encountered while
-	 *                 extending properties
-	 */
-	@Override
-	public final boolean generate(final String taskName) throws NamingException {
-		String prefix = "lsc";
-		Properties props = Configuration.getAsProperties(prefix);
-		props = checkAndAdd(props, "tasks", taskName);
-		props = replace(props, "tasks." + taskName + ".bean", "org.lsc.beans.SimpleBean");
-
-		// Add default DN generation configuration parameter
-		props = replace(props, "tasks." + taskName + ".dn", 
-				"\"uid=\" + srcBean.getAttributeValueById(\"uid\") + \",ou=People\"");
-		
-		switch (genType) {
-			case CSV2LDAP:
-			case DATABASE2LDAP:
-				// the POJO object used in db2ldap sync seems to be used directly as a destination object
-				props = replace(props, "tasks." + taskName + ".type", "db2ldap");
-				props = replace(props, "tasks." + taskName + ".srcService", jdbcSrcServiceClassName);
-				break;
-			case LDAP2LDAP:
-				// the POJO object used in ldap2ldap sync is to store original object from the source directory
-				props = replace(props, "tasks." + taskName + ".type", "ldap2ldap");
-				props = replace(props, "tasks." + taskName + ".srcService",
-						"org.lsc.jndi.SimpleJndiSrcService");
-				props = replaceDefaultSimpleJndiService(props, "tasks." + taskName + ".srcService", taskName);
-				break;
-			default:
-				throw new UnsupportedOperationException("Must never be here !");
-		}
-		props = replace(props, "tasks." + taskName + ".dstService", "org.lsc.jndi.SimpleJndiDstService");
-		props = replaceDefaultSimpleJndiService(props, "tasks." + taskName + ".dstService", taskName);
-		try {
-			Configuration.setProperties(prefix, props);
-		} catch (ConfigurationException e) {
-			LOGGER.error("Unable to save configuration file: {}", e.toString());
-			return false;
-		}
-		return true;
-	}
-
-	/**
-	 * This method initiate all required Jndi properties.
-	 * 
-	 * @param props
-	 *                the properties table
-	 * @param propertyPrefix
-	 *                the property prefix
-	 * @return the updated properties
-	 */
-	private Properties replaceDefaultSimpleJndiService(final Properties props,
-			final String propertyPrefix, final String objectClassName) {
-		Properties localProps = props;
-		localProps = replace(localProps, propertyPrefix + ".baseDn", "ou=People");
-		localProps = replace(localProps, propertyPrefix + ".pivotAttrs", "employeeNumber");
-		localProps = replace(localProps, propertyPrefix + ".filterId", "(&(objectClass=" + objectClassName + ")(employeeNumber={employeeNumber}))");
-		localProps = replace(localProps, propertyPrefix + ".filterAll", "(objectClass=" + objectClassName + ")");
-		localProps = replace(localProps, propertyPrefix + ".attrs", "uid cn sn givenName mail objectClass");
-		return localProps;
-	}
-
-	/**
-	 * Replace the property value in the properties.
-	 * 
-	 * @param props
-	 *                the properties table
-	 * @param property
-	 *                the property name
-	 * @param value
-	 *                the value to set
-	 * @return the updated properties
-	 */
-	private Properties replace(final Properties props, final String property,
-			final String value) {
-		props.setProperty(property, value);
-		return props;
-	}
-
-	/**
-	 * Set the specified value to the attribute, existing or not, in the
-	 * specified table.
-	 * 
-	 * @param props
-	 *                the properties table
-	 * @param property
-	 *                the property name
-	 * @param value
-	 *                the value to set
-	 * @return the updated properties
-	 */
-	private Properties checkAndAdd(final Properties props,
-			final String property, final String value) {
-		String propertyStr = props.getProperty(property);
-		if (propertyStr == null) {
-			propertyStr = value;
-		} else {
-			propertyStr = propertyStr.trim();
-			if (propertyStr.indexOf(value) < 0) {
-				if (propertyStr.length() > 0) {
-					propertyStr += "," + value;
-				} else {
-					propertyStr = value;
-				}
-			}
-		}
-		props.setProperty(property, propertyStr);
-		return props;
-	}
-
-	/**
-	 * Unused.
-	 * @return nothing
-	 */
-	@Override
-	protected final String generateContent() {
-		throw new UnsupportedOperationException();
-	}
-
-	/**
-	 * Unused.
-	 * @return nothing
-	 */
-	@Override
-	public final String getGenericPackageName() {
-		throw new UnsupportedOperationException();
-	}
-
-	/**
-	 * Run the CSV2SQL generator.
-	 * 
-	 * @param taskName
-	 *                the task name
-	 * @param destination
-	 *                the destination directory
-	 * @param genType
-	 *                the Generation type
-	 * @param jdbcSrcServiceClassName
-	 *                the jdbc source service name
-	 * @throws NamingException
-	 *                 thrown if an directory exception is encountered while
-	 *                 generating the new bean
-	 */
-	public static void run(final String taskName, final String destination,
-			final Generator.GEN_TYPE genType, final String jdbcSrcServiceClassName)
-	throws NamingException {
-		PropertiesGenerator pg = new PropertiesGenerator();
-		pg.init(genType, jdbcSrcServiceClassName);
-		pg.setDestination(destination);
-		pg.generate(taskName);
-	}
-
-	/**
-	 * Initialized all required parameters.
-	 * 
-	 * @param lgenType
-	 *                the Generation type
-	 * @param lbeanClassName
-	 *                the bean class name
-	 * @param dstObjectClassName
-	 *                the destination object class name
-	 * @param srcObjectClassName
-	 *                the source object class name or null if there is none
-	 * @param ljdbcSrcServiceClassName
-	 *                the jdbc source service name
-	 */
-	private void init(final Generator.GEN_TYPE lgenType, final String ljdbcSrcServiceClassName) {
-		genType = lgenType;
-		jdbcSrcServiceClassName = ljdbcSrcServiceClassName;
-	}
-
-	/**
-	 * Return a generic file name for latest generated file.
-	 * @return A java generic file name.
-	 */
-	public final String getFileName() {
-		return getStandardFileName();
-	}
-}



More information about the lsc-changes mailing list