* [ 1760867 ] Pack In failed to detect some sql execution error

* More verbose error message
This commit is contained in:
Heng Sin Low 2007-07-26 17:52:24 +00:00
parent f8a481e2a4
commit b7fe736339
14 changed files with 41 additions and 30 deletions

View File

@ -114,7 +114,6 @@ public class PackInHandler extends DefaultHandler {
private String m_UpdateMode = "true"; private String m_UpdateMode = "true";
private String packageDirectory = null; private String packageDirectory = null;
private String m_DatabaseType = "Oracle"; private String m_DatabaseType = "Oracle";
private boolean adempiereAD = false;
private int m_AD_Client_ID = 0; private int m_AD_Client_ID = 0;
private int AD_Package_Imp_ID=0; private int AD_Package_Imp_ID=0;
private int AD_Package_Imp_Inst_ID=0; private int AD_Package_Imp_Inst_ID=0;
@ -262,7 +261,6 @@ public class PackInHandler extends DefaultHandler {
// adempiereAD. // adempiereAD.
if (elementValue.equals("adempiereAD")) { if (elementValue.equals("adempiereAD")) {
log.info("adempiereAD updateMode="+m_UpdateMode); log.info("adempiereAD updateMode="+m_UpdateMode);
adempiereAD = true;
//Start package log //Start package log
hd_document.startElement("","","adempiereDocument",attsOut); hd_document.startElement("","","adempiereDocument",attsOut);
hd_document.startElement("","","header",attsOut); hd_document.startElement("","","header",attsOut);
@ -642,6 +640,9 @@ public class PackInHandler extends DefaultHandler {
} }
catch (Exception e) catch (Exception e)
{} {}
//reset
setupHandlers();
} else { } else {
Element e = stack.pop(); Element e = stack.pop();
ElementHandler handler = handlers.get(elementValue); ElementHandler handler = handlers.get(elementValue);

View File

@ -236,7 +236,7 @@ public class ColumnElementHandler extends AbstractElementHandler {
.get_ID(), AD_Backup_ID, Object_Status, "AD_Column", .get_ID(), AD_Backup_ID, Object_Status, "AD_Column",
get_IDWithColumn(ctx, "AD_Table", "TableName", get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Column")); "AD_Column"));
throw new POSaveFailedException("Column"); throw new POSaveFailedException("Failed to import column.");
} }
if (recreateColumn || syncDatabase) { if (recreateColumn || syncDatabase) {
@ -254,7 +254,7 @@ public class ColumnElementHandler extends AbstractElementHandler {
"ADTableNameID").toUpperCase(), "ADTableNameID").toUpperCase(),
get_IDWithColumn(ctx, "AD_Table", "TableName", atts get_IDWithColumn(ctx, "AD_Table", "TableName", atts
.getValue("ADTableNameID").toUpperCase())); .getValue("ADTableNameID").toUpperCase()));
throw new DatabaseAccessException("CreateColumn"); throw new DatabaseAccessException("Failed to create column or related constraint for " + m_Column.getColumnName());
} }
} }
} }
@ -333,6 +333,9 @@ public class ColumnElementHandler extends AbstractElementHandler {
for (int i = 0; i < statements.length; i++) { for (int i = 0; i < statements.length; i++) {
int count = DB.executeUpdate(statements[i], false, int count = DB.executeUpdate(statements[i], false,
getTrxName(ctx)); getTrxName(ctx));
if (count == -1) {
return 0;
}
no += count; no += count;
} }
} }

View File

@ -121,7 +121,7 @@ public class ImpFormatElementHandler extends AbstractElementHandler {
pstmt = null; pstmt = null;
} catch (Exception e) { } catch (Exception e) {
log.log(Level.SEVERE, "ImpFormat", e); log.log(Level.SEVERE, "ImpFormat", e);
throw new DatabaseAccessException("ImpFormat", e); throw new DatabaseAccessException("Failed to export Import Format.", e);
} finally { } finally {
try { try {
if (pstmt != null) if (pstmt != null)

View File

@ -229,11 +229,11 @@ public class PrintFormatElementHandler extends AbstractElementHandler {
if (e instanceof SAXException) if (e instanceof SAXException)
throw (SAXException) e; throw (SAXException) e;
else if (e instanceof SQLException) else if (e instanceof SQLException)
throw new DatabaseAccessException("Window", e); throw new DatabaseAccessException("Failed to export print format.", e);
else if (e instanceof RuntimeException) else if (e instanceof RuntimeException)
throw (RuntimeException) e; throw (RuntimeException) e;
else else
throw new RuntimeException("Window", e); throw new RuntimeException("Failed to export print format.", e);
} finally { } finally {
try { try {
if (pstmt != null) if (pstmt != null)

View File

@ -206,11 +206,11 @@ public class ProcessElementHandler extends AbstractElementHandler {
if (e instanceof SAXException) if (e instanceof SAXException)
throw (SAXException) e; throw (SAXException) e;
else if (e instanceof SQLException) else if (e instanceof SQLException)
throw new DatabaseAccessException("Window", e); throw new DatabaseAccessException("Failed to export process.", e);
else if (e instanceof RuntimeException) else if (e instanceof RuntimeException)
throw (RuntimeException) e; throw (RuntimeException) e;
else else
throw new RuntimeException("Window", e); throw new RuntimeException("Failed to export process.", e);
} finally { } finally {
try { try {
if (pstmtP != null) if (pstmtP != null)

View File

@ -152,11 +152,11 @@ public class ReferenceElementHandler extends AbstractElementHandler {
if (e instanceof SAXException) if (e instanceof SAXException)
throw (SAXException) e; throw (SAXException) e;
else if (e instanceof SQLException) else if (e instanceof SQLException)
throw new DatabaseAccessException("Window", e); throw new DatabaseAccessException("Failed to export Reference.", e);
else if (e instanceof RuntimeException) else if (e instanceof RuntimeException)
throw (RuntimeException) e; throw (RuntimeException) e;
else else
throw new RuntimeException("Window", e); throw new RuntimeException("Failed to export Reference.", e);
} finally { } finally {
try { try {
if (pstmt1 != null) if (pstmt1 != null)

View File

@ -258,7 +258,7 @@ public class ReferenceTableElementHandler extends AbstractElementHandler {
pstmt = null; pstmt = null;
} catch (Exception e) { } catch (Exception e) {
log.log(Level.SEVERE, e.getLocalizedMessage(), e); log.log(Level.SEVERE, e.getLocalizedMessage(), e);
throw new DatabaseAccessException("ReferenceTable", e); throw new DatabaseAccessException("Failed to export Reference Table", e);
} finally { } finally {
try { try {
if (pstmt != null) if (pstmt != null)

View File

@ -186,11 +186,11 @@ public class ReportViewElementHandler extends AbstractElementHandler {
if (e instanceof SAXException) if (e instanceof SAXException)
throw (SAXException) e; throw (SAXException) e;
else if (e instanceof SQLException) else if (e instanceof SQLException)
throw new DatabaseAccessException("Window", e); throw new DatabaseAccessException("Failed to export report view.", e);
else if (e instanceof RuntimeException) else if (e instanceof RuntimeException)
throw (RuntimeException) e; throw (RuntimeException) e;
else else
throw new RuntimeException("Window", e); throw new RuntimeException("Failed to export report view.", e);
} finally { } finally {
try { try {
if (pstmt != null) if (pstmt != null)

View File

@ -207,7 +207,7 @@ public class RoleElementHandler extends AbstractElementHandler {
catch (Exception e) { catch (Exception e) {
log.log(Level.SEVERE, "AD_Role_OrgAccess", e); log.log(Level.SEVERE, "AD_Role_OrgAccess", e);
throw new DatabaseAccessException("AD_Role_OrgAccess"); throw new DatabaseAccessException("Failed to export organization role access.");
} }
// Process user assignment access // Process user assignment access
sql = "SELECT * FROM AD_User_Roles WHERE AD_Role_ID= " + Role_id; sql = "SELECT * FROM AD_User_Roles WHERE AD_Role_ID= " + Role_id;
@ -226,7 +226,7 @@ public class RoleElementHandler extends AbstractElementHandler {
catch (Exception e) { catch (Exception e) {
log.log(Level.SEVERE, "AD_User_Roles", e); log.log(Level.SEVERE, "AD_User_Roles", e);
throw new DatabaseAccessException("AD_User_Roles"); throw new DatabaseAccessException("Failed to export user role assignment.");
} }
// Process AD_Window_Access Values // Process AD_Window_Access Values
@ -246,7 +246,7 @@ public class RoleElementHandler extends AbstractElementHandler {
catch (Exception e) { catch (Exception e) {
log.log(Level.SEVERE, "AD_Window_Access", e); log.log(Level.SEVERE, "AD_Window_Access", e);
throw new DatabaseAccessException("AD_Window_Access"); throw new DatabaseAccessException("Failed to export window access.");
} }
// Process AD_Process_Access Values // Process AD_Process_Access Values
@ -266,7 +266,7 @@ public class RoleElementHandler extends AbstractElementHandler {
catch (Exception e) { catch (Exception e) {
log.log(Level.SEVERE, "AD_Process_Access", e); log.log(Level.SEVERE, "AD_Process_Access", e);
throw new DatabaseAccessException("AD_Process_Access"); throw new DatabaseAccessException("Failed to export process access.");
} }
// Process AD_Form_Access Values // Process AD_Form_Access Values
@ -286,7 +286,7 @@ public class RoleElementHandler extends AbstractElementHandler {
catch (Exception e) { catch (Exception e) {
log.log(Level.SEVERE, "AD_Form_Access", e); log.log(Level.SEVERE, "AD_Form_Access", e);
throw new DatabaseAccessException("AD_Form_Access"); throw new DatabaseAccessException("Failed to export form access.");
} }
// Process AD_Workflow_Access Values // Process AD_Workflow_Access Values
@ -306,7 +306,7 @@ public class RoleElementHandler extends AbstractElementHandler {
catch (Exception e) { catch (Exception e) {
log.log(Level.SEVERE, "AD_Workflow_Access", e); log.log(Level.SEVERE, "AD_Workflow_Access", e);
throw new DatabaseAccessException("AD_Workflow_Access"); throw new DatabaseAccessException("Failed to export workflow access.");
} }
// Process AD_Task_Access Values // Process AD_Task_Access Values
@ -326,7 +326,7 @@ public class RoleElementHandler extends AbstractElementHandler {
catch (Exception e) { catch (Exception e) {
log.log(Level.SEVERE, "AD_Task_Access", e); log.log(Level.SEVERE, "AD_Task_Access", e);
throw new DatabaseAccessException("AD_Task_Access"); throw new DatabaseAccessException("Failed to export task access.");
} finally { } finally {
try { try {
if (pstmt != null) if (pstmt != null)

View File

@ -203,7 +203,7 @@ public class TabElementHandler extends AbstractElementHandler {
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE,e.getLocalizedMessage(), e); log.log(Level.SEVERE,e.getLocalizedMessage(), e);
throw new DatabaseAccessException("Tab", e); throw new DatabaseAccessException("Failed to export window tab", e);
} }
finally finally
{ {

View File

@ -62,7 +62,6 @@ public class TableElementHandler extends AbstractElementHandler {
packIn.addTable(tableName, id); packIn.addTable(tableName, id);
} }
if (id > 0 && isTableProcess(ctx, id)) { if (id > 0 && isTableProcess(ctx, id)) {
System.out.println("skip table, already process");
return; return;
} }

View File

@ -19,6 +19,8 @@ package org.adempiere.pipo.handler;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
@ -43,6 +45,8 @@ public class WindowElementHandler extends AbstractElementHandler {
private TabElementHandler tabHandler = new TabElementHandler(); private TabElementHandler tabHandler = new TabElementHandler();
private PreferenceElementHandler preferenceHandler = new PreferenceElementHandler(); private PreferenceElementHandler preferenceHandler = new PreferenceElementHandler();
private List<Integer> windows = new ArrayList<Integer>();
public void startElement(Properties ctx, Element element) public void startElement(Properties ctx, Element element)
throws SAXException { throws SAXException {
@ -54,6 +58,9 @@ public class WindowElementHandler extends AbstractElementHandler {
if (entitytype.equals("U") || (entitytype.equals("D") && getUpdateMode(ctx).equals("true"))) { if (entitytype.equals("U") || (entitytype.equals("D") && getUpdateMode(ctx).equals("true"))) {
String name = atts.getValue("Name"); String name = atts.getValue("Name");
int id = get_ID(ctx, "AD_Window", name); int id = get_ID(ctx, "AD_Window", name);
if (id > 0 && windows.contains(id)) {
return;
}
MWindow m_Window = new MWindow(ctx, id, getTrxName(ctx)); MWindow m_Window = new MWindow(ctx, id, getTrxName(ctx));
String Object_Status = null; String Object_Status = null;
int AD_Backup_ID = -1; int AD_Backup_ID = -1;
@ -117,6 +124,7 @@ public class WindowElementHandler extends AbstractElementHandler {
get_IDWithColumn(ctx, "AD_Table", "TableName", get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Window")); "AD_Window"));
element.recordId = m_Window.getAD_Window_ID(); element.recordId = m_Window.getAD_Window_ID();
windows.add(m_Window.getAD_Window_ID());
} else { } else {
record_log(ctx, 0, m_Window.getName(), "Window", m_Window record_log(ctx, 0, m_Window.getName(), "Window", m_Window
.get_ID(), AD_Backup_ID, Object_Status, "AD_Window", .get_ID(), AD_Backup_ID, Object_Status, "AD_Window",
@ -163,11 +171,11 @@ public class WindowElementHandler extends AbstractElementHandler {
if (e instanceof SAXException) if (e instanceof SAXException)
throw (SAXException) e; throw (SAXException) e;
else if (e instanceof SQLException) else if (e instanceof SQLException)
throw new DatabaseAccessException("Window", e); throw new DatabaseAccessException("Failed to export window.", e);
else if (e instanceof RuntimeException) else if (e instanceof RuntimeException)
throw (RuntimeException) e; throw (RuntimeException) e;
else else
throw new RuntimeException("Window", e); throw new RuntimeException("Failed to export window.", e);
} finally { } finally {
try { try {
if (pstmt != null) if (pstmt != null)
@ -200,11 +208,11 @@ public class WindowElementHandler extends AbstractElementHandler {
if (e instanceof SAXException) if (e instanceof SAXException)
throw (SAXException) e; throw (SAXException) e;
else if (e instanceof SQLException) else if (e instanceof SQLException)
throw new DatabaseAccessException("Window", e); throw new DatabaseAccessException("Failed to export window preference.", e);
else if (e instanceof RuntimeException) else if (e instanceof RuntimeException)
throw (RuntimeException) e; throw (RuntimeException) e;
else else
throw new RuntimeException("Window", e); throw new RuntimeException("Failed to export window preference.", e);
} finally { } finally {
try { try {
if (pstmt != null) if (pstmt != null)

View File

@ -238,9 +238,9 @@ public class WorkflowElementHandler extends AbstractElementHandler {
if (e instanceof SAXException) if (e instanceof SAXException)
throw (SAXException) e; throw (SAXException) e;
else if (e instanceof SQLException) else if (e instanceof SQLException)
throw new DatabaseAccessException("Workflow", e); throw new DatabaseAccessException("Failed to export workflow.", e);
else else
throw new RuntimeException("Workflow", e); throw new RuntimeException("Failed to export workflow.", e);
} finally { } finally {
try { try {
if (pstmt != null) if (pstmt != null)

View File

@ -276,7 +276,7 @@ public class MColumn extends X_AD_Column
.append(" ADD ").append(getSQLDDL()); .append(" ADD ").append(getSQLDDL());
String constraint = getConstraint(table.getTableName()); String constraint = getConstraint(table.getTableName());
if (constraint != null && constraint.length() > 0) { if (constraint != null && constraint.length() > 0) {
sql.append("; ").append("ALTER TABLE ") sql.append(DB.SQLSTATEMENT_SEPARATOR).append("ALTER TABLE ")
.append(table.getTableName()) .append(table.getTableName())
.append(" ADD ").append(constraint); .append(" ADD ").append(constraint);
} }