details:   /erp/devel/pi/rev/6c6935b5ba06
changeset: 6958:6c6935b5ba06
user:      Asier Lostalé <asier.lostale <at> openbravo.com>
date:      Thu Apr 08 15:41:50 2010 +0200
summary:   fixed issue 10068: URL links doesn't work if they contain protocol

diffstat:

 src/org/openbravo/erpCommon/modules/ModuleTree.java            |  35 ++++++---
 src/org/openbravo/erpCommon/modules/ModuleTreeDescription.srpt |   4 +-
 src/org/openbravo/erpCommon/modules/ModuleTree_data.xsql       |   4 +-
 3 files changed, 28 insertions(+), 15 deletions(-)

diffs (101 lines):

diff -r 8abd2ad43256 -r 6c6935b5ba06 
src/org/openbravo/erpCommon/modules/ModuleTree.java
--- a/src/org/openbravo/erpCommon/modules/ModuleTree.java       Thu Apr 08 
14:10:42 2010 +0200
+++ b/src/org/openbravo/erpCommon/modules/ModuleTree.java       Thu Apr 08 
15:41:50 2010 +0200
@@ -20,6 +20,7 @@
 
 import javax.servlet.ServletException;
 
+import org.apache.log4j.Logger;
 import org.openbravo.base.HttpBaseServlet;
 import org.openbravo.data.FieldProvider;
 import org.openbravo.erpCommon.utility.FieldProviderFactory;
@@ -33,6 +34,7 @@
  * It implements GenericTree, detailed description is in that API doc.
  */
 public class ModuleTree extends GenericTree {
+  private final static Logger log4j = Logger.getLogger(ModuleTree.class);
 
   /**
    * Constructor to generate a root tree
@@ -103,24 +105,35 @@
    */
   public String getHTMLDescription(String node) {
     try {
+      ModuleTreeData[] moduleDescription = 
ModuleTreeData.selectDescription(conn, lang, node);
+      addLinks(moduleDescription, true);
+      String discard[] = { "" };
+      if (moduleDescription != null && moduleDescription.length > 0) {
+        if (moduleDescription[0].linkname != null && 
!moduleDescription[0].linkname.equals("")) {
+          moduleDescription[0].statusName = "";
+        }
+        if (moduleDescription[0].updateAvailable == null
+            || moduleDescription[0].updateAvailable.equals("")) {
+          discard[0] = "update";
+        }
 
-      ModuleTreeData[] data = ModuleTreeData.selectDescription(conn, lang, 
node);
-      addLinks(data, true);
-      String discard[] = { "" };
-      if (data != null && data.length > 0 && data[0].linkname != null
-          && !data[0].linkname.equals(""))
-        data[0].statusName = "";
-      if (data != null && data.length > 0
-          && (data[0].updateAvailable == null || 
data[0].updateAvailable.equals("")))
-        discard[0] = "update";
+        String url = moduleDescription[0].url;
+        if (url != null && !url.isEmpty()) {
+          if (!url.matches("^[a-z]+://.+")) {
+            // url without protocol: infer http
+            url = "http://"; + url;
+          }
+          moduleDescription[0].url = url;
+        }
+      }
 
       XmlDocument xmlDocument = xmlEngine.readXmlTemplate(
           "org/openbravo/erpCommon/modules/ModuleTreeDescription", 
discard).createXmlDocument();
-      xmlDocument.setData("structureDesc", data);
+      xmlDocument.setData("structureDesc", moduleDescription);
       return xmlDocument.print();
 
     } catch (Exception e) {
-      e.printStackTrace();
+      log4j.error("Error obtaining module description. Module ID:" + node, e);
       return "";
     }
   }
diff -r 8abd2ad43256 -r 6c6935b5ba06 
src/org/openbravo/erpCommon/modules/ModuleTreeDescription.srpt
--- a/src/org/openbravo/erpCommon/modules/ModuleTreeDescription.srpt    Thu Apr 
08 14:10:42 2010 +0200
+++ b/src/org/openbravo/erpCommon/modules/ModuleTreeDescription.srpt    Thu Apr 
08 15:41:50 2010 +0200
@@ -12,7 +12,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2008 Openbravo SLU 
+ * All portions are Copyright (C) 2008-2010 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -36,7 +36,7 @@
       <td>Author</td><td id="author">xxAuthor</td>
     </tr>
     <tr>
-      <td>URL</td><td id="urlLink"><a class="LabelLink_noicon" href="#" 
onclick="openLink('http://xx', '_blank');return false;" id="url"></a></td>
+      <td>URL</td><td id="urlLink"><a class="LabelLink_noicon" href="#" 
onclick="openLink('xx', '_blank');return false;" id="url"></a></td>
     </tr>
     <FIELD_TMP id="update">
       <tr>
diff -r 8abd2ad43256 -r 6c6935b5ba06 
src/org/openbravo/erpCommon/modules/ModuleTree_data.xsql
--- a/src/org/openbravo/erpCommon/modules/ModuleTree_data.xsql  Thu Apr 08 
14:10:42 2010 +0200
+++ b/src/org/openbravo/erpCommon/modules/ModuleTree_data.xsql  Thu Apr 08 
15:41:50 2010 +0200
@@ -186,8 +186,8 @@
                  COALESCE(MI.Description, T.Description, M.Description) as 
Description,
                  COALESCE(MI.help, T.help, M.Help) as Help,
                  COALESCE(MI.Author, M.author) as author,
-                 COALESCE(MI.url, MI.url) as url,
-                 COALESCE(MI.status, MI.status) as status,
+                 COALESCE(MI.url, M.url) as url,
+                 COALESCE(MI.status, M.status) as status,
                  M.Update_Available,
                  M.AD_Module_ID as Node_ID,
                  COALESCE(RT.Name, R.Name) as Status_Name,

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to