summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin')
-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
15 files changed, 1170 insertions, 0 deletions
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