Fix issue with VNFImage rollback
[aai/model-loader.git] / src / main / java / org / onap / aai / modelloader / entity / catalog / VnfCatalogArtifactHandler.java
index b224407..3480c68 100644 (file)
@@ -1,22 +1,22 @@
 /**\r
- * ============LICENSE_START==========================================\r
+ * ============LICENSE_START=======================================================\r
  * org.onap.aai\r
- * ===================================================================\r
+ * ================================================================================\r
  * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.\r
- * Copyright © 2017-2018 Amdocs\r
- * ===================================================================\r
+ * Copyright © 2017-2018 European Software Marketing Ltd.\r
+ * ================================================================================\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
  * You may obtain a copy of the License at\r
  *\r
- *        http://www.apache.org/licenses/LICENSE-2.0\r
+ *       http://www.apache.org/licenses/LICENSE-2.0\r
  *\r
  * Unless required by applicable law or agreed to in writing, software\r
  * distributed under the License is distributed on an "AS IS" BASIS,\r
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
  * See the License for the specific language governing permissions and\r
  * limitations under the License.\r
- * ============LICENSE_END============================================\r
+ * ============LICENSE_END=========================================================\r
  */\r
 package org.onap.aai.modelloader.entity.catalog;\r
 \r
@@ -89,7 +89,7 @@ public class VnfCatalogArtifactHandler extends ArtifactHandler {
             // If an empty dataItem is supplied, do nothing.\r
             if (dataItem.isEmpty()) {\r
                 logger.warn(ModelLoaderMsgs.DISTRIBUTION_EVENT, "Empty image data supplied, skipping ingestion.");\r
-                return;\r
+                continue;\r
             }\r
 \r
             String urlParams;\r
@@ -142,18 +142,13 @@ public class VnfCatalogArtifactHandler extends ArtifactHandler {
         String uuid = UUID.randomUUID().toString();\r
         dataItem.put(ATTR_UUID, uuid);\r
 \r
-        String payload = createVnfImagePayload(dataItem);\r
+        String payload = new Gson().toJson(dataItem);\r
         String putUrl = config.getAaiBaseUrl() + config.getAaiVnfImageUrl() + "/vnf-image/" + uuid;\r
         OperationResult putResp =\r
                 restClient.putResource(putUrl, payload, distributionId, MediaType.APPLICATION_JSON_TYPE);\r
         return putResp != null && putResp.getResultCode() == Response.Status.CREATED.getStatusCode();\r
     }\r
 \r
-    private String createVnfImagePayload(Map<String, String> dataItem) {\r
-        dataItem.put(ATTR_UUID, UUID.randomUUID().toString());\r
-        return new Gson().toJson(dataItem);\r
-    }\r
-\r
     private List<Map<String, String>> unmarshallVnfcData(Artifact vnfcArtifact) {\r
         // Unmarshall Babel JSON payload into a List of Maps of JSON attribute name/values.\r
         return new Gson().fromJson(StringEscapeUtils.unescapeJson(vnfcArtifact.getPayload()),\r