aboutsummaryrefslogtreecommitdiffstats
path: root/asdctool/src/main/java/org
diff options
context:
space:
mode:
authorys9693 <ys9693@att.com>2020-01-19 13:50:02 +0200
committerOfir Sonsino <ofir.sonsino@intl.att.com>2020-01-22 12:33:31 +0000
commit16a9fce0e104a38371a9e5a567ec611ae3fc7f33 (patch)
tree03a2aff3060ddb5bc26a90115805a04becbaffc9 /asdctool/src/main/java/org
parentaa83a2da4f911c3ac89318b8e9e8403b072942e1 (diff)
Catalog alignment
Issue-ID: SDC-2724 Signed-off-by: ys9693 <ys9693@att.com> Change-Id: I52b4aacb58cbd432ca0e1ff7ff1f7dd52099c6fe
Diffstat (limited to 'asdctool/src/main/java/org')
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/App.java7
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/Utils.java6
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/cli/CLITool.java7
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/configuration/ArtifactUUIDFixConfiguration.java11
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/configuration/ConfigurationUploader.java24
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/configuration/CsarGeneratorConfiguration.java10
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/configuration/InternalToolConfiguration.java9
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/configuration/SdcSchemaFileImportConfiguration.java (renamed from asdctool/src/main/java/org/openecomp/sdc/asdctool/configuration/GetConsumersConfiguration.java)23
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/configuration/mocks/es/ESCatalogDAOMock.java61
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/enums/DistributionStatusEnum.java (renamed from asdctool/src/main/java/org/openecomp/sdc/asdctool/configuration/mocks/es/ElasticSearchMocksConfiguration.java)37
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/enums/LifeCycleTransitionEnum.java83
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/enums/LifecycleStateEnum.java (renamed from asdctool/src/main/java/org/openecomp/sdc/asdctool/configuration/mocks/es/EsHealthCheckDaoMock.java)35
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/enums/SchemaZipFileEnum.java4
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/ArtifactUuidFix.java176
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/DataMigration.java813
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/EsToCassandraDataMigrationConfig.java56
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphJsonValidator.java2
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphMLConverter.java43
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphMLDataAnalyzer.java13
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/JanusGraphInitializer.java10
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/ProductLogic.java7
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/UpdatePropertyOnVertex.java6
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/VrfObjectFixHandler.java6
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/internal/tool/CommonInternalTool.java6
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/internal/tool/CsarGenerator.java26
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/internal/tool/DeleteComponentHandler.java2
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManager.java7
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfiguration.java19
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecuter.java17
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/NodeToscaArtifactsValidatorExecuter.java2
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceToscaArtifactsValidatorExecutor.java4
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuter.java2
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuter.java9
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VFToscaArtifactValidatorExecutor.java2
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuter.java3
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtils.java13
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTask.java10
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManager.java20
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/main/CsarGeneratorTool.java4
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/main/DataSchemaMenu.java89
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/main/DeleteComponentTool.java9
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/main/EsToCassandraDataMigrationMenu.java105
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/main/ExportImportMenu.java7
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/main/GetConsumersMenu.java77
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/main/SdcInternalTool.java3
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/main/SdcSchemaFileImport.java36
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/config/MigrationSpringConfig.java23
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/config/mocks/CambriaHandlerMock.java87
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/config/mocks/DistributionEngineMock.java7
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/config/mocks/PortalHealthCheckBuilderMock.java (renamed from asdctool/src/main/java/org/openecomp/sdc/asdctool/configuration/mocks/es/ElasticSearchClientMock.java)30
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/core/DBVersion.java2
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/core/task/PostMigration.java2
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/dao/MigrationTasksAccessor.java3
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/dao/MigrationTasksDao.java22
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/service/SdcRepoService.java6
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/InstanceMigrationBase.java178
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/handlers/XlsOutputHandler.java2
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1710/UpgradeMigration1710.java98
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/ForwardPathMigration.java27
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/ResourceLifecycleMigration.java2
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/SDCInstancesMigration.java49
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1902/InterfaceOperationMigration.java9
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1902/SdcConsumerMigration.java108
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1902/SdcGroupsMigration.java186
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1902/SdcResourceIconMigration.java187
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1911/SdcDeploymentArtTimeOutMigration.java137
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig2002/SdcCollapsingRolesCERTIFIEDstateMigration.java139
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig2002/SdcCollapsingRolesCIPstateMigration.java153
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig2002/SdcCollapsingRolesRFCstateMigration.java147
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/servlets/ExportImportJanusGraphServlet.java14
70 files changed, 1968 insertions, 1571 deletions
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/App.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/App.java
index f7aaa1e0d9..b433357db3 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/App.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/App.java
@@ -23,15 +23,12 @@ package org.openecomp.sdc.asdctool;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* Hello world!
*
*/
public class App {
- private static Logger log = LoggerFactory.getLogger(App.class);
public static void main(String[] args) {
String asdcToolPort = "8087";
@@ -55,12 +52,12 @@ public class App {
try {
jettyServer.start();
- log.info("Server was started on port {}", asdcToolPort);
+ System.out.println("Server was started on port " + asdcToolPort);
jettyServer.join();
} catch (Exception e) {
- log.info("Server failed to start - {}", e);
+ e.printStackTrace();
System.exit(1);
} finally {
jettyServer.destroy();
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/Utils.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/Utils.java
index 44bfc536b6..378b81aaf2 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/Utils.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/Utils.java
@@ -20,12 +20,12 @@
package org.openecomp.sdc.asdctool;
-import org.janusgraph.core.JanusGraphFactory;
-import org.janusgraph.core.JanusGraph;
import org.apache.commons.configuration.Configuration;
import org.apache.tinkerpop.gremlin.structure.Element;
import org.apache.tinkerpop.gremlin.structure.Property;
import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphFactory;
import org.openecomp.sdc.common.log.wrappers.Logger;
import javax.ws.rs.core.Response;
@@ -38,7 +38,7 @@ public class Utils {
private static Logger log = Logger.getLogger(Utils.class.getName());
- public final static String NEW_LINE = System.getProperty("line.separator");
+ public static String NEW_LINE = System.getProperty("line.separator");
public static Response buildOkResponse(
/*
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/cli/CLITool.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/cli/CLITool.java
index 6cb6a5bb14..d4ebff6005 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/cli/CLITool.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/cli/CLITool.java
@@ -20,7 +20,12 @@
package org.openecomp.sdc.asdctool.cli;
-import org.apache.commons.cli.*;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.DefaultParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/configuration/ArtifactUUIDFixConfiguration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/configuration/ArtifactUUIDFixConfiguration.java
index abfd10547b..99234365da 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/configuration/ArtifactUUIDFixConfiguration.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/configuration/ArtifactUUIDFixConfiguration.java
@@ -30,12 +30,10 @@ import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade
import org.openecomp.sdc.be.tosca.CsarUtils;
import org.openecomp.sdc.be.tosca.ToscaExportHandler;
import org.openecomp.sdc.config.CatalogBESpringConfig;
-import org.springframework.beans.factory.config.PropertiesFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
-import org.springframework.core.io.FileSystemResource;
@Configuration
@Import({DAOSpringConfig.class, CatalogBESpringConfig.class, CatalogModelSpringConfig.class})
@@ -51,13 +49,4 @@ public class ArtifactUUIDFixConfiguration {
return new ArtifactUuidFix(janusGraphDao, toscaOperationFacade, toscaExportHandler, artifactCassandraDao, csarUtils);
}
- @Bean(name = "elasticsearchConfig")
- public PropertiesFactoryBean mapper() {
- String configHome = System.getProperty("config.home");
- PropertiesFactoryBean bean = new PropertiesFactoryBean();
- bean.setLocation(new FileSystemResource(configHome + "/elasticsearch.yml"));
- return bean;
- }
-
-
}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/configuration/ConfigurationUploader.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/configuration/ConfigurationUploader.java
index d115f9cbb0..975066f694 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/configuration/ConfigurationUploader.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/configuration/ConfigurationUploader.java
@@ -1,6 +1,9 @@
-/*
- * Copyright © 2016-2018 AT&T
- *
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2016-2020 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
@@ -12,6 +15,9 @@
* 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.asdctool.configuration;
@@ -21,6 +27,8 @@ import org.openecomp.sdc.common.api.ConfigurationSource;
import org.openecomp.sdc.common.impl.ExternalConfiguration;
import org.openecomp.sdc.common.impl.FSConfigurationSource;
+import java.io.File;
+
public class ConfigurationUploader {
public static void uploadConfigurationFiles(String appConfigDir) {
@@ -28,5 +36,15 @@ public class ConfigurationUploader {
new ConfigurationManager(configurationSource);
ExternalConfiguration.setAppVersion(ConfigurationManager.getConfigurationManager().getConfiguration().getAppVersion());
System.setProperty("config.home", appConfigDir);
+ System.setProperty("artifactgenerator.config", buildArtifactGeneratorPath(appConfigDir));
+ }
+
+ private static String buildArtifactGeneratorPath(String appConfigDir) {
+ StringBuilder artifactGeneratorPath = new StringBuilder(appConfigDir);
+ if(!appConfigDir.endsWith(File.separator)){
+ artifactGeneratorPath.append(File.separator);
+ }
+ artifactGeneratorPath.append(ConfigurationManager.getConfigurationManager().getConfiguration().getArtifactGeneratorConfig());
+ return artifactGeneratorPath.toString();
}
}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/configuration/CsarGeneratorConfiguration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/configuration/CsarGeneratorConfiguration.java
index 32c37a36b3..ee4d2c1be2 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/configuration/CsarGeneratorConfiguration.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/configuration/CsarGeneratorConfiguration.java
@@ -21,7 +21,6 @@
package org.openecomp.sdc.asdctool.configuration;
import org.openecomp.sdc.asdctool.impl.internal.tool.CsarGenerator;
-import org.openecomp.sdc.be.components.distribution.engine.ServiceDistributionArtifactsBuilder;
import org.openecomp.sdc.be.config.CatalogModelSpringConfig;
import org.openecomp.sdc.be.dao.cassandra.ArtifactCassandraDao;
import org.openecomp.sdc.be.dao.config.DAOSpringConfig;
@@ -30,12 +29,10 @@ import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade
import org.openecomp.sdc.be.tosca.CsarUtils;
import org.openecomp.sdc.be.tosca.ToscaExportHandler;
import org.openecomp.sdc.config.CatalogBESpringConfig;
-import org.springframework.beans.factory.config.PropertiesFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
-import org.springframework.core.io.FileSystemResource;
@Configuration
@Import({DAOSpringConfig.class, CatalogBESpringConfig.class, CatalogModelSpringConfig.class})
@@ -51,12 +48,5 @@ public class CsarGeneratorConfiguration {
artifactCassandraDao, toscaExportHandler);
}
- @Bean(name = "elasticsearchConfig")
- public PropertiesFactoryBean mapper() {
- String configHome = System.getProperty("config.home");
- PropertiesFactoryBean bean = new PropertiesFactoryBean();
- bean.setLocation(new FileSystemResource(configHome + "/elasticsearch.yml"));
- return bean;
- }
}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/configuration/InternalToolConfiguration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/configuration/InternalToolConfiguration.java
index 51956732f5..1b09b2a57e 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/configuration/InternalToolConfiguration.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/configuration/InternalToolConfiguration.java
@@ -26,22 +26,13 @@ import org.openecomp.sdc.be.dao.config.DAOSpringConfig;
import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.NodeTypeOperation;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.TopologyTemplateOperation;
-import org.springframework.beans.factory.config.PropertiesFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
-import org.springframework.core.io.FileSystemResource;
@Configuration
@Import({DAOSpringConfig.class, CatalogModelSpringConfig.class})
public class InternalToolConfiguration {
- @Bean(name = "elasticsearchConfig")
- public PropertiesFactoryBean mapper() {
- String configHome = System.getProperty("config.home");
- PropertiesFactoryBean bean = new PropertiesFactoryBean();
- bean.setLocation(new FileSystemResource(configHome + "/elasticsearch.yml"));
- return bean;
- }
@Bean
public DeleteComponentHandler deleteComponentHandler(
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/configuration/GetConsumersConfiguration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/configuration/SdcSchemaFileImportConfiguration.java
index 8c70ad3407..0cfd894b39 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/configuration/GetConsumersConfiguration.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/configuration/SdcSchemaFileImportConfiguration.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* SDC
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * 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.
@@ -20,21 +20,22 @@
package org.openecomp.sdc.asdctool.configuration;
-import org.openecomp.sdc.be.dao.config.JanusGraphSpringConfig;
-import org.openecomp.sdc.be.dao.janusgraph.JanusGraphGenericDao;
-import org.openecomp.sdc.be.model.operations.impl.ConsumerOperation;
+import org.openecomp.sdc.be.dao.cassandra.CassandraClient;
+import org.openecomp.sdc.be.dao.cassandra.SdcSchemaFilesCassandraDao;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Import;
@Configuration
-@Import({JanusGraphSpringConfig.class})
-public class GetConsumersConfiguration {
+public class SdcSchemaFileImportConfiguration {
- @Bean("consumer-operation")
- public ConsumerOperation consumerOperation(JanusGraphGenericDao janusGraphGenericDao) {
- return new ConsumerOperation(janusGraphGenericDao);
- }
+ @Bean(name = "cassandra-client")
+ public CassandraClient cassandraClient() {
+ return new CassandraClient();
+ }
+ @Bean(name = "sdc-schema-files-cassandra-dao")
+ public SdcSchemaFilesCassandraDao sdcSchemaFilesCassandraDao() {
+ return new SdcSchemaFilesCassandraDao(cassandraClient());
+ }
}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/configuration/mocks/es/ESCatalogDAOMock.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/configuration/mocks/es/ESCatalogDAOMock.java
deleted file mode 100644
index 75283f15ba..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/configuration/mocks/es/ESCatalogDAOMock.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 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=========================================================
- */
-
-package org.openecomp.sdc.asdctool.configuration.mocks.es;
-
-import fj.data.Either;
-import org.openecomp.sdc.be.dao.api.ICatalogDAO;
-import org.openecomp.sdc.be.dao.api.ResourceUploadStatus;
-import org.openecomp.sdc.be.resources.data.ESArtifactData;
-
-import java.util.List;
-
-public class ESCatalogDAOMock implements ICatalogDAO {
-
- @Override
- public void addToIndicesMap(String typeName, String indexName) {
-
- }
-
- @Override
- public void writeArtifact(ESArtifactData artifactData) {
-
- }
-
- @Override
- public Either<ESArtifactData, ResourceUploadStatus> getArtifact(String id) {
- return null;
- }
-
- @Override
- public Either<List<ESArtifactData>, ResourceUploadStatus> getArtifacts(String[] ids) {
- return null;
- }
-
- @Override
- public void deleteArtifact(String id) {
-
- }
-
- @Override
- public void deleteAllArtifacts() {
-
- }
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/configuration/mocks/es/ElasticSearchMocksConfiguration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/enums/DistributionStatusEnum.java
index fd68de24d2..92c4a7cf54 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/configuration/mocks/es/ElasticSearchMocksConfiguration.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/enums/DistributionStatusEnum.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* SDC
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * 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.
@@ -18,30 +18,29 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdc.asdctool.configuration.mocks.es;
+package org.openecomp.sdc.asdctool.enums;
-import org.openecomp.sdc.be.dao.api.ICatalogDAO;
-import org.openecomp.sdc.be.dao.api.IEsHealthCheckDao;
-import org.openecomp.sdc.be.dao.es.ElasticSearchClient;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
+public enum DistributionStatusEnum {
+ DISTRIBUTION_NOT_APPROVED("Distribution not approved"), DISTRIBUTION_APPROVED("Distribution approved"), DISTRIBUTED("Distributed"), DISTRIBUTION_REJECTED("Distribution rejected");
-@Configuration
-public class ElasticSearchMocksConfiguration {
+ private String value;
- @Bean("elasticsearch-client")
- public ElasticSearchClient elasticSearchClientMock() {
- return new ElasticSearchClientMock();
+ private DistributionStatusEnum(String value) {
+ this.value = value;
}
- @Bean("resource-dao")
- public ICatalogDAO esCatalogDAOMock() {
- return new ESCatalogDAOMock();
+ public String getValue() {
+ return value;
}
- @Bean("esHealthCheckDao")
- public IEsHealthCheckDao esHealthCheckDaoMock() {
- return new EsHealthCheckDaoMock();
+ public static DistributionStatusEnum findState(String state) {
+
+ for (DistributionStatusEnum distributionStatus : DistributionStatusEnum.values()) {
+ if (distributionStatus.name().equalsIgnoreCase(state) || distributionStatus.getValue().equalsIgnoreCase(state)) {
+ return distributionStatus;
+ }
+ }
+ return null;
}
-}
+} \ No newline at end of file
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/enums/LifeCycleTransitionEnum.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/enums/LifeCycleTransitionEnum.java
new file mode 100644
index 0000000000..b29f5fba8d
--- /dev/null
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/enums/LifeCycleTransitionEnum.java
@@ -0,0 +1,83 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2020 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=========================================================
+ */
+
+package org.openecomp.sdc.asdctool.enums;
+
+public enum LifeCycleTransitionEnum {
+
+ CHECKOUT("checkout"),
+ CHECKIN("checkin"),
+ CERTIFICATION_REQUEST("certificationRequest"),
+ UNDO_CHECKOUT("undoCheckout"),
+ CANCEL_CERTIFICATION("cancelCertification"),
+ START_CERTIFICATION("startCertification"),
+ FAIL_CERTIFICATION("failCertification"),
+ CERTIFY("certify"),
+ DISTRIBUTE("distribute");
+
+ String displayName;
+
+ LifeCycleTransitionEnum(String displayName) {
+ this.displayName = displayName;
+ }
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public static LifeCycleTransitionEnum getFromDisplayName(String name) {
+ if (name.equalsIgnoreCase(LifeCycleTransitionEnum.CHECKOUT.getDisplayName())) {
+ return LifeCycleTransitionEnum.CHECKOUT;
+ }
+ if (name.equalsIgnoreCase(LifeCycleTransitionEnum.CHECKIN.getDisplayName())) {
+ return LifeCycleTransitionEnum.CHECKIN;
+ }
+ if (name.equalsIgnoreCase(LifeCycleTransitionEnum.CERTIFICATION_REQUEST.getDisplayName())) {
+ return LifeCycleTransitionEnum.CERTIFICATION_REQUEST;
+ }
+ if (name.equalsIgnoreCase(LifeCycleTransitionEnum.UNDO_CHECKOUT.getDisplayName())) {
+ return LifeCycleTransitionEnum.UNDO_CHECKOUT;
+ }
+ if (name.equalsIgnoreCase(LifeCycleTransitionEnum.CANCEL_CERTIFICATION.getDisplayName())) {
+ return LifeCycleTransitionEnum.CANCEL_CERTIFICATION;
+ }
+ if (name.equalsIgnoreCase(LifeCycleTransitionEnum.START_CERTIFICATION.getDisplayName())) {
+ return LifeCycleTransitionEnum.START_CERTIFICATION;
+ }
+ if (name.equalsIgnoreCase(LifeCycleTransitionEnum.FAIL_CERTIFICATION.getDisplayName())) {
+ return LifeCycleTransitionEnum.FAIL_CERTIFICATION;
+ }
+ if (name.equalsIgnoreCase(LifeCycleTransitionEnum.CERTIFY.getDisplayName())) {
+ return LifeCycleTransitionEnum.CERTIFY;
+ }
+ if (name.equalsIgnoreCase(LifeCycleTransitionEnum.DISTRIBUTE.getDisplayName())) {
+ return LifeCycleTransitionEnum.DISTRIBUTE;
+ } else
+ throw new IllegalArgumentException(name + " value does not match any of LifeCycleTransitionEnum values");
+ }
+
+ public static String valuesAsString() {
+ StringBuilder sb = new StringBuilder();
+ for (LifeCycleTransitionEnum op : LifeCycleTransitionEnum.values()) {
+ sb.append(op.getDisplayName()).append(" ");
+ }
+ return sb.toString();
+ }
+} \ No newline at end of file
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/configuration/mocks/es/EsHealthCheckDaoMock.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/enums/LifecycleStateEnum.java
index a22e862ae7..98fb95faa7 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/configuration/mocks/es/EsHealthCheckDaoMock.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/enums/LifecycleStateEnum.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* SDC
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020 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.
@@ -18,14 +18,27 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdc.asdctool.configuration.mocks.es;
+package org.openecomp.sdc.asdctool.enums;
-import org.openecomp.sdc.be.dao.api.IEsHealthCheckDao;
-import org.openecomp.sdc.common.api.HealthCheckInfo;
+public enum LifecycleStateEnum {
-public class EsHealthCheckDaoMock implements IEsHealthCheckDao {
- @Override
- public HealthCheckInfo.HealthCheckStatus getClusterHealthStatus() {
- return HealthCheckInfo.HealthCheckStatus.UP;
+ READY_FOR_CERTIFICATION,
+
+ CERTIFICATION_IN_PROGRESS,
+
+ CERTIFIED,
+
+ NOT_CERTIFIED_CHECKIN,
+
+ NOT_CERTIFIED_CHECKOUT;
+
+ public static LifecycleStateEnum findState(String state) {
+
+ for (LifecycleStateEnum lifecycleStateEnum : LifecycleStateEnum.values()) {
+ if (lifecycleStateEnum.name().equals(state)) {
+ return lifecycleStateEnum;
+ }
+ }
+ return null;
}
-}
+} \ No newline at end of file
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/enums/SchemaZipFileEnum.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/enums/SchemaZipFileEnum.java
index 471b54d4cb..1ab2b809c1 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/enums/SchemaZipFileEnum.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/enums/SchemaZipFileEnum.java
@@ -20,7 +20,9 @@
package org.openecomp.sdc.asdctool.enums;
-import static org.openecomp.sdc.asdctool.enums.SchemaZipFileEnum.SchemaZipConstants.*;
+import static org.openecomp.sdc.asdctool.enums.SchemaZipFileEnum.SchemaZipConstants.DATA_IMPORT_LIST;
+import static org.openecomp.sdc.asdctool.enums.SchemaZipFileEnum.SchemaZipConstants.EMPTY_IMPORT_LIST;
+import static org.openecomp.sdc.asdctool.enums.SchemaZipFileEnum.SchemaZipConstants.RELATIONSHIPS_TYPES_IMPORT_LIST;
public enum SchemaZipFileEnum {
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/ArtifactUuidFix.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/ArtifactUuidFix.java
index 4dab15fa4b..4ad90b884c 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/ArtifactUuidFix.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/ArtifactUuidFix.java
@@ -44,7 +44,16 @@ import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
import org.openecomp.sdc.be.impl.ComponentsUtils;
-import org.openecomp.sdc.be.model.*;
+import org.openecomp.sdc.be.model.ArtifactDefinition;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.ComponentParametersView;
+import org.openecomp.sdc.be.model.DistributionStatusEnum;
+import org.openecomp.sdc.be.model.GroupDefinition;
+import org.openecomp.sdc.be.model.GroupInstance;
+import org.openecomp.sdc.be.model.LifecycleStateEnum;
+import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.model.Service;
import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.TopologyTemplate;
import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.ToscaElement;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
@@ -52,7 +61,7 @@ import org.openecomp.sdc.be.model.jsonjanusgraph.utils.ModelConverter;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter;
import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
-import org.openecomp.sdc.be.resources.data.ESArtifactData;
+import org.openecomp.sdc.be.resources.data.DAOArtifactData;
import org.openecomp.sdc.be.tosca.CsarUtils;
import org.openecomp.sdc.be.tosca.ToscaError;
import org.openecomp.sdc.be.tosca.ToscaExportHandler;
@@ -72,23 +81,23 @@ import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.EnumMap;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
-import java.util.EnumMap;
import java.util.stream.Collectors;
@org.springframework.stereotype.Component("artifactUuidFix")
public class ArtifactUuidFix {
-
+
private static final String MIGRATION1707_ARTIFACT_UUID_FIX = "Migration1707ArtifactUuidFix fix group: group name {} correct artifactId {} artifactUUID {} ";
- private static final String FAILED_TO_FETCH_VF_RESOURCES = "Failed to fetch vf resources ";
+ private static final String FAILED_TO_FETCH_VF_RESOURCES = "Failed to fetch vf resources ";
- private static final String UTF8 = "utf-8";
+ private static final String UTF8 = "utf-8";
private JanusGraphDao janusGraphDao;
private ToscaOperationFacade toscaOperationFacade;
@@ -249,7 +258,7 @@ public class ArtifactUuidFix {
vfLst.add(resource);
writeModuleResultToFile(writer, resource, service);
writer.flush();
-
+
}
janusGraphDao.commit();
}
@@ -274,7 +283,7 @@ public class ArtifactUuidFix {
Map<GraphPropertyEnum, Object> hasProps = new EnumMap<>(GraphPropertyEnum.class);
hasProps.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.SERVICE.name());
if ("distributed_only".equals(fixServices)) {
- hasProps.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name());
+ hasProps.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name());
hasProps.put(GraphPropertyEnum.DISTRIBUTION_STATUS, DistributionStatusEnum.DISTRIBUTED.name());
}
@@ -302,17 +311,17 @@ public class ArtifactUuidFix {
continue;
}
Service service = toscaElement.left().value();
-
+
String serviceName = (String) gv.getMetadataProperty(GraphPropertyEnum.NAME);
-
+
boolean isProblematic = isProblematicService(service, serviceName);
if (isProblematic) {
serviceList.add(service);
writeModuleResultToFile(writer, service, null);
writer.flush();
-
+
}
-
+
janusGraphDao.commit();
}
log.info("output file with list of services : {}", fileName);
@@ -326,9 +335,9 @@ public class ArtifactUuidFix {
}
private boolean isProblematicService( Service service, String serviceName) {
-
+
List<ComponentInstance> componentInstances = service.getComponentInstances();
-
+
if (componentInstances == null) {
log.info("No instances for service {} ", service.getUniqueId());
return false;
@@ -350,21 +359,21 @@ public class ArtifactUuidFix {
if(isCheckVFModules){
Optional<ArtifactDefinition> optionalVfModuleArtifact = deploymentArtifacts.values().stream()
.filter(p -> p.getArtifactType().equals(ArtifactTypeEnum.VF_MODULES_METADATA.name())).findAny();
-
- if(!optionalVfModuleArtifact.isPresent())
- return true;
-
- ArtifactDefinition vfModuleArtifact = optionalVfModuleArtifact.get();
- Either<List<VfModuleArtifactPayloadEx>, StorageOperationStatus> vfModulesEither = parseVFModuleJson(vfModuleArtifact);
- if(vfModulesEither.isRight()){
- log.error("Failed to parse vfModule for service {} status is {}", service.getUniqueId(), vfModulesEither.right().value());
- return true;
- }
- vfModules = vfModulesEither.left().value();
- if(vfModules == null || vfModules.isEmpty() ){
- log.info("vfModules empty for service {}", service.getUniqueId());
- return true;
- }
+
+ if(!optionalVfModuleArtifact.isPresent())
+ return true;
+
+ ArtifactDefinition vfModuleArtifact = optionalVfModuleArtifact.get();
+ Either<List<VfModuleArtifactPayloadEx>, StorageOperationStatus> vfModulesEither = parseVFModuleJson(vfModuleArtifact);
+ if(vfModulesEither.isRight()){
+ log.error("Failed to parse vfModule for service {} status is {}", service.getUniqueId(), vfModulesEither.right().value());
+ return true;
+ }
+ vfModules = vfModulesEither.left().value();
+ if(vfModules == null || vfModules.isEmpty() ){
+ log.info("vfModules empty for service {}", service.getUniqueId());
+ return true;
+ }
}
for (GroupInstance gi : groupInstances) {
@@ -373,7 +382,7 @@ public class ArtifactUuidFix {
if(isCheckVFModules && vfModules != null){
Optional<VfModuleArtifactPayloadEx> op = vfModules.stream().filter(vf -> vf.getVfModuleModelName().equals(gi.getGroupName())).findAny();
if(!op.isPresent()){
- log.error("Failed to find vfModule for group {}", gi.getGroupName());
+ log.error("Failed to find vfModule for group {}", gi.getGroupName());
return true;
}
vfModule = op.get();
@@ -383,13 +392,13 @@ public class ArtifactUuidFix {
}
}
}
-
+
}
return false;
}
private boolean isProblematicGroup(GroupDefinition gr, String resourceName,
- Map<String, ArtifactDefinition> deploymentArtifacts) {
+ Map<String, ArtifactDefinition> deploymentArtifacts) {
List<String> artifacts = gr.getArtifacts();
List<String> artifactsUuid = gr.getArtifactsUuid();
Set<String> artifactsSet = new HashSet<>();
@@ -454,14 +463,14 @@ public class ArtifactUuidFix {
}
private boolean isProblematicGroupInstance(GroupInstance gi, String instName, String servicename,
- Map<String, ArtifactDefinition> deploymentArtifacts, VfModuleArtifactPayloadEx vfModule) {
+ Map<String, ArtifactDefinition> deploymentArtifacts, VfModuleArtifactPayloadEx vfModule) {
List<String> artifacts = gi.getArtifacts();
List<String> artifactsUuid = gi.getArtifactsUuid();
List<String> instArtifactsUuid = gi.getGroupInstanceArtifactsUuid();
List<String> instArtifactsId = gi.getGroupInstanceArtifacts();
Set<String> instArtifatIdSet = new HashSet<>();
- Set<String> artifactsSet = new HashSet<>();
-
+ Set<String> artifactsSet = new HashSet<>();
+
log.info("check group {} for instance {} ", gi.getGroupName(), instName);
if ((artifactsUuid == null || artifactsUuid.isEmpty()) && (artifacts == null || artifacts.isEmpty())) {
log.info("No instance groups for instance {} in service {} ", instName, servicename);
@@ -548,12 +557,12 @@ public class ArtifactUuidFix {
if(vfModule != null && artifactsUuid != null){
return isProblematicVFModule(vfModule, artifactsUuid, instArtifactsUuid);
}
-
+
return false;
}
private boolean isProblematicVFModule(VfModuleArtifactPayloadEx vfModule, List<String> artifactsUuid,
- List<String> instArtifactsUuid) {
+ List<String> instArtifactsUuid) {
log.info(" isProblematicVFModule {} ", vfModule.getVfModuleModelName());
List<String> vfModuleArtifacts = vfModule.getArtifacts();
List<String> allArtifacts = new ArrayList<>();
@@ -580,10 +589,10 @@ public class ArtifactUuidFix {
return false;
}
-
+
private boolean fix(List<Resource> vfLst, List<Service> serviceList, Map<String, List<Component>> nodesToFixTosca,
- Map<String, List<Component>> vfToFixTosca, Map<String, List<Component>> servicesToFixTosca) {
+ Map<String, List<Component>> vfToFixTosca, Map<String, List<Component>> servicesToFixTosca) {
boolean res = true;
log.info(" Fix started ***** ");
if (vfLst != null && !vfLst.isEmpty()) {
@@ -600,6 +609,7 @@ public class ArtifactUuidFix {
long time = System.currentTimeMillis();
String fileName = "FailedGenerateTosca" + "_" + time + ".csv";
+
try(Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName), UTF8))) {
writer.write("componentType, name, version, UID, UUID, invariantUUID, state\n");
List<Component> failedList = new ArrayList<>();
@@ -614,7 +624,7 @@ public class ArtifactUuidFix {
generateAndSaveToscaArtifacts(vfToFixTosca, fixedIds, vfLst, failedList);
}
-
+
for (Component component : vfLst) {
res = generateToscaPerComponent(fixedIds, component);
if (res) {
@@ -642,7 +652,7 @@ public class ArtifactUuidFix {
}
-
+
for (Component component : serviceList) {
res = generateToscaPerComponent(fixedIds, component);
if (res) {
@@ -690,7 +700,7 @@ public class ArtifactUuidFix {
}
private boolean generateAndSaveToscaArtifacts(Map<String, List<Component>> nodesToFixTosca, Set<String> fixedIds,
- List<? extends Component> componentsWithFailedGroups, List<Component> failedList) {
+ List<? extends Component> componentsWithFailedGroups, List<Component> failedList) {
boolean res = true;
log.debug("Migration1707ArtifactUuidFix generateAndSaveToscaArtifacts started ");
for (Map.Entry<String, List<Component>> entry : nodesToFixTosca.entrySet()) {
@@ -751,9 +761,9 @@ public class ArtifactUuidFix {
log.error("Couldn't generate and save tosca template component unique id {}, name {} error: {}",
toscaElementFull.getUniqueId(), toscaElementFull.getName(), either.right().value());
res = false;
-
+
}
-
+
if (res) {
c.setToscaArtifacts(either.left().value().getToscaArtifacts());
fixedIds.add(toscaElementFull.getUniqueId());
@@ -770,7 +780,7 @@ public class ArtifactUuidFix {
}
private <T extends ToscaDataDefinition> boolean fixDataOnGraph(String componentId, VertexTypeEnum vertexTypeEnum,
- EdgeLabelEnum edgeLabelEnum, Map<String, T> groups) {
+ EdgeLabelEnum edgeLabelEnum, Map<String, T> groups) {
log.debug("amount groups to update: VertexTypeEnum {} EdgeLabelEnum {} data size {}", vertexTypeEnum.getName(),
edgeLabelEnum, groups.size());
boolean res = true;
@@ -860,7 +870,7 @@ public class ArtifactUuidFix {
}
private void fixGroupInstances(Service service, Map<String, ArtifactDefinition> artifactsMap,
- List<GroupInstance> groupsToDelete, GroupInstance group) {
+ List<GroupInstance> groupsToDelete, GroupInstance group) {
if (group.getType().equals(Constants.DEFAULT_GROUP_VF_MODULE)) {
log.debug("Migration1707ArtifactUuidFix fix group: resource id {}, group name {} ", service.getUniqueId(),
group.getName());
@@ -871,9 +881,9 @@ public class ArtifactUuidFix {
groupArtifactsSet.addAll(groupInsArtifacts);
}
List<String> groupArtifacts = new ArrayList<>(groupArtifactsSet);
-
+
clearGroupInstanceArtifacts(group);
-
+
for (String artifactId : groupArtifacts) {
fixArtifactUndergroupInstances(artifactsMap, group, groupArtifacts, artifactId);
}
@@ -902,14 +912,14 @@ public class ArtifactUuidFix {
else{
group.setGroupInstanceArtifacts(new ArrayList<>());
}
- if(group.getGroupInstanceArtifactsUuid() != null )
+ if(group.getGroupInstanceArtifactsUuid() != null )
group.getGroupInstanceArtifactsUuid().clear();
else
group.setGroupInstanceArtifactsUuid(new ArrayList<>());
}
private void fixArtifactUndergroupInstances(Map<String, ArtifactDefinition> artifactsMap, GroupInstance group,
- List<String> groupArtifacts, String artifactId) {
+ List<String> groupArtifacts, String artifactId) {
String artifactlabel = findArtifactLabelFromArtifactId(artifactId);
log.debug("Migration1707ArtifactUuidFix fix group: group name {} artifactId for fix {} artifactlabel {} ",
group.getName(), artifactId, artifactlabel);
@@ -938,7 +948,7 @@ public class ArtifactUuidFix {
} else {
log.debug(
MIGRATION1707_ARTIFACT_UUID_FIX,
- group.getName(), correctArtifactId, correctArtifactUUID);
+ group.getName(), correctArtifactId, correctArtifactUUID);
Set<String> tmpSet = new HashSet<>(group.getGroupInstanceArtifacts());
tmpSet.add(correctArtifactId);
group.setGroupInstanceArtifacts(new ArrayList<>(tmpSet));
@@ -997,7 +1007,7 @@ public class ArtifactUuidFix {
}
private void fixArtifactUnderGroup(Map<String, ArtifactDefinition> artifactsMap, GroupDefinition group,
- List<String> groupArtifacts, String artifactId) {
+ List<String> groupArtifacts, String artifactId) {
String artifactlabel = findArtifactLabelFromArtifactId(artifactId);
log.debug("Migration1707ArtifactUuidFix fix group: group name {} artifactId for fix {} artifactlabel {} ",
@@ -1037,7 +1047,7 @@ public class ArtifactUuidFix {
}
private void writeModuleResultToFile(Writer writer, org.openecomp.sdc.be.model.Component component,
- Service service) {
+ Service service) {
try {
// "service name, service id, state, version
StringBuilder sb = new StringBuilder(component.getName());
@@ -1071,7 +1081,7 @@ public class ArtifactUuidFix {
}
public boolean doFixTosca(Map<String, List<Component>> nodeToFix, Map<String, List<Component>> vfToFix,
- Map<String, List<Component>> serviceToFix) {
+ Map<String, List<Component>> serviceToFix) {
Map<GraphPropertyEnum, Object> hasProps = new EnumMap<>(GraphPropertyEnum.class);
hasProps.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.RESOURCE.name());
@@ -1099,7 +1109,7 @@ public class ArtifactUuidFix {
}
public Map<String, List<Component>> getVerticesToValidate(VertexTypeEnum type,
- Map<GraphPropertyEnum, Object> hasProps) {
+ Map<GraphPropertyEnum, Object> hasProps) {
Map<String, List<Component>> result = new HashMap<>();
try {
@@ -1146,7 +1156,7 @@ public class ArtifactUuidFix {
}
public boolean validateTosca(Map<String, List<Component>> vertices, Map<String, List<Component>> compToFix,
- String name) {
+ String name) {
boolean result = true;
long time = System.currentTimeMillis();
String fileName = name + "_" + time + ".csv";
@@ -1238,7 +1248,7 @@ public class ArtifactUuidFix {
toscaArtifact.setEsId(toscaArtifact.getUniqueId());
toscaArtifact.setArtifactChecksum(GeneralUtility.calculateMD5Base64EncodedByByteArray(decodedPayload));
- ESArtifactData artifactData = new ESArtifactData(toscaArtifact.getEsId(), decodedPayload);
+ DAOArtifactData artifactData = new DAOArtifactData(toscaArtifact.getEsId(), decodedPayload);
artifactCassandraDao.saveArtifact(artifactData);
log.debug("Tosca yaml artifact esId {} ", toscaArtifact.getEsId());
@@ -1270,7 +1280,7 @@ public class ArtifactUuidFix {
csarArtifact.setEsId(csarArtifact.getUniqueId());
csarArtifact.setArtifactChecksum(GeneralUtility.calculateMD5Base64EncodedByByteArray(decodedPayload));
- ESArtifactData artifactData = new ESArtifactData(csarArtifact.getEsId(), decodedPayload);
+ DAOArtifactData artifactData = new DAOArtifactData(csarArtifact.getEsId(), decodedPayload);
artifactCassandraDao.saveArtifact(artifactData);
log.debug("Tosca csar artifact esId {} ", csarArtifact.getEsId());
@@ -1285,29 +1295,29 @@ public class ArtifactUuidFix {
return Either.left(parent);
}
-
- private ArtifactDefinition createVfModuleArtifact(ComponentInstance currVF, Service service) {
- ArtifactDefinition vfModuleArtifactDefinition = new ArtifactDefinition();
+ private ArtifactDefinition createVfModuleArtifact(ComponentInstance currVF, Service service) {
- vfModuleArtifactDefinition.setDescription("Auto-generated VF Modules information artifact");
- vfModuleArtifactDefinition.setArtifactDisplayName("Vf Modules Metadata");
- vfModuleArtifactDefinition.setArtifactType(ArtifactTypeEnum.VF_MODULES_METADATA.getType());
- vfModuleArtifactDefinition.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT);
- vfModuleArtifactDefinition.setArtifactLabel("vfModulesMetadata");
- vfModuleArtifactDefinition.setTimeout(0);
- vfModuleArtifactDefinition.setArtifactName(currVF.getNormalizedName() + "_modules.json");
-
- return vfModuleArtifactDefinition;
- }
+ ArtifactDefinition vfModuleArtifactDefinition = new ArtifactDefinition();
+
+ vfModuleArtifactDefinition.setDescription("Auto-generated VF Modules information artifact");
+ vfModuleArtifactDefinition.setArtifactDisplayName("Vf Modules Metadata");
+ vfModuleArtifactDefinition.setArtifactType(ArtifactTypeEnum.VF_MODULES_METADATA.getType());
+ vfModuleArtifactDefinition.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT);
+ vfModuleArtifactDefinition.setArtifactLabel("vfModulesMetadata");
+ vfModuleArtifactDefinition.setTimeout(0);
+ vfModuleArtifactDefinition.setArtifactName(currVF.getNormalizedName() + "_modules.json");
+
+ return vfModuleArtifactDefinition;
+ }
private void fillVfModuleInstHeatEnvPayload(Component parent, ComponentInstance instance, List<GroupInstance> groupsForCurrVF,
- ArtifactDefinition vfModuleArtifact) {
+ ArtifactDefinition vfModuleArtifact) {
log.debug("generate new vf module for component. name {}, id {}, Version {}", instance.getName(), instance.getUniqueId());
-
+
String uniqueId = UniqueIdBuilder.buildInstanceArtifactUniqueId(parent.getUniqueId(), instance.getUniqueId(), vfModuleArtifact.getArtifactLabel());
-
+
vfModuleArtifact.setUniqueId(uniqueId);
vfModuleArtifact.setEsId(vfModuleArtifact.getUniqueId());
@@ -1329,7 +1339,7 @@ public class ArtifactUuidFix {
.calculateMD5Base64EncodedByByteArray(vfModulePayloadString.getBytes());
vfModuleArtifact.setArtifactChecksum(newCheckSum);
- ESArtifactData artifactData = new ESArtifactData(vfModuleArtifact.getEsId(),
+ DAOArtifactData artifactData = new DAOArtifactData(vfModuleArtifact.getEsId(),
vfModulePayloadString.getBytes());
artifactCassandraDao.saveArtifact(artifactData);
@@ -1338,21 +1348,21 @@ public class ArtifactUuidFix {
}
}
-
+
private Either<List<VfModuleArtifactPayloadEx>, StorageOperationStatus> parseVFModuleJson(ArtifactDefinition vfModuleArtifact) {
log.info("Try to get vfModule json from cassandra {}", vfModuleArtifact.getEsId());
- Either<ESArtifactData, CassandraOperationStatus> vfModuleData = artifactCassandraDao.getArtifact(vfModuleArtifact.getEsId());
-
+ Either<DAOArtifactData, CassandraOperationStatus> vfModuleData = artifactCassandraDao.getArtifact(vfModuleArtifact.getEsId());
+
if (vfModuleData.isRight()) {
CassandraOperationStatus resourceUploadStatus = vfModuleData.right().value();
StorageOperationStatus storageResponse = DaoStatusConverter.convertCassandraStatusToStorageStatus(resourceUploadStatus);
log.error("failed to fetch vfModule json {} from cassandra. Status is {}", vfModuleArtifact.getEsId(), storageResponse);
return Either.right(storageResponse);
-
+
}
- ESArtifactData esArtifactData = vfModuleData.left().value();
- String gsonData = new String( esArtifactData.getDataAsArray());
+ DAOArtifactData DAOArtifactData = vfModuleData.left().value();
+ String gsonData = new String( DAOArtifactData.getDataAsArray());
final Gson gson = new GsonBuilder().setPrettyPrinting().create();
JsonArray jsonElement = new JsonArray();
jsonElement = gson.fromJson(gsonData, jsonElement.getClass());
@@ -1361,10 +1371,10 @@ public class ArtifactUuidFix {
VfModuleArtifactPayloadEx vfModule = ComponentsUtils.parseJsonToObject(je.toString(), VfModuleArtifactPayloadEx.class);
vfModules.add(vfModule);
});
-
+
log.debug ("parse vf module finish {}", gsonData);
return Either.left(vfModules);
-
+
}
}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/DataMigration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/DataMigration.java
deleted file mode 100644
index 2e14b906ff..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/DataMigration.java
+++ /dev/null
@@ -1,813 +0,0 @@
-/*-
- * ============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=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl;
-
-
-import com.carrotsearch.hppc.cursors.ObjectCursor;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import fj.data.Either;
-import org.apache.commons.lang.SystemUtils;
-import org.elasticsearch.action.search.SearchResponse;
-import org.elasticsearch.cluster.metadata.IndexMetaData;
-import org.elasticsearch.common.collect.ImmutableOpenMap;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.common.unit.TimeValue;
-import org.elasticsearch.index.query.QueryBuilder;
-import org.elasticsearch.index.query.QueryBuilders;
-import org.elasticsearch.search.SearchHit;
-import org.openecomp.sdc.be.auditing.api.AuditEventFactory;
-import org.openecomp.sdc.be.auditing.impl.AuditAuthRequestEventFactory;
-import org.openecomp.sdc.be.auditing.impl.AuditConsumerEventFactory;
-import org.openecomp.sdc.be.auditing.impl.AuditGetUebClusterEventFactory;
-import org.openecomp.sdc.be.auditing.impl.category.AuditCategoryEventFactory;
-import org.openecomp.sdc.be.auditing.impl.category.AuditGetCategoryHierarchyEventFactory;
-import org.openecomp.sdc.be.auditing.impl.distribution.*;
-import org.openecomp.sdc.be.auditing.impl.resourceadmin.AuditResourceAdminEventMigrationFactory;
-import org.openecomp.sdc.be.auditing.impl.usersadmin.AuditGetUsersListEventFactory;
-import org.openecomp.sdc.be.auditing.impl.usersadmin.AuditUserAccessEventFactory;
-import org.openecomp.sdc.be.auditing.impl.usersadmin.AuditUserAdminEventFactory;
-import org.openecomp.sdc.be.dao.cassandra.ArtifactCassandraDao;
-import org.openecomp.sdc.be.dao.cassandra.AuditCassandraDao;
-import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus;
-import org.openecomp.sdc.be.dao.cassandra.schema.Table;
-import org.openecomp.sdc.be.dao.es.ElasticSearchClient;
-import org.openecomp.sdc.be.resources.data.ESArtifactData;
-import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
-import org.openecomp.sdc.be.resources.data.auditing.AuditingGenericEvent;
-import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
-import org.openecomp.sdc.be.resources.data.auditing.model.*;
-import org.openecomp.sdc.common.datastructure.AuditingFieldsKey;
-import org.openecomp.sdc.common.log.wrappers.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import java.io.*;
-import java.net.MalformedURLException;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.EnumMap;
-import java.util.Map;
-
-/**
- * Created by mlando on 5/16/2016.
- */
-public class DataMigration {
-
- private ObjectMapper jsonMapper = new ObjectMapper();
-
- private static Logger log = Logger.getLogger(DataMigration.class.getName());
-
- private ElasticSearchClient elasticSearchClient;
- private AuditCassandraDao auditCassandraDao;
- private ArtifactCassandraDao artifactCassandraDao;
-
- @Autowired
- public DataMigration(AuditCassandraDao auditCassandraDao,
- ArtifactCassandraDao artifactCassandraDao) {
- this.auditCassandraDao = auditCassandraDao;
- this.artifactCassandraDao = artifactCassandraDao;
- }
-
- /**
- * the method exports and imports the records from ES to cassandra the flow
- * will check to see if the files are not empty if the files are not empty
- * the export will be skiped and the flow will use the existing files. the
- * flow will check if the tables in cassandra are empty, if the tables are
- * not empty the proces will stop and exit. if the tables are empty the
- * method will import the records from the files. in case of a fail the flow
- * will exit and clear all the Cassandra tables.
- *
- * @param appConfigDir
- * the location of the dir in wich the output files will be
- * stored
- * @param exportFromEs
- * should the es be exported again and overwrite the old export
- * @param importToCassandra
- * should we import the data into cassandra
- * @return true in case the operation was successful.
- */
- public boolean migrateDataESToCassndra(String appConfigDir, boolean exportFromEs, boolean importToCassandra) {
- if (!initEsClient()) {
- return false;
- }
- Map<Table, File> files = createOutPutFiles(appConfigDir, exportFromEs);
- if (files == null) {
- return false;
- }
- if (exportFromEs && filesEmpty(files)) {
- Map<Table, PrintWriter> printerWritersMap = createWriters(files);
- if (printerWritersMap == null) {
- return false;
- }
- try {
- ImmutableOpenMap<String, IndexMetaData> indexData = getIndexData();
- for (ObjectCursor<String> key : indexData.keys()) {
- if (("resources".equalsIgnoreCase(key.value) || key.value.startsWith("auditingevents"))
- && !exportArtifacts(key.value, printerWritersMap)) {
- return false;
- }
- }
- } finally {
- if (elasticSearchClient != null) {
- elasticSearchClient.close();
- }
- for (PrintWriter writer : printerWritersMap.values()) {
- writer.close();
- }
- }
- }
-
- return !importToCassandra || importToCassndra(files);
- }
-
- private boolean initEsClient() {
- String configHome = System.getProperty("config.home");
- URL url = null;
- Settings settings = null;
- try {
- if (SystemUtils.IS_OS_WINDOWS) {
- url = new URL("file:///" + configHome + "/elasticsearch.yml");
- } else {
- url = new URL("file:" + configHome + "/elasticsearch.yml");
- }
- log.debug("URL {}", url);
- settings = Settings.settingsBuilder().loadFromPath(Paths.get(url.toURI())).build();
- } catch (MalformedURLException | URISyntaxException e1) {
- log.error("Failed to create URL in order to load elasticsearch yml", e1);
- return true;
- }
-
- this.elasticSearchClient = new ElasticSearchClient();
- this.elasticSearchClient.setClusterName(settings.get("cluster.name"));
- this.elasticSearchClient.setLocal(settings.get("elasticSearch.local"));
- this.elasticSearchClient.setTransportClient(settings.get("elasticSearch.transportclient"));
- try {
- elasticSearchClient.initialize();
- } catch (URISyntaxException e) {
- log.error(e.getMessage());
- return false;
- }
- return true;
- }
-
- /**
- * the method clears all the cassandra tables
- */
- private void truncateCassandraTable() {
- log.info("import failed. truncating Cassandra tables.");
- artifactCassandraDao.deleteAllArtifacts();
- auditCassandraDao.deleteAllAudit();
- }
-
- /**
- * the method imports the records from the files into cassandra
- *
- * @param files
- * a map of files holding
- * @return true if the operation was successful
- */
- private boolean importToCassndra(Map<Table, File> files) {
- log.info("starting to import date into Cassandra.");
- if (!validtaTablsNotEmpty(files))
- return true;
- for (Table table : files.keySet()) {
- log.info("importing recordes into {}", table.getTableDescription().getTableName());
- if (!handleImport(files, table)) {
- truncateCassandraTable();
- return false;
- }
- }
- log.info("finished to import date into Cassandra.");
- return true;
- }
-
- private boolean validtaTablsNotEmpty(Map<Table, File> files) {
- for (Table table : files.keySet()) {
- Either<Boolean, CassandraOperationStatus> isTableEmptyRes = checkIfTableIsEmpty(table);
- if (isTableEmptyRes.isRight() || !isTableEmptyRes.left().value()) {
- log.error("Cassandra table {} is not empty operation aborted.",
- table.getTableDescription().getTableName());
- return false;
- }
- }
- return true;
- }
-
- /**
- * the method retrieves the fields from the given map and generates
- * corresponding audit event according to the table name
- *
- * @param map
- * the map from which we will retrieve the fields enum values
- * @param table
- * the table we are going to store the record in.
- * @return an AuditingGenericEvent event representing the audit record that is going to be
- * created.
- */
- AuditingGenericEvent createAuditEvent(Map<AuditingFieldsKey, String> map, Table table) {
- AuditEventFactory factory = null;
- switch (table) {
- case USER_ADMIN_EVENT:
- factory = getAuditUserAdminEventFactory(map);
- break;
- case USER_ACCESS_EVENT:
- factory = getAuditUserAccessEventFactory(map);
- break;
- case RESOURCE_ADMIN_EVENT:
- factory = getAuditResourceAdminEventMigrationFactory(map);
- break;
- case DISTRIBUTION_DOWNLOAD_EVENT:
- factory = getAuditDistributionDownloadEventFactory(map);
- break;
- case DISTRIBUTION_ENGINE_EVENT:
- factory = getAuditDistributionEngineEventMigrationFactory(map);
- break;
- case DISTRIBUTION_NOTIFICATION_EVENT:
- factory = getAuditDistributionNotificationEventFactory(map);
- break;
- case DISTRIBUTION_STATUS_EVENT:
- factory = getAuditDistributionStatusEventFactory(map);
- break;
- case DISTRIBUTION_DEPLOY_EVENT:
- factory = getAuditDistributionDeployEventFactory(map);
- break;
- case DISTRIBUTION_GET_UEB_CLUSTER_EVENT:
- factory = getAuditGetUebClusterEventFactory(map);
- break;
- case AUTH_EVENT:
- factory = getAuditAuthRequestEventFactory(map);
- break;
- case CONSUMER_EVENT:
- factory = getAuditConsumerEventFactory(map);
- break;
- case CATEGORY_EVENT:
- factory = getAuditCategoryEventFactory(map);
- break;
- case GET_USERS_LIST_EVENT:
- factory = getAuditGetUsersListEventFactory(map);
- break;
- case GET_CATEGORY_HIERARCHY_EVENT:
- factory = getAuditGetCategoryHierarchyEventFactory(map);
- break;
- default:
- break;
- }
- return factory != null ? factory.getDbEvent() : null;
- }
-
- private AuditEventFactory getAuditGetCategoryHierarchyEventFactory(Map<AuditingFieldsKey, String> map) {
- return new AuditGetCategoryHierarchyEventFactory(
- CommonAuditData.newBuilder()
- .description(map.get(AuditingFieldsKey.AUDIT_DESC))
- .status(map.get(AuditingFieldsKey.AUDIT_STATUS))
- .requestId(map.get(AuditingFieldsKey.AUDIT_REQUEST_ID))
- .serviceInstanceId(map.get(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID))
- .build(),
- map.get(AuditingFieldsKey.AUDIT_MODIFIER_UID),
- map.get(AuditingFieldsKey.AUDIT_DETAILS),
- map.get(AuditingFieldsKey.AUDIT_TIMESTAMP));
- }
-
- private AuditEventFactory getAuditGetUsersListEventFactory(Map<AuditingFieldsKey, String> map) {
- return new AuditGetUsersListEventFactory(
- CommonAuditData.newBuilder()
- .description(map.get(AuditingFieldsKey.AUDIT_DESC))
- .status(map.get(AuditingFieldsKey.AUDIT_STATUS))
- .requestId(map.get(AuditingFieldsKey.AUDIT_REQUEST_ID))
- .serviceInstanceId(map.get(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID))
- .build(),
- map.get(AuditingFieldsKey.AUDIT_MODIFIER_UID),
- map.get(AuditingFieldsKey.AUDIT_USER_DETAILS),
- map.get(AuditingFieldsKey.AUDIT_TIMESTAMP));
- }
-
- private AuditEventFactory getAuditCategoryEventFactory(Map<AuditingFieldsKey, String> map) {
- return new AuditCategoryEventFactory(
- AuditingActionEnum.fromName(map.get(AuditingFieldsKey.AUDIT_ACTION)),
- CommonAuditData.newBuilder()
- .description(map.get(AuditingFieldsKey.AUDIT_DESC))
- .status(map.get(AuditingFieldsKey.AUDIT_STATUS))
- .requestId(map.get(AuditingFieldsKey.AUDIT_REQUEST_ID))
- .serviceInstanceId(map.get(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID))
- .build(),
- map.get(AuditingFieldsKey.AUDIT_MODIFIER_UID),
- map.get(AuditingFieldsKey.AUDIT_CATEGORY_NAME),
- map.get(AuditingFieldsKey.AUDIT_SUB_CATEGORY_NAME),
- map.get(AuditingFieldsKey.AUDIT_GROUPING_NAME),
- map.get(AuditingFieldsKey.AUDIT_RESOURCE_TYPE),
- map.get(AuditingFieldsKey.AUDIT_TIMESTAMP));
- }
-
- private AuditEventFactory getAuditUserAccessEventFactory(Map<AuditingFieldsKey, String> map) {
- return new AuditUserAccessEventFactory(
- CommonAuditData.newBuilder()
- .description(map.get(AuditingFieldsKey.AUDIT_DESC))
- .status(map.get(AuditingFieldsKey.AUDIT_STATUS))
- .requestId(map.get(AuditingFieldsKey.AUDIT_REQUEST_ID))
- .serviceInstanceId(map.get(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID))
- .build(),
- map.get(AuditingFieldsKey.AUDIT_USER_UID),
- map.get(AuditingFieldsKey.AUDIT_TIMESTAMP));
- }
-
- private AuditEventFactory getAuditUserAdminEventFactory(Map<AuditingFieldsKey, String> map) {
- return new AuditUserAdminEventFactory(
- AuditingActionEnum.fromName(map.get(AuditingFieldsKey.AUDIT_ACTION)),
- CommonAuditData.newBuilder()
- .description(map.get(AuditingFieldsKey.AUDIT_DESC))
- .status(map.get(AuditingFieldsKey.AUDIT_STATUS))
- .requestId(map.get(AuditingFieldsKey.AUDIT_REQUEST_ID))
- .serviceInstanceId(map.get(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID))
- .build(),
- map.get(AuditingFieldsKey.AUDIT_MODIFIER_UID),
- map.get(AuditingFieldsKey.AUDIT_USER_BEFORE),
- map.get(AuditingFieldsKey.AUDIT_USER_AFTER),
- map.get(AuditingFieldsKey.AUDIT_TIMESTAMP));
- }
-
- private AuditEventFactory getAuditConsumerEventFactory(Map<AuditingFieldsKey, String> map) {
- return new AuditConsumerEventFactory(
- AuditingActionEnum.fromName(map.get(AuditingFieldsKey.AUDIT_ACTION)),
- CommonAuditData.newBuilder()
- .description(map.get(AuditingFieldsKey.AUDIT_DESC))
- .status(map.get(AuditingFieldsKey.AUDIT_STATUS))
- .requestId(map.get(AuditingFieldsKey.AUDIT_REQUEST_ID))
- .serviceInstanceId(map.get(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID))
- .build(),
- map.get(AuditingFieldsKey.AUDIT_MODIFIER_UID),
- map.get(AuditingFieldsKey.AUDIT_ECOMP_USER),
- map.get(AuditingFieldsKey.AUDIT_TIMESTAMP));
- }
-
- private AuditEventFactory getAuditAuthRequestEventFactory(Map<AuditingFieldsKey, String> map) {
- return new AuditAuthRequestEventFactory(
- CommonAuditData.newBuilder()
- .description(map.get(AuditingFieldsKey.AUDIT_DESC))
- .status(map.get(AuditingFieldsKey.AUDIT_STATUS))
- .requestId(map.get(AuditingFieldsKey.AUDIT_REQUEST_ID))
- .serviceInstanceId(map.get(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID))
- .build(),
- map.get(AuditingFieldsKey.AUDIT_USER_UID),
- map.get(AuditingFieldsKey.AUDIT_AUTH_URL),
- map.get(AuditingFieldsKey.AUDIT_AUTH_REALM),
- map.get(AuditingFieldsKey.AUDIT_AUTH_STATUS),
- map.get(AuditingFieldsKey.AUDIT_TIMESTAMP));
- }
-
- private AuditEventFactory getAuditGetUebClusterEventFactory(Map<AuditingFieldsKey, String> map) {
- return new AuditGetUebClusterEventFactory(
- CommonAuditData.newBuilder()
- .description(map.get(AuditingFieldsKey.AUDIT_DESC))
- .status(map.get(AuditingFieldsKey.AUDIT_STATUS))
- .requestId(map.get(AuditingFieldsKey.AUDIT_REQUEST_ID))
- .serviceInstanceId(map.get(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID))
- .build(),
- map.get(AuditingFieldsKey.AUDIT_DISTRIBUTION_CONSUMER_ID),
- map.get(AuditingFieldsKey.AUDIT_TIMESTAMP));
- }
-
- private AuditEventFactory getAuditResourceAdminEventMigrationFactory(Map<AuditingFieldsKey, String> map) {
- return new AuditResourceAdminEventMigrationFactory(
- AuditingActionEnum.fromName(map.get(AuditingFieldsKey.AUDIT_ACTION)),
- CommonAuditData.newBuilder()
- .description(map.get(AuditingFieldsKey.AUDIT_DESC))
- .status(map.get(AuditingFieldsKey.AUDIT_STATUS))
- .requestId(map.get(AuditingFieldsKey.AUDIT_REQUEST_ID))
- .serviceInstanceId(map.get(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID))
- .build(),
- new ResourceCommonInfo(map.get(AuditingFieldsKey.AUDIT_RESOURCE_NAME),
- map.get(AuditingFieldsKey.AUDIT_RESOURCE_TYPE)),
- ResourceVersionInfo.newBuilder()
- .artifactUuid(map.get(AuditingFieldsKey.AUDIT_PREV_ARTIFACT_UUID))
- .state(map.get(AuditingFieldsKey.AUDIT_RESOURCE_PREV_STATE))
- .version(map.get(AuditingFieldsKey.AUDIT_RESOURCE_PREV_VERSION))
- .distributionStatus(map.get(AuditingFieldsKey.AUDIT_RESOURCE_DPREV_STATUS))
- .build(),
- ResourceVersionInfo.newBuilder()
- .artifactUuid(map.get(AuditingFieldsKey.AUDIT_CURR_ARTIFACT_UUID))
- .state(map.get(AuditingFieldsKey.AUDIT_RESOURCE_CURR_STATE))
- .version(map.get(AuditingFieldsKey.AUDIT_RESOURCE_CURR_VERSION))
- .distributionStatus(map.get(AuditingFieldsKey.AUDIT_RESOURCE_DCURR_STATUS))
- .build(),
- map.get(AuditingFieldsKey.AUDIT_INVARIANT_UUID),
- map.get(AuditingFieldsKey.AUDIT_MODIFIER_UID),
- map.get(AuditingFieldsKey.AUDIT_ARTIFACT_DATA),
- map.get(AuditingFieldsKey.AUDIT_RESOURCE_COMMENT),
- map.get(AuditingFieldsKey.AUDIT_DISTRIBUTION_ID),
- map.get(AuditingFieldsKey.AUDIT_RESOURCE_TOSCA_NODE_TYPE),
- map.get(AuditingFieldsKey.AUDIT_TIMESTAMP));
- }
-
- private AuditEventFactory getAuditDistributionDownloadEventFactory(Map<AuditingFieldsKey, String> map) {
- return new AuditDistributionDownloadEventFactory(
- CommonAuditData.newBuilder()
- .description(map.get(AuditingFieldsKey.AUDIT_DESC))
- .status(map.get(AuditingFieldsKey.AUDIT_STATUS))
- .requestId(map.get(AuditingFieldsKey.AUDIT_REQUEST_ID))
- .serviceInstanceId(map.get(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID))
- .build(),
- new DistributionData(map.get(AuditingFieldsKey.AUDIT_DISTRIBUTION_CONSUMER_ID),
- map.get(AuditingFieldsKey.AUDIT_RESOURCE_URL)),
- map.get(AuditingFieldsKey.AUDIT_TIMESTAMP));
- }
-
- private AuditEventFactory getAuditDistributionEngineEventMigrationFactory(Map<AuditingFieldsKey, String> map) {
- return new AuditDistributionEngineEventMigrationFactory(
- AuditingActionEnum.fromName(map.get(AuditingFieldsKey.AUDIT_ACTION)),
- CommonAuditData.newBuilder()
- .description(map.get(AuditingFieldsKey.AUDIT_DESC))
- .status(map.get(AuditingFieldsKey.AUDIT_STATUS))
- .requestId(map.get(AuditingFieldsKey.AUDIT_REQUEST_ID))
- .serviceInstanceId(map.get(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID))
- .build(),
- DistributionTopicData.newBuilder()
- .notificationTopic(map.get(AuditingFieldsKey.AUDIT_DISTRIBUTION_NOTIFICATION_TOPIC_NAME))
- .statusTopic(map.get(AuditingFieldsKey.AUDIT_DISTRIBUTION_STATUS_TOPIC_NAME))
- .build(),
- map.get(AuditingFieldsKey.AUDIT_DISTRIBUTION_CONSUMER_ID),
- map.get(AuditingFieldsKey.AUDIT_DISTRIBUTION_API_KEY),
- map.get(AuditingFieldsKey.AUDIT_DISTRIBUTION_ENVRIONMENT_NAME),
- map.get(AuditingFieldsKey.AUDIT_DISTRIBUTION_ROLE),
- map.get(AuditingFieldsKey.AUDIT_TIMESTAMP));
- }
-
- private AuditEventFactory getAuditDistributionDeployEventFactory(Map<AuditingFieldsKey, String> map) {
- return new AuditDistributionDeployEventFactory(
- CommonAuditData.newBuilder()
- .description(map.get(AuditingFieldsKey.AUDIT_DESC))
- .status(map.get(AuditingFieldsKey.AUDIT_STATUS))
- .requestId(map.get(AuditingFieldsKey.AUDIT_REQUEST_ID))
- .serviceInstanceId(map.get(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID))
- .build(),
- new ResourceCommonInfo(map.get(AuditingFieldsKey.AUDIT_RESOURCE_NAME),
- map.get(AuditingFieldsKey.AUDIT_RESOURCE_TYPE)),
- map.get(AuditingFieldsKey.AUDIT_RESOURCE_CURR_VERSION),
- map.get(AuditingFieldsKey.AUDIT_DISTRIBUTION_ID),
- map.get(AuditingFieldsKey.AUDIT_MODIFIER_UID),
- map.get(AuditingFieldsKey.AUDIT_TIMESTAMP));
- }
-
- private AuditEventFactory getAuditDistributionStatusEventFactory(Map<AuditingFieldsKey, String> map) {
- return new AuditDistributionStatusEventFactory(
- CommonAuditData.newBuilder()
- .description(map.get(AuditingFieldsKey.AUDIT_DESC))
- .status(map.get(AuditingFieldsKey.AUDIT_STATUS))
- .requestId(map.get(AuditingFieldsKey.AUDIT_REQUEST_ID))
- .serviceInstanceId(map.get(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID))
- .build(),
- new DistributionData(map.get(AuditingFieldsKey.AUDIT_DISTRIBUTION_CONSUMER_ID),
- map.get(AuditingFieldsKey.AUDIT_RESOURCE_URL)),
- map.get(AuditingFieldsKey.AUDIT_DISTRIBUTION_ID),
- map.get(AuditingFieldsKey.AUDIT_DISTRIBUTION_TOPIC_NAME),
- map.get(AuditingFieldsKey.AUDIT_DISTRIBUTION_STATUS_TIME),
- map.get(AuditingFieldsKey.AUDIT_TIMESTAMP));
- }
-
- private AuditEventFactory getAuditDistributionNotificationEventFactory(Map<AuditingFieldsKey, String> map) {
- return new AuditDistributionNotificationEventFactory(
- CommonAuditData.newBuilder()
- .description(map.get(AuditingFieldsKey.AUDIT_DESC))
- .status(map.get(AuditingFieldsKey.AUDIT_STATUS))
- .requestId(map.get(AuditingFieldsKey.AUDIT_REQUEST_ID))
- .serviceInstanceId(map.get(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID))
- .build(),
- new ResourceCommonInfo(map.get(AuditingFieldsKey.AUDIT_RESOURCE_NAME),
- map.get(AuditingFieldsKey.AUDIT_RESOURCE_TYPE)),
- ResourceVersionInfo.newBuilder()
- .state(map.get(AuditingFieldsKey.AUDIT_RESOURCE_CURR_STATE))
- .version(map.get(AuditingFieldsKey.AUDIT_RESOURCE_CURR_VERSION))
- .build(),
- map.get(AuditingFieldsKey.AUDIT_DISTRIBUTION_ID),
- map.get(AuditingFieldsKey.AUDIT_MODIFIER_UID),
- map.get(AuditingFieldsKey.AUDIT_DISTRIBUTION_TOPIC_NAME),
- new OperationalEnvAuditData(map.get(AuditingFieldsKey.AUDIT_DISTRIBUTION_ENVIRONMENT_ID),
- map.get(AuditingFieldsKey.AUDIT_DISTRIBUTION_VNF_WORKLOAD_CONTEXT),
- map.get(AuditingFieldsKey.AUDIT_DISTRIBUTION_TENANT)),
- map.get(AuditingFieldsKey.AUDIT_TIMESTAMP));
- }
-
-
-
- /**
- * the method reads the content of the file intended for a given table, and
- * sores them in cassandra
- *
- * @param files
- * a map of files from which the recordes will be retrieved.
- * @param table
- * the name of the table we want to look up in the files and sore
- * in Cassandra // * @param store the function to call when
- * storing recordes in cassndra
- * @return true if the operation was successful
- */
- private boolean handleImport(Map<Table, File> files, Table table) {
- BufferedReader br = null;
- try {
- br = new BufferedReader(new FileReader(files.get(table)));
- String line = null;
- while ((line = br.readLine()) != null) {
- CassandraOperationStatus res = CassandraOperationStatus.GENERAL_ERROR;
- if (Table.ARTIFACT.equals(table)) {
- res = artifactCassandraDao.saveArtifact(jsonMapper.readValue(line, ESArtifactData.class));
- }
- else {
- AuditingGenericEvent recordForCassandra = createAuditRecordForCassandra(line, table);
- if (recordForCassandra != null) {
- res = auditCassandraDao.saveRecord(recordForCassandra);
- }
- }
- if (!res.equals(CassandraOperationStatus.OK)) {
- log.error("save recored to cassndra {} failed with status {} aborting.",
- table.getTableDescription().getTableName(), res);
- return false;
- }
- }
- return true;
- } catch (IOException e) {
- log.error("failed to read file", e);
- return false;
- } finally {
- if (br != null) {
- try {
- br.close();
- } catch (IOException e) {
- log.error("failed to close file reader", e);
- }
- }
- }
- }
-
- AuditingGenericEvent createAuditRecordForCassandra(String json, Table table) throws IOException{
- return createAuditEvent(parseToMap(json), table);
- }
-
- private Map<AuditingFieldsKey, String> parseToMap(String json) throws IOException {
- return jsonMapper.readValue(json, new TypeReference<Map<AuditingFieldsKey, String>>(){});
- }
-
- /**
- * the method checks if the given table is empty
- *
- * @param table
- * the name of the table we want to check
- * @return true if the table is empty
- */
- private Either<Boolean, CassandraOperationStatus> checkIfTableIsEmpty(Table table) {
- if (Table.ARTIFACT.equals(table)) {
- return artifactCassandraDao.isTableEmpty(table.getTableDescription().getTableName());
- } else {
- return auditCassandraDao.isTableEmpty(table.getTableDescription().getTableName());
- }
- }
-
- private boolean filesEmpty(Map<Table, File> files) {
- for (Table table : files.keySet()) {
- File file = files.get(table);
- if (file.length() != 0) {
- log.info("file:{} is not empty skipping export", table.getTableDescription().getTableName());
- return false;
- }
- }
- return true;
- }
-
- /**
- * the method reads the records from es index of audit's into a file as
- * json's.
- *
- * @param value
- * the name of the index we want
- * @param printerWritersMap
- * a map of the writers we use to write to a file.
- * @return true in case the export was successful.
- */
- private boolean exportAudit(String value, Map<Table, PrintWriter> printerWritersMap) {
- log.info("stratng to export audit data from es index{} to file.", value);
- QueryBuilder queryBuilder = QueryBuilders.matchAllQuery();
- SearchResponse scrollResp = elasticSearchClient.getClient().prepareSearch(value).setScroll(new TimeValue(60000))
- .setQuery(queryBuilder).setSize(100).execute().actionGet();
- while (true) {
- for (SearchHit hit : scrollResp.getHits().getHits()) {
- PrintWriter out = printerWritersMap.get(TypeToTableMapping.getTableByType(hit.getType()));
- out.println(hit.getSourceAsString());
- }
- scrollResp = elasticSearchClient.getClient().prepareSearchScroll(scrollResp.getScrollId())
- .setScroll(new TimeValue(60000)).execute().actionGet();
- if (scrollResp.getHits().getHits().length == 0) {
- break;
-
- }
- }
-
- log.info("export audit data from es to file. finished succsesfully");
- return true;
- }
-
- /**
- * the method reads the records from es index of resources into a file as
- * json's.
- *
- * @param index
- * the name of the index we want to read
- * @param printerWritersMap
- * a map of the writers we use to write to a file.
- * @return true in case the export was successful.
- */
- private boolean exportArtifacts(String index, Map<Table, PrintWriter> printerWritersMap) {
- log.info("stratng to export artifact data from es to file.");
- PrintWriter out = printerWritersMap.get(Table.ARTIFACT);
- QueryBuilder queryBuilder = QueryBuilders.matchAllQuery();
- SearchResponse scrollResp = elasticSearchClient.getClient().prepareSearch(index).setScroll(new TimeValue(60000))
- .setQuery(queryBuilder).setSize(100).execute().actionGet();
- while (true) {
- for (SearchHit hit : scrollResp.getHits().getHits()) {
- ;
- out.println(hit.getSourceAsString());
- }
- scrollResp = elasticSearchClient.getClient().prepareSearchScroll(scrollResp.getScrollId())
- .setScroll(new TimeValue(60000)).execute().actionGet();
- if (scrollResp.getHits().getHits().length == 0) {
- break;
-
- }
- }
-
- log.info("export artifact data from es to file. finished succsesfully");
- return true;
- }
-
- /**
- * the method retrieves all the indexes from elasticsearch
- *
- * @return a map of indexes and there metadata
- */
- private ImmutableOpenMap<String, IndexMetaData> getIndexData() {
- return elasticSearchClient.getClient().admin().cluster().prepareState().get().getState().getMetaData()
- .getIndices();
- }
-
- /**
- * the method creates all the files and dir which holds them. in case the
- * files exist they will not be created again.
- *
- * @param appConfigDir
- * the base path under which the output dir will be created and
- * the export result files the created filesa are named according
- * to the name of the table into which it will be imported.
- * @param exportToEs
- * if true all the export files will be recreated
- * @returnthe returns a map of tables and the files representing them them
- */
- private Map<Table, File> createOutPutFiles(String appConfigDir, boolean exportToEs) {
- Map<Table, File> result = new EnumMap<Table, File>(Table.class);
- File outputDir = new File(appConfigDir + "/output/");
- if (!createOutPutFolder(outputDir)) {
- return null;
- }
- for (Table table : Table.values()) {
- File file = new File(outputDir + "/" + table.getTableDescription().getTableName());
- if (exportToEs) {
- try {
- if (file.exists()) {
- Files.delete(file.toPath());
- }
- } catch (IOException e) {
- log.error("failed to delete output file {}", file.getAbsolutePath(), e);
- return null;
- }
- file = new File(outputDir + "/" + table.getTableDescription().getTableName());
- }
- if (!file.exists()) {
- try {
- file.createNewFile();
- } catch (IOException e) {
- log.error("failed to create output file {}", file.getAbsolutePath(), e);
- return null;
- }
- }
- result.put(table, file);
-
- }
- return result;
- }
-
- /**
- * the method create the writers to each file
- *
- * @param files
- * a map of the files according to table
- * @return returns a map of writers according to table.
- */
- private Map<Table, PrintWriter> createWriters(Map<Table, File> files) {
- Map<Table, PrintWriter> printerWritersMap = new EnumMap<>(Table.class);
-
- for (Table table : files.keySet()) {
- log.info("creating writer for {}", table);
- File file = files.get(table);
- try(PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(file)) )){
- printerWritersMap.put(table, out);
- log.info("creating writer for {} was successful", table);
- } catch (IOException e) {
- log.error("create writer to file failed",e);
- return null;
- }
- }
- return printerWritersMap;
- }
-
- /**
- * the method creates the output dir in case it does not exist
- *
- * @param outputDir
- * the path under wich the directory will be created.
- * @return true in case the create was succsesful or the dir already exists
- */
- private boolean createOutPutFolder(File outputDir) {
- if (!outputDir.exists()) {
- log.info("creating output dir {}", outputDir.getAbsolutePath());
- try {
- Files.createDirectories(outputDir.toPath());
- } catch (IOException e) {
- log.error("failed to create output dir {}", outputDir.getAbsolutePath(), e);
- return false;
- }
- }
- return true;
- }
-
- public enum TypeToTableMapping {
- USER_ADMIN_EVENT_TYPE(AuditingTypesConstants.USER_ADMIN_EVENT_TYPE,
- Table.USER_ADMIN_EVENT), USER_ACCESS_EVENT_TYPE(AuditingTypesConstants.USER_ACCESS_EVENT_TYPE,
- Table.USER_ACCESS_EVENT), RESOURCE_ADMIN_EVENT_TYPE(
- AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE,
- Table.RESOURCE_ADMIN_EVENT), DISTRIBUTION_DOWNLOAD_EVENT_TYPE(
- AuditingTypesConstants.DISTRIBUTION_DOWNLOAD_EVENT_TYPE,
- Table.DISTRIBUTION_DOWNLOAD_EVENT), DISTRIBUTION_ENGINE_EVENT_TYPE(
- AuditingTypesConstants.DISTRIBUTION_ENGINE_EVENT_TYPE,
- Table.DISTRIBUTION_ENGINE_EVENT), DISTRIBUTION_NOTIFICATION_EVENT_TYPE(
- AuditingTypesConstants.DISTRIBUTION_NOTIFICATION_EVENT_TYPE,
- Table.DISTRIBUTION_NOTIFICATION_EVENT), DISTRIBUTION_STATUS_EVENT_TYPE(
- AuditingTypesConstants.DISTRIBUTION_STATUS_EVENT_TYPE,
- Table.DISTRIBUTION_STATUS_EVENT), DISTRIBUTION_DEPLOY_EVENT_TYPE(
- AuditingTypesConstants.DISTRIBUTION_DEPLOY_EVENT_TYPE,
- Table.DISTRIBUTION_DEPLOY_EVENT), DISTRIBUTION_GET_UEB_CLUSTER_EVENT_TYPE(
- AuditingTypesConstants.DISTRIBUTION_GET_UEB_CLUSTER_EVENT_TYPE,
- Table.DISTRIBUTION_GET_UEB_CLUSTER_EVENT), AUTH_EVENT_TYPE(
- AuditingTypesConstants.AUTH_EVENT_TYPE,
- Table.AUTH_EVENT), CONSUMER_EVENT_TYPE(
- AuditingTypesConstants.CONSUMER_EVENT_TYPE,
- Table.CONSUMER_EVENT), CATEGORY_EVENT_TYPE(
- AuditingTypesConstants.CATEGORY_EVENT_TYPE,
- Table.CATEGORY_EVENT), GET_USERS_LIST_EVENT_TYPE(
- AuditingTypesConstants.GET_USERS_LIST_EVENT_TYPE,
- Table.GET_USERS_LIST_EVENT), GET_CATEGORY_HIERARCHY_EVENT_TYPE(
- AuditingTypesConstants.GET_CATEGORY_HIERARCHY_EVENT_TYPE,
- Table.GET_CATEGORY_HIERARCHY_EVENT);
-
- String typeName;
- Table table;
-
- TypeToTableMapping(String typeName, Table table) {
- this.typeName = typeName;
- this.table = table;
- }
-
- public String getTypeName() {
- return typeName;
- }
-
- public Table getTable() {
- return table;
- }
-
- public static Table getTableByType(String type) {
- for (TypeToTableMapping mapping : TypeToTableMapping.values()) {
- if (mapping.getTypeName().equalsIgnoreCase(type)) {
- return mapping.getTable();
- }
- }
- return null;
- }
- }
-
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/EsToCassandraDataMigrationConfig.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/EsToCassandraDataMigrationConfig.java
deleted file mode 100644
index 6b15cb0075..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/EsToCassandraDataMigrationConfig.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*-
- * ============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=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl;
-
-import org.openecomp.sdc.be.dao.cassandra.ArtifactCassandraDao;
-import org.openecomp.sdc.be.dao.cassandra.AuditCassandraDao;
-import org.openecomp.sdc.be.dao.cassandra.CassandraClient;
-import org.openecomp.sdc.be.dao.cassandra.SdcSchemaFilesCassandraDao;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-@Configuration
-public class EsToCassandraDataMigrationConfig {
- @Bean(name = "DataMigrationBean")
- public DataMigration dataMigration(AuditCassandraDao auditCassandraDao, ArtifactCassandraDao artifactCassandraDao) {
- return new DataMigration(auditCassandraDao, artifactCassandraDao);
- }
-
- @Bean(name = "artifact-cassandra-dao")
- public ArtifactCassandraDao artifactCassandraDao(CassandraClient cassandraClient) {
- return new ArtifactCassandraDao(cassandraClient);
- }
-
- @Bean(name = "audit-cassandra-dao")
- public AuditCassandraDao auditCassandraDao(CassandraClient cassandraClient) {
- return new AuditCassandraDao(cassandraClient);
- }
-
- @Bean(name = "cassandra-client")
- public CassandraClient cassandraClient() {
- return new CassandraClient();
- }
-
- @Bean(name = "sdc-schema-files-cassandra-dao")
- public SdcSchemaFilesCassandraDao sdcSchemaFilesCassandraDao(CassandraClient cassandraClient) {
- return new SdcSchemaFilesCassandraDao(cassandraClient);
- }
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphJsonValidator.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphJsonValidator.java
index 57a7c251aa..2b96ba30b8 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphJsonValidator.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphJsonValidator.java
@@ -22,7 +22,6 @@ package org.openecomp.sdc.asdctool.impl;
import com.fasterxml.jackson.databind.ObjectMapper;
-import java.util.stream.Stream;
import org.openecomp.sdc.common.log.wrappers.Logger;
import java.io.IOException;
@@ -31,6 +30,7 @@ import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
+import java.util.stream.Stream;
/**
* simple util class to verify that the janusgraph export json graph is not corrupted
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphMLConverter.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphMLConverter.java
index deb766fff9..ae4a55903a 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphMLConverter.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphMLConverter.java
@@ -21,20 +21,6 @@
package org.openecomp.sdc.asdctool.impl;
import com.google.gson.Gson;
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
import org.apache.commons.configuration.BaseConfiguration;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.tinkerpop.gremlin.structure.Element;
@@ -54,6 +40,21 @@ import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.common.log.wrappers.Logger;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
public class GraphMLConverter {
private static final String STORAGE_BACKEND = "storage.backend";
@@ -95,6 +96,7 @@ public class GraphMLConverter {
return importJsonGraph(graph, inputFile, propertiesCriteriaToDelete);
} catch (Exception e) {
+ e.printStackTrace();
log.info("import graph failed ", e);
return false;
} finally {
@@ -121,6 +123,7 @@ public class GraphMLConverter {
log.info(LOG_FORMATTER, EXPORTED_FILE, result);
} catch (Exception e) {
+ e.printStackTrace();
log.info("export graph failed ", e);
return false;
} finally {
@@ -145,6 +148,7 @@ public class GraphMLConverter {
log.info(LOG_FORMATTER, EXPORTED_FILE, result);
} catch (Exception e) {
+ e.printStackTrace();
log.info("export exportGraphMl failed ", e);
return null;
} finally {
@@ -172,6 +176,7 @@ public class GraphMLConverter {
log.info(LOG_FORMATTER, EXPORTED_FILE, result);
} catch (Exception e) {
+ e.printStackTrace();
log.info("find Error In Json Graph failed ", e);
return false;
} finally {
@@ -208,8 +213,10 @@ public class GraphMLConverter {
result = outputFile;
} catch (Exception e) {
+ e.printStackTrace();
log.info("export Json Graph failed ", e);
graph.tx().rollback();
+ e.printStackTrace();
}
return result;
@@ -227,6 +234,7 @@ public class GraphMLConverter {
graph.tx().commit();
} catch (Exception e) {
graph.tx().rollback();
+ e.printStackTrace();
log.info("export Graph Ml failed ", e);
}
return result;
@@ -278,7 +286,9 @@ public class GraphMLConverter {
} catch (Exception e) {
log.info("Failed to import graph ", e);
+ e.printStackTrace();
graph.tx().rollback();
+ e.printStackTrace();
}
return result;
@@ -306,8 +316,10 @@ public class GraphMLConverter {
graph.tx().rollback();
} catch (Exception e) {
+ e.printStackTrace();
log.info("find Error In Json Graph failed ", e);
graph.tx().rollback();
+ e.printStackTrace();
}
return result;
@@ -355,8 +367,10 @@ public class GraphMLConverter {
result = outputFile;
} catch (Exception e) {
+ e.printStackTrace();
log.info("export Users failed ", e);
graph.tx().rollback();
+ e.printStackTrace();
}
return result;
@@ -397,6 +411,7 @@ public class GraphMLConverter {
log.info(EXPORTED_FILE, result);
} catch (Exception e) {
+ e.printStackTrace();
log.info("export Users failed ", e);
return false;
} finally {
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphMLDataAnalyzer.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphMLDataAnalyzer.java
index 853709225a..21e22be10c 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphMLDataAnalyzer.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphMLDataAnalyzer.java
@@ -20,12 +20,6 @@
package org.openecomp.sdc.asdctool.impl;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
@@ -38,6 +32,13 @@ import org.jdom2.util.IteratorIterable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
public class GraphMLDataAnalyzer {
private static Logger log = LoggerFactory.getLogger(GraphMLDataAnalyzer.class);
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/JanusGraphInitializer.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/JanusGraphInitializer.java
index fbebe2cd27..33fbf29f17 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/JanusGraphInitializer.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/JanusGraphInitializer.java
@@ -20,12 +20,16 @@
package org.openecomp.sdc.asdctool.impl;
-import org.janusgraph.core.*;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphException;
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraphQuery;
+import org.janusgraph.core.PropertyKey;
import org.janusgraph.core.schema.ConsistencyModifier;
import org.janusgraph.core.schema.JanusGraphIndex;
import org.janusgraph.core.schema.JanusGraphManagement;
-import org.apache.tinkerpop.gremlin.structure.Edge;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.openecomp.sdc.be.dao.graph.datatype.ActionEnum;
import org.openecomp.sdc.be.dao.graph.datatype.GraphElementTypeEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/ProductLogic.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/ProductLogic.java
index 883f5e50f4..e60640fa26 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/ProductLogic.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/ProductLogic.java
@@ -20,10 +20,10 @@
package org.openecomp.sdc.asdctool.impl;
-import org.janusgraph.core.JanusGraphFactory;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphFactory;
import org.janusgraph.core.JanusGraphVertex;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.common.log.wrappers.Logger;
@@ -75,7 +75,8 @@ public class ProductLogic {
graph.tx().commit();
return productsToDelete;
} catch (Exception e) {
- log.info("get All Products failed - {}" , e);
+ e.printStackTrace();
+ log.info("get All Products failed - {}" , e);
if(graph != null) {
graph.tx().rollback();
}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/UpdatePropertyOnVertex.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/UpdatePropertyOnVertex.java
index 9911fb73f3..7f9064fe71 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/UpdatePropertyOnVertex.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/UpdatePropertyOnVertex.java
@@ -20,10 +20,10 @@
package org.openecomp.sdc.asdctool.impl;
-import org.janusgraph.core.JanusGraphFactory;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphFactory;
import org.janusgraph.core.JanusGraphQuery;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.openecomp.sdc.asdctool.Utils;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
@@ -99,7 +99,7 @@ public class UpdatePropertyOnVertex {
return numberOfUpdatedVertexes;
} catch (Exception e) {
- log.info("update Property On Service At Least Certified failed -{}" , e);
+ e.printStackTrace();
graph.tx().rollback();
return null;
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/VrfObjectFixHandler.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/VrfObjectFixHandler.java
index cee0ded669..3633be7c98 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/VrfObjectFixHandler.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/VrfObjectFixHandler.java
@@ -42,7 +42,11 @@ import org.openecomp.sdc.be.model.operations.StorageException;
import org.openecomp.sdc.common.log.wrappers.Logger;
import java.io.IOException;
-import java.util.*;
+import java.util.EnumMap;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import static java.util.Collections.emptyList;
import static java.util.stream.Collectors.toList;
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/internal/tool/CommonInternalTool.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/internal/tool/CommonInternalTool.java
index 1808175d99..0adaf51ed5 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/internal/tool/CommonInternalTool.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/internal/tool/CommonInternalTool.java
@@ -19,13 +19,13 @@
*/
package org.openecomp.sdc.asdctool.impl.internal.tool;
-import java.io.IOException;
-import java.util.Map;
-
import org.openecomp.sdc.asdctool.utils.ConsoleWriter;
import org.openecomp.sdc.asdctool.utils.ReportWriter;
import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
+import java.io.IOException;
+import java.util.Map;
+
public abstract class CommonInternalTool {
protected ReportWriter reportWriter;
private String reportType;
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/internal/tool/CsarGenerator.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/internal/tool/CsarGenerator.java
index 78f0ecbc88..8d74ea5abb 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/internal/tool/CsarGenerator.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/internal/tool/CsarGenerator.java
@@ -19,24 +19,14 @@
*/
package org.openecomp.sdc.asdctool.impl.internal.tool;
-import java.io.IOException;
-import java.util.EnumMap;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Scanner;
-import java.util.function.Supplier;
-import java.util.stream.Collectors;
-
import org.openecomp.sdc.asdctool.utils.ConsoleWriter;
import org.openecomp.sdc.be.dao.cassandra.ArtifactCassandraDao;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
-import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
@@ -45,7 +35,7 @@ import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
-import org.openecomp.sdc.be.resources.data.ESArtifactData;
+import org.openecomp.sdc.be.resources.data.DAOArtifactData;
import org.openecomp.sdc.be.tosca.CsarUtils;
import org.openecomp.sdc.be.tosca.ToscaExportHandler;
import org.openecomp.sdc.common.api.ArtifactTypeEnum;
@@ -53,6 +43,16 @@ import org.openecomp.sdc.common.log.wrappers.Logger;
import org.openecomp.sdc.common.util.GeneralUtility;
import org.springframework.beans.factory.annotation.Autowired;
+import java.io.IOException;
+import java.util.EnumMap;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Scanner;
+import java.util.function.Supplier;
+import java.util.stream.Collectors;
+
@org.springframework.stereotype.Component("csarGenerator")
public class CsarGenerator extends CommonInternalTool {
@@ -174,7 +174,7 @@ public class CsarGenerator extends CommonInternalTool {
csarArtifact.setArtifactChecksum(GeneralUtility.calculateMD5Base64EncodedByByteArray(decodedPayload));
- ESArtifactData artifactData = new ESArtifactData(csarArtifact.getEsId(), decodedPayload);
+ DAOArtifactData artifactData = new DAOArtifactData(csarArtifact.getEsId(), decodedPayload);
artifactCassandraDao.saveArtifact(artifactData);
ConsoleWriter.dataLine("Artifact generated and saved into Cassandra ", csarArtifact.getArtifactLabel());
report(component, csarArtifact);
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/internal/tool/DeleteComponentHandler.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/internal/tool/DeleteComponentHandler.java
index 3bd13d0eff..62dd489810 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/internal/tool/DeleteComponentHandler.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/internal/tool/DeleteComponentHandler.java
@@ -19,11 +19,11 @@
*/
package org.openecomp.sdc.asdctool.impl.internal.tool;
-import org.janusgraph.core.JanusGraphVertex;
import fj.data.Either;
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.janusgraph.core.JanusGraphVertex;
import org.openecomp.sdc.asdctool.utils.ConsoleWriter;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManager.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManager.java
index cc75dfc968..cdb3b2c5a5 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManager.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManager.java
@@ -24,14 +24,14 @@
package org.openecomp.sdc.asdctool.impl.validator.config;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
/**
* Created by chaya on 7/4/2017.
*/
@@ -76,6 +76,7 @@ public class ValidationConfigManager {
input = new FileInputStream(path);
prop.load(input);
} catch (IOException ex) {
+ ex.printStackTrace();
log.info("FileInputStream failed - {}", ex);
}
return prop;
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 d59a9aae6a..b83417c6c1 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
@@ -20,11 +20,16 @@
package org.openecomp.sdc.asdctool.impl.validator.config;
-import java.util.List;
import org.openecomp.sdc.asdctool.impl.VrfObjectFixHandler;
import org.openecomp.sdc.asdctool.impl.validator.ArtifactToolBL;
import org.openecomp.sdc.asdctool.impl.validator.ValidationToolBL;
-import org.openecomp.sdc.asdctool.impl.validator.executers.*;
+import org.openecomp.sdc.asdctool.impl.validator.executers.IArtifactValidatorExecuter;
+import org.openecomp.sdc.asdctool.impl.validator.executers.NodeToscaArtifactsValidatorExecuter;
+import org.openecomp.sdc.asdctool.impl.validator.executers.ServiceToscaArtifactsValidatorExecutor;
+import org.openecomp.sdc.asdctool.impl.validator.executers.ServiceValidatorExecuter;
+import org.openecomp.sdc.asdctool.impl.validator.executers.VFToscaArtifactValidatorExecutor;
+import org.openecomp.sdc.asdctool.impl.validator.executers.ValidatorExecuter;
+import org.openecomp.sdc.asdctool.impl.validator.executers.VfValidatorExecuter;
import org.openecomp.sdc.asdctool.impl.validator.tasks.VfValidationTask;
import org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts.ArtifactValidationUtils;
import org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts.ServiceArtifactValidationTask;
@@ -46,7 +51,13 @@ import org.openecomp.sdc.be.dao.janusgraph.JanusGraphGenericDao;
import org.openecomp.sdc.be.dao.jsongraph.HealingJanusGraphDao;
import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.model.DerivedNodeTypeResolver;
-import org.openecomp.sdc.be.model.jsonjanusgraph.operations.*;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ArchiveOperation;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ByToscaNameDerivedNodeTypeResolver;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.GroupsOperation;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.NodeTemplateOperation;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.NodeTypeOperation;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.TopologyTemplateOperation;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
import org.openecomp.sdc.be.model.operations.api.IGraphLockOperation;
import org.openecomp.sdc.be.model.operations.impl.GraphLockOperation;
import org.openecomp.sdc.config.CatalogBESpringConfig;
@@ -58,6 +69,8 @@ import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Primary;
import org.springframework.core.io.FileSystemResource;
+import java.util.List;
+
/**
* Created by chaya on 7/3/2017.
*/
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecuter.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecuter.java
index 33cf9d46da..a5e7d7873b 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecuter.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecuter.java
@@ -34,8 +34,19 @@ import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.common.log.wrappers.Logger;
-import java.io.*;
-import java.util.*;
+import java.io.BufferedWriter;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
import java.util.stream.Collectors;
public class ArtifactValidatorExecuter{
@@ -134,7 +145,7 @@ public class ArtifactValidatorExecuter{
try {
// "service name, service id, state, version
for(Component component: components ){
- StringBuilder sb = new StringBuilder(component.getName());
+ StringBuffer sb = new StringBuffer(component.getName());
sb.append(",").append(component.getUniqueId()).append(",").append(component.getInvariantUUID()).append(",").append(component.getLifecycleState()).append(",").append(component.getVersion());
sb.append("\n");
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/NodeToscaArtifactsValidatorExecuter.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/NodeToscaArtifactsValidatorExecuter.java
index 99e6637a08..9fa92200ac 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/NodeToscaArtifactsValidatorExecuter.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/NodeToscaArtifactsValidatorExecuter.java
@@ -26,11 +26,11 @@ import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
public class NodeToscaArtifactsValidatorExecuter extends ArtifactValidatorExecuter implements IArtifactValidatorExecuter{
protected String name;
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceToscaArtifactsValidatorExecutor.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceToscaArtifactsValidatorExecutor.java
index ed4b6eabf8..aad803e672 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceToscaArtifactsValidatorExecutor.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceToscaArtifactsValidatorExecutor.java
@@ -26,12 +26,12 @@ import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
+import org.springframework.beans.factory.annotation.Autowired;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
-import org.springframework.beans.factory.annotation.Autowired;
@org.springframework.stereotype.Component
public class ServiceToscaArtifactsValidatorExecutor extends ArtifactValidatorExecuter implements IArtifactValidatorExecuter{
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuter.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuter.java
index 8f36dd3d85..a52fb370d5 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuter.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuter.java
@@ -25,10 +25,10 @@ import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
-import org.springframework.stereotype.Component;
/**
* Created by chaya on 7/4/2017.
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuter.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuter.java
index 5287ea1b7a..ca027cb3ed 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuter.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuter.java
@@ -24,17 +24,22 @@ import fj.data.Either;
import org.openecomp.sdc.asdctool.impl.validator.tasks.TopologyTemplateValidationTask;
import org.openecomp.sdc.asdctool.impl.validator.utils.ReportManager;
import org.openecomp.sdc.asdctool.impl.validator.utils.VertexResult;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
-import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.springframework.beans.factory.annotation.Autowired;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.EnumMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
/**
* Created by chaya on 7/3/2017.
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VFToscaArtifactValidatorExecutor.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VFToscaArtifactValidatorExecutor.java
index 29d49ae592..f1c9af681c 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VFToscaArtifactValidatorExecutor.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VFToscaArtifactValidatorExecutor.java
@@ -27,11 +27,11 @@ import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
public class VFToscaArtifactValidatorExecutor extends ArtifactValidatorExecuter implements IArtifactValidatorExecuter{
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuter.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuter.java
index eefd19594a..181495ad44 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuter.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuter.java
@@ -20,13 +20,14 @@
package org.openecomp.sdc.asdctool.impl.validator.executers;
-import java.util.List;
import org.openecomp.sdc.asdctool.impl.validator.tasks.VfValidationTask;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.springframework.beans.factory.annotation.Autowired;
+import java.util.List;
+
/**
* Created by chaya on 7/3/2017.
*/
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtils.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtils.java
index 2e804cc8a2..11c80eae70 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtils.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtils.java
@@ -21,12 +21,7 @@
package org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-
+import fj.data.Either;
import org.openecomp.sdc.asdctool.impl.validator.utils.ReportManager;
import org.openecomp.sdc.be.dao.cassandra.ArtifactCassandraDao;
import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus;
@@ -41,7 +36,11 @@ import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.springframework.beans.factory.annotation.Autowired;
-import fj.data.Either;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
/**
* Created by chaya on 7/6/2017.
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
index d6fafcbb5e..d45c896799 100644
--- 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
@@ -37,7 +37,12 @@ import org.openecomp.sdc.be.model.jsonjanusgraph.operations.TopologyTemplateOper
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.springframework.beans.factory.annotation.Autowired;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
import java.util.stream.Collectors;
/**
@@ -108,8 +113,7 @@ public class ModuleJsonTask extends ServiceValidationTask {
}
private boolean isAfterSubmitForTesting(GraphVertex vertex){
- List allowedStates = new ArrayList<>(Arrays.asList(LifecycleStateEnum.READY_FOR_CERTIFICATION.name(),
- LifecycleStateEnum.CERTIFICATION_IN_PROGRESS.name(), LifecycleStateEnum.CERTIFIED.name()));
+ List allowedStates = new ArrayList<>(Arrays.asList(LifecycleStateEnum.CERTIFIED.name()));
return allowedStates.contains(vertex.getMetadataProperty(GraphPropertyEnum.STATE));
}
}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManager.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManager.java
index 2be8f921fa..e575ffce24 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManager.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManager.java
@@ -21,19 +21,22 @@
package org.openecomp.sdc.asdctool.impl.validator.utils;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.nio.file.StandardOpenOption;
-import java.util.*;
-
import org.apache.commons.lang.text.StrBuilder;
import org.openecomp.sdc.asdctool.impl.validator.config.ValidationConfigManager;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.nio.file.StandardOpenOption;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+
/**
* Created by chaya on 7/5/2017.
*/
@@ -50,6 +53,7 @@ public class ReportManager {
initCsvFile();
initReportFile();
} catch (IOException e) {
+ e.printStackTrace();
log.info("Init file failed - {}", e.getClass().getSimpleName(), e);
}
}
@@ -98,6 +102,7 @@ public class ReportManager {
Files.write(Paths.get(reportOutputFilePath), new StrBuilder().appendNewLine().toString().getBytes(), StandardOpenOption.APPEND);
Files.write(Paths.get(reportOutputFilePath), message.getBytes(), StandardOpenOption.APPEND);
} catch (IOException e) {
+ e.printStackTrace();
log.info("write to file failed - {}", e.getClass().getSimpleName(), e);
}
}
@@ -145,6 +150,7 @@ public class ReportManager {
new StrBuilder().appendNewLine().toString().getBytes(),
StandardOpenOption.APPEND);
} catch (IOException e) {
+ e.printStackTrace();
log.info("write to file failed - {}", e.getClass().getSimpleName(), e);
}
}));
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/CsarGeneratorTool.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/CsarGeneratorTool.java
index 511e9baffc..882a4e12aa 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/CsarGeneratorTool.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/CsarGeneratorTool.java
@@ -20,14 +20,14 @@
package org.openecomp.sdc.asdctool.main;
-import java.util.Scanner;
-
import org.openecomp.sdc.asdctool.configuration.ConfigurationUploader;
import org.openecomp.sdc.asdctool.configuration.CsarGeneratorConfiguration;
import org.openecomp.sdc.asdctool.impl.internal.tool.CsarGenerator;
import org.openecomp.sdc.asdctool.utils.ConsoleWriter;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+import java.util.Scanner;
+
public class CsarGeneratorTool extends SdcInternalTool {
public static void main(String[] args) {
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/DataSchemaMenu.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/DataSchemaMenu.java
index d2d5e77f2b..4b3496faa6 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/DataSchemaMenu.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/DataSchemaMenu.java
@@ -35,67 +35,70 @@ public class DataSchemaMenu {
private static Logger log = Logger.getLogger(DataSchemaMenu.class.getName());
- public static void main(String[] args) {
+ public static void main(String[] args) {
String operation = args[0];
- String appConfigDir = args[1];
+ String appConfigDir = args[1];
- if (args == null || args.length < 2) {
- usageAndExit();
- }
+ if (args == null || args.length < 2) {
+ usageAndExit();
+ }
- ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
- ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
+ ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
+ ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
+
+ try {
SdcSchemaBuilder sdcSchemaBuilder = new SdcSchemaBuilder(new SdcSchemaUtils(),
ConfigurationManager.getConfigurationManager().getConfiguration()::getCassandraConfig);
- switch (operation.toLowerCase()) {
- case "create-cassandra-structures":
- log.debug("Start create cassandra keyspace, tables and indexes");
+ switch (operation.toLowerCase()) {
+ case "create-cassandra-structures":
+ log.debug("Start create cassandra keyspace, tables and indexes");
if (sdcSchemaBuilder.createSchema()) {
- log.debug("create cassandra keyspace, tables and indexes successfull");
- System.exit(0);
- } else {
- log.debug("create cassandra keyspace, tables and indexes failed");
- System.exit(2);
- }
- break;
+ log.debug("create cassandra keyspace, tables and indexes successfull");
+ System.exit(0);
+ } else {
+ log.debug("create cassandra keyspace, tables and indexes failed");
+ System.exit(2);
+ }
case "create-janusgraph-structures":
log.debug("Start create janusgraph keyspace");
String janusGraphCfg = 2 == args.length ? configurationManager.getConfiguration().getJanusGraphCfgFile() : args[2];
if (JanusGraphInitializer.createGraph(janusGraphCfg)) {
log.debug("create janusgraph keyspace successfull");
- System.exit(0);
- } else {
+ System.exit(0);
+ } else {
log.debug("create janusgraph keyspace failed");
- System.exit(2);
- }
- break;
- case "clean-cassndra":
- log.debug("Start clean keyspace, tables");
+ System.exit(2);
+ }
+ case "clean-cassndra":
+ log.debug("Start clean keyspace, tables");
if (sdcSchemaBuilder.deleteSchema()) {
- log.debug(" successfull");
- System.exit(0);
- } else {
- log.debug(" failed");
- System.exit(2);
- }
- break;
- default:
- usageAndExit();
- break;
- }
- }
+ log.debug(" successfull");
+ System.exit(0);
+ } else {
+ log.debug(" failed");
+ System.exit(2);
+ }
+ default:
+ usageAndExit();
+ }
+ } catch (Throwable t) {
+ t.printStackTrace();
+ log.debug("create cassandra keyspace, tables and indexes failed");
+ System.exit(3);
+ }
+ }
- private static void usageAndExit() {
- DataSchemeUsage();
- System.exit(1);
- }
+ private static void usageAndExit() {
+ DataSchemeUsage();
+ System.exit(1);
+ }
- private static void DataSchemeUsage() {
- System.out.println("Usage: create-cassandra-structures <configuration dir> ");
+ private static void DataSchemeUsage() {
+ System.out.println("Usage: create-cassandra-structures <configuration dir> ");
System.out.println("Usage: create-janusgraph-structures <configuration dir> ");
- }
+ }
}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/DeleteComponentTool.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/DeleteComponentTool.java
index d30249eb6b..309d23ca14 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/DeleteComponentTool.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/DeleteComponentTool.java
@@ -20,14 +20,14 @@
package org.openecomp.sdc.asdctool.main;
-import java.util.Scanner;
-
import org.openecomp.sdc.asdctool.configuration.ConfigurationUploader;
import org.openecomp.sdc.asdctool.configuration.InternalToolConfiguration;
import org.openecomp.sdc.asdctool.impl.internal.tool.DeleteComponentHandler;
import org.openecomp.sdc.asdctool.utils.ConsoleWriter;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+import java.util.Scanner;
+
public class DeleteComponentTool extends SdcInternalTool{
private static final String PSW = "ItIsTimeToDelete";
@@ -39,11 +39,6 @@ public class DeleteComponentTool extends SdcInternalTool{
String appConfigDir = args[0];
String password = args[1];
- if ( !PSW.equals(password) ){
- ConsoleWriter.dataLine("Wrong password");
- System.exit(1);
- }
-
disableConsole();
ConsoleWriter.dataLine("STARTED... ");
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/EsToCassandraDataMigrationMenu.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/EsToCassandraDataMigrationMenu.java
deleted file mode 100644
index c119d7e1ff..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/EsToCassandraDataMigrationMenu.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*-
- * ============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=========================================================
- */
-
-package org.openecomp.sdc.asdctool.main;
-
-import org.openecomp.sdc.asdctool.impl.DataMigration;
-import org.openecomp.sdc.asdctool.impl.EsToCassandraDataMigrationConfig;
-import org.openecomp.sdc.be.config.ConfigurationManager;
-import org.openecomp.sdc.common.api.ConfigurationSource;
-import org.openecomp.sdc.common.impl.ExternalConfiguration;
-import org.openecomp.sdc.common.impl.FSConfigurationSource;
-import org.openecomp.sdc.common.log.wrappers.Logger;
-import org.springframework.context.annotation.AnnotationConfigApplicationContext;
-
-public class EsToCassandraDataMigrationMenu {
-
- private static Logger log = Logger.getLogger(EsToCassandraDataMigrationMenu.class.getName());
-
- public static void main(String[] args) {
-
- if (args == null || args.length < 2) {
- usageAndExit();
- }
- String operation = args[0];
-
- String appConfigDir = args[1];
- System.setProperty("config.home", appConfigDir);
- ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(),
- appConfigDir);
- ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
-
- AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
- EsToCassandraDataMigrationConfig.class);
- DataMigration dataMigration = null;
- try {
- switch (operation.toLowerCase()) {
- case "es-to-cassndra-migration":
- dataMigration = (DataMigration) context.getBean("DataMigrationBean");
- log.debug("Start migration from ES to C* ");
- if (dataMigration.migrateDataESToCassndra(appConfigDir, true, true)) {
- log.debug("migration from ES to C* was finished successfull");
- System.exit(0);
- } else {
- log.debug("migration from ES to C* failed");
- System.exit(2);
- }
- break;
- case "es-to-cassndra-migration-export-only":
- dataMigration = (DataMigration) context.getBean("DataMigrationBean");
- log.debug("Start migration export only from ES to C* ");
- if (dataMigration.migrateDataESToCassndra(appConfigDir, true, false)) {
- log.debug("migration export only from ES to C* was finished successfull");
- System.exit(0);
- } else {
- log.debug("migration export only from ES to C* failed");
- System.exit(2);
- }
- break;
- case "es-to-cassndra-migration-import-only":
- dataMigration = (DataMigration) context.getBean("DataMigrationBean");
- log.debug("Start migration import only from ES to C* ");
- if (dataMigration.migrateDataESToCassndra(appConfigDir, false, true)) {
- log.debug("migration import only from ES to C* was finished successfull");
- System.exit(0);
- } else {
- log.debug("migration import only from ES to C* failed");
- System.exit(2);
- }
- break;
- default:
- usageAndExit();
- }
- } catch (Throwable t) {
- log.info("data migration failed - {}", t);
- System.exit(3);
- }
- }
-
- private static void usageAndExit() {
- MigrationUsage();
- System.exit(1);
- }
-
- private static void MigrationUsage() {
- System.out.println(
- "Usage: es-to-cassndra-migration/es-to-cassndra-migration-import-only/es-to-cassndra-migration-export-only <configuration dir>");
- }
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/ExportImportMenu.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/ExportImportMenu.java
index 9c8ca992aa..98aea2648c 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/ExportImportMenu.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/ExportImportMenu.java
@@ -22,13 +22,14 @@
package org.openecomp.sdc.asdctool.main;
+import org.openecomp.sdc.asdctool.impl.GraphJsonValidator;
+import org.openecomp.sdc.asdctool.impl.GraphMLConverter;
+import org.openecomp.sdc.asdctool.impl.GraphMLDataAnalyzer;
+
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
-import org.openecomp.sdc.asdctool.impl.GraphJsonValidator;
-import org.openecomp.sdc.asdctool.impl.GraphMLConverter;
-import org.openecomp.sdc.asdctool.impl.GraphMLDataAnalyzer;
public class ExportImportMenu {
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/GetConsumersMenu.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/GetConsumersMenu.java
deleted file mode 100644
index 3c4f7458d9..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/GetConsumersMenu.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 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=========================================================
- */
-
-package org.openecomp.sdc.asdctool.main;
-
-import fj.data.Either;
-import org.openecomp.sdc.asdctool.cli.CLIToolData;
-import org.openecomp.sdc.asdctool.cli.SpringCLITool;
-import org.openecomp.sdc.asdctool.configuration.GetConsumersConfiguration;
-import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
-import org.openecomp.sdc.be.model.operations.impl.ConsumerOperation;
-import org.openecomp.sdc.be.resources.data.ConsumerData;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
-
-public class GetConsumersMenu extends SpringCLITool {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(GetConsumersMenu.class);
-
- public static void main(String[] args) {
- GetConsumersMenu getConsumersMenu = new GetConsumersMenu();
- CLIToolData cliToolData = getConsumersMenu.init(args);
- ConsumerOperation consumersService = cliToolData.getSpringApplicationContext().getBean(ConsumerOperation.class);
- printConsumers(getConsumersMenu, consumersService);
- }
-
- private static void printConsumers(GetConsumersMenu getConsumersMenu, ConsumerOperation consumersService) {
- Either<List<ConsumerData>, StorageOperationStatus> allConsumers = consumersService.getAll();
- allConsumers.left().foreachDoEffect(getConsumersMenu::printConsumers);
- allConsumers.right().foreachDoEffect(getConsumersMenu::printErr);
- }
-
- private void printConsumers(List<ConsumerData> consumers) {
- System.out.println("SDC consumers: ");
- consumers.forEach(consumer -> {
- System.out.println("#########################");
- System.out.println(consumer);
- });
- System.exit(0);
- }
-
- private void printErr(StorageOperationStatus err) {
- String errMsg = String.format("failed to fetch consumers. reason: %s", err);
- LOGGER.error(errMsg);
- System.err.print(errMsg);
- System.exit(1);
- }
-
- @Override
- protected String commandName() {
- return "get-consumers";
- }
-
- @Override
- protected Class<?> getSpringConfigurationClass() {
- return GetConsumersConfiguration.class;
- }
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/SdcInternalTool.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/SdcInternalTool.java
index aeb7abe63a..2fb99e29f3 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/SdcInternalTool.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/SdcInternalTool.java
@@ -20,11 +20,10 @@
package org.openecomp.sdc.asdctool.main;
+import ch.qos.logback.core.Appender;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.slf4j.LoggerFactory;
-import ch.qos.logback.core.Appender;
-
public abstract class SdcInternalTool {
protected static void disableConsole() {
org.slf4j.Logger rootLogger = LoggerFactory.getILoggerFactory().getLogger(Logger.ROOT_LOGGER_NAME);
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/SdcSchemaFileImport.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/SdcSchemaFileImport.java
index eb1d487cdd..47a08ea70e 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/SdcSchemaFileImport.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/SdcSchemaFileImport.java
@@ -20,6 +20,21 @@
package org.openecomp.sdc.asdctool.main;
+import org.apache.commons.codec.digest.DigestUtils;
+import org.apache.commons.lang3.ArrayUtils;
+import org.openecomp.sdc.asdctool.configuration.SdcSchemaFileImportConfiguration;
+import org.openecomp.sdc.asdctool.enums.SchemaZipFileEnum;
+import org.openecomp.sdc.be.config.ConfigurationManager;
+import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus;
+import org.openecomp.sdc.be.dao.cassandra.SdcSchemaFilesCassandraDao;
+import org.openecomp.sdc.be.resources.data.SdcSchemaFilesData;
+import org.openecomp.sdc.common.api.ConfigurationSource;
+import org.openecomp.sdc.common.impl.ExternalConfiguration;
+import org.openecomp.sdc.common.impl.FSConfigurationSource;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.Yaml;
+
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
@@ -36,20 +51,6 @@ import java.util.Map;
import java.util.stream.Stream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
-import org.apache.commons.codec.digest.DigestUtils;
-import org.apache.commons.lang3.ArrayUtils;
-import org.openecomp.sdc.asdctool.enums.SchemaZipFileEnum;
-import org.openecomp.sdc.asdctool.impl.EsToCassandraDataMigrationConfig;
-import org.openecomp.sdc.be.config.ConfigurationManager;
-import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus;
-import org.openecomp.sdc.be.dao.cassandra.SdcSchemaFilesCassandraDao;
-import org.openecomp.sdc.be.resources.data.SdcSchemaFilesData;
-import org.openecomp.sdc.common.api.ConfigurationSource;
-import org.openecomp.sdc.common.impl.ExternalConfiguration;
-import org.openecomp.sdc.common.impl.FSConfigurationSource;
-import org.springframework.context.annotation.AnnotationConfigApplicationContext;
-import org.yaml.snakeyaml.DumperOptions;
-import org.yaml.snakeyaml.Yaml;
public class SdcSchemaFileImport {
@@ -106,10 +107,11 @@ public class SdcSchemaFileImport {
//Loop over schema file list and create each yaml file from /import/tosca folder
SchemaZipFileEnum[] schemaFileList = SchemaZipFileEnum.values();
for (SchemaZipFileEnum schemaZipFileEnum : schemaFileList) {
- String pathname = importToscaPath + SEPARATOR + schemaZipFileEnum.getSourceFolderName() + SEPARATOR + schemaZipFileEnum.getSourceFileName() + YAML_EXTENSION;
- try(InputStream input = new FileInputStream(new File(pathname));) {
+ try {
//get the source yaml file
+ String pathname = importToscaPath + SEPARATOR + schemaZipFileEnum.getSourceFolderName() + SEPARATOR + schemaZipFileEnum.getSourceFileName() + YAML_EXTENSION;
System.out.println("Processing file "+pathname+"....");
+ InputStream input = new FileInputStream(new File(pathname));
//Convert the content of file to yaml
Yaml yamlFileSource = new Yaml();
Object content = yamlFileSource.load(input);
@@ -275,6 +277,6 @@ public class SdcSchemaFileImport {
private static AnnotationConfigApplicationContext initContext(String appConfigDir) {
ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
new ConfigurationManager(configurationSource);
- return new AnnotationConfigApplicationContext(EsToCassandraDataMigrationConfig.class);
+ return new AnnotationConfigApplicationContext(SdcSchemaFileImportConfiguration.class);
}
}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/config/MigrationSpringConfig.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/config/MigrationSpringConfig.java
index e5e0740794..65f8c7be72 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/config/MigrationSpringConfig.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/config/MigrationSpringConfig.java
@@ -27,6 +27,8 @@ import org.openecomp.sdc.asdctool.migration.dao.MigrationTasksDao;
import org.openecomp.sdc.asdctool.migration.resolver.MigrationResolver;
import org.openecomp.sdc.asdctool.migration.resolver.SpringBeansMigrationResolver;
import org.openecomp.sdc.asdctool.migration.service.SdcRepoService;
+import org.openecomp.sdc.be.components.distribution.engine.DmaapClientFactory;
+import org.openecomp.sdc.be.components.health.HealthCheckBusinessLogic;
import org.openecomp.sdc.be.components.impl.ResourceBusinessLogic;
import org.openecomp.sdc.be.components.impl.ServiceBusinessLogic;
import org.openecomp.sdc.be.components.scheduledtasks.ComponentsCleanBusinessLogic;
@@ -42,12 +44,10 @@ import org.openecomp.sdc.be.model.operations.api.IGroupTypeOperation;
import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
import org.openecomp.sdc.config.CatalogBESpringConfig;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.config.PropertiesFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
-import org.springframework.core.io.FileSystemResource;
import java.util.ArrayList;
import java.util.List;
@@ -55,8 +55,8 @@ import java.util.List;
@Configuration
@Import({DAOSpringConfig.class, CatalogBESpringConfig.class, CatalogModelSpringConfig.class})
@ComponentScan({"org.openecomp.sdc.asdctool.migration.tasks",//migration tasks
- "org.openecomp.sdc.asdctool.migration.config.mocks"
- })
+ "org.openecomp.sdc.asdctool.migration.config.mocks",
+ "org.openecomp.sdc.be.filters" })
public class MigrationSpringConfig {
@Autowired(required=false)
@@ -85,14 +85,6 @@ public class MigrationSpringConfig {
return new MigrationTasksDao(cassandraClient);
}
- @Bean(name = "elasticsearchConfig")
- public PropertiesFactoryBean mapper() {
- String configHome = System.getProperty("config.home");
- PropertiesFactoryBean bean = new PropertiesFactoryBean();
- bean.setLocation(new FileSystemResource(configHome + "/elasticsearch.yml"));
- return bean;
- }
-
@Bean(name = "componentsCleanBusinessLogic")
public ComponentsCleanBusinessLogic componentsCleanBusinessLogic(
IElementOperation elementDao,
@@ -108,5 +100,12 @@ public class MigrationSpringConfig {
groupInstanceOperation, groupTypeOperation, interfaceOperation, interfaceLifecycleTypeOperation, resourceBusinessLogic,
serviceBusinessLogic, artifactToscaOperation);
}
+
+ @Bean(name = "dmaapClientFactory")
+ public DmaapClientFactory getDmaapClientFactory() {return new DmaapClientFactory();}
+ @Bean(name = "healthCheckBusinessLogic")
+ public HealthCheckBusinessLogic getHealthCheckBusinessLogic() {
+ return new HealthCheckBusinessLogic();
+ }
}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/config/mocks/CambriaHandlerMock.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/config/mocks/CambriaHandlerMock.java
new file mode 100644
index 0000000000..e8c6a955f0
--- /dev/null
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/config/mocks/CambriaHandlerMock.java
@@ -0,0 +1,87 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2020 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=========================================================
+ */
+
+package org.openecomp.sdc.asdctool.migration.config.mocks;
+
+import com.att.nsa.apiClient.credentials.ApiCredential;
+import fj.data.Either;
+import org.openecomp.sdc.be.components.distribution.engine.CambriaErrorResponse;
+import org.openecomp.sdc.be.components.distribution.engine.ICambriaHandler;
+import org.openecomp.sdc.be.components.distribution.engine.INotificationData;
+import org.openecomp.sdc.be.components.distribution.engine.SubscriberTypeEnum;
+import org.springframework.stereotype.Component;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
+@Component("cambriaHandler")
+public class CambriaHandlerMock implements ICambriaHandler {
+
+ @Override
+ public Either<Set<String>, CambriaErrorResponse> getTopics(List<String> hostSet) {
+ return null;
+ }
+
+ @Override
+ public CambriaErrorResponse createTopic(Collection<String> hostSet, String apiKey, String secretKey, String topicName, int partitionCount, int replicationCount) {
+ return null;
+ }
+
+ @Override
+ public CambriaErrorResponse unRegisterFromTopic(Collection<String> hostSet, String managerApiKey, String managerSecretKey, String subscriberApiKey, SubscriberTypeEnum subscriberTypeEnum, String topicName) {
+ return null;
+ }
+
+ @Override
+ public CambriaErrorResponse registerToTopic(Collection<String> hostSet, String managerApiKey, String managerSecretKey, String subscriberApiKey, SubscriberTypeEnum subscriberTypeEnum, String topicName) {
+ return null;
+ }
+
+ @Override
+ public com.att.nsa.cambria.client.CambriaConsumer createConsumer(Collection<String> hostSet, String topicName, String apiKey, String secretKey, String consumerId, String consumerGroup, int timeoutMS) throws Exception {
+ return null;
+ }
+
+ @Override
+ public CambriaErrorResponse sendNotification(String topicName, String uebPublicKey, String uebSecretKey, List<String> uebServers, INotificationData data) {
+ return null;
+ }
+
+ @Override
+ public CambriaErrorResponse sendNotificationAndClose(String topicName, String uebPublicKey, String uebSecretKey, List<String> uebServers, INotificationData data, long waitBeforeCloseTimeout) {
+ return null;
+ }
+
+ @Override
+ public CambriaErrorResponse getApiKey(String server, String apiKey) {
+ return null;
+ }
+
+ @Override
+ public Either<ApiCredential, CambriaErrorResponse> createUebKeys(List<String> hostSet) {
+ return null;
+ }
+
+ @Override
+ public Either<Iterable<String>, CambriaErrorResponse> fetchFromTopic(com.att.nsa.cambria.client.CambriaConsumer topicConsumer) {
+ return null;
+ }
+}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/config/mocks/DistributionEngineMock.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/config/mocks/DistributionEngineMock.java
index c4150e41a1..dde7f6a2ac 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/config/mocks/DistributionEngineMock.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/config/mocks/DistributionEngineMock.java
@@ -29,6 +29,8 @@ import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.resources.data.OperationalEnvironmentEntry;
import org.springframework.stereotype.Component;
+import java.util.List;
+
@Component("distributionEngine")
public class DistributionEngineMock implements IDistributionEngine {
@Override
@@ -76,4 +78,9 @@ public class DistributionEngineMock implements IDistributionEngine {
return null;
}
+ @Override
+ public OperationalEnvironmentEntry getEnvironmentByDmaapUebAddress(List<String> dmaapUebAddress) {
+ return null;
+ }
+
}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/configuration/mocks/es/ElasticSearchClientMock.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/config/mocks/PortalHealthCheckBuilderMock.java
index 04b398b7ce..46470cc04e 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/configuration/mocks/es/ElasticSearchClientMock.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/config/mocks/PortalHealthCheckBuilderMock.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* SDC
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020 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.
@@ -18,27 +18,27 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdc.asdctool.configuration.mocks.es;
+package org.openecomp.sdc.asdctool.migration.config.mocks;
-import org.openecomp.sdc.be.dao.es.ElasticSearchClient;
+import org.openecomp.sdc.be.components.health.PortalHealthCheckBuilder;
+import org.springframework.stereotype.Component;
-public class ElasticSearchClientMock extends ElasticSearchClient {
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
- @Override
- public void initialize() {
+@Component("portalHealthCheckBusinessLogic")
+public class PortalHealthCheckBuilderMock extends PortalHealthCheckBuilder {
- }
@Override
- public void setClusterName(final String clusterName) {
-
+ @PostConstruct
+ public PortalHealthCheckBuilder init() {
+ return null;
}
@Override
- public void setLocal(final String strIsLocal) {
- }
+ @PreDestroy
+ protected void destroy() {
- @Override
- public void setTransportClient(final String strIsTransportclient) {
}
}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/core/DBVersion.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/core/DBVersion.java
index a713f9243a..17c3aea42c 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/core/DBVersion.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/core/DBVersion.java
@@ -33,7 +33,7 @@ public class DBVersion implements Comparable<DBVersion>{
/**
* The current db version. should be tested against real db to verify it is compatible to the db version
*/
- public static final DBVersion CURRENT_VERSION = new DBVersion(1710, 0);
+ public static final DBVersion DEFAULT_VERSION = new DBVersion(1710, 0);
private DBVersion(BigInteger major, BigInteger minor) {
this.major = major;
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/core/task/PostMigration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/core/task/PostMigration.java
index f341ab2792..5ed2e56408 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/core/task/PostMigration.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/core/task/PostMigration.java
@@ -27,7 +27,7 @@ public interface PostMigration extends IMigrationStage {
@Override
default
public DBVersion getVersion() {
- return DBVersion.CURRENT_VERSION;
+ return DBVersion.DEFAULT_VERSION;
}
@Override
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/dao/MigrationTasksAccessor.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/dao/MigrationTasksAccessor.java
index 2dd51fcefd..74c74052e7 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/dao/MigrationTasksAccessor.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/dao/MigrationTasksAccessor.java
@@ -31,6 +31,9 @@ public interface MigrationTasksAccessor {
@Query("SELECT minor_version FROM sdcrepository.migrationTasks WHERE major_version = :majorVersion order by minor_version desc limit 1")
ResultSet getLatestMinorVersion(@Param("majorVersion") Long majorVersion);
+ @Query("SELECT major_version FROM sdcrepository.migrationTasks")
+ ResultSet getLatestMajorVersion();
+
@Query("DELETE FROM sdcrepository.migrationTasks WHERE major_version = :majorVersion")
void deleteTasksForMajorVersion(@Param("majorVersion") Long majorVersion);
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/dao/MigrationTasksDao.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/dao/MigrationTasksDao.java
index 1d7e66250e..aabd4d8bb0 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/dao/MigrationTasksDao.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/dao/MigrationTasksDao.java
@@ -27,6 +27,7 @@ import com.datastax.driver.mapping.Mapper;
import com.datastax.driver.mapping.MappingManager;
import fj.data.Either;
import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.openecomp.sdc.asdctool.migration.core.DBVersion;
import org.openecomp.sdc.be.dao.cassandra.CassandraClient;
import org.openecomp.sdc.be.dao.cassandra.CassandraDao;
import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus;
@@ -38,6 +39,9 @@ import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.math.BigInteger;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
@Service
public class MigrationTasksDao extends CassandraDao {
@@ -77,13 +81,29 @@ public class MigrationTasksDao extends CassandraDao {
try {
ResultSet latestMinorVersion = migrationTasksAccessor.getLatestMinorVersion(majorVersion.longValue());
Row minorVersionRow = latestMinorVersion.one();
- return minorVersionRow == null ? BigInteger.valueOf(Long.MIN_VALUE) : BigInteger.valueOf(minorVersionRow.getLong(0));
+ return minorVersionRow == null ? DBVersion.DEFAULT_VERSION.getMinor() : BigInteger.valueOf(minorVersionRow.getLong(0));
} catch (RuntimeException e) {
logger.error("failed to get latest minor version for major version {}", majorVersion, e);
throw e;
}
}
+ public BigInteger getLatestMajorVersion() {
+ try {
+ ResultSet latestMajorVersion = migrationTasksAccessor.getLatestMajorVersion();
+ List<Row> all = latestMajorVersion.all();
+ Long majorVersionRow = null;
+ if (all.size() != 0){
+ List<Long> majorVersions = all.stream().map(p -> p.getLong(0)).collect(Collectors.toList());
+ majorVersionRow = Collections.max(majorVersions);
+ }
+ return majorVersionRow == null ? DBVersion.DEFAULT_VERSION.getMajor() : BigInteger.valueOf(majorVersionRow);
+ } catch (RuntimeException e) {
+ logger.error("failed to get latest major version ", e);
+ throw e;
+ }
+ }
+
public void deleteAllTasksForVersion(BigInteger majorVersion) {
try {
migrationTasksAccessor.deleteTasksForMajorVersion(majorVersion.longValue());
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/service/SdcRepoService.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/service/SdcRepoService.java
index 9e62530d17..9141295dd4 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/service/SdcRepoService.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/service/SdcRepoService.java
@@ -35,13 +35,13 @@ public class SdcRepoService {
}
public DBVersion getLatestDBVersion() {
- BigInteger currentMajorVersion = DBVersion.CURRENT_VERSION.getMajor();
+ BigInteger currentMajorVersion = migrationTasksDao.getLatestMajorVersion();
BigInteger latestMinorVersion = migrationTasksDao.getLatestMinorVersion(currentMajorVersion);
- return latestMinorVersion == null ? DBVersion.from(currentMajorVersion, BigInteger.valueOf(Integer.MIN_VALUE)) : DBVersion.from(currentMajorVersion, latestMinorVersion);
+ return DBVersion.from(currentMajorVersion, latestMinorVersion);
}
public void clearTasksForCurrentMajor() {
- BigInteger currentMajorVersion = DBVersion.CURRENT_VERSION.getMajor();
+ BigInteger currentMajorVersion = DBVersion.DEFAULT_VERSION.getMajor();
migrationTasksDao.deleteAllTasksForVersion(currentMajorVersion);
}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/InstanceMigrationBase.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/InstanceMigrationBase.java
new file mode 100644
index 0000000000..b0a1d502aa
--- /dev/null
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/InstanceMigrationBase.java
@@ -0,0 +1,178 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2020 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=========================================================
+ */
+
+package org.openecomp.sdc.asdctool.migration.tasks;
+
+import fj.data.Either;
+import org.apache.tinkerpop.gremlin.structure.Direction;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.janusgraph.core.JanusGraphVertex;
+import org.openecomp.sdc.asdctool.migration.tasks.mig2002.SdcCollapsingRolesRFCstateMigration;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
+import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
+import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
+import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
+import org.openecomp.sdc.be.dao.jsongraph.types.EdgePropertyEnum;
+import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
+import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
+import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
+import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.EnumMap;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+public abstract class InstanceMigrationBase {
+
+ private static final Logger log = LoggerFactory.getLogger(InstanceMigrationBase.class);
+ protected JanusGraphDao janusGraphDao;
+
+ public InstanceMigrationBase(JanusGraphDao janusGraphDao) {
+ this.janusGraphDao = janusGraphDao;
+ }
+
+ protected StorageOperationStatus upgradeTopologyTemplates() {
+ Map<GraphPropertyEnum, Object> hasNotProps = new EnumMap<>(GraphPropertyEnum.class);
+ hasNotProps.put(GraphPropertyEnum.IS_DELETED, true);
+ hasNotProps.put(GraphPropertyEnum.RESOURCE_TYPE, ResourceTypeEnum.CVFC);
+
+ return janusGraphDao.getByCriteria(VertexTypeEnum.TOPOLOGY_TEMPLATE, null, hasNotProps, JsonParseFlagEnum.ParseAll)
+ .either(this::proceed, this::handleError);
+ }
+
+ protected abstract StorageOperationStatus handleOneContainer(GraphVertex containerV);
+
+ protected StorageOperationStatus proceed(List<GraphVertex> containersV) {
+ int failureCounter = 0;
+ log.info("found {} vertices to migrate ", containersV.size());
+ for (GraphVertex container : containersV) {
+ StorageOperationStatus storageOperationStatus = handleOneContainer(container);
+ if (storageOperationStatus != StorageOperationStatus.OK) {
+ failureCounter++;
+ }
+ }
+
+ if (failureCounter > 0) {
+ log.info("Failed to update {} vertices", failureCounter);
+ } else {
+ log.info("All vertices were successfully updated");
+ }
+
+ return StorageOperationStatus.OK;
+ }
+
+ protected GraphVertex getVertexById(String vertexId) {
+ Either<GraphVertex, JanusGraphOperationStatus> vertexById = janusGraphDao.getVertexById(vertexId);
+ if (vertexById.isRight()) {
+ log.info("Exception occurred while query vertexId: {} exception: {} " + vertexId + vertexById.right().value());
+ return null;
+ }
+ else return vertexById.left().value();
+ }
+
+ protected StorageOperationStatus updateVertexAndCommit(GraphVertex graphVertex) {
+ StorageOperationStatus status;
+ if ((status = janusGraphDao.updateVertex(graphVertex)
+ .either(v -> StorageOperationStatus.OK, this::handleError)) != StorageOperationStatus.OK) {
+ return status;
+ }
+ return DaoStatusConverter.convertJanusGraphStatusToStorageStatus(janusGraphDao.commit());
+ }
+
+ protected StorageOperationStatus handleError(JanusGraphOperationStatus err) {
+ return DaoStatusConverter.convertJanusGraphStatusToStorageStatus(JanusGraphOperationStatus.NOT_FOUND == err ? JanusGraphOperationStatus.OK : err);
+ }
+
+ protected void removeEdges(Iterator<Edge> edges) {
+
+ while (edges.hasNext()) {
+ Edge edge = edges.next();
+ edge.remove();
+ }
+ }
+
+ protected void removeEdgesInState(Iterator<Edge> edges, String state) {
+
+ while (edges.hasNext()) {
+ Edge edge = edges.next();
+ String edgeState = (String) janusGraphDao.getProperty(edge, EdgePropertyEnum.STATE);
+ if (edgeState.equals(state)) {
+ edge.remove();
+ }
+ }
+ }
+
+
+ protected void updateEdgeProperty(EdgePropertyEnum property, String value, Iterator<Edge> edges) throws IOException {
+ while (edges.hasNext()) {
+ Edge edge = edges.next();
+ Map<EdgePropertyEnum, Object> prop = new HashMap<>();
+ prop.put(property, value);
+ janusGraphDao.setEdgeProperties(edge, prop);
+ }
+
+ }
+
+
+ // check if user has both edges state and last_state
+ protected boolean sameUser(List<JanusGraphVertex> stateList, List<JanusGraphVertex> lastStateList) {
+
+ for (JanusGraphVertex lsVertex : lastStateList) {
+ String idLs = (String) janusGraphDao.getProperty(lsVertex, GraphPropertyEnum.USERID.getProperty());
+ String idSt = (String) janusGraphDao.getProperty(stateList.get(0), GraphPropertyEnum.USERID.getProperty());
+ if (idLs.equals(idSt)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ protected List<JanusGraphVertex> getVertexByEdgeSide(Iterator<Edge> edges, SdcCollapsingRolesRFCstateMigration.EdgeSide side) {
+ List<JanusGraphVertex> vertexList = new ArrayList();
+ while (edges.hasNext()) {
+ Edge edge = edges.next();
+
+ if (side == SdcCollapsingRolesRFCstateMigration.EdgeSide.OUT) {
+ vertexList.add((JanusGraphVertex) edge.outVertex());
+ } else {
+ vertexList.add((JanusGraphVertex) edge.inVertex());
+ }
+ }
+
+ return vertexList;
+ }
+
+ protected Iterator<Edge> getVertexEdge(GraphVertex containerV, Direction direction, EdgeLabelEnum edgeLabel) {
+ return containerV.getVertex().edges(direction, edgeLabel.name());
+ }
+
+ public enum EdgeSide {
+ IN, OUT;
+ }
+}
+
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/handlers/XlsOutputHandler.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/handlers/XlsOutputHandler.java
index d51271bd69..758589cb53 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/handlers/XlsOutputHandler.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/handlers/XlsOutputHandler.java
@@ -82,7 +82,7 @@ public class XlsOutputHandler implements OutputHandler {
file.close();
return true;
} catch (Exception e) {
- log.debug("#writeOutputAndCloseFile - Failed to write an output file. ", e);
+ log.debug("#writeOutputAndCloseFile - Failed to write an output file. The {} exception occurred. ", e.getMessage());
return false;
}
}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1710/UpgradeMigration1710.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1710/UpgradeMigration1710.java
index 49cd1fea88..8eda8640c6 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1710/UpgradeMigration1710.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1710/UpgradeMigration1710.java
@@ -26,12 +26,14 @@ import fj.data.Either;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
+import org.openecomp.sdc.asdctool.enums.LifecycleStateEnum;
import org.openecomp.sdc.asdctool.migration.core.task.MigrationResult;
import org.openecomp.sdc.asdctool.migration.core.task.PostMigration;
import org.openecomp.sdc.asdctool.migration.tasks.handlers.XlsOutputHandler;
import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
import org.openecomp.sdc.be.components.impl.ResourceBusinessLogic;
import org.openecomp.sdc.be.components.impl.ServiceBusinessLogic;
+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.lifecycle.LifecycleBusinessLogic;
@@ -47,22 +49,37 @@ import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
-import org.openecomp.sdc.be.datatypes.enums.*;
+import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
+import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
+import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.impl.ComponentsUtils;
-import org.openecomp.sdc.be.model.*;
+import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.ComponentInstanceProperty;
+import org.openecomp.sdc.be.model.ComponentParametersView;
+import org.openecomp.sdc.be.model.LifeCycleTransitionEnum;
+import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
import org.openecomp.sdc.be.model.jsonjanusgraph.utils.ModelConverter;
-import org.openecomp.sdc.be.model.operations.api.IUserAdminOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.CsarOperation;
import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter;
+import org.openecomp.sdc.be.model.operations.impl.UserAdminOperation;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.openecomp.sdc.exception.ResponseFormat;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.EnumMap;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
import java.util.function.Predicate;
import java.util.stream.Collectors;
@@ -103,7 +120,7 @@ public class UpgradeMigration1710 implements PostMigration {
private LifecycleBusinessLogic lifecycleBusinessLogic;
@Autowired
- private IUserAdminOperation userAdminOperation;
+ private UserAdminOperation userAdminOperation;
@Autowired
private ResourceBusinessLogic resourceBusinessLogic;
@@ -481,20 +498,25 @@ public class UpgradeMigration1710 implements PostMigration {
private Either<org.openecomp.sdc.be.model.Component, ResponseFormat> updateComposition(org.openecomp.sdc.be.model.Component component) {
if (component != null && component.getComponentInstances() != null) {
- Either<ComponentInstance, ResponseFormat> upgradeInstanceRes;
for (ComponentInstance instance : component.getComponentInstances()) {
- upgradeInstanceRes = upgradeInstance(component, instance);
- if (upgradeInstanceRes.isRight()) {
- log.error(FAILED_TO_UPGRADE_COMPONENT, component.getComponentType().getValue(), component.getName(), component.getInvariantUUID(), component.getVersion(), "upgradeInstance", upgradeInstanceRes.right().value().getFormattedMessage());
- outputHandler.addRecord(component.getComponentType().name(), component.getName(), component.getUUID(), component.getUniqueId(), MigrationResult.MigrationStatus.FAILED.name(), upgradeInstanceRes.right().value().getFormattedMessage());
- return Either.right(upgradeInstanceRes.right().value());
+ try {
+ upgradeInstance(component, instance);
+ }catch (ComponentException e){
+ ResponseFormat responseFormat = e.getResponseFormat();
+ log.error(FAILED_TO_UPGRADE_COMPONENT, component.getComponentType().getValue(), component.getName(),
+ component.getInvariantUUID(), component.getVersion(), "upgradeInstance",
+ responseFormat.getFormattedMessage());
+ outputHandler.addRecord(component.getComponentType().name(), component.getName(), component.getUUID(),
+ component.getUniqueId(), MigrationResult.MigrationStatus.FAILED.name(),
+ responseFormat.getFormattedMessage());
+ return Either.right(responseFormat);
}
}
}
return Either.left(component);
}
- private Either<ComponentInstance, ResponseFormat> upgradeInstance(org.openecomp.sdc.be.model.Component component, ComponentInstance instance) {
+ private ComponentInstance upgradeInstance(org.openecomp.sdc.be.model.Component component, ComponentInstance instance) {
log.info("Starting upgrade {} instance {} upon upgrade migration 1710 process. ", component.getComponentType().getValue(), instance.getName());
ComponentInstance newComponentInstance = new ComponentInstance(instance);
if (instance.getOriginType() == OriginTypeEnum.ServiceProxy) {
@@ -503,35 +525,33 @@ public class UpgradeMigration1710 implements PostMigration {
return upgradeResourceInstance(component, instance, newComponentInstance);
}
- private Either<ComponentInstance, ResponseFormat> upgradeResourceInstance(org.openecomp.sdc.be.model.Component component, ComponentInstance instance, ComponentInstance newComponentInstance) {
+ private ComponentInstance upgradeResourceInstance(org.openecomp.sdc.be.model.Component component, ComponentInstance instance, ComponentInstance newComponentInstance) {
log.info("Starting upgrade {} instance {} upon upgrade migration 1710 process. ", component.getComponentType().getValue(), instance.getName());
- Either<ComponentInstance, ResponseFormat> upgradeInstanceRes = null;
+ ComponentInstance upgradeInstanceRes = null;
VertexTypeEnum vertexType = ModelConverter.getVertexType(instance.getOriginType().name());
Either<Resource, StorageOperationStatus> getOriginRes = toscaOperationFacade.getLatestCertifiedByToscaResourceName(instance.getToscaComponentName(), vertexType, JsonParseFlagEnum.ParseMetadata);
if(getOriginRes.isRight()){
log.info("Upgrade of {} instance {} upon upgrade migration 1710 process failed due to a reason {}. ",
component.getComponentType().getValue(), instance.getName(), getOriginRes.right().value());
- upgradeInstanceRes = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(getOriginRes.right().value(), instance.getOriginType().getComponentType())));
+ throw new ByActionStatusComponentException(componentsUtils.convertFromStorageResponse(getOriginRes.right().value(), instance.getOriginType().getComponentType()));
}
- if(upgradeInstanceRes == null) {
- copyComponentNameAndVersionToNewInstance(newComponentInstance, getOriginRes.left().value());
+ copyComponentNameAndVersionToNewInstance(newComponentInstance, getOriginRes.left().value());
- if(isGreater(getOriginRes.left().value().getVersion(), instance.getComponentVersion())){
- upgradeInstanceRes = changeAssetVersion(component, instance, newComponentInstance);
- }
- if((upgradeInstanceRes == null || upgradeInstanceRes.isLeft()) && isAllottedResource(instance.getComponentUid()) && MapUtils.isNotEmpty(component.getComponentInstancesProperties())){
- ComponentInstance instanceToUpdate = upgradeInstanceRes == null ? instance : upgradeInstanceRes.left().value();
- upgradeInstanceRes = Either.left(updateServiceUuidProperty(component, instanceToUpdate, component.getComponentInstancesProperties().get(instance.getUniqueId())));
- }
+ if(isGreater(getOriginRes.left().value().getVersion(), instance.getComponentVersion())){
+ upgradeInstanceRes = changeAssetVersion(component, instance, newComponentInstance);
+ }
+ if(isAllottedResource(instance.getComponentUid()) && MapUtils.isNotEmpty(component.getComponentInstancesProperties())){
+ ComponentInstance instanceToUpdate = upgradeInstanceRes == null ? instance : upgradeInstanceRes;
+ upgradeInstanceRes = updateServiceUuidProperty(component, instanceToUpdate, component.getComponentInstancesProperties().get(instance.getUniqueId()));
}
//upgrade nodes contained by CVFC
if(upgradeInstanceRes == null && isVfcUpgradeRequired && newComponentInstance.getOriginType() == OriginTypeEnum.CVFC &&
!upgradeVf(getOriginRes.left().value().getUniqueId(), false, true)) {
- upgradeInstanceRes = Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
+ throw new ByActionStatusComponentException(ActionStatus.GENERAL_ERROR);
}
if(upgradeInstanceRes == null){
- upgradeInstanceRes = Either.left(instance);
+ upgradeInstanceRes = instance;
}
log.info("Upgrade of {} instance {} upon upgrade migration 1710 process finished successfully. ",
component.getComponentType().getValue(), instance.getName());
@@ -584,17 +604,17 @@ public class UpgradeMigration1710 implements PostMigration {
return isAllottedResource(component.getUniqueId());
}
- private Either<ComponentInstance, ResponseFormat> upgradeServiceProxyInstance(org.openecomp.sdc.be.model.Component component, ComponentInstance instance, ComponentInstance newComponentInstance) {
+ private ComponentInstance upgradeServiceProxyInstance(org.openecomp.sdc.be.model.Component component, ComponentInstance instance, ComponentInstance newComponentInstance) {
Either<List<GraphVertex>, JanusGraphOperationStatus> getLatestOriginServiceRes = getLatestCertifiedService(instance.getSourceModelInvariant());
if (getLatestOriginServiceRes.isRight()) {
- return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(getLatestOriginServiceRes.right().value()), instance.getOriginType().getComponentType())));
+ throw new ByActionStatusComponentException(componentsUtils.convertFromStorageResponse(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(getLatestOriginServiceRes.right().value()), instance.getOriginType().getComponentType()));
}
ModelConverter.getVertexType(instance.getOriginType().name());
Either<Resource, StorageOperationStatus> getOriginRes = toscaOperationFacade.getLatestByName(instance.getComponentName());
if(getOriginRes.isRight()){
log.info("Upgrade of {} instance {} upon upgrade migration 1710 process failed due to a reason {}. ",
component.getComponentType().getValue(), instance.getName(), getOriginRes.right().value());
- return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(getOriginRes.right().value(), instance.getOriginType().getComponentType())));
+ throw new ByActionStatusComponentException(componentsUtils.convertFromStorageResponse(getOriginRes.right().value(), instance.getOriginType().getComponentType()));
}
newComponentInstance.setComponentUid((String) getLatestOriginServiceRes.left().value().get(0).getJsonMetadataField(JsonPresentationFields.UNIQUE_ID));
return changeAssetVersion(component, instance, newComponentInstance);
@@ -613,7 +633,7 @@ public class UpgradeMigration1710 implements PostMigration {
.getByCriteria(VertexTypeEnum.TOPOLOGY_TEMPLATE, propertiesToMatch, propertiesNotToMatch, JsonParseFlagEnum.ParseMetadata);
}
- private Either<ComponentInstance, ResponseFormat> changeAssetVersion(org.openecomp.sdc.be.model.Component containerComponent, ComponentInstance instance, ComponentInstance newComponentInstance) {
+ private ComponentInstance changeAssetVersion(org.openecomp.sdc.be.model.Component containerComponent, ComponentInstance instance, ComponentInstance newComponentInstance) {
return componentInstanceBusinessLogic.changeComponentInstanceVersion(ComponentTypeEnum.SERVICE_PARAM_NAME, containerComponent.getUniqueId(), instance.getUniqueId(), user.getUserId(), newComponentInstance);
}
@@ -857,7 +877,7 @@ public class UpgradeMigration1710 implements PostMigration {
log.info("Starting upgrade node type with name {}, invariantUUID {}, version{}. ", nodeTypeV.getMetadataProperty(GraphPropertyEnum.NAME), nodeTypeV.getMetadataProperty(GraphPropertyEnum.INVARIANT_UUID), nodeTypeV.getMetadataProperty(GraphPropertyEnum.VERSION));
log.info("Starting to find derived to for node type with name {}, invariantUUID {}, version{}. ", nodeTypeV.getMetadataProperty(GraphPropertyEnum.NAME), nodeTypeV.getMetadataProperty(GraphPropertyEnum.INVARIANT_UUID), nodeTypeV.getMetadataProperty(GraphPropertyEnum.VERSION));
Either<List<GraphVertex>, JanusGraphOperationStatus> parentResourceRes = janusGraphDao
- .getParentVertecies(nodeTypeV, EdgeLabelEnum.DERIVED_FROM, JsonParseFlagEnum.ParseMetadata);
+ .getParentVertices(nodeTypeV, EdgeLabelEnum.DERIVED_FROM, JsonParseFlagEnum.ParseMetadata);
if (parentResourceRes.isRight() && parentResourceRes.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
return DaoStatusConverter.convertJanusGraphStatusToStorageStatus(parentResourceRes.right().value());
@@ -916,18 +936,9 @@ public class UpgradeMigration1710 implements PostMigration {
private Either<? extends org.openecomp.sdc.be.model.Component, ResponseFormat> performFullCertification(org.openecomp.sdc.be.model.Component component) {
log.info("Starting to perform full certification of {} with name {}, invariantUUID {}, version {}. ",
component.getComponentType().getValue(), component.getName(), component.getInvariantUUID(), component.getVersion());
-
- Either<? extends org.openecomp.sdc.be.model.Component, ResponseFormat> changeStateEither = lifecycleBusinessLogic.changeComponentState(component.getComponentType(), component.getUniqueId(), user, LifeCycleTransitionEnum.CERTIFICATION_REQUEST, changeInfo, true, false);
- if (changeStateEither.isRight()) {
- log.info(FAILED_TO_CHANGE_STATE_OF_COMPONENT, component.getName(), component.getInvariantUUID(), component.getVersion(), LifeCycleTransitionEnum.CERTIFICATION_REQUEST);
- return changeStateEither;
- }
- changeStateEither = lifecycleBusinessLogic.changeComponentState(component.getComponentType(), changeStateEither.left().value().getUniqueId(), user, LifeCycleTransitionEnum.START_CERTIFICATION, changeInfo, true, false);
- if (changeStateEither.isRight()) {
- log.info(FAILED_TO_CHANGE_STATE_OF_COMPONENT, component.getName(), component.getInvariantUUID(), component.getVersion(), LifeCycleTransitionEnum.START_CERTIFICATION);
- return changeStateEither;
- }
- changeStateEither = lifecycleBusinessLogic.changeComponentState(component.getComponentType(), changeStateEither.left().value().getUniqueId(), user, LifeCycleTransitionEnum.CERTIFY, changeInfo, true, false);
+ org.openecomp.sdc.be.model.Component updatedComponent = component;
+ Either<? extends org.openecomp.sdc.be.model.Component, ResponseFormat> changeStateEither;
+ changeStateEither = lifecycleBusinessLogic.changeComponentState(component.getComponentType(), updatedComponent.getUniqueId(), user, LifeCycleTransitionEnum.CERTIFY, changeInfo, true, false);
if (changeStateEither.isRight()) {
log.info(FAILED_TO_CHANGE_STATE_OF_COMPONENT, component.getName(), component.getInvariantUUID(), component.getVersion(), LifeCycleTransitionEnum.CERTIFY);
} else {
@@ -997,6 +1008,7 @@ public class UpgradeMigration1710 implements PostMigration {
propertiesToMatch.put(GraphPropertyEnum.COMPONENT_TYPE, componentType.name());
propertiesToMatch.put(GraphPropertyEnum.IS_HIGHEST_VERSION, true);
+
Map<GraphPropertyEnum, Object> propertiesNotToMatch = new EnumMap<>(GraphPropertyEnum.class);
propertiesNotToMatch.put(GraphPropertyEnum.IS_DELETED, true);
if (vertexType == VertexTypeEnum.TOPOLOGY_TEMPLATE && componentType == ComponentTypeEnum.RESOURCE) {
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/ForwardPathMigration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/ForwardPathMigration.java
index 812c07e6b0..f0f59c4450 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/ForwardPathMigration.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/ForwardPathMigration.java
@@ -17,33 +17,23 @@
package org.openecomp.sdc.asdctool.migration.tasks.mig1806;
import com.google.common.collect.ImmutableSet;
-import org.janusgraph.core.JanusGraphVertex;
import fj.data.Either;
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.EnumMap;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.stream.Collectors;
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.janusgraph.core.JanusGraphVertex;
import org.openecomp.sdc.asdctool.migration.core.DBVersion;
import org.openecomp.sdc.asdctool.migration.core.task.Migration;
import org.openecomp.sdc.asdctool.migration.core.task.MigrationResult;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
import org.openecomp.sdc.be.dao.jsongraph.utils.IdBuilderUtils;
-import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
@@ -56,7 +46,18 @@ import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter;
import org.openecomp.sdc.be.model.operations.impl.UserAdminOperation;
-@org.springframework.stereotype.Component
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.EnumMap;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+//@org.springframework.stereotype.Component
public class ForwardPathMigration implements Migration {
private JanusGraphDao janusGraphDao;
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/ResourceLifecycleMigration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/ResourceLifecycleMigration.java
index ea1e4a5529..8f7fc3eeb5 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/ResourceLifecycleMigration.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/ResourceLifecycleMigration.java
@@ -21,6 +21,7 @@
package org.openecomp.sdc.asdctool.migration.tasks.mig1806;
import fj.data.Either;
+import org.openecomp.sdc.asdctool.enums.LifecycleStateEnum;
import org.openecomp.sdc.asdctool.migration.core.DBVersion;
import org.openecomp.sdc.asdctool.migration.core.task.Migration;
import org.openecomp.sdc.asdctool.migration.core.task.MigrationResult;
@@ -36,7 +37,6 @@ import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
import org.openecomp.sdc.be.model.LifeCycleTransitionEnum;
-import org.openecomp.sdc.be.model.LifecycleStateEnum;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter;
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/SDCInstancesMigration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/SDCInstancesMigration.java
index bcb236338f..a28c27fe6c 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/SDCInstancesMigration.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/SDCInstancesMigration.java
@@ -24,34 +24,35 @@ import fj.data.Either;
import org.openecomp.sdc.asdctool.migration.core.DBVersion;
import org.openecomp.sdc.asdctool.migration.core.task.Migration;
import org.openecomp.sdc.asdctool.migration.core.task.MigrationResult;
+import org.openecomp.sdc.asdctool.migration.tasks.InstanceMigrationBase;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
-import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.CompositionDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapPropertiesDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
-import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.model.jsonjanusgraph.enums.JsonConstantKeysEnum;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.NodeTemplateOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
-import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.springframework.stereotype.Component;
import java.math.BigInteger;
-import java.util.*;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import java.util.Map.Entry;
+import java.util.Optional;
@Component
-public class SDCInstancesMigration implements Migration {
+public class SDCInstancesMigration extends InstanceMigrationBase implements Migration {
- private JanusGraphDao janusGraphDao;
private NodeTemplateOperation nodeTemplateOperation;
private static final Logger log = Logger.getLogger(SDCInstancesMigration.class);
@@ -62,7 +63,7 @@ public class SDCInstancesMigration implements Migration {
public SDCInstancesMigration(JanusGraphDao janusGraphDao, NodeTemplateOperation nodeTemplateOperation) {
- this.janusGraphDao = janusGraphDao;
+ super(janusGraphDao);
this.nodeTemplateOperation = nodeTemplateOperation;
}
@@ -78,41 +79,14 @@ public class SDCInstancesMigration implements Migration {
@Override
public MigrationResult migrate() {
- StorageOperationStatus status = connectAllContainers();
-
+ StorageOperationStatus status = upgradeTopologyTemplates();
return status == StorageOperationStatus.OK ? MigrationResult.success() : MigrationResult.error("failed to create connection between instances and origins. Error : " + status);
}
- private StorageOperationStatus connectAllContainers() {
- StorageOperationStatus status;
- Map<GraphPropertyEnum, Object> hasNotProps = new EnumMap<>(GraphPropertyEnum.class);
- hasNotProps.put(GraphPropertyEnum.IS_DELETED, true);
- hasNotProps.put(GraphPropertyEnum.RESOURCE_TYPE, ResourceTypeEnum.CVFC);
-
- status = janusGraphDao
- .getByCriteria(VertexTypeEnum.TOPOLOGY_TEMPLATE, null, hasNotProps, JsonParseFlagEnum.ParseAll)
- .either(this::connectAll, this::handleError);
- return status;
- }
-
- private StorageOperationStatus handleError(JanusGraphOperationStatus err) {
- return DaoStatusConverter.convertJanusGraphStatusToStorageStatus(
- JanusGraphOperationStatus.NOT_FOUND == err ? JanusGraphOperationStatus.OK : err);
- }
-
- private StorageOperationStatus connectAll(List<GraphVertex> containersV) {
+ protected StorageOperationStatus handleOneContainer(GraphVertex containerVorig) {
StorageOperationStatus status = StorageOperationStatus.OK;
- for (GraphVertex container : containersV) {
- status = handleOneContainer(container);
- if (status != StorageOperationStatus.OK) {
- break;
- }
- }
- return status;
- }
- private StorageOperationStatus handleOneContainer(GraphVertex containerV) {
- StorageOperationStatus status = StorageOperationStatus.OK;
+ GraphVertex containerV = getVertexById(containerVorig.getUniqueId());
boolean needConnectAllotted = false;
ComponentTypeEnum componentType = containerV.getType();
@@ -154,6 +128,7 @@ public class SDCInstancesMigration implements Migration {
return status;
}
+
private Either<Map<String, MapPropertiesDataDefinition>, StorageOperationStatus> getInstProperties(GraphVertex containerV) {
Map<String, MapPropertiesDataDefinition> instanceProperties;
Either<GraphVertex, JanusGraphOperationStatus> instProps = janusGraphDao
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1902/InterfaceOperationMigration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1902/InterfaceOperationMigration.java
index 35e795095e..fd71336fd5 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1902/InterfaceOperationMigration.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1902/InterfaceOperationMigration.java
@@ -17,10 +17,6 @@
package org.openecomp.sdc.asdctool.migration.tasks.mig1902;
import fj.data.Either;
-import java.math.BigInteger;
-import java.util.EnumMap;
-import java.util.List;
-import java.util.Map;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.openecomp.sdc.asdctool.migration.core.DBVersion;
@@ -45,6 +41,11 @@ import org.openecomp.sdc.be.model.operations.impl.UserAdminOperation;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.springframework.beans.factory.annotation.Autowired;
+import java.math.BigInteger;
+import java.util.EnumMap;
+import java.util.List;
+import java.util.Map;
+
@org.springframework.stereotype.Component
public class InterfaceOperationMigration implements Migration {
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1902/SdcConsumerMigration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1902/SdcConsumerMigration.java
new file mode 100644
index 0000000000..16f0c485dc
--- /dev/null
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1902/SdcConsumerMigration.java
@@ -0,0 +1,108 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2020 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=========================================================
+ */
+
+package org.openecomp.sdc.asdctool.migration.tasks.mig1902;
+
+import fj.data.Either;
+import org.openecomp.sdc.asdctool.migration.core.DBVersion;
+import org.openecomp.sdc.asdctool.migration.core.task.Migration;
+import org.openecomp.sdc.asdctool.migration.core.task.MigrationResult;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphGenericDao;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
+import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
+import org.openecomp.sdc.be.resources.data.ConsumerData;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+import java.math.BigInteger;
+import java.util.List;
+
+@Component
+public class SdcConsumerMigration implements Migration {
+
+ private static final Logger logger = LoggerFactory.getLogger(SdcConsumerMigration.class);
+
+ private JanusGraphGenericDao janusGraphGenericDao;
+
+ public SdcConsumerMigration(JanusGraphGenericDao janusGraphGenericDao) {
+ this.janusGraphGenericDao = janusGraphGenericDao;
+ }
+
+ @Override
+ public String description() {
+ return "remove all consumer nodes";
+ }
+
+ @Override
+ public DBVersion getVersion() {
+ return DBVersion.from(BigInteger.valueOf(1902), BigInteger.valueOf(0));
+ }
+
+ @Override
+ public MigrationResult migrate() {
+ JanusGraphOperationStatus status = null;
+ try {
+ status = handleConsumerNodes();
+ if (status == JanusGraphOperationStatus.OK){
+ logger.info("removed all consumer nodes.");
+ return MigrationResult.success();
+ } else {
+ return MigrationResult.error("failed to remove consumer nodes. error: " + status);
+ }
+ } finally {
+ commitOrRollBack(status);
+ }
+ }
+
+ private void commitOrRollBack(JanusGraphOperationStatus status) {
+ if (status == JanusGraphOperationStatus.OK) {
+ janusGraphGenericDao.commit();
+ } else {
+ janusGraphGenericDao.rollback();
+ }
+ }
+
+ private JanusGraphOperationStatus handleConsumerNodes() {
+ logger.info("getting all consumer nodes.");
+ return janusGraphGenericDao.getAll(NodeTypeEnum.ConsumerCredentials, ConsumerData.class)
+ .either(this::removeConsumerNodes, this::handleError);
+ }
+
+ private JanusGraphOperationStatus removeConsumerNodes(List<ConsumerData> consumerNodes){
+ logger.info("found {} consumer nodes.", consumerNodes.size());
+ return consumerNodes.stream()
+ .map(consumerNode -> janusGraphGenericDao.deleteNode(consumerNode, ConsumerData.class))
+ .filter(Either::isRight)
+ .map(either -> either.right().value())
+ .findAny()
+ .orElse(JanusGraphOperationStatus.OK);
+ }
+
+ private JanusGraphOperationStatus handleError(JanusGraphOperationStatus status){
+ if (status == JanusGraphOperationStatus.NOT_FOUND) {
+ logger.info("found 0 consumer nodes.");
+ return JanusGraphOperationStatus.OK;
+ } else{
+ return status;
+ }
+ }
+
+}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1902/SdcGroupsMigration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1902/SdcGroupsMigration.java
new file mode 100644
index 0000000000..1045634ef9
--- /dev/null
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1902/SdcGroupsMigration.java
@@ -0,0 +1,186 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2020 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=========================================================
+ */
+
+package org.openecomp.sdc.asdctool.migration.tasks.mig1902;
+
+import org.openecomp.sdc.asdctool.migration.core.DBVersion;
+import org.openecomp.sdc.asdctool.migration.core.task.Migration;
+import org.openecomp.sdc.asdctool.migration.core.task.MigrationResult;
+import org.openecomp.sdc.asdctool.migration.tasks.InstanceMigrationBase;
+import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
+import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
+import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
+import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
+import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
+import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
+import org.openecomp.sdc.be.model.GroupTypeDefinition;
+import org.openecomp.sdc.be.model.PropertyDefinition;
+import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+import org.openecomp.sdc.be.model.operations.impl.GroupTypeOperation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Component
+public class SdcGroupsMigration extends InstanceMigrationBase implements Migration {
+
+ private static final Logger log = LoggerFactory.getLogger(SdcGroupsMigration.class);
+
+ private final GroupTypeOperation groupTypeOperation;
+
+ private Map<String, GroupTypeDefinition> latestGroupTypeMap = new HashMap<>();
+
+ public enum GroupsForUpgrade {
+ NW_COLLECTION_GROUP_NAME("org.openecomp.groups.NetworkCollection"),
+ VFC_INSTANCE_GROUP_NAME("org.openecomp.groups.VfcInstanceGroup");
+
+ private String toscaType;
+
+ GroupsForUpgrade(String toscaType) {
+ this.toscaType = toscaType;
+ }
+
+ public static boolean containsToscaType(String type) {
+ try {
+ return Arrays.stream(values()).anyMatch(g->g.getToscaType().equals(type));
+ }
+ catch (IllegalArgumentException ex) {
+ return false;
+ }
+ }
+
+ public String getToscaType() {
+ return toscaType;
+ }
+
+ }
+ public SdcGroupsMigration(JanusGraphDao janusGraphDao, GroupTypeOperation groupTypeOperation) {
+ super(janusGraphDao);
+ this.groupTypeOperation = groupTypeOperation;
+ }
+
+ @Override
+ public String description() {
+ return "update derived from field value for NetworkCollection and VfcInstanceGroup group instances ";
+ }
+
+ @Override
+ public DBVersion getVersion() {
+ return DBVersion.from(BigInteger.valueOf(1902), BigInteger.valueOf(0));
+ }
+
+ @Override
+ public MigrationResult migrate() {
+ loadLatestGroupTypeDefinitions();
+ StorageOperationStatus status = upgradeTopologyTemplates();
+ return status == StorageOperationStatus.OK ?
+ MigrationResult.success() : MigrationResult.error("failed to update derived from value for NetworkCollection and VfcInstanceGroup group instances. Error : " + status);
+ }
+
+ void loadLatestGroupTypeDefinitions() {
+ Arrays.stream(GroupsForUpgrade.values()).forEach(this::getLatestGroupTypeDefinition);
+ }
+
+ @Override
+ protected StorageOperationStatus handleOneContainer(GraphVertex containerVorig) {
+ StorageOperationStatus status = StorageOperationStatus.NOT_FOUND;
+ GraphVertex containerV = getVertexById(containerVorig.getUniqueId());
+
+ try {
+ status = janusGraphDao.getChildVertex(containerV, EdgeLabelEnum.GROUPS, JsonParseFlagEnum.ParseAll)
+ .either(this::updateGroupPropertiesIfRequired, this::handleError);
+ }
+ catch (Exception e) {
+ log.error("Exception occurred:", e);
+ status = StorageOperationStatus.GENERAL_ERROR;
+ }
+ finally {
+ if (status != StorageOperationStatus.OK) {
+ janusGraphDao.rollback();
+ if (status == StorageOperationStatus.NOT_FOUND) {
+ //it is happy flow as well
+ status = StorageOperationStatus.OK;
+ }
+ }
+ if (log.isInfoEnabled()) {
+ log.info("Upgrade status is <{}> for topology template <{}> uniqueId <{}>",
+ status.name(), containerV.getMetadataProperties().get(GraphPropertyEnum.NAME),
+ containerV.getMetadataProperties().get(GraphPropertyEnum.UNIQUE_ID));
+ }
+ }
+ return status;
+ }
+
+ private StorageOperationStatus updateGroupPropertiesIfRequired(GraphVertex vertex) {
+ StorageOperationStatus status = StorageOperationStatus.NOT_FOUND;
+ boolean isUpdated = false;
+ Map<String, GroupDataDefinition> groupDefinitionMap = (Map<String, GroupDataDefinition>) vertex.getJson();
+ for (GroupDataDefinition groupDef : groupDefinitionMap.values()) {
+ if (GroupsForUpgrade.containsToscaType(groupDef.getType())) {
+ if (log.isDebugEnabled()) {
+ log.debug("Group instance named <{}> of type <{}> is supposed to be updated on vertex <{}>",
+ groupDef.getName(), groupDef.getType(), vertex.getUniqueId());
+ }
+ isUpdated = isGroupPropertiesUpdateDone(groupDef.getProperties(), latestGroupTypeMap.get(groupDef.getType()).getProperties());
+ if (log.isDebugEnabled()) {
+ String result = isUpdated ? "has been updated" : "is up to date ";
+ log.debug("Group instance named <{}> of type <{}> uniqueID <{}> {} on vertex <{}>",
+ groupDef.getName(), groupDef.getType(), groupDef.getUniqueId(), result, vertex.getUniqueId());
+ }
+ }
+ }
+ if (isUpdated) {
+ vertex.setJson(groupDefinitionMap);
+ status = updateVertexAndCommit(vertex);
+ if (status == StorageOperationStatus.OK && log.isDebugEnabled()) {
+ log.debug("Group properties change is committed on vertex <{}>", vertex.getUniqueId());
+ }
+ }
+ return status;
+ }
+
+ private boolean isGroupPropertiesUpdateDone(List<PropertyDataDefinition> curPropDefList, List<PropertyDefinition> latestGroupDefList) {
+ boolean isUpdated = false;
+ for (PropertyDefinition prop: latestGroupDefList) {
+ if (curPropDefList.stream().noneMatch(l->l.getName().equals(prop.getName()))) {
+ curPropDefList.add(prop);
+ isUpdated = true;
+ }
+ }
+ return isUpdated;
+ }
+
+ StorageOperationStatus getLatestGroupTypeDefinition(GroupsForUpgrade groupsForUpgrade) {
+ return groupTypeOperation.getLatestGroupTypeByType(groupsForUpgrade.getToscaType(), false)
+ .either(g-> {
+ latestGroupTypeMap.put(groupsForUpgrade.getToscaType(), g);
+ return StorageOperationStatus.OK;
+ }, err->err);
+ }
+
+
+}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1902/SdcResourceIconMigration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1902/SdcResourceIconMigration.java
new file mode 100644
index 0000000000..837abf1c08
--- /dev/null
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1902/SdcResourceIconMigration.java
@@ -0,0 +1,187 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2020 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=========================================================
+ */
+
+package org.openecomp.sdc.asdctool.migration.tasks.mig1902;
+
+import com.google.common.annotations.VisibleForTesting;
+import org.openecomp.sdc.asdctool.migration.core.DBVersion;
+import org.openecomp.sdc.asdctool.migration.core.task.Migration;
+import org.openecomp.sdc.asdctool.migration.core.task.MigrationResult;
+import org.openecomp.sdc.asdctool.migration.tasks.InstanceMigrationBase;
+import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
+import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
+import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
+import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
+import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.CompositionDataDefinition;
+import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
+import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
+import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
+import org.openecomp.sdc.be.model.jsonjanusgraph.enums.JsonConstantKeysEnum;
+import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+import org.openecomp.sdc.common.log.wrappers.Logger;
+import org.springframework.stereotype.Component;
+
+import java.math.BigInteger;
+import java.util.EnumMap;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Component
+public class SdcResourceIconMigration extends InstanceMigrationBase implements Migration {
+
+ private static final Logger log = Logger.getLogger(SdcResourceIconMigration.class);
+
+ private Map <String, String> resourceTypeToIconMap = new HashMap<>();
+
+ @VisibleForTesting
+ SdcResourceIconMigration(JanusGraphDao janusGraphDao) {
+ super(janusGraphDao);
+ }
+
+
+ @Override
+ public String description() {
+ return "update iconPath for VL and CP nodes";
+ }
+
+ @Override
+ public DBVersion getVersion() {
+ return DBVersion.from(BigInteger.valueOf(1902), BigInteger.valueOf(0));
+ }
+
+ @Override
+ public MigrationResult migrate() {
+ StorageOperationStatus status;
+ try {
+ updateNodeTypeIconAndStoreInMap(ResourceTypeEnum.VL);
+ updateNodeTypeIconAndStoreInMap(ResourceTypeEnum.CP);
+
+ if (!resourceTypeToIconMap.isEmpty()) {
+ status = upgradeTopologyTemplates();
+ } else {
+ log.error("No VL and CP node definitions found");
+ status = StorageOperationStatus.NOT_FOUND;
+ }
+ }
+ catch(Exception e) {
+ log.error("Exception thrown: {}", e);
+ status = StorageOperationStatus.GENERAL_ERROR;
+ }
+ return status == StorageOperationStatus.OK ?
+ MigrationResult.success() : MigrationResult.error("failed to update iconPath for VL and CP nodes. Error : " + status);
+ }
+
+ @Override
+ protected StorageOperationStatus handleOneContainer(GraphVertex containerVorig) {
+ StorageOperationStatus status = StorageOperationStatus.OK;
+ GraphVertex containerV = getVertexById(containerVorig.getUniqueId());
+
+ Map<String, CompositionDataDefinition> jsonComposition = (Map<String, CompositionDataDefinition>)containerV.getJson();
+ if (jsonComposition != null && !jsonComposition.isEmpty()) {
+ CompositionDataDefinition compositionDataDefinition = jsonComposition.get(JsonConstantKeysEnum.COMPOSITION.getValue());
+ Map<String, ComponentInstanceDataDefinition> componentInstances = compositionDataDefinition.getComponentInstances();
+
+ long updateCount = componentInstances.values()
+ .stream()
+ .filter(this::updateIconInsideInstance).count();
+ if (updateCount > 0) {
+ status = updateVertexAndCommit(containerV);
+ }
+ }
+ else {
+ log.warn("No json found for template <{}> uniqueId <{}>",
+ containerV.getMetadataProperties().get(GraphPropertyEnum.NAME),
+ containerV.getMetadataProperties().get(GraphPropertyEnum.UNIQUE_ID));
+ }
+ if (log.isInfoEnabled()) {
+ log.info("Upgrade status is <{}> for topology template <{}> uniqueId <{}>",
+ status.name(), containerV.getMetadataProperties().get(GraphPropertyEnum.NAME),
+ containerV.getMetadataProperties().get(GraphPropertyEnum.UNIQUE_ID));
+ }
+ return status;
+ }
+
+
+ @VisibleForTesting
+ boolean updateIconInsideInstance(ComponentInstanceDataDefinition componentInstanceDataDefinition) {
+ String iconPath = resourceTypeToIconMap.get(componentInstanceDataDefinition.getComponentName());
+ if (iconPath != null) {
+ componentInstanceDataDefinition.setIcon(iconPath);
+ if (log.isDebugEnabled()) {
+ log.debug("Icon of component {} is set to {}", componentInstanceDataDefinition.getComponentName(), iconPath);
+ }
+ return true;
+ }
+ return false;
+ }
+
+ @VisibleForTesting
+ void updateNodeTypeIconAndStoreInMap(ResourceTypeEnum resourceType) {
+ Map<GraphPropertyEnum, Object> propertiesToMatch = new EnumMap<>(GraphPropertyEnum.class);
+ Map<GraphPropertyEnum, Object> propertiesNotToMatch = new EnumMap<>(GraphPropertyEnum.class);
+
+ propertiesToMatch.put(GraphPropertyEnum.RESOURCE_TYPE, resourceType.name());
+ propertiesToMatch.put(GraphPropertyEnum.IS_HIGHEST_VERSION, true);
+
+ propertiesNotToMatch.put(GraphPropertyEnum.IS_DELETED, true);
+
+ String iconPath = String.valueOf(resourceType.getValue()).toLowerCase();
+
+ Map<String, String> resourceNameToIconMap = janusGraphDao.getByCriteria(VertexTypeEnum.NODE_TYPE, propertiesToMatch, propertiesNotToMatch, JsonParseFlagEnum.ParseAll)
+ .either(vl-> updateIconResource(vl, iconPath), status->null);
+
+ if (resourceNameToIconMap != null) {
+ resourceTypeToIconMap.putAll(resourceNameToIconMap);
+ }
+ else {
+ log.warn("Failed to get resources of type <{}>", resourceType.name());
+ }
+ }
+
+ private Map <String, String> updateIconResource(List<GraphVertex> vertexList, String iconPath) {
+ if (vertexList.isEmpty()) {
+ return null;
+ }
+ Map <String, String> nameToIconMap = new HashMap<>();
+ vertexList.forEach(v->{
+ StorageOperationStatus status = updateIconOnVertex(v, iconPath);
+ if (status == StorageOperationStatus.OK) {
+ if (log.isDebugEnabled()) {
+ log.debug("Node type's {} icon is updated to {}", v.getMetadataProperty(GraphPropertyEnum.NAME), iconPath);
+ }
+ nameToIconMap.put(String.valueOf(v.getMetadataProperty(GraphPropertyEnum.NAME)), iconPath);
+ }
+ else {
+ log.error("Failed to update node type {} icon due to a reason: {}",
+ v.getMetadataProperty(GraphPropertyEnum.NAME), status);
+ throw new RuntimeException("Node update failure");
+ }
+ });
+ return nameToIconMap;
+ }
+
+ private StorageOperationStatus updateIconOnVertex(GraphVertex vertex, String iconPath) {
+ vertex.setJsonMetadataField(JsonPresentationFields.ICON, iconPath);
+ return updateVertexAndCommit(vertex);
+ }
+
+}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1911/SdcDeploymentArtTimeOutMigration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1911/SdcDeploymentArtTimeOutMigration.java
new file mode 100644
index 0000000000..cba562750a
--- /dev/null
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1911/SdcDeploymentArtTimeOutMigration.java
@@ -0,0 +1,137 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2020 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=========================================================
+ */
+
+package org.openecomp.sdc.asdctool.migration.tasks.mig1911;
+
+import fj.data.Either;
+import org.openecomp.sdc.asdctool.migration.core.DBVersion;
+import org.openecomp.sdc.asdctool.migration.core.task.Migration;
+import org.openecomp.sdc.asdctool.migration.core.task.MigrationResult;
+import org.openecomp.sdc.asdctool.migration.tasks.InstanceMigrationBase;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
+import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
+import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
+import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
+import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
+import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
+import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.MapArtifactDataDefinition;
+import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
+import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+import org.openecomp.sdc.common.api.ArtifactTypeEnum;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+import java.math.BigInteger;
+import java.util.Collection;
+import java.util.EnumMap;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+
+@Component
+public class SdcDeploymentArtTimeOutMigration extends InstanceMigrationBase implements Migration {
+
+ private static final Logger log = LoggerFactory.getLogger(SdcDeploymentArtTimeOutMigration.class);
+ private static Integer defaultTimeOut = 120;
+
+ public SdcDeploymentArtTimeOutMigration(JanusGraphDao janusGraphDao) {
+ super(janusGraphDao);
+ }
+
+ @Override
+ public String description() {
+ return "update instance deployment artifact timeOut to default value 120 minutes";
+ }
+
+ @Override
+ public DBVersion getVersion() {
+ return DBVersion.from(BigInteger.valueOf(1911), BigInteger.valueOf(0));
+ }
+
+ @Override
+ public MigrationResult migrate() {
+ StorageOperationStatus status = updateDeploymentArtifactTimeOut();
+ return status == StorageOperationStatus.OK ?
+ MigrationResult.success() : MigrationResult.error("failed to update instance deployment artifact timeOut. Error : " + status);
+ }
+
+ protected StorageOperationStatus updateDeploymentArtifactTimeOut() {
+ Map<GraphPropertyEnum, Object> propertiesToMatch = new EnumMap<>(GraphPropertyEnum.class);
+ propertiesToMatch.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.SERVICE.name());
+ Map<GraphPropertyEnum, Object> propertiesNotToMatch = new EnumMap<>(GraphPropertyEnum.class);
+ propertiesNotToMatch.put(GraphPropertyEnum.IS_DELETED, true);
+ Either<List<GraphVertex>, JanusGraphOperationStatus> byCriteria = janusGraphDao.getByCriteria(VertexTypeEnum.TOPOLOGY_TEMPLATE, propertiesToMatch, propertiesNotToMatch, JsonParseFlagEnum.ParseAll);
+ return byCriteria.either(this::proceed, this::handleError);
+ }
+
+ @Override
+ protected StorageOperationStatus handleOneContainer(GraphVertex containerVorig) {
+ StorageOperationStatus status = StorageOperationStatus.NOT_FOUND;
+ GraphVertex containerV = getVertexById(containerVorig.getUniqueId());
+ try {
+ Either<GraphVertex, JanusGraphOperationStatus> childVertex = janusGraphDao.getChildVertex(containerV, EdgeLabelEnum.INST_DEPLOYMENT_ARTIFACTS, JsonParseFlagEnum.ParseAll);
+ GraphVertex instDeployArt = childVertex.left().value();
+ Collection<MapArtifactDataDefinition> values = (Collection<MapArtifactDataDefinition>) instDeployArt.getJson().values();
+ List<ArtifactDataDefinition> artifactDataDefinitionsList = values.stream().map(f -> f.getMapToscaDataDefinition().values()).flatMap(f -> f.stream().filter(isRelevantArtifact())).collect(Collectors.toList());
+ artifactDataDefinitionsList.forEach(t -> t.setTimeout(defaultTimeOut));
+ status = updateVertexAndCommit(instDeployArt);
+
+ } catch (NullPointerException e) {
+ log.error("Null Pointer Exception occurred - this mean we have zombie vertex, migration task will continue anyway", e);
+ status = StorageOperationStatus.OK;
+ }
+ catch (Exception e) {
+ //it is happy flow as well
+ log.error("Exception occurred:", e);
+ log.error("Migration task will continue anyway, please find below vertex details related to this exception", e);
+ if (containerV != null){
+ log.error("containerV.getUniqueId() {} ---> ", containerV.getUniqueId());
+ }
+
+ status = StorageOperationStatus.OK;
+ } finally {
+ if (status != StorageOperationStatus.OK) {
+ janusGraphDao.rollback();
+ log.info("failed to update vertex ID {} ", containerV.getUniqueId());
+ if (status == StorageOperationStatus.NOT_FOUND) {
+ //it is happy flow as well
+ status = StorageOperationStatus.OK;
+ }
+ }
+ else{
+ log.info("vertex ID {} successfully updated", containerV.getUniqueId());
+ }
+
+ }
+ return status;
+ }
+
+ private static Predicate<ArtifactDataDefinition> isRelevantArtifact() {
+
+ return p -> ((p.getArtifactType().equals(ArtifactTypeEnum.HEAT.getType()) || p.getArtifactType().equals(ArtifactTypeEnum.HEAT_VOL.getType()) || p.getArtifactType().equals(ArtifactTypeEnum.HEAT_NET.getType()))
+ && p.getTimeout() != defaultTimeOut);
+
+ }
+
+}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig2002/SdcCollapsingRolesCERTIFIEDstateMigration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig2002/SdcCollapsingRolesCERTIFIEDstateMigration.java
new file mode 100644
index 0000000000..1d7d3d1298
--- /dev/null
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig2002/SdcCollapsingRolesCERTIFIEDstateMigration.java
@@ -0,0 +1,139 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2020 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=========================================================
+ */
+
+package org.openecomp.sdc.asdctool.migration.tasks.mig2002;
+
+import fj.data.Either;
+import org.apache.tinkerpop.gremlin.structure.Direction;
+import org.openecomp.sdc.asdctool.enums.DistributionStatusEnum;
+import org.openecomp.sdc.asdctool.enums.LifecycleStateEnum;
+import org.openecomp.sdc.asdctool.migration.core.DBVersion;
+import org.openecomp.sdc.asdctool.migration.core.task.Migration;
+import org.openecomp.sdc.asdctool.migration.core.task.MigrationResult;
+import org.openecomp.sdc.asdctool.migration.tasks.InstanceMigrationBase;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
+import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
+import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
+import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
+import org.openecomp.sdc.be.dao.jsongraph.types.EdgePropertyEnum;
+import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
+import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
+import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+import java.math.BigInteger;
+import java.util.EnumMap;
+import java.util.List;
+import java.util.Map;
+
+@Component
+public class SdcCollapsingRolesCERTIFIEDstateMigration extends InstanceMigrationBase implements Migration {
+
+ private static final Logger log = LoggerFactory.getLogger(SdcCollapsingRolesCERTIFIEDstateMigration.class);
+
+ public SdcCollapsingRolesCERTIFIEDstateMigration(JanusGraphDao janusGraphDao) {
+ super(janusGraphDao);
+ }
+
+ @Override
+ public String description() {
+ return "remove LS=READY_FOR_CERTIFICATION edge from service node + migrate DISTRIBUTION approved/rejected states to <waiting for distribution> state";
+ }
+
+ @Override
+ public DBVersion getVersion() {
+ return DBVersion.from(BigInteger.valueOf(2002), BigInteger.valueOf(0));
+ }
+
+ @Override
+ public MigrationResult migrate() {
+ StorageOperationStatus status = updateServiceLifeCycleState();
+ return status == StorageOperationStatus.OK ?
+ MigrationResult.success() : MigrationResult.error("failed to service state. Error : " + status);
+ }
+
+ protected StorageOperationStatus updateServiceLifeCycleState() {
+ Map<GraphPropertyEnum, Object> propertiesToMatch = new EnumMap<>(GraphPropertyEnum.class);
+ propertiesToMatch.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.SERVICE.name());
+ propertiesToMatch.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name());
+ Map<GraphPropertyEnum, Object> propertiesNotToMatch = new EnumMap<>(GraphPropertyEnum.class);
+ propertiesNotToMatch.put(GraphPropertyEnum.IS_DELETED, true);
+ Either<List<GraphVertex>, JanusGraphOperationStatus> byCriteria = janusGraphDao.getByCriteria(VertexTypeEnum.TOPOLOGY_TEMPLATE, propertiesToMatch, propertiesNotToMatch, JsonParseFlagEnum.ParseAll);
+ return byCriteria.either(this::proceed, this::handleError);
+ }
+
+ @Override
+ protected StorageOperationStatus handleOneContainer(GraphVertex containerVorig) {
+ StorageOperationStatus status = StorageOperationStatus.NOT_FOUND;
+ GraphVertex containerV = getVertexById(containerVorig.getUniqueId());
+ try {
+
+ //update edges to meet above change
+ // update LS eges from RFC to NOT_CERTIFIED_CHECKIN
+
+ updateEdgeProperty(EdgePropertyEnum.STATE, LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.name(), getVertexEdge(containerV, Direction.IN, EdgeLabelEnum.LAST_STATE));
+
+ if (containerV.getMetadataProperty(GraphPropertyEnum.DISTRIBUTION_STATUS).equals(DistributionStatusEnum.DISTRIBUTION_APPROVED.name()) || containerV.getMetadataProperty(GraphPropertyEnum.DISTRIBUTION_STATUS).equals(DistributionStatusEnum.DISTRIBUTION_REJECTED.name())) {
+
+ // update vertex state property from DISTRIBUTION_APPROVED/REJECTED to DISTRIBUTION_NOT_APPROVED state
+
+ Map<GraphPropertyEnum, Object> metadataProperties = containerV.getMetadataProperties();
+ metadataProperties.put(GraphPropertyEnum.DISTRIBUTION_STATUS, DistributionStatusEnum.DISTRIBUTION_NOT_APPROVED.name());
+ containerV.setMetadataProperties(metadataProperties);
+
+ //update edges to meet above change
+ //delete LAST_DISTRIBUTION_STATE_MODIFIER edge
+
+ removeEdges(getVertexEdge(containerV, Direction.IN, EdgeLabelEnum.LAST_DISTRIBUTION_STATE_MODIFIER));
+
+ }
+
+ status = updateVertexAndCommit(containerV);
+
+ } catch (NullPointerException e) {
+ log.error("Null Pointer Exception occurred - this mean we have zombie vertex, migration task will continue anyway", e);
+ status = StorageOperationStatus.EXEUCTION_FAILED;
+ } catch (Exception e) {
+ //it is happy flow as well
+ log.error("Exception occurred:", e);
+ log.error("Migration task will continue anyway, please find below vertex details related to this exception", e);
+ if (containerV != null) {
+ log.error("containerV.getUniqueId() ---> {} ", containerV.getUniqueId());
+ }
+
+ } finally {
+ if (status != StorageOperationStatus.OK) {
+ janusGraphDao.rollback();
+ log.info("failed to update vertex ID {} ", containerV.getUniqueId());
+ log.info("Storage Operation Status {}", status.toString());
+ } else {
+ log.info("vertex ID {} successfully updated", containerV.getUniqueId());
+ }
+
+ }
+ return status;
+ }
+
+
+}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig2002/SdcCollapsingRolesCIPstateMigration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig2002/SdcCollapsingRolesCIPstateMigration.java
new file mode 100644
index 0000000000..463ccd8695
--- /dev/null
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig2002/SdcCollapsingRolesCIPstateMigration.java
@@ -0,0 +1,153 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2020 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=========================================================
+ */
+
+package org.openecomp.sdc.asdctool.migration.tasks.mig2002;
+
+import fj.data.Either;
+import org.apache.tinkerpop.gremlin.structure.Direction;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.openecomp.sdc.asdctool.enums.LifecycleStateEnum;
+import org.openecomp.sdc.asdctool.migration.core.DBVersion;
+import org.openecomp.sdc.asdctool.migration.core.task.Migration;
+import org.openecomp.sdc.asdctool.migration.core.task.MigrationResult;
+import org.openecomp.sdc.asdctool.migration.tasks.InstanceMigrationBase;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
+import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
+import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
+import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
+import org.openecomp.sdc.be.dao.jsongraph.types.EdgePropertyEnum;
+import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
+import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
+import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+import java.math.BigInteger;
+import java.util.EnumMap;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+@Component
+public class SdcCollapsingRolesCIPstateMigration extends InstanceMigrationBase implements Migration {
+
+ private static final Logger log = LoggerFactory.getLogger(SdcCollapsingRolesCIPstateMigration.class);
+
+ public SdcCollapsingRolesCIPstateMigration(JanusGraphDao janusGraphDao) {
+ super(janusGraphDao);
+ }
+
+ @Override
+ public String description() {
+ return "update Service state from CERTIFICATION_IN_PROGRES to NOT_CERTIFIED_CHECKOUT state ";
+ }
+
+ @Override
+ public DBVersion getVersion() {
+ return DBVersion.from(BigInteger.valueOf(2002), BigInteger.valueOf(0));
+ }
+
+ @Override
+ public MigrationResult migrate() {
+ StorageOperationStatus status = updateServiceLifeCycleState();
+ return status == StorageOperationStatus.OK ?
+ MigrationResult.success() : MigrationResult.error("failed to service state. Error : " + status);
+ }
+
+ protected StorageOperationStatus updateServiceLifeCycleState() {
+ Map<GraphPropertyEnum, Object> propertiesToMatch = new EnumMap<>(GraphPropertyEnum.class);
+ propertiesToMatch.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.SERVICE.name());
+ propertiesToMatch.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFICATION_IN_PROGRESS.name());
+ propertiesToMatch.put(GraphPropertyEnum.IS_HIGHEST_VERSION, true);
+ Map<GraphPropertyEnum, Object> propertiesNotToMatch = new EnumMap<>(GraphPropertyEnum.class);
+ propertiesNotToMatch.put(GraphPropertyEnum.IS_DELETED, true);
+ Either<List<GraphVertex>, JanusGraphOperationStatus> byCriteria = janusGraphDao.getByCriteria(VertexTypeEnum.TOPOLOGY_TEMPLATE, propertiesToMatch, propertiesNotToMatch, JsonParseFlagEnum.ParseAll);
+ return byCriteria.either(this::proceed, this::handleError);
+ }
+
+ @Override
+ protected StorageOperationStatus handleOneContainer(GraphVertex containerVorig) {
+ StorageOperationStatus status = StorageOperationStatus.NOT_FOUND;
+ GraphVertex containerV = getVertexById(containerVorig.getUniqueId());
+ try {
+
+ // update vertex state property from READY_FOR_CERTIFICATION to NOT_CERTIFIED_CHECKIN state
+
+ Map<GraphPropertyEnum, Object> metadataProperties = containerV.getMetadataProperties();
+ metadataProperties.put(GraphPropertyEnum.STATE, LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.name());
+ containerV.setMetadataProperties(metadataProperties);
+
+ //update edges to meet above change
+ // remove STATE and LAST_MODIFIER edges
+ removeEdges(getVertexEdge(containerV, Direction.IN, EdgeLabelEnum.STATE));
+ removeEdges(getVertexEdge(containerV, Direction.IN, EdgeLabelEnum.LAST_MODIFIER));
+
+ //find designer with LS = NOT_CERTIFIED_CHECKIN
+ Vertex relevantDesigner = findRelevantDesigner(getVertexEdge(containerV, Direction.IN, EdgeLabelEnum.LAST_STATE));
+ removeEdges(getVertexEdge(containerV, Direction.IN, EdgeLabelEnum.LAST_STATE));
+ Map<EdgePropertyEnum, Object> edgeProperties = new HashMap<>();
+ edgeProperties.put(EdgePropertyEnum.STATE, LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.name());
+ JanusGraphOperationStatus createSTedgeStatus = janusGraphDao.createEdge(relevantDesigner, containerV.getVertex(), EdgeLabelEnum.STATE, edgeProperties);
+ JanusGraphOperationStatus createLMedgeStatus = janusGraphDao.createEdge(relevantDesigner, containerV.getVertex(), EdgeLabelEnum.LAST_MODIFIER, new HashMap<>());
+
+ status = updateVertexAndCommit(containerV);
+
+ } catch (NullPointerException e) {
+ log.error("Null Pointer Exception occurred - this mean we have zombie vertex, migration task will continue anyway", e);
+ status = StorageOperationStatus.EXEUCTION_FAILED;
+ } catch (Exception e) {
+ //it is happy flow as well
+ log.error("Exception occurred:", e);
+ log.error("Migration task will continue anyway, please find below vertex details related to this exception", e);
+ if (containerV != null) {
+ log.error("containerV.getUniqueId() ---> {} ", containerV.getUniqueId());
+ }
+
+ } finally {
+ if (status != StorageOperationStatus.OK) {
+ janusGraphDao.rollback();
+ log.info("failed to update vertex ID {} ", containerV.getUniqueId());
+ log.info("Storage Operation Status {}", status.toString());
+ } else {
+ log.info("vertex ID {} successfully updated", containerV.getUniqueId());
+ }
+
+ }
+ return status;
+ }
+
+ private Vertex findRelevantDesigner(Iterator<Edge> edges) {
+ Vertex vertex = null;
+ while (edges.hasNext()) {
+ Edge edge = edges.next();
+ String state = (String) janusGraphDao.getProperty(edge, EdgePropertyEnum.STATE);
+ if (state.equals(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.name())) {
+ vertex = edge.outVertex();
+ }
+ }
+ return vertex;
+ }
+
+}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig2002/SdcCollapsingRolesRFCstateMigration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig2002/SdcCollapsingRolesRFCstateMigration.java
new file mode 100644
index 0000000000..559715ef5d
--- /dev/null
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig2002/SdcCollapsingRolesRFCstateMigration.java
@@ -0,0 +1,147 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2020 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=========================================================
+ */
+
+package org.openecomp.sdc.asdctool.migration.tasks.mig2002;
+
+import fj.data.Either;
+import org.apache.tinkerpop.gremlin.structure.Direction;
+import org.janusgraph.core.JanusGraphVertex;
+import org.openecomp.sdc.asdctool.enums.LifecycleStateEnum;
+import org.openecomp.sdc.asdctool.migration.core.DBVersion;
+import org.openecomp.sdc.asdctool.migration.core.task.Migration;
+import org.openecomp.sdc.asdctool.migration.core.task.MigrationResult;
+import org.openecomp.sdc.asdctool.migration.tasks.InstanceMigrationBase;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
+import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
+import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
+import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
+import org.openecomp.sdc.be.dao.jsongraph.types.EdgePropertyEnum;
+import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
+import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
+import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+import java.math.BigInteger;
+import java.util.EnumMap;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Component
+public class SdcCollapsingRolesRFCstateMigration extends InstanceMigrationBase implements Migration {
+
+ private static final Logger log = LoggerFactory.getLogger(SdcCollapsingRolesRFCstateMigration.class);
+
+ public SdcCollapsingRolesRFCstateMigration(JanusGraphDao janusGraphDao) {
+ super(janusGraphDao);
+ }
+
+ @Override
+ public String description() {
+ return "update Service state from READY_FOR_CERTIFICATION to NOT_CERTIFIED_CHECKOUT state ";
+ }
+
+ @Override
+ public DBVersion getVersion() {
+ return DBVersion.from(BigInteger.valueOf(2002), BigInteger.valueOf(0));
+ }
+
+ @Override
+ public MigrationResult migrate() {
+ StorageOperationStatus status = updateServiceLifeCycleState();
+ return status == StorageOperationStatus.OK ?
+ MigrationResult.success() : MigrationResult.error("failed to service state. Error : " + status);
+ }
+
+ protected StorageOperationStatus updateServiceLifeCycleState() {
+ Map<GraphPropertyEnum, Object> propertiesToMatch = new EnumMap<>(GraphPropertyEnum.class);
+ propertiesToMatch.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.SERVICE.name());
+ propertiesToMatch.put(GraphPropertyEnum.STATE, LifecycleStateEnum.READY_FOR_CERTIFICATION.name());
+ propertiesToMatch.put(GraphPropertyEnum.IS_HIGHEST_VERSION, true);
+ Map<GraphPropertyEnum, Object> propertiesNotToMatch = new EnumMap<>(GraphPropertyEnum.class);
+ propertiesNotToMatch.put(GraphPropertyEnum.IS_DELETED, true);
+ Either<List<GraphVertex>, JanusGraphOperationStatus> byCriteria = janusGraphDao.getByCriteria(VertexTypeEnum.TOPOLOGY_TEMPLATE, propertiesToMatch, propertiesNotToMatch, JsonParseFlagEnum.ParseAll);
+ return byCriteria.either(this::proceed, this::handleError);
+ }
+
+ @Override
+ protected StorageOperationStatus handleOneContainer(GraphVertex containerVorig) {
+ StorageOperationStatus status = StorageOperationStatus.NOT_FOUND;
+ GraphVertex containerV = getVertexById(containerVorig.getUniqueId());
+ try {
+
+ // update vertex state property from READY_FOR_CERTIFICATION to NOT_CERTIFIED_CHECKIN state
+
+ Map<GraphPropertyEnum, Object> metadataProperties = containerV.getMetadataProperties();
+ metadataProperties.put(GraphPropertyEnum.STATE, LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.name());
+ containerV.setMetadataProperties(metadataProperties);
+
+ //update edges to meet above change
+
+ List<JanusGraphVertex> stateEdgesOutVertexList = getVertexByEdgeSide(getVertexEdge(containerV, Direction.IN, EdgeLabelEnum.STATE), EdgeSide.OUT);
+ List<JanusGraphVertex> lastStateEdgesOutVertexList = getVertexByEdgeSide(getVertexEdge(containerV, Direction.IN, EdgeLabelEnum.LAST_STATE), EdgeSide.OUT);
+
+ if (sameUser(stateEdgesOutVertexList, lastStateEdgesOutVertexList)) {
+ updateEdgeProperty(EdgePropertyEnum.STATE, LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.name(), getVertexEdge(containerV, Direction.IN, EdgeLabelEnum.STATE));
+ removeEdges(getVertexEdge(containerV, Direction.IN, EdgeLabelEnum.LAST_STATE));
+ } else {
+ removeEdges(getVertexEdge(containerV, Direction.IN, EdgeLabelEnum.STATE));
+ removeEdges(getVertexEdge(containerV, Direction.IN, EdgeLabelEnum.LAST_STATE));
+ Map<EdgePropertyEnum, Object> edgeProperties = new HashMap<>();
+ edgeProperties.put(EdgePropertyEnum.STATE, LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.name());
+ janusGraphDao.createEdge(lastStateEdgesOutVertexList.get(0), containerV.getVertex(), EdgeLabelEnum.STATE, edgeProperties);
+
+ }
+
+ status = updateVertexAndCommit(containerV);
+
+ } catch (NullPointerException e) {
+ log.error("Null Pointer Exception occurred - this mean we have zombie vertex, migration task will continue anyway", e);
+ status = StorageOperationStatus.EXEUCTION_FAILED;
+ } catch (Exception e) {
+ //it is happy flow as well
+ log.error("Exception occurred:", e);
+ log.error("Migration task will ?" +
+ "" +
+ "" +
+ ", please find below vertex details related to this exception", e);
+ if (containerV != null) {
+ log.error("containerV.getUniqueId() ---> {} ", containerV.getUniqueId());
+ }
+
+ } finally {
+ if (status != StorageOperationStatus.OK) {
+ janusGraphDao.rollback();
+ log.info("failed to update vertex ID {} ", containerV.getUniqueId());
+ log.info("Storage Operation Status {}", status.toString());
+ } else {
+ log.info("vertex ID {} successfully updated", containerV.getUniqueId());
+ }
+
+ }
+ return status;
+ }
+
+
+}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/servlets/ExportImportJanusGraphServlet.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/servlets/ExportImportJanusGraphServlet.java
index e7d39ffb3e..412926fa6c 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/servlets/ExportImportJanusGraphServlet.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/servlets/ExportImportJanusGraphServlet.java
@@ -20,11 +20,11 @@
package org.openecomp.sdc.asdctool.servlets;
-import org.janusgraph.core.JanusGraph;
import org.apache.commons.configuration.BaseConfiguration;
import org.apache.commons.configuration.Configuration;
import org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLWriter;
import org.glassfish.jersey.media.multipart.FormDataParam;
+import org.janusgraph.core.JanusGraph;
import org.openecomp.sdc.asdctool.Utils;
import org.openecomp.sdc.common.log.wrappers.Logger;
@@ -34,7 +34,13 @@ import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import java.io.*;
+import java.io.BufferedOutputStream;
+import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.OutputStream;
import java.util.Map.Entry;
import java.util.Properties;
//import com.tinkerpop.blueprints.util.io.graphml.GraphMLWriter;
@@ -146,7 +152,7 @@ public class ExportImportJanusGraphServlet {
result = outputFile;
} catch (Exception e) {
- log.info("export Graph failed - {}" , e);
+ e.printStackTrace();
// graph.rollback();
graph.tx().rollback();
} finally {
@@ -155,7 +161,7 @@ public class ExportImportJanusGraphServlet {
out.close();
}
} catch (IOException e) {
- log.info("close FileOutputStream failed - {}" , e);
+ e.printStackTrace();
}
}
return result;