summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-migration-lib
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-migration-lib')
-rw-r--r--openecomp-be/lib/openecomp-migration-lib/pom.xml192
-rw-r--r--openecomp-be/lib/openecomp-migration-lib/pom.xml.versionsBackup151
-rw-r--r--openecomp-be/lib/openecomp-migration-lib/src/main/assembly/migration-lib-assembly.xml26
-rw-r--r--openecomp-be/lib/openecomp-migration-lib/src/main/java/org/openecomp/sdc/migration/TestScript.java11
-rw-r--r--openecomp-be/lib/openecomp-migration-lib/src/main/java/org/openecomp/sdc/migration/ToscaNamespaceMigration.java247
-rw-r--r--openecomp-be/lib/openecomp-migration-lib/src/main/resources/logback.xml280
-rw-r--r--openecomp-be/lib/openecomp-migration-lib/src/main/resources/openecomp-migration-lib.zipbin0 -> 36737135 bytes
7 files changed, 907 insertions, 0 deletions
diff --git a/openecomp-be/lib/openecomp-migration-lib/pom.xml b/openecomp-be/lib/openecomp-migration-lib/pom.xml
new file mode 100644
index 0000000000..01603fc5e7
--- /dev/null
+++ b/openecomp-be/lib/openecomp-migration-lib/pom.xml
@@ -0,0 +1,192 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>openecomp-migration-lib</artifactId>
+ <name>openecomp-migration-lib</name>
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-lib</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+
+ <properties>
+ <groovy.version>2.4.7</groovy.version>
+ <janino.version>2.7.7</janino.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-vendor-software-product-manager</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy</artifactId>
+ <version>${groovy.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.sdc.common</groupId>
+ <artifactId>openecomp-configuration-management-core</artifactId>
+ <version>${openecomp.sdc.common.version}</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.janino</groupId>
+ <artifactId>janino</artifactId>
+ <version>${janino.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.core</groupId>
+ <artifactId>openecomp-zusammen-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.janino</groupId>
+ <artifactId>commons-compiler</artifactId>
+ <version>3.0.6</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <phase>install</phase>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.build.directory}/lib</outputDirectory>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>false</overWriteSnapshots>
+ <overWriteIfNewer>true</overWriteIfNewer>
+ <!--includeScope>runtime</includeScope-->
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>${mvn.jar.version}</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ </execution>
+ </executions>
+ <configuration>
+ <archive>
+ <manifest>
+ <addClasspath>true</addClasspath>
+ <classpathLayoutType>custom</classpathLayoutType>
+ <customClasspathLayout>lib/${artifact.artifactId}-${baseVersion}.${artifact.extension}</customClasspathLayout>
+ <mainClass>org.openecomp.sdc.migration.ToscaNamespaceMigration</mainClass>
+ </manifest>
+ <manifestEntries>
+ <Class-Path>lib/</Class-Path>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.19.1</version>
+ <configuration>
+ <useSystemClassLoader>false</useSystemClassLoader>
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>com.google.code.maven-replacer-plugin</groupId>
+ <artifactId>maven-replacer-plugin</artifactId>
+ <version>1.3.5</version>
+ <executions>
+ <execution>
+ <id>replace-for-migration</id>
+ <phase>initialize</phase>
+ <goals>
+ <goal>replace</goal>
+ </goals>
+ <configuration>
+ <file>../../tools/migration/1702_to_1707.sh</file>
+ <preserveDir>false</preserveDir>
+ <outputDir>target</outputDir>
+ <replacements>
+ <replacement>
+ <token>1707.0.0-SNAPSHOT</token>
+ <value>${project.version}</value>
+ </replacement>
+ </replacements>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>ant-test</id>
+ <phase>package</phase>
+ <configuration>
+ <tasks>
+ <fixcrlf srcdir="target" eol="unix" includes="1702_to_1707.sh"/>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <!--<plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>${mvn.assembly.version}</version>
+ <executions>
+ <execution>
+ <id>Generate assembly</id>
+ <phase>install</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <descriptors>
+ <descriptor>${basedir}/src/main/assembly/migration-lib-assembly.xml</descriptor>
+ </descriptors>
+ <finalName>openecomp-migration-lib</finalName>
+ </configuration>
+ </plugin>-->
+
+ </plugins>
+ </build>
+</project>
diff --git a/openecomp-be/lib/openecomp-migration-lib/pom.xml.versionsBackup b/openecomp-be/lib/openecomp-migration-lib/pom.xml.versionsBackup
new file mode 100644
index 0000000000..bca0cd32a3
--- /dev/null
+++ b/openecomp-be/lib/openecomp-migration-lib/pom.xml.versionsBackup
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <properties>
+
+ <groovy.version>2.4.7</groovy.version>
+ <janino.version>2.7.7</janino.version>
+
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-vendor-software-product-manager</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy</artifactId>
+ <version>${groovy.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.sdc.common</groupId>
+ <artifactId>openecomp-configuration-management-core</artifactId>
+ <version>1707.0.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.janino</groupId>
+ <artifactId>janino</artifactId>
+ <version>${janino.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.janino</groupId>
+ <artifactId>commons-compiler</artifactId>
+ <version>3.0.6</version>
+ </dependency>
+
+ </dependencies>
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-lib</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+
+
+ <artifactId>openecomp-migration-lib</artifactId>
+ <name>openecomp-migration-lib</name>
+ <version>1.0-SNAPSHOT</version>
+
+ <build>
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <phase>install</phase>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.build.directory}/lib</outputDirectory>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>false</overWriteSnapshots>
+ <overWriteIfNewer>true</overWriteIfNewer>
+ <!--includeScope>runtime</includeScope-->
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ </execution>
+ </executions>
+ <configuration>
+ <archive>
+ <manifest>
+ <addClasspath>true</addClasspath>
+ <classpathPrefix>lib/</classpathPrefix>
+ <mainClass>org.openecomp.sdc.migration.ToscaNamespaceMigration</mainClass>
+ </manifest>
+ <manifestEntries>
+ <Class-Path>lib/</Class-Path>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>ant-test</id>
+ <phase>package</phase>
+ <configuration>
+ <tasks>
+ <fixcrlf srcdir="../../tools/migration/" eol="unix"
+ includes="1702_to_1707.sh"/>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>Generate assembly</id>
+ <phase>install</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <descriptors>
+ <descriptor>${basedir}/src/main/assembly/migration-lib-assembly.xml</descriptor>
+ </descriptors>
+ <finalName>openecomp-migration-lib</finalName>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+</project> \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-migration-lib/src/main/assembly/migration-lib-assembly.xml b/openecomp-be/lib/openecomp-migration-lib/src/main/assembly/migration-lib-assembly.xml
new file mode 100644
index 0000000000..3cb9fc07b4
--- /dev/null
+++ b/openecomp-be/lib/openecomp-migration-lib/src/main/assembly/migration-lib-assembly.xml
@@ -0,0 +1,26 @@
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
+ <formats>
+ <format>zip</format>
+ </formats>
+
+ <includeBaseDirectory>false</includeBaseDirectory>
+
+ <fileSets>
+ <fileSet>
+ <directory>${basedir}/target</directory>
+ <includes>
+ <include>openecomp-migration-lib*.jar</include>
+ <include>1702_to_1707.sh</include>
+ </includes>
+ <outputDirectory>/</outputDirectory>
+ <fileMode>0755</fileMode>
+ </fileSet>
+ <fileSet>
+ <directory>${basedir}/target/lib</directory>
+ <outputDirectory>/lib</outputDirectory>
+ </fileSet>
+ </fileSets>
+</assembly>
+
diff --git a/openecomp-be/lib/openecomp-migration-lib/src/main/java/org/openecomp/sdc/migration/TestScript.java b/openecomp-be/lib/openecomp-migration-lib/src/main/java/org/openecomp/sdc/migration/TestScript.java
new file mode 100644
index 0000000000..c6a23734e4
--- /dev/null
+++ b/openecomp-be/lib/openecomp-migration-lib/src/main/java/org/openecomp/sdc/migration/TestScript.java
@@ -0,0 +1,11 @@
+package org.openecomp.sdc.migration;
+
+/**
+ * Created by TALIO on 3/19/2017.
+ */
+public class TestScript {
+
+ public static void main(String[] args){
+ System.out.print("Test succeed!");
+ }
+}
diff --git a/openecomp-be/lib/openecomp-migration-lib/src/main/java/org/openecomp/sdc/migration/ToscaNamespaceMigration.java b/openecomp-be/lib/openecomp-migration-lib/src/main/java/org/openecomp/sdc/migration/ToscaNamespaceMigration.java
new file mode 100644
index 0000000000..82ba1396c7
--- /dev/null
+++ b/openecomp-be/lib/openecomp-migration-lib/src/main/java/org/openecomp/sdc/migration/ToscaNamespaceMigration.java
@@ -0,0 +1,247 @@
+package org.openecomp.sdc.migration;
+
+import org.apache.commons.io.IOUtils;
+import org.openecomp.core.model.dao.EnrichedServiceModelDao;
+import org.openecomp.core.model.dao.EnrichedServiceModelDaoFactory;
+import org.openecomp.core.model.dao.ServiceModelDao;
+import org.openecomp.core.model.dao.ServiceModelDaoFactory;
+import org.openecomp.core.model.types.ServiceElement;
+import org.openecomp.core.utilities.json.JsonUtil;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
+import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
+import org.openecomp.sdc.tosca.datatypes.model.Import;
+import org.openecomp.sdc.tosca.datatypes.model.Old1610ServiceTemplate;
+import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.openecomp.sdc.tosca.services.yamlutil.ToscaExtensionYamlUtil;
+import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManager;
+import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants;
+import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager;
+import org.openecomp.sdc.vendorsoftwareproduct.VspManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.core.zusammen.impl.CassandraConnectionInitializer;
+
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+import java.util.zip.ZipOutputStream;
+
+
+/**
+ * Created by TALIO on 3/19/2017
+ */
+public class ToscaNamespaceMigration {
+
+ private static VendorSoftwareProductManager vendorSoftwareProductManager =
+ VspManagerFactory.getInstance().createInterface();
+ private static OrchestrationTemplateCandidateManager orchestrationTemplateCandidateManager =
+ OrchestrationTemplateCandidateManagerFactory.getInstance().createInterface();
+ private static VendorSoftwareProductDao vendorSoftwareProductDao =
+ VendorSoftwareProductDaoFactory.getInstance().createInterface();
+ private static ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDao =
+ ServiceModelDaoFactory.getInstance().createInterface();
+ private static EnrichedServiceModelDao<ToscaServiceModel, ServiceElement>
+ enrichedServiceModelDao =
+ EnrichedServiceModelDaoFactory.getInstance().createInterface();
+ private static VendorSoftwareProductInfoDao vspInfoDao =
+ VendorSoftwareProductInfoDaoFactory.getInstance().createInterface();
+ private static PackageInfoDao packageInfoDao = PackageInfoDaoFactory.getInstance()
+ .createInterface();
+ private static Logger logger = LoggerFactory.getLogger(ToscaNamespaceMigration.class);
+ private static int status = 0;
+
+
+ public static void main(String[] args) {
+ CassandraConnectionInitializer.setCassandraConnectionPropertiesToSystem();
+
+ Collection<VspDetails> vspList = vspInfoDao.list(new VspDetails());
+
+ List<PackageInfo> packagesList =
+ packageInfoDao.listByCategory(null, null);
+
+ for (VspDetails vspInfo : vspList) {
+ printMessage("Performing migration on vsp " + vspInfo.getName() + " and version " + vspInfo
+ .getVersion().toString() + "\n");
+ performMigration(vspInfo);
+ }
+
+ System.exit(status);
+ }
+
+ private static void performMigration(VspDetails vspDetails) {
+ try {
+ changeNamespaceInServiceTemplates(vspDetails);
+ } catch (Exception e) {
+ printMessage(
+ "Could not perform migration for service templates on vsp " + vspDetails.getName());
+ status = -1;
+ }
+
+ if (vspDetails.getVersion().isFinal()) {
+ changeNamespaceInPackage(vspDetails);
+ }
+ }
+
+ private static void changeNamespaceInServiceTemplates(VspDetails vspDetails) throws IOException {
+ String vspId = vspDetails.getId();
+ Version version = vspDetails.getVersion();
+ ToscaServiceModel serviceModel;
+ ToscaServiceModel enrichedServiceModel;
+
+ serviceModel =
+ serviceModelDao.getServiceModel(vspId, version);
+ enrichedServiceModel =
+ enrichedServiceModelDao.getServiceModel(vspId, version);
+
+ printMessage("Working on vsp_service_template table in DB \n");
+ changeNamespaceInServiceModel(serviceModel);
+ printMessage("Finished Working on vsp_service_template table in DB \n");
+
+ printMessage("Working on vsp_enriched_service_template table in DB \n");
+ changeNamespaceInServiceModel(enrichedServiceModel);
+ printMessage("Finished Working on vsp_enriched_service_template table in DB \n");
+
+ serviceModelDao.storeServiceModel(vspId, version, serviceModel);
+ enrichedServiceModelDao.storeServiceModel(vspId, version, enrichedServiceModel);
+ }
+
+ private static void changeNamespaceInServiceModel(ToscaServiceModel serviceModel) {
+ Map<String, ServiceTemplate> changedServiceTemplates = new HashMap<>();
+ Map<String, ServiceTemplate> serviceTemplates = serviceModel.getServiceTemplates();
+
+ for (Map.Entry<String, ServiceTemplate> serviceTemplateEntry : serviceTemplates.entrySet()) {
+ printMessage(
+ "Changing namespace for Service Template " + serviceTemplateEntry.getKey() + "\n");
+
+ ServiceTemplate serviceTemplate = serviceTemplateEntry.getValue();
+ String fileAsJson = JsonUtil.object2Json(serviceTemplate);
+ String replacedNamespace = fileAsJson.replace("org.openecomp.d2", "org.openecomp");
+ ServiceTemplate newServiceTemplate;
+ try {
+ newServiceTemplate =
+ new ToscaExtensionYamlUtil().yamlToObject(replacedNamespace, ServiceTemplate.class);
+ } catch (Exception e) {
+ System.out.println("Found vsp with old-versioned tosca service template");
+ Old1610ServiceTemplate oldServiceTemplate =
+ JsonUtil.json2Object(replacedNamespace, Old1610ServiceTemplate.class);
+ newServiceTemplate = mapOldSTToCurrentST(oldServiceTemplate);
+
+ }
+ changedServiceTemplates.put(
+ serviceTemplateEntry.getKey(), newServiceTemplate);
+ }
+
+ serviceModel.setServiceTemplates(changedServiceTemplates);
+ }
+
+ private static org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate mapOldSTToCurrentST(
+ Old1610ServiceTemplate oldServiceTemplate) {
+ org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate
+ serviceTemplate = new org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate();
+
+ serviceTemplate.setArtifact_types(oldServiceTemplate.getArtifact_types());
+ serviceTemplate.setCapability_types(oldServiceTemplate.getCapability_types());
+ serviceTemplate.setData_types(oldServiceTemplate.getData_types());
+ serviceTemplate.setDescription(oldServiceTemplate.getDescription());
+ serviceTemplate.setGroup_types(oldServiceTemplate.getGroup_types());
+ serviceTemplate.setInterface_types(oldServiceTemplate.getInterface_types());
+ serviceTemplate.setMetadata(oldServiceTemplate.getMetadata());
+ serviceTemplate.setNode_types(oldServiceTemplate.getNode_types());
+ serviceTemplate.setPolicy_types(oldServiceTemplate.getPolicy_types());
+ serviceTemplate.setRelationship_types(oldServiceTemplate.getRelationship_types());
+ serviceTemplate.setTopology_template(oldServiceTemplate.getTopology_template());
+
+ List<Map<String, Import>> imports = new ArrayList<>();
+ for (Map.Entry<String, Import> importEntry : oldServiceTemplate.getImports().entrySet()) {
+ Map<String, Import> importMap = new HashMap<>();
+ importMap.put(importEntry.getKey(), importEntry.getValue());
+ imports.add(importMap);
+ }
+ serviceTemplate.setImports(imports);
+
+ return serviceTemplate;
+
+ }
+
+ private static void changeNamespaceInPackage(VspDetails vspDetails) {
+ String vspId = vspDetails.getId();
+ printMessage("Start updating CSAR file with new namespace in DB \n");
+
+ File translatedFile;
+ try {
+ translatedFile =
+ getTranslatedFile(vspId, vspDetails.getVersion());
+ } catch (Exception e) {
+ printMessage("No translated file was found under vsp " + vspDetails.getName() + "\n");
+ return;
+ }
+ try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ZipOutputStream zos = new ZipOutputStream(baos);
+ ZipFile zipFile = new ZipFile(translatedFile)) {
+ Enumeration<? extends ZipEntry> entries = zipFile.entries();
+
+ while (entries.hasMoreElements()) {
+ ZipEntry ze = entries.nextElement();
+ InputStream zipEntryIs = zipFile.getInputStream(ze);
+ byte[] contentAsByte = IOUtils.toByteArray(zipEntryIs);
+ String fileContent = new String(contentAsByte);
+
+ String replacedNamespace = fileContent.replace("org.openecomp.d2", "org.openecomp");
+
+ zos.putNextEntry(new ZipEntry(ze.getName()));
+ zos.write(replacedNamespace.getBytes());
+ }
+ printMessage("Changed Tosca namesapce in package for vsp " + vspDetails.getName() + "\n");
+
+
+ packageInfoDao.updateTranslatedContent(
+ vspId, vspDetails.getVersion(), ByteBuffer.wrap(baos.toByteArray()));
+ printMessage("Updated CSAR file with new namespace in DB \n");
+
+ } catch (Exception e) {
+ printMessage("Could not perform migration on csar");
+ }
+ }
+
+ private static void printMessage(String message) {
+ System.out.print(message);
+ logger.debug(message);
+ }
+
+ private static File getTranslatedFile(String vspId, Version version)
+ throws IOException {
+ PackageInfo packageInfo =
+ packageInfoDao.get(new PackageInfo(vspId, version));
+ ByteBuffer translatedFileBuffer = packageInfo == null ? null : packageInfo.getTranslatedFile();
+
+ File translatedFile = new File(VendorSoftwareProductConstants.VSP_PACKAGE_ZIP);
+
+ FileOutputStream fos = new FileOutputStream(translatedFile);
+ fos.write(translatedFileBuffer.array());
+ fos.close();
+
+
+ return translatedFile;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-migration-lib/src/main/resources/logback.xml b/openecomp-be/lib/openecomp-migration-lib/src/main/resources/logback.xml
new file mode 100644
index 0000000000..5596881329
--- /dev/null
+++ b/openecomp-be/lib/openecomp-migration-lib/src/main/resources/logback.xml
@@ -0,0 +1,280 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration scan="true" scanPeriod="5 seconds">
+
+ <property scope="system" name="OPENECOMP-component-name" value="ASDC" />
+ <property scope="system" name="OPENECOMP-subcomponent-name" value="ASDC-BE" />
+ <property file="${config.home}/catalog-be/configuration.yaml" />
+ <property scope="context" name="enable-all-log" value="false" />
+
+ <!--statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
+ <include resource="asdc_debug_logback.xml"/-->
+
+ <!-- value used by pattern field list (| - is inter-field separator, || - unavailable or not applicable field value) (m - mandatory, o- optional)-->
+ <!--timestamp(m)| requestID(m)| serviceInstanceID(o)| threadID(m)| physicalServerName(o)| serviceName(m)| userID(m)| logLevel(m)| severity(o)| serverIpAddress(m)| serverName(m)| clientIpAddress(o)| className(m)| timer(o)| detailedMessage(o)-->
+ <property name="default-log-pattern"
+ value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{uuid}|%X{serviceInstanceID}|%thread||${OPENECOMP-subcomponent-name}|%X{userId}|%level|%X{alarmSeverity}|%X{localAddr}|${beFqdn}|%X{remoteAddr}|%logger{35}|%X{timer}|ActivityType=&lt;%M&gt;, Desc=&lt;%msg&gt;%n" />
+
+ <property name="asdc-debug-log-pattern" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{RequestId}|%msg %n"/>
+
+ <!-- All log -->
+ <if condition='property("enable-all-log").equalsIgnoreCase("true")'>
+ <then>
+ <appender name="ALL_ROLLING"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${log.home}/${OPENECOMP-component-name}/${OPENECOMP-subcomponent-name}/all.log
+ </file>
+
+ <rollingPolicy
+ class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+ <fileNamePattern>${log.home}/${OPENECOMP-component-name}/${OPENECOMP-subcomponent-name}/all.log.%i
+ </fileNamePattern>
+ <minIndex>1</minIndex>
+ <maxIndex>10</maxIndex>
+ </rollingPolicy>
+
+ <triggeringPolicy
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ <maxFileSize>20MB</maxFileSize>
+ </triggeringPolicy>
+ <encoder>
+ <pattern>${default-log-pattern}</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="ASYNC_ALL" class="ch.qos.logback.classic.AsyncAppender">
+ <appender-ref ref="ALL_ROLLING" />
+ </appender>
+ </then>
+ </if>
+
+ <!-- Error log -->
+ <appender name="ERROR_ROLLING"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${log.home}/${OPENECOMP-component-name}/${OPENECOMP-subcomponent-name}/Error.log
+ </file>
+
+ <!-- Audit messages filter - deny audit messages -->
+ <filter class="ch.qos.logback.core.filter.EvaluatorFilter">
+ <evaluator class="ch.qos.logback.classic.boolex.OnMarkerEvaluator">
+ <marker>AUDIT_MARKER</marker>
+ </evaluator>
+ <onMismatch>NEUTRAL</onMismatch>
+ <onMatch>DENY</onMatch>
+ </filter>
+
+ <!-- Transaction messages filter - deny Transaction messages -->
+ <filter class="ch.qos.logback.core.filter.EvaluatorFilter">
+ <evaluator class="ch.qos.logback.classic.boolex.OnMarkerEvaluator">
+ <marker>TRANSACTION_MARKER</marker>
+ </evaluator>
+ <onMismatch>NEUTRAL</onMismatch>
+ <onMatch>DENY</onMatch>
+ </filter>
+
+ <!-- deny all events with a level below INFO, that is TRACE and DEBUG -->
+ <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+ <level>INFO</level>
+ </filter>
+
+ <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+ <fileNamePattern>${log.home}/${OPENECOMP-component-name}/${OPENECOMP-subcomponent-name}/Error.log.%i
+ </fileNamePattern>
+ <minIndex>1</minIndex>
+ <maxIndex>10</maxIndex>
+ </rollingPolicy>
+
+ <triggeringPolicy
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ <maxFileSize>20MB</maxFileSize>
+ </triggeringPolicy>
+ <encoder>
+ <pattern>${default-log-pattern}</pattern>
+ </encoder>
+ </appender>
+
+ <!-- Debug log -->
+ <appender name="DEBUG_ROLLING"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${log.home}/${OPENECOMP-component-name}/${OPENECOMP-subcomponent-name}/debug.log
+ </file>
+
+ <!-- No need to deny audit messages - they are INFO only, will be denied
+ anyway -->
+ <!-- Transaction messages filter - deny Transaction messages, there are
+ some DEBUG level messages among them -->
+ <filter class="ch.qos.logback.core.filter.EvaluatorFilter">
+ <evaluator class="ch.qos.logback.classic.boolex.OnMarkerEvaluator">
+ <marker>TRANSACTION_MARKER</marker>
+ </evaluator>
+ <onMismatch>NEUTRAL</onMismatch>
+ <onMatch>DENY</onMatch>
+ </filter>
+
+ <!-- accept DEBUG and TRACE level -->
+ <filter class="ch.qos.logback.core.filter.EvaluatorFilter">
+ <evaluator class="ch.qos.logback.classic.boolex.GEventEvaluator">
+ <expression>
+ e.level.toInt() &lt;= DEBUG.toInt()
+ </expression>
+ </evaluator>
+ <OnMismatch>DENY</OnMismatch>
+ <OnMatch>NEUTRAL</OnMatch>
+ </filter>
+
+ <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+ <fileNamePattern>${log.home}/${OPENECOMP-component-name}/${OPENECOMP-subcomponent-name}/debug.log.%i
+ </fileNamePattern>
+ <minIndex>1</minIndex>
+ <maxIndex>10</maxIndex>
+ </rollingPolicy>
+
+ <triggeringPolicy
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ <maxFileSize>20MB</maxFileSize>
+ </triggeringPolicy>
+ <encoder>
+ <pattern>${default-log-pattern}</pattern>
+ </encoder>
+ </appender>
+
+ <!-- Debug log -->
+ <appender name="PACKAGE_DEBUG_ROLLING"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${log.home}/${OPENECOMP-component-name}/${OPENECOMP-subcomponent-name}/migration_debug.log
+ </file>
+
+ <!-- No need to deny audit messages - they are INFO only, will be denied
+ anyway -->
+ <!-- Transaction messages filter - deny Transaction messages, there are
+ some DEBUG level messages among them -->
+ <filter class="ch.qos.logback.core.filter.EvaluatorFilter">
+ <evaluator class="ch.qos.logback.classic.boolex.OnMarkerEvaluator">
+ <marker>TRANSACTION_MARKER</marker>
+ </evaluator>
+ <onMismatch>NEUTRAL</onMismatch>
+ <onMatch>DENY</onMatch>
+ </filter>
+
+ <!-- accept DEBUG and TRACE level -->
+ <filter class="ch.qos.logback.core.filter.EvaluatorFilter">
+ <evaluator class="ch.qos.logback.classic.boolex.GEventEvaluator">
+ <expression>
+ e.level.toInt() &lt;= DEBUG.toInt()
+ </expression>
+ </evaluator>
+ <OnMismatch>DENY</OnMismatch>
+ <OnMatch>NEUTRAL</OnMatch>
+ </filter>
+
+ <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+ <fileNamePattern>${log.home}/${OPENECOMP-component-name}/${OPENECOMP-subcomponent-name}/debug_by_package.log.%i
+ </fileNamePattern>
+ <minIndex>1</minIndex>
+ <maxIndex>10</maxIndex>
+ </rollingPolicy>
+
+ <triggeringPolicy
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ <maxFileSize>20MB</maxFileSize>
+ </triggeringPolicy>
+ <encoder>
+ <pattern>${asdc-debug-log-pattern}</pattern>
+ </encoder>
+ </appender>
+
+ <!-- Audit log -->
+ <appender name="AUDIT_ROLLING"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+
+ <file>${log.home}/${OPENECOMP-component-name}/${OPENECOMP-subcomponent-name}/audit.log
+ </file>
+
+ <!-- Audit messages filter - accept audit messages -->
+ <filter class="ch.qos.logback.core.filter.EvaluatorFilter">
+ <evaluator class="ch.qos.logback.classic.boolex.OnMarkerEvaluator">
+ <marker>AUDIT_MARKER</marker>
+ </evaluator>
+ <onMismatch>DENY</onMismatch>
+ <onMatch>ACCEPT</onMatch>
+ </filter>
+
+ <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+ <fileNamePattern>${log.home}/${OPENECOMP-component-name}/${OPENECOMP-subcomponent-name}/audit.log.%i
+ </fileNamePattern>
+ <minIndex>1</minIndex>
+ <maxIndex>10</maxIndex>
+ </rollingPolicy>
+
+ <triggeringPolicy
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ <maxFileSize>20MB</maxFileSize>
+ </triggeringPolicy>
+ <encoder>
+ <pattern>${default-log-pattern}</pattern>
+ </encoder>
+ </appender>
+
+ <!-- SdncTransaction log -->
+ <appender name="TRANSACTION_ROLLING"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+
+ <file>${log.home}/${OPENECOMP-component-name}/${OPENECOMP-subcomponent-name}/transaction.log
+ </file>
+
+ <!-- Transaction messages filter - accept audit messages -->
+ <filter class="ch.qos.logback.core.filter.EvaluatorFilter">
+ <evaluator class="ch.qos.logback.classic.boolex.OnMarkerEvaluator">
+ <marker>TRANSACTION_MARKER</marker>
+ </evaluator>
+ <onMismatch>DENY</onMismatch>
+ <onMatch>ACCEPT</onMatch>
+ </filter>
+
+ <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+ <fileNamePattern>${log.home}/${OPENECOMP-component-name}/${OPENECOMP-subcomponent-name}/transaction.log.%i
+ </fileNamePattern>
+ <minIndex>1</minIndex>
+ <maxIndex>10</maxIndex>
+ </rollingPolicy>
+
+ <triggeringPolicy
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ <maxFileSize>20MB</maxFileSize>
+ </triggeringPolicy>
+ <encoder>
+ <pattern>${default-log-pattern}</pattern>
+ </encoder>
+ </appender>
+
+ <!-- Asynchronicity Configurations -->
+ <appender name="ASYNC_DEBUG" class="ch.qos.logback.classic.AsyncAppender">
+ <appender-ref ref="DEBUG_ROLLING" />
+ </appender>
+
+ <appender name="ASYNC_TRANSACTION" class="ch.qos.logback.classic.AsyncAppender">
+ <appender-ref ref="TRANSACTION_ROLLING" />
+ </appender>
+
+ <appender name="ASYNC_ERROR" class="ch.qos.logback.classic.AsyncAppender">
+ <appender-ref ref="ERROR_ROLLING" />
+ </appender>
+
+
+ <root level="INFO">
+ <appender-ref ref="ASYNC_ERROR" />
+ <appender-ref ref="ASYNC_DEBUG" />
+ <appender-ref ref="AUDIT_ROLLING" />
+ <appender-ref ref="ASYNC_TRANSACTION" />
+ <if condition='property("enable-all-log").equalsIgnoreCase("true")'>
+ <then>
+ <appender-ref ref="ALL_ROLLING" />
+ </then>
+ </if>
+ </root>
+
+ <logger name="org.openecomp.sdc" level="INFO" />
+
+ <logger name="org.openecomp.sdc.migration" level="DEBUG" additivity ="false">
+ <appender-ref ref="PACKAGE_DEBUG_ROLLING" />
+ </logger>
+</configuration>
diff --git a/openecomp-be/lib/openecomp-migration-lib/src/main/resources/openecomp-migration-lib.zip b/openecomp-be/lib/openecomp-migration-lib/src/main/resources/openecomp-migration-lib.zip
new file mode 100644
index 0000000000..7f141387c9
--- /dev/null
+++ b/openecomp-be/lib/openecomp-migration-lib/src/main/resources/openecomp-migration-lib.zip
Binary files differ