aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/api
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2023-01-17 18:59:55 +0000
committerMichael Morris <michael.morris@est.tech>2023-01-19 21:59:49 +0000
commit3ef8252b29317f8fec99fd93c38e9f306639e6bb (patch)
tree822dbf3714000d5aed13951469a94d14edad42f4 /openecomp-be/api
parent3943534cd3409c0cca6588f36527df34345d74f2 (diff)
Fix 'SDC be API returns HTTP 200 response code on error'-bug
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Change-Id: I7c314a8d3aa7978d60bee8256e5a83958f2328db Issue-ID: SDC-3505
Diffstat (limited to 'openecomp-be/api')
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java15
1 files changed, 11 insertions, 4 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java
index acbb0cdd03..bf674d5dcd 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java
@@ -50,6 +50,7 @@ import java.util.UUID;
import javax.activation.DataHandler;
import javax.inject.Named;
import javax.ws.rs.core.Response;
+import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import org.openecomp.sdc.activitylog.ActivityLogManager;
@@ -176,12 +177,18 @@ public class OrchestrationTemplateCandidateImpl implements OrchestrationTemplate
vspUploadStatus = orchestrationTemplateCandidateUploadManager.putUploadInProcessing(vspId, versionId, user);
response = processOnboardPackage(onboardPackageInfo, vspDetails, errorMessages);
final UploadFileResponseDto entity = (UploadFileResponseDto) response.getEntity();
- if (artifactStorageManager.isEnabled()) {
- if (entity.getErrors().isEmpty()) {
- artifactStorageManager.put(vspId, versionId + ".reduced", new ByteArrayInputStream(fileToUploadBytes));
- } else {
+ final Map<String, List<ErrorMessage>> errors = entity.getErrors();
+ if (MapUtils.isNotEmpty(errors)) {
+ if (artifactStorageManager.isEnabled()) {
artifactStorageManager.delete(artifactInfo);
}
+ orchestrationTemplateCandidateUploadManager
+ .putUploadAsFinished(vspId, versionId, vspUploadStatus.getLockId(), VspUploadStatus.ERROR, user);
+ return Response.status(NOT_ACCEPTABLE)
+ .entity(buildUploadResponseWithError(errors.values().stream().flatMap(List::stream).toArray(ErrorMessage[]::new))).build();
+ }
+ if (artifactStorageManager.isEnabled()) {
+ artifactStorageManager.put(vspId, versionId + ".reduced", new ByteArrayInputStream(fileToUploadBytes));
}
orchestrationTemplateCandidateUploadManager
.putUploadAsFinished(vspId, versionId, vspUploadStatus.getLockId(), VspUploadStatus.SUCCESS, user);