svn commit: r741383 - /ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java

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

svn commit: r741383 - /ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java

hansbak-2
Author: hansbak
Date: Fri Feb  6 03:03:58 2009
New Revision: 741383

URL: http://svn.apache.org/viewvc?rev=741383&view=rev
Log:
more checks on missing data, added error message

Modified:
    ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java

Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java?rev=741383&r1=741382&r2=741383&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java Fri Feb  6 03:03:58 2009
@@ -682,11 +682,19 @@
                  String combinedName = dataResource.getString("objectInfo");
                     if ("URL_RESOURCE".equals(dataResource.getString("dataResourceTypeId")) && UtilValidate.isNotEmpty(combinedName) && combinedName.startsWith("component://")) {
                      modelScreen = ScreenFactory.getScreenFromLocation(combinedName);
-                    } else { // stored in  a single file
+                    } else { // stored in  a single file, long or short text
                      Document screenXml = UtilXml.readXmlDocument(getDataResourceText(dataResource, targetMimeTypeId, locale, templateContext, delegator, cache), true);
-                     modelScreen = (ModelScreen) ScreenFactory.readScreenDocument(screenXml, "DataResourceId: " + dataResource.getString("dataResourceId")).entrySet().iterator().next().getValue();
+                     Map modelScreenMap = ScreenFactory.readScreenDocument(screenXml, "DataResourceId: " + dataResource.getString("dataResourceId"));
+                     if (UtilValidate.isNotEmpty(modelScreenMap)) {
+                     Map.Entry entry = (Map.Entry) (modelScreenMap.entrySet().iterator().next()); // get first entry, only one screen allowed per file
+                     modelScreen = (ModelScreen) entry.getValue();
+                     }
+                    }
+                    if (UtilValidate.isNotEmpty(modelScreen)) {
+                     modelScreen.renderScreenString(out, context, renderer);
+                    } else {
+                        throw new GeneralException("The dataResource file [" + dataResourceId + "] could not be found");
                     }
-                    modelScreen.renderScreenString(out, context, renderer);
                 } catch (SAXException e) {
                     throw new GeneralException("Error rendering Screen template", e);
                 } catch (ParserConfigurationException e) {