Refactored as per given comment 91/26991/3
authormojahidi <mojahidul.islam@amdocs.com>
Wed, 27 Dec 2017 09:16:35 +0000 (14:46 +0530)
committerVitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com>
Wed, 27 Dec 2017 13:52:55 +0000 (13:52 +0000)
Removed exception handling fixes

Change-Id: Ie5a89783a63ebcf4b404db4f2b8be2c7b2140e50
Issue-ID: SDC-343
Signed-off-by: mojahidi <mojahidul.islam@amdocs.com>
openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java

index b0e1e17..1db8875 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * Copyright © 2016-2017 European Support Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.process;
 
 import org.apache.commons.collections4.MapUtils;
@@ -37,15 +53,15 @@ import java.util.Optional;
 
 public class OrchestrationTemplateProcessCsarHandler
     implements OrchestrationTemplateProcessHandler {
-  private static final Logger LOGGER =
-      LoggerFactory.getLogger(OrchestrationTemplateProcessCsarHandler.class);
-  private CandidateService candidateService =
-      CandidateServiceFactory.getInstance().createInterface();
-  ToscaTreeManager toscaTreeManager = new ToscaTreeManager();
+  private static final Logger LOGGER = LoggerFactory
+          .getLogger(OrchestrationTemplateProcessCsarHandler.class);
+  private final CandidateService candidateService = CandidateServiceFactory
+          .getInstance().createInterface();
+  private final ToscaTreeManager toscaTreeManager = new ToscaTreeManager();
 
   @Override
   public OrchestrationTemplateActionResponse process(VspDetails vspDetails,
-                                                     OrchestrationTemplateCandidateData candidateData) {
+                                  OrchestrationTemplateCandidateData candidateData) {
     LOGGER.audit(
         AuditMessages.AUDIT_MSG + AuditMessages.CSAR_VALIDATION_STARTED + vspDetails.getId());
 
@@ -102,11 +118,13 @@ public class OrchestrationTemplateProcessCsarHandler
             OnboardingTypesEnum.CSAR, errors);
 
     orchestrationUtil.deleteUploadDataAndContent(vspDetails.getId(), vspDetails.getVersion());
-    orchestrationUtil.saveUploadData(vspDetails, candidateData, zipByteArrayInputStream.get(),
-            fileContentHandler, tree);
+    zipByteArrayInputStream.ifPresent(byteArrayInputStream -> orchestrationUtil
+            .saveUploadData(vspDetails, candidateData, byteArrayInputStream,
+            fileContentHandler, tree));
 
     ToscaServiceModel toscaServiceModel = new ToscaConverterImpl().convert(fileContentHandler);
-    orchestrationUtil.saveServiceModel(vspDetails.getId(), vspDetails.getVersion(), toscaServiceModel,
+    orchestrationUtil.saveServiceModel(vspDetails.getId(),
+            vspDetails.getVersion(), toscaServiceModel,
         toscaServiceModel);
 
   }