summaryrefslogtreecommitdiffstats
path: root/asdctool/src/main/java/org
diff options
context:
space:
mode:
authorcb478c <cb478c@att.com>2017-07-19 13:22:23 +0300
committerMichael Lando <ml636r@att.com>2017-07-30 21:02:43 +0300
commita521335db6949fb0fdd846a4f1faa0c26336b0a9 (patch)
tree092af5af8154dd2d627824b2116bf9be1a3b8b68 /asdctool/src/main/java/org
parent9ce1c9cce49d3aeeca1f34f3d798f3f8a7ba9ede (diff)
[SDC]first draft of module json validation task
Change-Id: I551560e79ccd284ab852e8c1f1fec6cc9bf958d0 Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'asdctool/src/main/java/org')
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfiguration.java4
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTask.java76
2 files changed, 80 insertions, 0 deletions
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfiguration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfiguration.java
index 87b27c7369..038134bbfe 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfiguration.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfiguration.java
@@ -7,6 +7,7 @@ import org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts.VfArtifactValid
import org.openecomp.sdc.asdctool.impl.validator.executers.ServiceValidatorExecuter;
import org.openecomp.sdc.asdctool.impl.validator.executers.VfValidatorExecuter;
import org.openecomp.sdc.asdctool.impl.validator.ValidationToolBL;
+import org.openecomp.sdc.asdctool.impl.validator.tasks.moduleJson.ModuleJsonTask;
import org.openecomp.sdc.asdctool.impl.validator.utils.ReportManager;
import org.openecomp.sdc.be.dao.DAOTitanStrategy;
import org.openecomp.sdc.be.dao.TitanClientStrategy;
@@ -38,6 +39,9 @@ public class ValidationToolConfiguration {
public ServiceArtifactValidationTask serviceArtifactValidationTask() { return new ServiceArtifactValidationTask();}
@Bean
+ public ModuleJsonTask moduleJsonTask() { return new ModuleJsonTask();}
+
+ @Bean
public ValidationToolBL validationToolBL() {
return new ValidationToolBL();
}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTask.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTask.java
new file mode 100644
index 0000000000..675ac1f25d
--- /dev/null
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTask.java
@@ -0,0 +1,76 @@
+package org.openecomp.sdc.asdctool.impl.validator.tasks.moduleJson;
+
+import fj.data.Either;
+import org.openecomp.sdc.asdctool.impl.validator.tasks.ServiceValidationTask;
+import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
+import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.MapArtifactDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.MapGroupsDataDefinition;
+import org.openecomp.sdc.be.model.ComponentParametersView;
+import org.openecomp.sdc.be.model.LifecycleStateEnum;
+import org.openecomp.sdc.be.model.jsontitan.datamodel.TopologyTemplate;
+import org.openecomp.sdc.be.model.jsontitan.datamodel.ToscaElement;
+import org.openecomp.sdc.be.model.jsontitan.operations.TopologyTemplateOperation;
+import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * Created by chaya on 7/18/2017.
+ */
+public class ModuleJsonTask extends ServiceValidationTask {
+
+ @Autowired
+ private TopologyTemplateOperation topologyTemplateOperation;
+
+ @Override
+ public boolean validate(GraphVertex vertex) {
+ ComponentParametersView paramView = new ComponentParametersView();
+ paramView.disableAll();
+ paramView.setIgnoreArtifacts(false);
+ paramView.setIgnoreGroups(false);
+ paramView.setIgnoreComponentInstances(false);
+ Either<ToscaElement, StorageOperationStatus> toscaElementEither = topologyTemplateOperation.getToscaElement(vertex.getUniqueId(), paramView);
+ if (toscaElementEither.isRight()) {
+ return false;
+ }
+ TopologyTemplate element = (TopologyTemplate) toscaElementEither.left().value();
+ if (!isAfterSubmitForTesting(element)) {
+ return false;
+ }
+ Map<String, MapGroupsDataDefinition> instGroups = element.getInstGroups();
+ Map<String, MapArtifactDataDefinition> instDeploymentArtifacts = element.getInstDeploymentArtifacts();
+
+ for (Map.Entry<String, MapGroupsDataDefinition> pair : instGroups.entrySet()) {
+ String groupKey = pair.getKey();
+ MapGroupsDataDefinition groups = pair.getValue();
+ if (groups != null && !groups.getMapToscaDataDefinition().isEmpty()) {
+ MapArtifactDataDefinition deploymentsArtifacts = instDeploymentArtifacts.get(groupKey);
+ if (deploymentsArtifacts != null && !deploymentsArtifacts.getMapToscaDataDefinition().isEmpty()) {
+ List<ArtifactDataDefinition> moduleJsonArtifacts = deploymentsArtifacts.getMapToscaDataDefinition().values().stream().filter(artifact -> {
+ String artifactName = artifact.getArtifactName();
+ if (artifactName.startsWith(groupKey) && artifactName.endsWith("module.json")) {
+ return true;
+ }
+ return false;
+ }).collect(Collectors.toList());
+ if (moduleJsonArtifacts.size() > 0) {
+ return true;
+ }
+ }
+ }
+ }
+ return true;
+ }
+
+ private boolean isAfterSubmitForTesting(TopologyTemplate element){
+ List allowedStates = new ArrayList<>(Arrays.asList(LifecycleStateEnum.READY_FOR_CERTIFICATION,
+ LifecycleStateEnum.CERTIFICATION_IN_PROGRESS, LifecycleStateEnum.CERTIFIED));
+ return allowedStates.contains(element.getLifecycleState());
+ }
+}