From 03ceb5f88f688f5aa4c305be6bee8011f3c28601 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Thu, 21 Dec 2023 13:39:20 +0100 Subject: [PATCH] IDEMPIERE-5965 Translation Import crashed with a wrong XML (#2152) --- .../src/org/compiere/install/Translation.java | 4 ++-- .../compiere/install/TranslationHandler.java | 23 +++++++++++-------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/install/Translation.java b/org.adempiere.base/src/org/compiere/install/Translation.java index a66ec4bce7..7ef4128953 100644 --- a/org.adempiere.base/src/org/compiere/install/Translation.java +++ b/org.adempiere.base/src/org/compiere/install/Translation.java @@ -40,6 +40,7 @@ import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.adempiere.base.Core; +import org.adempiere.exceptions.AdempiereException; import org.compiere.Adempiere; import org.compiere.model.MLanguage; import org.compiere.model.MPInstance; @@ -174,8 +175,7 @@ public class Translation implements IApplication } catch (Exception e) { - log.log(Level.SEVERE, "importTrl", e); - return e.toString(); + throw new AdempiereException(e); } } // importTrl diff --git a/org.adempiere.base/src/org/compiere/install/TranslationHandler.java b/org.adempiere.base/src/org/compiere/install/TranslationHandler.java index e53e9dd847..cb3f92f538 100644 --- a/org.adempiere.base/src/org/compiere/install/TranslationHandler.java +++ b/org.adempiere.base/src/org/compiere/install/TranslationHandler.java @@ -19,6 +19,7 @@ package org.compiere.install; import java.sql.Timestamp; import java.util.logging.Level; +import org.adempiere.exceptions.AdempiereException; import org.compiere.util.CLogger; import org.compiere.util.DB; import org.compiere.util.Language; @@ -185,16 +186,20 @@ public class TranslationHandler extends DefaultHandler m_sql.insert(0, m_updateSQL); // Execute - int no = DB.executeUpdate(m_sql.toString(), m_trxName); - if (no == 1) - { - if (log.isLoggable(Level.FINE)) log.fine(m_sql.toString()); - m_updateCount++; + try { + int no = DB.executeUpdateEx(m_sql.toString(), m_trxName); + if (no == 1) + { + if (log.isLoggable(Level.FINE)) log.fine(m_sql.toString()); + m_updateCount++; + } + else if (no == 0) + log.warning ("Not Found - " + m_sql.toString()); + else + log.severe ("Update Rows=" + no + " (Should be 1) - " + m_sql.toString()); + } catch (Exception e) { + throw new AdempiereException("Error: " + e.getLocalizedMessage() + " ... executing " + m_sql, e); } - else if (no == 0) - log.warning ("Not Found - " + m_sql.toString()); - else - log.severe ("Update Rows=" + no + " (Should be 1) - " + m_sql.toString()); } else if (qName.equals(Translation.XML_VALUE_TAG)) {