From 743ec4acfb3dcc9b18db40435360f4f66a0ee278 Mon Sep 17 00:00:00 2001 From: hidetaka hasegawa <> Date: Thu, 24 Feb 2022 18:24:52 +0900 Subject: [PATCH 1/3] =?UTF-8?q?ApiFault=E3=82=92=E3=82=AD=E3=83=A3?= =?UTF-8?q?=E3=83=83=E3=83=81=E3=81=97=E3=81=A6=E4=BE=8B=E5=A4=96=E3=83=A1?= =?UTF-8?q?=E3=83=83=E3=82=BB=E3=83=BC=E3=82=B8=E3=82=92=E3=83=AD=E3=82=B0?= =?UTF-8?q?=E3=81=AB=E5=87=BA=E5=8A=9B=E3=81=99=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/embulk/output/sf_bulk_api/ForceClient.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/embulk/output/sf_bulk_api/ForceClient.java b/src/main/java/org/embulk/output/sf_bulk_api/ForceClient.java index dd9387f..66a89fb 100644 --- a/src/main/java/org/embulk/output/sf_bulk_api/ForceClient.java +++ b/src/main/java/org/embulk/output/sf_bulk_api/ForceClient.java @@ -6,6 +6,7 @@ import com.sforce.soap.partner.PartnerConnection; import com.sforce.soap.partner.Connector; +import com.sforce.soap.partner.fault.ApiFault; import com.sforce.soap.partner.sobject.SObject; import com.sforce.soap.partner.SaveResult; import com.sforce.soap.partner.UpsertResult; @@ -70,7 +71,9 @@ private void insert(final List sObjects) final SaveResult[] saveResultArray = partnerConnection.create(sObjects.toArray(new SObject[sObjects.size()])); loggingSaveErrorMessage(saveResultArray); } - catch (Exception e) { + catch (ApiFault e) { + logger.error(e.getExceptionCode().toString() + ":" + e.getExceptionMessage(), e); + } catch (Exception e) { logger.error(e.getMessage(), e); } } @@ -89,7 +92,9 @@ private void upsert(final String key, final List sObjects) } }); } - catch (Exception e) { + catch (ApiFault e) { + logger.error(e.getExceptionCode().toString() + ":" + e.getExceptionMessage(), e); + } catch (Exception e) { logger.error(e.getMessage(), e); } } @@ -100,7 +105,9 @@ private void update(final List sObjects) final SaveResult[] saveResultArray = partnerConnection.update(sObjects.toArray(new SObject[sObjects.size()])); loggingSaveErrorMessage(saveResultArray); } - catch (Exception e) { + catch (ApiFault e) { + logger.error(e.getExceptionCode().toString() + ":" + e.getExceptionMessage(), e); + } catch (Exception e) { logger.error(e.getMessage(), e); } } From d68170d7f82dae9a74e7631d0c2efa2bbe2ccc3d Mon Sep 17 00:00:00 2001 From: hidetaka hasegawa <> Date: Thu, 24 Feb 2022 18:28:37 +0900 Subject: [PATCH 2/3] =?UTF-8?q?=E3=83=90=E3=83=BC=E3=82=B8=E3=83=A7?= =?UTF-8?q?=E3=83=B3=E3=82=A2=E3=83=83=E3=83=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index ecc11bb..117ff63 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,7 @@ configurations { provided } -version = "0.1.7" +version = "0.1.8" sourceCompatibility = 1.8 targetCompatibility = 1.8 From 5323bdbf20b5818c566f3142581a99915deadc41 Mon Sep 17 00:00:00 2001 From: hidetaka hasegawa <> Date: Thu, 24 Feb 2022 18:46:22 +0900 Subject: [PATCH 3/3] =?UTF-8?q?=E3=83=AA=E3=83=95=E3=82=A1=E3=82=AF?= =?UTF-8?q?=E3=82=BF=E3=83=AA=E3=83=B3=E3=82=B0:=20=E3=83=AD=E3=82=B0?= =?UTF-8?q?=E3=82=92=E5=87=BA=E5=8A=9B=E3=81=99=E3=82=8B=E7=AE=87=E6=89=80?= =?UTF-8?q?=E3=82=92=E4=B8=80=E7=AE=87=E6=89=80=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../output/sf_bulk_api/ForceClient.java | 59 ++++++------------- .../SForceTransactionalPageOutput.java | 6 +- 2 files changed, 22 insertions(+), 43 deletions(-) diff --git a/src/main/java/org/embulk/output/sf_bulk_api/ForceClient.java b/src/main/java/org/embulk/output/sf_bulk_api/ForceClient.java index 66a89fb..ad86608 100644 --- a/src/main/java/org/embulk/output/sf_bulk_api/ForceClient.java +++ b/src/main/java/org/embulk/output/sf_bulk_api/ForceClient.java @@ -6,7 +6,6 @@ import com.sforce.soap.partner.PartnerConnection; import com.sforce.soap.partner.Connector; -import com.sforce.soap.partner.fault.ApiFault; import com.sforce.soap.partner.sobject.SObject; import com.sforce.soap.partner.SaveResult; import com.sforce.soap.partner.UpsertResult; @@ -65,51 +64,27 @@ private ConnectorConfig createConnectorConfig(final PluginTask pluginTask) return config; } - private void insert(final List sObjects) - { - try { - final SaveResult[] saveResultArray = partnerConnection.create(sObjects.toArray(new SObject[sObjects.size()])); - loggingSaveErrorMessage(saveResultArray); - } - catch (ApiFault e) { - logger.error(e.getExceptionCode().toString() + ":" + e.getExceptionMessage(), e); - } catch (Exception e) { - logger.error(e.getMessage(), e); - } + private void insert(final List sObjects) throws ConnectionException { + final SaveResult[] saveResultArray = partnerConnection.create(sObjects.toArray(new SObject[sObjects.size()])); + loggingSaveErrorMessage(saveResultArray); } - private void upsert(final String key, final List sObjects) - { - try { - final UpsertResult[] upsertResultArray = partnerConnection.upsert(key, sObjects.toArray(new SObject[sObjects.size()])); - final List upsertResults = Arrays.asList(upsertResultArray); - upsertResults.forEach(result -> { - if (!result.isSuccess()) { - final List errors = Arrays.asList(result.getErrors()) - .stream().map(e -> e.getStatusCode() + ":" + e.getMessage()) - .collect(Collectors.toList()); - logger.warn(String.join(",", errors)); - } - }); - } - catch (ApiFault e) { - logger.error(e.getExceptionCode().toString() + ":" + e.getExceptionMessage(), e); - } catch (Exception e) { - logger.error(e.getMessage(), e); - } + private void upsert(final String key, final List sObjects) throws ConnectionException { + final UpsertResult[] upsertResultArray = partnerConnection.upsert(key, sObjects.toArray(new SObject[sObjects.size()])); + final List upsertResults = Arrays.asList(upsertResultArray); + upsertResults.forEach(result -> { + if (!result.isSuccess()) { + final List errors = Arrays.asList(result.getErrors()) + .stream().map(e -> e.getStatusCode() + ":" + e.getMessage()) + .collect(Collectors.toList()); + logger.warn(String.join(",", errors)); + } + }); } - private void update(final List sObjects) - { - try { - final SaveResult[] saveResultArray = partnerConnection.update(sObjects.toArray(new SObject[sObjects.size()])); - loggingSaveErrorMessage(saveResultArray); - } - catch (ApiFault e) { - logger.error(e.getExceptionCode().toString() + ":" + e.getExceptionMessage(), e); - } catch (Exception e) { - logger.error(e.getMessage(), e); - } + private void update(final List sObjects) throws ConnectionException { + final SaveResult[] saveResultArray = partnerConnection.update(sObjects.toArray(new SObject[sObjects.size()])); + loggingSaveErrorMessage(saveResultArray); } private void loggingSaveErrorMessage(final SaveResult[] saveResultArray) diff --git a/src/main/java/org/embulk/output/sf_bulk_api/SForceTransactionalPageOutput.java b/src/main/java/org/embulk/output/sf_bulk_api/SForceTransactionalPageOutput.java index bf16ec1..bd8fb54 100644 --- a/src/main/java/org/embulk/output/sf_bulk_api/SForceTransactionalPageOutput.java +++ b/src/main/java/org/embulk/output/sf_bulk_api/SForceTransactionalPageOutput.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.List; +import com.sforce.soap.partner.fault.ApiFault; import com.sforce.soap.partner.sobject.SObject; import com.sforce.ws.ConnectionException; @@ -54,7 +55,10 @@ public void add(Page page) forceClient.action(records); } } - catch (ConnectionException e) { + catch (ApiFault e) { + logger.error(e.getExceptionCode().toString() + ":" + e.getExceptionMessage(), e); + } + catch (Exception e) { logger.error(e.getMessage(), e); } }