IDEMPIERE-5965 Translation Import crashed with a wrong XML (#2152)

This commit is contained in:
Carlos Ruiz 2023-12-21 13:39:20 +01:00 committed by GitHub
parent ccbcfb1eb7
commit 03ceb5f88f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 11 deletions

View File

@ -40,6 +40,7 @@ import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamResult;
import org.adempiere.base.Core; import org.adempiere.base.Core;
import org.adempiere.exceptions.AdempiereException;
import org.compiere.Adempiere; import org.compiere.Adempiere;
import org.compiere.model.MLanguage; import org.compiere.model.MLanguage;
import org.compiere.model.MPInstance; import org.compiere.model.MPInstance;
@ -174,8 +175,7 @@ public class Translation implements IApplication
} }
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE, "importTrl", e); throw new AdempiereException(e);
return e.toString();
} }
} // importTrl } // importTrl

View File

@ -19,6 +19,7 @@ package org.compiere.install;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.logging.Level; import java.util.logging.Level;
import org.adempiere.exceptions.AdempiereException;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.Language; import org.compiere.util.Language;
@ -185,16 +186,20 @@ public class TranslationHandler extends DefaultHandler
m_sql.insert(0, m_updateSQL); m_sql.insert(0, m_updateSQL);
// Execute // Execute
int no = DB.executeUpdate(m_sql.toString(), m_trxName); try {
if (no == 1) int no = DB.executeUpdateEx(m_sql.toString(), m_trxName);
{ if (no == 1)
if (log.isLoggable(Level.FINE)) log.fine(m_sql.toString()); {
m_updateCount++; 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)) else if (qName.equals(Translation.XML_VALUE_TAG))
{ {