svn commit: r833731 - in /ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools: ./ artifactinfo/ labelmanager/

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

svn commit: r833731 - in /ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools: ./ artifactinfo/ labelmanager/

jleroux@apache.org
Author: jleroux
Date: Sat Nov  7 18:49:09 2009
New Revision: 833731

URL: http://svn.apache.org/viewvc?rev=833731&view=rev
Log:
A (slightly modified) patch from Marc Morin "Resolve java warnings exposed in Eclipse : framework - webtools" (https://issues.apache.org/jira/browse/OFBIZ-3122) - OFBIZ-3122
I have replaced some while loops by enhanced for loops


Modified:
    ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/GenericWebEvent.java
    ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/UtilCacheEvents.java
    ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java
    ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java
    ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/FormWidgetArtifactInfo.java
    ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ScreenWidgetArtifactInfo.java
    ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelManagerFactory.java
    ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelReferences.java

Modified: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/GenericWebEvent.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/GenericWebEvent.java?rev=833731&r1=833730&r2=833731&view=diff
==============================================================================
--- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/GenericWebEvent.java (original)
+++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/GenericWebEvent.java Sat Nov  7 18:49:09 2009
@@ -215,8 +215,8 @@
             }
             if (tempEntity != null) {
                 Map<String, String> messageMap = UtilMisc.toMap("primaryKey", findByEntity.getPrimaryKey().toString());
-                String errMsg = entity.getEntityName() + UtilProperties.getMessage(GenericWebEvent.err_resource, "genericWebEvent.already_exists_pk", messageMap, locale)+ ".";
-                Debug.logWarning("[updateGeneric] " + entity.getEntityName() + " already exists with primary key: " + findByEntity.getPrimaryKey().toString() + "; please change.", module);
+                String errMsg = "[updateGeneric] " + entity.getEntityName() + UtilProperties.getMessage(GenericWebEvent.err_resource, "genericWebEvent.already_exists_pk", messageMap, locale)+ ".";
+                Debug.logWarning(errMsg, module);
             }
         }
 
@@ -228,7 +228,7 @@
 
             for (int j = 0; j < field.getValidatorsSize(); j++) {
                 String curValidate = field.getValidator(j);
-                Class[] paramTypes = new Class[] {String.class};
+                Class<?>[] paramTypes = new Class[] {String.class};
                 Object[] params = new Object[] {findByEntity.get(field.getName()).toString()};
 
                 String className = "org.ofbiz.base.util.UtilValidate";
@@ -291,10 +291,8 @@
         }
 
         if (updateMode.equals("CREATE")) {
-            GenericValue value;
-
             try {
-                value = delegator.create(findByEntity.getEntityName(), findByEntity.getAllFields());
+                delegator.create(findByEntity.getEntityName(), findByEntity.getAllFields());
             } catch (GenericEntityException e) {
                 Map<String, String> messageMap = UtilMisc.toMap("entityName", entity.getEntityName());
                 String errMsg = UtilProperties.getMessage(GenericWebEvent.err_resource, "genericWebEvent.creation_param_failed", messageMap, locale)+ ": " + findByEntity.toString() + ": " + e.toString();

Modified: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/UtilCacheEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/UtilCacheEvents.java?rev=833731&r1=833730&r2=833731&view=diff
==============================================================================
--- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/UtilCacheEvents.java (original)
+++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/UtilCacheEvents.java Sat Nov  7 18:49:09 2009
@@ -74,7 +74,7 @@
             return "error";
         }
 
-        UtilCache utilCache = UtilCache.findCache(name);
+        UtilCache<?, ?> utilCache = UtilCache.findCache(name);
 
         if (utilCache != null) {
             Object key = null;
@@ -85,7 +85,7 @@
                 } catch (Exception e) {}
             } else {
                 // no LRU, try looping through the keySet to see if we find the specified index...
-                Iterator ksIter = utilCache.cacheLineTable.keySet().iterator();
+                Iterator<?> ksIter = utilCache.cacheLineTable.keySet().iterator();
                 int curNum = 0;
 
                 while (ksIter.hasNext()) {
@@ -139,7 +139,7 @@
             request.setAttribute("_ERROR_MESSAGE_", errMsg);
             return "error";
         }
-        UtilCache utilCache = UtilCache.findCache(name);
+        UtilCache<?, ?> utilCache = UtilCache.findCache(name);
 
         if (utilCache != null) {
             utilCache.clear();
@@ -233,7 +233,7 @@
             expireTime = Long.valueOf(expireTimeStr);
         } catch (Exception e) {}
 
-        UtilCache utilCache = UtilCache.findCache(name);
+        UtilCache<?, ?> utilCache = UtilCache.findCache(name);
 
         if (utilCache != null) {
             if (maxSize != null)

Modified: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java?rev=833731&r1=833730&r2=833731&view=diff
==============================================================================
--- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java (original)
+++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java Sat Nov  7 18:49:09 2009
@@ -42,8 +42,6 @@
 import java.util.Set;
 import java.util.TreeSet;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
 import javax.xml.parsers.ParserConfigurationException;
 
 import javolution.util.FastList;
@@ -55,7 +53,6 @@
 import org.ofbiz.base.util.GeneralException;
 import org.ofbiz.base.util.StringUtil;
 import org.ofbiz.base.util.UtilDateTime;
-import org.ofbiz.base.util.UtilHttp;
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.UtilPlist;
 import org.ofbiz.base.util.UtilProperties;
@@ -647,11 +644,9 @@
 
         String search = (String) context.get("search");
         List<Map<String, Object>> packagesList = FastList.newInstance();
-        Iterator piter = packageNames.iterator();
         try {
-            while (piter.hasNext()) {
+            for (String pName : packageNames) {
                 Map<String, Object> packageMap = FastMap.newInstance();
-                String pName = (String) piter.next();
                 TreeSet<String> entities = entitiesByPackage.get(pName);
                 List<Map<String, Object>> entitiesList = FastList.newInstance();
                 for (String entityName: entities) {

Modified: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java?rev=833731&r1=833730&r2=833731&view=diff
==============================================================================
--- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java (original)
+++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java Sat Nov  7 18:49:09 2009
@@ -171,15 +171,13 @@
                     screenFilePath = screenFilePath.replace('\\', '/');
                     String screenFileRelativePath = screenFilePath.substring(rootComponentPath.length());
                     String screenLocation = "component://" + componentName + "/" + screenFileRelativePath;
-                    Map modelScreenMap = null;
+                    Map<String, ModelScreen> modelScreenMap = null;
                     try {
                         modelScreenMap = ScreenFactory.getScreensFromLocation(screenLocation);
                     } catch (Exception exc) {
                         throw new GeneralException(exc.getMessage());
                     }
-                    Iterator screenNames = modelScreenMap.keySet().iterator();
-                    while (screenNames.hasNext()) {
-                        String screenName = (String)screenNames.next();
+                    for (String screenName : modelScreenMap.keySet()) {
                         this.getScreenWidgetArtifactInfo(screenName, screenLocation);
                     }
                 }
@@ -190,15 +188,13 @@
                     formFilePath = formFilePath.replace('\\', '/');
                     String formFileRelativePath = formFilePath.substring(rootComponentPath.length());
                     String formLocation = "component://" + componentName + "/" + formFileRelativePath;
-                    Map modelFormMap = null;
+                    Map<String, ModelForm> modelFormMap = null;
                     try {
                         modelFormMap = FormFactory.getFormsFromLocation(formLocation, this.getEntityModelReader(), this.getDispatchContext());
                     } catch (Exception exc) {
                         throw new GeneralException(exc.getMessage());
                     }
-                    Iterator formNames = modelFormMap.keySet().iterator();
-                    while (formNames.hasNext()) {
-                        String formName = (String)formNames.next();
+                    for (String formName : modelFormMap.keySet()) {
                         this.getFormWidgetArtifactInfo(formName, formLocation);
                     }
                 }

Modified: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/FormWidgetArtifactInfo.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/FormWidgetArtifactInfo.java?rev=833731&r1=833730&r2=833731&view=diff
==============================================================================
--- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/FormWidgetArtifactInfo.java (original)
+++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/FormWidgetArtifactInfo.java Sat Nov  7 18:49:09 2009
@@ -26,14 +26,11 @@
 
 import javax.xml.parsers.ParserConfigurationException;
 
-import javolution.util.FastSet;
-
 import org.ofbiz.base.location.FlexibleLocation;
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.GeneralException;
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.UtilURL;
-import org.ofbiz.service.ModelService;
 import org.ofbiz.widget.form.ModelForm;
 import org.xml.sax.SAXException;
 
@@ -88,7 +85,7 @@
             }
 
             try {
-                ModelForm modelForm = aif.getModelForm(formName);
+                aif.getModelForm(formName);
             } catch (Exception e) {
                 Debug.logWarning("Form [" + formName + "] reference in form [" + this.formName + "] in resource [" + this.formLocation + "] does not exist!", module);
                 return;
@@ -132,7 +129,7 @@
                 continue;
             }
             try {
-                ModelService modelService = aif.getModelService(serviceName);
+                aif.getModelService(serviceName);
             } catch (GeneralException e) {
                 Debug.logWarning("Service [" + serviceName + "] reference in form [" + this.formName + "] in resource [" + this.formLocation + "] does not exist!", module);
                 continue;

Modified: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ScreenWidgetArtifactInfo.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ScreenWidgetArtifactInfo.java?rev=833731&r1=833730&r2=833731&view=diff
==============================================================================
--- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ScreenWidgetArtifactInfo.java (original)
+++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ScreenWidgetArtifactInfo.java Sat Nov  7 18:49:09 2009
@@ -33,8 +33,6 @@
 import org.ofbiz.base.util.GeneralException;
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.UtilURL;
-import org.ofbiz.service.ModelService;
-import org.ofbiz.widget.form.ModelForm;
 import org.ofbiz.widget.screen.ModelScreen;
 import org.xml.sax.SAXException;
 
@@ -89,7 +87,7 @@
                 continue;
             }
             try {
-                ModelService modelService = aif.getModelService(serviceName);
+                aif.getModelService(serviceName);
             } catch (GeneralException e) {
                 Debug.logWarning("Service [" + serviceName + "] reference in screen [" + this.screenName + "] in resource [" + this.screenLocation + "] does not exist!", module);
                 continue;
@@ -136,7 +134,7 @@
             }
 
             try {
-                ModelForm modelForm = aif.getModelForm(formName);
+                aif.getModelForm(formName);
             } catch (Exception e) {
                 Debug.logWarning("Form [" + formName + "] reference in screen [" + this.screenName + "] in resource [" + this.screenLocation + "] does not exist!", module);
                 continue;

Modified: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelManagerFactory.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelManagerFactory.java?rev=833731&r1=833730&r2=833731&view=diff
==============================================================================
--- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelManagerFactory.java (original)
+++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelManagerFactory.java Sat Nov  7 18:49:09 2009
@@ -34,7 +34,6 @@
 
 import org.ofbiz.base.component.ComponentConfig;
 import org.ofbiz.base.component.ComponentConfig.ClasspathInfo;
-import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.FileUtil;
 import org.ofbiz.base.util.GeneralException;
 import org.ofbiz.base.util.StringUtil;

Modified: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelReferences.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelReferences.java?rev=833731&r1=833730&r2=833731&view=diff
==============================================================================
--- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelReferences.java (original)
+++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelReferences.java Sat Nov  7 18:49:09 2009
@@ -34,7 +34,6 @@
 import javolution.util.FastSet;
 
 import org.ofbiz.base.component.ComponentConfig;
-import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.FileUtil;
 import org.ofbiz.base.util.UtilFormatOut;
 import org.ofbiz.base.util.UtilValidate;