svn commit: r638698 - in /ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo: ArtifactInfoFactory.java ControllerRequestArtifactInfo.java ControllerViewArtifactInfo.java ScreenWidgetArtifactInfo.java

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

svn commit: r638698 - in /ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo: ArtifactInfoFactory.java ControllerRequestArtifactInfo.java ControllerViewArtifactInfo.java ScreenWidgetArtifactInfo.java

jacopoc
Author: jacopoc
Date: Tue Mar 18 21:03:10 2008
New Revision: 638698

URL: http://svn.apache.org/viewvc?rev=638698&view=rev
Log:
Improved error handling during artifact info creation.

Modified:
    ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java
    ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ControllerRequestArtifactInfo.java
    ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ControllerViewArtifactInfo.java
    ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ScreenWidgetArtifactInfo.java

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=638698&r1=638697&r2=638698&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 Tue Mar 18 21:03:10 2008
@@ -205,10 +205,18 @@
                     }
                     ControllerConfig cc = ConfigXMLReader.getControllerConfig(controllerUrl);
                     for (String requestUri: cc.requestMap.keySet()) {
-                        this.getControllerRequestArtifactInfo(controllerUrl, requestUri);
+                        try {
+                            this.getControllerRequestArtifactInfo(controllerUrl, requestUri);
+                        } catch(GeneralException e) {
+                            Debug.logWarning(e.getMessage(), module);
+                        }
                     }
                     for (String viewUri: cc.viewMap.keySet()) {
-                        this.getControllerViewArtifactInfo(controllerUrl, viewUri);
+                        try {
+                            this.getControllerViewArtifactInfo(controllerUrl, viewUri);
+                        } catch(GeneralException e) {
+                            Debug.logWarning(e.getMessage(), module);
+                        }
                     }
                 }
             }
@@ -244,7 +252,8 @@
     }
 
     public Map<String, String> getControllerViewInfoMap(URL controllerXmlUrl, String viewUri) {
-        return ConfigXMLReader.getControllerConfig(controllerXmlUrl).viewMap.get(viewUri);
+        ControllerConfig cc = ConfigXMLReader.getControllerConfig(controllerXmlUrl);
+        return cc.viewMap.get(viewUri);
     }
 
     public EntityArtifactInfo getEntityArtifactInfo(String entityName) throws GeneralException {
@@ -288,7 +297,12 @@
     public ScreenWidgetArtifactInfo getScreenWidgetArtifactInfo(String screenName, String screenLocation) throws GeneralException {
         ScreenWidgetArtifactInfo curInfo = this.allScreenInfos.get(screenLocation + "#" + screenName);
         if (curInfo == null) {
-            curInfo = new ScreenWidgetArtifactInfo(screenName, screenLocation, this);
+            try {
+                curInfo = new ScreenWidgetArtifactInfo(screenName, screenLocation, this);
+            } catch(GeneralException e) {
+                Debug.logWarning("Error loading screen [" + screenName + "] from resource [" + screenLocation + "]: " + e.toString(), module);
+                return null;
+            }
             this.allScreenInfos.put(curInfo.getUniqueId(), curInfo);
         }
         return curInfo;

Modified: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ControllerRequestArtifactInfo.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ControllerRequestArtifactInfo.java?rev=638698&r1=638697&r2=638698&view=diff
==============================================================================
--- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ControllerRequestArtifactInfo.java (original)
+++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ControllerRequestArtifactInfo.java Tue Mar 18 21:03:10 2008
@@ -24,6 +24,7 @@
 
 import javolution.util.FastSet;
 
+import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.GeneralException;
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.UtilObject;
@@ -34,6 +35,8 @@
  */
 public class ControllerRequestArtifactInfo extends ArtifactInfoBase {
     
+    public static final String module = ControllerRequestArtifactInfo.class.getName();
+
     protected URL controllerXmlUrl;
     protected String requestUri;
     
@@ -49,7 +52,11 @@
         this.requestUri = requestUri;
         
         this.requestInfoMap = aif.getControllerRequestInfoMap(controllerXmlUrl, requestUri);
-        
+  
+        if (this.requestInfoMap == null) {
+            throw new GeneralException("Controller request with name [" + requestUri + "] is not defined in controller file [" + controllerXmlUrl + "].");
+        }
+
         // populate serviceCalledByRequestEvent, requestsThatAreResponsesToThisRequest, viewsThatAreResponsesToThisRequest and related reverse maps
         
         if ("service".equals(this.requestInfoMap.get(ConfigXMLReader.EVENT_TYPE))) {

Modified: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ControllerViewArtifactInfo.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ControllerViewArtifactInfo.java?rev=638698&r1=638697&r2=638698&view=diff
==============================================================================
--- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ControllerViewArtifactInfo.java (original)
+++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ControllerViewArtifactInfo.java Tue Mar 18 21:03:10 2008
@@ -22,6 +22,7 @@
 import java.util.Map;
 import java.util.Set;
 
+import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.GeneralException;
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.UtilObject;
@@ -32,7 +33,9 @@
  *
  */
 public class ControllerViewArtifactInfo extends ArtifactInfoBase {
-    
+
+    public static final String module = ControllerViewArtifactInfo.class.getName();
+
     protected URL controllerXmlUrl;
     protected String viewUri;
     
@@ -47,6 +50,9 @@
         
         this.viewInfoMap = aif.getControllerViewInfoMap(controllerXmlUrl, viewUri);
 
+        if (this.viewInfoMap == null) {
+            throw new GeneralException("Controller view with name [" + viewUri + "] is not defined in controller file [" + controllerXmlUrl + "].");
+        }
         // populate screenCalledByThisView and reverse in aif.allViewInfosReferringToScreen
         if ("screen".equals(this.viewInfoMap.get(ConfigXMLReader.VIEW_TYPE))) {
             String fullScreenName = this.viewInfoMap.get(ConfigXMLReader.VIEW_PAGE);
@@ -54,7 +60,11 @@
                 int poundIndex = fullScreenName.indexOf('#');
                 this.screenCalledByThisView = this.aif.getScreenWidgetArtifactInfo(fullScreenName.substring(poundIndex+1), fullScreenName.substring(0, poundIndex));
                 // add the reverse association
-                UtilMisc.addToSetInMap(this, aif.allViewInfosReferringToScreen, this.screenCalledByThisView.getUniqueId());
+                if (this.screenCalledByThisView != null) {
+                    UtilMisc.addToSetInMap(this, aif.allViewInfosReferringToScreen, this.screenCalledByThisView.getUniqueId());
+                } else {
+                    Debug.logWarning("The controller view [" + this.viewUri + "] in resource [" + controllerXmlUrl + "] is pointing to a screen [" + fullScreenName.substring(poundIndex+1) + "] in resource [" + fullScreenName.substring(0, poundIndex) + "] that doesn't exists", module);
+                }
             }
         }
     }

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=638698&r1=638697&r2=638698&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 Tue Mar 18 21:03:10 2008
@@ -48,6 +48,8 @@
             throw new GeneralException(e);
         } catch (IOException e) {
             throw new GeneralException(e);
+        } catch (IllegalArgumentException e) {
+            throw new GeneralException(e);
         }
         
     }