Author: jonesde
Date: Tue Mar 13 08:31:24 2007
New Revision: 517731

URL: http://svn.apache.org/viewvc?view=rev&rev=517731
Log:
Chagned ofbizContentUrl to not NPE when there is no request in the context; now 
tries to do its best with the standard content prefix from url.properties; this 
was happening in the Order PDF with an image URL which should probably not use 
ofbizContentUrl in the first place, but now will at least work

Modified:
    
ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/ftl/OfbizContentTransform.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/ContentUrlTag.java

Modified: 
ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/ftl/OfbizContentTransform.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/ftl/OfbizContentTransform.java?view=diff&rev=517731&r1=517730&r2=517731
==============================================================================
--- 
ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/ftl/OfbizContentTransform.java
 (original)
+++ 
ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/ftl/OfbizContentTransform.java
 Tue Mar 13 08:31:24 2007
@@ -51,7 +51,7 @@
                     try {                              
                         Environment env = Environment.getCurrentEnvironment();
                         BeanModel req = (BeanModel)env.getVariable("request");
-                        HttpServletRequest request = (HttpServletRequest) 
req.getWrappedObject();
+                        HttpServletRequest request = req == null ? null : 
(HttpServletRequest) req.getWrappedObject();
                         
                         // make the link
                         StringBuffer newURL = new StringBuffer();

Modified: 
ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/ContentUrlTag.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/ContentUrlTag.java?view=diff&rev=517731&r1=517730&r2=517731
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/ContentUrlTag.java 
(original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/ContentUrlTag.java 
Tue Mar 13 08:31:24 2007
@@ -39,6 +39,14 @@
     public static final String module = UrlTag.class.getName();
 
     public static void appendContentPrefix(HttpServletRequest request, 
StringBuffer urlBuffer) {
+        if (request == null) {
+            Debug.logWarning("WARNING: request was null in 
appendContentPrefix; this probably means this was used where it shouldn't be, 
like using ofbizContentUrl in a screen rendered through a service; using 
best-bet behavior: standard prefix from url.properties (no WebSite or security 
setting known)", module);
+            String prefix = UtilProperties.getPropertyValue("url", 
"content.url.prefix.standard");
+            if (prefix != null) {
+                urlBuffer.append(prefix.trim());
+            }
+            return;
+        }
         GenericValue webSite = WebSiteWorker.getWebSite(request);
         if (request.isSecure()) {
             if (webSite != null && 
UtilValidate.isNotEmpty(webSite.getString("secureContentPrefix"))) {


Reply via email to