[lsc-changes] r282 - in lsc/trunk: . src/main/java/org/lsc src/main/java/org/lsc/beans src/main/java/org/lsc/jndi src/main/java/org/lsc/objects src/main/java/org/lsc/service src/main/java/org/lsc/utils src/test/java/org/lsc src/test/java/org/lsc/beans src/test/java/org/lsc/beans/syncoptions src/test/java/org/lsc/jndi src/test/java/org/lsc/utils/directory

sbahloul at lsc-project.org sbahloul at lsc-project.org
Tue Jul 7 12:45:22 CEST 2009


Author: sbahloul
Date: 2009-07-07 12:45:22 +0200 (Tue, 07 Jul 2009)
New Revision: 282

Added:
   lsc/trunk/src/main/java/org/lsc/beans/SimpleBean.java
   lsc/trunk/src/main/java/org/lsc/service/AttributeTypeHandler.java
   lsc/trunk/src/main/java/org/lsc/service/DataSchemaProvider.java
   lsc/trunk/src/main/java/org/lsc/service/IBatisDataSchemaProvider.java
   lsc/trunk/src/main/java/org/lsc/service/JndiDataSchemaProvider.java
Modified:
   lsc/trunk/pom.xml
   lsc/trunk/src/main/java/org/lsc/AbstractSynchronize.java
   lsc/trunk/src/main/java/org/lsc/SimpleSynchronize.java
   lsc/trunk/src/main/java/org/lsc/beans/AbstractBean.java
   lsc/trunk/src/main/java/org/lsc/jndi/AbstractSimpleJndiService.java
   lsc/trunk/src/main/java/org/lsc/jndi/SimpleJndiSrcService.java
   lsc/trunk/src/main/java/org/lsc/objects/top.java
   lsc/trunk/src/main/java/org/lsc/service/AbstractJdbcService.java
   lsc/trunk/src/main/java/org/lsc/service/ISrcService.java
   lsc/trunk/src/main/java/org/lsc/utils/JScriptEvaluator.java
   lsc/trunk/src/test/java/org/lsc/Ldap2LdapSyncTest.java
   lsc/trunk/src/test/java/org/lsc/beans/personBean.java
   lsc/trunk/src/test/java/org/lsc/beans/syncoptions/PropertiesBasedSyncOptionsTest.java
   lsc/trunk/src/test/java/org/lsc/jndi/ScriptableJndiServicesTest.java
   lsc/trunk/src/test/java/org/lsc/utils/directory/ADTest.java
   lsc/trunk/src/test/java/org/lsc/utils/directory/LDAPTest.java
Log:
First try without POJO generation

Modified: lsc/trunk/pom.xml
===================================================================
--- lsc/trunk/pom.xml	2009-07-01 17:16:44 UTC (rev 281)
+++ lsc/trunk/pom.xml	2009-07-07 10:45:22 UTC (rev 282)
@@ -165,7 +165,7 @@
 				<configuration>
 					<instrumentation>
 						<ignores>
-							<ignore>org.lsc.*Test*</ignore>
+							<ignore>*Test</ignore>
 							<ignore>org.lsc.opends.EmbeddedOpenDS</ignore>
 							<ignore>org.lsc.utils.LdapServer</ignore>
 						</ignores>
@@ -271,21 +271,21 @@
 			<url>http://lsc-project.org/maven</url>
 		</repository>
 	</repositories>
-	<dependencies>
+	<dependencies><!--
 		<dependency>
-			<groupId>com.ibatis</groupId>
-			<artifactId>ibatis2-common</artifactId>
-			<version>2.1.7.597</version>
+			<groupId>org.apache.ibatis</groupId>
+			<artifactId>ibatis-common</artifactId>
+			<version>2.3.4.726</version>
 		</dependency>
 		<dependency>
-			<groupId>com.ibatis</groupId>
-			<artifactId>ibatis2-dao</artifactId>
-			<version>2.1.7.597</version>
+			<groupId>org.apache.ibatis</groupId>
+			<artifactId>ibatis-dao</artifactId>
+			<version>2.3.4.726</version>
 		</dependency>
-		<dependency>
-			<groupId>com.ibatis</groupId>
-			<artifactId>ibatis2-sqlmap</artifactId>
-			<version>2.1.7.597</version>
+		--><dependency>
+			<groupId>org.apache.ibatis</groupId>
+			<artifactId>ibatis-sqlmap</artifactId>
+			<version>2.3.4.726</version>
 		</dependency>
 		<dependency>
 			<groupId>commons-collections</groupId>
@@ -417,10 +417,6 @@
 			</releases>
 		</pluginRepository>
 	</pluginRepositories>
-	<dependencyManagement>
-		<dependencies>
-		</dependencies>
-	</dependencyManagement>
 	<distributionManagement>
 		<repository>
 			<id>lsc-project.org</id>

Modified: lsc/trunk/src/main/java/org/lsc/AbstractSynchronize.java
===================================================================
--- lsc/trunk/src/main/java/org/lsc/AbstractSynchronize.java	2009-07-01 17:16:44 UTC (rev 281)
+++ lsc/trunk/src/main/java/org/lsc/AbstractSynchronize.java	2009-07-07 10:45:22 UTC (rev 282)
@@ -45,8 +45,6 @@
  */
 package org.lsc;
 
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
@@ -54,7 +52,6 @@
 
 import javax.naming.CommunicationException;
 import javax.naming.NamingException;
-import javax.naming.ServiceUnavailableException;
 
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.CommandLineParser;
@@ -71,8 +68,6 @@
 import org.lsc.jndi.JndiModificationType;
 import org.lsc.jndi.JndiModifications;
 import org.lsc.jndi.JndiServices;
-import org.lsc.objects.top;
-import org.lsc.objects.flat.fTop;
 import org.lsc.service.ISrcService;
 import org.lsc.utils.I18n;
 import org.lsc.utils.JScriptEvaluator;
@@ -170,7 +165,8 @@
         int countCompleted = 0;
         
         JndiModifications jm = null;
-        LscObject srcObject = null;
+//        LscObject srcObject = null;
+        AbstractBean bean = null;
         
         /** Hash table to pass objects into JavaScript condition */
         Map<String, Object> conditionObjects = null;
@@ -183,10 +179,10 @@
 
             try {
                 // Search for the corresponding object in the source
-                srcObject = srcService.getObject(id);
+            	bean = srcService.getBean(bean, id);
 
                 // If we didn't find the object in the source, delete it in the destination
-                if (srcObject == null) {
+                if (bean == null) {
                     // Retrieve condition to evaluate before deleting
                     Boolean doDelete = null;
                     String conditionString = syncOptions.getDeleteCondition();
@@ -199,7 +195,7 @@
                     } else {
                         // If condition is based on dstBean, retrieve the full object from destination
 	                    if (conditionString.contains("dstBean")) {
-	                        AbstractBean bean = dstJndiService.getBean(id);
+//	                        AbstractBean bean = dstJndiService.getBean(id);
 
 	                        // Log an error if the bean could not be retrieved! This shouldn't happen.
 	                        if (bean == null) {
@@ -280,15 +276,13 @@
      *                the source service (JDBC or JNDI)
      * @param dstService
      *                the JNDI destination service
-     * @param object
      * @param objectBean
      * @param customLibrary
      */
     protected final void synchronize2Ldap(final String syncName,
             final ISrcService srcService,
             final IJndiDstService dstService,
-            final top object,
-            final Class<? extends AbstractBean> objectBean,
+            final Class<AbstractBean> objectBean,
             final Object customLibrary) {
 
         // Get list of all entries from the source
@@ -313,10 +307,10 @@
         int countCompleted = 0;
 
         JndiModifications jm = null;
-        LscObject srcObject = null;
+//        LscObject srcObject = null;
         ISyncOptions syncOptions = this.getSyncOptions(syncName);
         // store method to obtain source bean
-        Method beanGetInstanceMethod = null;
+//        Method beanGetInstanceMethod = null;
         AbstractBean srcBean = null;
         AbstractBean dstBean = null;
 
@@ -328,34 +322,34 @@
             countAll++;
 
             Entry<String, LscAttributes> id = ids.next();
-            LOGGER.debug("Synchronizing " + object.getClass().getName() + " for " + id.getKey());
+            LOGGER.debug("Synchronizing " + syncName + " for " + id.getKey());
 
             try {
-                srcObject = srcService.getObject(id);
+                srcBean = srcService.getBean(objectBean.newInstance(), id);
 
                 /* Log an error if the source object could not be retrieved! This shouldn't happen. */
-                if(srcObject == null) {
+                if(srcBean == null) {
                     countError++;
                     LOGGER.error("Unable to get object for id=" + id.getKey());
                     continue;
                 }
 
-                // Specific JDBC - transform flat object into a normal object
-                if (fTop.class.isAssignableFrom(srcObject.getClass())) {
-                	top normalObject = object.getClass().newInstance();
-                	normalObject.setUpFromObject((fTop)srcObject);
-                	srcObject = normalObject;
-                }
+//                // Specific JDBC - transform flat object into a normal object
+//                if (fTop.class.isAssignableFrom(srcObject.getClass())) {
+//                	top normalObject = object.getClass().newInstance();
+//                	normalObject.setUpFromObject((fTop)srcObject);
+//                	srcObject = normalObject;
+//                }
 
-                if (beanGetInstanceMethod == null) {
-                    beanGetInstanceMethod = objectBean.getMethod("getInstance", new Class[] { top.class });
-                }
+//                if (beanGetInstanceMethod == null) {
+//                    beanGetInstanceMethod = objectBean.getMethod("getInstance", new Class[] { top.class });
+//                }
 
-                try {
-                    srcBean = (AbstractBean) beanGetInstanceMethod.invoke(null, new Object[] { srcObject });
-                } catch (InvocationTargetException ite) {
-                    throw ite.getCause();
-                }
+//                try {
+//                    srcBean = (AbstractBean) beanGetInstanceMethod.invoke(null, new Object[] { srcObject });
+//                } catch (InvocationTargetException ite) {
+//                    throw ite.getCause();
+//                }
 
                 // Search destination for matching object
                 dstBean = dstService.getBean(id);
@@ -473,7 +467,7 @@
 
         LOGGER.error(I18n.getMessage(null,
                 "org.lsc.messages.SYNC_ERROR", new Object[] {
-                jm.getDistinguishName(), str, "", except }), except);
+                (jm != null ? jm.getDistinguishName() : ""), str, "", except }), except);
 
         if (jm != null) {
             LOGGER.error(jm);

Modified: lsc/trunk/src/main/java/org/lsc/SimpleSynchronize.java
===================================================================
--- lsc/trunk/src/main/java/org/lsc/SimpleSynchronize.java	2009-07-01 17:16:44 UTC (rev 281)
+++ lsc/trunk/src/main/java/org/lsc/SimpleSynchronize.java	2009-07-07 10:45:22 UTC (rev 282)
@@ -55,7 +55,6 @@
 import org.apache.log4j.Logger;
 import org.lsc.beans.AbstractBean;
 import org.lsc.jndi.IJndiDstService;
-import org.lsc.objects.top;
 import org.lsc.service.ISrcService;
 import org.lsc.utils.LSCStructuralLogger;
 
@@ -198,6 +197,12 @@
     }
     
 
+    private void checkTaskOldProperty(String taskName, String propertyName, String message) {
+   		String errorMessage = "Deprecated value specified in task " + taskName + " for " + propertyName + "! Please read upgrade notes ! (" + message + ")";
+   		LOGGER.fatal(errorMessage);
+   		throw new ExceptionInInitializerError(errorMessage);
+    }
+    
     private String getTaskPropertyAndCheckNotNull(String taskName, Properties props, String propertyName) {
     	String value = props.getProperty(TASKS_PROPS_PREFIX + "." + taskName + "." + propertyName);
     	
@@ -233,7 +238,7 @@
 
             // Get all properties
             // TODO : nice error message if a class name is specified but doesn't exist
-            String objectClassName = getTaskPropertyAndCheckNotNull(taskName, lscProperties, OBJECT_PROPS_PREFIX);
+            checkTaskOldProperty(taskName, OBJECT_PROPS_PREFIX, "Please take a look at upgrade notes at http://lsc-project.org/wiki/documentation/upgrade/1.1-1.2");
             String beanClassName = getTaskPropertyAndCheckNotNull(taskName, lscProperties, BEAN_PROPS_PREFIX);
             String srcServiceClass = getTaskPropertyAndCheckNotNull(taskName, lscProperties, SRCSERVICE_PROPS_PREFIX);
             String dstServiceClass = getTaskPropertyAndCheckNotNull(taskName, lscProperties, DSTSERVICE_PROPS_PREFIX);
@@ -258,7 +263,7 @@
                             + prefix + SRCSERVICE_PROPS_PREFIX);
                     
                     Constructor<?> constrSrcJndiService = Class.forName(srcServiceClass).getConstructor(new Class[] { Properties.class, String.class });
-                    srcService = (ISrcService) constrSrcJndiService.newInstance(new Object[] { srcServiceProperties, objectClassName });
+                    srcService = (ISrcService) constrSrcJndiService.newInstance(new Object[] { srcServiceProperties });
 
                     break;
                 case db2ldap:
@@ -275,9 +280,8 @@
                     clean2Ldap(taskName, srcService, dstJndiService);
                     break;
                 case sync:
-                    top taskObject = (top) Class.forName(objectClassName).newInstance();
-                    Class<? extends AbstractBean> taskBean = (Class<? extends AbstractBean>) Class.forName(beanClassName);
-                    synchronize2Ldap(taskName, srcService, dstJndiService, taskObject, taskBean, customLibrary);
+                    Class<AbstractBean> taskBean = (Class<AbstractBean>) Class.forName(beanClassName);
+                    synchronize2Ldap(taskName, srcService, dstJndiService, taskBean, customLibrary);
                     break;
                 default:        
                     //Should not happen

Modified: lsc/trunk/src/main/java/org/lsc/beans/AbstractBean.java
===================================================================
--- lsc/trunk/src/main/java/org/lsc/beans/AbstractBean.java	2009-07-01 17:16:44 UTC (rev 281)
+++ lsc/trunk/src/main/java/org/lsc/beans/AbstractBean.java	2009-07-07 10:45:22 UTC (rev 282)
@@ -47,6 +47,7 @@
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.sql.ResultSetMetaData;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
@@ -64,6 +65,7 @@
 import org.apache.log4j.Logger;
 import org.lsc.Configuration;
 import org.lsc.objects.top;
+import org.lsc.service.DataSchemaProvider;
 import org.lsc.utils.DateUtils;
 
 
@@ -109,6 +111,9 @@
 
     /** The distinguish name. */
     private String distinguishName;
+    
+    /** Data schema related to this bean - must always be set just after initiating the bean */
+    private DataSchemaProvider dataSchemaProvider;
 
     /**
      * The default constructor.
@@ -490,14 +495,17 @@
     }
 
     /**
-     * Set an attribute.
+     * Set an attribute. 
+     * API CHANGE: Do nothing if attribute is empty 
      *
      * @param attr
      *                the attribute to set
      */
     public final void setAttribute(final Attribute attr) {
         // use lower case since attribute names are case-insensitive
-        attrs.put(attr.getID().toLowerCase(), attr);
+    	if(attr != null && attr.size() > 0) {
+            attrs.put(attr.getID().toLowerCase(), attr);
+    	}
     }
 
     /**
@@ -609,4 +617,20 @@
 		}
 	}
 
+	public void setDataSchema(DataSchemaProvider dataSchema) {
+		this.dataSchemaProvider = dataSchema;
+	}
+
+	public DataSchemaProvider getDataSchema() {
+		return dataSchemaProvider;
+	}
+
+	/**
+	 * Manage something there !
+	 * @param metaData
+	 */
+	public static void setMetadata(ResultSetMetaData metaData) {
+		// TODO Auto-generated method stub
+		
+	}
 }

Added: lsc/trunk/src/main/java/org/lsc/beans/SimpleBean.java
===================================================================
--- lsc/trunk/src/main/java/org/lsc/beans/SimpleBean.java	                        (rev 0)
+++ lsc/trunk/src/main/java/org/lsc/beans/SimpleBean.java	2009-07-07 10:45:22 UTC (rev 282)
@@ -0,0 +1,57 @@
+/*
+ ****************************************************************************
+ * 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;
+
+/**
+ * Empty simple bean
+ *
+ * May be override by any subclass if neede
+
+ * @author Sebastien Bahloul &lt;seb at lsc-project.org&gt;
+ */
+public class SimpleBean extends AbstractBean {
+
+}

Modified: lsc/trunk/src/main/java/org/lsc/jndi/AbstractSimpleJndiService.java
===================================================================
--- lsc/trunk/src/main/java/org/lsc/jndi/AbstractSimpleJndiService.java	2009-07-01 17:16:44 UTC (rev 281)
+++ lsc/trunk/src/main/java/org/lsc/jndi/AbstractSimpleJndiService.java	2009-07-07 10:45:22 UTC (rev 282)
@@ -59,6 +59,7 @@
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
+import javax.naming.directory.BasicAttribute;
 import javax.naming.directory.SearchControls;
 import javax.naming.directory.SearchResult;
 
@@ -66,6 +67,7 @@
 import org.lsc.Configuration;
 import org.lsc.LscAttributes;
 import org.lsc.LscObject;
+import org.lsc.beans.AbstractBean;
 
 /**
  * This class is an abstract generic but configurable implementation to get data
@@ -213,6 +215,36 @@
 	}
 
 	/**
+	 * Map the ldap search result into a abstractbean inherited object.
+	 * 
+	 * @param sr the ldap search result
+	 * @param objToFill
+	 *            the original object to fill
+	 * 
+	 * @return the object modified
+	 * 
+	 * @throws NamingException
+	 *             thrown if a directory exception is encountered while
+	 *             switching to the Java POJO
+	 */
+	public final AbstractBean getBeanFromSR(final SearchResult sr,
+			final AbstractBean beanToFill) throws NamingException {
+
+		if (sr == null)
+			return null;
+
+		// get dn
+		beanToFill.setDistinguishName(sr.getNameInNamespace());
+		
+		NamingEnumeration<?> ne = sr.getAttributes().getAll();
+		while (ne.hasMore()) {
+			Attribute attr = (Attribute) ne.next();
+			beanToFill.setAttribute(attr);
+		}
+		return beanToFill;
+	}
+
+	/**
 	 * Get a list of object values from the NamingEnumeration.
 	 * 
 	 * @param ne

Modified: lsc/trunk/src/main/java/org/lsc/jndi/SimpleJndiSrcService.java
===================================================================
--- lsc/trunk/src/main/java/org/lsc/jndi/SimpleJndiSrcService.java	2009-07-01 17:16:44 UTC (rev 281)
+++ lsc/trunk/src/main/java/org/lsc/jndi/SimpleJndiSrcService.java	2009-07-07 10:45:22 UTC (rev 282)
@@ -54,8 +54,7 @@
 
 import org.apache.log4j.Logger;
 import org.lsc.LscAttributes;
-import org.lsc.LscObject;
-import org.lsc.objects.top;
+import org.lsc.beans.AbstractBean;
 import org.lsc.service.ISrcService;
 
 
@@ -73,12 +72,6 @@
 	private static final Logger LOGGER = Logger.getLogger(SimpleJndiSrcService.class);
 
 	/**
-	 * Preceding the object feeding, it will be instantiated from this
-	 * class.
-	 */
-	private Class<top> objectClass;
-
-	/**
 	 * Constructor adapted to the context properties and the bean class name
 	 * to instantiate.
 	 * 
@@ -88,14 +81,8 @@
 	 * and feed up
 	 */
 	@SuppressWarnings("unchecked")
-	public SimpleJndiSrcService(final Properties props, final String objectClassName) {
+	public SimpleJndiSrcService(final Properties props) {
 		super(props);
-
-		try {
-			this.objectClass = (Class<top>) Class.forName(objectClassName);
-		} catch (ClassNotFoundException e) {
-			throw new ExceptionInInitializerError(e);
-		}
 	}
 
 	/**
@@ -109,24 +96,8 @@
 	 * @throws NamingException thrown if an directory exception is encountered
 	 *         while getting the identified bean
 	 */
-	public final LscObject getObject(final Entry<String, LscAttributes> ids) throws NamingException {
-		try {
-		    LscObject topObject = objectClass.newInstance();
-
-			return this.getObjectFromSR(get(ids), topObject);
-		} catch (InstantiationException e) {
-			LOGGER.error("Unable to instanciate simple object "
-					+ objectClass.getName()
-					+ " ! This is probably a programmer's error (" + e
-					+ ")", e);
-		} catch (IllegalAccessException e) {
-			LOGGER.error("Unable to instanciate simple object "
-					+ objectClass.getName()
-					+ " ! This is probably a programmer's error (" + e
-					+ ")", e);
-		}
-
-		return null;
+	public final AbstractBean getBean(AbstractBean bean, final Entry<String, LscAttributes> ids) throws NamingException {
+		return this.getBeanFromSR(get(ids), bean);
 	}
 
 	/**

Modified: lsc/trunk/src/main/java/org/lsc/objects/top.java
===================================================================
--- lsc/trunk/src/main/java/org/lsc/objects/top.java	2009-07-01 17:16:44 UTC (rev 281)
+++ lsc/trunk/src/main/java/org/lsc/objects/top.java	2009-07-07 10:45:22 UTC (rev 282)
@@ -48,7 +48,6 @@
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
-import java.util.Date;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;

Modified: lsc/trunk/src/main/java/org/lsc/service/AbstractJdbcService.java
===================================================================
--- lsc/trunk/src/main/java/org/lsc/service/AbstractJdbcService.java	2009-07-01 17:16:44 UTC (rev 281)
+++ lsc/trunk/src/main/java/org/lsc/service/AbstractJdbcService.java	2009-07-07 10:45:22 UTC (rev 282)
@@ -59,6 +59,7 @@
 import org.apache.log4j.Logger;
 import org.lsc.LscAttributes;
 import org.lsc.LscObject;
+import org.lsc.beans.AbstractBean;
 import org.lsc.persistence.DaoConfig;
 
 import com.ibatis.sqlmap.client.SqlMapClient;
@@ -79,17 +80,23 @@
 	public abstract String getRequestNameForList();
 	
 	public abstract String getRequestNameForObject();
+	
+	private DataSchemaProvider cb;
 
 	public AbstractJdbcService() {
 		sqlMapper = DaoConfig.getSqlMapClient();
 	}
+	
+	public void setCallback(DataSchemaProvider cb) {
+		this.cb = cb;
+	}
 
-	public LscObject getObject(Entry<String, LscAttributes> ids) throws NamingException {
+	public AbstractBean getBean(AbstractBean nonUsed, Entry<String, LscAttributes> ids) throws NamingException {
 		String id = ids.getKey();
 		Map<String,Object> attributeMap = ids.getValue().getAttributes();
-		
 		try {
-			return (LscObject) sqlMapper.queryForObject(getRequestNameForObject(), attributeMap);
+			Object o = sqlMapper.queryForObject(getRequestNameForObject(), attributeMap);
+			return (AbstractBean) o;
 		} catch (SQLException e) {
 			LOGGER.warn("Error while looking for a specific entry with id="
 					+ id + " (" + e + ")", e);

Added: lsc/trunk/src/main/java/org/lsc/service/AttributeTypeHandler.java
===================================================================
--- lsc/trunk/src/main/java/org/lsc/service/AttributeTypeHandler.java	                        (rev 0)
+++ lsc/trunk/src/main/java/org/lsc/service/AttributeTypeHandler.java	2009-07-07 10:45:22 UTC (rev 282)
@@ -0,0 +1,84 @@
+/*
+ ****************************************************************************
+ * 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 java.sql.SQLException;
+
+import javax.naming.directory.Attribute;
+import javax.naming.directory.BasicAttribute;
+
+import org.lsc.beans.AbstractBean;
+
+import com.ibatis.sqlmap.client.extensions.ParameterSetter;
+import com.ibatis.sqlmap.client.extensions.ResultGetter;
+import com.ibatis.sqlmap.client.extensions.TypeHandlerCallback;
+
+/**
+ * This class provides handling of all types to AbstractBean
+ * Must add &lt;typeHandler javaType="abstractBean" callback="org.lsc.service.AbstractBeanTypeHandler"/&gt;
+ * in SqlMap config file
+ * @author Sebastien Bahloul &lt;seb at lsc-project.org&gt;
+ */
+public class AttributeTypeHandler implements TypeHandlerCallback {
+
+	public Object getResult(ResultGetter getter) throws SQLException {
+		if(!getter.wasNull()) {
+			AbstractBean.setMetadata(getter.getResultSet().getMetaData());
+			Attribute attribute = new BasicAttribute(getter.getColumnName(), getter.getObject());
+			return attribute;
+		} else 
+			return null;
+	}
+
+	public void setParameter(ParameterSetter setter, Object parameter)
+			throws SQLException {
+        setter.setObject(parameter);
+	}
+
+	public Object valueOf(String value) {
+		return value;
+	}
+
+}

Added: lsc/trunk/src/main/java/org/lsc/service/DataSchemaProvider.java
===================================================================
--- lsc/trunk/src/main/java/org/lsc/service/DataSchemaProvider.java	                        (rev 0)
+++ lsc/trunk/src/main/java/org/lsc/service/DataSchemaProvider.java	2009-07-07 10:45:22 UTC (rev 282)
@@ -0,0 +1,85 @@
+/*
+ ****************************************************************************
+ * 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 java.util.Collection;
+
+/**
+ * This class represents the data schema, that is a list of element name and their Java types
+ * 
+ * In this class, elements may be either directory attributes or SQL request columns or any
+ * single format data subtype returned by the data source
+ * @author Sebastien Bahloul &lt;seb at lsc-project.org&gt;
+ */
+public interface DataSchemaProvider {
+
+	/**
+	 * Return the list of elements name
+	 * @return the list of elements name
+	 */
+	public Collection<String> getElementsName();
+	
+	/**
+	 * Return the Java type of the specified element
+	 * @param elementName
+	 * @return
+	 */
+	public Class<?> getElementSingleType(String elementName);
+	
+	/**
+	 * Must the abstract bean include a value for the following attributes
+	 * Binded to SINGLE-VALUE directory attributes. Default for SQL columns  
+	 * @return element mandatory character
+	 */
+	public boolean isElementMultivalued(String elementName);
+	
+	/**
+	 * Must the abstract bean include a value for the following attributes
+	 * Binded to mandatory directory attributes or non null SQL columns  
+	 * @return element mandatory character
+	 */
+	public boolean isElementMandatory(String elementName);
+}

Added: lsc/trunk/src/main/java/org/lsc/service/IBatisDataSchemaProvider.java
===================================================================
--- lsc/trunk/src/main/java/org/lsc/service/IBatisDataSchemaProvider.java	                        (rev 0)
+++ lsc/trunk/src/main/java/org/lsc/service/IBatisDataSchemaProvider.java	2009-07-07 10:45:22 UTC (rev 282)
@@ -0,0 +1,104 @@
+/*
+ ****************************************************************************
+ * 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 java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.lsc.AbstractGenerator;
+
+/**
+ * This class provides the data schema by reading the request schema
+ * via iBatis
+ * @author Sebastien Bahloul &lt;seb at lsc-project.org&gt;
+ */
+public class IBatisDataSchemaProvider implements DataSchemaProvider {
+
+	private ResultSetMetaData metadata;
+	
+	private Map<String, String> metadataCache;
+	
+    /** This is the local logger. */
+    public static final Logger LOGGER = 
+        Logger.getLogger(AbstractGenerator.class);
+
+    public IBatisDataSchemaProvider(ResultSetMetaData metadata) {
+    	this.metadata = metadata;
+    	metadataCache = new HashMap<String, String>();
+    	try {
+    		for(int i = 1; i <= metadata.getColumnCount(); i++) {
+    			metadataCache.put(metadata.getColumnLabel(i), metadata.getColumnTypeName(i));
+    		}
+    	} catch (SQLException e) {
+    		
+    	}
+    }
+    
+    
+	public Collection<String> getElementsName() {
+		return metadataCache.keySet();
+	}
+
+	public Class<?> getElementSingleType(String elementName) {
+		return String.class;
+	}
+
+	public boolean isElementMandatory(String elementName) {
+		throw new UnsupportedOperationException();
+	}
+
+	/**
+	 * Never return true, or maybe in a 3D database implementation :)
+	 * @return false 
+	 */
+	public boolean isElementMultivalued(String elementName) {
+		return false;
+	}
+}

Modified: lsc/trunk/src/main/java/org/lsc/service/ISrcService.java
===================================================================
--- lsc/trunk/src/main/java/org/lsc/service/ISrcService.java	2009-07-01 17:16:44 UTC (rev 281)
+++ lsc/trunk/src/main/java/org/lsc/service/ISrcService.java	2009-07-07 10:45:22 UTC (rev 282)
@@ -51,7 +51,7 @@
 import javax.naming.NamingException;
 
 import org.lsc.LscAttributes;
-import org.lsc.LscObject;
+import org.lsc.beans.AbstractBean;
 
 /**
  * @author rschermesser
@@ -60,13 +60,14 @@
 public interface ISrcService {
     /**
      * The simple object getter according to its identifier.
+     * @param bean base object
      * @param obj The data identifier in the directory - must return a unique
 	 *        directory entry
      * @return the object or null if not found
      * @throws May throw a NamingException if the object is not found in the directory,
      * 			or if more than one object would be returned.
      */
-    LscObject getObject(Entry<String, LscAttributes> obj) throws NamingException;
+    AbstractBean getBean(AbstractBean bean, Entry<String, LscAttributes> obj) throws NamingException;
 
     /**
      * Returns a list of all the objects' identifiers.

Added: lsc/trunk/src/main/java/org/lsc/service/JndiDataSchemaProvider.java
===================================================================
--- lsc/trunk/src/main/java/org/lsc/service/JndiDataSchemaProvider.java	                        (rev 0)
+++ lsc/trunk/src/main/java/org/lsc/service/JndiDataSchemaProvider.java	2009-07-07 10:45:22 UTC (rev 282)
@@ -0,0 +1,206 @@
+/*
+ ****************************************************************************
+ * 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 java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.MissingFormatArgumentException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.naming.NamingException;
+
+import org.apache.log4j.Logger;
+import org.lsc.AbstractGenerator;
+import org.lsc.jndi.JndiServices;
+import org.lsc.jndi.parser.LdapAttributeType;
+import org.lsc.jndi.parser.LdapObjectClass;
+
+/**
+ * This class provides the data schema by reading the directory schema
+ * @author Sebastien Bahloul &lt;seb at lsc-project.org&gt;
+ */
+public class JndiDataSchemaProvider implements DataSchemaProvider {
+
+    /** This is the local logger. */
+    public static final Logger LOGGER = 
+        Logger.getLogger(AbstractGenerator.class);
+
+    /** 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;
+    
+    private LdapObjectClass ldapObjectClass;
+    private Map<String, LdapAttributeType> ldapAttributeTypes; 
+
+
+    /**
+     * Initialize the data schema provider by reading the directory schema and 
+     * looking for the specified objectclass name
+     * @param js
+     * @param className
+     * @throws NamingException 
+     */
+    public JndiDataSchemaProvider(JndiServices js, String className) throws NamingException {
+
+        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;
+        }
+
+        objectClasses = filterNames(ocsTemp.values().iterator().next());
+        attributeTypes = filterNames(atsTemp.values().iterator().next());
+
+        ldapAttributeTypes = new HashMap<String, LdapAttributeType>();
+        Iterator<String> atIter = attributeTypes.iterator();
+        while (atIter.hasNext()) {
+            String atStr = atIter.next();
+            LdapAttributeType lat = LdapAttributeType.parse(atStr);
+            if (lat != null) {
+            	ldapAttributeTypes.put(lat.getName(), lat);
+            }
+        }
+
+        
+        Iterator<String> ocIter = objectClasses.iterator();
+        while (ocIter.hasNext() && ldapObjectClass == null) {
+            String ocStr = ocIter.next();
+            LdapObjectClass loc = LdapObjectClass.parse(ocStr, ldapAttributeTypes);
+            if (loc != null
+                    && loc.getName().compareToIgnoreCase(className) == 0) {
+                ldapObjectClass = loc;
+            }
+        }
+
+	}
+	
+    /**
+     * 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: " + name + ". Attributes or object class not generated !!!");
+    		}
+    	}
+    	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;
+		}
+	}
+
+	/**
+	 * List of attributes authorized for this object
+	 * @return the attributes name collection
+	 */
+	public Collection<String> getElementsName() {
+		return ldapAttributeTypes.keySet();
+	}
+
+	/**
+	 * @TODO Refactor to return the good type
+	 */
+	public Class<?> getElementSingleType(String elementName) {
+		return String.class;
+	}
+
+	/**
+	 * Unsupported at this time !
+	 */
+	public boolean isElementMandatory(String elementName) {
+		throw new UnsupportedOperationException();
+	}
+
+	/**
+	 * Return true if the attribute is not marked as SINGLE-VALUE
+	 * @return the attribute multi-valued status
+	 * @throws MissingFormatArgumentException is the attribute is unknown
+	 */
+	public boolean isElementMultivalued(String elementName) {
+		if(!ldapObjectClass.getMonoAttrs().contains(elementName)
+			&& !ldapObjectClass.getMultiAttrs().contains(elementName)) {
+			throw new MissingFormatArgumentException("Unknown attribute: " + elementName);
+		}
+		return ldapObjectClass.getMultiAttrs().contains(elementName);
+	}
+}

Modified: lsc/trunk/src/main/java/org/lsc/utils/JScriptEvaluator.java
===================================================================
--- lsc/trunk/src/main/java/org/lsc/utils/JScriptEvaluator.java	2009-07-01 17:16:44 UTC (rev 281)
+++ lsc/trunk/src/main/java/org/lsc/utils/JScriptEvaluator.java	2009-07-07 10:45:22 UTC (rev 282)
@@ -50,7 +50,6 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Arrays;
 
 import org.lsc.jndi.JndiServices;
 import org.lsc.jndi.ScriptableJndiServices;

Modified: lsc/trunk/src/test/java/org/lsc/Ldap2LdapSyncTest.java
===================================================================
--- lsc/trunk/src/test/java/org/lsc/Ldap2LdapSyncTest.java	2009-07-01 17:16:44 UTC (rev 281)
+++ lsc/trunk/src/test/java/org/lsc/Ldap2LdapSyncTest.java	2009-07-07 10:45:22 UTC (rev 282)
@@ -45,32 +45,27 @@
  */
 package org.lsc;
 
-import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
-import java.util.Properties;
-import java.util.Map.Entry;
 
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.SearchResult;
 
+import junit.framework.TestCase;
+
 import org.lsc.beans.AbstractBean;
 import org.lsc.beans.personBean;
 import org.lsc.jndi.JndiServices;
-import org.lsc.jndi.ScriptableJndiServices;
 import org.lsc.jndi.SimpleJndiSrcService;
-import org.lsc.objects.top;
 import org.lsc.service.ISrcService;
 import org.lsc.utils.I18n;
 import org.lsc.utils.directory.LDAP;
 
-import junit.framework.TestCase;
-
 /**
  * This test case attempts to reproduce a typical ldap2ldap setup via
  * SimpleSynchronize. This relies on settings in lsc.properties from the test
@@ -118,10 +113,8 @@
 		attributeValues.put("sn", "SN0001");
 		ids.put(DN_MODIFY_SRC, new LscAttributes(attributeValues));
 
-		ISrcService srcService = new SimpleJndiSrcService(Configuration.getAsProperties("lsc.tasks." +  TASK_NAME + ".srcService"), "org.lsc.objects.person");
-		LscObject srcObject = srcService.getObject(ids.entrySet().iterator().next());
-		
-		AbstractBean srcBean = personBean.getInstance((top) srcObject);
+		ISrcService srcService = new SimpleJndiSrcService(Configuration.getAsProperties("lsc.tasks." +  TASK_NAME + ".srcService"));
+		AbstractBean srcBean = srcService.getBean(new personBean(), ids.entrySet().iterator().next());
 		String userPassword = srcBean.getAttributeValueById("userPassword");
 		
 		// OpenDS automatically hashes the password using seeded SHA,

Modified: lsc/trunk/src/test/java/org/lsc/beans/personBean.java
===================================================================
--- lsc/trunk/src/test/java/org/lsc/beans/personBean.java	2009-07-01 17:16:44 UTC (rev 281)
+++ lsc/trunk/src/test/java/org/lsc/beans/personBean.java	2009-07-07 10:45:22 UTC (rev 282)
@@ -4,8 +4,7 @@
 package org.lsc.beans;
 
 import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.HashMap;
+
 import javax.naming.NamingException;
 
 import org.lsc.jndi.JndiModifications;

Modified: lsc/trunk/src/test/java/org/lsc/beans/syncoptions/PropertiesBasedSyncOptionsTest.java
===================================================================
--- lsc/trunk/src/test/java/org/lsc/beans/syncoptions/PropertiesBasedSyncOptionsTest.java	2009-07-01 17:16:44 UTC (rev 281)
+++ lsc/trunk/src/test/java/org/lsc/beans/syncoptions/PropertiesBasedSyncOptionsTest.java	2009-07-07 10:45:22 UTC (rev 282)
@@ -50,10 +50,7 @@
 
 import junit.framework.TestCase;
 
-import org.apache.log4j.Logger;
-import org.lsc.jndi.JndiServices;
 import org.lsc.utils.JScriptEvaluator;
-import org.mozilla.javascript.EcmaError;
 
 public class PropertiesBasedSyncOptionsTest extends TestCase {
 

Modified: lsc/trunk/src/test/java/org/lsc/jndi/ScriptableJndiServicesTest.java
===================================================================
--- lsc/trunk/src/test/java/org/lsc/jndi/ScriptableJndiServicesTest.java	2009-07-01 17:16:44 UTC (rev 281)
+++ lsc/trunk/src/test/java/org/lsc/jndi/ScriptableJndiServicesTest.java	2009-07-07 10:45:22 UTC (rev 282)
@@ -49,8 +49,6 @@
 
 import junit.framework.TestCase;
 
-import org.lsc.jndi.ScriptableJndiServices;
-
 public class ScriptableJndiServicesTest extends TestCase {
 
 	public void testValuesOutOfRange() throws NamingException {

Modified: lsc/trunk/src/test/java/org/lsc/utils/directory/ADTest.java
===================================================================
--- lsc/trunk/src/test/java/org/lsc/utils/directory/ADTest.java	2009-07-01 17:16:44 UTC (rev 281)
+++ lsc/trunk/src/test/java/org/lsc/utils/directory/ADTest.java	2009-07-07 10:45:22 UTC (rev 282)
@@ -46,7 +46,6 @@
 package org.lsc.utils.directory;
 
 import java.util.Calendar;
-import java.util.Date;
 
 import junit.framework.TestCase;
 

Modified: lsc/trunk/src/test/java/org/lsc/utils/directory/LDAPTest.java
===================================================================
--- lsc/trunk/src/test/java/org/lsc/utils/directory/LDAPTest.java	2009-07-01 17:16:44 UTC (rev 281)
+++ lsc/trunk/src/test/java/org/lsc/utils/directory/LDAPTest.java	2009-07-07 10:45:22 UTC (rev 282)
@@ -49,12 +49,11 @@
 
 import javax.naming.CommunicationException;
 import javax.naming.NamingException;
-import javax.naming.SizeLimitExceededException;
 
-import org.lsc.utils.JScriptEvaluator;
-
 import junit.framework.TestCase;
 
+import org.lsc.utils.JScriptEvaluator;
+
 /**
  * Test LDAP function library.
  * 



More information about the lsc-changes mailing list