details:   https://code.openbravo.com/erp/devel/pi/rev/0bdd29a50fcc
changeset: 18079:0bdd29a50fcc
user:      Shankar Balachandran <shankar.balachandran <at> openbravo.com>
date:      Fri Sep 28 12:59:32 2012 +0200
summary:   Fixes Issue 0010979 : Display Error for unparsed XML Files.

In Import translation process, throws an exception when there are unparsable 
files.

diffstat:

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

diffs (57 lines):

diff -r e952e0c0f83e -r 0bdd29a50fcc src-db/database/sourcedata/AD_MESSAGE.xml
--- a/src-db/database/sourcedata/AD_MESSAGE.xml Fri Sep 28 14:37:39 2012 +0200
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml Fri Sep 28 12:59:32 2012 +0200
@@ -17873,6 +17873,18 @@
 <!--7DB7D480F58F4D3BB81F13B6BDE62AE5-->  
<AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--7DB7D480F58F4D3BB81F13B6BDE62AE5--></AD_MESSAGE>
 
+<!--7DE20AA77B0341F9B1816B7DF908A2B2--><AD_MESSAGE>
+<!--7DE20AA77B0341F9B1816B7DF908A2B2-->  
<AD_MESSAGE_ID><![CDATA[7DE20AA77B0341F9B1816B7DF908A2B2]]></AD_MESSAGE_ID>
+<!--7DE20AA77B0341F9B1816B7DF908A2B2-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--7DE20AA77B0341F9B1816B7DF908A2B2-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--7DE20AA77B0341F9B1816B7DF908A2B2-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--7DE20AA77B0341F9B1816B7DF908A2B2-->  
<VALUE><![CDATA[ERROR_PARSE_FILE]]></VALUE>
+<!--7DE20AA77B0341F9B1816B7DF908A2B2-->  <MSGTEXT><![CDATA[Error parsing files 
: %s. Please fix them and run the process again.]]></MSGTEXT>
+<!--7DE20AA77B0341F9B1816B7DF908A2B2-->  <MSGTIP><![CDATA[Error Parsing 
Files]]></MSGTIP>
+<!--7DE20AA77B0341F9B1816B7DF908A2B2-->  <MSGTYPE><![CDATA[E]]></MSGTYPE>
+<!--7DE20AA77B0341F9B1816B7DF908A2B2-->  
<AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--7DE20AA77B0341F9B1816B7DF908A2B2--></AD_MESSAGE>
+
 <!--7E3E5C3B752A4026A78ADDFA826E4A1C--><AD_MESSAGE>
 <!--7E3E5C3B752A4026A78ADDFA826E4A1C-->  
<AD_MESSAGE_ID><![CDATA[7E3E5C3B752A4026A78ADDFA826E4A1C]]></AD_MESSAGE_ID>
 <!--7E3E5C3B752A4026A78ADDFA826E4A1C-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
diff -r e952e0c0f83e -r 0bdd29a50fcc 
src/org/openbravo/erpCommon/ad_forms/TranslationManager.java
--- a/src/org/openbravo/erpCommon/ad_forms/TranslationManager.java      Fri Sep 
28 14:37:39 2012 +0200
+++ b/src/org/openbravo/erpCommon/ad_forms/TranslationManager.java      Fri Sep 
28 12:59:32 2012 +0200
@@ -36,6 +36,7 @@
 import org.apache.commons.betwixt.io.BeanWriter;
 import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
+import org.openbravo.base.exception.OBException;
 import org.openbravo.base.session.OBPropertiesProvider;
 import org.openbravo.database.ConnectionProvider;
 import org.openbravo.erpCommon.ad_process.buildStructure.Build;
@@ -246,7 +247,13 @@
       for (int i = 0; i < tables.length; i++)
         importTrlFile(cp, directory, AD_Client_ID, AD_Language, tables[i].c);
       importContributors(cp, directory, AD_Language);
-    } catch (final Exception e) {
+    } catch (OBException e) {
+      myMessage.setType("Error");
+      String message = String.format(BasicUtility.messageBD(cp, 
"ERROR_PARSE_FILE", UILanguage),
+          e.getMessage());
+      myMessage.setMessage(BasicUtility.messageBD(cp, message, UILanguage));
+      return myMessage;
+    } catch (Exception e) {
       log4j.error(e.toString());
       myMessage.setType("Error");
       myMessage.setMessage(BasicUtility.messageBD(cp, "Error", UILanguage));
@@ -633,7 +640,7 @@
       return "";
     } catch (final Exception e) {
       log4j.error("importTrlFile - error parsing file: " + fileName, e);
-      return e.toString();
+      throw new OBException(fileName);
     }
   }
 

------------------------------------------------------------------------------
Got visibility?
Most devs has no idea what their production app looks like.
Find out how fast your code is with AppDynamics Lite.
http://ad.doubleclick.net/clk;262219671;13503038;y?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to