summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/java
diff options
context:
space:
mode:
authorFrancis Toth <francis.toth@yoppworks.com>2020-05-08 08:27:25 -0400
committerOfir Sonsino <ofir.sonsino@intl.att.com>2020-05-10 06:24:23 +0000
commitfeb112c63e395bd682b09a43d6a03d13eb29dcd4 (patch)
treee5939f1d8620d63012f5ec2081c78dbf7ee23c85 /catalog-be/src/main/java
parent4a98c7efa0e8103b4e14c1d521b7963d095495e0 (diff)
Moved ArtifactsBusinessLogic::buildJsonStringForCsarVfcArtifact to JsonUtils
Signed-off-by: Francis Toth <francis.toth@yoppworks.com> Change-Id: Ia3bb9fe9f97e1759e4e5b70eb5e5396ed87d716d Issue-ID: SDC-2961
Diffstat (limited to 'catalog-be/src/main/java')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java18
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/utils/ArtifactUtils.java51
2 files changed, 53 insertions, 16 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java
index 1983e32d7c..f34f3a6c00 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java
@@ -65,6 +65,7 @@ import org.openecomp.sdc.be.components.impl.artifact.PayloadTypeEnum;
import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException;
import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
+import org.openecomp.sdc.be.components.utils.ArtifactUtils;
import org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic;
import org.openecomp.sdc.be.components.lifecycle.LifecycleChangeInfoWithAction;
import org.openecomp.sdc.be.components.lifecycle.LifecycleChangeInfoWithAction.LifecycleChanceActionEnum;
@@ -4657,7 +4658,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
String origMd5;
try {
for (ArtifactDefinition artifact : artifactsToHandle) {
- originData = buildJsonStringForCsarVfcArtifact(artifact);
+ originData = ArtifactUtils.buildJsonStringForCsarVfcArtifact(artifact);
origMd5 = GeneralUtility.calculateMD5Base64EncodedByString(originData);
actionResult = handleArtifactRequest(component.getUniqueId(), user.getUserId(), componentType, operation, artifact
.getUniqueId(), artifact, origMd5, originData, null, null, null, null, shouldLock, inTransaction);
@@ -4846,19 +4847,6 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
return checkoutRes.left().value();
}
- private String buildJsonStringForCsarVfcArtifact(ArtifactDefinition artifact) {
- Map<String, Object> json = new HashMap<>();
- String artifactName = artifact.getArtifactName();
- json.put(Constants.ARTIFACT_NAME, artifactName);
- json.put(Constants.ARTIFACT_LABEL, artifact.getArtifactLabel());
- json.put(Constants.ARTIFACT_TYPE, artifact.getArtifactType());
- json.put(Constants.ARTIFACT_GROUP_TYPE, ArtifactGroupTypeEnum.DEPLOYMENT.getType());
- json.put(Constants.ARTIFACT_DESCRIPTION, artifact.getDescription());
- json.put(Constants.ARTIFACT_PAYLOAD_DATA, artifact.getPayloadData());
- json.put(Constants.ARTIFACT_DISPLAY_NAME, artifact.getArtifactDisplayName());
- return gson.toJson(json);
- }
-
@Autowired
void setNodeTemplateOperation(NodeTemplateOperation nodeTemplateOperation) {
this.nodeTemplateOperation = nodeTemplateOperation;
@@ -4867,6 +4855,4 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
public List<ArtifactConfiguration> getConfiguration() {
return ConfigurationManager.getConfigurationManager().getConfiguration().getArtifacts();
}
-
}
-
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/utils/ArtifactUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/utils/ArtifactUtils.java
new file mode 100644
index 0000000000..9f95caa2fa
--- /dev/null
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/utils/ArtifactUtils.java
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
+ */
+
+package org.openecomp.sdc.be.components.utils;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import java.util.HashMap;
+import java.util.Map;
+import org.openecomp.sdc.be.model.ArtifactDefinition;
+import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
+import org.openecomp.sdc.common.api.Constants;
+
+public final class ArtifactUtils {
+
+ private ArtifactUtils() {
+ }
+
+ public static String buildJsonStringForCsarVfcArtifact(ArtifactDefinition artifact) {
+ Gson gson = new GsonBuilder().setPrettyPrinting().create();
+ Map<String, Object> json = new HashMap<>();
+ String artifactName = artifact.getArtifactName();
+ json.put(Constants.ARTIFACT_NAME, artifactName);
+ json.put(Constants.ARTIFACT_LABEL, artifact.getArtifactLabel());
+ json.put(Constants.ARTIFACT_TYPE, artifact.getArtifactType());
+ json.put(Constants.ARTIFACT_GROUP_TYPE, ArtifactGroupTypeEnum.DEPLOYMENT.getType());
+ json.put(Constants.ARTIFACT_DESCRIPTION, artifact.getDescription());
+ json.put(Constants.ARTIFACT_PAYLOAD_DATA, artifact.getPayloadData());
+ json.put(Constants.ARTIFACT_DISPLAY_NAME, artifact.getArtifactDisplayName());
+ return gson.toJson(json);
+ }
+}