svn commit: r672897 [1/2] - in /ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext: data/ eca/ permission/ synchronization/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r672897 [1/2] - in /ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext: data/ eca/ permission/ synchronization/

doogie-3
Author: doogie
Date: Mon Jun 30 13:16:55 2008
New Revision: 672897

URL: http://svn.apache.org/viewvc?rev=672897&view=rev
Log:
Generics and java1.5 features.

Modified:
    ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java
    ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataServices.java
    ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/DelegatorEcaHandler.java
    ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaAction.java
    ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaCondition.java
    ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaRule.java
    ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaSetField.java
    ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaUtil.java
    ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/permission/EntityPermissionChecker.java
    ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncContext.java
    ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncServices.java

Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java?rev=672897&r1=672896&r2=672897&view=diff
==============================================================================
--- ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java (original)
+++ ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java Mon Jun 30 13:16:55 2008
@@ -22,11 +22,11 @@
 import java.net.MalformedURLException;
 import java.text.NumberFormat;
 import java.util.Iterator;
-import java.util.LinkedList;
 import java.util.List;
-import java.util.ArrayList;
 import java.io.File;
 
+import javolution.util.FastList;
+
 import org.ofbiz.base.container.Container;
 import org.ofbiz.base.container.ContainerConfig;
 import org.ofbiz.base.container.ContainerException;
@@ -51,7 +51,7 @@
     protected String configFile = null;
     protected String readers = null;
     protected String directory = null;
-    protected ArrayList files = new ArrayList();
+    protected List<String> files = FastList.newInstance();
     protected String component = null;
     protected boolean useDummyFks = false;
     protected boolean maintainTxs = false;
@@ -86,8 +86,7 @@
            $ java -jar ofbiz.jar -install -file=/tmp/dataload.xml
         */
         if (args != null) {
-            for (int i = 0; i < args.length; i++) {
-                String argument = args[i];
+            for (String argument: args) {
                 // arguments can prefix w/ a '-'. Just strip them off
                 if (argument.startsWith("-")) {
                     int subIdx = 1;
@@ -179,10 +178,10 @@
         }
 
         // parse the pass in list of readers to use
-        List readerNames = null;
+        List<String> readerNames = null;
         if (this.readers != null && !"none".equalsIgnoreCase(this.readers)) {
             if (this.readers.indexOf(",") == -1) {
-                readerNames = new LinkedList();
+                readerNames = FastList.newInstance();
                 readerNames.add(this.readers);
             } else {
                 readerNames = StringUtil.split(this.readers, ",");
@@ -202,7 +201,7 @@
         }
 
         // get the reader name URLs first
-        List urlList = null;
+        List<URL> urlList = null;
         if (readerNames != null) {
             urlList = EntityDataLoader.getUrlList(helperName, component, readerNames);
         } else if (!"none".equalsIgnoreCase(this.readers)) {
@@ -211,13 +210,12 @@
 
         // need a list if it is empty
         if (urlList == null) {
-            urlList = new ArrayList();
+            urlList = FastList.newInstance();
         }
 
         // add in the defined extra files
-        Iterator it = this.files.iterator();
-        while (it.hasNext()) {
-            URL fileUrl = UtilURL.fromResource((String) it.next());
+        for (String fileName: this.files) {
+            URL fileUrl = UtilURL.fromResource((String) fileName);
             if (fileUrl != null) {
                 urlList.add(fileUrl);
             }
@@ -229,12 +227,12 @@
             if (dir.exists() && dir.isDirectory() && dir.canRead()) {
                 File[] fileArray = dir.listFiles();
                 if (fileArray != null && fileArray.length > 0) {
-                    for (int i = 0; i < fileArray.length; i++) {
-                        if (fileArray[i].getName().toLowerCase().endsWith(".xml")) {
+                    for (File file: fileArray) {
+                        if (file.getName().toLowerCase().endsWith(".xml")) {
                             try {
-                                urlList.add(fileArray[i].toURI().toURL());
+                                urlList.add(file.toURI().toURL());
                             } catch (MalformedURLException e) {
-                                Debug.logError(e, "Unable to load file (" + fileArray[i].getName() + "); not a valid URL.", module);
+                                Debug.logError(e, "Unable to load file (" + file.getName() + "); not a valid URL.", module);
                             }
                         }
                     }
@@ -247,22 +245,18 @@
         changedFormat.setMinimumIntegerDigits(5);
         changedFormat.setGroupingUsed(false);
         
-        List errorMessages = new LinkedList();
-        List infoMessages = new LinkedList();
+        List<Object> errorMessages = FastList.newInstance();
+        List<String> infoMessages = FastList.newInstance();
         int totalRowsChanged = 0;
         if (urlList != null && urlList.size() > 0) {
             Debug.logImportant("=-=-=-=-=-=-= Doing a data load with the following files:", module);
-            Iterator urlIter = urlList.iterator();
-            while (urlIter.hasNext()) {
-                URL dataUrl = (URL) urlIter.next();
+            for (URL dataUrl: urlList) {
                 Debug.logImportant(dataUrl.toExternalForm(), module);
             }
 
             Debug.logImportant("=-=-=-=-=-=-= Starting the data load...", module);
 
-            urlIter = urlList.iterator();
-            while (urlIter.hasNext()) {
-                URL dataUrl = (URL) urlIter.next();
+            for (URL dataUrl: urlList) {
                 try {
                     int rowsChanged = EntityDataLoader.loadData(dataUrl, helperName, delegator, errorMessages, txTimeout, useDummyFks, maintainTxs, tryInserts);
                     totalRowsChanged += rowsChanged;
@@ -277,17 +271,15 @@
 
         if (infoMessages.size() > 0) {
             Debug.logImportant("=-=-=-=-=-=-= Here is a summary of the data load:", module);
-            Iterator infoIter = infoMessages.iterator();
-            while (infoIter.hasNext()){
-              Debug.logImportant((String) infoIter.next(), module);
+            for (String message: infoMessages) {
+              Debug.logImportant(message, module);
             }
         }
         
         if (errorMessages.size() > 0) {
             Debug.logImportant("The following errors occured in the data load:", module);
-            Iterator errIter = errorMessages.iterator();
-            while (errIter.hasNext()){
-              Debug.logImportant((String) errIter.next(), module);
+            for (Object message: errorMessages) {
+              Debug.logImportant(message.toString(), module);
             }
         }
 

Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataServices.java?rev=672897&r1=672896&r2=672897&view=diff
==============================================================================
--- ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataServices.java (original)
+++ ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataServices.java Mon Jun 30 13:16:55 2008
@@ -35,6 +35,8 @@
 import org.ofbiz.base.util.UtilURL;
 import org.ofbiz.base.util.UtilMisc;
 
+import javolution.util.FastList;
+
 import java.util.*;
 import java.io.*;
 import java.net.URI;
@@ -51,11 +53,11 @@
 
     public static final String module = EntityDataServices.class.getName();
 
-    public static Map exportDelimitedToDirectory(DispatchContext dctx, Map context) {
+    public static Map<String, Object> exportDelimitedToDirectory(DispatchContext dctx, Map<String, Object> context) {
         return ServiceUtil.returnError("This service is not implemented yet.");
     }
 
-    public static Map importDelimitedFromDirectory(DispatchContext dctx, Map context) {
+    public static Map<String, Object> importDelimitedFromDirectory(DispatchContext dctx, Map<String, Object> context) {
         LocalDispatcher dispatcher = dctx.getDispatcher();
         Security security = dctx.getSecurity();
 
@@ -90,13 +92,11 @@
         }
 
         // get the file list
-        List files = getFileList(root);
+        List<File> files = getFileList(root);
         if (files != null && files.size() > 0) {
-            Iterator i = files.iterator();
-            while (i.hasNext()) {
-                File file = (File) i.next();
+            for (File file: files) {
                 try {
-                    Map serviceCtx = UtilMisc.toMap("file", file, "delimiter", delimiter, "userLogin", userLogin);
+                    Map<String, Object> serviceCtx = UtilMisc.toMap("file", file, "delimiter", delimiter, "userLogin", userLogin);
                     dispatcher.runSyncIgnore("importDelimitedEntityFile", serviceCtx);
                 } catch (GenericServiceException e) {
                     Debug.logError(e, module);
@@ -109,7 +109,7 @@
         return ServiceUtil.returnSuccess();
     }
 
-    public static Map importDelimitedFile(DispatchContext dctx, Map context) {
+    public static Map<String, Object> importDelimitedFile(DispatchContext dctx, Map<String, Object> context) {
         GenericDelegator delegator = dctx.getDelegator();
         Security security = dctx.getSecurity();
 
@@ -144,13 +144,13 @@
         long runTime = endTime - startTime;
 
         Debug.logInfo("Imported/Updated [" + records + "] from : " + file.getAbsolutePath() + " [" + runTime + "ms]", module);
-        Map result = ServiceUtil.returnSuccess();
-        result.put("records", new Integer(records));
+        Map<String, Object> result = ServiceUtil.returnSuccess();
+        result.put("records", Integer.valueOf(records));
         return result;
     }
 
-    private static List getFileList(File root) {
-        List fileList = new ArrayList();
+    private static List<File> getFileList(File root) {
+        List<File> fileList = FastList.newInstance();
 
         // check for a file list file
         File listFile = new File(root, "FILELIST.txt");
@@ -186,11 +186,10 @@
                 Debug.logInfo("Read file list : " + fileList.size() + " entities.", module);
             }
         } else {
-            File[] files = root.listFiles();
-            for (int i = 0; i < files.length; i++) {
-                String fileName = files[i].getName();
+            for (File file: root.listFiles()) {
+                String fileName = file.getName();
                 if (!fileName.startsWith("_") && fileName.endsWith(".txt")) {
-                    fileList.add(files[i]);
+                    fileList.add(file);
                 }
             }
             Debug.logInfo("No file list found; using directory order : " + fileList.size() + " entities.", module);
@@ -311,21 +310,21 @@
         if (entity == null) {
             return null;
         }
-        List modelFields = entity.getFieldsUnmodifiable();
+        List<ModelField> modelFields = entity.getFieldsUnmodifiable();
         if (modelFields == null) {
             return null;
         }
 
         String[] fieldNames = new String[modelFields.size()];
         for (int i = 0; i < modelFields.size(); i++) {
-            ModelField field = (ModelField) modelFields.get(i);
+            ModelField field = modelFields.get(i);
             fieldNames[i] = field.getName();
         }
 
         return fieldNames;
     }
 
-    public static Map rebuildAllIndexesAndKeys(DispatchContext dctx, Map context) {
+    public static Map<String, Object> rebuildAllIndexesAndKeys(DispatchContext dctx, Map<String, Object> context) {
         GenericDelegator delegator = dctx.getDelegator();
         Security security = dctx.getSecurity();
 
@@ -350,54 +349,35 @@
             Debug.logError(e, errorMessage, module);
             return ServiceUtil.returnError(errorMessage);
         }
-        Set<String> modelEntityNames = new TreeSet(modelEntities.keySet());
-
-        Iterator<String> modelEntityNameIter = null;
 
         // step 1 - remove FK indices
         Debug.logImportant("Removing all foreign key indices", module);
-        modelEntityNameIter = modelEntityNames.iterator();
-        while (modelEntityNameIter.hasNext()) {
-          String modelEntityName = (String) modelEntityNameIter.next();
-          ModelEntity modelEntity = (ModelEntity) modelEntities.get(modelEntityName);
+        for (ModelEntity modelEntity: modelEntities.values()) {
             dbUtil.deleteForeignKeyIndices(modelEntity, messages);
         }
-        modelEntityNameIter = null;
 
         // step 2 - remove FKs
         Debug.logImportant("Removing all foreign keys", module);
-        modelEntityNameIter = modelEntityNames.iterator();
-        while (modelEntityNameIter.hasNext()) {
-          String modelEntityName = (String) modelEntityNameIter.next();
-          ModelEntity modelEntity = (ModelEntity) modelEntities.get(modelEntityName);
+        for (ModelEntity modelEntity: modelEntities.values()) {
             dbUtil.deleteForeignKeys(modelEntity, modelEntities, messages);
         }
-        modelEntityNameIter = null;
 
         // step 3 - remove PKs
         Debug.logImportant("Removing all primary keys", module);
-        modelEntityNameIter = modelEntityNames.iterator();
-        while (modelEntityNameIter.hasNext()) {
-            String modelEntityName = (String) modelEntityNameIter.next();
-            ModelEntity modelEntity = (ModelEntity) modelEntities.get(modelEntityName);
+        for (ModelEntity modelEntity: modelEntities.values()) {
             dbUtil.deletePrimaryKey(modelEntity, messages);
         }
-        modelEntityNameIter = null;
 
         // step 4 - remove declared indices
         Debug.logImportant("Removing all declared indices", module);
-        modelEntityNameIter = modelEntityNames.iterator();
-        while (modelEntityNameIter.hasNext()) {
-            String modelEntityName = (String) modelEntityNameIter.next();
-            ModelEntity modelEntity = (ModelEntity) modelEntities.get(modelEntityName);
+        for (ModelEntity modelEntity: modelEntities.values()) {
             dbUtil.deleteDeclaredIndices(modelEntity, messages);
         }
-        modelEntityNameIter = null;
 
         // step 5 - repair field sizes
         if (fixSizes.booleanValue()) {
             Debug.logImportant("Updating column field size changes", module);
-            List fieldsWrongSize = FastList.newInstance();
+            List<String> fieldsWrongSize = FastList.newInstance();
             dbUtil.checkDb(modelEntities, fieldsWrongSize, messages, true, true, true, true);
             if (fieldsWrongSize.size() > 0) {
                 dbUtil.repairColumnSizeChanges(modelEntities, fieldsWrongSize, messages);
@@ -410,54 +390,38 @@
 
         // step 6 - create PKs
         Debug.logImportant("Creating all primary keys", module);
-        modelEntityNameIter = modelEntityNames.iterator();
-        while (modelEntityNameIter.hasNext()) {
-            String modelEntityName = (String) modelEntityNameIter.next();
-            ModelEntity modelEntity = (ModelEntity) modelEntities.get(modelEntityName);
+        for (ModelEntity modelEntity: modelEntities.values()) {
             dbUtil.createPrimaryKey(modelEntity, messages);
         }
-        modelEntityNameIter = null;
 
         // step 7 - create FK indices
         Debug.logImportant("Creating all foreign key indices", module);
-        modelEntityNameIter = modelEntityNames.iterator();
-        while (modelEntityNameIter.hasNext()) {
-          String modelEntityName = (String) modelEntityNameIter.next();
-          ModelEntity modelEntity = (ModelEntity) modelEntities.get(modelEntityName);
+        for (ModelEntity modelEntity: modelEntities.values()) {
             dbUtil.createForeignKeyIndices(modelEntity, messages);
         }
-        modelEntityNameIter = null;
 
         // step 8 - create FKs
         Debug.logImportant("Creating all foreign keys", module);
-        modelEntityNameIter = modelEntityNames.iterator();
-        while (modelEntityNameIter.hasNext()) {
-          String modelEntityName = (String) modelEntityNameIter.next();
-          ModelEntity modelEntity = (ModelEntity) modelEntities.get(modelEntityName);
+        for (ModelEntity modelEntity: modelEntities.values()) {
             dbUtil.createForeignKeys(modelEntity, modelEntities, messages);
         }
-        modelEntityNameIter = null;
 
         // step 8 - create FKs
         Debug.logImportant("Creating all declared indices", module);
-        modelEntityNameIter = modelEntityNames.iterator();
-        while (modelEntityNameIter.hasNext()) {
-          String modelEntityName = (String) modelEntityNameIter.next();
-          ModelEntity modelEntity = (ModelEntity) modelEntities.get(modelEntityName);
+        for (ModelEntity modelEntity: modelEntities.values()) {
             dbUtil.createDeclaredIndices(modelEntity, messages);
         }
-        modelEntityNameIter = null;
 
         // step 8 - checkdb
         Debug.logImportant("Running DB check with add missing enabled", module);
         dbUtil.checkDb(modelEntities, messages, true);
         
-        Map result = ServiceUtil.returnSuccess();
+        Map<String, Object> result = ServiceUtil.returnSuccess();
         result.put("messages", messages);
         return result;
     }
     
-    public static Map unwrapByteWrappers(DispatchContext dctx, Map context) {
+    public static Map<String, Object> unwrapByteWrappers(DispatchContext dctx, Map<String, Object> context) {
         GenericDelegator delegator = dctx.getDelegator();
         String entityName = (String) context.get("entityName");
         String fieldName = (String) context.get("fieldName");

Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/DelegatorEcaHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/DelegatorEcaHandler.java?rev=672897&r1=672896&r2=672897&view=diff
==============================================================================
--- ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/DelegatorEcaHandler.java (original)
+++ ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/DelegatorEcaHandler.java Mon Jun 30 13:16:55 2008
@@ -18,13 +18,13 @@
  *******************************************************************************/
 package org.ofbiz.entityext.eca;
 
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.TreeSet;
 
 import org.ofbiz.base.util.Debug;
+import static org.ofbiz.base.util.UtilGenerics.checkList;
 import org.ofbiz.entity.GenericDelegator;
 import org.ofbiz.entity.GenericEntity;
 import org.ofbiz.entity.GenericEntityException;
@@ -35,7 +35,7 @@
 /**
  * EntityEcaUtil
  */
-public class DelegatorEcaHandler implements EntityEcaHandler {
+public class DelegatorEcaHandler implements EntityEcaHandler<EntityEcaRule> {
 
     public static final String module = DelegatorEcaHandler.class.getName();
 
@@ -56,13 +56,13 @@
         EntityEcaUtil.getEntityEcaCache(this.entityEcaReaderName);
     }
 
-    public Map getEntityEventMap(String entityName) {
-        Map ecaCache = EntityEcaUtil.getEntityEcaCache(this.entityEcaReaderName);
+    public Map<String, List<EntityEcaRule>> getEntityEventMap(String entityName) {
+        Map<String, Map<String, List<EntityEcaRule>>> ecaCache = EntityEcaUtil.getEntityEcaCache(this.entityEcaReaderName);
         if (ecaCache == null) return null;
-        return (Map) ecaCache.get(entityName);
+        return ecaCache.get(entityName);
     }
 
-    public void evalRules(String currentOperation, Map eventMap, String event, GenericEntity value, boolean isError) throws GenericEntityException {
+    public void evalRules(String currentOperation, Map<String, List<EntityEcaRule>> eventMap, String event, GenericEntity value, boolean isError) throws GenericEntityException {
         // if the eventMap is passed we save a HashMap lookup, but if not that's okay we'll just look it up now
         if (eventMap == null) eventMap = this.getEntityEventMap(value.getEntityName());
         if (eventMap == null || eventMap.size() == 0) {
@@ -70,18 +70,16 @@
             return;
         }
 
-        List rules = (List) eventMap.get(event);
+        List<EntityEcaRule> rules = eventMap.get(event);
         //Debug.logInfo("Handler.evalRules for entity " + value.getEntityName() + ", event " + event + ", num rules=" + (rules == null ? 0 : rules.size()), module);
         
         if (rules == null || rules.size() == 0) {
             return;
         }
         
-        Iterator i = rules.iterator();
-        if (i.hasNext() && Debug.verboseOn()) Debug.logVerbose("Running ECA (" + event + ").", module);
-        Set actionsRun = new TreeSet();
-        while (i.hasNext()) {
-            EntityEcaRule eca = (EntityEcaRule) i.next();
+        if (!rules.isEmpty() && Debug.verboseOn()) Debug.logVerbose("Running ECA (" + event + ").", module);
+        Set<String> actionsRun = new TreeSet<String>();
+        for (EntityEcaRule eca: rules) {
             eca.eval(currentOperation, this.dctx, value, isError, actionsRun);
         }
     }

Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaAction.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaAction.java?rev=672897&r1=672896&r2=672897&view=diff
==============================================================================
--- ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaAction.java (original)
+++ ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaAction.java Mon Jun 30 13:16:55 2008
@@ -64,12 +64,12 @@
         this.valueAttr = action.getAttribute("value-attr");
     }
 
-    public void runAction(DispatchContext dctx, Map context, GenericEntity newValue) throws GenericEntityException {
-        Map actionResult = null;
+    public void runAction(DispatchContext dctx, Map<String, ? extends Object> context, GenericEntity newValue) throws GenericEntityException {
+        Map<String, Object> actionResult = null;
         
         try {
             // pull out context parameters needed for this service.
-            Map actionContext = dctx.getModelService(serviceName).makeValid(context, ModelService.IN_PARAM);
+            Map<String, Object> actionContext = dctx.getModelService(serviceName).makeValid(context, ModelService.IN_PARAM);
             // if value-attr is specified, insert the value object in that attr name
             if (valueAttr != null && valueAttr.length() > 0) {
                 actionContext.put(valueAttr, newValue);

Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaCondition.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaCondition.java?rev=672897&r1=672896&r2=672897&view=diff
==============================================================================
--- ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaCondition.java (original)
+++ ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaCondition.java Mon Jun 30 13:16:55 2008
@@ -19,9 +19,10 @@
 package org.ofbiz.entityext.eca;
 
 import java.util.Iterator;
-import java.util.LinkedList;
 import java.util.List;
 
+import javolution.util.FastList;
+
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.ObjectType;
 import org.ofbiz.entity.GenericEntity;
@@ -83,14 +84,13 @@
         if (Debug.verboseOn()) Debug.logVerbose("Comparing : " + lhsValue + " " + operator + " " + rhsValue, module);
 
         // evaluate the condition & invoke the action(s)
-        List messages = new LinkedList();
+        List<Object> messages = FastList.newInstance();
         Boolean cond = ObjectType.doRealCompare(lhsValue, rhsValue, operator, compareType, format, messages, null, dctx.getClassLoader(), constant);
 
         // if any messages were returned send them out
         if (messages.size() > 0) {
-            Iterator m = messages.iterator();
-            while (m.hasNext()) {
-                Debug.logWarning((String) m.next(), module);
+            for (Object message: messages) {
+                Debug.logWarning((String) message, module);
             }
         }
         if (cond != null) {
@@ -102,12 +102,12 @@
 
     public String toString() {
         StringBuilder buf = new StringBuilder();
-        buf.append("[" + lhsValueName + "]");
-        buf.append("[" + operator + "]");
-        buf.append("[" + rhsValueName + "]");
-        buf.append("[" + constant + "]");
-        buf.append("[" + compareType + "]");
-        buf.append("[" + format + "]");
+        buf.append("[").append(lhsValueName).append("]");
+        buf.append("[").append(operator).append("]");
+        buf.append("[").append(rhsValueName).append("]");
+        buf.append("[").append(constant).append("]");
+        buf.append("[").append(compareType).append("]");
+        buf.append("[").append(format).append("]");
         return buf.toString();
     }
 }

Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaRule.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaRule.java?rev=672897&r1=672896&r2=672897&view=diff
==============================================================================
--- ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaRule.java (original)
+++ ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaRule.java Mon Jun 30 13:16:55 2008
@@ -45,8 +45,8 @@
     protected String operationName = null;
     protected String eventName = null;
     protected boolean runOnError = false;
-    protected List conditions = FastList.newInstance();
-    protected List actionsAndSets = FastList.newInstance();
+    protected List<EntityEcaCondition> conditions = FastList.newInstance();
+    protected List<Object> actionsAndSets = FastList.newInstance();
     protected boolean enabled = true;
 
     protected EntityEcaRule() {}
@@ -57,27 +57,20 @@
         this.eventName = eca.getAttribute("event");
         this.runOnError = "true".equals(eca.getAttribute("run-on-error"));
 
-        List condList = UtilXml.childElementList(eca, "condition");
-        Iterator ci = condList.iterator();
-        while (ci.hasNext()) {
-            conditions.add(new EntityEcaCondition((Element) ci.next(), true));
+        for (Element element: UtilXml.childElementList(eca, "condition")) {
+            conditions.add(new EntityEcaCondition(element, true));
         }
 
-        List condFList = UtilXml.childElementList(eca, "condition-field");
-        Iterator cfi = condFList.iterator();
-        while (cfi.hasNext()) {
-            conditions.add(new EntityEcaCondition((Element) cfi.next(), false));
+        for (Element element: UtilXml.childElementList(eca, "condition-field")) {
+            conditions.add(new EntityEcaCondition(element, false));
         }
 
         if (Debug.verboseOn()) Debug.logVerbose("Conditions: " + conditions, module);
 
-        Set nameSet = FastSet.newInstance();
+        Set<String> nameSet = FastSet.newInstance();
         nameSet.add("set");
         nameSet.add("action");
-        List actionAndSetList = UtilXml.childElementList(eca, nameSet);
-        Iterator si = actionAndSetList.iterator();
-        while (si.hasNext()) {
-            Element actionOrSetElement = (Element) si.next();
+        for (Element actionOrSetElement: UtilXml.childElementList(eca, nameSet)) {
             if ("action".equals(actionOrSetElement.getNodeName())) {
                 this.actionsAndSets.add(new EntityEcaAction(actionOrSetElement));
             } else {
@@ -88,7 +81,7 @@
         if (Debug.verboseOn()) Debug.logVerbose("actions and sets (intermixed): " + actionsAndSets, module);
     }
 
-    public void eval(String currentOperation, DispatchContext dctx, GenericEntity value, boolean isError, Set actionsRun) throws GenericEntityException {
+    public void eval(String currentOperation, DispatchContext dctx, GenericEntity value, boolean isError, Set<String> actionsRun) throws GenericEntityException {
         if (!enabled) {
             Debug.logInfo("Entity ECA [" + this.entityName + "] on [" + this.eventName + "] is disabled; not running.", module);
             return;
@@ -103,13 +96,11 @@
             return;
         }
         
-        Map context = FastMap.newInstance();
+        Map<String, Object> context = FastMap.newInstance();
         context.putAll(value);
 
         boolean allCondTrue = true;
-        Iterator c = conditions.iterator();
-        while (c.hasNext()) {
-            EntityEcaCondition ec = (EntityEcaCondition) c.next();
+        for (EntityEcaCondition ec: conditions) {
             if (!ec.eval(dctx, value)) {
                 allCondTrue = false;
                 break;
@@ -117,9 +108,7 @@
         }
 
         if (allCondTrue) {
-            Iterator actionsAndSetIter = actionsAndSets.iterator();
-            while (actionsAndSetIter.hasNext()) {
-                Object actionOrSet = actionsAndSetIter.next();
+            for (Object actionOrSet: actionsAndSets) {
                 if (actionOrSet instanceof EntityEcaAction) {
                     EntityEcaAction ea = (EntityEcaAction) actionOrSet;
                     // in order to enable OR logic without multiple calls to the given service,

Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaSetField.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaSetField.java?rev=672897&r1=672896&r2=672897&view=diff
==============================================================================
--- ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaSetField.java (original)
+++ ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaSetField.java Mon Jun 30 13:16:55 2008
@@ -46,7 +46,7 @@
         this.format = set.getAttribute("format");
     }
 
-    public void eval(Map context) {
+    public void eval(Map<String, Object> context) {
         if (fieldName != null) {
             // try to expand the envName
             if (UtilValidate.isEmpty(value)) {
@@ -69,19 +69,19 @@
         }
     }
 
-    protected Object format(String s, Map c) {
+    protected Object format(String s, Map<String, ? extends Object> c) {
         if (UtilValidate.isEmpty(s) || UtilValidate.isEmpty(format)) {            
             return s;
         }
 
         // string formats
         if ("append".equalsIgnoreCase(format) && envName != null) {
-            String newStr = "";
+            StringBuilder newStr = new StringBuilder();
             if (c.get(envName) != null) {
-                newStr = newStr + c.get(envName);
+                newStr.append(c.get(envName));
             }
-            newStr = newStr + s;
-            return newStr;
+            newStr.append(s);
+            return newStr.toString();
         }
         if ("to-upper".equalsIgnoreCase(format)) {
             return s.toUpperCase();
@@ -90,13 +90,13 @@
             return s.toLowerCase();
         }
         if ("hash-code".equalsIgnoreCase(format)) {
-            return new Integer(s.hashCode());
+            return Integer.valueOf(s.hashCode());
         }
         if ("long".equalsIgnoreCase(format)) {
-            return new Long(s);
+            return Long.valueOf(s);
         }
         if ("double".equalsIgnoreCase(format)) {
-            return new Double(s);
+            return Double.valueOf(s);
         }
 
         // entity formats

Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaUtil.java?rev=672897&r1=672896&r2=672897&view=diff
==============================================================================
--- ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaUtil.java (original)
+++ ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaUtil.java Mon Jun 30 13:16:55 2008
@@ -48,13 +48,13 @@
 
     public static final String module = EntityEcaUtil.class.getName();
 
-    public static UtilCache entityEcaReaders = new UtilCache("entity.EcaReaders", 0, 0, false);
+    public static UtilCache<String, Map<String, Map<String, List<EntityEcaRule>>>> entityEcaReaders = new UtilCache<String, Map<String, Map<String, List<EntityEcaRule>>>>("entity.EcaReaders", 0, 0, false);
 
     public static Map<String, Map<String, List<EntityEcaRule>>> getEntityEcaCache(String entityEcaReaderName) {
-        Map<String, Map<String, List<EntityEcaRule>>> ecaCache = (Map) entityEcaReaders.get(entityEcaReaderName);
+        Map<String, Map<String, List<EntityEcaRule>>> ecaCache = entityEcaReaders.get(entityEcaReaderName);
         if (ecaCache == null) {
             synchronized (EntityEcaUtil.class) {
-                ecaCache = (Map) entityEcaReaders.get(entityEcaReaderName);
+                ecaCache = entityEcaReaders.get(entityEcaReaderName);
                 if (ecaCache == null) {
                     ecaCache = FastMap.newInstance();
                     readConfig(entityEcaReaderName, ecaCache);
@@ -74,32 +74,27 @@
         return delegatorInfo.entityEcaReader;
     }
 
-    protected static void readConfig(String entityEcaReaderName, Map ecaCache) {
+    protected static void readConfig(String entityEcaReaderName, Map<String, Map<String, List<EntityEcaRule>>> ecaCache) {
         EntityEcaReaderInfo entityEcaReaderInfo = EntityConfigUtil.getEntityEcaReaderInfo(entityEcaReaderName);
         if (entityEcaReaderInfo == null) {
             Debug.logError("BAD ERROR: Could not find entity-eca-reader config with name: " + entityEcaReaderName, module);
             return;
         }
 
-        Iterator eecaResourceIter = entityEcaReaderInfo.resourceElements.iterator();
-        while (eecaResourceIter.hasNext()) {
-            Element eecaResourceElement = (Element) eecaResourceIter.next();
+        for (Element eecaResourceElement: entityEcaReaderInfo.resourceElements) {
             ResourceHandler handler = new MainResourceHandler(EntityConfigUtil.ENTITY_ENGINE_XML_FILENAME, eecaResourceElement);
             addEcaDefinitions(handler, ecaCache);
         }
 
         // get all of the component resource eca stuff, ie specified in each ofbiz-component.xml file
-        List componentResourceInfos = ComponentConfig.getAllEntityResourceInfos("eca");
-        Iterator componentResourceInfoIter = componentResourceInfos.iterator();
-        while (componentResourceInfoIter.hasNext()) {
-            ComponentConfig.EntityResourceInfo componentResourceInfo = (ComponentConfig.EntityResourceInfo) componentResourceInfoIter.next();
+        for (ComponentConfig.EntityResourceInfo componentResourceInfo: ComponentConfig.getAllEntityResourceInfos("eca")) {
             if (entityEcaReaderName.equals(componentResourceInfo.readerName)) {
                 addEcaDefinitions(componentResourceInfo.createResourceHandler(), ecaCache);
             }
         }
     }
 
-    protected static void addEcaDefinitions(ResourceHandler handler, Map ecaCache) {
+    protected static void addEcaDefinitions(ResourceHandler handler, Map<String, Map<String, List<EntityEcaRule>>> ecaCache) {
         Element rootElement = null;
         try {
             rootElement = handler.getDocument().getDocumentElement();
@@ -108,22 +103,19 @@
             return;
         }
 
-        List ecaList = UtilXml.childElementList(rootElement, "eca");
-        Iterator ecaIt = ecaList.iterator();
         int numDefs = 0;
-        while (ecaIt.hasNext()) {
-            Element e = (Element) ecaIt.next();
+        for (Element e: UtilXml.childElementList(rootElement, "eca")) {
             String entityName = e.getAttribute("entity");
             String eventName = e.getAttribute("event");
-            Map eventMap = (Map) ecaCache.get(entityName);
-            List rules = null;
+            Map<String, List<EntityEcaRule>> eventMap = ecaCache.get(entityName);
+            List<EntityEcaRule> rules = null;
             if (eventMap == null) {
                 eventMap = FastMap.newInstance();
                 rules = FastList.newInstance();
                 ecaCache.put(entityName, eventMap);
                 eventMap.put(eventName, rules);
             } else {
-                rules = (List) eventMap.get(eventName);
+                rules = eventMap.get(eventName);
                 if (rules == null) {
                     rules = FastList.newInstance();
                     eventMap.put(eventName, rules);
@@ -135,14 +127,12 @@
         Debug.logImportant("Loaded " + numDefs + " Entity ECA definitions from " + handler.getLocation() + " in loader " + handler.getLoaderName(), module);
     }
 
-    public static Collection getEntityEcaRules(GenericDelegator delegator, String entityName, String event) {
-        Map ecaCache = EntityEcaUtil.getEntityEcaCache(EntityEcaUtil.getEntityEcaReaderName(delegator.getDelegatorName()));
-        Map eventMap = (Map) ecaCache.get(entityName);
+    public static Collection<EntityEcaRule> getEntityEcaRules(GenericDelegator delegator, String entityName, String event) {
+        Map<String, Map<String, List<EntityEcaRule>>> ecaCache = EntityEcaUtil.getEntityEcaCache(EntityEcaUtil.getEntityEcaReaderName(delegator.getDelegatorName()));
+        Map<String, List<EntityEcaRule>> eventMap = ecaCache.get(entityName);
         if (eventMap != null) {
             if (event != null) {
-                return (Collection) eventMap.get(event);
-            } else {
-                return eventMap.values();
+                return eventMap.get(event);
             }
         }
         return null;

Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/permission/EntityPermissionChecker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/permission/EntityPermissionChecker.java?rev=672897&r1=672896&r2=672897&view=diff
==============================================================================
--- ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/permission/EntityPermissionChecker.java (original)
+++ ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/permission/EntityPermissionChecker.java Mon Jun 30 13:16:55 2008
@@ -19,23 +19,24 @@
 package org.ofbiz.entityext.permission;
 
 import java.sql.Timestamp;
-import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.ListIterator;
 import java.util.Map;
+import java.util.Set;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpSession;
 
 import javolution.util.FastList;
+import javolution.util.FastMap;
+import javolution.util.FastSet;
 
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.StringUtil;
 import org.ofbiz.base.util.UtilDateTime;
+import static org.ofbiz.base.util.UtilGenerics.checkList;
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.base.util.UtilXml;
@@ -104,15 +105,15 @@
 
     }
 
-    public boolean runPermissionCheck(Map context) {
+    public boolean runPermissionCheck(Map<String, ?> context) {
         
         boolean passed = false;
         String idString = entityIdExdr.expandString(context);
-        List entityIdList = null;
+        List<String> entityIdList = null;
         if (UtilValidate.isNotEmpty(idString)) {
             entityIdList = StringUtil.split(idString, "|");
         } else {
-            entityIdList = new ArrayList();
+            entityIdList = FastList.newInstance();
         }
         String entityName = entityNameExdr.expandString(context);
         HttpServletRequest request = (HttpServletRequest)context.get("request");
@@ -136,7 +137,7 @@
             if (!passed && displayFailCond) {
                  String errMsg =  "Permission is denied. \nThese are the conditions of which one must be met:\n"
                      + permissionConditionGetter.dumpAsText();
-                 List errorMessageList = (List)context.get("errorMessageList");
+                 List<Object> errorMessageList = checkList(context.get("errorMessageList"));
                  errorMessageList.add(errMsg);
             }
         } catch(GenericEntityException e) {
@@ -145,47 +146,47 @@
         return passed;
     }
 
-    public static Map checkPermission(GenericValue content, String statusId, GenericValue userLogin, List passedPurposes, List targetOperations, List passedRoles, GenericDelegator delegator , Security security, String entityAction) {
+    public static Map<String, Object> checkPermission(GenericValue content, String statusId, GenericValue userLogin, List<String> passedPurposes, List<String> targetOperations, List<String> passedRoles, GenericDelegator delegator , Security security, String entityAction) {
          String privilegeEnumId = null;
          return checkPermission(content, statusId, userLogin, passedPurposes, targetOperations, passedRoles, delegator, security, entityAction, privilegeEnumId, null);
     }
 
-    public static Map checkPermission(GenericValue content, String statusId,
-                                  GenericValue userLogin, List passedPurposes,
-                                  List targetOperations, List passedRoles,
+    public static Map<String, Object> checkPermission(GenericValue content, String statusId,
+                                  GenericValue userLogin, List<String> passedPurposes,
+                                  List<String> targetOperations, List<String> passedRoles,
                                   GenericDelegator delegator ,
                                   Security security, String entityAction,
                                   String privilegeEnumId, String quickCheckContentId) {
-         List statusList = null;
+         List<String> statusList = null;
          if (statusId != null) {
              statusList = StringUtil.split(statusId, "|");
          }
          return checkPermission(content, statusList, userLogin, passedPurposes, targetOperations, passedRoles, delegator, security, entityAction, privilegeEnumId, quickCheckContentId);
     }
 
-    public static Map checkPermission(GenericValue content, List statusList,
-                                  GenericValue userLogin, List passedPurposes,
-                                  List targetOperations, List passedRoles,
+    public static Map<String, Object> checkPermission(GenericValue content, List<String> statusList,
+                                  GenericValue userLogin, List<String> passedPurposes,
+                                  List<String> targetOperations, List<String> passedRoles,
                                   GenericDelegator delegator ,
                                   Security security, String entityAction,
                                   String privilegeEnumId) {
          return checkPermission(content, statusList, userLogin, passedPurposes, targetOperations, passedRoles, delegator, security, entityAction, privilegeEnumId, null);
     }
 
-    public static Map checkPermission(GenericValue content, List statusList,
-                                  GenericValue userLogin, List passedPurposes,
-                                  List targetOperations, List passedRoles,
+    public static Map<String, Object> checkPermission(GenericValue content, List<String> statusList,
+                                  GenericValue userLogin, List<String> passedPurposes,
+                                  List<String> targetOperations, List<String> passedRoles,
                                   GenericDelegator delegator ,
                                   Security security, String entityAction,
                                   String privilegeEnumId, String quickCheckContentId) {
 
-        List entityIds = new ArrayList();
+        List<Object> entityIds = FastList.newInstance();
         if (content != null) entityIds.add(content);
         if (UtilValidate.isNotEmpty(quickCheckContentId)) {
-            List quickList = StringUtil.split(quickCheckContentId, "|");
+            List<String> quickList = StringUtil.split(quickCheckContentId, "|");
             if (UtilValidate.isNotEmpty(quickList)) entityIds.addAll(quickList);
         }
-        Map results  = new HashMap();
+        Map<String, Object> results  = FastMap.newInstance();
         boolean passed = false;
         if (userLogin != null && entityAction != null) {
             passed = security.hasEntityPermission("CONTENTMGR", entityAction, userLogin);
@@ -208,7 +209,7 @@
     }
     
     
-    public static boolean checkPermissionMethod(GenericDelegator delegator, GenericValue userLogin, List targetOperationList, String entityName, List entityIdList, List purposeList, List roleList, String privilegeEnumId) throws GenericEntityException {
+    public static boolean checkPermissionMethod(GenericDelegator delegator, GenericValue userLogin, List<String> targetOperationList, String entityName, List<? extends Object> entityIdList, List<String> purposeList, List<String> roleList, String privilegeEnumId) throws GenericEntityException {
         boolean passed = false;
     
         String lcEntityName = entityName.toLowerCase();
@@ -234,7 +235,7 @@
         if (modelEntity.getField("privilegeEnumId") != null)
             hasPrivilegeField = true;
     
-        List operationEntities = null;
+        List<GenericValue> operationEntities = null;
         ModelEntity modelOperationEntity = delegator.getModelEntity(entityName + "PurposeOperation");
         if (modelOperationEntity == null) {
             modelOperationEntity = delegator.getModelEntity(entityName + "Operation");            
@@ -257,7 +258,7 @@
         
         // Get all the condition operations that could apply, rather than having to go thru
         // entire table each time.
-        //List condList = new ArrayList();
+        //List condList = FastList.newInstance();
         //Iterator iterType = targetOperationList.iterator();
         //while (iterType.hasNext()) {
         //    String op = (String)iterType.next();
@@ -267,8 +268,8 @@
         
         EntityCondition opCond = EntityCondition.makeCondition(lcEntityName + "OperationId", EntityOperator.IN, targetOperationList);
         
-        List targetOperationEntityList = delegator.findList(modelOperationEntity.getEntityName(), opCond, null, null, null, true);
-        Map entities = new HashMap();
+        List<GenericValue> targetOperationEntityList = delegator.findList(modelOperationEntity.getEntityName(), opCond, null, null, null, true);
+        Map<String, GenericValue> entities = FastMap.newInstance();
         String pkFieldName = modelEntity.getFirstPkFieldName();
     
         //TODO: privilegeEnumId test
@@ -318,14 +319,13 @@
         // check permission for each id in passed list until success.
         // Note that "quickCheck" id come first in the list
         // Check with no roles or purposes on the chance that the permission fields contain _NA_ s.
-        List alreadyCheckedIds = new ArrayList();
-        Map purposes = new HashMap();
-        Map roles = new HashMap();
-        Iterator iter = entityIdList.iterator();
+        List alreadyCheckedIds = FastList.newInstance();
+        Map<String, List<String>> purposes = FastMap.newInstance();
+        Map<String, List<String>> roles = FastMap.newInstance();
         //List purposeList = null;
         //List roleList = null;
-        while (iter.hasNext()) {
-               GenericValue entity = getNextEntity(delegator, entityName, pkFieldName, iter.next(), entities);
+        for (Object id: entityIdList) {
+               GenericValue entity = getNextEntity(delegator, entityName, pkFieldName, id, entities);
              if (entity == null) continue;
                   
             String statusId = null;
@@ -351,9 +351,8 @@
         
         if (hasPurposeOp) {
             // Check with just purposes next.
-            iter = entityIdList.iterator();
-            while (iter.hasNext()) {
-                GenericValue entity = getNextEntity(delegator, entityName, pkFieldName, iter.next(), entities);
+            for (Object id: entityIdList) {
+                GenericValue entity = getNextEntity(delegator, entityName, pkFieldName, id, entities);
                 if (entity == null) continue;
                 
                 String entityId = entity.getString(pkFieldName);
@@ -378,12 +377,11 @@
         if (userLogin == null) return false;
     
         // Check with roles.
-        iter = entityIdList.iterator();
-        while (iter.hasNext()) {
-            GenericValue entity = getNextEntity(delegator, entityName, pkFieldName, iter.next(), entities);
+        for (Object id: entityIdList) {
+            GenericValue entity = getNextEntity(delegator, entityName, pkFieldName, id, entities);
             if (entity == null) continue;
             String entityId = entity.getString(pkFieldName);
-            List tmpPurposeList = (List)purposes.get(entityId);
+            List<String> tmpPurposeList = purposes.get(entityId);
             if (purposeList != null ) {
                 if (tmpPurposeList != null) {
                     purposeList.addAll(tmpPurposeList);
@@ -392,7 +390,7 @@
                 purposeList = tmpPurposeList;
             }
                 
-            List tmpRoleList = getUserRoles(entity, userLogin, delegator);
+            List<String> tmpRoleList = getUserRoles(entity, userLogin, delegator);
             if (roleList != null ) {
                 if (tmpRoleList != null) {
                     roleList.addAll(tmpRoleList);
@@ -418,22 +416,21 @@
         
         // Follow ownedEntityIds
         if (modelEntity.getField("owner" + entityName + "Id") != null) {
-            iter = entityIdList.iterator();
-            while (iter.hasNext()) {
-                GenericValue entity = getNextEntity(delegator, entityName, pkFieldName, iter.next(), entities);
+            for (Object id: entityIdList) {
+                GenericValue entity = getNextEntity(delegator, entityName, pkFieldName, id, entities);
                 if (entity == null) continue;
                 
                 String entityId = entity.getString(pkFieldName);
-                List ownedContentIdList = new ArrayList();
+                List<String> ownedContentIdList = FastList.newInstance();
                 getEntityOwners(delegator, entity, ownedContentIdList, "Content", "ownerContentId");
     
-                List ownedContentRoleIds = getUserRolesFromList(delegator, ownedContentIdList, partyId, "contentId", "partyId", "roleTypeId", "ContentRole");
+                List<String> ownedContentRoleIds = getUserRolesFromList(delegator, ownedContentIdList, partyId, "contentId", "partyId", "roleTypeId", "ContentRole");
                 String statusId = null;
                 if (hasStatusOp && hasStatusField) {
                     statusId = entity.getString("statusId");
                 }
                   
-                purposeList = (List)purposes.get(entityId);
+                purposeList = purposes.get(entityId);
                 passed = hasMatch(entityName, targetOperationEntityList, ownedContentRoleIds, hasPurposeOp, purposeList, hasStatusOp, statusId);
                 if (passed) break;
               
@@ -499,7 +496,7 @@
         
         return passed;
     }
-    public static boolean checkPermissionMethod(GenericDelegator delegator, String partyId,  String entityName, List entityIdList, AuxiliaryValueGetter auxiliaryValueGetter, RelatedRoleGetter relatedRoleGetter, PermissionConditionGetter permissionConditionGetter) throws GenericEntityException {
+    public static boolean checkPermissionMethod(GenericDelegator delegator, String partyId,  String entityName, List<? extends Object> entityIdList, AuxiliaryValueGetter auxiliaryValueGetter, RelatedRoleGetter relatedRoleGetter, PermissionConditionGetter permissionConditionGetter) throws GenericEntityException {
     
         permissionConditionGetter.init(delegator);
         if (Debug.verboseOn()) Debug.logVerbose(permissionConditionGetter.dumpAsText(), module);
@@ -524,8 +521,7 @@
         String pkFieldName = modelEntity.getFirstPkFieldName();
         if (Debug.infoOn()) {
         String entityIdString = "ENTITIES: ";
-        for (int i=0; i < entityIdList.size(); i++) {
-            Object obj = entityIdList.get(i);
+        for (Object obj: entityIdList) {
             if (obj instanceof GenericValue) {
                 String s = ((GenericValue)obj).getString(pkFieldName);
                 entityIdString += s + "  ";
@@ -536,13 +532,12 @@
             //if (Debug.infoOn()) Debug.logInfo(entityIdString, module);
         }
         
-        List alreadyCheckedIds = new ArrayList();
-        Map entities = new HashMap();
-        Iterator iter = entityIdList.iterator();
+        List alreadyCheckedIds = FastList.newInstance();
+        Map<String, GenericValue> entities = FastMap.newInstance();
         //List purposeList = null;
         //List roleList = null;
-        while (iter.hasNext()) {
-            GenericValue entity = getNextEntity(delegator, entityName, pkFieldName, iter.next(), entities);
+        for (Object id: entityIdList) {
+            GenericValue entity = getNextEntity(delegator, entityName, pkFieldName, id, entities);
             if (entity == null) continue;
             checkAncestors = false;
             passed = hasMatch(entity, permissionConditionGetter, relatedRoleGetter, null, partyId, checkAncestors);
@@ -558,9 +553,8 @@
         if (auxiliaryValueGetter != null) {
             //if (Debug.infoOn()) Debug.logInfo(auxiliaryValueGetter.dumpAsText(), module);
             // Check with just purposes next.
-            iter = entityIdList.iterator();
-            while (iter.hasNext()) {
-                GenericValue entity = getNextEntity(delegator, entityName, pkFieldName, iter.next(), entities);
+            for (Object id: entityIdList) {
+                GenericValue entity = getNextEntity(delegator, entityName, pkFieldName, id, entities);
                 if (entity == null) continue;
                 checkAncestors = false;
                 passed = hasMatch(entity, permissionConditionGetter, relatedRoleGetter, auxiliaryValueGetter, partyId, checkAncestors);
@@ -578,9 +572,8 @@
     
         // Check with roles.
         if (relatedRoleGetter != null) {
-            iter = entityIdList.iterator();
-            while (iter.hasNext()) {
-                GenericValue entity = getNextEntity(delegator, entityName, pkFieldName, iter.next(), entities);
+            for (Object id: entityIdList) {
+                GenericValue entity = getNextEntity(delegator, entityName, pkFieldName, id, entities);
                 if (entity == null) continue;
                 checkAncestors = false;
                 passed = hasMatch(entity, permissionConditionGetter, relatedRoleGetter, auxiliaryValueGetter, partyId, checkAncestors);
@@ -595,9 +588,8 @@
             return true;
         
         if (relatedRoleGetter != null) {
-            iter = entityIdList.iterator();
-            while (iter.hasNext()) {
-                GenericValue entity = getNextEntity(delegator, entityName, pkFieldName, iter.next(), entities);
+            for (Object id: entityIdList) {
+                GenericValue entity = getNextEntity(delegator, entityName, pkFieldName, id, entities);
                 if (entity == null) continue;
                 checkAncestors = true;
                 passed = hasMatch(entity, permissionConditionGetter, relatedRoleGetter, auxiliaryValueGetter, partyId, checkAncestors);
@@ -613,11 +605,11 @@
     }
     
     
-    public static GenericValue getNextEntity(GenericDelegator delegator, String entityName, String pkFieldName, Object obj, Map entities) throws GenericEntityException {
+    public static GenericValue getNextEntity(GenericDelegator delegator, String entityName, String pkFieldName, Object obj, Map<String, GenericValue> entities) throws GenericEntityException {
         GenericValue entity = null;
         if (obj instanceof String) {
             String entityId  = (String)obj;
-            if (entities != null) entity = (GenericValue)entities.get(entityId);
+            if (entities != null) entity = entities.get(entityId);
             
             if (entity == null) entity = delegator.findByPrimaryKeyCache(entityName,UtilMisc.toMap(pkFieldName, entityId));
         } else if (obj instanceof GenericValue) {
@@ -627,11 +619,11 @@
     }
     
     public static boolean checkHasRoleOperations(String partyId,  PermissionConditionGetter permissionConditionGetter , GenericDelegator delegator) {
-        List targetOperations = permissionConditionGetter.getOperationList();
+        List<String> targetOperations = permissionConditionGetter.getOperationList();
         return checkHasRoleOperations(partyId, targetOperations, delegator);
     }
     
-    public static boolean checkHasRoleOperations(String partyId,  List targetOperations, GenericDelegator delegator) {
+    public static boolean checkHasRoleOperations(String partyId,  List<String> targetOperations, GenericDelegator delegator) {
         //if (Debug.infoOn()) Debug.logInfo("targetOperations:" + targetOperations, module);
         //if (Debug.infoOn()) Debug.logInfo("userLoginId:" + userLoginId, module);
         if (targetOperations == null) return false;
@@ -639,11 +631,9 @@
         if (partyId != null && targetOperations.contains("HAS_USER_ROLE")) return true;
     
         boolean hasRoleOperation = false;
-        Iterator targOpIter = targetOperations.iterator();
         boolean hasNeed = false;
-        List newHasRoleList = new ArrayList();
-        while (targOpIter.hasNext()) {
-            String roleOp = (String)targOpIter.next();
+        List<String> newHasRoleList = FastList.newInstance();
+        for (String roleOp: targetOperations) {
             int idx1 = roleOp.indexOf("HAS_");
             if (idx1 == 0) {
                 String roleOp1 = roleOp.substring(4); // lop off "HAS_"
@@ -660,14 +650,10 @@
         if (hasNeed) {
             try {
                 if (UtilValidate.isNotEmpty(partyId)) {
-                    List partyRoleList = delegator.findByAndCache("PartyRole", UtilMisc.toMap("partyId", partyId));
-                    Iterator partyRoleIter = partyRoleList.iterator();
-                    while (partyRoleIter.hasNext()) {
-                        GenericValue partyRole = (GenericValue)partyRoleIter.next();
+                    List<GenericValue> partyRoleList = delegator.findByAndCache("PartyRole", UtilMisc.toMap("partyId", partyId));
+                    for (GenericValue partyRole: partyRoleList) {
                         String roleTypeId = partyRole.getString("roleTypeId");
-                        targOpIter = newHasRoleList.iterator();
-                        while (targOpIter.hasNext()) {
-                            String thisRole = (String)targOpIter.next();
+                        for (String thisRole: newHasRoleList) {
                             if (roleTypeId.indexOf(thisRole) >= 0) {
                                 hasRoleOperation = true;
                                 break;
@@ -685,7 +671,7 @@
         return hasRoleOperation;
     }
     
-    public static boolean hasMatch(String entityName, List targetOperations, List roles, boolean hasPurposeOp, List purposes, boolean hasStatusOp, String targStatusId) {
+    public static boolean hasMatch(String entityName, List<GenericValue> targetOperations, List<String> roles, boolean hasPurposeOp, List<String> purposes, boolean hasStatusOp, String targStatusId) {
         boolean isMatch = false;
         int targPrivilegeSeq = 0;
     //    if (UtilValidate.isNotEmpty(targPrivilegeEnumId) && !targPrivilegeEnumId.equals("_NA_") && !targPrivilegeEnumId.equals("_00_") ) {
@@ -693,9 +679,7 @@
             // The lookup could be a static store or it could be done on Enumeration entity.
     //    }
         String lcEntityName = entityName.toLowerCase();
-        Iterator targetOpsIter = targetOperations.iterator();
-        while (targetOpsIter.hasNext() ) {
-            GenericValue targetOp = (GenericValue)targetOpsIter.next();
+        for (GenericValue targetOp: targetOperations) {
             String testRoleTypeId = (String)targetOp.get("roleTypeId");
             String testContentPurposeTypeId = null;
             if (hasPurposeOp)
@@ -732,7 +716,7 @@
         if (Debug.verboseOn()) Debug.logVerbose("\n\nIN hasMatch: entityId:" + entityId + " partyId:" + partyId + " checkAncestors:" + checkAncestors, module);
         boolean isMatch = false;
         permissionConditionGetter.restart();
-        List auxiliaryValueList = null;
+        List<String> auxiliaryValueList = null;
         if (auxiliaryValueGetter != null) {
            auxiliaryValueGetter.init(delegator, entityId);
            auxiliaryValueList =   auxiliaryValueGetter.getList();
@@ -740,7 +724,7 @@
         } else {
             if (Debug.verboseOn()) Debug.logVerbose("NO AUX GETTER", module);
         }
-        List roleValueList = null;
+        List<String> roleValueList = null;
         if (relatedRoleGetter != null) {
             if (checkAncestors) {
                 relatedRoleGetter.initWithAncestors(delegator, entity, partyId);
@@ -780,21 +764,22 @@
     /**
      * getRelatedPurposes
      */
-    public static List getRelatedPurposes(GenericValue entity, List passedPurposes) {
+    public static List<String> getRelatedPurposes(GenericValue entity, List<String> passedPurposes) {
     
         if(entity == null) return passedPurposes;
     
-        List purposeIds = null;
+        List<String> purposeIds = null;
         if (passedPurposes == null) {
-            purposeIds = new ArrayList( );
+            purposeIds = FastList.newInstance( );
         } else {
-            purposeIds = new ArrayList( passedPurposes );
+            purposeIds = FastList.newInstance( );
+            purposeIds.addAll( passedPurposes );
         }
     
         String entityName = entity.getEntityName();
         String lcEntityName = entityName.toLowerCase();
     
-        List purposes = null;
+        List<GenericValue> purposes = null;
         try {
             purposes = entity.getRelatedCache(entityName + "Purpose");
         } catch (GenericEntityException e) {
@@ -802,10 +787,8 @@
             return purposeIds;
         }
     
-        Iterator purposesIter = purposes.iterator();
-        while (purposesIter.hasNext() ) {
-            GenericValue val = (GenericValue)purposesIter.next();
-            purposeIds.add(val.get(lcEntityName + "PurposeTypeId"));
+        for (GenericValue val: purposes) {
+            purposeIds.add((String) val.get(lcEntityName + "PurposeTypeId"));
         }
         
     
@@ -819,10 +802,10 @@
      * and returns the ones that match the user.
      * Follows group parties to see if the user is a member.
      */
-    public static List getUserRoles(GenericValue entity, GenericValue userLogin, GenericDelegator delegator) throws GenericEntityException {
+    public static List<String> getUserRoles(GenericValue entity, GenericValue userLogin, GenericDelegator delegator) throws GenericEntityException {
     
         String entityName = entity.getEntityName();
-        List roles = new ArrayList();
+        List<String> roles = FastList.newInstance();
         if(entity == null) return roles;
             // TODO: Need to use ContentManagementWorker.getAuthorContent first
     
@@ -839,13 +822,11 @@
         }
         
         String partyId = (String)userLogin.get("partyId");
-        List relatedRoles = null;
-        List tmpRelatedRoles = entity.getRelatedCache(entityName + "Role");
+        List<GenericValue> relatedRoles = null;
+        List<GenericValue> tmpRelatedRoles = entity.getRelatedCache(entityName + "Role");
         relatedRoles = EntityUtil.filterByDate(tmpRelatedRoles);
         if(relatedRoles != null ) {
-            Iterator rolesIter = relatedRoles.iterator();
-            while (rolesIter.hasNext() ) {
-                GenericValue contentRole = (GenericValue)rolesIter.next();
+            for (GenericValue contentRole: relatedRoles) {
                 String roleTypeId = (String)contentRole.get("roleTypeId");
                 String targPartyId = (String)contentRole.get("partyId");
                 if (targPartyId.equals(partyId)) {
@@ -860,7 +841,7 @@
                         party = contentRole.getRelatedOne("Party");
                         partyTypeId = (String)party.get("partyTypeId");
                         if ( partyTypeId != null && partyTypeId.equals("PARTY_GROUP") ) {
-                           HashMap map = new HashMap();
+                           Map<String, Object> map = FastMap.newInstance();
                         
                            // At some point from/thru date will need to be added
                            map.put("partyIdFrom", partyId);
@@ -883,7 +864,7 @@
     /**
      * Tests to see if the user belongs to a group
      */
-    public static boolean isGroupMember( Map partyRelationshipValues, GenericDelegator delegator ) {
+    public static boolean isGroupMember( Map<String, ?> partyRelationshipValues, GenericDelegator delegator ) {
         boolean isMember = false;
         String partyIdFrom = (String)partyRelationshipValues.get("partyIdFrom") ;
         String partyIdTo = (String)partyRelationshipValues.get("partyIdTo") ;
@@ -917,10 +898,10 @@
     
         // This method is simplified to make it work, these conditions need to be added back in.
         //List joinList = UtilMisc.toList(fromExpr, thruCond, partyFromExpr, partyToExpr, relationExpr);
-        List joinList = UtilMisc.toList( partyFromExpr, partyToExpr);
+        List<? extends EntityCondition> joinList = UtilMisc.toList( partyFromExpr, partyToExpr);
         EntityCondition condition = EntityCondition.makeCondition(joinList);
     
-        List partyRelationships = null;
+        List<GenericValue> partyRelationships = null;
         try {
             partyRelationships = delegator.findList("PartyRelationship", condition, null, null, null, false);
         } catch (GenericEntityException e) {
@@ -946,17 +927,17 @@
         public void init(GenericDelegator delegator) throws GenericEntityException;
         public void restart();
         public void setOperationList(String operationIdString);
-        public void setOperationList(List opList);
-        public List getOperationList();
+        public void setOperationList(List<String> opList);
+        public List<String> getOperationList();
         public String dumpAsText();
         public void clearList();
     }
     
     public static class StdPermissionConditionGetter implements PermissionConditionGetter {
     
-        protected List entityList;
-        protected List operationList;
-        protected ListIterator iter;
+        protected List<GenericValue> entityList;
+        protected List<String> operationList;
+        protected ListIterator<GenericValue> iter;
         protected GenericValue currentValue;
         protected String operationFieldName;
         protected String roleFieldName;
@@ -997,7 +978,7 @@
         public boolean getNext() {
             boolean hasNext = false;
             if (iter != null && iter.hasNext()) {
-                currentValue = (GenericValue)iter.next();
+                currentValue = iter.next();
                 hasNext = true;
             }
             return hasNext;
@@ -1049,16 +1030,16 @@
             }
         }
         
-        public void setOperationList(List operationList) {
+        public void setOperationList(List<String> operationList) {
             this.operationList = operationList;
         }
         
-        public List getOperationList() {
+        public List<String> getOperationList() {
             return this.operationList;
         }
         
         public void clearList() {
-            this.entityList = new ArrayList();
+            this.entityList = FastList.newInstance();
         }
         
         public void init( GenericDelegator delegator) throws GenericEntityException {
@@ -1074,8 +1055,8 @@
         }
     
         public String dumpAsText() {
-             List fieldNames = UtilMisc.toList("roleFieldName",  "auxiliaryFieldName",  "statusFieldName");
-             Map widths = UtilMisc.toMap("roleFieldName", new Integer(24), "auxiliaryFieldName", new Integer(24), "statusFieldName", new Integer(24));
+             List<String> fieldNames = UtilMisc.toList("roleFieldName",  "auxiliaryFieldName",  "statusFieldName");
+             Map<String, Integer> widths = UtilMisc.toMap("roleFieldName", Integer.valueOf(24), "auxiliaryFieldName", Integer.valueOf(24), "statusFieldName", Integer.valueOf(24));
              StringBuilder buf = new StringBuilder();
              Integer wid = null;
             
@@ -1084,27 +1065,21 @@
              buf.append(" ops:");
              buf.append(StringUtil.join(this.operationList, ","));
              buf.append("\n");
-             Iterator itFields = fieldNames.iterator();
-             while (itFields.hasNext()) {
-                 String fld = (String)itFields.next();
+             for (String fld: fieldNames) {
                  wid = (Integer)widths.get(fld);
                  buf.append(fld);  
                  for (int i=0; i < (wid.intValue() - fld.length()); i++) buf.append("^");
                  buf.append("  ");
              }
                      buf.append("\n");
-             itFields = fieldNames.iterator();
-             while (itFields.hasNext()) {
-                 String fld = (String)itFields.next();
+             for (String fld: fieldNames) {
                  wid = (Integer)widths.get(fld);
                  for (int i=0; i < wid.intValue(); i++) buf.append("-");
                  buf.append("  ");
              }
                      buf.append("\n");
              if (entityList != null) {
-                 Iterator it = this.entityList.iterator();
-                 while (it.hasNext()) {
-                     GenericValue contentPurposeOperation = (GenericValue)it.next();  
+                 for (GenericValue contentPurposeOperation: this.entityList) {
                      /*
                      String contentOperationId = contentPurposeOperation.getString(this.operationFieldName);
                      if (UtilValidate.isEmpty(contentOperationId)) {
@@ -1154,14 +1129,14 @@
     
     public interface AuxiliaryValueGetter {
         public void init(GenericDelegator delegator, String entityId) throws GenericEntityException;
-        public List getList();
+        public List<String> getList();
         public void clearList();
         public String dumpAsText();
     }
     
     public static class StdAuxiliaryValueGetter implements AuxiliaryValueGetter {
     
-        protected List entityList = new ArrayList();
+        protected List<String> entityList = FastList.newInstance();
         protected String auxiliaryFieldName;
         protected String entityName;
         protected String entityIdName;
@@ -1187,30 +1162,28 @@
             this.entityIdName = getterElement.getAttribute("entity-id-name");
         }
         
-        public List getList() {
+        public List<String> getList() {
             return entityList;
         }
         
         public void clearList() {
-            this.entityList = new ArrayList();
+            this.entityList = FastList.newInstance();
         }
         
-        public void setList(List lst) {
+        public void setList(List<String> lst) {
             this.entityList = lst;
         }
         
         public void init(GenericDelegator delegator, String entityId) throws GenericEntityException {
             
             if (this.entityList == null) {
-               this.entityList = new ArrayList();
+               this.entityList = FastList.newInstance();
             }
             if (UtilValidate.isEmpty(this.entityName)) {
                 return;  
             }
-            List values = delegator.findByAndCache(this.entityName, UtilMisc.toMap(this.entityIdName, entityId));
-            Iterator iter = values.iterator();
-            while (iter.hasNext()) {
-                GenericValue entity = (GenericValue)iter.next();
+            List<GenericValue> values = delegator.findByAndCache(this.entityName, UtilMisc.toMap(this.entityIdName, entityId));
+            for (GenericValue entity: values) {
                 this.entityList.add(entity.getString(this.auxiliaryFieldName));
             }
         }
@@ -1219,8 +1192,7 @@
              StringBuilder buf = new StringBuilder();
              buf.append("AUXILIARY: ");
              if (entityList != null) {
-                for (int i=0; i < entityList.size(); i++) {
-                    String val = (String)entityList.get(i);
+                 for (String val: entityList) {
                     buf.append(val);
                     buf.append("  ");
                 }
@@ -1232,16 +1204,16 @@
     public interface RelatedRoleGetter {
         public void init(GenericDelegator delegator, String entityId, String partyId, GenericValue entity) throws GenericEntityException;
         public void initWithAncestors(GenericDelegator delegator, GenericValue entity, String partyId) throws GenericEntityException;
-        public List getList();
+        public List<String> getList();
         public void clearList();
-        public void setList(List lst);
+        public void setList(List<String> lst);
         public String dumpAsText();
         public boolean isOwner(GenericValue entity, String targetPartyId);
     }
     
     public static class StdRelatedRoleGetter implements RelatedRoleGetter {
     
-        protected List roleIdList = new ArrayList();
+        protected List<String> roleIdList = FastList.newInstance();
         protected String roleTypeFieldName;
         protected String partyFieldName;
         protected String entityName;
@@ -1279,21 +1251,21 @@
             this.roleEntityIdName = getterElement.getAttribute("entity-id-name");
         }
         
-        public List getList() {
+        public List<String> getList() {
             return this.roleIdList;
         }
         
         public void clearList() {
-            this.roleIdList = new ArrayList();
+            this.roleIdList = FastList.newInstance();
         }
         
-        public void setList(List lst) {
+        public void setList(List<String> lst) {
             this.roleIdList = lst;
         }
         
         public void init(GenericDelegator delegator, String entityId, String partyId, GenericValue entity) throws GenericEntityException {
             
-            List lst = getUserRolesFromList(delegator, UtilMisc.toList(entityId), partyId, this.roleEntityIdName,
+            List<String> lst = getUserRolesFromList(delegator, UtilMisc.toList(entityId), partyId, this.roleEntityIdName,
                                                this.partyFieldName, this.roleTypeFieldName, this.roleEntityName);
             this.roleIdList.addAll(lst);
             if (isOwner(entity, partyId)) {
@@ -1303,10 +1275,10 @@
         
         public void initWithAncestors(GenericDelegator delegator, GenericValue entity, String partyId) throws GenericEntityException {
             
-           List ownedContentIdList = new ArrayList();
+           List<String> ownedContentIdList = FastList.newInstance();
            getEntityOwners(delegator, entity, ownedContentIdList, this.entityName, this.ownerEntityFieldName);
            if (ownedContentIdList.size() > 0) {
-               List lst = getUserRolesFromList(delegator, ownedContentIdList, partyId, this.roleEntityIdName, this.partyFieldName, this.roleTypeFieldName, this.roleEntityName);
+               List<String> lst = getUserRolesFromList(delegator, ownedContentIdList, partyId, this.roleEntityIdName, this.partyFieldName, this.roleTypeFieldName, this.roleEntityName);
                this.roleIdList.addAll(lst);
            }
         }
@@ -1345,8 +1317,7 @@
              StringBuilder buf = new StringBuilder();
              buf.append("ROLES: ");
              if (roleIdList != null) {
-                for (int i=0; i < roleIdList.size(); i++) {
-                    String val = (String)roleIdList.get(i);
+                for (String val: roleIdList) {
                     buf.append(val);
                     buf.append("  ");
                 }
@@ -1355,25 +1326,23 @@
         }
     }
 
-    public static List getUserRolesFromList(GenericDelegator delegator, List idList, String partyId, String entityIdFieldName, String partyIdFieldName, String roleTypeIdFieldName, String entityName) throws GenericEntityException {
+    public static List<String> getUserRolesFromList(GenericDelegator delegator, List<String> idList, String partyId, String entityIdFieldName, String partyIdFieldName, String roleTypeIdFieldName, String entityName) throws GenericEntityException {
         
         EntityExpr expr = EntityCondition.makeCondition(entityIdFieldName, EntityOperator.IN, idList);
         EntityExpr expr2 = EntityCondition.makeCondition(partyIdFieldName, partyId);
         EntityConditionList condList = EntityCondition.makeCondition(UtilMisc.toList(expr, expr2));
-        List roleList = delegator.findList(entityName, condList, null, null, null, true);
-        List roleListFiltered = EntityUtil.filterByDate(roleList);
-        HashSet distinctSet = new HashSet();
-        Iterator iter = roleListFiltered.iterator();
-        while (iter.hasNext()) {
-            GenericValue contentRole = (GenericValue)iter.next();
+        List<GenericValue> roleList = delegator.findList(entityName, condList, null, null, null, true);
+        List<GenericValue> roleListFiltered = EntityUtil.filterByDate(roleList);
+        Set<String> distinctSet = FastSet.newInstance();
+        for (GenericValue contentRole: roleListFiltered) {
             String roleTypeId = contentRole.getString(roleTypeIdFieldName);
             distinctSet.add(roleTypeId);
         }
-        List distinctList = Arrays.asList(distinctSet.toArray());
+        List<String> distinctList = Arrays.asList(distinctSet.toArray(new String[distinctSet.size()]));
         return distinctList;
     }
 
-    public static void getEntityOwners(GenericDelegator delegator, GenericValue entity,  List contentOwnerList, String entityName, String ownerIdFieldName) throws GenericEntityException {
+    public static void getEntityOwners(GenericDelegator delegator, GenericValue entity,  List<String> contentOwnerList, String entityName, String ownerIdFieldName) throws GenericEntityException {
 
         String ownerContentId = entity.getString(ownerIdFieldName);
         if (UtilValidate.isNotEmpty(ownerContentId)) {