details:   https://code.openbravo.com/erp/devel/pi/rev/43a1d064d9c4
changeset: 17695:43a1d064d9c4
user:      Shankar Balachandran <shankar.balachandran <at> openbravo.com>
date:      Thu Aug 09 17:37:00 2012 +0530
summary:   Related to issue 21246 : Null Pointer Exception while installing 
module

Installing a module with wrong source.path configuration now shows NPE.
Fixed that to show 'Invalid source path' when the folder does not exist.

diffstat:

 src-db/database/sourcedata/AD_MESSAGE.xml                  |  11 +++++++++++
 src/org/openbravo/erpCommon/ad_forms/ModuleManagement.java |  10 ++++++++--
 2 files changed, 19 insertions(+), 2 deletions(-)

diffs (62 lines):

diff -r 78e4e8656a9d -r 43a1d064d9c4 src-db/database/sourcedata/AD_MESSAGE.xml
--- a/src-db/database/sourcedata/AD_MESSAGE.xml Thu Aug 16 13:58:02 2012 +0200
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml Thu Aug 09 17:37:00 2012 +0530
@@ -17807,6 +17807,17 @@
 <!--7FD28F8FE35B492FA9200FF14D0A7749-->  
<AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--7FD28F8FE35B492FA9200FF14D0A7749--></AD_MESSAGE>
 
+<!--8045FEA4D98F4B41AB5DF8068CA19692--><AD_MESSAGE>
+<!--8045FEA4D98F4B41AB5DF8068CA19692-->  
<AD_MESSAGE_ID><![CDATA[8045FEA4D98F4B41AB5DF8068CA19692]]></AD_MESSAGE_ID>
+<!--8045FEA4D98F4B41AB5DF8068CA19692-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--8045FEA4D98F4B41AB5DF8068CA19692-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--8045FEA4D98F4B41AB5DF8068CA19692-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--8045FEA4D98F4B41AB5DF8068CA19692-->  
<VALUE><![CDATA[WrongPathError]]></VALUE>
+<!--8045FEA4D98F4B41AB5DF8068CA19692-->  <MSGTEXT><![CDATA[Invalid source 
path]]></MSGTEXT>
+<!--8045FEA4D98F4B41AB5DF8068CA19692-->  <MSGTYPE><![CDATA[E]]></MSGTYPE>
+<!--8045FEA4D98F4B41AB5DF8068CA19692-->  
<AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--8045FEA4D98F4B41AB5DF8068CA19692--></AD_MESSAGE>
+
 <!--804D6F47FC0041C09F86F21DDE1FFF4C--><AD_MESSAGE>
 <!--804D6F47FC0041C09F86F21DDE1FFF4C-->  
<AD_MESSAGE_ID><![CDATA[804D6F47FC0041C09F86F21DDE1FFF4C]]></AD_MESSAGE_ID>
 <!--804D6F47FC0041C09F86F21DDE1FFF4C-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
diff -r 78e4e8656a9d -r 43a1d064d9c4 
src/org/openbravo/erpCommon/ad_forms/ModuleManagement.java
--- a/src/org/openbravo/erpCommon/ad_forms/ModuleManagement.java        Thu Aug 
16 13:58:02 2012 +0200
+++ b/src/org/openbravo/erpCommon/ad_forms/ModuleManagement.java        Thu Aug 
09 17:37:00 2012 +0530
@@ -82,6 +82,7 @@
 import org.openbravo.erpCommon.utility.NavigationBar;
 import org.openbravo.erpCommon.utility.OBError;
 import org.openbravo.erpCommon.utility.OBErrorBuilder;
+import org.openbravo.base.exception.OBException;
 import org.openbravo.erpCommon.utility.SQLReturnObject;
 import org.openbravo.erpCommon.utility.ToolBar;
 import org.openbravo.erpCommon.utility.Utility;
@@ -1097,7 +1098,7 @@
       return;
     }
 
-    boolean localChanges = verifyLocalChanges();
+    boolean localChanges = verifyLocalChanges(vars);
     if (localChanges) {
       final PrintWriter out = response.getWriter();
       final String discardlc[] = {};
@@ -2605,7 +2606,7 @@
   /**
    * Checks if there are local changes in the application
    */
-  private boolean verifyLocalChanges() {
+  private boolean verifyLocalChanges(VariablesSecureApp vars){
     long t1 = System.currentTimeMillis();
     Connection connection = OBDal.getInstance().getConnection();
     PreparedStatement ps = null;
@@ -2631,6 +2632,11 @@
     String sourcePath = 
OBPropertiesProvider.getInstance().getOpenbravoProperties()
         .getProperty("source.path");
     File sources = new File(sourcePath);
+    //Added file exists condition to check invalid source path
+    if(!sources.exists()
+    {
+      throw new 
OBException(Utility.messageBD(this,"WrongPathError",vars.getLanguage()));
+    }
     File model = new File(sources, "src-db/database/model/tables");
     if (model.exists()) {
       modelFiles.add(model);

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to