From bc3a91919e6da7a5b788b309a340a2f97411e111 Mon Sep 17 00:00:00 2001 From: Manuel Soulier Date: Fri, 1 Dec 2023 19:06:28 +0100 Subject: [PATCH] fix: bug in not scalable case for drop table and export --- .../arc/ws/services/importServlet/dao/ClientDao.java | 11 ++--------- .../arc/ws/services/importServlet/dao/ServiceDao.java | 11 +++++++---- .../ws/services/importServlet/dao/ClientDaoTest.java | 1 - 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/arc-ws/src/main/java/fr/insee/arc/ws/services/importServlet/dao/ClientDao.java b/arc-ws/src/main/java/fr/insee/arc/ws/services/importServlet/dao/ClientDao.java index d4a044d85..041016664 100644 --- a/arc-ws/src/main/java/fr/insee/arc/ws/services/importServlet/dao/ClientDao.java +++ b/arc-ws/src/main/java/fr/insee/arc/ws/services/importServlet/dao/ClientDao.java @@ -440,13 +440,12 @@ public void dropTable(String clientTable) { } public void dropTable(int connectionIndex, String clientTable) { - if (StringUtils.isBlank(clientTable)) { - return; - } UtilitaireDao.get(connectionIndex).dropTable(connection, clientTable); } public void dropTable(TableToRetrieve table) { + + dropTable(table.getTableName()); if (table.getNod().equals(ArcDatabase.EXECUTOR)) { int numberOfExecutorNods = ArcDatabase.numberOfExecutorNods(); @@ -454,8 +453,6 @@ public void dropTable(TableToRetrieve table) { .getIndex() + numberOfExecutorNods; executorConnectionId++) { dropTable(executorConnectionId, table.getTableName()); } - } else { - dropTable(0, table.getTableName()); } } @@ -553,10 +550,6 @@ public void deleteFromTrackTable(String tableName) throws ArcException { UtilitaireDao.get(0).executeImmediate(connection, query); } - public void setConnection(Connection connection) { - this.connection = connection; - } - public long getTimestamp() { return timestamp; } diff --git a/arc-ws/src/main/java/fr/insee/arc/ws/services/importServlet/dao/ServiceDao.java b/arc-ws/src/main/java/fr/insee/arc/ws/services/importServlet/dao/ServiceDao.java index 62ce0bb68..60494f05e 100644 --- a/arc-ws/src/main/java/fr/insee/arc/ws/services/importServlet/dao/ServiceDao.java +++ b/arc-ws/src/main/java/fr/insee/arc/ws/services/importServlet/dao/ServiceDao.java @@ -13,14 +13,16 @@ public class ServiceDao { public static void execQueryExportDataToResponse(OutputStream os, TableToRetrieve table, boolean csvExportFormat) throws ArcException { - + + int numberOfExecutorNods = ArcDatabase.numberOfExecutorNods(); + if (csvExportFormat) { try(GZIPOutputStream goz=new GZIPOutputStream(os);) { - if (table.getNod().equals(ArcDatabase.EXECUTOR)) + + if (table.getNod().equals(ArcDatabase.EXECUTOR) && numberOfExecutorNods>0) { - int numberOfExecutorNods = ArcDatabase.numberOfExecutorNods(); for (int executorConnectionId = ArcDatabase.EXECUTOR.getIndex(); executorConnectionId < ArcDatabase.EXECUTOR .getIndex() + numberOfExecutorNods; executorConnectionId++) { UtilitaireDao.get(executorConnectionId).exporting(null, table.getTableName(), goz, csvExportFormat); @@ -36,7 +38,8 @@ public static void execQueryExportDataToResponse(OutputStream os, TableToRetriev } else { - if (table.getNod().equals(ArcDatabase.EXECUTOR)) + // binary transfer cannot be scaled + if (numberOfExecutorNods>0) { throw new ArcException(ArcExceptionMessage.WS_RETRIEVE_DATA_SCALABLE_TABLE_MUST_BE_EXPORT_IN_CSV); } diff --git a/arc-ws/src/test/java/fr/insee/arc/ws/services/importServlet/dao/ClientDaoTest.java b/arc-ws/src/test/java/fr/insee/arc/ws/services/importServlet/dao/ClientDaoTest.java index c991ab6be..7aa657830 100644 --- a/arc-ws/src/test/java/fr/insee/arc/ws/services/importServlet/dao/ClientDaoTest.java +++ b/arc-ws/src/test/java/fr/insee/arc/ws/services/importServlet/dao/ClientDaoTest.java @@ -13,7 +13,6 @@ import fr.insee.arc.core.dataobjects.ArcDatabase; import fr.insee.arc.core.dataobjects.ArcPreparedStatementBuilder; -import fr.insee.arc.core.dataobjects.ViewEnum; import fr.insee.arc.utils.dao.SQL; import fr.insee.arc.utils.dao.UtilitaireDao; import fr.insee.arc.utils.exception.ArcException;