From 8f01af4f635801a5d319bab7f9f9f2c437f7af37 Mon Sep 17 00:00:00 2001 From: Elena Kuleshov Date: Tue, 4 Jun 2019 20:49:09 -0400 Subject: Handle 201 and 422 status codes SDC activitySpec API returns 201 for success and 422 when already exists Issue-ID: SO-1996 Signed-off-by: Kuleshov, Elena Change-Id: I75837b75cbd24f4ccfb97a07e91219b3b61453f6 --- .../main/java/org/onap/so/asdc/activity/ActivitySpecsActions.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'asdc-controller/src/main') diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/activity/ActivitySpecsActions.java b/asdc-controller/src/main/java/org/onap/so/asdc/activity/ActivitySpecsActions.java index c80e84b574..619d89438e 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/activity/ActivitySpecsActions.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/activity/ActivitySpecsActions.java @@ -67,7 +67,9 @@ public class ActivitySpecsActions { Response response = httpClient.post(payload); int statusCode = response.getStatus(); - if (statusCode != HttpStatus.SC_OK) { + if (statusCode == HttpStatus.SC_UNPROCESSABLE_ENTITY) { + logger.warn("{} {} {}", "ActivitySpec", activitySpec.getName(), "already exists in SDC"); + } else if (statusCode != HttpStatus.SC_OK && statusCode != HttpStatus.SC_CREATED) { logger.warn("{} {} {}", "Error creating activity spec", activitySpec.getName(), statusCode); } else { if (response.getEntity() != null) { @@ -108,7 +110,9 @@ public class ActivitySpecsActions { int statusCode = response.getStatus(); - if (statusCode != HttpStatus.SC_OK) { + if (statusCode == HttpStatus.SC_UNPROCESSABLE_ENTITY) { + logger.warn("{} {} {}", "ActivitySpec with id", activitySpecId, "is already certified in SDC"); + } else if (statusCode != HttpStatus.SC_OK) { logger.warn("{} {} {}", "Error certifying activity", activitySpecId, statusCode); } else { certificationResult = true; -- cgit 1.2.3-korg