summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib')
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/pom.xml49
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/core/zusammen/api/ZusammenAdaptor.java76
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/core/zusammen/api/ZusammenAdaptorFactory.java31
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/core/zusammen/api/ZusammenUtil.java40
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/resources/factoryConfiguration.json3
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/pom.xml85
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/ZusammenConnector.java51
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/ZusammenConnectorFactory.java31
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/impl/ZusammenConnectorFactoryImpl.java39
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/impl/ZusammenConnectorImpl.java200
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/impl/CassandraConnectionInitializer.java59
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/impl/ItemElementLoggerTargetServiceName.java27
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/impl/ZusammenAdaptorFactoryImpl.java35
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/impl/ZusammenAdaptorImpl.java228
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/resources/factoryConfiguration.json3
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/pom.xml37
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/ZusammenPluginConstants.java25
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/ZusammenPluginUtil.java95
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/ElementCollaborationStore.java101
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/VersionCollaborationStore.java79
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/ElementRepository.java25
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/ElementRepositoryFactory.java14
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/CassandraDaoUtils.java27
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/CassandraElementRepository.java358
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/CassandraElementRepositoryFactory.java31
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/types/ElementEntity.java134
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/main/CassandraCollaborationStorePluginImpl.java160
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/main/CassandraStateStorePluginImpl.java58
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/resources/factoryConfiguration.json3
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/resources/zusammen.json23
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/pom.xml24
31 files changed, 2151 insertions, 0 deletions
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/pom.xml b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/pom.xml
new file mode 100644
index 0000000000..37930ff9b3
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/pom.xml
@@ -0,0 +1,49 @@
+<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>
+
+ <name>openecomp-zusammen-api</name>
+ <artifactId>openecomp-zusammen-api</artifactId>
+
+
+ <parent>
+ <groupId>org.openecomp.core</groupId>
+ <artifactId>openecomp-zusammen-lib</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-logging-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.core</groupId>
+ <artifactId>openecomp-facade-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.core</groupId>
+ <artifactId>openecomp-facade-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.amdocs.zusammen</groupId>
+ <artifactId>zusammen-adaptor-inbound-api</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-datatypes-lib</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ <version>3.4</version>
+ </dependency>
+ </dependencies>
+
+
+</project> \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/core/zusammen/api/ZusammenAdaptor.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/core/zusammen/api/ZusammenAdaptor.java
new file mode 100644
index 0000000000..1495ed27a8
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/core/zusammen/api/ZusammenAdaptor.java
@@ -0,0 +1,76 @@
+package org.openecomp.core.zusammen.api;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.item.ElementContext;
+import com.amdocs.zusammen.datatypes.item.Info;
+import com.amdocs.zusammen.datatypes.item.Item;
+import com.amdocs.zusammen.datatypes.item.ItemVersion;
+import com.amdocs.zusammen.datatypes.item.ItemVersionData;
+import com.amdocs.zusammen.datatypes.itemversion.Tag;
+import org.apache.commons.lang3.tuple.ImmutablePair;
+
+import java.util.Collection;
+import java.util.Optional;
+
+public interface ZusammenAdaptor {
+
+ Collection<Item> listItems(SessionContext context);
+
+ Id createItem(SessionContext context, Info info);
+
+ void updateItem(SessionContext context, Id itemId, Info info);
+
+ // TODO: 4/4/2017 fix this workaround when versionId will be recieved from UI
+ Optional<ItemVersion> getFirstVersion(SessionContext context, Id itemId);
+
+ Id createVersion(SessionContext context, Id itemId, Id baseVersionId,
+ ItemVersionData itemVersionData);
+
+ void updateVersion(SessionContext context, Id itemId, Id versionId,
+ ItemVersionData itemVersionData);
+
+ void tagVersion(SessionContext context, Id itemId, Id versionId, Tag tag);
+
+ void resetVersionHistory(SessionContext context, Id itemId, Id versionId, String changeRef);
+
+ Optional<ElementInfo> getElementInfo(SessionContext context, ElementContext elementContext,
+ Id elementId);
+
+ Optional<Element> getElement(SessionContext context, ElementContext elementContext,
+ String elementId); // TODO: 4/3/2017 change to Id
+
+ Optional<Element> getElementByName(
+ SessionContext context, ElementContext elementContext, Id parentElementId,
+ String elementName);
+
+ Collection<ElementInfo> listElements(SessionContext context,
+ ElementContext elementContext,
+ Id parentElementId);
+
+ Collection<Element> listElementData(SessionContext context,
+ ElementContext elementContext,
+ Id parentElementId);
+
+ /**
+ * Lists the sub elements of the element named <elementName> which is a sub element of <parentElementId>
+ * @param context
+ * @param elementContext
+ * @param parentElementId
+ * @param elementName
+ * @return
+ */
+ Collection<ElementInfo> listElementsByName(
+ SessionContext context, ElementContext elementContext, Id parentElementId,
+ String elementName);
+
+ Optional<ElementInfo> getElementInfoByName(
+ SessionContext context, ElementContext elementContext, Id parentElementId,
+ String elementName);
+
+ Optional<Element> saveElement(SessionContext context, ElementContext elementContext,
+ ZusammenElement element, String message);
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/core/zusammen/api/ZusammenAdaptorFactory.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/core/zusammen/api/ZusammenAdaptorFactory.java
new file mode 100644
index 0000000000..53981ba478
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/core/zusammen/api/ZusammenAdaptorFactory.java
@@ -0,0 +1,31 @@
+/*-
+ * ============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.zusammen.api;
+
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
+
+public abstract class ZusammenAdaptorFactory extends AbstractComponentFactory<ZusammenAdaptor> {
+
+ public static ZusammenAdaptorFactory getInstance() {
+ return AbstractFactory.getInstance(ZusammenAdaptorFactory.class);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/core/zusammen/api/ZusammenUtil.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/core/zusammen/api/ZusammenUtil.java
new file mode 100644
index 0000000000..3df6151fae
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/core/zusammen/api/ZusammenUtil.java
@@ -0,0 +1,40 @@
+package org.openecomp.core.zusammen.api;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.UserInfo;
+import com.amdocs.zusammen.datatypes.item.Action;
+import com.amdocs.zusammen.datatypes.item.Info;
+import com.amdocs.zusammen.datatypes.item.ItemVersionData;
+
+public class ZusammenUtil {
+ // TODO: 3/19/2017 add user and tenant args
+ public static SessionContext createSessionContext() {
+ SessionContext sessionContext = new SessionContext();
+ sessionContext.setUser(new UserInfo("GLOBAL_USER"));
+ sessionContext.setTenant("dox");
+ return sessionContext;
+ }
+
+ public static ZusammenElement buildStructuralElement(String structureElementName,
+ Action action) {
+ ZusammenElement element = new ZusammenElement();
+ Info info = new Info();
+ info.setName(structureElementName);
+ element.setInfo(info);
+ if (action != null) {
+ element.setAction(action);
+ }
+ return element;
+ }
+
+ // TODO: 4/24/2017 remove upon working with more than one single version
+ public static ItemVersionData createFirstVersionData() {
+ Info info = new Info();
+ info.setName("main version");
+ ItemVersionData itemVersionData = new ItemVersionData();
+ itemVersionData.setInfo(info);
+ return itemVersionData;
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/resources/factoryConfiguration.json b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/resources/factoryConfiguration.json
new file mode 100644
index 0000000000..30abb9bfed
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/resources/factoryConfiguration.json
@@ -0,0 +1,3 @@
+{
+ "org.openecomp.core.zusammen.api.ZusammenAdaptorFactory": "org.openecomp.core.zusammen.impl.ZusammenAdaptorFactoryImpl"
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/pom.xml b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/pom.xml
new file mode 100644
index 0000000000..eb418eae8f
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/pom.xml
@@ -0,0 +1,85 @@
+<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>
+
+ <name>openecomp-zusammen-core</name>
+ <artifactId>openecomp-zusammen-core</artifactId>
+
+ <parent>
+ <groupId>org.openecomp.core</groupId>
+ <artifactId>openecomp-zusammen-lib</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.core</groupId>
+ <artifactId>openecomp-zusammen-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.amdocs.zusammen</groupId>
+ <artifactId>zusammen-commons-utils</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>com.amdocs.zusammen</groupId>
+ <artifactId>zusammen-adaptor-inbound-api</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>com.amdocs.zusammen</groupId>
+ <artifactId>zusammen-adaptor-inbound-impl</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.core</groupId>
+ <artifactId>openecomp-zusammen-plugin</artifactId>
+ <version>${project.version}</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>com.datastax.cassandra</groupId>
+ <artifactId>cassandra-driver-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.datastax.cassandra</groupId>
+ <artifactId>cassandra-driver-mapping</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>com.amdocs.zusammen.plugin</groupId>
+ <artifactId>zusammen-search-index-empty-plugin</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-logging-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-datatypes-lib</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.core</groupId>
+ <artifactId>openecomp-facade-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <version>3.1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.core</groupId>
+ <artifactId>openecomp-nosqldb-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/ZusammenConnector.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/ZusammenConnector.java
new file mode 100644
index 0000000000..f746d706e1
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/ZusammenConnector.java
@@ -0,0 +1,51 @@
+package org.openecomp.core.zusammen.db;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.item.ElementContext;
+import com.amdocs.zusammen.datatypes.item.Info;
+import com.amdocs.zusammen.datatypes.item.Item;
+import com.amdocs.zusammen.datatypes.item.ItemVersion;
+import com.amdocs.zusammen.datatypes.item.ItemVersionData;
+import com.amdocs.zusammen.datatypes.itemversion.Tag;
+import com.amdocs.zusammen.datatypes.response.Response;
+
+import java.util.Collection;
+import java.util.Optional;
+
+public interface ZusammenConnector {
+
+ Collection<Item> listItems(SessionContext context);
+
+ Id createItem(SessionContext context, Info info);
+
+ void updateItem(SessionContext context, Id itemId, Info info);
+
+
+ Collection<ItemVersion> listVersions(SessionContext context, Id itemId);
+
+ Id createVersion(SessionContext context, Id itemId, Id baseVersionId,
+ ItemVersionData itemVersionData);
+
+ void updateVersion(SessionContext context, Id itemId, Id versionId,
+ ItemVersionData itemVersionData);
+
+ void tagVersion(SessionContext context, Id itemId, Id versionId, Tag tag);
+
+ void resetVersionHistory(SessionContext context, Id itemId, Id versionId, String changeRef);
+
+
+ Collection<ElementInfo> listElements(SessionContext context, ElementContext elementContext,
+ Id parentElementId);
+
+ Response<ElementInfo> getElementInfo(SessionContext context, ElementContext elementContext, Id
+ elementId);
+
+ Response<Element> getElement(SessionContext context, ElementContext elementContext, Id elementId);
+
+ Optional<Element> saveElement(SessionContext context, ElementContext elementContext,
+ ZusammenElement element, String message);
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/ZusammenConnectorFactory.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/ZusammenConnectorFactory.java
new file mode 100644
index 0000000000..31a8bf598d
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/ZusammenConnectorFactory.java
@@ -0,0 +1,31 @@
+/*-
+ * ============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.zusammen.db;
+
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
+
+public abstract class ZusammenConnectorFactory extends AbstractComponentFactory<ZusammenConnector> {
+
+ public static ZusammenConnectorFactory getInstance() {
+ return AbstractFactory.getInstance(ZusammenConnectorFactory.class);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/impl/ZusammenConnectorFactoryImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/impl/ZusammenConnectorFactoryImpl.java
new file mode 100644
index 0000000000..f3916521dd
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/impl/ZusammenConnectorFactoryImpl.java
@@ -0,0 +1,39 @@
+/*-
+ * ============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.zusammen.db.impl;
+
+import com.amdocs.zusammen.adaptor.inbound.api.item.ElementAdaptorFactory;
+import com.amdocs.zusammen.adaptor.inbound.api.item.ItemAdaptorFactory;
+import com.amdocs.zusammen.adaptor.inbound.api.item.ItemVersionAdaptorFactory;
+import org.openecomp.core.zusammen.db.ZusammenConnector;
+import org.openecomp.core.zusammen.db.ZusammenConnectorFactory;
+
+public class ZusammenConnectorFactoryImpl extends ZusammenConnectorFactory {
+ private static final ZusammenConnector INSTANCE =
+ new ZusammenConnectorImpl(ItemAdaptorFactory.getInstance(),
+ ItemVersionAdaptorFactory.getInstance(),
+ ElementAdaptorFactory.getInstance());
+
+ @Override
+ public ZusammenConnector createInterface() {
+ return INSTANCE;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/impl/ZusammenConnectorImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/impl/ZusammenConnectorImpl.java
new file mode 100644
index 0000000000..8aa8e129df
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/impl/ZusammenConnectorImpl.java
@@ -0,0 +1,200 @@
+package org.openecomp.core.zusammen.db.impl;
+
+import com.amdocs.zusammen.adaptor.inbound.api.item.ElementAdaptorFactory;
+import com.amdocs.zusammen.adaptor.inbound.api.item.ItemAdaptorFactory;
+import com.amdocs.zusammen.adaptor.inbound.api.item.ItemVersionAdaptorFactory;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.Space;
+import com.amdocs.zusammen.datatypes.item.ElementContext;
+import com.amdocs.zusammen.datatypes.item.Info;
+import com.amdocs.zusammen.datatypes.item.Item;
+import com.amdocs.zusammen.datatypes.item.ItemVersion;
+import com.amdocs.zusammen.datatypes.item.ItemVersionData;
+import com.amdocs.zusammen.datatypes.itemversion.Tag;
+import com.amdocs.zusammen.datatypes.response.Response;
+import com.amdocs.zusammen.datatypes.response.ReturnCode;
+import org.openecomp.core.zusammen.db.ZusammenConnector;
+import org.openecomp.core.zusammen.impl.CassandraConnectionInitializer;
+import org.openecomp.core.zusammen.impl.ItemElementLoggerTargetServiceName;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
+import org.openecomp.sdc.logging.types.LoggerConstants;
+import org.openecomp.sdc.logging.types.LoggerErrorCode;
+
+import java.util.Collection;
+import java.util.Optional;
+
+public class ZusammenConnectorImpl implements ZusammenConnector {
+
+ private ItemAdaptorFactory itemAdaptorFactory;
+ private ItemVersionAdaptorFactory versionAdaptorFactory;
+ private ElementAdaptorFactory elementAdaptorFactory;
+
+ public ZusammenConnectorImpl(
+ ItemAdaptorFactory itemAdaptorFactory,
+ ItemVersionAdaptorFactory versionAdaptorFactory,
+ ElementAdaptorFactory elementAdaptorFactory) {
+ this.itemAdaptorFactory = itemAdaptorFactory;
+ this.versionAdaptorFactory = versionAdaptorFactory;
+ this.elementAdaptorFactory = elementAdaptorFactory;
+ CassandraConnectionInitializer.setCassandraConnectionPropertiesToSystem();
+ }
+
+ @Override
+ public Collection<Item> listItems(SessionContext context) {
+ Response<Collection<Item>> response =
+ itemAdaptorFactory.createInterface(context).list(context);
+ if (response.isSuccessful()) {
+ return response.getValue();
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public Id createItem(SessionContext context, Info info) {
+ Response<Id> response = itemAdaptorFactory.createInterface(context).create(context, info);
+ if (response.isSuccessful()) {
+ return response.getValue();
+ } else {
+ throw new RuntimeException(
+ "failed to create Item. message:" + response.getReturnCode().getMessage());
+ }
+ }
+
+ @Override
+ public void updateItem(SessionContext context, Id itemId, Info info) {
+ Response<Void> response =
+ itemAdaptorFactory.createInterface(context).update(context, itemId, info);
+
+ if (!response.isSuccessful()) {
+ throw new RuntimeException("failed to update Item . ItemId:" + itemId + "" +
+ " message:" + response.getReturnCode().getMessage());
+ }
+ }
+
+ @Override
+ public Collection<ItemVersion> listVersions(SessionContext context, Id itemId) {
+ Response<Collection<ItemVersion>> versions =
+ versionAdaptorFactory.createInterface(context).list(context, Space.PRIVATE, itemId);
+ if (!versions.isSuccessful()) {
+ logErrorMessageToMdc(ItemElementLoggerTargetServiceName.ITEM_VERSION_RETRIEVAL, versions
+ .getReturnCode());
+ throw new RuntimeException(versions.getReturnCode().getMessage()); // TODO: 3/26/2017
+ }
+ return versions.getValue();
+ }
+
+ @Override
+ public Id createVersion(SessionContext context, Id itemId, Id baseVersionId,
+ ItemVersionData itemVersionData) {
+ Response<Id> response = versionAdaptorFactory.createInterface(context).create(context, itemId,
+ baseVersionId, itemVersionData);
+ if (response.isSuccessful()) {
+ return response.getValue();
+ } else {
+ throw new RuntimeException("failed to create Item Version. ItemId:" + itemId + " based " +
+ "on:" + baseVersionId +
+ " message:" + response
+ .getReturnCode().getMessage());
+ }
+ }
+
+ @Override
+ public void updateVersion(SessionContext context, Id itemId, Id versionId,
+ ItemVersionData itemVersionData) {
+ Response<Void> response = versionAdaptorFactory.createInterface(context)
+ .update(context, itemId, versionId, itemVersionData);
+ if (!response.isSuccessful()) {
+ throw new RuntimeException(
+ String.format("failed to create Item Version. ItemId: %s, versionId: %s, message: %s",
+ itemId.getValue(), versionId.getValue(), response.getReturnCode().getMessage()));
+ }
+ }
+
+ @Override
+ public void tagVersion(SessionContext context, Id itemId, Id versionId, Tag tag) {
+ Response<Void> response = versionAdaptorFactory.createInterface(context)
+ .tag(context, itemId, versionId, null, tag);
+ if (!response.isSuccessful()) {
+ throw new RuntimeException(String.format(
+ "failed to tag Item Version with tag %s. ItemId: %s, versionId: %s, message: %s",
+ tag.getName(), itemId.getValue(), versionId.getValue(), response.getReturnCode()
+ .getMessage()));
+ }
+ }
+
+ @Override
+ public void resetVersionHistory(SessionContext context, Id itemId, Id versionId,
+ String changeRef) {
+ Response<Void> response = versionAdaptorFactory.createInterface(context)
+ .resetHistory(context, itemId, versionId, changeRef);
+ if (!response.isSuccessful()) {
+ throw new RuntimeException(String.format(
+ "failed to reset Item Version back to %s. ItemId: %s, versionId: %s, message: %s",
+ changeRef, itemId.getValue(), versionId.getValue(),
+ response.getReturnCode().getMessage()));
+ }
+ }
+
+ @Override
+ public Collection<ElementInfo> listElements(SessionContext context,
+ ElementContext elementContext,
+ Id parentElementId) {
+ Response<Collection<ElementInfo>> elementInfosResponse = elementAdaptorFactory
+ .createInterface(context).list(context, elementContext, parentElementId);
+ if (elementInfosResponse.isSuccessful()) {
+ return elementInfosResponse.getValue();
+ } else {
+ logErrorMessageToMdc(ItemElementLoggerTargetServiceName.ELEMENT_GET_BY_PROPERTY,
+ elementInfosResponse.getReturnCode());
+ throw new RuntimeException(elementInfosResponse.getReturnCode().getMessage());
+ }
+ }
+
+ @Override
+ public Response<ElementInfo> getElementInfo(SessionContext context, ElementContext elementContext,
+ Id elementId) {
+ return elementAdaptorFactory.createInterface(context)
+ .getInfo(context, elementContext, elementId);
+ }
+
+
+ @Override
+ public Response<Element> getElement(SessionContext context, ElementContext elementContext,
+ Id elementId) {
+ return elementAdaptorFactory.createInterface(context).get(context, elementContext, elementId);
+ }
+
+ @Override
+ public Optional<Element> saveElement(SessionContext context, ElementContext elementContext,
+ ZusammenElement element, String message) {
+ Response<Element> saveResponse = elementAdaptorFactory.createInterface(context)
+ .save(context, elementContext, element, message);
+ return saveResponse.isSuccessful()
+ ? Optional.of(saveResponse.getValue())
+ : Optional.empty(); // TODO: 3/21/2017 error?
+ }
+
+ private void logErrorMessageToMdc(ItemElementLoggerTargetServiceName
+ itemElementLoggerTargetServiceName,
+ ReturnCode returnCode) {
+ logErrorMessageToMdc(itemElementLoggerTargetServiceName, returnCode.toString());
+ }
+
+ private void logErrorMessageToMdc(ItemElementLoggerTargetServiceName
+ itemElementLoggerTargetServiceName,
+ String message) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ itemElementLoggerTargetServiceName.getDescription(),
+ ErrorLevel.ERROR.name(),
+ LoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode(),
+ message);
+ }
+
+
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/impl/CassandraConnectionInitializer.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/impl/CassandraConnectionInitializer.java
new file mode 100644
index 0000000000..47cb57c5f7
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/impl/CassandraConnectionInitializer.java
@@ -0,0 +1,59 @@
+package org.openecomp.core.zusammen.impl;
+
+
+import org.apache.commons.lang3.StringUtils;
+import org.openecomp.core.nosqldb.util.CassandraUtils;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+/**
+ * @author Avrahamg
+ * @since April 25, 2017
+ */
+
+public class CassandraConnectionInitializer implements ServletContextListener {
+ @Override
+ public void contextInitialized(ServletContextEvent servletContextEvent) {
+ setCassandraConnectionPropertiesToSystem();
+ }
+
+ public static void setCassandraConnectionPropertiesToSystem() {
+ if (!System.getProperties().containsKey("cassandra.nodes")) {
+ System.setProperty("cassandra.nodes", StringUtils.join(CassandraUtils.getAddresses(), ','));
+ }
+ if (!System.getProperties().containsKey("cassandra.authenticate")) {
+ System
+ .setProperty("cassandra.authenticate",
+ CassandraUtils.isAuthenticate() ? "true" : "false");
+ }
+ if (!System.getProperties().containsKey("cassandra.ssl")) {
+ System.setProperty("cassandra.ssl",
+ CassandraUtils.isSsl() ? "true" : "false");
+ }
+ if (!System.getProperties().containsKey("cassandra.truststore")) {
+ System.setProperty("cassandra.truststore", CassandraUtils.getTruststore());
+ }
+ if (!System.getProperties().containsKey("cassandra.truststore.password")) {
+ System.setProperty("cassandra.truststore.password", CassandraUtils.getTruststorePassword());
+ }
+ if (!System.getProperties().containsKey("cassandra.user")) {
+ System.setProperty("cassandra.user", CassandraUtils.getUser());
+ }
+ if (!System.getProperties().containsKey("cassandra.password")) {
+ System.setProperty("cassandra.password", CassandraUtils.getPassword());
+ }
+ if (!System.getProperties().containsKey("cassandra.keyspace")) {
+ System.setProperty("cassandra.keyspace", "zusammen");
+ }
+ }
+
+ // -Dcassandra.nodes=10.147.97.145 -Dcassandra.keyspace=zusammen -Dcassandra.authenticate=true -Dcassandra.ssl=true
+ // -Dcassandra.truststore=/apps/jetty/base/be/config/.truststore -Dcassandra.truststore.password=Aa123456
+ // -Dcassandra.user=asdc_user -Dcassandra.password=Aa1234%^!
+
+ @Override
+ public void contextDestroyed(ServletContextEvent servletContextEvent) {
+
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/impl/ItemElementLoggerTargetServiceName.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/impl/ItemElementLoggerTargetServiceName.java
new file mode 100644
index 0000000000..1a4466a3c5
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/impl/ItemElementLoggerTargetServiceName.java
@@ -0,0 +1,27 @@
+package org.openecomp.core.zusammen.impl;
+
+/**
+ * @author Avrahamg.
+ * @since February 19, 2017
+ */
+public enum ItemElementLoggerTargetServiceName {
+ ITEM_CREATION("Item Creation"),
+ ITEM_VERSION_CREATION("Item Version Creation"),
+ ELEMENT_CREATION("Element Creation"),
+ ELEMENT_UPDATE("Element Update"),
+ ELEMENT_LIST("Element List"),
+ ELEMENT_GET("Element Get"),
+ ELEMENT_GET_BY_PROPERTY("Element Get By Property"),
+ ITEM_RETRIEVAL("Item retrieval"),
+ ITEM_VERSION_RETRIEVAL("Item version retrieval)");
+
+ private final String description;
+
+ public String getDescription() {
+ return description;
+ }
+
+ ItemElementLoggerTargetServiceName(String description) {
+ this.description = description;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/impl/ZusammenAdaptorFactoryImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/impl/ZusammenAdaptorFactoryImpl.java
new file mode 100644
index 0000000000..edc1abf108
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/impl/ZusammenAdaptorFactoryImpl.java
@@ -0,0 +1,35 @@
+/*-
+ * ============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.zusammen.impl;
+
+import org.openecomp.core.zusammen.api.ZusammenAdaptor;
+import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory;
+import org.openecomp.core.zusammen.db.ZusammenConnectorFactory;
+
+public class ZusammenAdaptorFactoryImpl extends ZusammenAdaptorFactory {
+ private static final ZusammenAdaptor INSTANCE =
+ new ZusammenAdaptorImpl(ZusammenConnectorFactory.getInstance().createInterface());
+
+ @Override
+ public ZusammenAdaptor createInterface() {
+ return INSTANCE;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/impl/ZusammenAdaptorImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/impl/ZusammenAdaptorImpl.java
new file mode 100644
index 0000000000..ad4839bd00
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/impl/ZusammenAdaptorImpl.java
@@ -0,0 +1,228 @@
+package org.openecomp.core.zusammen.impl;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.item.Action;
+import com.amdocs.zusammen.datatypes.item.ElementContext;
+import com.amdocs.zusammen.datatypes.item.Info;
+import com.amdocs.zusammen.datatypes.item.Item;
+import com.amdocs.zusammen.datatypes.item.ItemVersion;
+import com.amdocs.zusammen.datatypes.item.ItemVersionData;
+import com.amdocs.zusammen.datatypes.itemversion.Tag;
+import com.amdocs.zusammen.datatypes.response.Response;
+import com.amdocs.zusammen.datatypes.response.ReturnCode;
+import org.openecomp.core.zusammen.api.ZusammenAdaptor;
+import org.openecomp.core.zusammen.db.ZusammenConnector;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
+import org.openecomp.sdc.logging.types.LoggerConstants;
+import org.openecomp.sdc.logging.types.LoggerErrorCode;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Optional;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+
+public class ZusammenAdaptorImpl implements ZusammenAdaptor {
+
+ private ZusammenConnector connector;
+
+ public ZusammenAdaptorImpl(ZusammenConnector connector) {
+ this.connector = connector;
+ }
+
+ @Override
+ public Optional<ItemVersion> getFirstVersion(SessionContext context, Id itemId) {
+ Collection<ItemVersion> versions = connector.listVersions(context, itemId);
+ if(versions == null || versions.size()==0) {
+ return Optional.empty();
+ }
+ List<ItemVersion> itemVersions = new ArrayList<>(versions);
+ sortItemVersionListByModificationTimeDescOrder(itemVersions);
+ ItemVersion itemVersion = itemVersions.iterator().next();
+
+ return Optional.ofNullable(itemVersion);
+ }
+
+ @Override
+ public Optional<ElementInfo> getElementInfo(SessionContext context, ElementContext elementContext,
+ Id elementId) {
+ Response<ElementInfo> response = connector.getElementInfo(context, elementContext, elementId);
+ return response.isSuccessful() ? Optional.ofNullable(response.getValue()) : Optional.empty();
+ }
+
+ @Override
+ public Optional<Element> getElement(SessionContext context, ElementContext elementContext,
+ String elementId) {
+ Response<Element> response = connector.getElement(context, elementContext, new Id(elementId));
+ return response.isSuccessful() ? Optional.ofNullable(response.getValue()) : Optional.empty();
+ }
+
+ @Override
+ public Optional<Element> getElementByName(
+ SessionContext context, ElementContext elementContext, Id parentElementId,
+ String elementName) {
+ Collection<ElementInfo> elementInfos =
+ connector.listElements(context, elementContext, parentElementId);
+ Predicate<ElementInfo> elementInfoPredicate = elementInfo -> elementInfo.getInfo() != null
+ && elementName.equals(elementInfo.getInfo().getName());
+ return getFirstElementInfo(elementInfos, elementInfoPredicate)
+ .map(elementInfo -> getElement(context, elementContext, elementInfo.getId().getValue()))
+ .orElse(Optional.empty());
+ }
+
+ @Override
+ public Collection<ElementInfo> listElements(SessionContext context, ElementContext elementContext,
+ Id parentElementId) {
+ return connector.listElements(context, elementContext, parentElementId);
+ }
+
+ @Override
+ public Collection<Element> listElementData(SessionContext context,
+ ElementContext elementContext,
+ Id parentElementId) {
+
+ Collection<ElementInfo> elementInfoList = connector.listElements(context, elementContext,
+ parentElementId);
+ if (elementInfoList != null) {
+ return elementInfoList.stream().map(elementInfo -> connector.getElement(context,
+ elementContext, elementInfo.getId()).getValue()).collect(Collectors.toList());
+ }
+
+ return new ArrayList<>();
+
+ }
+
+
+ @Override
+ public Collection<ElementInfo> listElementsByName(
+ SessionContext context, ElementContext elementContext, Id parentElementId,
+ String elementName) {
+ Optional<ElementInfo> elementInfoByName =
+ getElementInfoByName(context, elementContext, parentElementId, elementName);
+
+ return elementInfoByName.isPresent()
+ ? connector.listElements(context, elementContext, elementInfoByName.get().getId())
+ : new ArrayList<>();
+ }
+
+ @Override
+ public Optional<ElementInfo> getElementInfoByName(
+ SessionContext context, ElementContext elementContext, Id parentElementId,
+ String elementName) {
+ Collection<ElementInfo> elementInfos =
+ connector.listElements(context, elementContext, parentElementId);
+ return getFirstElementInfo(elementInfos,
+ elementInfo -> elementInfo.getInfo() != null &&
+ elementName.equals(elementInfo.getInfo().getName()));
+ }
+
+ @Override
+ public Optional<Element> saveElement(SessionContext context, ElementContext elementContext,
+ ZusammenElement element, String message) {
+ enrichElementHierarchyRec(context, elementContext, null, element);
+ return connector.saveElement(context, elementContext, element, message);
+ }
+
+ private void enrichElementHierarchyRec(SessionContext context, ElementContext
+ elementContext, Id parentElementId, ZusammenElement element) {
+ if (element.getAction() == Action.CREATE) {
+ return;
+ }
+ locateElementAndUpdateAction(context, elementContext, parentElementId, element);
+ element.getSubElements().forEach(subElement -> enrichElementHierarchyRec(
+ context, elementContext, element.getElementId(), (ZusammenElement) subElement));
+ }
+
+ // should be applied only for structural elements
+ private void locateElementAndUpdateAction(SessionContext context, ElementContext elementContext,
+ Id parentElementId, ZusammenElement element) {
+ if (element.getElementId() != null) {
+ return;
+ }
+ Optional<ElementInfo> elementInfo =
+ getElementInfoByName(context, elementContext, parentElementId, element.getInfo().getName());
+ if (elementInfo.isPresent()) {
+ element.setElementId(elementInfo.get().getId());
+ if (element.getAction() == null) {
+ element.setAction(Action.IGNORE);
+ }
+ } else {
+ element.setAction(Action.CREATE);
+ }
+ }
+
+ private Optional<ElementInfo> getFirstElementInfo(Collection<ElementInfo> elementInfos,
+ Predicate<ElementInfo> elementInfoPredicate) {
+ return elementInfos.stream()
+ .filter(elementInfoPredicate)
+ .findFirst();
+ }
+
+ private void logErrorMessageToMdc(ItemElementLoggerTargetServiceName
+ itemElementLoggerTargetServiceName,
+ ReturnCode returnCode) {
+ logErrorMessageToMdc(itemElementLoggerTargetServiceName, returnCode.toString());
+ }
+
+ private void logErrorMessageToMdc(ItemElementLoggerTargetServiceName
+ itemElementLoggerTargetServiceName,
+ String message) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ itemElementLoggerTargetServiceName.getDescription(),
+ ErrorLevel.ERROR.name(),
+ LoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode(),
+ message);
+ }
+
+ @Override
+ public Id createItem(SessionContext context, Info info) {
+ return connector.createItem(context, info);
+ }
+
+ @Override
+ public Id createVersion(SessionContext context, Id itemId, Id baseVersionId, ItemVersionData
+ itemVersionData) {
+ return connector.createVersion(context, itemId, baseVersionId, itemVersionData);
+
+ }
+
+ @Override
+ public Collection<Item> listItems(SessionContext context) {
+ return connector.listItems(context);
+ }
+
+ @Override
+ public void updateVersion(SessionContext context, Id itemId, Id versionId,
+ ItemVersionData itemVersionData) {
+ connector.updateVersion(context, itemId, versionId, itemVersionData);
+ }
+
+ @Override
+ public void tagVersion(SessionContext context, Id itemId, Id versionId, Tag tag) {
+ connector.tagVersion(context, itemId, versionId, tag);
+ }
+
+ @Override
+ public void resetVersionHistory(SessionContext context, Id itemId, Id versionId,
+ String changeRef) {
+ connector.resetVersionHistory(context, itemId, versionId, changeRef);
+ }
+
+ @Override
+ public void updateItem(SessionContext context, Id itemId, Info info) {
+ connector.updateItem(context, itemId, info);
+ }
+
+ private static void sortItemVersionListByModificationTimeDescOrder(
+ List<ItemVersion> itemVersions) {
+ itemVersions.sort((o1, o2) -> ((Integer)o2.getId().getValue().length())
+ .compareTo( (o1.getId().getValue().length())));
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/resources/factoryConfiguration.json b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/resources/factoryConfiguration.json
new file mode 100644
index 0000000000..eb20b04531
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/resources/factoryConfiguration.json
@@ -0,0 +1,3 @@
+{
+ "org.openecomp.core.zusammen.db.ZusammenConnectorFactory": "org.openecomp.core.zusammen.db.impl.ZusammenConnectorFactoryImpl"
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/pom.xml b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/pom.xml
new file mode 100644
index 0000000000..7c41ca730c
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/pom.xml
@@ -0,0 +1,37 @@
+<?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>
+
+ <parent>
+ <groupId>org.openecomp.core</groupId>
+ <artifactId>openecomp-zusammen-lib</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>openecomp-zusammen-plugin</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>com.amdocs.zusammen</groupId>
+ <artifactId>zusammen-sdk</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>com.amdocs.zusammen</groupId>
+ <artifactId>zusammen-commons-db-api</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>com.amdocs.zusammen</groupId>
+ <artifactId>zusammen-commons-db-impl</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.amdocs.zusammen.plugin</groupId>
+ <artifactId>zusammen-state-store-cassandra-plugin</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/ZusammenPluginConstants.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/ZusammenPluginConstants.java
new file mode 100644
index 0000000000..f9e6091fb0
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/ZusammenPluginConstants.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright © 2016-2017 European Support Limited
+ *
+ * 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.
+ */
+
+package org.openecomp.core.zusammen.plugin;
+
+
+import com.amdocs.zusammen.datatypes.Id;
+
+public class ZusammenPluginConstants {
+ public static final String PUBLIC_SPACE = "public";
+ public static final Id ROOT_ELEMENTS_PARENT_ID = Id.ZERO;
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/ZusammenPluginUtil.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/ZusammenPluginUtil.java
new file mode 100644
index 0000000000..59afa70e9a
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/ZusammenPluginUtil.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright © 2016-2017 European Support Limited
+ *
+ * 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.
+ */
+
+package org.openecomp.core.zusammen.plugin;
+
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.Space;
+import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
+import com.amdocs.zusammen.sdk.collaboration.types.CollaborationElement;
+import com.amdocs.zusammen.utils.fileutils.FileUtils;
+import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
+
+import java.io.ByteArrayInputStream;
+import java.nio.ByteBuffer;
+
+public class ZusammenPluginUtil {
+
+ public static String getSpaceName(SessionContext context, Space space) {
+ switch (space) {
+ case PUBLIC:
+ return ZusammenPluginConstants.PUBLIC_SPACE;
+ case PRIVATE:
+ return ZusammenPluginUtil.getPrivateSpaceName(context);
+ default:
+ throw new IllegalArgumentException(String.format("Space %s is not supported.", space));
+ }
+ }
+
+ public static String getPrivateSpaceName(SessionContext context) {
+ return context.getUser().getUserName();
+ }
+
+ public static ElementEntity getElementEntity(CollaborationElement element) {
+ ElementEntity elementEntity = new ElementEntity(element.getId());
+ elementEntity.setNamespace(element.getNamespace());
+ elementEntity.setParentId(element.getParentId() == null
+ ? ZusammenPluginConstants.ROOT_ELEMENTS_PARENT_ID
+ : element.getParentId());
+ elementEntity.setInfo(element.getInfo());
+ elementEntity.setRelations(element.getRelations());
+ if (element.getData() != null) {
+ elementEntity.setData(ByteBuffer.wrap(FileUtils.toByteArray(element.getData())));
+ }
+ if (element.getSearchableData() != null) {
+ elementEntity.setSearchableData(
+ ByteBuffer.wrap(FileUtils.toByteArray(element.getSearchableData())));
+ }
+ if (element.getVisualization() != null) {
+ elementEntity.setVisualization(
+ ByteBuffer.wrap(FileUtils.toByteArray(element.getVisualization())));
+ }
+ return elementEntity;
+ }
+
+ public static CollaborationElement getCollaborationElement(
+ ElementEntityContext elementEntityContext, ElementEntity elementEntity) {
+ Id parentId =
+ ZusammenPluginConstants.ROOT_ELEMENTS_PARENT_ID.equals(elementEntity.getParentId())
+ ? null
+ : elementEntity.getParentId();
+ CollaborationElement element = new CollaborationElement(elementEntityContext.getItemId(),
+ elementEntityContext.getVersionId(), elementEntity.getNamespace(), elementEntity.getId());
+
+ element.setParentId(parentId);
+ element.setInfo(elementEntity.getInfo());
+ element.setRelations(elementEntity.getRelations());
+
+ if (elementEntity.getData() != null) {
+ element.setData(new ByteArrayInputStream(elementEntity.getData().array()));
+ }
+ if (elementEntity.getSearchableData() != null) {
+ element.setSearchableData(
+ new ByteArrayInputStream(elementEntity.getSearchableData().array()));
+ }
+ if (elementEntity.getVisualization() != null) {
+ element.setVisualization(new ByteArrayInputStream(elementEntity.getVisualization().array()));
+ }
+ element.setSubElements(elementEntity.getSubElementIds());
+ return element;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/ElementCollaborationStore.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/ElementCollaborationStore.java
new file mode 100644
index 0000000000..93ee2d058b
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/ElementCollaborationStore.java
@@ -0,0 +1,101 @@
+package org.openecomp.core.zusammen.plugin.collaboration;
+
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.item.ElementContext;
+import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
+import com.amdocs.zusammen.sdk.collaboration.types.CollaborationElement;
+import org.openecomp.core.zusammen.plugin.ZusammenPluginConstants;
+import org.openecomp.core.zusammen.plugin.ZusammenPluginUtil;
+import org.openecomp.core.zusammen.plugin.dao.ElementRepository;
+import org.openecomp.core.zusammen.plugin.dao.ElementRepositoryFactory;
+import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+import static org.openecomp.core.zusammen.plugin.ZusammenPluginUtil.getSpaceName;
+
+
+public class ElementCollaborationStore {
+
+ public Collection<CollaborationElement> listElements(SessionContext context,
+ ElementContext elementContext,
+ Id elementId) {
+ ElementEntityContext elementEntityContext =
+ new ElementEntityContext(ZusammenPluginUtil.getPrivateSpaceName(context), elementContext);
+
+ if (elementId == null) {
+ elementId = ZusammenPluginConstants.ROOT_ELEMENTS_PARENT_ID;
+ }
+
+ ElementRepository elementRepository = getElementRepository(context);
+ return elementRepository.get(context, elementEntityContext, new ElementEntity(elementId))
+ .map(ElementEntity::getSubElementIds).orElse(new HashSet<>()).stream()
+ .map(subElementId -> elementRepository
+ .get(context, elementEntityContext, new ElementEntity(subElementId)).get())
+ .filter(Objects::nonNull)
+ .map(subElement -> ZusammenPluginUtil
+ .getCollaborationElement(elementEntityContext, subElement))
+ .collect(Collectors.toList());
+ }
+
+ public CollaborationElement getElement(SessionContext context, ElementContext elementContext,
+ Id elementId) {
+ ElementEntityContext elementEntityContext =
+ new ElementEntityContext(ZusammenPluginUtil.getPrivateSpaceName(context), elementContext);
+ return getElementRepository(context)
+ .get(context, elementEntityContext, new ElementEntity(elementId))
+ .map(elementEntity -> ZusammenPluginUtil
+ .getCollaborationElement(elementEntityContext, elementEntity))
+ .orElse(null);
+ }
+
+ public void createElement(SessionContext context, CollaborationElement element) {
+ getElementRepository(context)
+ .create(context,
+ new ElementEntityContext(getSpaceName(context, element.getSpace()),
+ element.getItemId(), element.getVersionId()),
+ ZusammenPluginUtil.getElementEntity(element));
+ }
+
+ public void updateElement(SessionContext context, CollaborationElement element) {
+ getElementRepository(context)
+ .update(context,
+ new ElementEntityContext(getSpaceName(context, element.getSpace()),
+ element.getItemId(), element.getVersionId()),
+ ZusammenPluginUtil.getElementEntity(element));
+ }
+
+ public void deleteElement(SessionContext context, CollaborationElement element) {
+ deleteElementHierarchy(getElementRepository(context),
+ context,
+ new ElementEntityContext(getSpaceName(context, element.getSpace()),
+ element.getItemId(), element.getVersionId()),
+ ZusammenPluginUtil.getElementEntity(element));
+ }
+
+ private void deleteElementHierarchy(ElementRepository elementRepository, SessionContext context,
+ ElementEntityContext elementEntityContext,
+ ElementEntity elementEntity) {
+ Optional<ElementEntity> retrieved =
+ elementRepository.get(context, elementEntityContext, elementEntity);
+ if (!retrieved.isPresent()) {
+ return;
+ }
+ retrieved.get().getSubElementIds().stream()
+ .map(ElementEntity::new)
+ .forEach(subElementEntity -> deleteElementHierarchy(
+ elementRepository, context, elementEntityContext, subElementEntity));
+
+ // only for the first one the parentId will populated (so it'll be removed from its parent)
+ elementRepository.delete(context, elementEntityContext, elementEntity);
+ }
+
+ protected ElementRepository getElementRepository(SessionContext context) {
+ return ElementRepositoryFactory.getInstance().createInterface(context);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/VersionCollaborationStore.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/VersionCollaborationStore.java
new file mode 100644
index 0000000000..ae23b6e8a9
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/VersionCollaborationStore.java
@@ -0,0 +1,79 @@
+package org.openecomp.core.zusammen.plugin.collaboration;
+
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.Space;
+import com.amdocs.zusammen.datatypes.item.Action;
+import com.amdocs.zusammen.datatypes.itemversion.Tag;
+import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
+import com.amdocs.zusammen.sdk.collaboration.types.CollaborationElementChange;
+import com.amdocs.zusammen.sdk.collaboration.types.CollaborationMergeChange;
+import org.openecomp.core.zusammen.plugin.ZusammenPluginUtil;
+import org.openecomp.core.zusammen.plugin.dao.ElementRepository;
+import org.openecomp.core.zusammen.plugin.dao.ElementRepositoryFactory;
+import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
+
+import java.util.Collection;
+
+import static org.openecomp.core.zusammen.plugin.ZusammenPluginUtil.getSpaceName;
+
+public class VersionCollaborationStore {
+
+ public void tagItemVersion(SessionContext context, Id itemId, Id versionId, Id changeId,
+ Tag tag) {
+ if (changeId != null) {
+ throw new UnsupportedOperationException(
+ "In this plugin implementation tag is supported only on versionId");
+ }
+ copyElements(context, getSpaceName(context, Space.PRIVATE), itemId, versionId, tag.getName());
+ }
+
+ public CollaborationMergeChange resetItemVersionHistory(SessionContext context, Id itemId,
+ Id versionId, String changeRef) {
+ ElementRepository elementRepository = getElementRepository(context);
+ ElementEntityContext elementContext =
+ new ElementEntityContext(getSpaceName(context, Space.PRIVATE), itemId, versionId);
+
+ CollaborationMergeChange resetChange = new CollaborationMergeChange();
+
+ Collection<ElementEntity> versionElements = elementRepository.list(context, elementContext);
+ versionElements.stream()
+ .map(elementEntity ->
+ convertElementEntityToElementChange(elementEntity, elementContext, Action.DELETE))
+ .forEach(resetChange.getChangedElements()::add);
+
+ elementContext.setChangeRef(changeRef);
+ Collection<ElementEntity> changeRefElements = elementRepository.list(context, elementContext);
+ changeRefElements.stream()
+ .map(elementEntity ->
+ convertElementEntityToElementChange(elementEntity, elementContext, Action.CREATE))
+ .forEach(resetChange.getChangedElements()::add);
+
+ return resetChange; // TODO: 4/19/2017 version change...
+ }
+
+ private void copyElements(SessionContext context, String space, Id itemId, Id sourceVersionId,
+ String targetTag) {
+ ElementRepository elementRepository = getElementRepository(context);
+ ElementEntityContext elementContext = new ElementEntityContext(space, itemId, sourceVersionId);
+
+ Collection<ElementEntity> versionElements = elementRepository.list(context, elementContext);
+
+ elementContext.setChangeRef(targetTag);
+ versionElements
+ .forEach(elementEntity -> elementRepository.create(context, elementContext, elementEntity));
+ }
+
+ private CollaborationElementChange convertElementEntityToElementChange(
+ ElementEntity elementEntity, ElementEntityContext elementContext, Action action) {
+ CollaborationElementChange elementChange = new CollaborationElementChange();
+ elementChange
+ .setElement(ZusammenPluginUtil.getCollaborationElement(elementContext, elementEntity));
+ elementChange.setAction(action);
+ return elementChange;
+ }
+
+ protected ElementRepository getElementRepository(SessionContext context) {
+ return ElementRepositoryFactory.getInstance().createInterface(context);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/ElementRepository.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/ElementRepository.java
new file mode 100644
index 0000000000..468b6f0a28
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/ElementRepository.java
@@ -0,0 +1,25 @@
+package org.openecomp.core.zusammen.plugin.dao;
+
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
+import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
+
+import java.util.Collection;
+import java.util.Optional;
+
+public interface ElementRepository {
+
+ Collection<ElementEntity> list(SessionContext context, ElementEntityContext elementContext);
+
+ void create(SessionContext context, ElementEntityContext elementContext, ElementEntity element);
+
+ void update(SessionContext context, ElementEntityContext elementContext, ElementEntity element);
+
+ void delete(SessionContext context, ElementEntityContext elementContext, ElementEntity element);
+
+ Optional<ElementEntity> get(SessionContext context, ElementEntityContext elementContext,
+ ElementEntity element);
+
+ void createNamespace(SessionContext context, ElementEntityContext elementContext,
+ ElementEntity element);
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/ElementRepositoryFactory.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/ElementRepositoryFactory.java
new file mode 100644
index 0000000000..c541302d97
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/ElementRepositoryFactory.java
@@ -0,0 +1,14 @@
+package org.openecomp.core.zusammen.plugin.dao;
+
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.utils.facade.api.AbstractComponentFactory;
+import com.amdocs.zusammen.utils.facade.api.AbstractFactory;
+
+public abstract class ElementRepositoryFactory extends AbstractComponentFactory<ElementRepository> {
+ public static ElementRepositoryFactory getInstance() {
+ return AbstractFactory.getInstance(ElementRepositoryFactory.class);
+ }
+
+ public abstract ElementRepository createInterface(SessionContext context);
+}
+
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/CassandraDaoUtils.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/CassandraDaoUtils.java
new file mode 100644
index 0000000000..20a1e1803f
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/CassandraDaoUtils.java
@@ -0,0 +1,27 @@
+package org.openecomp.core.zusammen.plugin.dao.impl;
+
+import com.datastax.driver.core.Session;
+import com.amdocs.zusammen.commons.db.api.cassandra.CassandraConnectorFactory;
+import com.amdocs.zusammen.commons.db.api.cassandra.types.CassandraContext;
+import com.amdocs.zusammen.datatypes.SessionContext;
+
+class CassandraDaoUtils {
+
+ static <T> T getAccessor(SessionContext context, Class<T> classOfT) {
+ return CassandraConnectorFactory.getInstance().createInterface(getCassandraContext(context))
+ .getMappingManager()
+ .createAccessor(classOfT);
+ }
+
+ static Session getSession(SessionContext context) {
+ return CassandraConnectorFactory.getInstance().createInterface(getCassandraContext(context))
+ .getMappingManager()
+ .getSession();
+ }
+
+ private static CassandraContext getCassandraContext(SessionContext context) {
+ CassandraContext cassandraContext = new CassandraContext();
+ cassandraContext.setTenant(context.getTenant());
+ return cassandraContext;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/CassandraElementRepository.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/CassandraElementRepository.java
new file mode 100644
index 0000000000..12fd2dabba
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/CassandraElementRepository.java
@@ -0,0 +1,358 @@
+/*
+ * Copyright © 2016-2017 European Support Limited
+ *
+ * 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.
+ */
+
+package org.openecomp.core.zusammen.plugin.dao.impl;
+
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+import com.datastax.driver.mapping.annotations.Accessor;
+import com.datastax.driver.mapping.annotations.Param;
+import com.datastax.driver.mapping.annotations.Query;
+import com.google.gson.reflect.TypeToken;
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.Namespace;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.item.Info;
+import com.amdocs.zusammen.datatypes.item.Relation;
+import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
+import com.amdocs.zusammen.utils.fileutils.json.JsonUtil;
+import org.openecomp.core.zusammen.plugin.dao.ElementRepository;
+import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
+
+import java.lang.reflect.Type;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+public class CassandraElementRepository implements ElementRepository {
+
+ @Override
+ public Collection<ElementEntity> list(SessionContext context,
+ ElementEntityContext elementContext) {
+ Set<String> elementIds = getVersionElementIds(context, elementContext);
+
+ return elementIds.stream()
+ .map(elementId -> get(context, elementContext, new ElementEntity(new Id(elementId))).get())
+ .filter(Objects::nonNull)
+ .collect(Collectors.toList());
+ }
+
+ @Override
+ public void create(SessionContext context, ElementEntityContext elementContext,
+ ElementEntity element) {
+ createElement(context, elementContext, element);
+ addElementToParent(context, elementContext, element);
+ }
+
+ @Override
+ public void update(SessionContext context, ElementEntityContext elementContext,
+ ElementEntity element) {
+ updateElement(context, elementContext, element);
+ }
+
+ @Override
+ public void delete(SessionContext context, ElementEntityContext elementContext,
+ ElementEntity element) {
+ removeElementFromParent(context, elementContext, element);
+ deleteElement(context, elementContext, element);
+ }
+
+ @Override
+ public Optional<ElementEntity> get(SessionContext context, ElementEntityContext elementContext,
+ ElementEntity element) {
+ Row row = getElementAccessor(context).get(
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ getVersionId(elementContext),
+ element.getId().toString()).one();
+
+ return row == null ? Optional.empty() : Optional.of(getElementEntity(element, row));
+ }
+
+ @Override
+ public void createNamespace(SessionContext context, ElementEntityContext elementContext,
+ ElementEntity element) {
+ getElementNamespaceAccessor(context).create(
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ element.getId().toString(),
+ element.getNamespace().toString());
+ }
+
+ private String getVersionId(ElementEntityContext elementContext) {
+ return elementContext.getChangeRef() == null
+ ? elementContext.getVersionId().toString()
+ : elementContext.getChangeRef();
+ }
+
+ private ElementNamespaceAccessor getElementNamespaceAccessor(SessionContext context) {
+ return CassandraDaoUtils.getAccessor(context, ElementNamespaceAccessor.class);
+ }
+
+ private ElementAccessor getElementAccessor(SessionContext context) {
+ return CassandraDaoUtils.getAccessor(context, ElementAccessor.class);
+ }
+
+ private VersionElementsAccessor getVersionElementsAccessor(SessionContext context) {
+ return CassandraDaoUtils.getAccessor(context, VersionElementsAccessor.class);
+ }
+
+ private void createElement(SessionContext context, ElementEntityContext elementContext,
+ ElementEntity element) {
+ Set<String> subElementIds =
+ element.getSubElementIds().stream().map(Id::toString).collect(Collectors.toSet());
+ String versionId = getVersionId(elementContext);
+
+ getElementAccessor(context).create(
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ versionId,
+ element.getId().toString(),
+ element.getParentId().toString(),
+ element.getNamespace().toString(),
+ JsonUtil.object2Json(element.getInfo()),
+ JsonUtil.object2Json(element.getRelations()),
+ element.getData(),
+ element.getSearchableData(),
+ element.getVisualization(),
+ subElementIds);
+
+ getVersionElementsAccessor(context).addElements(
+ Collections.singleton(element.getId().toString()),
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ versionId);
+ }
+
+ private void updateElement(SessionContext context, ElementEntityContext elementContext,
+ ElementEntity element) {
+ getElementAccessor(context).update(
+ JsonUtil.object2Json(element.getInfo()),
+ JsonUtil.object2Json(element.getRelations()),
+ element.getData(),
+ element.getSearchableData(),
+ element.getVisualization(),
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ elementContext.getVersionId().toString(),
+ element.getId().toString());
+ }
+
+ private void deleteElement(SessionContext context, ElementEntityContext elementContext,
+ ElementEntity element) {
+ String versionId = getVersionId(elementContext);
+
+ getElementAccessor(context).delete(
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ versionId,
+ element.getId().toString());
+
+ getVersionElementsAccessor(context).removeElements(
+ Collections.singleton(element.getId().toString()),
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ versionId);
+ }
+
+ private void addElementToParent(SessionContext context, ElementEntityContext elementContext,
+ ElementEntity element) {
+ getElementAccessor(context).addSubElements(
+ Collections.singleton(element.getId().toString()),
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ getVersionId(elementContext),
+ element.getParentId().toString());
+ }
+
+ private void removeElementFromParent(SessionContext context, ElementEntityContext elementContext,
+ ElementEntity element) {
+ if (element.getParentId() == null) {
+ return;
+ }
+ getElementAccessor(context).removeSubElements(
+ Collections.singleton(element.getId().toString()),
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ getVersionId(elementContext),
+ element.getParentId().toString());
+ }
+
+ private ElementEntity getElementEntity(ElementEntity element, Row row) {
+ element.setNamespace(getNamespace(row.getString(ElementField.NAMESPACE)));
+ element.setParentId(new Id(row.getString(ElementField.PARENT_ID)));
+ element.setInfo(json2Object(row.getString(ElementField.INFO), Info.class));
+ element.setRelations(
+ json2Object(row.getString(ElementField.RELATIONS), new TypeToken<ArrayList<Relation>>() {
+ }.getType()));
+ element.setData(row.getBytes(ElementField.DATA));
+ element.setSearchableData(row.getBytes(ElementField.SEARCHABLE_DATA));
+ element.setVisualization(row.getBytes(ElementField.VISUALIZATION));
+ element.setSubElementIds(row.getSet(ElementField.SUB_ELEMENT_IDS, String.class)
+ .stream().map(Id::new).collect(Collectors.toSet()));
+ return element;
+ }
+
+ private Namespace getNamespace(String namespaceStr) {
+ Namespace namespace = new Namespace();
+ if (namespaceStr != null) {
+ namespace.setValue(namespaceStr);
+ }
+ return namespace;
+ }
+
+ private static <T> T json2Object(String json, Type typeOfT) {
+ return json == null ? null : JsonUtil.json2Object(json, typeOfT);
+ }
+
+ private Set<String> getVersionElementIds(SessionContext context,
+ ElementEntityContext elementContext) {
+ Row row = getVersionElementsAccessor(context).get(
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ getVersionId(elementContext)).one();
+ return row == null
+ ? new HashSet<>()
+ : row.getSet(CassandraElementRepository.VersionElementsField.ELEMENT_IDS, String.class);
+ }
+
+ /*
+CREATE TABLE IF NOT EXISTS element_namespace (
+ space text,
+ item_id text,
+ element_id text,
+ namespace text,
+ PRIMARY KEY (( space, item_id, element_id ))
+);
+ */
+ @Accessor
+ interface ElementNamespaceAccessor {
+ @Query(
+ "UPDATE element_namespace SET namespace=:ns " +
+ "WHERE space=:space AND item_id=:item AND element_id=:id ")
+ void create(@Param("space") String space,
+ @Param("item") String itemId,
+ @Param("id") String elementId,
+ @Param("ns") String namespace);
+ }
+
+ /*
+CREATE TABLE IF NOT EXISTS element (
+ space text,
+ item_id text,
+ version_id text,
+ element_id text,
+ parent_id text,
+ namespace text,
+ info text,
+ relations text,
+ data blob,
+ searchable_data blob,
+ visualization blob,
+ sub_element_ids set<text>,
+ PRIMARY KEY (( space, item_id, version_id, element_id ))
+);
+ */
+ @Accessor
+ interface ElementAccessor {
+ @Query(
+ "UPDATE element SET parent_id=:parentId, namespace=:ns, info=:info, relations=:rels, " +
+ "data=:data, searchable_data=:searchableData, visualization=:visualization, " +
+ "sub_element_ids=sub_element_ids+:subs " +
+ "WHERE space=:space AND item_id=:item AND version_id=:ver AND element_id=:id ")
+ void create(@Param("space") String space,
+ @Param("item") String itemId,
+ @Param("ver") String versionId,
+ @Param("id") String elementId,
+ @Param("parentId") String parentElementId,
+ @Param("ns") String namespace,
+ @Param("info") String info,
+ @Param("rels") String relations,
+ @Param("data") ByteBuffer data,
+ @Param("searchableData") ByteBuffer searchableData,
+ @Param("visualization") ByteBuffer visualization,
+ @Param("subs") Set<String> subElementIds);
+
+ @Query("UPDATE element SET info=?, relations=?, data=?, searchable_data=?, visualization=?" +
+ " WHERE space=? AND item_id=? AND version_id=? AND element_id=? ")
+ void update(String info, String relations, ByteBuffer data, ByteBuffer searchableData,
+ ByteBuffer visualization, String space, String itemId, String versionId,
+ String elementId);
+
+ @Query("DELETE FROM element WHERE space=? AND item_id=? AND version_id=? AND element_id=?")
+ void delete(String space, String itemId, String versionId, String elementId);
+
+ @Query("SELECT parent_id, namespace, info, relations, data, searchable_data, visualization, " +
+ "sub_element_ids FROM element " +
+ "WHERE space=? AND item_id=? AND version_id=? AND element_id=? ")
+ ResultSet get(String space, String itemId, String versionId, String elementId);
+
+ @Query("UPDATE element SET sub_element_ids=sub_element_ids+? " +
+ " WHERE space=? AND item_id=? AND version_id=? AND element_id=? ")
+ void addSubElements(Set<String> subElementIds, String space, String itemId, String versionId,
+ String elementId);
+
+ @Query("UPDATE element SET sub_element_ids=sub_element_ids-? " +
+ " WHERE space=? AND item_id=? AND version_id=? AND element_id=? ")
+ void removeSubElements(Set<String> subElementIds, String space, String itemId, String versionId,
+ String elementId);
+ }
+
+ private static final class ElementField {
+ private static final String NAMESPACE = "namespace";
+ private static final String PARENT_ID = "parent_id";
+ private static final String INFO = "info";
+ private static final String RELATIONS = "relations";
+ private static final String DATA = "data";
+ private static final String SEARCHABLE_DATA = "searchable_data";
+ private static final String VISUALIZATION = "visualization";
+ private static final String SUB_ELEMENT_IDS = "sub_element_ids";
+ }
+
+ /*
+ CREATE TABLE IF NOT EXISTS version_elements (
+ space text,
+ item_id text,
+ version_id text,
+ element_ids set<text>,
+ PRIMARY KEY (( space, item_id, version_id ))
+ );
+ */
+ @Accessor
+ interface VersionElementsAccessor {
+
+ @Query("UPDATE version_elements SET element_ids=element_ids+? " +
+ "WHERE space=? AND item_id=? AND version_id=?")
+ void addElements(Set<String> elementIds, String space, String itemId, String versionId);
+
+ @Query("UPDATE version_elements SET element_ids=element_ids-? " +
+ "WHERE space=? AND item_id=? AND version_id=?")
+ void removeElements(Set<String> elementIds, String space, String itemId, String versionId);
+
+ @Query("SELECT element_ids FROM version_elements WHERE space=? AND item_id=? AND version_id=?")
+ ResultSet get(String space, String itemId, String versionId);
+ }
+
+ private static final class VersionElementsField {
+ private static final String ELEMENT_IDS = "element_ids";
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/CassandraElementRepositoryFactory.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/CassandraElementRepositoryFactory.java
new file mode 100644
index 0000000000..f3072a6502
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/CassandraElementRepositoryFactory.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright © 2016-2017 European Support Limited
+ *
+ * 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.
+ */
+
+package org.openecomp.core.zusammen.plugin.dao.impl;
+
+import com.amdocs.zusammen.datatypes.SessionContext;
+import org.openecomp.core.zusammen.plugin.dao.ElementRepository;
+import org.openecomp.core.zusammen.plugin.dao.ElementRepositoryFactory;
+
+public class CassandraElementRepositoryFactory extends ElementRepositoryFactory {
+
+ private static final ElementRepository INSTANCE = new CassandraElementRepository();
+
+ @Override
+ public ElementRepository createInterface(SessionContext context) {
+ return INSTANCE;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/types/ElementEntity.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/types/ElementEntity.java
new file mode 100644
index 0000000000..1663d83427
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/types/ElementEntity.java
@@ -0,0 +1,134 @@
+/*
+ * Copyright © 2016-2017 European Support Limited
+ *
+ * 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.
+ */
+
+package org.openecomp.core.zusammen.plugin.dao.types;
+
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.Namespace;
+import com.amdocs.zusammen.datatypes.item.Info;
+import com.amdocs.zusammen.datatypes.item.Relation;
+
+import java.nio.ByteBuffer;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Set;
+
+public class ElementEntity {
+ private Id id;
+ private Id parentId;
+ private Namespace namespace;
+ private Info info;
+ private Collection<Relation> relations = Collections.emptyList();
+ private ByteBuffer data;
+ private ByteBuffer searchableData;
+ private ByteBuffer visualization;
+ private Set<Id> subElementIds = Collections.emptySet();
+
+ public ElementEntity(Id id) {
+ this.id = id;
+ }
+
+ public Id getParentId() {
+ return parentId;
+ }
+
+ public void setParentId(Id parentId) {
+ this.parentId = parentId;
+ }
+
+ public Id getId() {
+ return id;
+ }
+
+ public void setId(Id id) {
+ this.id = id;
+ }
+
+ public Namespace getNamespace() {
+ return namespace;
+ }
+
+ public void setNamespace(Namespace namespace) {
+ this.namespace = namespace;
+ }
+
+ public Info getInfo() {
+ return info;
+ }
+
+ public void setInfo(Info info) {
+ this.info = info;
+ }
+
+ public Collection<Relation> getRelations() {
+ return relations;
+ }
+
+ public void setRelations(Collection<Relation> relations) {
+ this.relations = relations;
+ }
+
+ public ByteBuffer getData() {
+ return data;
+ }
+
+ public void setData(ByteBuffer data) {
+ this.data = data;
+ }
+
+ public ByteBuffer getSearchableData() {
+ return searchableData;
+ }
+
+ public void setSearchableData(ByteBuffer searchableData) {
+ this.searchableData = searchableData;
+ }
+
+ public ByteBuffer getVisualization() {
+ return visualization;
+ }
+
+ public void setVisualization(ByteBuffer visualization) {
+ this.visualization = visualization;
+ }
+
+ public Set<Id> getSubElementIds() {
+ return subElementIds;
+ }
+
+ public void setSubElementIds(Set<Id> subElementIds) {
+ this.subElementIds = subElementIds;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ ElementEntity that = (ElementEntity) o;
+
+ return id.equals(that.id);
+ }
+
+ @Override
+ public int hashCode() {
+ return id.hashCode();
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/main/CassandraCollaborationStorePluginImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/main/CassandraCollaborationStorePluginImpl.java
new file mode 100644
index 0000000000..4bf9a8d25e
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/main/CassandraCollaborationStorePluginImpl.java
@@ -0,0 +1,160 @@
+/*
+ * Copyright © 2016-2017 European Support Limited
+ *
+ * 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.
+ */
+
+package org.openecomp.core.zusammen.plugin.main;
+
+import com.amdocs.zusammen.commons.health.data.HealthInfo;
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.Namespace;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.item.ElementContext;
+import com.amdocs.zusammen.datatypes.item.Info;
+import com.amdocs.zusammen.datatypes.item.ItemVersionData;
+import com.amdocs.zusammen.datatypes.itemversion.ItemVersionHistory;
+import com.amdocs.zusammen.datatypes.itemversion.Tag;
+import com.amdocs.zusammen.datatypes.response.Response;
+import com.amdocs.zusammen.datatypes.response.ZusammenException;
+import com.amdocs.zusammen.sdk.collaboration.CollaborationStore;
+import com.amdocs.zusammen.sdk.collaboration.types.CollaborationElement;
+import com.amdocs.zusammen.sdk.collaboration.types.CollaborationMergeChange;
+import com.amdocs.zusammen.sdk.collaboration.types.CollaborationMergeResult;
+import com.amdocs.zusammen.sdk.collaboration.types.CollaborationPublishResult;
+import org.openecomp.core.zusammen.plugin.collaboration.ElementCollaborationStore;
+import org.openecomp.core.zusammen.plugin.collaboration.VersionCollaborationStore;
+
+import java.util.Collection;
+
+public class CassandraCollaborationStorePluginImpl implements CollaborationStore {
+
+ private VersionCollaborationStore versionCollaborationStore = new VersionCollaborationStore();
+ private ElementCollaborationStore elementCollaborationStore = new ElementCollaborationStore();
+
+ @Override
+ public Response<Void> createItem(SessionContext context, Id id, Info info) {
+ // done by state store
+ return new Response(Void.TYPE);
+ }
+
+ @Override
+ public Response<Void> deleteItem(SessionContext context, Id id) {
+ // done by state store
+ return new Response(Void.TYPE);
+ }
+
+ @Override
+ public Response<Void> createItemVersion(SessionContext context, Id itemId, Id versionId, Id id2,
+ ItemVersionData itemVersionData) {
+ // done by state store
+ return new Response(Void.TYPE);
+ }
+
+ @Override
+ public Response<Void> updateItemVersion(SessionContext context, Id itemId, Id versionId,
+ ItemVersionData itemVersionData) {
+ // done by state store
+ return new Response(Void.TYPE);
+ }
+
+ @Override
+ public Response<Void> deleteItemVersion(SessionContext context, Id itemId, Id versionId) {
+ // done by state store
+ return new Response(Void.TYPE);
+ }
+
+ @Override
+ public Response<Void> tagItemVersion(SessionContext context, Id itemId, Id versionId, Id changeId,
+ Tag tag) {
+ versionCollaborationStore.tagItemVersion(context, itemId, versionId, changeId, tag);
+ return new Response(Void.TYPE);
+ }
+
+ @Override
+ public Response<CollaborationPublishResult> publishItemVersion(SessionContext context,
+ Id itemId, Id versionId,
+ String s) {
+ throw new UnsupportedOperationException("publishItemVersion");
+ }
+
+ @Override
+ public Response<CollaborationMergeResult> syncItemVersion(SessionContext context, Id id,
+ Id id1) {
+ throw new UnsupportedOperationException("syncItemVersion");
+ }
+
+ @Override
+ public Response<CollaborationMergeResult> mergeItemVersion(SessionContext context, Id id,
+ Id id1, Id id2) {
+ throw new UnsupportedOperationException("mergeItemVersion");
+ }
+
+ @Override
+ public Response<ItemVersionHistory> listItemVersionHistory(SessionContext context, Id id,
+ Id id1) {
+ throw new UnsupportedOperationException("listItemVersionHistory");
+ }
+
+ @Override
+ public Response<CollaborationMergeChange> resetItemVersionHistory(SessionContext context,
+ Id itemId, Id versionId,
+ String changeRef) {
+ return new Response<>(versionCollaborationStore.resetItemVersionHistory(context, itemId, versionId, changeRef));
+ }
+
+ @Override
+ public Response<Collection<CollaborationElement>> listElements(SessionContext context,
+ ElementContext elementContext,
+ Namespace namespace,
+ Id elementId) {
+ return new Response<>(
+ elementCollaborationStore.listElements(context, elementContext, elementId));
+ }
+
+ @Override
+ public Response<CollaborationElement> getElement(SessionContext context,
+ ElementContext elementContext,
+ Namespace namespace, Id elementId) {
+ return new Response<>(elementCollaborationStore.getElement(context, elementContext, elementId));
+ }
+
+ @Override
+ public Response<Void> createElement(SessionContext context, CollaborationElement element) {
+ elementCollaborationStore.createElement(context, element);
+ return new Response(Void.TYPE);
+ }
+
+ @Override
+ public Response<Void> updateElement(SessionContext context, CollaborationElement element) {
+ elementCollaborationStore.updateElement(context, element);
+ return new Response(Void.TYPE);
+ }
+
+ @Override
+ public Response<Void> deleteElement(SessionContext context, CollaborationElement element) {
+ elementCollaborationStore.deleteElement(context, element);
+ return new Response(Void.TYPE);
+ }
+
+ @Override
+ public Response<Void> commitElements(SessionContext context, Id itemId, Id versionId, String s) {
+ // not needed
+ return new Response(Void.TYPE);
+ }
+
+ @Override
+ public Response<HealthInfo> checkHealth(SessionContext sessionContext) throws ZusammenException {
+ return null;
+ }
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/main/CassandraStateStorePluginImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/main/CassandraStateStorePluginImpl.java
new file mode 100644
index 0000000000..b4767b2872
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/main/CassandraStateStorePluginImpl.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright © 2016-2017 European Support Limited
+ *
+ * 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.
+ */
+
+package org.openecomp.core.zusammen.plugin.main;
+
+
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.response.Response;
+import com.amdocs.zusammen.plugin.statestore.cassandra.StateStoreImpl;
+import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
+import com.amdocs.zusammen.sdk.state.types.StateElement;
+import org.openecomp.core.zusammen.plugin.dao.ElementRepositoryFactory;
+import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
+
+import static org.openecomp.core.zusammen.plugin.ZusammenPluginUtil.getSpaceName;
+
+public class CassandraStateStorePluginImpl extends StateStoreImpl {
+
+ @Override
+ public Response<Void> createElement(SessionContext context, StateElement element) {
+ ElementEntity elementEntity = new ElementEntity(element.getId());
+ elementEntity.setNamespace(element.getNamespace());
+
+ ElementRepositoryFactory.getInstance().createInterface(context)
+ .createNamespace(context,
+ new ElementEntityContext(getSpaceName(context, element.getSpace()),
+ element.getItemId(), element.getVersionId()),
+ elementEntity);
+ // create element is done by collaboration store
+ return new Response(Void.TYPE);
+ }
+
+ @Override
+ public Response<Void> updateElement(SessionContext context, StateElement element) {
+ // done by collaboration store
+ return new Response(Void.TYPE);
+ }
+
+ @Override
+ public Response<Void> deleteElement(SessionContext context, StateElement element) {
+ // done by collaboration store
+ return new Response(Void.TYPE);
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/resources/factoryConfiguration.json b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/resources/factoryConfiguration.json
new file mode 100644
index 0000000000..cd1e293b4b
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/resources/factoryConfiguration.json
@@ -0,0 +1,3 @@
+{
+ "org.openecomp.core.zusammen.plugin.dao.ElementRepositoryFactory": "org.openecomp.core.zusammen.plugin.dao.impl.CassandraElementRepositoryFactory"
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/resources/zusammen.json b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/resources/zusammen.json
new file mode 100644
index 0000000000..e90d80f016
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/resources/zusammen.json
@@ -0,0 +1,23 @@
+{
+ "configuration": {
+ "level": 10,
+ "plugins": {
+ "zusammen_state_store": {
+ "implementationClass": "org.openecomp.core.zusammen.plugin.main.CassandraStateStorePluginImpl"
+ },
+ "zusammen_collaborative_store": {
+ "implementationClass": "org.openecomp.core.zusammen.plugin.main.CassandraCollaborationStorePluginImpl",
+ "properties": {
+ "master.branch": "main",
+ "private.path": "C:\\git\\private",
+ "public.path": "C:\\git\\public",
+ "blueprint.path": "C:\\git\\BP",
+ "public.url": "C:\\git\\public"
+ }
+ }
+ },
+ "properties": {
+
+ }
+ }
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/pom.xml b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/pom.xml
new file mode 100644
index 0000000000..6cded9524b
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/pom.xml
@@ -0,0 +1,24 @@
+<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>
+
+ <name>openecomp-zusammen-lib</name>
+ <artifactId>openecomp-zusammen-lib</artifactId>
+ <groupId>org.openecomp.core</groupId>
+ <packaging>pom</packaging>
+ <parent>
+ <groupId>org.openecomp.core</groupId>
+ <artifactId>openecomp-core-lib</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+
+ </parent>
+
+ <modules>
+ <module>openecomp-zusammen-api</module>
+ <module>openecomp-zusammen-core</module>
+ <module>openecomp-zusammen-plugin</module>
+ </modules>
+
+
+</project> \ No newline at end of file