aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/tools
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/tools')
-rw-r--r--openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/VspInformationConvertor.java37
-rw-r--r--openecomp-be/tools/zusammen-tools/pom.xml246
-rw-r--r--openecomp-be/tools/zusammen-tools/src/main/assembly/zusammen-tools-lib-assembly.xml39
-rw-r--r--openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/ResetOldVersion.java81
-rw-r--r--openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/loaders/VersionInfoCassandraLoader.java53
-rw-r--r--openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/loaders/zusammen/VspGeneralLoader.java40
-rw-r--r--openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/loaders/zusammen/VspItemLoader.java4
-rw-r--r--openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/main/ZusammenMainTool.java76
-rw-r--r--openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/ElementHandler.java26
-rw-r--r--openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/util/ToolsUtil.java14
-rw-r--r--openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/util/Utils.java15
-rw-r--r--openecomp-be/tools/zusammen-tools/src/main/resources/logback.xml282
-rw-r--r--openecomp-be/tools/zusammen-tools/src/main/resources/zusammenMainTool.sh16
13 files changed, 921 insertions, 8 deletions
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/VspInformationConvertor.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/VspInformationConvertor.java
index b7a1d42386..59fba5f066 100644
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/VspInformationConvertor.java
+++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/VspInformationConvertor.java
@@ -55,13 +55,21 @@ public class VspInformationConvertor {
public static CollaborationElement[] convertVspToElement(VspInformation vspInformation) {
- CollaborationElement[] vspElements = new CollaborationElement[4];
+ CollaborationElement[] vspElements;
+ if(vspInformation.getQuestionnaireData() == null){
+ vspElements = new CollaborationElement[4];
+ }else{
+ vspElements = new CollaborationElement[5];
+ }
+
+ int index=0;
+
List<String> vspNamespace = getVspNamespace(vspInformation);
String vspEntityId = StructureElement.General.name();
- vspElements[0] = ElementHandler.getElementEntity(
+ vspElements[index] = ElementHandler.getElementEntity(
vspInformation.getId(), vspInformation.getVersion().toString(),
vspEntityId,
vspNamespace,
@@ -70,8 +78,9 @@ public class VspInformationConvertor {
null,
null);
+ index++;
String vspOrchestrationTemplateEntityId = StructureElement.OrchestrationTemplate.name();
- vspElements[1] = ElementHandler.getElementEntity(
+ vspElements[index] = ElementHandler.getElementEntity(
vspInformation.getId(), vspInformation.getVersion().toString(),
vspOrchestrationTemplateEntityId,
vspNamespace,
@@ -80,11 +89,23 @@ public class VspInformationConvertor {
null,
null);
-
+ if(vspInformation.getQuestionnaireData()!= null) {
+ index++;
+ String vspQuestionnaireEntityId = StructureElement.Questionnaire.name();
+ vspElements[index] = ElementHandler.getElementEntity(
+ vspInformation.getId(), vspInformation.getVersion().toString(),
+ vspQuestionnaireEntityId,
+ vspNamespace,
+ ElementHandler.getStructuralElementInfo(vspQuestionnaireEntityId),
+ null,
+ null,
+ vspInformation.getQuestionnaireData().getBytes() != null ? vspInformation
+ .getQuestionnaireData().getBytes() : null);
+ }
vspNamespace.add(vspOrchestrationTemplateEntityId);
-
+ index++;
String vspOrchestrationTemplateValidationDataEntityId = StructureElement.OrchestrationTemplateValidationData.name();
- vspElements[2] = ElementHandler.getElementEntity(
+ vspElements[index] = ElementHandler.getElementEntity(
vspInformation.getId(), vspInformation.getVersion().toString(),
vspOrchestrationTemplateValidationDataEntityId,
vspNamespace,
@@ -93,9 +114,9 @@ public class VspInformationConvertor {
null,
vspInformation.getValidationData()!= null?vspInformation.getValidationData().getBytes()
:null);
-
+ index++;
String vspOrchestrationTemplateContentEntityId = StructureElement.OrchestrationTemplateContent.name();
- vspElements[3] = ElementHandler.getElementEntity(
+ vspElements[index] = ElementHandler.getElementEntity(
vspInformation.getId(), vspInformation.getVersion().toString(),
vspOrchestrationTemplateContentEntityId,
vspNamespace,
diff --git a/openecomp-be/tools/zusammen-tools/pom.xml b/openecomp-be/tools/zusammen-tools/pom.xml
new file mode 100644
index 0000000000..57f3250a5c
--- /dev/null
+++ b/openecomp-be/tools/zusammen-tools/pom.xml
@@ -0,0 +1,246 @@
+<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>
+
+
+
+ <name>openecomp-zusammen-tools</name>
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-vendor-software-product-api</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <artifactId>openecomp-zusammen-plugin</artifactId>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <version>1.1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-vendor-software-product-core</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-vendor-license-api</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-model-impl</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-zusammen-core</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>com.amdocs.zusammen.plugin</groupId>
+ <artifactId>zusammen-state-store-cassandra-plugin</artifactId>
+ <version>0.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-validator</artifactId>
+ <version>RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-vendor-license-core</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+ <artifactId>openecomp-zusammen-tools</artifactId>
+ <groupId>org.openecomp.sdc.core.tools</groupId>
+ <version>1.0-SNAPSHOT</version>
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-lib</artifactId>
+ <relativePath>../../lib</relativePath>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+ <!--parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent-->
+ <build>
+ <plugins>
+
+ <!-- ================================================== -->
+ <!-- Set the JDK compiler version. -->
+ <!-- ================================================== -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.5.1</version>
+ <inherited>true</inherited>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>license-maven-plugin</artifactId>
+ <version>1.10</version>
+ <configuration>
+ <addJavaLicenseAfterPackage>false</addJavaLicenseAfterPackage>
+ <processStartTag>
+ ============LICENSE_START=======================================================
+ </processStartTag>
+ <processEndTag>
+ ============LICENSE_END=========================================================
+ </processEndTag>
+ <sectionDelimiter>
+ ================================================================================
+ </sectionDelimiter>
+ <licenseName>apache_v2</licenseName>
+ <inceptionYear>2017</inceptionYear>
+ <organizationName>AT&amp;T Intellectual Property. All rights reserved.
+ </organizationName>
+ <projectName>SDC</projectName>
+ <canUpdateCopyright>true</canUpdateCopyright>
+ <canUpdateDescription>true</canUpdateDescription>
+ <canUpdateLicense>true</canUpdateLicense>
+ <emptyLineAfterHeader>true</emptyLineAfterHeader>
+ <verbose>false</verbose>
+ <includes>
+ <include>**/*.java</include>
+ <include>**/*.js</include>
+ <include>**/*.ts</include>
+ </includes>
+ <roots>
+ <root>src</root>
+ <root>app</root>
+ <root>server-mock</root>
+ <root>typings</root>
+ </roots>
+ </configuration>
+ <executions>
+ <execution>
+ <id>first</id>
+ <goals>
+ <goal>update-file-header</goal>
+ </goals>
+ <!--phase>process-sources</phase-->
+ </execution>
+ </executions>
+ </plugin>
+
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>2.8</version>
+ <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>2.4</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.core.tools.main.ZusammenMainTool
+ </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>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>ant-test</id>
+ <phase>package</phase>
+ <configuration>
+ <tasks>
+ <fixcrlf srcdir="./" eol="unix"
+ includes="zusammenMainTool.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/zusammen-tools-lib-assembly.xml
+ </descriptor>
+ </descriptors>
+ <appendAssemblyId>false</appendAssemblyId>
+ <finalName>openecomp-zusammen-tools-lib</finalName>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+
+</project> \ No newline at end of file
diff --git a/openecomp-be/tools/zusammen-tools/src/main/assembly/zusammen-tools-lib-assembly.xml b/openecomp-be/tools/zusammen-tools/src/main/assembly/zusammen-tools-lib-assembly.xml
new file mode 100644
index 0000000000..923115ee5d
--- /dev/null
+++ b/openecomp-be/tools/zusammen-tools/src/main/assembly/zusammen-tools-lib-assembly.xml
@@ -0,0 +1,39 @@
+<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">
+ <id>tools</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+
+ <includeBaseDirectory>false</includeBaseDirectory>
+
+ <files>
+ <file>
+ <source>src/main/resources/zusammenMainTool.sh</source>
+ </file>
+ </files>
+
+ <fileSets>
+ <fileSet>
+ <includes>
+ <include>zusammenMainTool.sh</include>
+ </includes>
+ <fileMode>0755</fileMode>
+ </fileSet>
+ <fileSet>
+ <directory>${basedir}/target</directory>
+ <includes>
+ <include>
+ openecomp-zusammen*.jar
+ </include>
+ </includes>
+ <outputDirectory>/</outputDirectory>
+ </fileSet>
+ <fileSet>
+ <directory>${basedir}/target/lib</directory>
+ <outputDirectory>/lib</outputDirectory>
+ </fileSet>
+ </fileSets>
+</assembly>
+
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/ResetOldVersion.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/ResetOldVersion.java
new file mode 100644
index 0000000000..185e80030f
--- /dev/null
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/ResetOldVersion.java
@@ -0,0 +1,81 @@
+package org.openecomp.core.tools.Commands;
+
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.plugin.statestore.cassandra.dao.impl.ItemCassandraDao;
+import com.amdocs.zusammen.plugin.statestore.cassandra.dao.impl.VersionCassandraDao;
+import org.openecomp.core.tools.loaders.VersionInfoCassandraLoader;
+import org.openecomp.core.tools.loaders.zusammen.VspGeneralLoader;
+import org.openecomp.core.tools.store.ElementHandler;
+import org.openecomp.core.zusammen.impl.CassandraConnectionInitializer;
+import org.openecomp.core.zusammen.plugin.dao.impl.CassandraElementRepository;
+import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants;
+import org.openecomp.sdc.versioning.dao.types.VersionInfoEntity;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class ResetOldVersion {
+
+
+ public static Map<String, List<String>> itemVersionMap = new HashMap<>();
+
+ public static void reset(SessionContext context, String oldVersion) {
+
+
+
+ CassandraConnectionInitializer.setCassandraConnectionPropertiesToSystem();
+
+ loadItemVersionInfo(context);
+
+ Map<String, ElementEntity> generalElementMap =
+ VspGeneralLoader.load(context,
+ itemVersionMap);
+
+ generalElementMap.values().forEach(elementEntity -> updateOldVersionFlag(elementEntity,oldVersion));
+
+
+ itemVersionMap.entrySet().forEach(entry->entry.getValue().stream().filter
+ (version->generalElementMap.containsKey(context.getUser().getUserName()+"_"+entry.getKey()
+ +"_"+version)).forEach(version->ElementHandler.update(context,
+ entry.getKey(),version,generalElementMap.get(context.getUser().getUserName()+"_"+entry.getKey()
+ +"_"+version))));
+ }
+
+ private static void updateOldVersionFlag(ElementEntity elementEntity, String oldVersion) {
+ elementEntity.getInfo().addProperty("oldVersion",oldVersion);
+ }
+
+
+ private static void loadItemVersionInfo(SessionContext context) {
+
+ List<String> items = new ArrayList<>();
+ System.setProperty("cassandra.dox.keystore", "dox");
+ VersionInfoCassandraLoader versionInfoCassandraLoader = new VersionInfoCassandraLoader();
+ Collection<VersionInfoEntity> versions =
+ versionInfoCassandraLoader.list();
+
+ versions.stream().filter(versionInfoEntity -> versionInfoEntity.getEntityType().equals
+ (VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE)).forEach
+ (versionInfoEntity
+ -> items.add(versionInfoEntity.getEntityId()));
+ System.setProperty("cassandra.dox.keystore", "zusammen_dox");
+ VersionCassandraDao versionCassandraDao = new VersionCassandraDao();
+
+ items
+ .forEach(itemId -> versionCassandraDao.list(context, context.getUser().getUserName(), new Id
+ (itemId)).forEach(itemVersion -> addItemVersion(itemId, itemVersion.getId())));
+
+ }
+
+ private static void addItemVersion(String itemId, Id versionId) {
+ if (!itemVersionMap.containsKey(itemId)) {
+ itemVersionMap.put(itemId, new ArrayList<>());
+ }
+ itemVersionMap.get(itemId).add(versionId.getValue());
+ }
+}
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/loaders/VersionInfoCassandraLoader.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/loaders/VersionInfoCassandraLoader.java
new file mode 100644
index 0000000000..8840975a56
--- /dev/null
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/loaders/VersionInfoCassandraLoader.java
@@ -0,0 +1,53 @@
+/*-
+ * ============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.core.tools.loaders;
+
+import com.datastax.driver.mapping.Mapper;
+import com.datastax.driver.mapping.Result;
+import com.datastax.driver.mapping.annotations.Accessor;
+import com.datastax.driver.mapping.annotations.Query;
+import org.openecomp.core.nosqldb.api.NoSqlDb;
+import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
+import org.openecomp.sdc.versioning.dao.types.VersionInfoEntity;
+
+import java.util.Collection;
+
+public class VersionInfoCassandraLoader {
+
+ private static NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
+ private static Mapper<VersionInfoEntity> mapper =
+ noSqlDb.getMappingManager().mapper(VersionInfoEntity.class);
+ private static VersionInfoAccessor accessor =
+ noSqlDb.getMappingManager().createAccessor(VersionInfoAccessor.class);
+
+
+
+
+ public Collection<VersionInfoEntity> list() {
+ return accessor.getAll().all();
+ }
+
+ @Accessor
+ interface VersionInfoAccessor {
+ @Query("select * from version_info ")
+ Result<VersionInfoEntity> getAll();
+ }
+}
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/loaders/zusammen/VspGeneralLoader.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/loaders/zusammen/VspGeneralLoader.java
new file mode 100644
index 0000000000..d92866bb47
--- /dev/null
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/loaders/zusammen/VspGeneralLoader.java
@@ -0,0 +1,40 @@
+package org.openecomp.core.tools.loaders.zusammen;
+
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
+import org.openecomp.core.zusammen.plugin.dao.impl.CassandraElementRepository;
+import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.StructureElement;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+public class VspGeneralLoader {
+ public static Map<String, ElementEntity> load(SessionContext context,
+ Map<String, List<String>> vspItemVersionsMap) {
+ Map<String, ElementEntity> elementEntityMap = new HashMap<>();
+ System.setProperty("cassandra.dox.keystore", "zusammen_dox");
+ CassandraElementRepository cassandraElementRepository = new CassandraElementRepository();
+ for (Map.Entry<String, List<String>> entry : vspItemVersionsMap.entrySet()) {
+
+ for (String version : entry.getValue()) {
+
+ Optional<ElementEntity> result =
+ cassandraElementRepository.get(context, new ElementEntityContext(
+ context.getUser().getUserName(),
+ new Id(entry.getKey()),
+ new Id(version)),
+ new ElementEntity(new Id(StructureElement.General.name())));
+ if (result.isPresent()) {
+ elementEntityMap.put(context.getUser().getUserName() + "_" + entry.getKey()
+ + "_" + version, result.get());
+ }
+ }
+ }
+
+ return elementEntityMap;
+ }
+}
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/loaders/zusammen/VspItemLoader.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/loaders/zusammen/VspItemLoader.java
new file mode 100644
index 0000000000..78b915c525
--- /dev/null
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/loaders/zusammen/VspItemLoader.java
@@ -0,0 +1,4 @@
+package org.openecomp.core.tools.loaders.zusammen;
+
+public class VspItemLoader {
+}
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/main/ZusammenMainTool.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/main/ZusammenMainTool.java
new file mode 100644
index 0000000000..7bc4bb23fb
--- /dev/null
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/main/ZusammenMainTool.java
@@ -0,0 +1,76 @@
+package org.openecomp.core.tools.main;
+
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.UserInfo;
+import org.openecomp.core.tools.Commands.ResetOldVersion;
+import org.openecomp.core.tools.util.ToolsUtil;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
+
+import java.time.Duration;
+import java.time.Instant;
+
+import static org.openecomp.core.tools.util.Utils.printMessage;
+
+public class ZusammenMainTool {
+
+ private static final String GLOBAL_USER = "GLOBAL_USER";
+ private static Logger logger = LoggerFactory.getLogger(ZusammenMainTool.class);
+ private static int status = 0;
+
+ public static void main(String[] args) {
+
+ String command = ToolsUtil.getParam("c",args);
+ if(command == null){
+ printMessage(logger,
+ "parameter -c is mandatory. script usage: zusammenMainTool.sh -c {command name} " +
+ "[additional arguments depending on the command] ");
+ System.exit(-1);
+ }
+ Instant startTime = Instant.now();
+
+ SessionContext context = new SessionContext();
+ context.setUser(new UserInfo(GLOBAL_USER));
+ context.setTenant("dox");
+
+
+ switch (COMMANDS.valueOf(command)){
+ case RESET_OLD_VERSION:
+ ResetOldVersion.reset(context,ToolsUtil.getParam("v",args));
+ break;
+ case EXPORT:
+ break;
+ case IMPORT:
+ break;
+
+ }
+
+ Instant stopTime = Instant.now();
+ Duration duration = Duration.between(startTime, stopTime);
+ long minutesPart = duration.toMinutes();
+ long secondsPart = duration.minusMinutes(minutesPart).getSeconds();
+
+
+ printMessage(logger,
+ "Zusammen tools command:[] finished . Total run time was : " + minutesPart + ":" +
+ secondsPart
+ + " minutes");
+ System.exit(status);
+
+ }
+
+ private enum COMMANDS{
+
+
+ RESET_OLD_VERSION("reset-old-version"),
+ EXPORT("export"),
+ IMPORT("import");
+
+ COMMANDS(String command) {
+ this.command = command;
+ }
+
+ private String command;
+ }
+
+}
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/ElementHandler.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/ElementHandler.java
new file mode 100644
index 0000000000..2690130974
--- /dev/null
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/ElementHandler.java
@@ -0,0 +1,26 @@
+package org.openecomp.core.tools.store;
+
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
+import org.openecomp.core.zusammen.plugin.dao.impl.CassandraElementRepository;
+import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
+
+public class ElementHandler {
+
+ private static final String GLOBAL_USER = "GLOBAL_USER";
+
+ public static void update(SessionContext context,
+
+ String itemId, String versionId,
+ ElementEntity elementEntity) {
+
+ ElementEntityContext elementContext;
+ elementContext = new ElementEntityContext(GLOBAL_USER, new Id(itemId),
+ new Id(versionId));
+ CassandraElementRepository cassandraElementRepository = new CassandraElementRepository();
+ cassandraElementRepository.update(context, elementContext, elementEntity);
+
+ }
+}
+
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/util/ToolsUtil.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/util/ToolsUtil.java
new file mode 100644
index 0000000000..e2c80f0226
--- /dev/null
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/util/ToolsUtil.java
@@ -0,0 +1,14 @@
+package org.openecomp.core.tools.util;
+
+public class ToolsUtil {
+
+ public static String getParam(String key, String[] args) {
+
+ for (int j = 0; j < args.length; j++) {
+ if (args[j].equals("-" + key)) {
+ return args[j + 1];
+ }
+ }
+ return null;
+ }
+}
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/util/Utils.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/util/Utils.java
new file mode 100644
index 0000000000..d1621ad672
--- /dev/null
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/util/Utils.java
@@ -0,0 +1,15 @@
+package org.openecomp.core.tools.util;
+
+import org.openecomp.sdc.logging.api.Logger;
+
+/**
+ * @author Avrahamg
+ * @since April 24, 2017
+ */
+public class Utils {
+ public static void printMessage(Logger logger, String message) {
+ System.out.println(message);
+ logger.debug(message);
+ }
+}
+
diff --git a/openecomp-be/tools/zusammen-tools/src/main/resources/logback.xml b/openecomp-be/tools/zusammen-tools/src/main/resources/logback.xml
new file mode 100644
index 0000000000..b1c1335302
--- /dev/null
+++ b/openecomp-be/tools/zusammen-tools/src/main/resources/logback.xml
@@ -0,0 +1,282 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration scan="true" scanPeriod="5 seconds">
+
+ <property scope="system" name="ECOMP-component-name" value="ASDC" />
+ <property scope="system" name="ECOMP-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||${ECOMP-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}/${ECOMP-component-name}/${ECOMP-subcomponent-name}/all.log
+ </file>
+
+ <rollingPolicy
+ class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+ <fileNamePattern>${log.home}/${ECOMP-component-name}/${ECOMP-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}/${ECOMP-component-name}/${ECOMP-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}/${ECOMP-component-name}/${ECOMP-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}/${ECOMP-component-name}/${ECOMP-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}/${ECOMP-component-name}/${ECOMP-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="MIGRATION_DEBUG_ROLLING"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${log.home}/${ECOMP-component-name}/${ECOMP-subcomponent-name}/cassandra2zusammen_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}/${ECOMP-component-name}/${ECOMP-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}/${ECOMP-component-name}/${ECOMP-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}/${ECOMP-component-name}/${ECOMP-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}/${ECOMP-component-name}/${ECOMP-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}/${ECOMP-component-name}/${ECOMP-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.core" level="DEBUG" additivity="false">
+ <appender-ref ref="MIGRATION_DEBUG_ROLLING" />
+ </logger>
+</configuration>
+
+
diff --git a/openecomp-be/tools/zusammen-tools/src/main/resources/zusammenMainTool.sh b/openecomp-be/tools/zusammen-tools/src/main/resources/zusammenMainTool.sh
new file mode 100644
index 0000000000..c274d84424
--- /dev/null
+++ b/openecomp-be/tools/zusammen-tools/src/main/resources/zusammenMainTool.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+###########################################################################################################
+# script name - cassandra2zusammen.sh
+# run script - ./cassandra2zusammen.sh
+# This script migrates ASDC 1st class citizen entities and their sub-entities from Cassandra to
+# Zusammen.
+# This script should be run when upgrading from 1702 to 1707
+###########################################################################################################
+
+
+# change exist package and service templates in db
+java -Dlog.home=/apps/jetty/base/be/logs -Dconfiguration.yaml=/apps/jetty/base/be/config/catalog-be/configuration.yaml -jar openecomp-zusammen-tools-1.0-SNAPSHOT.jar org.openecomp.core.tools.main.ZusammenMainTool $1 $2 $3 $4
+
+STATUS="${?}" echo "${STATUS}" echo "All log messages for the zusammenMainTool
+migration process are in /apps/jetty/base/be/logs/ASDC/ASDC-BE/zusammen_tool_debug.log"