From c4c3e348b6031a9340c2dee1b67b16c11d4183d7 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Mon, 20 Dec 2021 04:25:59 +0100 Subject: [PATCH] IDEMPIERE-5107 Can't 2pack zip for Window Role - improve showing error messages (#1066) --- .../pipo2/handler/CommonTranslationHandler.java | 3 ++- .../pipo2/handler/ImpFormatElementHandler.java | 3 ++- .../pipo2/handler/MenuElementHandler.java | 3 ++- .../handler/PrintFormatElementHandler.java | 3 ++- .../pipo2/handler/ReportViewElementHandler.java | 10 ++++++---- .../pipo2/handler/RoleElementHandler.java | 17 +++++++++-------- .../pipo2/handler/TabElementHandler.java | 3 ++- .../webui/panel/action/ExportAction.java | 3 +-- 8 files changed, 26 insertions(+), 19 deletions(-) diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/CommonTranslationHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/CommonTranslationHandler.java index 8febb967a7..2150f5693c 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/CommonTranslationHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/CommonTranslationHandler.java @@ -2,6 +2,7 @@ package org.adempiere.pipo2.handler; import java.sql.PreparedStatement; import java.sql.ResultSet; +import java.sql.SQLException; import java.util.ArrayList; import java.util.HashMap; import java.util.logging.Level; @@ -129,7 +130,7 @@ public class CommonTranslationHandler extends AbstractElementHandler implements if(pstm.executeUpdate()<0){ throw new SAXException(); } - } catch (Exception e) { + } catch (SQLException e) { throw new DBException(e); } finally { DB.close(pstm); diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ImpFormatElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ImpFormatElementHandler.java index 9e884bbf79..75c2b89aff 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ImpFormatElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ImpFormatElementHandler.java @@ -18,6 +18,7 @@ package org.adempiere.pipo2.handler; import java.sql.PreparedStatement; import java.sql.ResultSet; +import java.sql.SQLException; import java.util.List; import java.util.logging.Level; @@ -120,7 +121,7 @@ public class ImpFormatElementHandler extends AbstractElementHandler { createImpFormatRow(ctx, document, rs .getInt("AD_ImpFormat_Row_ID")); } - } catch (Exception e) { + } catch (SQLException e) { log.log(Level.SEVERE, "ImpFormat", e); throw new DatabaseAccessException("Failed to export Import Format.", e); } finally { diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/MenuElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/MenuElementHandler.java index 33e5eaac65..b31bb77a84 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/MenuElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/MenuElementHandler.java @@ -19,6 +19,7 @@ package org.adempiere.pipo2.handler; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.ResultSetMetaData; +import java.sql.SQLException; import java.util.List; import java.util.UUID; import java.util.logging.Level; @@ -157,7 +158,7 @@ public class MenuElementHandler extends AbstractElementHandler { oldseqNo = seqNo; } - } catch (Exception e) { + } catch (SQLException e) { throw new DBException(e); } finally { DB.close(rs, pstmt); diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/PrintFormatElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/PrintFormatElementHandler.java index 4d1ffa819a..ee23b91321 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/PrintFormatElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/PrintFormatElementHandler.java @@ -19,6 +19,7 @@ package org.adempiere.pipo2.handler; import java.sql.PreparedStatement; import java.sql.ResultSet; +import java.sql.SQLException; import java.util.List; import java.util.logging.Level; @@ -160,7 +161,7 @@ public class PrintFormatElementHandler extends AbstractElementHandler { while (rs.next()) { createItem(ctx, document, rs.getInt("AD_PrintFormatItem_ID")); } - } catch (Exception e) { + } catch (SQLException e) { throw new DBException(e); } finally { DB.close(rs, pstmt); diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ReportViewElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ReportViewElementHandler.java index 0cb5261224..8bc8e7a0dc 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ReportViewElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ReportViewElementHandler.java @@ -18,11 +18,13 @@ package org.adempiere.pipo2.handler; import java.sql.PreparedStatement; import java.sql.ResultSet; +import java.sql.SQLException; import java.util.List; import javax.xml.transform.sax.TransformerHandler; import org.adempiere.exceptions.AdempiereException; +import org.adempiere.exceptions.DBException; import org.adempiere.pipo2.AbstractElementHandler; import org.adempiere.pipo2.Element; import org.adempiere.pipo2.ElementHandler; @@ -129,8 +131,8 @@ public class ReportViewElementHandler extends AbstractElementHandler { while (rs.next()) { createReportViewCol(ctx, document, rs.getInt("AD_ReportView_Col_ID")); } - } catch (Exception e) { - throw new AdempiereException(e); + } catch (SQLException e) { + throw new DBException(e); } finally { DB.close(rs, pstmt); } @@ -145,8 +147,8 @@ public class ReportViewElementHandler extends AbstractElementHandler { while (rs.next()) { createReportViewColumn(ctx, document, AD_ReportView_ID, rs.getInt("AD_Column_ID")); } - } catch (Exception e) { - throw new AdempiereException(e); + } catch (SQLException e) { + throw new DBException(e); } finally { DB.close(rs, pstmt); } diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/RoleElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/RoleElementHandler.java index 837f49b4fc..b121d9bc73 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/RoleElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/RoleElementHandler.java @@ -18,6 +18,7 @@ package org.adempiere.pipo2.handler; import java.sql.PreparedStatement; import java.sql.ResultSet; +import java.sql.SQLException; import java.util.List; import java.util.logging.Level; @@ -131,7 +132,7 @@ public class RoleElementHandler extends AbstractElementHandler { while (rs.next()) { createOrgAccess(ctx, document, rs.getInt("AD_Org_ID"), rs.getInt("AD_Role_ID")); } - } catch (Exception e) { + } catch (SQLException e) { log.log(Level.SEVERE, "AD_Role_OrgAccess", e); throw new DatabaseAccessException("Failed to export organization role access."); } finally { @@ -150,7 +151,7 @@ public class RoleElementHandler extends AbstractElementHandler { while (rs.next()) { createUserRole(ctx, document, rs.getInt("AD_User_ID"), rs.getInt("AD_Role_ID"), rs.getInt("AD_Org_ID")); } - } catch (Exception e) { + } catch (SQLException e) { log.log(Level.SEVERE, "AD_User_Roles", e); throw new DatabaseAccessException("Failed to export user role assignment."); } finally { @@ -168,7 +169,7 @@ public class RoleElementHandler extends AbstractElementHandler { while (rs.next()) { createWindowAccess(ctx, document, rs.getInt("AD_Window_ID"), rs.getInt("AD_Role_ID")); } - } catch (Exception e) { + } catch (SQLException e) { log.log(Level.SEVERE, "AD_Window_Access", e); throw new DatabaseAccessException("Failed to export window access."); } finally { @@ -185,7 +186,7 @@ public class RoleElementHandler extends AbstractElementHandler { while (rs.next()) { createProcessAccess(ctx, document, rs.getInt("AD_Process_ID"), rs.getInt("AD_Role_ID")); } - } catch (Exception e) { + } catch (SQLException e) { log.log(Level.SEVERE, "AD_Process_Access", e); throw new DatabaseAccessException("Failed to export process access."); } finally { @@ -202,7 +203,7 @@ public class RoleElementHandler extends AbstractElementHandler { while (rs.next()) { createFormAccess(ctx, document, rs.getInt("AD_Form_ID"), rs.getInt("AD_Role_ID")); } - } catch (Exception e) { + } catch (SQLException e) { log.log(Level.SEVERE, "AD_Form_Access", e); throw new DatabaseAccessException("Failed to export form access."); } finally { @@ -219,7 +220,7 @@ public class RoleElementHandler extends AbstractElementHandler { while (rs.next()) { createWorkflowAccess(ctx, document, rs.getInt("AD_Workflow_ID"), rs.getInt("AD_Role_ID")); } - } catch (Exception e) { + } catch (SQLException e) { log.log(Level.SEVERE, "AD_Workflow_Access", e); throw new DatabaseAccessException("Failed to export workflow access."); } finally { @@ -236,7 +237,7 @@ public class RoleElementHandler extends AbstractElementHandler { while (rs.next()) { createTaskAccess(ctx, document, rs.getInt("AD_Task_ID"), rs.getInt("AD_Role_ID")); } - } catch (Exception e) { + } catch (SQLException e) { log.log(Level.SEVERE, "AD_Task_Access", e); throw new DatabaseAccessException("Failed to export task access."); } finally { @@ -253,7 +254,7 @@ public class RoleElementHandler extends AbstractElementHandler { while (rs.next()) { createInfoWindowAccess(ctx, document, rs.getInt("AD_InfoWindow_ID"), rs.getInt("AD_Role_ID")); } - } catch (Exception e) { + } catch (SQLException e) { log.log(Level.SEVERE, "AD_InfoWindow_Access", e); throw new DatabaseAccessException("Failed to export InfoWindow access."); } finally { diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/TabElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/TabElementHandler.java index 12904daccb..83642d1878 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/TabElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/TabElementHandler.java @@ -18,6 +18,7 @@ package org.adempiere.pipo2.handler; import java.sql.PreparedStatement; import java.sql.ResultSet; +import java.sql.SQLException; import java.util.List; import java.util.logging.Level; @@ -138,7 +139,7 @@ public class TabElementHandler extends AbstractElementHandler { createField(ctx, document, rs.getInt("AD_Field_ID")); } } - catch (Exception e) + catch (SQLException e) { log.log(Level.SEVERE,e.getLocalizedMessage(), e); throw new DatabaseAccessException("Failed to export window tab", e); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/ExportAction.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/ExportAction.java index b2daee0ec4..70ce7eddb9 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/ExportAction.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/ExportAction.java @@ -23,7 +23,6 @@ import java.util.Set; import org.adempiere.base.IGridTabExporter; import org.adempiere.base.equinox.EquinoxExtensionLocator; -import org.adempiere.exceptions.AdempiereException; import org.adempiere.webui.AdempiereWebUI; import org.adempiere.webui.LayoutUtils; import org.adempiere.webui.adwindow.AbstractADWindowContent; @@ -342,7 +341,7 @@ public class ExportAction implements EventListener media = new AMedia(exporter.getSuggestedFileName(panel.getActiveGridTab()), null, exporter.getContentType(), file, true); Filedownload.save(media); } catch (Exception e) { - throw new AdempiereException(e); + FDialog.error(0, winExportFile, e.getLocalizedMessage()); } finally { if (winExportFile != null) winExportFile.onClose();