[Yanel-commits] rev 55039 - public/yanel/trunk/src/impl/java/org/wyona/yanel/impl/resources

michi at wyona.com michi at wyona.com
Mon Nov 29 15:29:17 CET 2010


Author: michi
Date: 2010-11-29 15:29:16 +0100 (Mon, 29 Nov 2010)
New Revision: 55039

Modified:
   public/yanel/trunk/src/impl/java/org/wyona/yanel/impl/resources/BasicXMLResource.java
Log:
catch null pointer exception in case sub-classes are calling this method but are not implementing view descriptors

Modified: public/yanel/trunk/src/impl/java/org/wyona/yanel/impl/resources/BasicXMLResource.java
===================================================================
--- public/yanel/trunk/src/impl/java/org/wyona/yanel/impl/resources/BasicXMLResource.java	2010-11-29 13:47:41 UTC (rev 55038)
+++ public/yanel/trunk/src/impl/java/org/wyona/yanel/impl/resources/BasicXMLResource.java	2010-11-29 14:29:16 UTC (rev 55039)
@@ -117,14 +117,24 @@
 
     protected HashMap<String, ViewDescriptor> viewDescriptors;
 
+    /**
+     * Get view descriptor for a particular view id
+     * @param viewId View id
+     */
     protected ViewDescriptor getViewDescriptor(String viewId) {
         ViewDescriptor[] viewDescriptors = getViewDescriptors();
-        for (int i = 0; i < viewDescriptors.length; i++) {
-            if (viewDescriptors[i].getId().equals(viewId)) {
-                return viewDescriptors[i];
+        if (viewDescriptors != null) {
+            for (int i = 0; i < viewDescriptors.length; i++) {
+                if (viewDescriptors[i].getId().equals(viewId)) {
+                    return viewDescriptors[i];
+                }
             }
+            log.warn("No view descriptor found for view id: " + viewId);
+            return null;
+        } else {
+            log.warn("No view descriptors set (within resource configuration)!");
+            return null;
         }
-        return null;
     }
 
     /**
@@ -211,6 +221,9 @@
         return -1;
     }
 
+    /**
+     *
+     */
     public View getXMLView(String viewId, InputStream xmlInputStream) throws Exception {
         View view = new View();
         if (viewId == null) {



More information about the Yanel-commits mailing list