[lsc-changes] r514 - lsc/trunk/src/main/java/org/lsc

rschermesser at lsc-project.org rschermesser at lsc-project.org
Mon Nov 30 15:23:39 CET 2009


Author: rschermesser
Date: 2009-11-30 15:23:39 +0100 (Mon, 30 Nov 2009)
New Revision: 514

Modified:
   lsc/trunk/src/main/java/org/lsc/AbstractSynchronize.java
Log:
Change iterators to foreach, add better logging

Modified: lsc/trunk/src/main/java/org/lsc/AbstractSynchronize.java
===================================================================
--- lsc/trunk/src/main/java/org/lsc/AbstractSynchronize.java	2009-11-30 14:23:31 UTC (rev 513)
+++ lsc/trunk/src/main/java/org/lsc/AbstractSynchronize.java	2009-11-30 14:23:39 UTC (rev 514)
@@ -50,6 +50,7 @@
 import java.util.Map;
 import java.util.Map.Entry;
 
+import java.util.Set;
 import javax.naming.CommunicationException;
 import javax.naming.NamingException;
 
@@ -138,9 +139,9 @@
 					final IJndiDstService dstJndiService) {
 
 		// Get list of all entries from the destination
-		Iterator<Entry<String, LscAttributes>> ids = null;
+		Set<Entry<String, LscAttributes>> ids = null;
 		try {
-			ids = dstJndiService.getListPivots().entrySet().iterator();
+			ids = dstJndiService.getListPivots().entrySet();
 		} catch (NamingException e) {
 			LOGGER.error("Error getting list of IDs in the destination for task {}", syncName);
 			LOGGER.debug(e.toString(), e);
@@ -148,7 +149,7 @@
 		}
 
 		// Make sure we have at least one entry to work on
-		if (!ids.hasNext()) {
+		if (ids.isEmpty()) {
 			LOGGER.error("Empty or non existant destination (no IDs found)");
 			return;
 		}
@@ -168,11 +169,9 @@
 		IBean taskBean;
 
 		// Loop on all entries in the destination and delete them if they're not found in the source
-		while (ids.hasNext()) {
+		for(Entry<String, LscAttributes> id: ids) {
 			countAll++;
 
-			Entry<String, LscAttributes> id = ids.next();
-
 			try {
 				try {
 					taskBean = taskBeanClass.newInstance();
@@ -293,9 +292,9 @@
 					final Object customLibrary) {
 
 		// Get list of all entries from the source
-		Iterator<Entry<String, LscAttributes>> ids = null;
+		Set<Entry<String, LscAttributes>> ids = null;
 		try {
-			ids = srcService.getListPivots().entrySet().iterator();
+			ids = srcService.getListPivots().entrySet();
 		} catch (Exception e) {
 			LOGGER.error("Error getting list of IDs in the source for task {}", syncName);
 			LOGGER.debug(e.toString(), e);
@@ -303,7 +302,7 @@
 		}
 
 		// Make sure we have at least one entry to work on
-		if (!ids.hasNext()) {
+		if (ids.isEmpty()) {
 			LOGGER.error("Empty or non existant source (no IDs found)");
 			return;
 		}
@@ -323,10 +322,9 @@
 		Map<String, Object> conditionObjects = null;
 
 		/* Loop on all entries in the source and add or update them in the destination */
-		while (ids.hasNext()) {
+		for(Entry<String, LscAttributes> id: ids) {
 			countAll++;
 
-			Entry<String, LscAttributes> id = ids.next();
 			LOGGER.debug("Synchronizing {} for {}", syncName, id.getValue());
 
 			try {
@@ -575,7 +573,13 @@
 				return false;
 			}
 		} catch (final ParseException e) {
-			LOGGER.error("Unable to parse options : {} ({})", args, e.toString());
+			if(LOGGER.isErrorEnabled()) {
+				StringBuilder sb = new StringBuilder();
+				for(String arg: args) {
+					sb.append(arg).append(" ");
+				}
+				LOGGER.error("Unable to parse options : {}({})", sb.toString(), e.toString());
+			}
 			LOGGER.debug(e.toString(), e);
 			return false;
 		}



More information about the lsc-changes mailing list