diff --git a/catalog-dao/pom.xml b/catalog-dao/pom.xml
index ee2da54..3e04560 100644
--- a/catalog-dao/pom.xml
+++ b/catalog-dao/pom.xml
@@ -230,11 +230,10 @@
 			<scope>test</scope>
 		</dependency>
 
-		<!-- TITAN -->
 		<dependency>
-			<groupId>com.thinkaurelius.titan</groupId>
-			<artifactId>titan-core</artifactId>
-			<version>${titan.version}</version>
+			<groupId>org.janusgraph</groupId>
+			<artifactId>janusgraph-core</artifactId>
+			<version>${janusgraph.version}</version>
 			<scope>provided</scope>
 			<exclusions>
 				<exclusion>
@@ -257,9 +256,9 @@
 		</dependency>
 
 		<dependency>
-			<groupId>org.onap.sdc.sdc-titan-cassandra</groupId>
-			<artifactId>sdc-titan-cassandra</artifactId>
-			<version>${sdc.titan.version}</version>
+			<groupId>org.janusgraph</groupId>
+			<artifactId>janusgraph-cassandra</artifactId>
+			<version>${janusgraph.version}</version>
 			<scope>provided</scope>
 			<exclusions>
 				<exclusion>
@@ -275,7 +274,6 @@
 			<version>${lang3.version}</version>
 			<scope>provided</scope>
 		</dependency>
-		<!-- TITAN END -->
 
 		<!-- CASSANDRA -->
 		<dependency>
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/DAOTitanStrategy.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/DAOJanusGraphStrategy.java
similarity index 91%
rename from catalog-dao/src/main/java/org/openecomp/sdc/be/dao/DAOTitanStrategy.java
rename to catalog-dao/src/main/java/org/openecomp/sdc/be/dao/DAOJanusGraphStrategy.java
index 2452245..1a96ebf 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/DAOTitanStrategy.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/DAOJanusGraphStrategy.java
@@ -22,11 +22,11 @@
 
 import org.openecomp.sdc.be.config.ConfigurationManager;
 
-public class DAOTitanStrategy implements TitanClientStrategy {
+public class DAOJanusGraphStrategy implements JanusGraphClientStrategy {
 
     @Override
     public String getConfigFile() {
-        return ConfigurationManager.getConfigurationManager().getConfiguration().getTitanCfgFile();
+        return ConfigurationManager.getConfigurationManager().getConfiguration().getJanusGraphCfgFile();
     }
 
 }
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/TitanClientStrategy.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/JanusGraphClientStrategy.java
similarity index 95%
rename from catalog-dao/src/main/java/org/openecomp/sdc/be/dao/TitanClientStrategy.java
rename to catalog-dao/src/main/java/org/openecomp/sdc/be/dao/JanusGraphClientStrategy.java
index 36aaec8..14e12e9 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/TitanClientStrategy.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/JanusGraphClientStrategy.java
@@ -20,7 +20,7 @@
 
 package org.openecomp.sdc.be.dao;
 
-public interface TitanClientStrategy {
+public interface JanusGraphClientStrategy {
 
     String getConfigFile();
 
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaBuilder.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaBuilder.java
index 5af12a8..53d71fe 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaBuilder.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaBuilder.java
@@ -120,7 +120,7 @@
 			Map<String, Map<String, List<String>>> cassndraMetadata = parseKeyspaceMetadata(keyspacesMetadateFromCassandra);
       log.info("Cassandra Metadata: {}" ,cassndraMetadata);
       cassndraMetadata.forEach((k, v) -> {
-				if (AuditingTypesConstants.TITAN_KEYSPACE.equals(k)) {
+				if (AuditingTypesConstants.janusGraph_KEYSPACE.equals(k)) {
 					// session.execute("")
 				} else if (AuditingTypesConstants.ARTIFACT_KEYSPACE.equals(k)) {
 
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/DAOSpringConfig.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/DAOSpringConfig.java
index 99acb3b..e40b5aa 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/DAOSpringConfig.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/DAOSpringConfig.java
@@ -26,7 +26,7 @@
 import org.springframework.context.annotation.PropertySource;
 
 @Configuration
-@Import({TitanSpringConfig.class})
+@Import({JanusGraphSpringConfig.class})
 @ComponentScan({
         "org.openecomp.sdc.be.dao.cassandra",
         "org.openecomp.sdc.be.dao.neo4j",
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/JanusGraphSpringConfig.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/JanusGraphSpringConfig.java
new file mode 100644
index 0000000..d30caf1
--- /dev/null
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/JanusGraphSpringConfig.java
@@ -0,0 +1,54 @@
+package org.openecomp.sdc.be.dao.config;
+
+import org.openecomp.sdc.be.dao.DAOJanusGraphStrategy;
+import org.openecomp.sdc.be.dao.JanusGraphClientStrategy;
+import org.openecomp.sdc.be.dao.impl.HealingPipelineDao;
+import org.openecomp.sdc.be.dao.janusgraph.HealingJanusGraphGenericDao;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphClient;
+import org.openecomp.sdc.be.dao.janusgraph.transactions.SimpleJanusGraphTransactionManager;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+import org.springframework.transaction.PlatformTransactionManager;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+
+@Configuration
+@ComponentScan({
+        "org.openecomp.sdc.be.dao.jsongraph",
+})
+@EnableTransactionManagement
+public class JanusGraphSpringConfig {
+
+    @Bean(name = "janusgraph-generic-dao")
+    @Primary
+    public HealingJanusGraphGenericDao janusGraphGenericDao(@Qualifier("janusgraph-client") JanusGraphClient janusGraphClient) {
+        return new HealingJanusGraphGenericDao(janusGraphClient);
+    }
+
+    @Bean(name = "janusgraph-client", initMethod = "createGraph")
+    @Primary
+    public JanusGraphClient janusGraphClient(@Qualifier("dao-client-strategy")
+                                                 JanusGraphClientStrategy janusGraphClientStrategy) {
+        return new JanusGraphClient(janusGraphClientStrategy);
+    }
+
+    @Bean(name = "dao-client-strategy")
+    public JanusGraphClientStrategy janusGraphClientStrategy() {
+        return new DAOJanusGraphStrategy();
+    }
+
+    @Bean
+    public PlatformTransactionManager txManager() {
+        return new SimpleJanusGraphTransactionManager(janusGraphClient(janusGraphClientStrategy()));
+    }
+
+    @Bean(name = "healingPipelineDao")
+    public HealingPipelineDao  healingPipeline(){
+        HealingPipelineDao healingPipelineDao = new HealingPipelineDao();
+        healingPipelineDao.setHealVersion(1);
+        healingPipelineDao.initHealVersion();
+        return healingPipelineDao;
+    }
+}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/TitanSpringConfig.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/TitanSpringConfig.java
deleted file mode 100644
index 34a860d..0000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/TitanSpringConfig.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package org.openecomp.sdc.be.dao.config;
-
-import org.openecomp.sdc.be.dao.DAOTitanStrategy;
-import org.openecomp.sdc.be.dao.TitanClientStrategy;
-import org.openecomp.sdc.be.dao.impl.HealingPipelineDao;
-import org.openecomp.sdc.be.dao.titan.HealingTitanGenericDao;
-import org.openecomp.sdc.be.dao.titan.TitanGraphClient;
-import org.openecomp.sdc.be.dao.titan.transactions.SimpleTitanTransactionManager;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.ComponentScan;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Primary;
-import org.springframework.transaction.PlatformTransactionManager;
-import org.springframework.transaction.annotation.EnableTransactionManagement;
-
-@Configuration
-@ComponentScan({
-        "org.openecomp.sdc.be.dao.jsongraph",
-})
-@EnableTransactionManagement
-public class TitanSpringConfig {
-
-    @Bean(name = "titan-generic-dao")
-    @Primary
-    public HealingTitanGenericDao titanGenericDao(@Qualifier("titan-client") TitanGraphClient titanGraphClient) {
-        return new HealingTitanGenericDao(titanGraphClient);
-    }
-
-    @Bean(name = "titan-client", initMethod = "createGraph")
-    @Primary
-    public TitanGraphClient titanGraphClient(@Qualifier("dao-client-strategy") TitanClientStrategy titanClientStrategy) {
-        return new TitanGraphClient(titanClientStrategy);
-    }
-
-    @Bean(name = "dao-client-strategy")
-    public TitanClientStrategy titanClientStrategy() {
-        return new DAOTitanStrategy();
-    }
-
-    @Bean
-    public PlatformTransactionManager txManager() {
-        return new SimpleTitanTransactionManager(titanGraphClient(titanClientStrategy()));
-    }
-
-    @Bean(name = "healingPipelineDao")
-    public HealingPipelineDao  healingPipeline(){
-        HealingPipelineDao healingPipelineDao = new HealingPipelineDao();
-        healingPipelineDao.setHealVersion(1);
-        healingPipelineDao.initHealVersion();
-        return healingPipelineDao;
-    }
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/HealingPipelineDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/HealingPipelineDao.java
index 5b219b2..f757b58 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/HealingPipelineDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/HealingPipelineDao.java
@@ -20,7 +20,7 @@
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableListMultimap;
-import com.thinkaurelius.titan.core.TitanVertex;
+import org.janusgraph.core.JanusGraphVertex;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
@@ -33,7 +33,7 @@
 import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
 import org.openecomp.sdc.be.dao.impl.heal.HealGraphDao;
 import org.openecomp.sdc.be.dao.impl.heal.HealNodeGraphDao;
-import org.openecomp.sdc.be.dao.impl.heal.HealTitanGraphDao;
+import org.openecomp.sdc.be.dao.impl.heal.HealJanusGraphDao;
 import org.openecomp.sdc.be.dao.impl.heal.HealVertexGraphDao;
 import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
 import org.openecomp.sdc.be.dao.jsongraph.heal.Heal;
@@ -58,7 +58,7 @@
 
     private HealGraphDao healNodeGraphDao;
     private HealGraphDao healVertexGraphDao;
-    private HealGraphDao healTitanVertexGraphDao;
+    private HealGraphDao healJanusGraphVertexGraphDao;
 
     public HealingPipelineDao() {
         healingPipeline = ImmutableListMultimap.of();
@@ -74,7 +74,7 @@
     public void initGraphHealers() {
         healNodeGraphDao = new HealNodeGraphDao(this);
         healVertexGraphDao = new HealVertexGraphDao(this);
-        healTitanVertexGraphDao = new HealTitanGraphDao(this);
+        healJanusGraphVertexGraphDao = new HealJanusGraphDao(this);
     }
 
 
@@ -85,8 +85,8 @@
         if (graphNode instanceof GraphElement) {
             return healNodeGraphDao;
         }
-        if (graphNode instanceof TitanVertex) {
-            return healTitanVertexGraphDao;
+        if (graphNode instanceof JanusGraphVertex) {
+            return healJanusGraphVertexGraphDao;
         }
 
         return null;
@@ -133,7 +133,7 @@
         graphVertex.addMetadataProperty(GraphPropertyEnum.HEALING_VERSION, currentHealVersion.getVersion());
     }
 
-    public void setHealingVersion(TitanVertex graphVertex) {
+    public void setHealingVersion(JanusGraphVertex graphVertex) {
         graphVertex.property(GraphPropertyEnum.HEALING_VERSION.getProperty(), currentHealVersion.getVersion());
     }
 
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealTitanGraphDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealJanusGraphDao.java
similarity index 78%
rename from catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealTitanGraphDao.java
rename to catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealJanusGraphDao.java
index 1e33c61..76be4a6 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealTitanGraphDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealJanusGraphDao.java
@@ -1,6 +1,6 @@
 package org.openecomp.sdc.be.dao.impl.heal;
 
-import com.thinkaurelius.titan.core.TitanVertex;
+import org.janusgraph.core.JanusGraphVertex;
 import org.openecomp.sdc.be.dao.impl.HealingPipelineDao;
 import org.openecomp.sdc.be.dao.jsongraph.heal.Heal;
 import org.openecomp.sdc.be.dao.jsongraph.heal.HealConstants;
@@ -9,16 +9,16 @@
 import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
 import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
 
-public class HealTitanGraphDao implements HealGraphDao<TitanVertex, GraphEdgeLabels> {
+public class HealJanusGraphDao implements HealGraphDao<JanusGraphVertex, GraphEdgeLabels> {
 
     private HealingPipelineDao healingPipelineDao;
 
-    public HealTitanGraphDao(HealingPipelineDao healingPipelineDao) {
+    public HealJanusGraphDao(HealingPipelineDao healingPipelineDao) {
         this.healingPipelineDao = healingPipelineDao;
     }
 
     @Override
-    public TitanVertex performGraphReadHealing(TitanVertex childVertex, GraphEdgeLabels graphEdgeLabels) {
+    public JanusGraphVertex performGraphReadHealing(JanusGraphVertex childVertex, GraphEdgeLabels graphEdgeLabels) {
         final Integer healingVersionInt = (Integer) childVertex.property(GraphPropertyEnum.HEALING_VERSION.getProperty()).orElse(HealConstants.DEFAULT_HEAL_VERSION);
         HealVersion<Integer> healingVersion = HealVersionBuilder.build(healingVersionInt);
         healingPipelineDao.getHealersForVertex(graphEdgeLabels.name(), healingVersion).forEach(heal -> healGraphVertex(childVertex, heal));
@@ -27,7 +27,7 @@
     }
 
 
-    private TitanVertex healGraphVertex(TitanVertex childVertex, Heal<TitanVertex> heal) {
+    private JanusGraphVertex healGraphVertex(JanusGraphVertex childVertex, Heal<JanusGraphVertex> heal) {
         heal.healData(childVertex);
         final HealVersion<Integer> healVersion = heal.fromVersion();
         HealVersion newerVersion = HealVersionBuilder.build(healVersion.getVersion() + 1);
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealNodeGraphDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealNodeGraphDao.java
index 2fc5c8f..9bc75a0 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealNodeGraphDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealNodeGraphDao.java
@@ -20,12 +20,12 @@
     public GraphNode performGraphReadHealing(GraphNode childVertex, GraphEdge graphEdge) {
         Integer healingVersionInt =  childVertex.getHealingVersion();
         HealVersion<Integer> healingVersion = HealVersionBuilder.build(healingVersionInt);
-        healingPipelineDao.getHealersForVertex(graphEdge.getEdgeType().getProperty(), healingVersion).forEach(heal -> healTitanVertex(childVertex, heal));
+        healingPipelineDao.getHealersForVertex(graphEdge.getEdgeType().getProperty(), healingVersion).forEach(heal -> healJanusGraphVertex(childVertex, heal));
         childVertex.setHealingVersion(healingPipelineDao.getCurrentHealVersion().getVersion());
         return childVertex;
     }
 
-    private GraphNode healTitanVertex(GraphNode childVertex, Heal<GraphNode> heal) {
+    private GraphNode healJanusGraphVertex(GraphNode childVertex, Heal<GraphNode> heal) {
         heal.healData(childVertex);
         final HealVersion<Integer> healVersion = heal.fromVersion();
         HealVersion<Integer> newerVersion = HealVersionBuilder.build(healVersion.getVersion() + 1);
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/HealingTitanGenericDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/HealingJanusGraphGenericDao.java
similarity index 66%
rename from catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/HealingTitanGenericDao.java
rename to catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/HealingJanusGraphGenericDao.java
index 37546a5..f8ab531 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/HealingTitanGenericDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/HealingJanusGraphGenericDao.java
@@ -13,9 +13,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.openecomp.sdc.be.dao.titan;
+package org.openecomp.sdc.be.dao.janusgraph;
 
-import com.thinkaurelius.titan.core.TitanVertex;
+import org.janusgraph.core.JanusGraphVertex;
 import fj.data.Either;
 import java.util.List;
 import org.apache.commons.lang3.tuple.ImmutablePair;
@@ -25,9 +25,7 @@
 import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge;
 import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
 import org.openecomp.sdc.be.dao.impl.HealingPipelineDao;
-import org.openecomp.sdc.be.dao.jsongraph.heal.Heal;
 import org.openecomp.sdc.be.dao.jsongraph.heal.HealConstants;
-import org.openecomp.sdc.be.dao.jsongraph.heal.HealVersion;
 import org.openecomp.sdc.be.dao.jsongraph.heal.HealVersionBuilder;
 import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
 import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
@@ -35,28 +33,28 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
-@Component("titan-generic-dao")
-public class HealingTitanGenericDao extends TitanGenericDao {
+@Component("janusgraph-generic-dao")
+public class HealingJanusGraphGenericDao extends JanusGraphGenericDao {
 
     @Autowired
     private HealingPipelineDao healingPipelineDao;
 
-    public HealingTitanGenericDao(TitanGraphClient titanClient) {
-        super(titanClient);
+    public HealingJanusGraphGenericDao(JanusGraphClient janusGraphClient) {
+        super(janusGraphClient);
     }
 
     @Override
-    public ImmutablePair<TitanVertex, Edge> getChildVertex(TitanVertex childVertex, GraphEdgeLabels edgeType) {
-        ImmutablePair<TitanVertex, Edge> childVertexEdgeImmutablePair = super.getChildVertex(childVertex, edgeType);
-        final TitanVertex graphVertex = childVertexEdgeImmutablePair.left;
+    public ImmutablePair<JanusGraphVertex, Edge> getChildVertex(JanusGraphVertex childVertex, GraphEdgeLabels edgeType) {
+        ImmutablePair<JanusGraphVertex, Edge> childVertexEdgeImmutablePair = super.getChildVertex(childVertex, edgeType);
+        final JanusGraphVertex graphVertex = childVertexEdgeImmutablePair.left;
         healingPipelineDao.performGraphReadHealing(graphVertex, edgeType);
         healingPipelineDao.setHealingVersion(graphVertex);
         return childVertexEdgeImmutablePair;
     }
 
     @Override
-    public <T extends GraphNode> Either<List<ImmutablePair<T, GraphEdge>>, TitanOperationStatus> getChildrenNodes(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz, boolean withEdges) {
-        Either<List<ImmutablePair<T, GraphEdge>>, TitanOperationStatus> either = super.getChildrenNodes(key, uniqueId, edgeType, nodeTypeEnum, clazz, withEdges);
+    public <T extends GraphNode> Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> getChildrenNodes(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz, boolean withEdges) {
+        Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> either = super.getChildrenNodes(key, uniqueId, edgeType, nodeTypeEnum, clazz, withEdges);
         if (either.isRight()) {
             return either;
         }
@@ -66,8 +64,8 @@
     }
 
     @Override
-    public <T extends GraphNode> Either<ImmutablePair<T, GraphEdge>, TitanOperationStatus> getChild(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz) {
-        Either<ImmutablePair<T, GraphEdge>, TitanOperationStatus> eitherChild = super.getChild(key, uniqueId, edgeType, nodeTypeEnum, clazz);
+    public <T extends GraphNode> Either<ImmutablePair<T, GraphEdge>, JanusGraphOperationStatus> getChild(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz) {
+        Either<ImmutablePair<T, GraphEdge>, JanusGraphOperationStatus> eitherChild = super.getChild(key, uniqueId, edgeType, nodeTypeEnum, clazz);
         if (eitherChild.isRight()) {
             return eitherChild;
         }
@@ -89,19 +87,19 @@
     }
 
     @Override
-    public Either<List<ImmutablePair<TitanVertex, Edge>>, TitanOperationStatus> getChildrenVertecies(String key, String uniqueId, GraphEdgeLabels edgeType) {
-        Either<List<ImmutablePair<TitanVertex, Edge>>, TitanOperationStatus> either = super.getChildrenVertecies(key, uniqueId, edgeType);
+    public Either<List<ImmutablePair<JanusGraphVertex, Edge>>, JanusGraphOperationStatus> getChildrenVertecies(String key, String uniqueId, GraphEdgeLabels edgeType) {
+        Either<List<ImmutablePair<JanusGraphVertex, Edge>>, JanusGraphOperationStatus> either = super.getChildrenVertecies(key, uniqueId, edgeType);
         if (either.isRight()) {
             return either;
         }
-        List<ImmutablePair<TitanVertex, Edge>> list = either.left().value();
+        List<ImmutablePair<JanusGraphVertex, Edge>> list = either.left().value();
         list.forEach(this::transformVertexPair);
         return either;
     }
 
-    private void transformVertexPair(ImmutablePair<TitanVertex, Edge> either) {
+    private void transformVertexPair(ImmutablePair<JanusGraphVertex, Edge> either) {
         String edgeType = either.right.label();
-        TitanVertex childVertex = either.left;
+        JanusGraphVertex childVertex = either.left;
         VertexProperty<Integer> healingVersionProperty = childVertex.property(GraphPropertyEnum.HEALING_VERSION.getProperty());
         Integer healingVersioInt = healingVersionProperty.orElse(HealConstants.DEFAULT_HEAL_VERSION);
         HealVersionBuilder.build(healingVersioInt);
@@ -110,13 +108,13 @@
     }
 
     @Override
-    public <T extends GraphNode> Either<T, TitanOperationStatus> updateNode(GraphNode node, Class<T> clazz) {
+    public <T extends GraphNode> Either<T, JanusGraphOperationStatus> updateNode(GraphNode node, Class<T> clazz) {
         healingPipelineDao.setHealingVersion(node);
         return super.updateNode(node, clazz);
     }
 
     @Override
-    public TitanOperationStatus updateVertex(GraphNode node, Vertex vertex) {
+    public JanusGraphOperationStatus updateVertex(GraphNode node, Vertex vertex) {
         healingPipelineDao.setHealingVersion(node);
         return super.updateVertex(node, vertex);
     }
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanGraphClient.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphClient.java
similarity index 61%
rename from catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanGraphClient.java
rename to catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphClient.java
index 9d5ff9d..5be907c 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanGraphClient.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphClient.java
@@ -18,24 +18,24 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.openecomp.sdc.be.dao.titan;
+package org.openecomp.sdc.be.dao.janusgraph;
 
-import com.thinkaurelius.titan.core.*;
-import com.thinkaurelius.titan.core.schema.ConsistencyModifier;
-import com.thinkaurelius.titan.core.schema.TitanGraphIndex;
-import com.thinkaurelius.titan.core.schema.TitanManagement;
-import com.thinkaurelius.titan.core.util.TitanCleanup;
-import com.thinkaurelius.titan.diskstorage.ResourceUnavailableException;
-import com.thinkaurelius.titan.diskstorage.locking.PermanentLockingException;
-import com.thinkaurelius.titan.graphdb.database.idassigner.IDPoolExhaustedException;
+import org.janusgraph.core.*;
+import org.janusgraph.core.schema.ConsistencyModifier;
+import org.janusgraph.core.schema.JanusGraphIndex;
+import org.janusgraph.core.schema.JanusGraphManagement;
+import org.janusgraph.diskstorage.BackendException;
+import org.janusgraph.diskstorage.ResourceUnavailableException;
+import org.janusgraph.diskstorage.locking.PermanentLockingException;
+import org.janusgraph.graphdb.database.idassigner.IDPoolExhaustedException;
 import fj.data.Either;
 import org.apache.commons.configuration.BaseConfiguration;
 import org.apache.tinkerpop.gremlin.structure.T;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.openecomp.sdc.be.config.BeEcompErrorManager;
 import org.openecomp.sdc.be.config.ConfigurationManager;
-import org.openecomp.sdc.be.dao.DAOTitanStrategy;
-import org.openecomp.sdc.be.dao.TitanClientStrategy;
+import org.openecomp.sdc.be.dao.DAOJanusGraphStrategy;
+import org.openecomp.sdc.be.dao.JanusGraphClientStrategy;
 import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -47,23 +47,23 @@
 import java.util.concurrent.*;
 
 
-@Component("titan-client")
-public class TitanGraphClient {
-	private static Logger logger = LoggerFactory.getLogger(TitanGraphClient.class.getName());
-	private static Logger healthLogger = LoggerFactory.getLogger("titan.healthcheck");
+@Component("janusgraph-client")
+public class JanusGraphClient {
+	private static Logger logger = LoggerFactory.getLogger(JanusGraphClient.class.getName());
+	private static Logger healthLogger = LoggerFactory.getLogger("janusgraph.healthcheck");
 
 	private static final String HEALTH_CHECK = GraphPropertiesDictionary.HEALTH_CHECK.getProperty();
 	private static final String OK = "GOOD";
 
-	public TitanGraphClient() {
+	public JanusGraphClient() {
 	}
 
 	private class HealthCheckTask implements Callable<Vertex> {
 		@Override
 		public Vertex call() {
 
-			TitanVertex v = (TitanVertex) graph.query().has(HEALTH_CHECK, OK).vertices().iterator().next();
-			TitanVertexProperty<String> property = v.property("healthcheck", OK + "_" + System.currentTimeMillis());
+			JanusGraphVertex v = (JanusGraphVertex) graph.query().has(HEALTH_CHECK, OK).vertices().iterator().next();
+			JanusGraphVertexProperty<String> property = v.property("healthcheck", OK + "_" + System.currentTimeMillis());
 			healthLogger.trace("Health Check Node Found...{}", v.property(HEALTH_CHECK));
 			graph.tx().commit();
 
@@ -74,11 +74,11 @@
 	private class HealthCheckScheduledTask implements Runnable {
 		@Override
 		public void run() {
-			healthLogger.trace("Executing TITAN Health Check Task - Start");
+			healthLogger.trace("Executing janusGraph Health Check Task - Start");
 			boolean healthStatus = isGraphOpen();
-			healthLogger.trace("Executing TITAN Health Check Task - Status = {}", healthStatus);
+			healthLogger.trace("Executing janusGraph Health Check Task - Status = {}", healthStatus);
 			if (healthStatus != lastHealthState) {
-				logger.trace("TITAN  Health State Changed to {}. Issuing alarm / recovery alarm...", healthStatus);
+				logger.trace("janusGraph  Health State Changed to {}. Issuing alarm / recovery alarm...", healthStatus);
 				lastHealthState = healthStatus;
 				logAlarm();
 			}
@@ -88,14 +88,14 @@
 	private class ReconnectTask implements Runnable {
 		@Override
 		public void run() {
-			logger.trace("Trying to reconnect to Titan...");
+			logger.trace("Trying to reconnect to JanusGraph...");
 			if (graph == null) {
-				createGraph(titanCfgFile);
+				createGraph(janusGraphCfgFile);
 			}
 		}
 	}
 
-	private TitanGraph graph;
+	private JanusGraph graph;
 
 	// Health Check Variables
 
@@ -105,7 +105,7 @@
 	ExecutorService healthCheckExecutor = Executors.newSingleThreadExecutor(new ThreadFactory() {
 		@Override
 		public Thread newThread(Runnable r) {
-			return new Thread(r, "Titan-Health-Check-Thread");
+			return new Thread(r, "JanusGraph-Health-Check-Thread");
 		}
 	});
 	private long healthCheckReadTimeout = 2;
@@ -121,51 +121,51 @@
 	@SuppressWarnings("rawtypes")
 	private Future reconnectFuture;
 
-	private String titanCfgFile = null;
-	TitanClientStrategy titanClientStrategy;
+	private String janusGraphCfgFile = null;
+	JanusGraphClientStrategy janusGraphClientStrategy;
 
-	public TitanGraphClient(TitanClientStrategy titanClientStrategy) {
+	public JanusGraphClient(JanusGraphClientStrategy janusGraphClientStrategy) {
 		super();
-		this.titanClientStrategy = titanClientStrategy;
+		this.janusGraphClientStrategy = janusGraphClientStrategy;
 
 		// Initialize a single threaded scheduler for health-check
 		this.healthCheckScheduler = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
 			@Override
 			public Thread newThread(Runnable r) {
-				return new Thread(r, "Titan-Health-Check-Task");
+				return new Thread(r, "JanusGraph-Health-Check-Task");
 			}
 		});
 
-		healthCheckReadTimeout = ConfigurationManager.getConfigurationManager().getConfiguration().getTitanHealthCheckReadTimeout(2);
-		reconnectInterval = ConfigurationManager.getConfigurationManager().getConfiguration().getTitanReconnectIntervalInSeconds(3);
+		healthCheckReadTimeout = ConfigurationManager.getConfigurationManager().getConfiguration().getJanusGraphHealthCheckReadTimeout(2);
+		reconnectInterval = ConfigurationManager.getConfigurationManager().getConfiguration().getJanusGraphReconnectIntervalInSeconds(3);
 
-		logger.info("** TitanGraphClient created");
+		logger.info("** JanusGraphClient created");
 	}
 
 	@PostConstruct
-	public TitanOperationStatus createGraph() {
+	public JanusGraphOperationStatus createGraph() {
 
 		logger.info("** createGraph started **");
 
-		if (ConfigurationManager.getConfigurationManager().getConfiguration().getTitanInMemoryGraph()) {
+		if (ConfigurationManager.getConfigurationManager().getConfiguration().getJanusGraphInMemoryGraph()) {
 			BaseConfiguration conf = new BaseConfiguration();
 			conf.setProperty("storage.backend", "inmemory");
-			graph = TitanFactory.open(conf);
-            createTitanSchema(); 
+			graph = JanusGraphFactory.open(conf);
+            createJanusGraphSchema();
 			logger.info("** in memory graph created");
-			return TitanOperationStatus.OK;
+			return JanusGraphOperationStatus.OK;
 		} else {
-			this.titanCfgFile = titanClientStrategy.getConfigFile();
-			if (titanCfgFile == null || titanCfgFile.isEmpty()) {
-				titanCfgFile = "config/titan.properties";
+			this.janusGraphCfgFile = janusGraphClientStrategy.getConfigFile();
+			if (janusGraphCfgFile == null || janusGraphCfgFile.isEmpty()) {
+				janusGraphCfgFile = "config/janusgraph.properties";
 			}
 
 			// yavivi
 			// In case connection failed on init time, schedule a reconnect task
 			// in the BG
-			TitanOperationStatus status = createGraph(titanCfgFile);
-			logger.debug("Create Titan graph status {}", status);
-			if (status != TitanOperationStatus.OK) {
+			JanusGraphOperationStatus status = createGraph(janusGraphCfgFile);
+			logger.debug("Create JanusGraph graph status {}", status);
+			if (status != JanusGraphOperationStatus.OK) {
 				this.startReconnectTask();
 			}
 
@@ -178,7 +178,7 @@
 	}
 
 	/**
-	 * This method will be invoked ONLY on init time in case Titan storage is down.
+	 * This method will be invoked ONLY on init time in case JanusGraph storage is down.
 	 */
 	private void startReconnectTask() {
 		this.reconnectTask = new ReconnectTask();
@@ -186,7 +186,7 @@
 		this.reconnectScheduler = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
 			@Override
 			public Thread newThread(Runnable r) {
-				return new Thread(r, "Titan-Reconnect-Task");
+				return new Thread(r, "JanusGraph-Reconnect-Task");
 			}
 		});
 
@@ -198,45 +198,49 @@
 		if (graph != null) {
 			// graph.shutdown();
 			graph.close();
-			TitanCleanup.clear(graph);
+			try {
+				JanusGraphFactory.drop(graph);
+			} catch (BackendException e) {
+				e.printStackTrace();
+			}
 		}
 	}
 
 	private boolean graphInitialized(){
-		TitanManagement graphMgmt = graph.openManagement();
+		JanusGraphManagement graphMgmt = graph.openManagement();
 		return graphMgmt.containsPropertyKey(HEALTH_CHECK) && graphMgmt.containsGraphIndex(HEALTH_CHECK);
 	}
 	
 
-	public TitanOperationStatus createGraph(String titanCfgFile) {
-		logger.info("** open graph with {} started", titanCfgFile);
+	public JanusGraphOperationStatus createGraph(String janusGraphCfgFile) {
+		logger.info("** open graph with {} started", janusGraphCfgFile);
 		try {
-			logger.info("openGraph : try to load file {}", titanCfgFile);
-			graph = TitanFactory.open(titanCfgFile);
+			logger.info("openGraph : try to load file {}", janusGraphCfgFile);
+			graph = JanusGraphFactory.open(janusGraphCfgFile);
 			if (graph.isClosed() || !graphInitialized()) {
-				logger.error("titan graph was not initialized");
-				return TitanOperationStatus.NOT_CREATED;
+				logger.error("janusgraph graph was not initialized");
+				return JanusGraphOperationStatus.NOT_CREATED;
 			}
 
 		} catch (Exception e) {
 			this.graph = null;
-			logger.info("createGraph : failed to open Titan graph with configuration file: {}", titanCfgFile);
+			logger.info("createGraph : failed to open JanusGraph graph with configuration file: {}", janusGraphCfgFile);
 			logger.debug("createGraph : failed with exception.", e);
-			return TitanOperationStatus.NOT_CONNECTED;
+			return JanusGraphOperationStatus.NOT_CONNECTED;
 		}
 
-		logger.info("** Titan graph created ");
+		logger.info("** JanusGraph graph created ");
 
 		// Do some post creation actions
 		this.onGraphOpened();
 
-		return TitanOperationStatus.OK;
+		return JanusGraphOperationStatus.OK;
 	}
 
 	private void onGraphOpened() {
 		// if a reconnect task is running, cancel it.
 		if (this.reconnectFuture != null) {
-			logger.info("** Cancelling Titan reconnect task");
+			logger.info("** Cancelling JanusGraph reconnect task");
 			reconnectFuture.cancel(true);
 		}
 
@@ -254,72 +258,72 @@
 	}
 
 
-	public Either<TitanGraph, TitanOperationStatus> getGraph() {
+	public Either<JanusGraph, JanusGraphOperationStatus> getGraph() {
 		if (graph != null) {
 			return Either.left(graph);
 		} else {
-			return Either.right(TitanOperationStatus.NOT_CREATED);
+			return Either.right(JanusGraphOperationStatus.NOT_CREATED);
 		}
 	}
 
-	public TitanOperationStatus commit() {
+	public JanusGraphOperationStatus commit() {
 		if (graph != null) {
 			try {
 				graph.tx().commit();
-				return TitanOperationStatus.OK;
+				return JanusGraphOperationStatus.OK;
 			} catch (Exception e) {
-				return handleTitanException(e);
+				return handleJanusGraphException(e);
 			}
 		} else {
-			return TitanOperationStatus.NOT_CREATED;
+			return JanusGraphOperationStatus.NOT_CREATED;
 		}
 	}
 
-	public TitanOperationStatus rollback() {
+	public JanusGraphOperationStatus rollback() {
 		if (graph != null) {
 			try {
 				// graph.rollback();
 				graph.tx().rollback();
-				return TitanOperationStatus.OK;
+				return JanusGraphOperationStatus.OK;
 			} catch (Exception e) {
-				return handleTitanException(e);
+				return handleJanusGraphException(e);
 			}
 		} else {
-			return TitanOperationStatus.NOT_CREATED;
+			return JanusGraphOperationStatus.NOT_CREATED;
 		}
 	}
 
-	public static TitanOperationStatus handleTitanException(Exception e) {
-		if (e instanceof TitanConfigurationException) {
-			return TitanOperationStatus.TITAN_CONFIGURATION;
+	public static JanusGraphOperationStatus handleJanusGraphException(Exception e) {
+		if (e instanceof JanusGraphConfigurationException) {
+			return JanusGraphOperationStatus.JANUSGRAPH_CONFIGURATION;
 		}
 		if (e instanceof SchemaViolationException) {
-			return TitanOperationStatus.TITAN_SCHEMA_VIOLATION;
+			return JanusGraphOperationStatus.JANUSGRAPH_SCHEMA_VIOLATION;
 		}
 		if (e instanceof PermanentLockingException) {
-			return TitanOperationStatus.TITAN_SCHEMA_VIOLATION;
+			return JanusGraphOperationStatus.JANUSGRAPH_SCHEMA_VIOLATION;
 		}
 		if (e instanceof IDPoolExhaustedException) {
-			return TitanOperationStatus.GENERAL_ERROR;
+			return JanusGraphOperationStatus.GENERAL_ERROR;
 		}
 		if (e instanceof InvalidElementException) {
-			return TitanOperationStatus.INVALID_ELEMENT;
+			return JanusGraphOperationStatus.INVALID_ELEMENT;
 		}
 		if (e instanceof InvalidIDException) {
-			return TitanOperationStatus.INVALID_ID;
+			return JanusGraphOperationStatus.INVALID_ID;
 		}
 		if (e instanceof QueryException) {
-			return TitanOperationStatus.INVALID_QUERY;
+			return JanusGraphOperationStatus.INVALID_QUERY;
 		}
 		if (e instanceof ResourceUnavailableException) {
-			return TitanOperationStatus.RESOURCE_UNAVAILABLE;
+			return JanusGraphOperationStatus.RESOURCE_UNAVAILABLE;
 		}
 		if (e instanceof IllegalArgumentException) {
 			// TODO check the error message??
-			return TitanOperationStatus.ILLEGAL_ARGUMENT;
+			return JanusGraphOperationStatus.ILLEGAL_ARGUMENT;
 		}
 
-		return TitanOperationStatus.GENERAL_ERROR;
+		return JanusGraphOperationStatus.GENERAL_ERROR;
 	}
 
 	public boolean getHealth() {
@@ -327,7 +331,7 @@
 	}
 
 	private boolean isGraphOpen() {
-		healthLogger.trace("Invoking Titan health check ...");
+		healthLogger.trace("Invoking JanusGraph health check ...");
 		Vertex v = null;
 		if (graph != null) {
 			try {
@@ -340,7 +344,7 @@
 				if (message == null) {
 					message = e.getClass().getName();
 				}
-				logger.error("Titan Health Check Failed. {}", message);
+				logger.error("JanusGraph Health Check Failed. {}", message);
 				return false;
 			}
 			return true;
@@ -351,7 +355,7 @@
 
 
 	public static void main(String[] args) throws InterruptedException {
-		TitanGraphClient client = new TitanGraphClient(new DAOTitanStrategy());
+		JanusGraphClient client = new JanusGraphClient(new DAOJanusGraphStrategy());
 		client.createGraph();
 
 		while (true) {
@@ -363,20 +367,20 @@
 	}
 
 
-	private static final String TITAN_HEALTH_CHECK_STR = "titanHealthCheck";
+	private static final String JANUSGRAPH_HEALTH_CHECK = "janusgraphHealthCheck";
 
 	private void logAlarm() {
 		if (lastHealthState) {
-			BeEcompErrorManager.getInstance().logBeHealthCheckTitanRecovery(TITAN_HEALTH_CHECK_STR);
+			BeEcompErrorManager.getInstance().logBeHealthCheckJanusGraphRecovery(JANUSGRAPH_HEALTH_CHECK);
 		} else {
-			BeEcompErrorManager.getInstance().logBeHealthCheckTitanError(TITAN_HEALTH_CHECK_STR);
+			BeEcompErrorManager.getInstance().logBeHealthCheckJanusGraphError(JANUSGRAPH_HEALTH_CHECK);
 		}
 	}
 	
-	private void createTitanSchema() {
+	private void createJanusGraphSchema() {
 		
-		TitanManagement graphMgt = graph.openManagement();
-		TitanGraphIndex index = null;
+		JanusGraphManagement graphMgt = graph.openManagement();
+		JanusGraphIndex index = null;
 		for (GraphPropertiesDictionary prop : GraphPropertiesDictionary.values()) {
 			PropertyKey propKey = null;
 			if (!graphMgt.containsPropertyKey(prop.getProperty())) {
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanGenericDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphGenericDao.java
similarity index 64%
rename from catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanGenericDao.java
rename to catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphGenericDao.java
index 2123910..591d7f3 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanGenericDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphGenericDao.java
@@ -18,15 +18,15 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.openecomp.sdc.be.dao.titan;
+package org.openecomp.sdc.be.dao.janusgraph;
 
-import com.thinkaurelius.titan.core.PropertyKey;
-import com.thinkaurelius.titan.core.TitanEdge;
-import com.thinkaurelius.titan.core.TitanGraph;
-import com.thinkaurelius.titan.core.TitanGraphQuery;
-import com.thinkaurelius.titan.core.TitanVertex;
-import com.thinkaurelius.titan.core.TitanVertexQuery;
-import com.thinkaurelius.titan.graphdb.query.TitanPredicate;
+import org.janusgraph.core.PropertyKey;
+import org.janusgraph.core.JanusGraphEdge;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphQuery;
+import org.janusgraph.core.JanusGraphVertex;
+import org.janusgraph.core.JanusGraphVertexQuery;
+import org.janusgraph.graphdb.query.JanusGraphPredicate;
 import fj.data.Either;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -58,28 +58,28 @@
 import org.openecomp.sdc.common.log.wrappers.Logger;
 import org.springframework.beans.factory.annotation.Qualifier;
 
-public class TitanGenericDao {
+public class JanusGraphGenericDao {
 
 	private static final String FAILED_TO_RETRIEVE_GRAPH_STATUS_IS = "Failed to retrieve graph. status is {}";
     private static final String NO_EDGES_IN_GRAPH_FOR_CRITERIA = "No edges in graph for criteria";
     private static final String FAILED_TO_CREATE_EDGE_FROM_TO = "Failed to create edge from [{}] to [{}]";
-    private TitanGraphClient titanClient;
-	private static Logger log = Logger.getLogger(TitanGenericDao.class.getName());
+    private JanusGraphClient janusGraphClient;
+	private static Logger log = Logger.getLogger(JanusGraphGenericDao.class.getName());
 	private static final String LOCK_NODE_PREFIX = "lock_";
 
-	public TitanGenericDao(@Qualifier("titan-client") TitanGraphClient titanClient) {
-		this.titanClient = titanClient;
-		log.info("** TitanGenericDao created");
+	public JanusGraphGenericDao(@Qualifier("janusgraph-client") JanusGraphClient janusGraphClient) {
+		this.janusGraphClient = janusGraphClient;
+		log.info("** JanusGraphGenericDao created");
 	}
 
-	public TitanOperationStatus commit() {
+	public JanusGraphOperationStatus commit() {
 		log.debug("doing commit.");
-		return titanClient.commit();
+		return janusGraphClient.commit();
 	}
 
-	public TitanOperationStatus rollback() {
+	public JanusGraphOperationStatus rollback() {
 		log.error("Going to execute rollback on graph.");
-		return titanClient.rollback();
+		return janusGraphClient.rollback();
 	}
 
 	public <T, TStatus> void handleTransactionCommitRollback(boolean inTransaction, Either<T, TStatus> result) {
@@ -92,13 +92,13 @@
 		}
 	}
 
-	public Either<TitanGraph, TitanOperationStatus> getGraph() {
-		return titanClient.getGraph();
+	public Either<JanusGraph, JanusGraphOperationStatus> getGraph() {
+		return janusGraphClient.getGraph();
 	}
 
 	// For healthCheck
 	public boolean isGraphOpen() {
-		return titanClient.getHealth();
+		return janusGraphClient.getHealth();
 	}
 
 	/**
@@ -107,13 +107,13 @@
 	 * @param clazz
 	 * @return
 	 */
-	public <T extends GraphNode> Either<T, TitanOperationStatus> createNode(T node, Class<T> clazz) {
+	public <T extends GraphNode> Either<T, JanusGraphOperationStatus> createNode(T node, Class<T> clazz) {
 		log.debug("try to create node for ID [{}]", node.getKeyValueId());
-		Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+		Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
 		if (graph.isLeft()) {
 			T newNode;
 			try {
-				TitanGraph tGraph = graph.left().value();
+				JanusGraph tGraph = graph.left().value();
 
 				Vertex vertex = tGraph.addVertex();
 
@@ -131,7 +131,7 @@
 
 			} catch (Exception e) {
 				log.debug("Failed to create Node for ID [{}]", node.getKeyValueId(), e);
-				return Either.right(TitanGraphClient.handleTitanException(e));
+				return Either.right(JanusGraphClient.handleJanusGraphException(e));
 			}
 
 		} else {
@@ -140,14 +140,14 @@
 		}
 	}
 
-	public Either<TitanVertex, TitanOperationStatus> createNode(GraphNode node) {
+	public Either<JanusGraphVertex, JanusGraphOperationStatus> createNode(GraphNode node) {
 		log.debug("try to create node for ID [{}]", node.getKeyValueId());
-		Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+		Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
 		if (graph.isLeft()) {
 			try {
-				TitanGraph tGraph = graph.left().value();
+				JanusGraph tGraph = graph.left().value();
 
-				TitanVertex vertex = tGraph.addVertex();
+				JanusGraphVertex vertex = tGraph.addVertex();
 
 				vertex.property(GraphPropertiesDictionary.LABEL.getProperty(), node.getLabel());
 
@@ -160,7 +160,7 @@
 
 			} catch (Exception e) {
 				log.debug("Failed to create Node for ID [{}]", node.getKeyValueId(), e);
-				return Either.right(TitanGraphClient.handleTitanException(e));
+				return Either.right(JanusGraphClient.handleJanusGraphException(e));
 			}
 
 		} else {
@@ -174,7 +174,7 @@
 	 * @param relation
 	 * @return
 	 */
-	public Either<GraphRelation, TitanOperationStatus> createRelation(GraphRelation relation) {
+	public Either<GraphRelation, JanusGraphOperationStatus> createRelation(GraphRelation relation) {
 		log.debug("try to create relation from [{}] to [{}] ", relation.getFrom(), relation.getTo());
 
 		RelationEndPoint from = relation.getFrom();
@@ -186,25 +186,25 @@
 
 	}
 
-	private Either<GraphRelation, TitanOperationStatus> createEdge(String type, ImmutablePair<String, Object> from, ImmutablePair<String, Object> to, String fromLabel, String toLabel, Map<String, Object> properties) {
-		Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+	private Either<GraphRelation, JanusGraphOperationStatus> createEdge(String type, ImmutablePair<String, Object> from, ImmutablePair<String, Object> to, String fromLabel, String toLabel, Map<String, Object> properties) {
+		Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
 
 		if (graph.isLeft()) {
 			try {
-				Either<Vertex, TitanOperationStatus> fromV = getVertexByPropertyAndLabel(from.getKey(), from.getValue(), fromLabel);
+				Either<Vertex, JanusGraphOperationStatus> fromV = getVertexByPropertyAndLabel(from.getKey(), from.getValue(), fromLabel);
 				if (fromV.isRight()) {
-					TitanOperationStatus error = fromV.right().value();
-					if (TitanOperationStatus.NOT_FOUND.equals(error)) {
-						return Either.right(TitanOperationStatus.INVALID_ID);
+					JanusGraphOperationStatus error = fromV.right().value();
+					if (JanusGraphOperationStatus.NOT_FOUND.equals(error)) {
+						return Either.right(JanusGraphOperationStatus.INVALID_ID);
 					} else {
 						return Either.right(error);
 					}
 				}
-				Either<Vertex, TitanOperationStatus> toV = getVertexByPropertyAndLabel(to.getKey(), to.getValue(), toLabel);
+				Either<Vertex, JanusGraphOperationStatus> toV = getVertexByPropertyAndLabel(to.getKey(), to.getValue(), toLabel);
 				if (toV.isRight()) {
-					TitanOperationStatus error = toV.right().value();
-					if (TitanOperationStatus.NOT_FOUND.equals(error)) {
-						return Either.right(TitanOperationStatus.INVALID_ID);
+					JanusGraphOperationStatus error = toV.right().value();
+					if (JanusGraphOperationStatus.NOT_FOUND.equals(error)) {
+						return Either.right(JanusGraphOperationStatus.INVALID_ID);
 					} else {
 						return Either.right(error);
 					}
@@ -230,7 +230,7 @@
 				return Either.left(newRelation);
 			} catch (Exception e) {
 				log.debug(FAILED_TO_CREATE_EDGE_FROM_TO, from, to, e);
-				return Either.right(TitanGraphClient.handleTitanException(e));
+				return Either.right(JanusGraphClient.handleJanusGraphException(e));
 			}
 		} else {
 			log.debug("Failed to create edge from [{}] to [{}]   {}", from, to, graph.right().value());
@@ -238,14 +238,14 @@
 		}
 	}
 
-	public TitanOperationStatus createEdge(Vertex vertexOut, Vertex vertexIn, GraphEdgeLabels type, Map<String, Object> properties) {
+	public JanusGraphOperationStatus createEdge(Vertex vertexOut, Vertex vertexIn, GraphEdgeLabels type, Map<String, Object> properties) {
 		try {
 			Edge edge = addEdge(vertexOut, vertexIn, type, properties);
 		} catch (Exception e) {
 			log.debug(FAILED_TO_CREATE_EDGE_FROM_TO, vertexOut, vertexIn, e);
-			return TitanGraphClient.handleTitanException(e);
+			return JanusGraphClient.handleJanusGraphException(e);
 		}
-		return TitanOperationStatus.OK;
+		return JanusGraphOperationStatus.OK;
 
 	}
 	
@@ -264,7 +264,7 @@
 	 * @param edge
 	 * @return the copy operation status
 	 */
-	public Either<Edge, TitanOperationStatus> copyEdge(Vertex out, Vertex in, Edge edge) {
+	public Either<Edge, JanusGraphOperationStatus> copyEdge(Vertex out, Vertex in, Edge edge) {
 		GraphEdgeLabels byName = GraphEdgeLabels.getByName(edge.label());
 		return this.saveEdge(out, in, byName, edgePropertiesToMap(edge));
 	}
@@ -274,30 +274,30 @@
 		return StreamSupport.stream(propertiesIterable.spliterator(), false).collect(Collectors.toMap(Property::key, Property::value));
 	}
 
-	public Either<Edge, TitanOperationStatus> saveEdge(Vertex vertexOut, Vertex vertexIn, GraphEdgeLabels type, Map<String, Object> properties) {
+	public Either<Edge, JanusGraphOperationStatus> saveEdge(Vertex vertexOut, Vertex vertexIn, GraphEdgeLabels type, Map<String, Object> properties) {
 		try {
 			Edge edge = addEdge(vertexOut, vertexIn, type, properties);
 			return Either.left(edge);
 		} catch (Exception e) {
 			log.debug(FAILED_TO_CREATE_EDGE_FROM_TO, vertexOut, vertexIn, e);
-			return Either.right(TitanGraphClient.handleTitanException(e));
+			return Either.right(JanusGraphClient.handleJanusGraphException(e));
 		}
 
 	}
 
-	public TitanOperationStatus createEdge(TitanVertex vertexOut, GraphNode to, GraphEdgeLabels type, Map<String, Object> properties) {
+	public JanusGraphOperationStatus createEdge(JanusGraphVertex vertexOut, GraphNode to, GraphEdgeLabels type, Map<String, Object> properties) {
 
-		TitanVertex vertexIn;
-		Either<Vertex, TitanOperationStatus> toV = getVertexByPropertyAndLabel(to.getUniqueIdKey(), to.getUniqueId(), to.getLabel());
+		JanusGraphVertex vertexIn;
+		Either<Vertex, JanusGraphOperationStatus> toV = getVertexByPropertyAndLabel(to.getUniqueIdKey(), to.getUniqueId(), to.getLabel());
 		if (toV.isRight()) {
-			TitanOperationStatus error = toV.right().value();
-			if (TitanOperationStatus.NOT_FOUND.equals(error)) {
-				return TitanOperationStatus.INVALID_ID;
+			JanusGraphOperationStatus error = toV.right().value();
+			if (JanusGraphOperationStatus.NOT_FOUND.equals(error)) {
+				return JanusGraphOperationStatus.INVALID_ID;
 			} else {
 				return error;
 			}
 		}
-		vertexIn = (TitanVertex) toV.left().value();
+		vertexIn = (JanusGraphVertex) toV.left().value();
 		return createEdge(vertexOut, vertexIn, type, properties);
 	}
 
@@ -309,26 +309,26 @@
 	 * @param properties
 	 * @return
 	 */
-	public Either<GraphRelation, TitanOperationStatus> createRelation(GraphNode from, GraphNode to, GraphEdgeLabels label, Map<String, Object> properties) {
+	public Either<GraphRelation, JanusGraphOperationStatus> createRelation(GraphNode from, GraphNode to, GraphEdgeLabels label, Map<String, Object> properties) {
 		log.debug("try to create relation from [{}] to [{}]", from.getKeyValueId(), to.getKeyValueId());
 		return createEdge(label.getProperty(), from.getKeyValueId(), to.getKeyValueId(), from.getLabel(), to.getLabel(), properties);
 	}
 
-	public Either<GraphRelation, TitanOperationStatus> replaceRelationLabel(GraphNode from, GraphNode to, GraphEdgeLabels label, GraphEdgeLabels newLabel) {
+	public Either<GraphRelation, JanusGraphOperationStatus> replaceRelationLabel(GraphNode from, GraphNode to, GraphEdgeLabels label, GraphEdgeLabels newLabel) {
 
 		log.debug("try to replace relation {} to {} from [{}] to [{}]", label.name(), newLabel.name(), from.getKeyValueId(), to.getKeyValueId());
-		Either<GraphRelation, TitanOperationStatus> getRelationResult = getRelation(from, to, label);
+		Either<GraphRelation, JanusGraphOperationStatus> getRelationResult = getRelation(from, to, label);
 		if (getRelationResult.isRight()) {
 			return getRelationResult;
 		}
 
 		GraphRelation origRelation = getRelationResult.left().value();
-		Either<GraphRelation, TitanOperationStatus> createRelationResult = createRelation(from, to, newLabel, origRelation.toGraphMap());
+		Either<GraphRelation, JanusGraphOperationStatus> createRelationResult = createRelation(from, to, newLabel, origRelation.toGraphMap());
 		if (createRelationResult.isRight()) {
 			return createRelationResult;
 		}
 
-		Either<GraphRelation, TitanOperationStatus> deleteRelationResult = deleteRelation(origRelation);
+		Either<GraphRelation, JanusGraphOperationStatus> deleteRelationResult = deleteRelation(origRelation);
 		if (deleteRelationResult.isRight()) {
 			return deleteRelationResult;
 		}
@@ -342,11 +342,11 @@
 	 * @param clazz
 	 * @return
 	 */
-	public <T extends GraphNode> Either<T, TitanOperationStatus> getNode(String keyName, Object keyValue, Class<T> clazz) {
+	public <T extends GraphNode> Either<T, JanusGraphOperationStatus> getNode(String keyName, Object keyValue, Class<T> clazz) {
 
 		log.debug("Try to get node for key [{}] with value [{}] ", keyName, keyValue);
 
-		Either<TitanVertex, TitanOperationStatus> vertexByProperty = getVertexByProperty(keyName, keyValue);
+		Either<JanusGraphVertex, JanusGraphOperationStatus> vertexByProperty = getVertexByProperty(keyName, keyValue);
 
 		if (vertexByProperty.isLeft()) {
 			try {
@@ -356,7 +356,7 @@
 				return Either.left(node);
 			} catch (Exception e) {
 				log.debug("Failed to get node for key [{}] with value [{}] ", keyName, keyValue, e);
-				return Either.right(TitanGraphClient.handleTitanException(e));
+				return Either.right(JanusGraphClient.handleJanusGraphException(e));
 			}
 		} else {
 			log.debug("Failed to get node for key [{}] with value [{}]  ", keyName, keyValue, vertexByProperty.right().value());
@@ -371,10 +371,10 @@
 	 * @param label
 	 * @return
 	 */
-	public Either<GraphRelation, TitanOperationStatus> getRelation(GraphNode from, GraphNode to, GraphEdgeLabels label) {
+	public Either<GraphRelation, JanusGraphOperationStatus> getRelation(GraphNode from, GraphNode to, GraphEdgeLabels label) {
 		log.debug("try to get relation from [{}] to [{}]", from.getKeyValueId(), to.getKeyValueId());
 
-		Either<Edge, TitanOperationStatus> edge = getEdgeByNodes(from, to, label);
+		Either<Edge, JanusGraphOperationStatus> edge = getEdgeByNodes(from, to, label);
 
 		if (edge.isLeft()) {
 			try {
@@ -383,7 +383,7 @@
 				return Either.left(relation);
 			} catch (Exception e) {
 				log.debug("Failed to get  get relation from [{}] to [{}]", from.getKeyValueId(), to.getKeyValueId(), e);
-				return Either.right(TitanGraphClient.handleTitanException(e));
+				return Either.right(JanusGraphClient.handleJanusGraphException(e));
 			}
 		} else {
 			log.debug("Failed to get  get relation from [{}] to [{}]   {}", from.getKeyValueId(), to.getKeyValueId(), edge.right().value());
@@ -391,18 +391,18 @@
 		}
 	}
 
-	public Either<Edge, TitanOperationStatus> getEdgeByNodes(GraphNode from, GraphNode to, GraphEdgeLabels label) {
+	public Either<Edge, JanusGraphOperationStatus> getEdgeByNodes(GraphNode from, GraphNode to, GraphEdgeLabels label) {
 		ImmutablePair<String, Object> keyValueIdFrom = from.getKeyValueId();
 		ImmutablePair<String, Object> keyValueIdTo = to.getKeyValueId();
 
 		return getEdgeByVerticies(keyValueIdFrom.getKey(), keyValueIdFrom.getValue(), keyValueIdTo.getKey(), keyValueIdTo.getValue(), label.getProperty());
 	}
 
-	public Either<GraphRelation, TitanOperationStatus> deleteIncomingRelationByCriteria(GraphNode to, GraphEdgeLabels label, Map<String, Object> props) {
+	public Either<GraphRelation, JanusGraphOperationStatus> deleteIncomingRelationByCriteria(GraphNode to, GraphEdgeLabels label, Map<String, Object> props) {
 
-		Either<Edge, TitanOperationStatus> edgeByCriteria = getIncomingEdgeByCriteria(to, label, props);
+		Either<Edge, JanusGraphOperationStatus> edgeByCriteria = getIncomingEdgeByCriteria(to, label, props);
 		if (edgeByCriteria.isLeft()) {
-			Either<TitanGraph, TitanOperationStatus> graph = getGraph();
+			Either<JanusGraph, JanusGraphOperationStatus> graph = getGraph();
 			if (graph.isLeft()) {
 				Edge edge = edgeByCriteria.left().value();
 				log.debug("delete edge {} to {} ", label.getProperty(), to.getUniqueId());
@@ -425,11 +425,11 @@
 
 	}
 
-	public Either<GraphRelation, TitanOperationStatus> getIncomingRelationByCriteria(GraphNode to, GraphEdgeLabels label, Map<String, Object> props) {
+	public Either<GraphRelation, JanusGraphOperationStatus> getIncomingRelationByCriteria(GraphNode to, GraphEdgeLabels label, Map<String, Object> props) {
 
-		Either<Edge, TitanOperationStatus> edgeByCriteria = getIncomingEdgeByCriteria(to, label, props);
+		Either<Edge, JanusGraphOperationStatus> edgeByCriteria = getIncomingEdgeByCriteria(to, label, props);
 		if (edgeByCriteria.isLeft()) {
-			Either<TitanGraph, TitanOperationStatus> graph = getGraph();
+			Either<JanusGraph, JanusGraphOperationStatus> graph = getGraph();
 			if (graph.isLeft()) {
 				Edge edge = edgeByCriteria.left().value();
 				Map<String, Object> properties = getProperties(edge);
@@ -450,17 +450,17 @@
 
 	}
 
-	public Either<Edge, TitanOperationStatus> getIncomingEdgeByCriteria(GraphNode to, GraphEdgeLabels label, Map<String, Object> props) {
+	public Either<Edge, JanusGraphOperationStatus> getIncomingEdgeByCriteria(GraphNode to, GraphEdgeLabels label, Map<String, Object> props) {
 
 		ImmutablePair<String, Object> keyValueIdTo = to.getKeyValueId();
 
-		Either<TitanVertex, TitanOperationStatus> vertexFrom = getVertexByProperty(keyValueIdTo.getKey(), keyValueIdTo.getValue());
+		Either<JanusGraphVertex, JanusGraphOperationStatus> vertexFrom = getVertexByProperty(keyValueIdTo.getKey(), keyValueIdTo.getValue());
 		if (vertexFrom.isRight()) {
 			return Either.right(vertexFrom.right().value());
 		}
 		Vertex vertex = vertexFrom.left().value();
-		TitanVertex titanVertex = (TitanVertex) vertex;
-		TitanVertexQuery<?> query = titanVertex.query();
+		JanusGraphVertex janusGraphVertex = (JanusGraphVertex) vertex;
+		JanusGraphVertexQuery<?> query = janusGraphVertex.query();
 		query = query.labels(label.getProperty());
 
 		if (props != null && !props.isEmpty()) {
@@ -469,34 +469,34 @@
 			}
 		}
 		Edge matchingEdge = null;
-		Iterable<TitanEdge> edges = query.edges();
+		Iterable<JanusGraphEdge> edges = query.edges();
 		if (edges == null) {
 			log.debug(NO_EDGES_IN_GRAPH_FOR_CRITERIA);
-			return Either.right(TitanOperationStatus.NOT_FOUND);
+			return Either.right(JanusGraphOperationStatus.NOT_FOUND);
 		}
-		Iterator<TitanEdge> eIter = edges.iterator();
+		Iterator<JanusGraphEdge> eIter = edges.iterator();
 		if (eIter.hasNext()) {
             matchingEdge = eIter.next();
 		}
 
 		if (matchingEdge == null) {
 			log.debug(NO_EDGES_IN_GRAPH_FOR_CRITERIA);
-			return Either.right(TitanOperationStatus.NOT_FOUND);
+			return Either.right(JanusGraphOperationStatus.NOT_FOUND);
 		}
 		return Either.left(matchingEdge);
 	}
 
-	public Either<Edge, TitanOperationStatus> getEdgeByVerticies(String keyNameFrom, Object keyValueFrom, String keyNameTo, Object keyValueTo, String label) {
-		Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+	public Either<Edge, JanusGraphOperationStatus> getEdgeByVerticies(String keyNameFrom, Object keyValueFrom, String keyNameTo, Object keyValueTo, String label) {
+		Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
 
 		if (graph.isLeft()) {
 			try {
-				Either<TitanVertex, TitanOperationStatus> vertexFrom = getVertexByProperty(keyNameFrom, keyValueFrom);
+				Either<JanusGraphVertex, JanusGraphOperationStatus> vertexFrom = getVertexByProperty(keyNameFrom, keyValueFrom);
 				if (vertexFrom.isRight()) {
 					return Either.right(vertexFrom.right().value());
 				}
-				Iterable<TitanEdge> edges = vertexFrom.left().value().query().labels(label).edges();
-				Iterator<TitanEdge> eIter = edges.iterator();
+				Iterable<JanusGraphEdge> edges = vertexFrom.left().value().query().labels(label).edges();
+				Iterator<JanusGraphEdge> eIter = edges.iterator();
 				while (eIter.hasNext()) {
 					Edge edge = eIter.next();
 					Vertex vertexIn = edge.inVertex();
@@ -505,22 +505,22 @@
 					}
 				}
 				log.debug("No relation in graph from [{}={}] to [{}={}]", keyNameFrom, keyValueFrom, keyNameTo, keyValueTo);
-				return Either.right(TitanOperationStatus.NOT_FOUND);
+				return Either.right(JanusGraphOperationStatus.NOT_FOUND);
 			} catch (Exception e) {
 				log.debug("Failed to get  get relation from [{}={}] to [{}={}]", keyNameFrom, keyValueFrom, keyNameTo, keyValueTo, e);
-				return Either.right(TitanGraphClient.handleTitanException(e));
+				return Either.right(JanusGraphClient.handleJanusGraphException(e));
 			}
 		} else {
 			return Either.right(graph.right().value());
 		}
 	}
 
-	public Either<List<Edge>, TitanOperationStatus> getEdgesForNode(GraphNode node, Direction requestedDirection) {
+	public Either<List<Edge>, JanusGraphOperationStatus> getEdgesForNode(GraphNode node, Direction requestedDirection) {
 
-		Either<List<Edge>, TitanOperationStatus> result;
+		Either<List<Edge>, JanusGraphOperationStatus> result;
 
 		ImmutablePair<String, Object> keyValueId = node.getKeyValueId();
-		Either<TitanVertex, TitanOperationStatus> eitherVertex = getVertexByProperty(keyValueId.getKey(), keyValueId.getValue());
+		Either<JanusGraphVertex, JanusGraphOperationStatus> eitherVertex = getVertexByProperty(keyValueId.getKey(), keyValueId.getValue());
 
 		if (eitherVertex.isLeft()) {
 			List<Edge> edges = prepareEdgesList(eitherVertex.left().value(), requestedDirection);
@@ -534,7 +534,7 @@
 
 	private List<Edge> prepareEdgesList(Vertex vertex, Direction requestedDirection) {
 		List<Edge> edges = new ArrayList<>();
-		Iterator<TitanEdge> edgesItr = ((TitanVertex) vertex).query().edges().iterator();
+		Iterator<JanusGraphEdge> edgesItr = ((JanusGraphVertex) vertex).query().edges().iterator();
 		while (edgesItr.hasNext()) {
 			Edge edge = edgesItr.next();
 			Direction currEdgeDirection = getEdgeDirection(vertex, edge);
@@ -566,14 +566,14 @@
 	 * @param properties
 	 * @return
 	 */
-	public Either<GraphRelation, TitanOperationStatus> updateRelation(GraphNode from, GraphNode to, GraphEdgeLabels label, Map<String, Object> properties) {
+	public Either<GraphRelation, JanusGraphOperationStatus> updateRelation(GraphNode from, GraphNode to, GraphEdgeLabels label, Map<String, Object> properties) {
 		log.debug("try to update relation from [{}] to [{}]", from.getKeyValueId(), to.getKeyValueId());
 		return updateEdge(label.getProperty(), from.getKeyValueId(), to.getKeyValueId(), from.getLabel(), to.getLabel(), properties);
 	}
 
-	private Either<GraphRelation, TitanOperationStatus> updateEdge(String type, ImmutablePair<String, Object> from, ImmutablePair<String, Object> to, String fromLabel, String toLabel, Map<String, Object> properties) {
+	private Either<GraphRelation, JanusGraphOperationStatus> updateEdge(String type, ImmutablePair<String, Object> from, ImmutablePair<String, Object> to, String fromLabel, String toLabel, Map<String, Object> properties) {
 
-		Either<Edge, TitanOperationStatus> edgeS = getEdgeByVerticies(from.getKey(), from.getValue(), to.getKey(), to.getValue(), type);
+		Either<Edge, JanusGraphOperationStatus> edgeS = getEdgeByVerticies(from.getKey(), from.getValue(), to.getKey(), to.getValue(), type);
 		if (edgeS.isLeft()) {
 
 			try {
@@ -597,7 +597,7 @@
 				if (log.isDebugEnabled()) {
 					log.debug("Failed to update relation from [{}] to [{}] ", from, to, e);
 				}
-				return Either.right(TitanGraphClient.handleTitanException(e));
+				return Either.right(JanusGraphClient.handleJanusGraphException(e));
 			}
 		} else {
 			if (log.isDebugEnabled()) {
@@ -612,7 +612,7 @@
 	 * @param relation
 	 * @return
 	 */
-	public Either<GraphRelation, TitanOperationStatus> updateRelation(GraphRelation relation) {
+	public Either<GraphRelation, JanusGraphOperationStatus> updateRelation(GraphRelation relation) {
 		log.debug("try to update relation from [{}] to [{}]", relation.getFrom(), relation.getTo());
 		RelationEndPoint from = relation.getFrom();
 		RelationEndPoint to = relation.getTo();
@@ -623,17 +623,17 @@
 
 	}
 
-	private Either<Vertex, TitanOperationStatus> getVertexByPropertyAndLabel(String name, Object value, String label) {
+	private Either<Vertex, JanusGraphOperationStatus> getVertexByPropertyAndLabel(String name, Object value, String label) {
 
-		Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+		Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
 		if (graph.isLeft()) {
 			try {
-				TitanGraph tGraph = graph.left().value();
+				JanusGraph tGraph = graph.left().value();
 
 				@SuppressWarnings("unchecked")
-				Iterable<TitanVertex> vertecies = tGraph.query().has(name, value).has(GraphPropertiesDictionary.LABEL.getProperty(), label).vertices();
+				Iterable<JanusGraphVertex> vertecies = tGraph.query().has(name, value).has(GraphPropertiesDictionary.LABEL.getProperty(), label).vertices();
 
-				java.util.Iterator<TitanVertex> iterator = vertecies.iterator();
+				java.util.Iterator<JanusGraphVertex> iterator = vertecies.iterator();
 				if (iterator.hasNext()) {
 					Vertex vertex = iterator.next();
 					return Either.left(vertex);
@@ -641,12 +641,12 @@
 				if (log.isDebugEnabled()) {
 					log.debug("No vertex in graph for key =" + name + " and value = " + value + "  label = " + label);
 				}
-				return Either.right(TitanOperationStatus.NOT_FOUND);
+				return Either.right(JanusGraphOperationStatus.NOT_FOUND);
 			} catch (Exception e) {
 				if (log.isDebugEnabled()) {
 					log.debug("Failed to get vertex in graph for key ={} and value = {} label = {}",name,value,label);
 				}
-				return Either.right(TitanGraphClient.handleTitanException(e));
+				return Either.right(JanusGraphClient.handleJanusGraphException(e));
 			}
 
 		} else {
@@ -657,37 +657,37 @@
 		}
 	}
 
-	public Either<TitanVertex, TitanOperationStatus> getVertexByProperty(String name, Object value) {
+	public Either<JanusGraphVertex, JanusGraphOperationStatus> getVertexByProperty(String name, Object value) {
 
-		Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+		Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
 		if (value == null) {
 			if (log.isDebugEnabled()) {
 				log.debug("No vertex in graph for key = {} and value = {}", name, value);
 			}
-			return Either.right(TitanOperationStatus.NOT_FOUND);
+			return Either.right(JanusGraphOperationStatus.NOT_FOUND);
 		}
 		if (graph.isLeft()) {
 			try {
-				TitanGraph tGraph = graph.left().value();
+				JanusGraph tGraph = graph.left().value();
 
 				@SuppressWarnings("unchecked")
-				Iterable<TitanVertex> vertecies = tGraph.query().has(name, value).vertices();
+				Iterable<JanusGraphVertex> vertecies = tGraph.query().has(name, value).vertices();
 
-				java.util.Iterator<TitanVertex> iterator = vertecies.iterator();
+				java.util.Iterator<JanusGraphVertex> iterator = vertecies.iterator();
 				if (iterator.hasNext()) {
-					TitanVertex vertex = iterator.next();
+					JanusGraphVertex vertex = iterator.next();
 					return Either.left(vertex);
 				} else {
 					if (log.isDebugEnabled()) {
 						log.debug("No vertex in graph for key ={} and value = {}", name, value);
 					}
-					return Either.right(TitanOperationStatus.NOT_FOUND);
+					return Either.right(JanusGraphOperationStatus.NOT_FOUND);
 				}
 			} catch (Exception e) {
 				if (log.isDebugEnabled()) {
 					log.debug("Failed to get vertex in graph for key = {} and value = ", name, value);
 				}
-				return Either.right(TitanGraphClient.handleTitanException(e));
+				return Either.right(JanusGraphClient.handleJanusGraphException(e));
 			}
 		} else {
 			if (log.isDebugEnabled()) {
@@ -697,13 +697,13 @@
 		}
 	}
 
-	public <T extends GraphNode> Either<List<T>, TitanOperationStatus> getByCriteria(NodeTypeEnum type, Map<String, Object> hasProps, Map<String, Object> hasNotProps, Class<T> clazz) {
-		Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+	public <T extends GraphNode> Either<List<T>, JanusGraphOperationStatus> getByCriteria(NodeTypeEnum type, Map<String, Object> hasProps, Map<String, Object> hasNotProps, Class<T> clazz) {
+		Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
 		if (graph.isLeft()) {
 			try {
-				TitanGraph tGraph = graph.left().value();
+				JanusGraph tGraph = graph.left().value();
 
-				TitanGraphQuery<? extends TitanGraphQuery> query = tGraph.query();
+				JanusGraphQuery<? extends JanusGraphQuery> query = tGraph.query();
 				query = query.has(GraphPropertiesDictionary.LABEL.getProperty(), type.getName());
 
 				if (hasProps != null && !hasProps.isEmpty()) {
@@ -716,12 +716,12 @@
 						query = query.hasNot(entry.getKey(), entry.getValue());
 					}
 				}
-				Iterable<TitanVertex> vertices = query.vertices();
+				Iterable<JanusGraphVertex> vertices = query.vertices();
 				if (vertices == null) {
-					return Either.right(TitanOperationStatus.NOT_FOUND);
+					return Either.right(JanusGraphOperationStatus.NOT_FOUND);
 				}
 
-				Iterator<TitanVertex> iterator = vertices.iterator();
+				Iterator<JanusGraphVertex> iterator = vertices.iterator();
 				List<T> result = new ArrayList<>();
 
 				while (iterator.hasNext()) {
@@ -736,7 +736,7 @@
 					log.debug("Number of fetced nodes in graph for criteria : from type = {} and properties has = {}, properties hasNot = {}  is {}", type, hasProps, hasNotProps, result.size());
 				}
 				if (result.size() == 0) {
-					return Either.right(TitanOperationStatus.NOT_FOUND);
+					return Either.right(JanusGraphOperationStatus.NOT_FOUND);
 				}
 
 				return Either.left(result);
@@ -744,7 +744,7 @@
 				if (log.isDebugEnabled()) {
 					log.debug("Failed  get by  criteria for type = {}", type, e);
 				}
-				return Either.right(TitanGraphClient.handleTitanException(e));
+				return Either.right(JanusGraphClient.handleJanusGraphException(e));
 			}
 
 		} else {
@@ -755,13 +755,13 @@
 		}
 	}
 
-	public <T extends GraphNode> Either<List<T>, TitanOperationStatus> getByCriteria(NodeTypeEnum type, Class<T> clazz, List<ImmutableTriple<QueryType, String, Object>> props) {
-		Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+	public <T extends GraphNode> Either<List<T>, JanusGraphOperationStatus> getByCriteria(NodeTypeEnum type, Class<T> clazz, List<ImmutableTriple<QueryType, String, Object>> props) {
+		Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
 		if (graph.isLeft()) {
 			try {
-				TitanGraph tGraph = graph.left().value();
+				JanusGraph tGraph = graph.left().value();
 
-				TitanGraphQuery<? extends TitanGraphQuery> query = tGraph.query();
+				JanusGraphQuery<? extends JanusGraphQuery> query = tGraph.query();
 				query = query.has(GraphPropertiesDictionary.LABEL.getProperty(), type.getName());
 				for (ImmutableTriple<QueryType, String, Object> prop : props) {
 					if (QueryType.HAS.equals(prop.getLeft())) {
@@ -770,12 +770,12 @@
 						query = query.hasNot(prop.getMiddle(), prop.getRight());
 					}
 				}
-				Iterable<TitanVertex> vertices = query.vertices();
+				Iterable<JanusGraphVertex> vertices = query.vertices();
 				if (vertices == null) {
-					return Either.right(TitanOperationStatus.NOT_FOUND);
+					return Either.right(JanusGraphOperationStatus.NOT_FOUND);
 				}
 
-				Iterator<TitanVertex> iterator = vertices.iterator();
+				Iterator<JanusGraphVertex> iterator = vertices.iterator();
 				List<T> result = new ArrayList<>();
 
 				while (iterator.hasNext()) {
@@ -787,7 +787,7 @@
 					result.add(element);
 				}
 				if (result.size() == 0) {
-					return Either.right(TitanOperationStatus.NOT_FOUND);
+					return Either.right(JanusGraphOperationStatus.NOT_FOUND);
 				}
 
 				return Either.left(result);
@@ -795,7 +795,7 @@
 				if (log.isDebugEnabled()) {
 					log.debug("Failed  get by  criteria for type = {}", type, e);
 				}
-				return Either.right(TitanGraphClient.handleTitanException(e));
+				return Either.right(JanusGraphClient.handleJanusGraphException(e));
 			}
 
 		} else {
@@ -806,13 +806,13 @@
 		}
 	}
 
-	public <T extends GraphNode> Either<List<T>, TitanOperationStatus> getByCriteria(NodeTypeEnum type, Map<String, Object> props, Class<T> clazz) {
-		Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+	public <T extends GraphNode> Either<List<T>, JanusGraphOperationStatus> getByCriteria(NodeTypeEnum type, Map<String, Object> props, Class<T> clazz) {
+		Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
 		if (graph.isLeft()) {
 			try {
-				TitanGraph tGraph = graph.left().value();
+				JanusGraph tGraph = graph.left().value();
 
-				TitanGraphQuery<? extends TitanGraphQuery> query = tGraph.query();
+				JanusGraphQuery<? extends JanusGraphQuery> query = tGraph.query();
 				query = query.has(GraphPropertiesDictionary.LABEL.getProperty(), type.getName());
 
 				if (props != null && !props.isEmpty()) {
@@ -820,12 +820,12 @@
 						query = query.has(entry.getKey(), entry.getValue());
 					}
 				}
-				Iterable<TitanVertex> vertices = query.vertices();
+				Iterable<JanusGraphVertex> vertices = query.vertices();
 				if (vertices == null) {
-					return Either.right(TitanOperationStatus.NOT_FOUND);
+					return Either.right(JanusGraphOperationStatus.NOT_FOUND);
 				}
 
-				Iterator<TitanVertex> iterator = vertices.iterator();
+				Iterator<JanusGraphVertex> iterator = vertices.iterator();
 				List<T> result = new ArrayList<>();
 
 				while (iterator.hasNext()) {
@@ -840,7 +840,7 @@
 					log.debug("Number of fetced nodes in graph for criteria : from type = {} and properties = {} is {}", type, props, result.size());
 				}
 				if (result.size() == 0) {
-					return Either.right(TitanOperationStatus.NOT_FOUND);
+					return Either.right(JanusGraphOperationStatus.NOT_FOUND);
 				}
 
 				return Either.left(result);
@@ -848,7 +848,7 @@
 				if (log.isDebugEnabled()) {
 					log.debug("Failed  get by  criteria for type = {} and properties = {}", type, props, e);
 				}
-				return Either.right(TitanGraphClient.handleTitanException(e));
+				return Either.right(JanusGraphClient.handleJanusGraphException(e));
 			}
 
 		} else {
@@ -859,30 +859,30 @@
 		}
 	}
 
-	public <T extends GraphNode> Either<List<T>, TitanOperationStatus> getByCriteriaWithPredicate(NodeTypeEnum type, Map<String, Entry<TitanPredicate, Object>> props, Class<T> clazz) {
-		Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+	public <T extends GraphNode> Either<List<T>, JanusGraphOperationStatus> getByCriteriaWithPredicate(NodeTypeEnum type, Map<String, Entry<JanusGraphPredicate, Object>> props, Class<T> clazz) {
+		Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
 		if (graph.isLeft()) {
 			try {
-				TitanGraph tGraph = graph.left().value();
+				JanusGraph tGraph = graph.left().value();
 
-				TitanGraphQuery<? extends TitanGraphQuery> query = tGraph.query();
+				JanusGraphQuery<? extends JanusGraphQuery> query = tGraph.query();
 				query = query.has(GraphPropertiesDictionary.LABEL.getProperty(), type.getName());
 
 				if (props != null && !props.isEmpty()) {
-					TitanPredicate predicate = null;
+					JanusGraphPredicate predicate = null;
 					Object object = null;
-					for (Map.Entry<String, Entry<TitanPredicate, Object>> entry : props.entrySet()) {
+					for (Map.Entry<String, Entry<JanusGraphPredicate, Object>> entry : props.entrySet()) {
 						predicate = entry.getValue().getKey();
 						object = entry.getValue().getValue();
 						query = query.has(entry.getKey(), predicate, object);
 					}
 				}
-				Iterable<TitanVertex> vertices = query.vertices();
+				Iterable<JanusGraphVertex> vertices = query.vertices();
 				if (vertices == null) {
-					return Either.right(TitanOperationStatus.NOT_FOUND);
+					return Either.right(JanusGraphOperationStatus.NOT_FOUND);
 				}
 
-				Iterator<TitanVertex> iterator = vertices.iterator();
+				Iterator<JanusGraphVertex> iterator = vertices.iterator();
 				List<T> result = new ArrayList<>();
 
 				while (iterator.hasNext()) {
@@ -893,7 +893,7 @@
 					result.add(element);
 				}
 				if (result.size() == 0) {
-					return Either.right(TitanOperationStatus.NOT_FOUND);
+					return Either.right(JanusGraphOperationStatus.NOT_FOUND);
 				}
 				if (log.isDebugEnabled()) {
 					log.debug("No nodes in graph for criteria : from type = {} and properties = {}", type, props);
@@ -903,7 +903,7 @@
 				if (log.isDebugEnabled()) {
 					log.debug("Failed  get by  criteria for type = {} and properties = {}", type, props, e);
 				}
-				return Either.right(TitanGraphClient.handleTitanException(e));
+				return Either.right(JanusGraphClient.handleJanusGraphException(e));
 			}
 
 		} else {
@@ -914,7 +914,7 @@
 		}
 	}
 
-	public <T extends GraphNode> Either<List<T>, TitanOperationStatus> getAll(NodeTypeEnum type, Class<T> clazz) {
+	public <T extends GraphNode> Either<List<T>, JanusGraphOperationStatus> getAll(NodeTypeEnum type, Class<T> clazz) {
 		return getByCriteria(type, null, clazz);
 	}
 
@@ -924,11 +924,11 @@
 	 * @param clazz
 	 * @return
 	 */
-	public <T extends GraphNode> Either<T, TitanOperationStatus> updateNode(GraphNode node, Class<T> clazz) {
+	public <T extends GraphNode> Either<T, JanusGraphOperationStatus> updateNode(GraphNode node, Class<T> clazz) {
 		log.debug("Try to update node for {}", node.getKeyValueId());
 
 		ImmutablePair<String, Object> keyValueId = node.getKeyValueId();
-		Either<Vertex, TitanOperationStatus> vertexByProperty = getVertexByPropertyAndLabel(keyValueId.getKey(), keyValueId.getValue(), node.getLabel());
+		Either<Vertex, JanusGraphOperationStatus> vertexByProperty = getVertexByPropertyAndLabel(keyValueId.getKey(), keyValueId.getValue(), node.getLabel());
 
 		if (vertexByProperty.isLeft()) {
 			try {
@@ -942,7 +942,7 @@
 					}
 				}
 
-				Either<Vertex, TitanOperationStatus> vertexByPropertyAndLabel = getVertexByPropertyAndLabel(keyValueId.getKey(), keyValueId.getValue(), node.getLabel());
+				Either<Vertex, JanusGraphOperationStatus> vertexByPropertyAndLabel = getVertexByPropertyAndLabel(keyValueId.getKey(), keyValueId.getValue(), node.getLabel());
 				if (vertexByPropertyAndLabel.isRight()) {
 					return Either.right(vertexByPropertyAndLabel.right().value());
 				} else {
@@ -954,7 +954,7 @@
 				if (log.isDebugEnabled()) {
 					log.debug("Failed to update node for {}", node.getKeyValueId(), e);
 				}
-				return Either.right(TitanGraphClient.handleTitanException(e));
+				return Either.right(JanusGraphClient.handleJanusGraphException(e));
 			}
 		} else {
 			if (log.isDebugEnabled()) {
@@ -965,7 +965,7 @@
 
 	}
 
-	public TitanOperationStatus updateVertex(GraphNode node, Vertex vertex) {
+	public JanusGraphOperationStatus updateVertex(GraphNode node, Vertex vertex) {
 		log.debug("Try to update node for {}", node.getKeyValueId());
 		try {
 
@@ -981,9 +981,9 @@
 			if (log.isDebugEnabled()) {
 				log.debug("Failed to update node for {}", node.getKeyValueId(), e);
 			}
-			return TitanGraphClient.handleTitanException(e);
+			return JanusGraphClient.handleJanusGraphException(e);
 		}
-		return TitanOperationStatus.OK;
+		return JanusGraphOperationStatus.OK;
 
 	}
 
@@ -993,7 +993,7 @@
 	 * @param clazz
 	 * @return
 	 */
-	public <T extends GraphNode> Either<T, TitanOperationStatus> deleteNode(GraphNode node, Class<T> clazz) {
+	public <T extends GraphNode> Either<T, JanusGraphOperationStatus> deleteNode(GraphNode node, Class<T> clazz) {
 		log.debug("Try to delete node for {}", node.getKeyValueId());
 		ImmutablePair<String, Object> keyValueId = node.getKeyValueId();
 		return deleteNode(keyValueId.getKey(), keyValueId.getValue(), clazz);
@@ -1006,8 +1006,8 @@
 	 * @param clazz
 	 * @return
 	 */
-	public <T extends GraphNode> Either<T, TitanOperationStatus> deleteNode(String keyName, Object keyValue, Class<T> clazz) {
-		Either<TitanVertex, TitanOperationStatus> vertexByProperty = getVertexByProperty(keyName, keyValue);
+	public <T extends GraphNode> Either<T, JanusGraphOperationStatus> deleteNode(String keyName, Object keyValue, Class<T> clazz) {
+		Either<JanusGraphVertex, JanusGraphOperationStatus> vertexByProperty = getVertexByProperty(keyName, keyValue);
 
 		if (vertexByProperty.isLeft()) {
 			try {
@@ -1019,9 +1019,9 @@
 
 					T node = GraphElementFactory.createElement(label, GraphElementTypeEnum.Node, properties, clazz);
 					if (node != null) {
-						Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+						Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
 						if (graph.isLeft()) {
-							TitanGraph tGraph = graph.left().value();
+							JanusGraph tGraph = graph.left().value();
 							vertex.remove();
 						} else {
 							return Either.right(graph.right().value());
@@ -1031,19 +1031,19 @@
 						if (log.isDebugEnabled()) {
 							log.debug("Failed to delete node for {} = {} Missing label property on node", keyName, keyValue);
 						}
-						return Either.right(TitanOperationStatus.MISSING_NODE_LABEL);
+						return Either.right(JanusGraphOperationStatus.MISSING_NODE_LABEL);
 					}
 				} else {
 					if (log.isDebugEnabled()) {
 						log.debug("Failed to delete node for {} = {} Missing label property on node", keyName, keyValue);
 					}
-					return Either.right(TitanOperationStatus.MISSING_NODE_LABEL);
+					return Either.right(JanusGraphOperationStatus.MISSING_NODE_LABEL);
 				}
 			} catch (Exception e) {
 				if (log.isDebugEnabled()) {
 					log.debug("Failed to delete node for {} = {}", keyName, keyValue, e);
 				}
-				return Either.right(TitanGraphClient.handleTitanException(e));
+				return Either.right(JanusGraphClient.handleJanusGraphException(e));
 			}
 
 		} else {
@@ -1051,7 +1051,7 @@
 		}
 	}
 
-	public Either<GraphRelation, TitanOperationStatus> deleteRelation(GraphRelation relation) {
+	public Either<GraphRelation, JanusGraphOperationStatus> deleteRelation(GraphRelation relation) {
 		log.debug("try to delete relation from [{}] to [{}]", relation.getFrom(), relation.getTo());
 		RelationEndPoint from = relation.getFrom();
 		RelationEndPoint to = relation.getTo();
@@ -1062,21 +1062,21 @@
 
 	}
 
-	public Either<Boolean, TitanOperationStatus> isRelationExist(GraphNode from, GraphNode to, GraphEdgeLabels edgeLabel) {
+	public Either<Boolean, JanusGraphOperationStatus> isRelationExist(GraphNode from, GraphNode to, GraphEdgeLabels edgeLabel) {
 		return getEdgeByNodes(from, to, edgeLabel)
 				.left()
 				.map(edge -> true)
 				.right()
-				.bind(err -> err == TitanOperationStatus.NOT_FOUND ? Either.left(false): Either.right(err));
+				.bind(err -> err == JanusGraphOperationStatus.NOT_FOUND ? Either.left(false): Either.right(err));
 	}
 
-	public Either<GraphRelation, TitanOperationStatus> deleteRelation(GraphNode from, GraphNode to, GraphEdgeLabels label) {
+	public Either<GraphRelation, JanusGraphOperationStatus> deleteRelation(GraphNode from, GraphNode to, GraphEdgeLabels label) {
 		log.debug("try to delete relation from [{}] to [{}]", from.getKeyValueId(), to.getKeyValueId());
 		return deleteEdge(label.getProperty(), from.getKeyValueId(), to.getKeyValueId(), from.getLabel(), to.getLabel());
 	}
 
-	private Either<GraphRelation, TitanOperationStatus> deleteEdge(String type, ImmutablePair<String, Object> fromKeyId, ImmutablePair<String, Object> toKeyId, String fromLabel, String toLabel) {
-		Either<Edge, TitanOperationStatus> edgeS = getEdgeByVerticies(fromKeyId.getKey(), fromKeyId.getValue(), toKeyId.getKey(), toKeyId.getValue(), type);
+	private Either<GraphRelation, JanusGraphOperationStatus> deleteEdge(String type, ImmutablePair<String, Object> fromKeyId, ImmutablePair<String, Object> toKeyId, String fromLabel, String toLabel) {
+		Either<Edge, JanusGraphOperationStatus> edgeS = getEdgeByVerticies(fromKeyId.getKey(), fromKeyId.getValue(), toKeyId.getKey(), toKeyId.getValue(), type);
 		if (edgeS.isLeft()) {
 			try {
 				Edge edge = edgeS.left().value();
@@ -1089,7 +1089,7 @@
 
 				GraphRelation newRelation = GraphElementFactory.createRelation(edge.label(), getProperties(edge), nodeOut, nodeIn);
 
-				Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+				Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
 
 				if (graph.isLeft()) {
 					edge.remove();
@@ -1105,7 +1105,7 @@
 				if (log.isDebugEnabled()) {
 					log.debug("Failed to delete relation {} from {}  to {}", type, fromKeyId, toKeyId, e);
 				}
-				return Either.right(TitanGraphClient.handleTitanException(e));
+				return Either.right(JanusGraphClient.handleJanusGraphException(e));
 			}
 		} else {
 			if (log.isDebugEnabled()) {
@@ -1115,11 +1115,11 @@
 		}
 	}
 
-	public void setTitanGraphClient(TitanGraphClient titanGraphClient) {
-		this.titanClient = titanGraphClient;
+	public void setJanusGraphClient(JanusGraphClient janusGraphClient) {
+		this.janusGraphClient = janusGraphClient;
 	}
 
-	public Either<GraphRelation, TitanOperationStatus> deleteIncomingRelation(GraphRelation relation) {
+	public Either<GraphRelation, JanusGraphOperationStatus> deleteIncomingRelation(GraphRelation relation) {
 
 		RelationEndPoint to = relation.getTo();
 		ImmutablePair<String, Object> toKeyId = new ImmutablePair<>(to.getIdName(), to.getIdValue());
@@ -1128,12 +1128,12 @@
 
 	}
 
-	private Either<GraphRelation, TitanOperationStatus> deleteIncomingEdge(String type, ImmutablePair<String, Object> toKeyId) {
+	private Either<GraphRelation, JanusGraphOperationStatus> deleteIncomingEdge(String type, ImmutablePair<String, Object> toKeyId) {
 
-		Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+		Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
 
 		if (graph.isLeft()) {
-			Either<TitanVertex, TitanOperationStatus> rootVertexResult = getVertexByProperty(toKeyId.getKey(), toKeyId.getValue());
+			Either<JanusGraphVertex, JanusGraphOperationStatus> rootVertexResult = getVertexByProperty(toKeyId.getKey(), toKeyId.getValue());
 			if (rootVertexResult.isLeft()) {
 				Vertex rootVertex = rootVertexResult.left().value();
 				Iterator<Edge> edgesIterator = rootVertex.edges(Direction.IN, type);
@@ -1144,10 +1144,10 @@
 					if (edgesIterator.hasNext()) {
 						edge = edgesIterator.next();
 						if (edgesIterator.hasNext()) {
-							return Either.right(TitanOperationStatus.MULTIPLE_EDGES_WITH_SAME_LABEL);
+							return Either.right(JanusGraphOperationStatus.MULTIPLE_EDGES_WITH_SAME_LABEL);
 						}
 					} else {
-						return Either.right(TitanOperationStatus.NOT_FOUND);
+						return Either.right(JanusGraphOperationStatus.NOT_FOUND);
 					}
 
 					log.debug("Find the tail vertex of the edge of type {} to vertex {}", type, toKeyId);
@@ -1166,7 +1166,7 @@
 					return Either.left(newRelation);
 
 				} else {
-					return Either.right(TitanOperationStatus.NOT_FOUND);
+					return Either.right(JanusGraphOperationStatus.NOT_FOUND);
 				}
 
 			} else {
@@ -1179,7 +1179,7 @@
 
 	}
 
-	public Either<GraphRelation, TitanOperationStatus> deleteOutgoingRelation(GraphRelation relation) {
+	public Either<GraphRelation, JanusGraphOperationStatus> deleteOutgoingRelation(GraphRelation relation) {
 
 		RelationEndPoint from = relation.getFrom();
 		ImmutablePair<String, Object> fromKeyId = new ImmutablePair<>(from.getIdName(), from.getIdValue());
@@ -1188,12 +1188,12 @@
 
 	}
 
-	private Either<GraphRelation, TitanOperationStatus> deleteOutgoingEdge(String type, ImmutablePair<String, Object> toKeyId) {
+	private Either<GraphRelation, JanusGraphOperationStatus> deleteOutgoingEdge(String type, ImmutablePair<String, Object> toKeyId) {
 
-		Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+		Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
 
 		if (graph.isLeft()) {
-			Either<TitanVertex, TitanOperationStatus> rootVertexResult = getVertexByProperty(toKeyId.getKey(), toKeyId.getValue());
+			Either<JanusGraphVertex, JanusGraphOperationStatus> rootVertexResult = getVertexByProperty(toKeyId.getKey(), toKeyId.getValue());
 			if (rootVertexResult.isLeft()) {
 				Vertex rootVertex = rootVertexResult.left().value();
 				Iterator<Edge> edgesIterator = rootVertex.edges(Direction.OUT, type);
@@ -1204,10 +1204,10 @@
 					if (edgesIterator.hasNext()) {
 						edge = edgesIterator.next();
 						if (edgesIterator.hasNext()) {
-							return Either.right(TitanOperationStatus.MULTIPLE_EDGES_WITH_SAME_LABEL);
+							return Either.right(JanusGraphOperationStatus.MULTIPLE_EDGES_WITH_SAME_LABEL);
 						}
 					} else {
-						return Either.right(TitanOperationStatus.NOT_FOUND);
+						return Either.right(JanusGraphOperationStatus.NOT_FOUND);
 					}
 
 					log.debug("Find the tail vertex of the edge of type {}  to vertex ", type, toKeyId);
@@ -1226,7 +1226,7 @@
 					return Either.left(newRelation);
 
 				} else {
-					return Either.right(TitanOperationStatus.NOT_FOUND);
+					return Either.right(JanusGraphOperationStatus.NOT_FOUND);
 				}
 
 			} else {
@@ -1244,34 +1244,34 @@
 	 * @return
 	 */
 
-	public TitanOperationStatus lockElement(String id, NodeTypeEnum type) {
+	public JanusGraphOperationStatus lockElement(String id, NodeTypeEnum type) {
 
 		StringBuffer lockId = new StringBuffer(LOCK_NODE_PREFIX);
 		lockId.append(type.getName()).append("_").append(id);
 		return lockNode(lockId.toString());
 	}
 
-	public TitanOperationStatus lockElement(GraphNode node) {
+	public JanusGraphOperationStatus lockElement(GraphNode node) {
 
 		StringBuffer lockId = createLockElementId(node);
 
 		return lockNode(lockId.toString());
 	}
 
-	private TitanOperationStatus lockNode(String lockId) {
-		TitanOperationStatus status = TitanOperationStatus.OK;
+	private JanusGraphOperationStatus lockNode(String lockId) {
+		JanusGraphOperationStatus status = JanusGraphOperationStatus.OK;
 
 		GraphNodeLock lockNode = new GraphNodeLock(lockId);
 
-		Either<GraphNodeLock, TitanOperationStatus> lockNodeNew = createNode(lockNode, GraphNodeLock.class);
+		Either<GraphNodeLock, JanusGraphOperationStatus> lockNodeNew = createNode(lockNode, GraphNodeLock.class);
 		if (lockNodeNew.isLeft()) {
 			log.debug("before commit, Lock node created for {}", lockId);
-			return titanClient.commit();
+			return janusGraphClient.commit();
 		} else {
-			Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+			Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
 			if (graph.isLeft()) {
-				TitanGraph tGraph = graph.left().value();
-				Either<TitanVertex, TitanOperationStatus> vertex = getVertexByProperty(lockNode.getUniqueIdKey(), lockNode.getUniqueId());
+				JanusGraph tGraph = graph.left().value();
+				Either<JanusGraphVertex, JanusGraphOperationStatus> vertex = getVertexByProperty(lockNode.getUniqueIdKey(), lockNode.getUniqueId());
 				if (vertex.isLeft()) {
 					status = relockNode(lockNode, lockNodeNew, tGraph, vertex);
 				} else {
@@ -1284,45 +1284,45 @@
 		return status;
 	}
 
-	private TitanOperationStatus relockNode(GraphNodeLock lockNode, Either<GraphNodeLock, TitanOperationStatus> lockNodeNew, TitanGraph tGraph, Either<TitanVertex, TitanOperationStatus> vertex) {
-		TitanOperationStatus status = TitanOperationStatus.OK;
+	private JanusGraphOperationStatus relockNode(GraphNodeLock lockNode, Either<GraphNodeLock, JanusGraphOperationStatus> lockNodeNew, JanusGraph tGraph, Either<JanusGraphVertex, JanusGraphOperationStatus> vertex) {
+		JanusGraphOperationStatus status = JanusGraphOperationStatus.OK;
 		Long time = vertex.left().value().value(GraphPropertiesDictionary.CREATION_DATE.getProperty());
-		Long lockTimeout = ConfigurationManager.getConfigurationManager().getConfiguration().getTitanLockTimeout();
+		Long lockTimeout = ConfigurationManager.getConfigurationManager().getConfiguration().getJanusGraphLockTimeout();
 		if (time + lockTimeout * 1000 < System.currentTimeMillis()) {
 			log.debug("Found not released lock node with id {}", lockNode.getUniqueId());
 			vertex.left().value().remove();
 			lockNodeNew = createNode(lockNode, GraphNodeLock.class);
 			if (lockNodeNew.isLeft()) {
 				log.debug("Lock node created for {}", lockNode.getUniqueIdKey());
-				return titanClient.commit();
+				return janusGraphClient.commit();
 			} else {
 				log.debug("Failed Lock node for {} .  Commit transacton for deleted previous vertex .", lockNode.getUniqueIdKey());
-				titanClient.commit();
+				janusGraphClient.commit();
 				status = checkLockError(lockNode.getUniqueIdKey(), lockNodeNew);
 			}
 		} else {
 			log.debug("Failed Lock node for {}  rollback transacton", lockNode.getUniqueIdKey());
-			titanClient.rollback();
+			janusGraphClient.rollback();
 			status = checkLockError(lockNode.getUniqueIdKey(), lockNodeNew);
 		}
 		return status;
 	}
 
-	public <T extends GraphNode> Either<List<ImmutablePair<T, GraphEdge>>, TitanOperationStatus> getChildrenNodes(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz, boolean withEdges) {
+	public <T extends GraphNode> Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> getChildrenNodes(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz, boolean withEdges) {
 
 		List<ImmutablePair<T, GraphEdge>> immutablePairs = new ArrayList<>();
 
-		Either<TitanGraph, TitanOperationStatus> graphRes = titanClient.getGraph();
+		Either<JanusGraph, JanusGraphOperationStatus> graphRes = janusGraphClient.getGraph();
 		if (graphRes.isRight()) {
 			log.error(FAILED_TO_RETRIEVE_GRAPH_STATUS_IS, graphRes);
 			return Either.right(graphRes.right().value());
 		}
 
-		TitanGraph titanGraph = graphRes.left().value();
+		JanusGraph janusGraph = graphRes.left().value();
 		@SuppressWarnings("unchecked")
-		Iterable<TitanVertex> vertices = titanGraph.query().has(key, uniqueId).vertices();
+		Iterable<JanusGraphVertex> vertices = janusGraph.query().has(key, uniqueId).vertices();
 		if (vertices == null || !vertices.iterator().hasNext()) {
-			return Either.right(TitanOperationStatus.INVALID_ID);
+			return Either.right(JanusGraphOperationStatus.INVALID_ID);
 		}
 
 		Vertex rootVertex = vertices.iterator().next();
@@ -1349,28 +1349,28 @@
 		}
 
 		if (immutablePairs.isEmpty()) {
-			return Either.right(TitanOperationStatus.NOT_FOUND);
+			return Either.right(JanusGraphOperationStatus.NOT_FOUND);
 		}
 
 		return Either.left(immutablePairs);
 
 	}
 
-	public Either<List<ImmutablePair<TitanVertex, Edge>>, TitanOperationStatus> getChildrenVertecies(String key, String uniqueId, GraphEdgeLabels edgeType) {
+	public Either<List<ImmutablePair<JanusGraphVertex, Edge>>, JanusGraphOperationStatus> getChildrenVertecies(String key, String uniqueId, GraphEdgeLabels edgeType) {
 
-		List<ImmutablePair<TitanVertex, Edge>> immutablePairs = new ArrayList<>();
+		List<ImmutablePair<JanusGraphVertex, Edge>> immutablePairs = new ArrayList<>();
 
-		Either<TitanGraph, TitanOperationStatus> graphRes = titanClient.getGraph();
+		Either<JanusGraph, JanusGraphOperationStatus> graphRes = janusGraphClient.getGraph();
 		if (graphRes.isRight()) {
 			log.error(FAILED_TO_RETRIEVE_GRAPH_STATUS_IS, graphRes);
 			return Either.right(graphRes.right().value());
 		}
 
-		TitanGraph titanGraph = graphRes.left().value();
+		JanusGraph janusGraph = graphRes.left().value();
 		@SuppressWarnings("unchecked")
-		Iterable<TitanVertex> vertices = titanGraph.query().has(key, uniqueId).vertices();
+		Iterable<JanusGraphVertex> vertices = janusGraph.query().has(key, uniqueId).vertices();
 		if (vertices == null || !vertices.iterator().hasNext()) {
-			return Either.right(TitanOperationStatus.INVALID_ID);
+			return Either.right(JanusGraphOperationStatus.INVALID_ID);
 		}
 
 		Vertex rootVertex = vertices.iterator().next();
@@ -1379,30 +1379,31 @@
 		if (edgesCreatorIterator != null) {
 			while (edgesCreatorIterator.hasNext()) {
 				Edge edge = edgesCreatorIterator.next();
-				TitanVertex vertex = (TitanVertex) edge.inVertex();
+				JanusGraphVertex vertex = (JanusGraphVertex) edge.inVertex();
 
-				ImmutablePair<TitanVertex, Edge> immutablePair = new ImmutablePair<>(vertex, edge);
+				ImmutablePair<JanusGraphVertex, Edge> immutablePair = new ImmutablePair<>(vertex, edge);
 				immutablePairs.add(immutablePair);
 			}
 		}
 		if (immutablePairs.isEmpty()) {
-			return Either.right(TitanOperationStatus.NOT_FOUND);
+			return Either.right(JanusGraphOperationStatus.NOT_FOUND);
 		}
 
 		return Either.left(immutablePairs);
 
 	}
 
-	public <T extends GraphNode> Either<List<ImmutablePair<T, GraphEdge>>, TitanOperationStatus> getChildrenNodes(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz) {
+	public <T extends GraphNode> Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> getChildrenNodes(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz) {
 		return this.getChildrenNodes(key, uniqueId, edgeType, nodeTypeEnum, clazz, true);
 	}
 
-	private TitanOperationStatus checkLockError(String lockId, Either<GraphNodeLock, TitanOperationStatus> lockNodeNew) {
-		TitanOperationStatus status;
-		TitanOperationStatus error = lockNodeNew.right().value();
+	private JanusGraphOperationStatus checkLockError(String lockId, Either<GraphNodeLock, JanusGraphOperationStatus> lockNodeNew) {
+		JanusGraphOperationStatus status;
+		JanusGraphOperationStatus error = lockNodeNew.right().value();
 		log.debug("Failed to Lock node for {}  error = {}", lockId, error);
-		if (error.equals(TitanOperationStatus.TITAN_SCHEMA_VIOLATION) || error.equals(TitanOperationStatus.ILLEGAL_ARGUMENT)) {
-			status = TitanOperationStatus.ALREADY_LOCKED;
+		if (error.equals(JanusGraphOperationStatus.JANUSGRAPH_SCHEMA_VIOLATION) || error.equals(
+				JanusGraphOperationStatus.ILLEGAL_ARGUMENT)) {
+			status = JanusGraphOperationStatus.ALREADY_LOCKED;
 		} else {
 			status = error;
 		}
@@ -1414,28 +1415,28 @@
 	 * @param node
 	 * @return
 	 */
-	public TitanOperationStatus releaseElement(GraphNode node) {
+	public JanusGraphOperationStatus releaseElement(GraphNode node) {
 		StringBuffer lockId = createLockElementId(node);
 
 		return unlockNode(lockId);
 	}
 
-	private TitanOperationStatus unlockNode(StringBuffer lockId) {
+	private JanusGraphOperationStatus unlockNode(StringBuffer lockId) {
 		GraphNodeLock lockNode = new GraphNodeLock(lockId.toString());
 
-		Either<GraphNodeLock, TitanOperationStatus> lockNodeNew = deleteNode(lockNode, GraphNodeLock.class);
+		Either<GraphNodeLock, JanusGraphOperationStatus> lockNodeNew = deleteNode(lockNode, GraphNodeLock.class);
 		if (lockNodeNew.isLeft()) {
 			log.debug("Lock node released for lock id = {}", lockId);
-			return titanClient.commit();
+			return janusGraphClient.commit();
 		} else {
-			titanClient.rollback();
-			TitanOperationStatus error = lockNodeNew.right().value();
+			janusGraphClient.rollback();
+			JanusGraphOperationStatus error = lockNodeNew.right().value();
 			log.debug("Failed to Release node for lock id {} error = {}", lockId, error);
 			return error;
 		}
 	}
 
-	public TitanOperationStatus releaseElement(String id, NodeTypeEnum type) {
+	public JanusGraphOperationStatus releaseElement(String id, NodeTypeEnum type) {
 		StringBuffer lockId = new StringBuffer(LOCK_NODE_PREFIX);
 		lockId.append(type.getName()).append("_").append(id);
 		return unlockNode(lockId);
@@ -1447,9 +1448,9 @@
 		return lockId;
 	}
 
-	public <T extends GraphNode> Either<ImmutablePair<T, GraphEdge>, TitanOperationStatus> getChild(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz) {
+	public <T extends GraphNode> Either<ImmutablePair<T, GraphEdge>, JanusGraphOperationStatus> getChild(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz) {
 
-		Either<List<ImmutablePair<T, GraphEdge>>, TitanOperationStatus> childrenNodes = getChildrenNodes(key, uniqueId, edgeType, nodeTypeEnum, clazz);
+		Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> childrenNodes = getChildrenNodes(key, uniqueId, edgeType, nodeTypeEnum, clazz);
 
 		if (childrenNodes.isRight()) {
 			return Either.right(childrenNodes.right().value());
@@ -1458,43 +1459,43 @@
 		List<ImmutablePair<T, GraphEdge>> value = childrenNodes.left().value();
 
 		if (value.size() > 1) {
-			return Either.right(TitanOperationStatus.MULTIPLE_CHILDS_WITH_SAME_EDGE);
+			return Either.right(JanusGraphOperationStatus.MULTIPLE_CHILDS_WITH_SAME_EDGE);
 		}
 
 		return Either.left(value.get(0));
 
 	}
 
-	public ImmutablePair<TitanVertex, Edge> getChildVertex(TitanVertex vertex, GraphEdgeLabels edgeType) {
+	public ImmutablePair<JanusGraphVertex, Edge> getChildVertex(JanusGraphVertex vertex, GraphEdgeLabels edgeType) {
 
-		ImmutablePair<TitanVertex, Edge> pair = null;
+		ImmutablePair<JanusGraphVertex, Edge> pair = null;
 		Iterator<Edge> edges = vertex.edges(Direction.OUT, edgeType.getProperty());
 		if (edges.hasNext()) {
 			// get only first edge
 			Edge edge = edges.next();
-			pair = new ImmutablePair<>((TitanVertex) edge.inVertex(), edge);
+			pair = new ImmutablePair<>((JanusGraphVertex) edge.inVertex(), edge);
 		}
 		return pair;
 	}
 
-	public <T extends GraphNode> Either<List<ImmutablePair<T, GraphEdge>>, TitanOperationStatus> getParentNodes(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz) {
+	public <T extends GraphNode> Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> getParentNodes(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz) {
 
 		List<ImmutablePair<T, GraphEdge>> immutablePairs = new ArrayList<>();
 
 		T data = null;
 		GraphEdge graphEdge = null;
 
-		Either<TitanGraph, TitanOperationStatus> graphRes = titanClient.getGraph();
+		Either<JanusGraph, JanusGraphOperationStatus> graphRes = janusGraphClient.getGraph();
 		if (graphRes.isRight()) {
 			log.error(FAILED_TO_RETRIEVE_GRAPH_STATUS_IS, graphRes);
 			return Either.right(graphRes.right().value());
 		}
 
-		TitanGraph titanGraph = graphRes.left().value();
+		JanusGraph janusGraph = graphRes.left().value();
 		@SuppressWarnings("unchecked")
-		Iterable<TitanVertex> vertices = titanGraph.query().has(key, uniqueId).vertices();
+		Iterable<JanusGraphVertex> vertices = janusGraph.query().has(key, uniqueId).vertices();
 		if (vertices == null || !vertices.iterator().hasNext()) {
-			return Either.right(TitanOperationStatus.INVALID_ID);
+			return Either.right(JanusGraphOperationStatus.INVALID_ID);
 		}
 
 		Vertex rootVertex = vertices.iterator().next();
@@ -1517,16 +1518,16 @@
 		}
 
 		if (immutablePairs.isEmpty()) {
-			return Either.right(TitanOperationStatus.NOT_FOUND);
+			return Either.right(JanusGraphOperationStatus.NOT_FOUND);
 		}
 
 		return Either.left(immutablePairs);
 
 	}
 
-	public <T extends GraphNode> Either<ImmutablePair<T, GraphEdge>, TitanOperationStatus> getParentNode(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz) {
+	public <T extends GraphNode> Either<ImmutablePair<T, GraphEdge>, JanusGraphOperationStatus> getParentNode(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz) {
 
-		Either<List<ImmutablePair<T, GraphEdge>>, TitanOperationStatus> parentNodesRes = this.getParentNodes(key, uniqueId, edgeType, nodeTypeEnum, clazz);
+		Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> parentNodesRes = this.getParentNodes(key, uniqueId, edgeType, nodeTypeEnum, clazz);
 
 		if (parentNodesRes.isRight()) {
 			log.debug("failed to get edge key:{} uniqueId:{} edgeType {} nodeTypeEnum: {}, reason:{}", key, uniqueId, edgeType, nodeTypeEnum, parentNodesRes.right().value());
@@ -1536,17 +1537,17 @@
 		List<ImmutablePair<T, GraphEdge>> value = parentNodesRes.left().value();
 
 		if (value.size() > 1) {
-			return Either.right(TitanOperationStatus.MULTIPLE_CHILDS_WITH_SAME_EDGE);
+			return Either.right(JanusGraphOperationStatus.MULTIPLE_CHILDS_WITH_SAME_EDGE);
 		}
 
 		return Either.left(value.get(0));
 	}
 
-	public <T extends GraphNode> Either<ImmutablePair<T, GraphEdge>, TitanOperationStatus> getChildByEdgeCriteria(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz, Map<String, Object> edgeProperties) {
+	public <T extends GraphNode> Either<ImmutablePair<T, GraphEdge>, JanusGraphOperationStatus> getChildByEdgeCriteria(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz, Map<String, Object> edgeProperties) {
 
-		Either<Edge, TitanOperationStatus> outgoingEdgeByCriteria = getOutgoingEdgeByCriteria(key, uniqueId, edgeType, edgeProperties);
+		Either<Edge, JanusGraphOperationStatus> outgoingEdgeByCriteria = getOutgoingEdgeByCriteria(key, uniqueId, edgeType, edgeProperties);
 		if (outgoingEdgeByCriteria.isRight()) {
-			TitanOperationStatus status = outgoingEdgeByCriteria.right().value();
+			JanusGraphOperationStatus status = outgoingEdgeByCriteria.right().value();
 			log.debug("Cannot find outgoing edge from vertex {} with label {} and properties {}" + uniqueId, edgeType, edgeProperties);
 			return Either.right(status);
 		}
@@ -1565,30 +1566,30 @@
 		return Either.left(immutablePair);
 	}
 
-	public Either<ImmutablePair<TitanVertex, Edge>, TitanOperationStatus> getChildByEdgeCriteria(TitanVertex vertex, GraphEdgeLabels edgeType, Map<String, Object> edgeProperties) {
+	public Either<ImmutablePair<JanusGraphVertex, Edge>, JanusGraphOperationStatus> getChildByEdgeCriteria(JanusGraphVertex vertex, GraphEdgeLabels edgeType, Map<String, Object> edgeProperties) {
 
-		Either<Edge, TitanOperationStatus> outgoingEdgeByCriteria = getOutgoingEdgeByCriteria(vertex, edgeType, edgeProperties);
+		Either<Edge, JanusGraphOperationStatus> outgoingEdgeByCriteria = getOutgoingEdgeByCriteria(vertex, edgeType, edgeProperties);
 		if (outgoingEdgeByCriteria.isRight()) {
-			TitanOperationStatus status = outgoingEdgeByCriteria.right().value();
+			JanusGraphOperationStatus status = outgoingEdgeByCriteria.right().value();
 			log.debug("Cannot find outgoing edge from vertex {} with label {} and properties {}", vertex, edgeType, edgeProperties);
 			return Either.right(status);
 		}
 		Edge edge = outgoingEdgeByCriteria.left().value();
 
-		TitanVertex outgoingVertex = (TitanVertex) edge.inVertex();
+		JanusGraphVertex outgoingVertex = (JanusGraphVertex) edge.inVertex();
 
-		ImmutablePair<TitanVertex, Edge> immutablePair = new ImmutablePair<>(outgoingVertex, edge);
+		ImmutablePair<JanusGraphVertex, Edge> immutablePair = new ImmutablePair<>(outgoingVertex, edge);
 
 		return Either.left(immutablePair);
 	}
 
-	public Either<Edge, TitanOperationStatus> getOutgoingEdgeByCriteria(String key, String value, GraphEdgeLabels label, Map<String, Object> props) {
+	public Either<Edge, JanusGraphOperationStatus> getOutgoingEdgeByCriteria(String key, String value, GraphEdgeLabels label, Map<String, Object> props) {
 
-		Either<TitanVertex, TitanOperationStatus> vertexFrom = getVertexByProperty(key, value);
+		Either<JanusGraphVertex, JanusGraphOperationStatus> vertexFrom = getVertexByProperty(key, value);
 		if (vertexFrom.isRight()) {
-			TitanOperationStatus status = vertexFrom.right().value();
-			if (status == TitanOperationStatus.NOT_FOUND) {
-				return Either.right(TitanOperationStatus.INVALID_ID);
+			JanusGraphOperationStatus status = vertexFrom.right().value();
+			if (status == JanusGraphOperationStatus.NOT_FOUND) {
+				return Either.right(JanusGraphOperationStatus.INVALID_ID);
 			}
 			return Either.right(status);
 		}
@@ -1596,9 +1597,9 @@
 		return getOutgoingEdgeByCriteria(vertexFrom.left().value(), label, props);
 	}
 
-	public Either<Edge, TitanOperationStatus> getOutgoingEdgeByCriteria(TitanVertex vertex, GraphEdgeLabels label, Map<String, Object> props) {
+	public Either<Edge, JanusGraphOperationStatus> getOutgoingEdgeByCriteria(JanusGraphVertex vertex, GraphEdgeLabels label, Map<String, Object> props) {
 
-		TitanVertexQuery<?> query = vertex.query();
+		JanusGraphVertexQuery<?> query = vertex.query();
 		query = query.direction(Direction.OUT).labels(label.getProperty());
 
 		if (props != null && !props.isEmpty()) {
@@ -1607,40 +1608,40 @@
 			}
 		}
 		Edge matchingEdge = null;
-		Iterable<TitanEdge> edges = query.edges();
+		Iterable<JanusGraphEdge> edges = query.edges();
 		if (edges == null) {
 			log.debug(NO_EDGES_IN_GRAPH_FOR_CRITERIA);
-			return Either.right(TitanOperationStatus.NOT_FOUND);
+			return Either.right(JanusGraphOperationStatus.NOT_FOUND);
 		}
-		Iterator<TitanEdge> eIter = edges.iterator();
+		Iterator<JanusGraphEdge> eIter = edges.iterator();
 		if (eIter.hasNext()) {
             matchingEdge = eIter.next();
 		}
 
 		if (matchingEdge == null) {
 			log.debug(NO_EDGES_IN_GRAPH_FOR_CRITERIA);
-			return Either.right(TitanOperationStatus.NOT_FOUND);
+			return Either.right(JanusGraphOperationStatus.NOT_FOUND);
 		}
 		return Either.left(matchingEdge);
 	}
 
-	public <T extends GraphNode> Either<List<ImmutablePair<T, GraphEdge>>, TitanOperationStatus> deleteChildrenNodes(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz) {
+	public <T extends GraphNode> Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> deleteChildrenNodes(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz) {
 
 		List<ImmutablePair<T, GraphEdge>> result = new ArrayList<>();
 
-		Either<List<ImmutablePair<T, GraphEdge>>, TitanOperationStatus> childrenNodesRes = getChildrenNodes(key, uniqueId, edgeType, nodeTypeEnum, clazz);
+		Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> childrenNodesRes = getChildrenNodes(key, uniqueId, edgeType, nodeTypeEnum, clazz);
 
 		if (childrenNodesRes.isRight()) {
-			TitanOperationStatus status = childrenNodesRes.right().value();
+			JanusGraphOperationStatus status = childrenNodesRes.right().value();
 			return Either.right(status);
 		}
 
 		List<ImmutablePair<T, GraphEdge>> list = childrenNodesRes.left().value();
 		for (ImmutablePair<T, GraphEdge> pair : list) {
 			T node = pair.getKey();
-			Either<T, TitanOperationStatus> deleteNodeRes = this.deleteNode(node, clazz);
+			Either<T, JanusGraphOperationStatus> deleteNodeRes = this.deleteNode(node, clazz);
 			if (deleteNodeRes.isRight()) {
-				TitanOperationStatus status = deleteNodeRes.right().value();
+				JanusGraphOperationStatus status = deleteNodeRes.right().value();
 				log.error("Failed to delete node {} . status is {}", node, status);
 				return Either.right(status);
 			}
@@ -1686,8 +1687,8 @@
 		return result;
 	}
 
-	public Object getProperty(TitanVertex vertex, String key) {
-		PropertyKey propertyKey = titanClient.getGraph().left().value().getPropertyKey(key);
+	public Object getProperty(JanusGraphVertex vertex, String key) {
+		PropertyKey propertyKey = janusGraphClient.getGraph().left().value().getPropertyKey(key);
         return vertex.valueOrNull(propertyKey);
 	}
 
@@ -1700,14 +1701,14 @@
 		return value;
 	}
 
-	public <T extends GraphNode> Either<List<ImmutablePair<T, GraphEdge>>, TitanOperationStatus> getChildrenByEdgeCriteria(Vertex vertex, String vertexUniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz,
-			Map<String, Object> edgeProperties) {
+	public <T extends GraphNode> Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> getChildrenByEdgeCriteria(Vertex vertex, String vertexUniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz,
+																																																															Map<String, Object> edgeProperties) {
 
 		List<ImmutablePair<T, GraphEdge>> result = new ArrayList<>();
 
-		Either<List<Edge>, TitanOperationStatus> outgoingEdgeByCriteria = getOutgoingEdgesByCriteria(vertex, edgeType, edgeProperties);
+		Either<List<Edge>, JanusGraphOperationStatus> outgoingEdgeByCriteria = getOutgoingEdgesByCriteria(vertex, edgeType, edgeProperties);
 		if (outgoingEdgeByCriteria.isRight()) {
-			TitanOperationStatus status = outgoingEdgeByCriteria.right().value();
+			JanusGraphOperationStatus status = outgoingEdgeByCriteria.right().value();
 			log.debug("Cannot find outgoing edge from vertex {} with label {}  and properties {}", vertexUniqueId, edgeType, edgeProperties);
 			return Either.right(status);
 		}
@@ -1731,12 +1732,12 @@
 		return Either.left(result);
 	}
 
-	public Either<List<Edge>, TitanOperationStatus> getOutgoingEdgesByCriteria(Vertex vertexFrom, GraphEdgeLabels label, Map<String, Object> props) {
+	public Either<List<Edge>, JanusGraphOperationStatus> getOutgoingEdgesByCriteria(Vertex vertexFrom, GraphEdgeLabels label, Map<String, Object> props) {
 
 		List<Edge> edgesResult = new ArrayList<>();
 
-		TitanVertex titanVertex = (TitanVertex) vertexFrom;
-		TitanVertexQuery<?> query = titanVertex.query();
+		JanusGraphVertex janusGraphVertex = (JanusGraphVertex) vertexFrom;
+		JanusGraphVertexQuery<?> query = janusGraphVertex.query();
 
 		query = query.direction(Direction.OUT).labels(label.getProperty());
 
@@ -1746,11 +1747,11 @@
 			}
 		}
 
-		Iterable<TitanEdge> edges = query.edges();
-		Iterator<TitanEdge> eIter = edges.iterator();
+		Iterable<JanusGraphEdge> edges = query.edges();
+		Iterator<JanusGraphEdge> eIter = edges.iterator();
 		if (edges == null || !eIter.hasNext()) {
 			log.debug("No edges found in graph for criteria (label = {} properties={})", label.getProperty(), props);
-			return Either.right(TitanOperationStatus.NOT_FOUND);
+			return Either.right(JanusGraphOperationStatus.NOT_FOUND);
 		}
 
 		while (eIter.hasNext()) {
@@ -1760,7 +1761,7 @@
 
 		if (edgesResult.isEmpty()) {
 			log.debug("No edges found in graph for criteria (label = {} properties={})", label.getProperty(), props);
-			return Either.right(TitanOperationStatus.NOT_FOUND);
+			return Either.right(JanusGraphOperationStatus.NOT_FOUND);
 		}
 		return Either.left(edgesResult);
 
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanOperationStatus.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphOperationStatus.java
similarity index 73%
rename from catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanOperationStatus.java
rename to catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphOperationStatus.java
index dc9ed02..a4ebcf7 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanOperationStatus.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphOperationStatus.java
@@ -18,9 +18,9 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.openecomp.sdc.be.dao.titan;
+package org.openecomp.sdc.be.dao.janusgraph;
 
-public enum TitanOperationStatus {
-	OK, NOT_CONNECTED, NOT_CREATED, INDEX_CANNOT_BE_CHANGED, NOT_FOUND, MISSING_UNIQUE_ID, MISSING_NODE_LABEL, MULTIPLE_EDGES_WITH_SAME_LABEL, CANNOT_DELETE_NON_LEAF_NODE, MULTIPLE_NODES_WITH_SAME_ID, GRAPH_IS_NOT_AVAILABLE, TITAN_CONFIGURATION, TITAN_SCHEMA_VIOLATION, INVALID_ELEMENT, INVALID_QUERY, INVALID_ID, RESOURCE_UNAVAILABLE, ILLEGAL_ARGUMENT, ALREADY_LOCKED, ALREADY_EXIST, MULTIPLE_CHILDS_WITH_SAME_EDGE, GENERAL_ERROR, MATCH_NOT_FOUND, INVALID_TYPE, PROPERTY_NAME_ALREADY_EXISTS, INVALID_PROPERTY,
+public enum JanusGraphOperationStatus {
+	OK, NOT_CONNECTED, NOT_CREATED, INDEX_CANNOT_BE_CHANGED, NOT_FOUND, MISSING_UNIQUE_ID, MISSING_NODE_LABEL, MULTIPLE_EDGES_WITH_SAME_LABEL, CANNOT_DELETE_NON_LEAF_NODE, MULTIPLE_NODES_WITH_SAME_ID, GRAPH_IS_NOT_AVAILABLE, JANUSGRAPH_CONFIGURATION, JANUSGRAPH_SCHEMA_VIOLATION, INVALID_ELEMENT, INVALID_QUERY, INVALID_ID, RESOURCE_UNAVAILABLE, ILLEGAL_ARGUMENT, ALREADY_LOCKED, ALREADY_EXIST, MULTIPLE_CHILDS_WITH_SAME_EDGE, GENERAL_ERROR, MATCH_NOT_FOUND, INVALID_TYPE, PROPERTY_NAME_ALREADY_EXISTS, INVALID_PROPERTY,
 
 }
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphUtils.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphUtils.java
new file mode 100644
index 0000000..fd9856b
--- /dev/null
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphUtils.java
@@ -0,0 +1,27 @@
+package org.openecomp.sdc.be.dao.janusgraph;
+
+import org.janusgraph.graphdb.query.JanusGraphPredicate;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import static org.janusgraph.core.attribute.Contain.NOT_IN;
+import static java.util.Collections.emptyMap;
+import static org.apache.commons.collections.CollectionUtils.isEmpty;
+
+public class JanusGraphUtils {
+
+    private JanusGraphUtils() {
+    }
+
+    public static <T> Map<String, Entry<JanusGraphPredicate, Object>> buildNotInPredicate(String propKey, Collection<T> notInCollection) {
+        if (isEmpty(notInCollection)) {
+            return emptyMap();
+        }
+        Map<String, Entry<JanusGraphPredicate,  Object>> predicateCriteria = new HashMap<>();
+        predicateCriteria.put(propKey, new HashMap.SimpleEntry<>(NOT_IN, notInCollection));
+        return predicateCriteria;
+    }
+}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/QueryType.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/QueryType.java
similarity index 95%
rename from catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/QueryType.java
rename to catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/QueryType.java
index 689ed32..fc2f2d0 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/QueryType.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/QueryType.java
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.openecomp.sdc.be.dao.titan;
+package org.openecomp.sdc.be.dao.janusgraph;
 
 /**
  * Created by mlando on 9/21/2016.
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/transactions/SimpleJanusGraphTransactionManager.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/transactions/SimpleJanusGraphTransactionManager.java
new file mode 100644
index 0000000..8c67254
--- /dev/null
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/transactions/SimpleJanusGraphTransactionManager.java
@@ -0,0 +1,70 @@
+package org.openecomp.sdc.be.dao.janusgraph.transactions;
+
+import org.janusgraph.core.JanusGraphException;
+import org.janusgraph.core.JanusGraph;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphClient;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
+import org.openecomp.sdc.common.log.wrappers.Logger;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.PlatformTransactionManager;
+import org.springframework.transaction.TransactionDefinition;
+import org.springframework.transaction.TransactionStatus;
+import org.springframework.transaction.TransactionSystemException;
+import org.springframework.transaction.support.SimpleTransactionStatus;
+
+import javax.annotation.PostConstruct;
+
+/**
+ * Simple transaction manager for the janusgraph database.
+ * This manager does not deal with transactions propagation and relies on the fact that transactions are automatically created with the first operation on the graph
+ */
+@Component
+public class SimpleJanusGraphTransactionManager implements PlatformTransactionManager {
+
+    private static final Logger log = Logger.getLogger(SimpleJanusGraphTransactionManager.class.getName());
+    private final JanusGraphClient janusGraphClient;
+    private JanusGraph janusGraph;
+
+    public SimpleJanusGraphTransactionManager(JanusGraphClient janusGraphClient) {
+        this.janusGraphClient = janusGraphClient;
+    }
+
+    @PostConstruct
+    public void onInit() {
+        janusGraph = janusGraphClient.getGraph().left().on(this::onFailingToStartJanusGraph);
+    }
+
+    @Override
+    public TransactionStatus getTransaction(TransactionDefinition transactionDefinition) {
+        log.debug("#getTransaction - returning simple transaction status");
+        return new SimpleTransactionStatus();
+    }
+
+    @Override
+    public void commit(TransactionStatus transactionStatus) {
+        log.debug("#commit - committing transaction");
+        try {
+            janusGraph.tx().commit();
+        } catch (JanusGraphException e) {
+            log.debug("#commit - failed to commit transaction", e);
+            throw new TransactionSystemException("failed to commit transaction", e);
+        }
+    }
+
+    @Override
+    public void rollback(TransactionStatus transactionStatus) {
+        log.debug("#rollback - committing transaction");
+        try {
+            janusGraph.tx().rollback();
+        } catch (JanusGraphException e) {
+            log.debug("#rollback - failed to rollback transaction", e);
+            throw new TransactionSystemException("failed to rollback transaction", e);
+        }
+    }
+
+    private JanusGraph onFailingToStartJanusGraph(JanusGraphOperationStatus err) {
+        log.debug("#onFailingToStartJanusGraph - could not open janusgraph client");
+        throw new IllegalStateException("janusgraph could not be initialized: " + err);
+    }
+
+}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/GraphVertex.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/GraphVertex.java
index 7485294..2db22a7 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/GraphVertex.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/GraphVertex.java
@@ -20,7 +20,7 @@
 
 package org.openecomp.sdc.be.dao.jsongraph;
 
-import com.thinkaurelius.titan.core.TitanVertex;
+import org.janusgraph.core.JanusGraphVertex;
 import org.apache.commons.collections.MapUtils;
 import org.apache.commons.lang.StringUtils;
 import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
@@ -37,7 +37,7 @@
 public class GraphVertex {
 	private String uniqueId;
 
-	private TitanVertex vertex;
+	private JanusGraphVertex vertex;
 	private VertexTypeEnum label;
 
 	private Map<String, ? extends ToscaDataDefinition> json;
@@ -70,11 +70,11 @@
 		this.json = json;
 	}
 
-	public TitanVertex getVertex() {
+	public JanusGraphVertex getVertex() {
 		return vertex;
 	}
 
-	public void setVertex(TitanVertex vertex) {
+	public void setVertex(JanusGraphVertex vertex) {
 		this.vertex = vertex;
 	}
 
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/HealingTitanDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/HealingJanusGraphDao.java
similarity index 74%
rename from catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/HealingTitanDao.java
rename to catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/HealingJanusGraphDao.java
index fb6b9d8..c2ef659 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/HealingTitanDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/HealingJanusGraphDao.java
@@ -21,29 +21,29 @@
 import java.util.Optional;
 import java.util.stream.Collectors;
 import org.openecomp.sdc.be.dao.impl.HealingPipelineDao;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphClient;
 import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
 import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
-import org.openecomp.sdc.be.dao.titan.TitanGraphClient;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
-@Component("titan-dao")
-public class HealingTitanDao extends TitanDao {
+@Component("janusgraph-dao")
+public class HealingJanusGraphDao extends JanusGraphDao {
 
 
     @Autowired
     private HealingPipelineDao healingPipelineDao;
 
 
-    public HealingTitanDao(TitanGraphClient titanClient) {
-        super(titanClient);
+    public HealingJanusGraphDao(JanusGraphClient janusGraphClient) {
+        super(janusGraphClient);
     }
 
     @Override
-    public Either<List<GraphVertex>, TitanOperationStatus> getChildrenVertecies(GraphVertex parentVertex,
-            EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
-        Either<List<GraphVertex>, TitanOperationStatus> childrenVertecies =
+    public Either<List<GraphVertex>, JanusGraphOperationStatus> getChildrenVertecies(GraphVertex parentVertex,
+                                                                                     EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
+        Either<List<GraphVertex>, JanusGraphOperationStatus> childrenVertecies =
                 super.getChildrenVertecies(parentVertex, edgeLabel, parseFlag);
         return Either.iif(childrenVertecies.isRight(), () -> childrenVertecies.right().value(),
                 () -> childrenVertecies.left().value().stream()
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/TitanDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/JanusGraphDao.java
similarity index 69%
rename from catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/TitanDao.java
rename to catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/JanusGraphDao.java
index a31900a..5917b14 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/TitanDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/JanusGraphDao.java
@@ -20,19 +20,19 @@
 
 package org.openecomp.sdc.be.dao.jsongraph;
 
-import com.thinkaurelius.titan.core.*;
+import org.janusgraph.core.*;
 import fj.data.Either;
 import org.apache.commons.collections.MapUtils;
 import org.apache.commons.lang3.tuple.ImmutablePair;
 import org.apache.tinkerpop.gremlin.structure.*;
 import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphClient;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
 import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
 import org.openecomp.sdc.be.dao.jsongraph.types.EdgePropertyEnum;
 import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
 import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
 import org.openecomp.sdc.be.dao.jsongraph.utils.JsonParserUtils;
-import org.openecomp.sdc.be.dao.titan.TitanGraphClient;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
 import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
 import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
@@ -40,7 +40,6 @@
 import org.openecomp.sdc.common.jsongraph.util.CommonUtility.LogLevelEnum;
 import org.openecomp.sdc.common.log.wrappers.Logger;
 import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.stereotype.Component;
 
 import java.io.IOException;
 import java.util.*;
@@ -49,28 +48,28 @@
 import static org.apache.commons.collections.CollectionUtils.isEmpty;
 
 
-public class TitanDao {
-    TitanGraphClient titanClient;
+public class JanusGraphDao {
+    JanusGraphClient janusGraphClient;
 
-    private static Logger logger = Logger.getLogger(TitanDao.class.getName());
+    private static Logger logger = Logger.getLogger(JanusGraphDao.class.getName());
 
-    public TitanDao(@Qualifier("titan-client") TitanGraphClient titanClient) {
-        this.titanClient = titanClient;
-        logger.info("** TitanDao created");
+    public JanusGraphDao(@Qualifier("janusgraph-client") JanusGraphClient janusGraphClient) {
+        this.janusGraphClient = janusGraphClient;
+        logger.info("** JanusGraphDao created");
     }
 
-    public TitanOperationStatus commit() {
+    public JanusGraphOperationStatus commit() {
         logger.debug("#commit - The operation succeeded. Doing commit...");
-        return titanClient.commit();
+        return janusGraphClient.commit();
     }
 
-    public TitanOperationStatus rollback() {
+    public JanusGraphOperationStatus rollback() {
         logger.debug("#rollback - The operation failed. Doing rollback...");
-        return titanClient.rollback();
+        return janusGraphClient.rollback();
     }
 
-    public Either<TitanGraph, TitanOperationStatus> getGraph() {
-        return titanClient.getGraph();
+    public Either<JanusGraph, JanusGraphOperationStatus> getGraph() {
+        return janusGraphClient.getGraph();
     }
 
     /**
@@ -78,14 +77,14 @@
      * @param graphVertex
      * @return
      */
-    public Either<GraphVertex, TitanOperationStatus> createVertex(GraphVertex graphVertex) {
+    public Either<GraphVertex, JanusGraphOperationStatus> createVertex(GraphVertex graphVertex) {
         logger.trace("try to create vertex for ID [{}]", graphVertex.getUniqueId());
-        Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+        Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
         if (graph.isLeft()) {
             try {
-                TitanGraph tGraph = graph.left().value();
+                JanusGraph tGraph = graph.left().value();
 
-                TitanVertex vertex = tGraph.addVertex();
+                JanusGraphVertex vertex = tGraph.addVertex();
 
                 setVertexProperties(vertex, graphVertex);
 
@@ -95,7 +94,7 @@
 
             } catch (Exception e) {
                 logger.debug("Failed to create Node for ID [{}]", graphVertex.getUniqueId(), e);
-                return Either.right(TitanGraphClient.handleTitanException(e));
+                return Either.right(JanusGraphClient.handleJanusGraphException(e));
             }
         } else {
             logger.debug("Failed to create vertex for ID [{}]  {}", graphVertex.getUniqueId(), graph.right().value());
@@ -110,23 +109,23 @@
      * @param label
      * @return
      */
-    public Either<GraphVertex, TitanOperationStatus> getVertexByPropertyAndLabel(GraphPropertyEnum name, Object value, VertexTypeEnum label) {
+    public Either<GraphVertex, JanusGraphOperationStatus> getVertexByPropertyAndLabel(GraphPropertyEnum name, Object value, VertexTypeEnum label) {
         return getVertexByPropertyAndLabel(name, value, label, JsonParseFlagEnum.ParseAll);
     }
 
-    public Either<GraphVertex, TitanOperationStatus> getVertexByLabel(VertexTypeEnum label) {
-        return titanClient.getGraph().left().map(graph -> graph.query().has(GraphPropertyEnum.LABEL.getProperty(), label.getName()).vertices()).left().bind(titanVertices -> getFirstFoundVertex(JsonParseFlagEnum.NoParse, titanVertices));
+    public Either<GraphVertex, JanusGraphOperationStatus> getVertexByLabel(VertexTypeEnum label) {
+        return janusGraphClient.getGraph().left().map(graph -> graph.query().has(GraphPropertyEnum.LABEL.getProperty(), label.getName()).vertices()).left().bind(janusGraphVertices -> getFirstFoundVertex(JsonParseFlagEnum.NoParse, janusGraphVertices));
     }
 
-    private Either<GraphVertex, TitanOperationStatus> getFirstFoundVertex(JsonParseFlagEnum parseFlag, Iterable<TitanVertex> vertices) {
-        Iterator<TitanVertex> iterator = vertices.iterator();
+    private Either<GraphVertex, JanusGraphOperationStatus> getFirstFoundVertex(JsonParseFlagEnum parseFlag, Iterable<JanusGraphVertex> vertices) {
+        Iterator<JanusGraphVertex> iterator = vertices.iterator();
         if (iterator.hasNext()) {
-            TitanVertex vertex = iterator.next();
+            JanusGraphVertex vertex = iterator.next();
             GraphVertex graphVertex = createAndFill(vertex, parseFlag);
 
             return Either.left(graphVertex);
         }
-        return Either.right(TitanOperationStatus.NOT_FOUND);
+        return Either.right(JanusGraphOperationStatus.NOT_FOUND);
     }
 
     /**
@@ -137,19 +136,19 @@
      * @param parseFlag
      * @return
      */
-    public Either<GraphVertex, TitanOperationStatus> getVertexByPropertyAndLabel(GraphPropertyEnum name, Object value, VertexTypeEnum label, JsonParseFlagEnum parseFlag) {
+    public Either<GraphVertex, JanusGraphOperationStatus> getVertexByPropertyAndLabel(GraphPropertyEnum name, Object value, VertexTypeEnum label, JsonParseFlagEnum parseFlag) {
 
-        Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+        Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
         if (graph.isLeft()) {
             try {
-                TitanGraph tGraph = graph.left().value();
+                JanusGraph tGraph = graph.left().value();
 
                 @SuppressWarnings("unchecked")
-                Iterable<TitanVertex> vertecies = tGraph.query().has(name.getProperty(), value).has(GraphPropertyEnum.LABEL.getProperty(), label.getName()).vertices();
+                Iterable<JanusGraphVertex> vertecies = tGraph.query().has(name.getProperty(), value).has(GraphPropertyEnum.LABEL.getProperty(), label.getName()).vertices();
 
-                java.util.Iterator<TitanVertex> iterator = vertecies.iterator();
+                java.util.Iterator<JanusGraphVertex> iterator = vertecies.iterator();
                 if (iterator.hasNext()) {
-                    TitanVertex vertex = iterator.next();
+                    JanusGraphVertex vertex = iterator.next();
                     GraphVertex graphVertex = createAndFill(vertex, parseFlag);
 
                     return Either.left(graphVertex);
@@ -157,12 +156,12 @@
                 if (logger.isDebugEnabled()) {
                     logger.debug("No vertex in graph for key = {}  and value = {}   label = {}" + name, value, label);
                 }
-                return Either.right(TitanOperationStatus.NOT_FOUND);
+                return Either.right(JanusGraphOperationStatus.NOT_FOUND);
             } catch (Exception e) {
                 if (logger.isDebugEnabled()) {
                     logger.debug("Failed to get vertex in graph for key ={} and value = {}  label = {}", name, value, label);
                 }
-                return Either.right(TitanGraphClient.handleTitanException(e));
+                return Either.right(JanusGraphClient.handleJanusGraphException(e));
             }
 
         } else {
@@ -178,7 +177,7 @@
      * @param id
      * @return
      */
-    public Either<GraphVertex, TitanOperationStatus> getVertexById(String id) {
+    public Either<GraphVertex, JanusGraphOperationStatus> getVertexById(String id) {
         return getVertexById(id, JsonParseFlagEnum.ParseAll);
     }
 
@@ -188,38 +187,38 @@
      * @param parseFlag
      * @return
      */
-    public Either<GraphVertex, TitanOperationStatus> getVertexById(String id, JsonParseFlagEnum parseFlag) {
+    public Either<GraphVertex, JanusGraphOperationStatus> getVertexById(String id, JsonParseFlagEnum parseFlag) {
 
-        Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+        Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
         if (id == null) {
             if (logger.isDebugEnabled()) {
                 logger.debug("No vertex in graph for id = {} ", id);
             }
-            return Either.right(TitanOperationStatus.NOT_FOUND);
+            return Either.right(JanusGraphOperationStatus.NOT_FOUND);
         }
         if (graph.isLeft()) {
             try {
-                TitanGraph tGraph = graph.left().value();
+                JanusGraph tGraph = graph.left().value();
 
                 @SuppressWarnings("unchecked")
-                Iterable<TitanVertex> vertecies = tGraph.query().has(GraphPropertyEnum.UNIQUE_ID.getProperty(), id).vertices();
+                Iterable<JanusGraphVertex> vertecies = tGraph.query().has(GraphPropertyEnum.UNIQUE_ID.getProperty(), id).vertices();
 
-                java.util.Iterator<TitanVertex> iterator = vertecies.iterator();
+                java.util.Iterator<JanusGraphVertex> iterator = vertecies.iterator();
                 if (iterator.hasNext()) {
-                    TitanVertex vertex = iterator.next();
+                    JanusGraphVertex vertex = iterator.next();
                     GraphVertex graphVertex = createAndFill(vertex, parseFlag);
                     return Either.left(graphVertex);
                 } else {
                     if (logger.isDebugEnabled()) {
                         logger.debug("No vertex in graph for id = {}", id);
                     }
-                    return Either.right(TitanOperationStatus.NOT_FOUND);
+                    return Either.right(JanusGraphOperationStatus.NOT_FOUND);
                 }
             } catch (Exception e) {
                 if (logger.isDebugEnabled()) {
                     logger.debug("Failed to get vertex in graph for id {} ", id);
                 }
-                return Either.right(TitanGraphClient.handleTitanException(e));
+                return Either.right(JanusGraphClient.handleJanusGraphException(e));
             }
         } else {
             if (logger.isDebugEnabled()) {
@@ -229,7 +228,7 @@
         }
     }
 
-    private void setVertexProperties(TitanVertex vertex, GraphVertex graphVertex) throws IOException {
+    private void setVertexProperties(JanusGraphVertex vertex, GraphVertex graphVertex) throws IOException {
 
         if (graphVertex.getMetadataProperties() != null) {
             for (Map.Entry<GraphPropertyEnum, Object> entry : graphVertex.getMetadataProperties().entrySet()) {
@@ -261,7 +260,7 @@
         }
     }
 
-    private GraphVertex createAndFill(TitanVertex vertex, JsonParseFlagEnum parseFlag) {
+    private GraphVertex createAndFill(JanusGraphVertex vertex, JsonParseFlagEnum parseFlag) {
         GraphVertex graphVertex = new GraphVertex();
         graphVertex.setVertex(vertex);
         parseVertexProperties(graphVertex, parseFlag);
@@ -269,7 +268,7 @@
     }
 
     public void parseVertexProperties(GraphVertex graphVertex, JsonParseFlagEnum parseFlag) {
-        TitanVertex vertex = graphVertex.getVertex();
+        JanusGraphVertex vertex = graphVertex.getVertex();
         Map<GraphPropertyEnum, Object> properties = getVertexProperties(vertex);
         VertexTypeEnum label = VertexTypeEnum.getByName((String) (properties.get(GraphPropertyEnum.LABEL)));
         for (Map.Entry<GraphPropertyEnum, Object> entry : properties.entrySet()) {
@@ -308,30 +307,30 @@
         }
     }
 
-    public TitanOperationStatus createEdge(GraphVertex from, GraphVertex to, EdgeLabelEnum label, Map<EdgePropertyEnum, Object> properties) {
+    public JanusGraphOperationStatus createEdge(GraphVertex from, GraphVertex to, EdgeLabelEnum label, Map<EdgePropertyEnum, Object> properties) {
         return createEdge(from.getVertex(), to.getVertex(), label, properties);
     }
 
-    public TitanOperationStatus createEdge(Vertex from, Vertex to, EdgeLabelEnum label, Map<EdgePropertyEnum, Object> properties) {
+    public JanusGraphOperationStatus createEdge(Vertex from, Vertex to, EdgeLabelEnum label, Map<EdgePropertyEnum, Object> properties) {
         if (logger.isTraceEnabled()) {
             logger.trace("Try to connect {} with {} label {} properties {}",
                     from == null ? "NULL" : from.property(GraphPropertyEnum.UNIQUE_ID.getProperty()),
                     to == null ? "NULL" : to.property(GraphPropertyEnum.UNIQUE_ID.getProperty()), label, properties);
         }
         if (from == null || to == null) {
-            logger.trace("No Titan vertex for id from {} or id to {}",
+            logger.trace("No JanusGraph vertex for id from {} or id to {}",
                     from == null ? "NULL" : from.property(GraphPropertyEnum.UNIQUE_ID.getProperty()),
                     to == null ? "NULL" : to.property(GraphPropertyEnum.UNIQUE_ID.getProperty()));
-            return TitanOperationStatus.NOT_FOUND;
+            return JanusGraphOperationStatus.NOT_FOUND;
         }
         Edge edge = from.addEdge(label.name(), to);
-        TitanOperationStatus status;
+        JanusGraphOperationStatus status;
         try {
             setEdgeProperties(edge, properties);
-            status = TitanOperationStatus.OK;
+            status = JanusGraphOperationStatus.OK;
         } catch (IOException e) {
             logger.debug("Failed to set properties on edge  properties [{}]", properties, e);
-            status = TitanOperationStatus.GENERAL_ERROR;
+            status = JanusGraphOperationStatus.GENERAL_ERROR;
         }
         return status;
     }
@@ -401,17 +400,17 @@
         }
     }
 
-    public Either<List<GraphVertex>, TitanOperationStatus> getByCriteria(VertexTypeEnum type, Map<GraphPropertyEnum, Object> props) {
+    public Either<List<GraphVertex>, JanusGraphOperationStatus> getByCriteria(VertexTypeEnum type, Map<GraphPropertyEnum, Object> props) {
         return getByCriteria(type, props, JsonParseFlagEnum.ParseAll);
     }
 
-    public Either<List<GraphVertex>, TitanOperationStatus> getByCriteria(VertexTypeEnum type, Map<GraphPropertyEnum, Object> props, JsonParseFlagEnum parseFlag) {
-        Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+    public Either<List<GraphVertex>, JanusGraphOperationStatus> getByCriteria(VertexTypeEnum type, Map<GraphPropertyEnum, Object> props, JsonParseFlagEnum parseFlag) {
+        Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
         if (graph.isLeft()) {
             try {
-                TitanGraph tGraph = graph.left().value();
+                JanusGraph tGraph = graph.left().value();
 
-                TitanGraphQuery<? extends TitanGraphQuery> query = tGraph.query();
+                JanusGraphQuery<? extends JanusGraphQuery> query = tGraph.query();
                 if (type != null) {
                     query = query.has(GraphPropertyEnum.LABEL.getProperty(), type.getName());
                 }
@@ -421,16 +420,16 @@
                         query = query.has(entry.getKey().getProperty(), entry.getValue());
                     }
                 }
-                Iterable<TitanVertex> vertices = query.vertices();
+                Iterable<JanusGraphVertex> vertices = query.vertices();
                 if (vertices == null) {
-                    return Either.right(TitanOperationStatus.NOT_FOUND);
+                    return Either.right(JanusGraphOperationStatus.NOT_FOUND);
                 }
 
-                Iterator<TitanVertex> iterator = vertices.iterator();
+                Iterator<JanusGraphVertex> iterator = vertices.iterator();
                 List<GraphVertex> result = new ArrayList<>();
 
                 while (iterator.hasNext()) {
-                    TitanVertex vertex = iterator.next();
+                    JanusGraphVertex vertex = iterator.next();
 
                     Map<GraphPropertyEnum, Object> newProp = getVertexProperties(vertex);
                     GraphVertex graphVertex = createAndFill(vertex, parseFlag);
@@ -441,7 +440,7 @@
                     logger.debug("Number of fetced nodes in graph for criteria : from type = {} and properties = {} is {}", type, props, result.size());
                 }
                 if (result.size() == 0) {
-                    return Either.right(TitanOperationStatus.NOT_FOUND);
+                    return Either.right(JanusGraphOperationStatus.NOT_FOUND);
                 }
 
                 return Either.left(result);
@@ -449,7 +448,7 @@
                 if (logger.isDebugEnabled()) {
                     logger.debug("Failed  get by  criteria for type = {} and properties = {}", type, props, e);
                 }
-                return Either.right(TitanGraphClient.handleTitanException(e));
+                return Either.right(JanusGraphClient.handleJanusGraphException(e));
             }
 
         } else {
@@ -460,13 +459,13 @@
         }
     }
 
-    public Either<List<GraphVertex>, TitanOperationStatus> getByCriteria(VertexTypeEnum type, Map<GraphPropertyEnum, Object> props, Map<GraphPropertyEnum, Object> hasNotProps, JsonParseFlagEnum parseFlag) {
-        Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+    public Either<List<GraphVertex>, JanusGraphOperationStatus> getByCriteria(VertexTypeEnum type, Map<GraphPropertyEnum, Object> props, Map<GraphPropertyEnum, Object> hasNotProps, JsonParseFlagEnum parseFlag) {
+        Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
         if (graph.isLeft()) {
             try {
-                TitanGraph tGraph = graph.left().value();
+                JanusGraph tGraph = graph.left().value();
 
-                TitanGraphQuery<? extends TitanGraphQuery> query = tGraph.query();
+                JanusGraphQuery<? extends JanusGraphQuery> query = tGraph.query();
                 if (type != null) {
                     query = query.has(GraphPropertyEnum.LABEL.getProperty(), type.getName());
                 }
@@ -485,16 +484,16 @@
                         }
                     }
                 }
-                Iterable<TitanVertex> vertices = query.vertices();
+                Iterable<JanusGraphVertex> vertices = query.vertices();
                 if (vertices == null) {
-                    return Either.right(TitanOperationStatus.NOT_FOUND);
+                    return Either.right(JanusGraphOperationStatus.NOT_FOUND);
                 }
 
-                Iterator<TitanVertex> iterator = vertices.iterator();
+                Iterator<JanusGraphVertex> iterator = vertices.iterator();
                 List<GraphVertex> result = new ArrayList<>();
 
                 while (iterator.hasNext()) {
-                    TitanVertex vertex = iterator.next();
+                    JanusGraphVertex vertex = iterator.next();
 
                     Map<GraphPropertyEnum, Object> newProp = getVertexProperties(vertex);
                     GraphVertex graphVertex = createAndFill(vertex, parseFlag);
@@ -505,7 +504,7 @@
                     logger.debug("Number of fetced nodes in graph for criteria : from type = {} and properties = {} is {}", type, props, result.size());
                 }
                 if (result.size() == 0) {
-                    return Either.right(TitanOperationStatus.NOT_FOUND);
+                    return Either.right(JanusGraphOperationStatus.NOT_FOUND);
                 }
 
                 return Either.left(result);
@@ -513,7 +512,7 @@
                 if (logger.isDebugEnabled()) {
                     logger.debug("Failed  get by  criteria for type = {} and properties = {}", type, props, e);
                 }
-                return Either.right(TitanGraphClient.handleTitanException(e));
+                return Either.right(JanusGraphClient.handleJanusGraphException(e));
             }
 
         } else {
@@ -524,22 +523,22 @@
         }
     }
 
-    public Either<Iterator<Vertex>, TitanOperationStatus> getCatalogOrArchiveVerticies(boolean isCatalog) {
-        Either<TitanGraph, TitanOperationStatus> graph = titanClient.getGraph();
+    public Either<Iterator<Vertex>, JanusGraphOperationStatus> getCatalogOrArchiveVerticies(boolean isCatalog) {
+        Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
         if (graph.isLeft()) {
             try {
-                TitanGraph tGraph = graph.left().value();
+                JanusGraph tGraph = graph.left().value();
 
                 String name = isCatalog ? VertexTypeEnum.CATALOG_ROOT.getName() : VertexTypeEnum.ARCHIVE_ROOT.getName();
-                Iterable<TitanVertex> vCatalogIter = tGraph.query().has(GraphPropertyEnum.LABEL.getProperty(), name).vertices();
+                Iterable<JanusGraphVertex> vCatalogIter = tGraph.query().has(GraphPropertyEnum.LABEL.getProperty(), name).vertices();
                 if (vCatalogIter == null) {
                     logger.debug("Failed to fetch catalog vertex");
-                    return Either.right(TitanOperationStatus.GENERAL_ERROR);
+                    return Either.right(JanusGraphOperationStatus.GENERAL_ERROR);
                 }
-                TitanVertex catalogV = vCatalogIter.iterator().next();
+                JanusGraphVertex catalogV = vCatalogIter.iterator().next();
                 if (catalogV == null) {
                     logger.debug("Failed to fetch catalog vertex");
-                    return Either.right(TitanOperationStatus.GENERAL_ERROR);
+                    return Either.right(JanusGraphOperationStatus.GENERAL_ERROR);
                 }
                 String edgeLabel = isCatalog ? EdgeLabelEnum.CATALOG_ELEMENT.name() : EdgeLabelEnum.ARCHIVE_ELEMENT.name();
                 Iterator<Vertex> vertices = catalogV.vertices(Direction.OUT, edgeLabel);
@@ -549,7 +548,7 @@
                 if (logger.isDebugEnabled()) {
                     logger.debug("Failed  get by  criteria: ", e);
                 }
-                return Either.right(TitanGraphClient.handleTitanException(e));
+                return Either.right(JanusGraphClient.handleJanusGraphException(e));
             }
 
         } else {
@@ -560,7 +559,7 @@
         }
     }
 
-    private void buildMultipleNegateQueryFromList(Map.Entry<GraphPropertyEnum, Object> entry, TitanGraphQuery query) {
+    private void buildMultipleNegateQueryFromList(Map.Entry<GraphPropertyEnum, Object> entry, JanusGraphQuery query) {
         List<Object> negateList = (List<Object>) entry.getValue();
         for (Object listItem : negateList) {
             query.hasNot(entry.getKey().getProperty(), listItem);
@@ -574,8 +573,8 @@
      * @param parseFlag
      * @return
      */
-    public Either<GraphVertex, TitanOperationStatus> getChildVertex(GraphVertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
-        Either<List<GraphVertex>, TitanOperationStatus> childrenVertecies = getChildrenVertecies(parentVertex, edgeLabel, parseFlag);
+    public Either<GraphVertex, JanusGraphOperationStatus> getChildVertex(GraphVertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
+        Either<List<GraphVertex>, JanusGraphOperationStatus> childrenVertecies = getChildrenVertecies(parentVertex, edgeLabel, parseFlag);
         if (childrenVertecies.isRight()) {
             return Either.right(childrenVertecies.right().value());
         }
@@ -589,32 +588,32 @@
      * @param parseFlag
      * @return
      */
-    public Either<Vertex, TitanOperationStatus> getChildVertex(Vertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
-        Either<List<Vertex>, TitanOperationStatus> childrenVertecies = getChildrenVertecies(parentVertex, edgeLabel, parseFlag);
+    public Either<Vertex, JanusGraphOperationStatus> getChildVertex(Vertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
+        Either<List<Vertex>, JanusGraphOperationStatus> childrenVertecies = getChildrenVertecies(parentVertex, edgeLabel, parseFlag);
         if (childrenVertecies.isRight()) {
             return Either.right(childrenVertecies.right().value());
         }
         return Either.left(childrenVertecies.left().value().get(0));
     }
 
-    public Either<GraphVertex, TitanOperationStatus> getParentVertex(GraphVertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
-        Either<List<GraphVertex>, TitanOperationStatus> childrenVertecies = getParentVertecies(parentVertex, edgeLabel, parseFlag);
+    public Either<GraphVertex, JanusGraphOperationStatus> getParentVertex(GraphVertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
+        Either<List<GraphVertex>, JanusGraphOperationStatus> childrenVertecies = getParentVertecies(parentVertex, edgeLabel, parseFlag);
         if (childrenVertecies.isRight()) {
             return Either.right(childrenVertecies.right().value());
         }
         if (isEmpty(childrenVertecies.left().value())){
-            return Either.right(TitanOperationStatus.NOT_FOUND);
+            return Either.right(JanusGraphOperationStatus.NOT_FOUND);
         }
         return Either.left(childrenVertecies.left().value().get(0));
     }
 
-    public Either<Vertex, TitanOperationStatus> getParentVertex(Vertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
-        Either<List<Vertex>, TitanOperationStatus> childrenVertecies = getParentVertecies(parentVertex, edgeLabel, parseFlag);
+    public Either<Vertex, JanusGraphOperationStatus> getParentVertex(Vertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
+        Either<List<Vertex>, JanusGraphOperationStatus> childrenVertecies = getParentVertecies(parentVertex, edgeLabel, parseFlag);
         if (childrenVertecies.isRight() ) {
             return Either.right(childrenVertecies.right().value());
         }
         if (isEmpty(childrenVertecies.left().value())){
-            return Either.right(TitanOperationStatus.NOT_FOUND);
+            return Either.right(JanusGraphOperationStatus.NOT_FOUND);
         }
         return Either.left(childrenVertecies.left().value().get(0));
     }
@@ -626,22 +625,22 @@
      * @param parseFlag
      * @return
      */
-    public Either<List<GraphVertex>, TitanOperationStatus> getChildrenVertecies(GraphVertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
+    public Either<List<GraphVertex>, JanusGraphOperationStatus> getChildrenVertecies(GraphVertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
         return getAdjacentVerticies(parentVertex, edgeLabel, parseFlag, Direction.OUT);
     }
 
-    public Either<List<GraphVertex>, TitanOperationStatus> getParentVertecies(GraphVertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
+    public Either<List<GraphVertex>, JanusGraphOperationStatus> getParentVertecies(GraphVertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
         return getAdjacentVerticies(parentVertex, edgeLabel, parseFlag, Direction.IN);
     }
 
-    public Either<List<Vertex>, TitanOperationStatus> getParentVertecies(Vertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
+    public Either<List<Vertex>, JanusGraphOperationStatus> getParentVertecies(Vertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
         return getAdjacentVerticies(parentVertex, edgeLabel, parseFlag, Direction.IN);
     }
 
-    private Either<List<Vertex>, TitanOperationStatus> getAdjacentVerticies(Vertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag, Direction direction) {
+    private Either<List<Vertex>, JanusGraphOperationStatus> getAdjacentVerticies(Vertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag, Direction direction) {
         List<Vertex> list = new ArrayList<>();
         try {
-            Either<TitanGraph, TitanOperationStatus> graphRes = titanClient.getGraph();
+            Either<JanusGraph, JanusGraphOperationStatus> graphRes = janusGraphClient.getGraph();
             if (graphRes.isRight()) {
                 logger.error("Failed to retrieve graph. status is {}", graphRes);
                 return Either.right(graphRes.right().value());
@@ -650,11 +649,11 @@
             if (edgesCreatorIterator != null) {
                 while (edgesCreatorIterator.hasNext()) {
                     Edge edge = edgesCreatorIterator.next();
-                    TitanVertex vertex;
+                    JanusGraphVertex vertex;
                     if (direction == Direction.IN) {
-                        vertex = (TitanVertex) edge.outVertex();
+                        vertex = (JanusGraphVertex) edge.outVertex();
                     } else {
-                        vertex = (TitanVertex) edge.inVertex();
+                        vertex = (JanusGraphVertex) edge.inVertex();
                     }
                     // GraphVertex graphVertex = createAndFill(vertex, parseFlag);
 
@@ -662,11 +661,11 @@
                 }
             }
             if (list.isEmpty()) {
-                return Either.right(TitanOperationStatus.NOT_FOUND);
+                return Either.right(JanusGraphOperationStatus.NOT_FOUND);
             }
         } catch (Exception e) {
             logger.error("Failed to perform graph operation ", e);
-            Either.right(TitanGraphClient.handleTitanException(e));
+            Either.right(JanusGraphClient.handleJanusGraphException(e));
         }
 
         return Either.left(list);
@@ -679,19 +678,19 @@
      * @param parseFlag
      * @return
      */
-    public Either<List<Vertex>, TitanOperationStatus> getChildrenVertecies(Vertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
+    public Either<List<Vertex>, JanusGraphOperationStatus> getChildrenVertecies(Vertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
         return getAdjacentVerticies(parentVertex, edgeLabel, parseFlag, Direction.OUT);
     }
 
-    private Either<List<GraphVertex>, TitanOperationStatus> getAdjacentVerticies(GraphVertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag, Direction direction) {
+    private Either<List<GraphVertex>, JanusGraphOperationStatus> getAdjacentVerticies(GraphVertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag, Direction direction) {
         List<GraphVertex> list = new ArrayList<>();
 
-        Either<List<Vertex>, TitanOperationStatus> adjacentVerticies = getAdjacentVerticies(parentVertex.getVertex(), edgeLabel, parseFlag, direction);
+        Either<List<Vertex>, JanusGraphOperationStatus> adjacentVerticies = getAdjacentVerticies(parentVertex.getVertex(), edgeLabel, parseFlag, direction);
         if (adjacentVerticies.isRight()) {
             return Either.right(adjacentVerticies.right().value());
         }
         adjacentVerticies.left().value().stream().forEach(vertex -> {
-            list.add(createAndFill((TitanVertex) vertex, parseFlag));
+            list.add(createAndFill((JanusGraphVertex) vertex, parseFlag));
         });
 
         return Either.left(list);
@@ -703,15 +702,15 @@
      * @param vertex
      * @param label
      * @param properties
-     * @return found edge or TitanOperationStatus
+     * @return found edge or JanusGraphOperationStatus
      */
-    public Either<Edge, TitanOperationStatus> getBelongingEdgeByCriteria(GraphVertex vertex, EdgeLabelEnum label, Map<GraphPropertyEnum, Object> properties) {
+    public Either<Edge, JanusGraphOperationStatus> getBelongingEdgeByCriteria(GraphVertex vertex, EdgeLabelEnum label, Map<GraphPropertyEnum, Object> properties) {
 
-        Either<Edge, TitanOperationStatus> result = null;
+        Either<Edge, JanusGraphOperationStatus> result = null;
         Edge matchingEdge = null;
         String notFoundMsg = "No edges in graph for criteria";
         try {
-            TitanVertexQuery<?> query = vertex.getVertex().query().labels(label.name());
+            JanusGraphVertexQuery<?> query = vertex.getVertex().query().labels(label.name());
 
             if (properties != null && !properties.isEmpty()) {
                 for (Map.Entry<GraphPropertyEnum, Object> entry : properties.entrySet()) {
@@ -719,17 +718,17 @@
                 }
             }
 
-            Iterable<TitanEdge> edges = query.edges();
+            Iterable<JanusGraphEdge> edges = query.edges();
             if (edges == null) {
                 CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, notFoundMsg);
-                result = Either.right(TitanOperationStatus.NOT_FOUND);
+                result = Either.right(JanusGraphOperationStatus.NOT_FOUND);
             } else {
-                Iterator<TitanEdge> eIter = edges.iterator();
+                Iterator<JanusGraphEdge> eIter = edges.iterator();
                 if (eIter.hasNext()) {
                     matchingEdge = eIter.next();
                 } else {
                     CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, notFoundMsg);
-                    result = Either.right(TitanOperationStatus.NOT_FOUND);
+                    result = Either.right(JanusGraphOperationStatus.NOT_FOUND);
                 }
             }
             if (result == null) {
@@ -737,13 +736,13 @@
             }
         } catch (Exception e) {
             CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occured during getting edge by criteria for component with id {}. {}", vertex.getUniqueId(), e);
-            return Either.right(TitanGraphClient.handleTitanException(e));
+            return Either.right(JanusGraphClient.handleJanusGraphException(e));
         }
         return result;
     }
 
-    public Either<Edge, TitanOperationStatus> getEdgeByChildrenVertexProperties(GraphVertex vertex, EdgeLabelEnum label, Map<GraphPropertyEnum, Object> properties) {
-        Either<Edge, TitanOperationStatus> result = null;
+    public Either<Edge, JanusGraphOperationStatus> getEdgeByChildrenVertexProperties(GraphVertex vertex, EdgeLabelEnum label, Map<GraphPropertyEnum, Object> properties) {
+        Either<Edge, JanusGraphOperationStatus> result = null;
         Edge matchingEdge = null;
         String notFoundMsg = "No edges in graph for criteria";
         try {
@@ -761,11 +760,11 @@
             if (result == null) {
                 //no match 
                 CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, notFoundMsg);
-                result = Either.right(TitanOperationStatus.NOT_FOUND);
+                result = Either.right(JanusGraphOperationStatus.NOT_FOUND);
             }
         } catch (Exception e) {
             CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occured during getting edge by criteria for component with id {}. {}", vertex.getUniqueId(), e);
-            return Either.right(TitanGraphClient.handleTitanException(e));
+            return Either.right(JanusGraphClient.handleJanusGraphException(e));
         }
         return result;
     }
@@ -778,8 +777,8 @@
      * @param properties
      * @return
      */
-    public Either<Edge, TitanOperationStatus> deleteBelongingEdgeByCriteria(GraphVertex vertex, EdgeLabelEnum label, Map<GraphPropertyEnum, Object> properties) {
-        Either<Edge, TitanOperationStatus> result = null;
+    public Either<Edge, JanusGraphOperationStatus> deleteBelongingEdgeByCriteria(GraphVertex vertex, EdgeLabelEnum label, Map<GraphPropertyEnum, Object> properties) {
+        Either<Edge, JanusGraphOperationStatus> result = null;
         try {
             result = getBelongingEdgeByCriteria(vertex, label, properties);
             if (result.isLeft()) {
@@ -792,7 +791,7 @@
             }
         } catch (Exception e) {
             CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occured during deleting an edge by criteria for the component with id {}. {}", vertex == null ? "NULL" : vertex.getUniqueId(), e);
-            return Either.right(TitanGraphClient.handleTitanException(e));
+            return Either.right(JanusGraphClient.handleJanusGraphException(e));
         }
         return result;
     }
@@ -807,19 +806,19 @@
      * @return
      */
 
-    public Either<Edge, TitanOperationStatus> deleteEdge(GraphVertex fromVertex, GraphVertex toVertex, EdgeLabelEnum label) {
+    public Either<Edge, JanusGraphOperationStatus> deleteEdge(GraphVertex fromVertex, GraphVertex toVertex, EdgeLabelEnum label) {
         return deleteEdge(fromVertex.getVertex(), toVertex.getVertex(), label, fromVertex.getUniqueId(), toVertex.getUniqueId(), false);
     }
 
-    public Either<Edge, TitanOperationStatus> deleteAllEdges(GraphVertex fromVertex, GraphVertex toVertex, EdgeLabelEnum label) {
+    public Either<Edge, JanusGraphOperationStatus> deleteAllEdges(GraphVertex fromVertex, GraphVertex toVertex, EdgeLabelEnum label) {
         return deleteEdge(fromVertex.getVertex(), toVertex.getVertex(), label, fromVertex.getUniqueId(), toVertex.getUniqueId(), true);
     }
 
-    public Either<Edge, TitanOperationStatus> deleteEdge(TitanVertex fromVertex, TitanVertex toVertex, EdgeLabelEnum label, String uniqueIdFrom, String uniqueIdTo, boolean deleteAll) {
-        Either<Edge, TitanOperationStatus> result = null;
+    public Either<Edge, JanusGraphOperationStatus> deleteEdge(JanusGraphVertex fromVertex, JanusGraphVertex toVertex, EdgeLabelEnum label, String uniqueIdFrom, String uniqueIdTo, boolean deleteAll) {
+        Either<Edge, JanusGraphOperationStatus> result = null;
         try {
-            Iterable<TitanEdge> edges = fromVertex.query().labels(label.name()).edges();
-            Iterator<TitanEdge> eIter = edges.iterator();
+            Iterable<JanusGraphEdge> edges = fromVertex.query().labels(label.name()).edges();
+            Iterator<JanusGraphEdge> eIter = edges.iterator();
             while (eIter.hasNext()) {
                 Edge edge = eIter.next();
                 String currVertexUniqueId = edge.inVertex().value(GraphPropertyEnum.UNIQUE_ID.getProperty());
@@ -834,16 +833,16 @@
             }
             if (result == null) {
                 CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to delete an edge with the label {} between vertices {} and {}. ", label.name(), uniqueIdFrom, uniqueIdTo);
-                result = Either.right(TitanOperationStatus.NOT_FOUND);
+                result = Either.right(JanusGraphOperationStatus.NOT_FOUND);
             }
         } catch (Exception e) {
             CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occured during deleting an edge with the label {} between vertices {} and {}. {}", label.name(), uniqueIdFrom, uniqueIdTo, e);
-            return Either.right(TitanGraphClient.handleTitanException(e));
+            return Either.right(JanusGraphClient.handleJanusGraphException(e));
         }
         return result;
     }
 
-    public TitanOperationStatus deleteEdgeByDirection(GraphVertex fromVertex, Direction direction, EdgeLabelEnum label) {
+    public JanusGraphOperationStatus deleteEdgeByDirection(GraphVertex fromVertex, Direction direction, EdgeLabelEnum label) {
         try {
             Iterator<Edge> edges = fromVertex.getVertex().edges(direction, label.name());
 
@@ -853,9 +852,9 @@
             }
         } catch (Exception e) {
             logger.debug("Failed to remove from vertex {} edges {} by direction {} ", fromVertex.getUniqueId(), label, direction, e);
-            return TitanGraphClient.handleTitanException(e);
+            return JanusGraphClient.handleJanusGraphException(e);
         }
-        return TitanOperationStatus.OK;
+        return JanusGraphOperationStatus.OK;
     }
 
     /**
@@ -864,7 +863,7 @@
      * @param graphVertex
      * @return
      */
-    public Either<GraphVertex, TitanOperationStatus> updateVertex(GraphVertex graphVertex) {
+    public Either<GraphVertex, JanusGraphOperationStatus> updateVertex(GraphVertex graphVertex) {
         CommonUtility.addRecordToLog(logger, LogLevelEnum.TRACE, "Going to update metadata of vertex with uniqueId {}. ", graphVertex.getUniqueId());
         try {
             graphVertex.updateMetadataJsonWithCurrentMetadataProperties();
@@ -872,7 +871,7 @@
 
         } catch (Exception e) {
             CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to update metadata of vertex with uniqueId {}. ", graphVertex.getUniqueId(), e);
-            return Either.right(TitanGraphClient.handleTitanException(e));
+            return Either.right(JanusGraphClient.handleJanusGraphException(e));
         }
         return Either.left(graphVertex);
     }
@@ -883,12 +882,12 @@
      * @param verticesToGet
      * @return
      */
-    public Either<Map<String, GraphVertex>, TitanOperationStatus> getVerticesByUniqueIdAndParseFlag(Map<String, ImmutablePair<GraphPropertyEnum, JsonParseFlagEnum>> verticesToGet) {
+    public Either<Map<String, GraphVertex>, JanusGraphOperationStatus> getVerticesByUniqueIdAndParseFlag(Map<String, ImmutablePair<GraphPropertyEnum, JsonParseFlagEnum>> verticesToGet) {
 
-        Either<Map<String, GraphVertex>, TitanOperationStatus> result = null;
+        Either<Map<String, GraphVertex>, JanusGraphOperationStatus> result = null;
         Map<String, GraphVertex> vertices = new HashMap<>();
-        TitanOperationStatus titatStatus;
-        Either<GraphVertex, TitanOperationStatus> getVertexRes = null;
+        JanusGraphOperationStatus titatStatus;
+        Either<GraphVertex, JanusGraphOperationStatus> getVertexRes = null;
         for (Map.Entry<String, ImmutablePair<GraphPropertyEnum, JsonParseFlagEnum>> entry : verticesToGet.entrySet()) {
             if (entry.getValue().getKey() == GraphPropertyEnum.UNIQUE_ID) {
                 getVertexRes = getVertexById(entry.getKey(), entry.getValue().getValue());
@@ -896,7 +895,7 @@
                 getVertexRes = getVertexByPropertyAndLabel(entry.getValue().getKey(), entry.getKey(), VertexTypeEnum.USER, entry.getValue().getValue());
             }
             if (getVertexRes == null) {
-                titatStatus = TitanOperationStatus.ILLEGAL_ARGUMENT;
+                titatStatus = JanusGraphOperationStatus.ILLEGAL_ARGUMENT;
                 CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Invalid vertex type label {} has been received. ", entry.getValue().getKey(), titatStatus);
                 return Either.right(titatStatus);
             }
@@ -924,16 +923,16 @@
      * @param edgeToCopy
      * @return
      */
-    public TitanOperationStatus createEdge(Vertex from, Vertex to, EdgeLabelEnum label, Edge edgeToCopy) {
+    public JanusGraphOperationStatus createEdge(Vertex from, Vertex to, EdgeLabelEnum label, Edge edgeToCopy) {
         return createEdge(from, to, label, getEdgeProperties(edgeToCopy));
     }
 
-    public TitanOperationStatus replaceEdgeLabel(Vertex fromVertex, Vertex toVertex, Edge prevEdge, EdgeLabelEnum prevLabel, EdgeLabelEnum newLabel) {
+    public JanusGraphOperationStatus replaceEdgeLabel(Vertex fromVertex, Vertex toVertex, Edge prevEdge, EdgeLabelEnum prevLabel, EdgeLabelEnum newLabel) {
         CommonUtility.addRecordToLog(logger, LogLevelEnum.TRACE, "Going to replace edge with label {} to {} between vertices {} and {}", prevLabel, newLabel, fromVertex!=null ? fromVertex.property(GraphPropertyEnum.UNIQUE_ID.getProperty()) : "NULL",
                 toVertex!=null ? toVertex.property(GraphPropertyEnum.UNIQUE_ID.getProperty()) : "NULL");
 
-        TitanOperationStatus result = createEdge(fromVertex, toVertex, newLabel, prevEdge);
-        if (result == TitanOperationStatus.OK) {
+        JanusGraphOperationStatus result = createEdge(fromVertex, toVertex, newLabel, prevEdge);
+        if (result == JanusGraphOperationStatus.OK) {
             prevEdge.remove();
         }
         return result;
@@ -948,14 +947,14 @@
      * @param newLabel
      * @return
      */
-    public TitanOperationStatus replaceEdgeLabel(Vertex fromVertex, Vertex toVertex, EdgeLabelEnum prevLabel, EdgeLabelEnum newLabel) {
+    public JanusGraphOperationStatus replaceEdgeLabel(Vertex fromVertex, Vertex toVertex, EdgeLabelEnum prevLabel, EdgeLabelEnum newLabel) {
 
-        TitanOperationStatus result = null;
+        JanusGraphOperationStatus result = null;
         Iterator<Edge> prevEdgeIter = toVertex.edges(Direction.IN, prevLabel.name());
         if (prevEdgeIter == null || !prevEdgeIter.hasNext()) {
             CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to replace edge with label {} to {} between vertices {} and {}", prevLabel, newLabel, fromVertex.property(GraphPropertyEnum.UNIQUE_ID.getProperty()),
                     toVertex.property(GraphPropertyEnum.UNIQUE_ID.getProperty()));
-            result = TitanOperationStatus.NOT_FOUND;
+            result = JanusGraphOperationStatus.NOT_FOUND;
         }
         if (result == null) {
             result = replaceEdgeLabel(fromVertex, toVertex, prevEdgeIter.next(), prevLabel, newLabel);
@@ -971,7 +970,7 @@
      * @param properties
      * @return
      */
-    public TitanOperationStatus updateVertexMetadataPropertiesWithJson(Vertex vertex, Map<GraphPropertyEnum, Object> properties) {
+    public JanusGraphOperationStatus updateVertexMetadataPropertiesWithJson(Vertex vertex, Map<GraphPropertyEnum, Object> properties) {
         try {
             if (!MapUtils.isEmpty(properties)) {
                 String jsonMetadataStr = (String) vertex.property(GraphPropertyEnum.METADATA.getProperty()).value();
@@ -984,12 +983,12 @@
             }
         } catch (Exception e) {
             CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occurred during update vertex metadata properties with json{}. {}", vertex.property(GraphPropertyEnum.UNIQUE_ID.getProperty()), e.getMessage());
-            return TitanGraphClient.handleTitanException(e);
+            return JanusGraphClient.handleJanusGraphException(e);
         }
-        return TitanOperationStatus.OK;
+        return JanusGraphOperationStatus.OK;
     }
 
-    public TitanOperationStatus disassociateAndDeleteLast(GraphVertex vertex, Direction direction, EdgeLabelEnum label) {
+    public JanusGraphOperationStatus disassociateAndDeleteLast(GraphVertex vertex, Direction direction, EdgeLabelEnum label) {
         try {
             Iterator<Edge> edges = vertex.getVertex().edges(direction, label.name());
 
@@ -1015,13 +1014,13 @@
             }
         } catch (Exception e) {
             CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occured during deleting an edge with the label {} direction {} from vertex {}. {}", label.name(), direction, vertex.getUniqueId(), e);
-            return TitanGraphClient.handleTitanException(e);
+            return JanusGraphClient.handleJanusGraphException(e);
         }
-        return TitanOperationStatus.OK;
+        return JanusGraphOperationStatus.OK;
     }
 
-    public Object getProperty(TitanVertex vertex, String key) {
-        PropertyKey propertyKey = titanClient.getGraph().left().value().getPropertyKey(key);
+    public Object getProperty(JanusGraphVertex vertex, String key) {
+        PropertyKey propertyKey = janusGraphClient.getGraph().left().value().getPropertyKey(key);
         return vertex.valueOrNull(propertyKey);
     }
 
@@ -1050,26 +1049,26 @@
      * @param direction
      * @return
      */
-    public TitanOperationStatus moveEdge(GraphVertex vertexA, GraphVertex vertexB, EdgeLabelEnum label, Direction direction) {
-        TitanOperationStatus result = deleteEdgeByDirection(vertexA, direction, label);
-        if (result != TitanOperationStatus.OK) {
+    public JanusGraphOperationStatus moveEdge(GraphVertex vertexA, GraphVertex vertexB, EdgeLabelEnum label, Direction direction) {
+        JanusGraphOperationStatus result = deleteEdgeByDirection(vertexA, direction, label);
+        if (result != JanusGraphOperationStatus.OK) {
             logger.error("Failed to diassociate {} from element {}. error {} ", label, vertexA.getUniqueId(), result);
             return result;
         }
-        TitanOperationStatus createRelation;
+        JanusGraphOperationStatus createRelation;
         if (direction == Direction.IN) {
             createRelation = createEdge(vertexB, vertexA, label, null);
         } else {
             createRelation = createEdge(vertexA, vertexB, label, null);
         }
-        if (createRelation != TitanOperationStatus.OK) {
+        if (createRelation != JanusGraphOperationStatus.OK) {
             return createRelation;
         }
-        return TitanOperationStatus.OK;
+        return JanusGraphOperationStatus.OK;
     }
 
-    public Either<Edge, TitanOperationStatus> getBelongingEdgeByCriteria(String parentId, EdgeLabelEnum label, Map<GraphPropertyEnum, Object> properties) {
-        Either<GraphVertex, TitanOperationStatus> getVertexRes = getVertexById(parentId, JsonParseFlagEnum.NoParse);
+    public Either<Edge, JanusGraphOperationStatus> getBelongingEdgeByCriteria(String parentId, EdgeLabelEnum label, Map<GraphPropertyEnum, Object> properties) {
+        Either<GraphVertex, JanusGraphOperationStatus> getVertexRes = getVertexById(parentId, JsonParseFlagEnum.NoParse);
         if (getVertexRes.isRight()) {
             return Either.right(getVertexRes.right().value());
         }
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/AbstractTitanVertexHeal.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/AbstractJanusGraphVertexHeal.java
similarity index 89%
rename from catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/AbstractTitanVertexHeal.java
rename to catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/AbstractJanusGraphVertexHeal.java
index e01ddab..f60a063 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/AbstractTitanVertexHeal.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/AbstractJanusGraphVertexHeal.java
@@ -17,6 +17,6 @@
 
 import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
 
-public abstract class AbstractTitanVertexHeal implements Heal<GraphNode> {
+public abstract class AbstractJanusGraphVertexHeal implements Heal<GraphNode> {
 
 }
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanUtils.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanUtils.java
deleted file mode 100644
index 163ef80..0000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanUtils.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package org.openecomp.sdc.be.dao.titan;
-
-import com.thinkaurelius.titan.graphdb.query.TitanPredicate;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import static com.thinkaurelius.titan.core.attribute.Contain.NOT_IN;
-import static java.util.Collections.emptyMap;
-import static org.apache.commons.collections.CollectionUtils.isEmpty;
-
-public class TitanUtils {
-
-    private TitanUtils() {
-    }
-
-    public static <T> Map<String, Entry<TitanPredicate, Object>> buildNotInPredicate(String propKey, Collection<T> notInCollection) {
-        if (isEmpty(notInCollection)) {
-            return emptyMap();
-        }
-        Map<String, Entry<TitanPredicate,  Object>> predicateCriteria = new HashMap<>();
-        predicateCriteria.put(propKey, new HashMap.SimpleEntry<>(NOT_IN, notInCollection));
-        return predicateCriteria;
-    }
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/transactions/SimpleTitanTransactionManager.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/transactions/SimpleTitanTransactionManager.java
deleted file mode 100644
index 2e5b7ea..0000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/transactions/SimpleTitanTransactionManager.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package org.openecomp.sdc.be.dao.titan.transactions;
-
-import com.thinkaurelius.titan.core.TitanException;
-import com.thinkaurelius.titan.core.TitanGraph;
-import org.openecomp.sdc.be.dao.titan.TitanGraphClient;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
-import org.openecomp.sdc.common.log.wrappers.Logger;
-import org.springframework.stereotype.Component;
-import org.springframework.transaction.PlatformTransactionManager;
-import org.springframework.transaction.TransactionDefinition;
-import org.springframework.transaction.TransactionStatus;
-import org.springframework.transaction.TransactionSystemException;
-import org.springframework.transaction.support.SimpleTransactionStatus;
-
-import javax.annotation.PostConstruct;
-
-/**
- * Simple transaction manager for the titan database.
- * This manager does not deal with transactions propagation and relies on the fact that transactions are automatically created with the first operation on the graph
- */
-@Component
-public class SimpleTitanTransactionManager implements PlatformTransactionManager {
-
-    private static final Logger log = Logger.getLogger(SimpleTitanTransactionManager.class.getName());
-    private final TitanGraphClient titanClient;
-    private TitanGraph titanGraph;
-
-    public SimpleTitanTransactionManager(TitanGraphClient titanClient) {
-        this.titanClient = titanClient;
-    }
-
-    @PostConstruct
-    public void onInit() {
-        titanGraph = titanClient.getGraph().left().on(this::onFailingToStartTitan);
-    }
-
-    @Override
-    public TransactionStatus getTransaction(TransactionDefinition transactionDefinition) {
-        log.debug("#getTransaction - returning simple transaction status");
-        return new SimpleTransactionStatus();
-    }
-
-    @Override
-    public void commit(TransactionStatus transactionStatus) {
-        log.debug("#commit - committing transaction");
-        try {
-            titanGraph.tx().commit();
-        } catch (TitanException e) {
-            log.debug("#commit - failed to commit transaction", e);
-            throw new TransactionSystemException("failed to commit transaction", e);
-        }
-    }
-
-    @Override
-    public void rollback(TransactionStatus transactionStatus) {
-        log.debug("#rollback - committing transaction");
-        try {
-            titanGraph.tx().rollback();
-        } catch (TitanException e) {
-            log.debug("#rollback - failed to rollback transaction", e);
-            throw new TransactionSystemException("failed to rollback transaction", e);
-        }
-    }
-
-    private TitanGraph onFailingToStartTitan(TitanOperationStatus err) {
-        log.debug("#onFailingToStartTitan - could not open titan client");
-        throw new IllegalStateException("titan could not be initialized: " + err);
-    }
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingTypesConstants.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingTypesConstants.java
index b7ca476..c6c609b 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingTypesConstants.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingTypesConstants.java
@@ -26,7 +26,7 @@
     String REPO_KEYSPACE = "sdcrepository";
     String AUDIT_KEYSPACE = "sdcaudit";
     String COMPONENT_KEYSPACE = "sdccomponent";
-    String TITAN_KEYSPACE = "titan";
+    String janusGraph_KEYSPACE = "janusgraph";
 
     String USER_ADMIN_EVENT_TYPE = "useradminevent";
     String USER_ACCESS_EVENT_TYPE = "useraccessevent";
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/HealingPipelineDaoTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/HealingPipelineDaoTest.java
index 83b6892..c0d9e46 100644
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/HealingPipelineDaoTest.java
+++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/HealingPipelineDaoTest.java
@@ -17,10 +17,10 @@
 package org.openecomp.sdc.be.dao.cassandra;
 
 import com.google.common.collect.ImmutableListMultimap;
-import com.thinkaurelius.titan.core.TitanVertex;
-import com.thinkaurelius.titan.graphdb.relations.StandardVertexProperty;
-import com.thinkaurelius.titan.graphdb.types.system.EmptyVertex;
-import com.thinkaurelius.titan.graphdb.types.system.ImplicitKey;
+import org.janusgraph.core.JanusGraphVertex;
+import org.janusgraph.graphdb.relations.StandardVertexProperty;
+import org.janusgraph.graphdb.types.system.EmptyVertex;
+import org.janusgraph.graphdb.types.system.ImplicitKey;
 import java.util.HashMap;
 import org.junit.Test;
 import org.mockito.Mockito;
@@ -85,7 +85,7 @@
     }
 
     @Test
-    public void testPipelineFilter3AttributesTitanVertex() {
+    public void testPipelineFilter3AttributesJanusGraphVertex() {
         // init data
         HealingPipelineDao healingPipelineDao = new HealingPipelineDao();
         healingPipelineDao.setHealVersion(7);
@@ -95,16 +95,16 @@
 
         assertEquals(2,
                 healingPipelineDao.getHealersForVertex(GraphEdgeLabels.CAPABILITY.getProperty(), HealVersionBuilder.build(5)).size());
-        TitanVertex titanVertex = Mockito.mock(TitanVertex.class);
+        JanusGraphVertex janusGraphVertex = Mockito.mock(JanusGraphVertex.class);
         final int version = 5;
         StandardVertexProperty vertexProperty = new StandardVertexProperty(1, ImplicitKey.ID, new EmptyVertex(), version, (byte) 1);
-        Mockito.when(titanVertex.property(GraphPropertyEnum.HEALING_VERSION.getProperty())).thenReturn(vertexProperty);
+        Mockito.when(janusGraphVertex.property(GraphPropertyEnum.HEALING_VERSION.getProperty())).thenReturn(vertexProperty);
 
         // perform test
 
-        Optional optional = healingPipelineDao.performGraphReadHealing(titanVertex, GraphEdgeLabels.CAPABILITY);
+        Optional optional = healingPipelineDao.performGraphReadHealing(janusGraphVertex, GraphEdgeLabels.CAPABILITY);
         assertTrue(optional.isPresent());
-        final TitanVertex changedVertex = (TitanVertex) optional.get();
+        final JanusGraphVertex changedVertex = (JanusGraphVertex) optional.get();
 
         //validate result
         assertNotNull(changedVertex);
@@ -112,7 +112,7 @@
     }
 
     @Test
-    public void testPipelineFilterGenericTitanDao() {
+    public void testPipelineFilterGenericJanusGraphDao() {
         // init data
         HealingPipelineDao healingPipelineDao = new HealingPipelineDao();
         healingPipelineDao.setHealVersion(7);
@@ -140,7 +140,7 @@
     }
 
     @Test
-    public void testPipelineFilterTitanGraph1Attributes() {
+    public void testPipelineFilterJanusGraph1Attributes() {
         // init data
         HealingPipelineDao healingPipelineDao = new HealingPipelineDao();
         healingPipelineDao.setHealVersion(7);
@@ -217,9 +217,9 @@
                 .put(GraphEdgeLabels.ATTRIBUTE.getProperty(), new GraphNodeHealTestMock(4))
                 .put(GraphEdgeLabels.ATTRIBUTE.getProperty(), new GraphNodeHealTestMock(5))
                 .put(GraphEdgeLabels.ATTRIBUTE.getProperty(), new GraphNodeHealTestMock(6))
-                .put(GraphEdgeLabels.CAPABILITY.getProperty(), new TitanVertexHealTestMock(4))
-                .put(GraphEdgeLabels.CAPABILITY.getProperty(), new TitanVertexHealTestMock(5))
-                .put(GraphEdgeLabels.CAPABILITY.getProperty(), new TitanVertexHealTestMock(6)).build();
+                .put(GraphEdgeLabels.CAPABILITY.getProperty(), new JanusGraphVertexHealTestMock(4))
+                .put(GraphEdgeLabels.CAPABILITY.getProperty(), new JanusGraphVertexHealTestMock(5))
+                .put(GraphEdgeLabels.CAPABILITY.getProperty(), new JanusGraphVertexHealTestMock(6)).build();
     }
 
     public GraphEdge createGraphEdge(GraphEdgeLabels graphEdgeLabels){
@@ -247,7 +247,7 @@
 
     }
 
-    private class GraphNodeHealTestMock extends AbstractTitanVertexHeal {
+    private class GraphNodeHealTestMock extends AbstractJanusGraphVertexHeal {
         private HealVersion healVersion;
 
         public GraphNodeHealTestMock(int i) {
@@ -266,10 +266,10 @@
     }
 
 
-    private class TitanVertexHealTestMock implements Heal<TitanVertex> {
+    private class JanusGraphVertexHealTestMock implements Heal<JanusGraphVertex> {
         private HealVersion healVersion;
 
-        public TitanVertexHealTestMock(int i) {
+        public JanusGraphVertexHealTestMock(int i) {
             healVersion = HealVersionBuilder.build(i);
         }
 
@@ -279,7 +279,7 @@
         }
 
         @Override
-        public void healData(TitanVertex parentV) {
+        public void healData(JanusGraphVertex parentV) {
 
         }
     }
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphUtilsTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphUtilsTest.java
new file mode 100644
index 0000000..b3fd59e
--- /dev/null
+++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphUtilsTest.java
@@ -0,0 +1,21 @@
+package org.openecomp.sdc.be.dao.janusgraph;
+
+import org.janusgraph.graphdb.query.JanusGraphPredicate;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.junit.Test;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Map.Entry;
+public class JanusGraphUtilsTest {
+
+	@Test
+	public void testBuildNotInPredicate() throws Exception {
+		String propKey = "";
+		Collection<T> notInCollection = null;
+		Map<String, Entry<JanusGraphPredicate, Object>> result;
+
+		// default test
+		result = JanusGraphUtils.buildNotInPredicate(propKey, notInCollection);
+	}
+}
\ No newline at end of file
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/jsongraph/GraphVertexTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/jsongraph/GraphVertexTest.java
index b336bc6..8ce2019 100644
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/jsongraph/GraphVertexTest.java
+++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/jsongraph/GraphVertexTest.java
@@ -1,6 +1,6 @@
 package org.openecomp.sdc.be.dao.jsongraph;
 
-import com.thinkaurelius.titan.core.TitanVertex;
+import org.janusgraph.core.JanusGraphVertex;
 import org.junit.Test;
 import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
@@ -70,7 +70,7 @@
 	@Test
 	public void testGetVertex() throws Exception {
 		GraphVertex testSubject;
-		TitanVertex result;
+		JanusGraphVertex result;
 
 		// default test
 		testSubject = createTestSubject();
@@ -81,7 +81,7 @@
 	@Test
 	public void testSetVertex() throws Exception {
 		GraphVertex testSubject;
-		TitanVertex vertex = null;
+		JanusGraphVertex vertex = null;
 
 		// default test
 		testSubject = createTestSubject();
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/jsongraph/TitanDaoMockTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/jsongraph/JanusGraphDaoMockTest.java
similarity index 70%
rename from catalog-dao/src/test/java/org/openecomp/sdc/be/dao/jsongraph/TitanDaoMockTest.java
rename to catalog-dao/src/test/java/org/openecomp/sdc/be/dao/jsongraph/JanusGraphDaoMockTest.java
index 5703e53..72a9d54 100644
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/jsongraph/TitanDaoMockTest.java
+++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/jsongraph/JanusGraphDaoMockTest.java
@@ -1,7 +1,7 @@
 package org.openecomp.sdc.be.dao.jsongraph;
 
-import com.thinkaurelius.titan.core.TitanGraph;
-import com.thinkaurelius.titan.core.TitanVertex;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphVertex;
 import fj.data.Either;
 import mockit.Deencapsulation;
 import org.apache.commons.lang3.tuple.ImmutablePair;
@@ -15,12 +15,12 @@
 import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.MockitoAnnotations;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
 import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
 import org.openecomp.sdc.be.dao.jsongraph.types.EdgePropertyEnum;
 import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
 import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
-import org.openecomp.sdc.be.dao.titan.TitanGraphClient;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphClient;
 import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
 
 import java.util.HashMap;
@@ -28,13 +28,13 @@
 import java.util.List;
 import java.util.Map;
 
-public class TitanDaoMockTest {
+public class JanusGraphDaoMockTest {
 
 	@InjectMocks
-	TitanDao testSubject;
+	JanusGraphDao testSubject;
 
 	@Mock
-	TitanGraphClient titanClient;
+	JanusGraphClient janusGraphClient;
 
 	@Before
 	public void setUp() throws Exception {
@@ -43,7 +43,7 @@
 
 	@Test
 	public void testCommit() throws Exception {
-		TitanOperationStatus result;
+		JanusGraphOperationStatus result;
 
 		// default test
 		result = testSubject.commit();
@@ -51,7 +51,7 @@
 
 	@Test
 	public void testRollback() throws Exception {
-		TitanOperationStatus result;
+		JanusGraphOperationStatus result;
 
 		// default test
 		result = testSubject.rollback();
@@ -60,7 +60,7 @@
 	@Test
 	public void testGetGraph() throws Exception {
 
-		Either<TitanGraph, TitanOperationStatus> result;
+		Either<JanusGraph, JanusGraphOperationStatus> result;
 
 		// default test
 
@@ -72,14 +72,14 @@
 
 		GraphVertex graphVertex = new GraphVertex();
 		graphVertex.setLabel(VertexTypeEnum.ADDITIONAL_INFORMATION);
-		Either<GraphVertex, TitanOperationStatus> result;
+		Either<GraphVertex, JanusGraphOperationStatus> result;
 
-		TitanGraph tg = Mockito.mock(TitanGraph.class);
-		Either<TitanGraph, TitanOperationStatus> value = Either.left(tg);
+		JanusGraph tg = Mockito.mock(JanusGraph.class);
+		Either<JanusGraph, JanusGraphOperationStatus> value = Either.left(tg);
 		// default test
-		TitanVertex value2 = Mockito.mock(TitanVertex.class);
+		JanusGraphVertex value2 = Mockito.mock(JanusGraphVertex.class);
 		Mockito.when(tg.addVertex()).thenReturn(value2);
-		Mockito.when(titanClient.getGraph()).thenReturn(value);
+		Mockito.when(janusGraphClient.getGraph()).thenReturn(value);
 		result = testSubject.createVertex(graphVertex);
 	}
 
@@ -88,11 +88,11 @@
 
 		GraphVertex graphVertex = new GraphVertex();
 		graphVertex.setLabel(VertexTypeEnum.ADDITIONAL_INFORMATION);
-		Either<GraphVertex, TitanOperationStatus> result;
+		Either<GraphVertex, JanusGraphOperationStatus> result;
 
-		Either<TitanGraph, TitanOperationStatus> value = Either.right(TitanOperationStatus.GENERAL_ERROR);
+		Either<JanusGraph, JanusGraphOperationStatus> value = Either.right(JanusGraphOperationStatus.GENERAL_ERROR);
 		// default test
-		Mockito.when(titanClient.getGraph()).thenReturn(value);
+		Mockito.when(janusGraphClient.getGraph()).thenReturn(value);
 		result = testSubject.createVertex(graphVertex);
 	}
 
@@ -101,35 +101,35 @@
 
 		GraphVertex graphVertex = new GraphVertex();
 		graphVertex.setLabel(VertexTypeEnum.ADDITIONAL_INFORMATION);
-		Either<GraphVertex, TitanOperationStatus> result;
+		Either<GraphVertex, JanusGraphOperationStatus> result;
 
-		TitanGraph tg = Mockito.mock(TitanGraph.class);
-		Either<TitanGraph, TitanOperationStatus> value = Either.left(tg);
+		JanusGraph tg = Mockito.mock(JanusGraph.class);
+		Either<JanusGraph, JanusGraphOperationStatus> value = Either.left(tg);
 		// default test
 		Mockito.when(tg.addVertex()).thenThrow(RuntimeException.class);
-		Mockito.when(titanClient.getGraph()).thenReturn(value);
+		Mockito.when(janusGraphClient.getGraph()).thenReturn(value);
 		result = testSubject.createVertex(graphVertex);
 	}
 
 	@Test
 	public void testGetVertexByPropertyAndLabel() throws Exception {
-		Either<GraphVertex, TitanOperationStatus> result;
+		Either<GraphVertex, JanusGraphOperationStatus> result;
 
 		// default test
-		Mockito.when(titanClient.getGraph()).thenReturn(Either.right(TitanOperationStatus.GENERAL_ERROR));
+		Mockito.when(janusGraphClient.getGraph()).thenReturn(Either.right(JanusGraphOperationStatus.GENERAL_ERROR));
 		result = testSubject.getVertexByPropertyAndLabel(GraphPropertyEnum.COMPONENT_TYPE, "mock",
 				VertexTypeEnum.ADDITIONAL_INFORMATION);
 	}
 
 	@Test
 	public void testGetFirstFoundVertex() throws Exception {
-		Iterable<TitanVertex> vertices = Mockito.mock(Iterable.class);
-		Either<GraphVertex, TitanOperationStatus> result;
+		Iterable<JanusGraphVertex> vertices = Mockito.mock(Iterable.class);
+		Either<GraphVertex, JanusGraphOperationStatus> result;
 
-		Iterator<TitanVertex> value = Mockito.mock(Iterator.class);
+		Iterator<JanusGraphVertex> value = Mockito.mock(Iterator.class);
 		Mockito.when(vertices.iterator()).thenReturn(value);
 		Mockito.when(value.hasNext()).thenReturn(true);
-		TitanVertex value2 = Mockito.mock(TitanVertex.class);
+		JanusGraphVertex value2 = Mockito.mock(JanusGraphVertex.class);
 		Mockito.when(value.next()).thenReturn(value2);
 
 		// default test
@@ -138,13 +138,13 @@
 
 	@Test
 	public void testGetFirstFoundVertexNotFound() throws Exception {
-		Iterable<TitanVertex> vertices = Mockito.mock(Iterable.class);
-		Either<GraphVertex, TitanOperationStatus> result;
+		Iterable<JanusGraphVertex> vertices = Mockito.mock(Iterable.class);
+		Either<GraphVertex, JanusGraphOperationStatus> result;
 
-		Iterator<TitanVertex> value = Mockito.mock(Iterator.class);
+		Iterator<JanusGraphVertex> value = Mockito.mock(Iterator.class);
 		Mockito.when(vertices.iterator()).thenReturn(value);
 		Mockito.when(value.hasNext()).thenReturn(false);
-		TitanVertex value2 = Mockito.mock(TitanVertex.class);
+		JanusGraphVertex value2 = Mockito.mock(JanusGraphVertex.class);
 		Mockito.when(value.next()).thenReturn(value2);
 
 		// default test
@@ -155,14 +155,14 @@
 	public void testGetVertexById_1Exception() throws Exception {
 
 		String id = "mock";
-		Either<GraphVertex, TitanOperationStatus> result;
+		Either<GraphVertex, JanusGraphOperationStatus> result;
 
-		TitanGraph tg = Mockito.mock(TitanGraph.class);
-		Either<TitanGraph, TitanOperationStatus> value = Either.left(tg);
+		JanusGraph tg = Mockito.mock(JanusGraph.class);
+		Either<JanusGraph, JanusGraphOperationStatus> value = Either.left(tg);
 		// default test
-		TitanVertex value2 = Mockito.mock(TitanVertex.class);
+		JanusGraphVertex value2 = Mockito.mock(JanusGraphVertex.class);
 		Mockito.when(tg.addVertex()).thenReturn(value2);
-		Mockito.when(titanClient.getGraph()).thenReturn(value);
+		Mockito.when(janusGraphClient.getGraph()).thenReturn(value);
 
 		// test 1
 		result = testSubject.getVertexById(id, JsonParseFlagEnum.NoParse);
@@ -173,13 +173,13 @@
 	public void testGetVertexById_1GraphClosed() throws Exception {
 
 		String id = "mock";
-		Either<GraphVertex, TitanOperationStatus> result;
+		Either<GraphVertex, JanusGraphOperationStatus> result;
 
 		Object b;
-		Either<TitanGraph, TitanOperationStatus> value = Either.right(TitanOperationStatus.GENERAL_ERROR);
+		Either<JanusGraph, JanusGraphOperationStatus> value = Either.right(JanusGraphOperationStatus.GENERAL_ERROR);
 		// default test
-		TitanVertex value2 = Mockito.mock(TitanVertex.class);
-		Mockito.when(titanClient.getGraph()).thenReturn(value);
+		JanusGraphVertex value2 = Mockito.mock(JanusGraphVertex.class);
+		Mockito.when(janusGraphClient.getGraph()).thenReturn(value);
 
 		// test 1
 		result = testSubject.getVertexById(id, JsonParseFlagEnum.NoParse);
@@ -199,7 +199,7 @@
 	@Test
 	public void testCreateAndFill() throws Exception {
 
-		TitanVertex vertex = Mockito.mock(TitanVertex.class);
+		JanusGraphVertex vertex = Mockito.mock(JanusGraphVertex.class);
 		JsonParseFlagEnum parseFlag = null;
 		GraphVertex result;
 
@@ -212,7 +212,7 @@
 	public void testParseVertexProperties() throws Exception {
 
 		GraphVertex graphVertex = new GraphVertex();
-		TitanVertex vertex = Mockito.mock(TitanVertex.class);
+		JanusGraphVertex vertex = Mockito.mock(JanusGraphVertex.class);
 		graphVertex.setVertex(vertex);
 		JsonParseFlagEnum parseFlag = null;
 
@@ -228,11 +228,11 @@
 		GraphVertex from = Mockito.mock(GraphVertex.class);
 		GraphVertex to = Mockito.mock(GraphVertex.class);
 		
-		TitanVertex value = Mockito.mock(TitanVertex.class);
+		JanusGraphVertex value = Mockito.mock(JanusGraphVertex.class);
 		Mockito.when(from.getVertex()).thenReturn(value);
 		Mockito.when(to.getVertex()).thenReturn(value);
 		Map<EdgePropertyEnum, Object> properties = new HashMap<>();
-		TitanOperationStatus result;
+		JanusGraphOperationStatus result;
 
 		// default test
 
@@ -257,13 +257,13 @@
 	@Test
 	public void testGetByCriteria() throws Exception {
 		Map<GraphPropertyEnum, Object> props = new HashMap<>();
-		Either<List<GraphVertex>, TitanOperationStatus> result;
+		Either<List<GraphVertex>, JanusGraphOperationStatus> result;
 
-		TitanGraph tg = Mockito.mock(TitanGraph.class);
-		Either<TitanGraph, TitanOperationStatus> value = Either.left(tg);
-		TitanVertex value2 = Mockito.mock(TitanVertex.class);
+		JanusGraph tg = Mockito.mock(JanusGraph.class);
+		Either<JanusGraph, JanusGraphOperationStatus> value = Either.left(tg);
+		JanusGraphVertex value2 = Mockito.mock(JanusGraphVertex.class);
 		Mockito.when(tg.addVertex()).thenReturn(value2);
-		Mockito.when(titanClient.getGraph()).thenReturn(value);
+		Mockito.when(janusGraphClient.getGraph()).thenReturn(value);
 		
 		// default test
 		result = testSubject.getByCriteria(VertexTypeEnum.ADDITIONAL_INFORMATION, props);
@@ -273,11 +273,11 @@
 	public void testGetByCriteria_1() throws Exception {
 
 		Map<GraphPropertyEnum, Object> props = new HashMap<>();
-		Either<List<GraphVertex>, TitanOperationStatus> result;
+		Either<List<GraphVertex>, JanusGraphOperationStatus> result;
 
-		Either<TitanGraph, TitanOperationStatus> value = Either.right(TitanOperationStatus.GENERAL_ERROR);
-		TitanVertex value2 = Mockito.mock(TitanVertex.class);
-		Mockito.when(titanClient.getGraph()).thenReturn(value);
+		Either<JanusGraph, JanusGraphOperationStatus> value = Either.right(JanusGraphOperationStatus.GENERAL_ERROR);
+		JanusGraphVertex value2 = Mockito.mock(JanusGraphVertex.class);
+		Mockito.when(janusGraphClient.getGraph()).thenReturn(value);
 
 		// default test
 		result = testSubject.getByCriteria(VertexTypeEnum.ADDITIONAL_INFORMATION, props, JsonParseFlagEnum.NoParse);
@@ -285,12 +285,12 @@
 
 	@Test
 	public void testGetCatalogVerticies() throws Exception {
-		Either<Iterator<Vertex>, TitanOperationStatus> result;
+		Either<Iterator<Vertex>, JanusGraphOperationStatus> result;
 
-		Either<TitanGraph, TitanOperationStatus> value = Either.right(TitanOperationStatus.GENERAL_ERROR);
+		Either<JanusGraph, JanusGraphOperationStatus> value = Either.right(JanusGraphOperationStatus.GENERAL_ERROR);
 		// default test
-		TitanVertex value2 = Mockito.mock(TitanVertex.class);
-		Mockito.when(titanClient.getGraph()).thenReturn(value);
+		JanusGraphVertex value2 = Mockito.mock(JanusGraphVertex.class);
+		Mockito.when(janusGraphClient.getGraph()).thenReturn(value);
 		
 		// default test
 		result = testSubject.getCatalogOrArchiveVerticies(true);
@@ -302,11 +302,11 @@
 		GraphVertex parentVertex = new GraphVertex();
 		EdgeLabelEnum edgeLabel = null;
 		JsonParseFlagEnum parseFlag = null;
-		Either<GraphVertex, TitanOperationStatus> result;
+		Either<GraphVertex, JanusGraphOperationStatus> result;
 
-		Either<TitanGraph, TitanOperationStatus> value = Either.right(TitanOperationStatus.GENERAL_ERROR);
-		TitanVertex value2 = Mockito.mock(TitanVertex.class);
-		Mockito.when(titanClient.getGraph()).thenReturn(value);
+		Either<JanusGraph, JanusGraphOperationStatus> value = Either.right(JanusGraphOperationStatus.GENERAL_ERROR);
+		JanusGraphVertex value2 = Mockito.mock(JanusGraphVertex.class);
+		Mockito.when(janusGraphClient.getGraph()).thenReturn(value);
 		
 		// default test
 		result = testSubject.getChildVertex(parentVertex, EdgeLabelEnum.ADDITIONAL_INFORMATION, JsonParseFlagEnum.NoParse);
@@ -318,11 +318,11 @@
 		Vertex parentVertex = null;
 		EdgeLabelEnum edgeLabel = null;
 		JsonParseFlagEnum parseFlag = null;
-		Either<Vertex, TitanOperationStatus> result;
+		Either<Vertex, JanusGraphOperationStatus> result;
 
-		Either<TitanGraph, TitanOperationStatus> value = Either.right(TitanOperationStatus.GENERAL_ERROR);
-		TitanVertex value2 = Mockito.mock(TitanVertex.class);
-		Mockito.when(titanClient.getGraph()).thenReturn(value);
+		Either<JanusGraph, JanusGraphOperationStatus> value = Either.right(JanusGraphOperationStatus.GENERAL_ERROR);
+		JanusGraphVertex value2 = Mockito.mock(JanusGraphVertex.class);
+		Mockito.when(janusGraphClient.getGraph()).thenReturn(value);
 
 		// default test
 		result = testSubject.getChildVertex(parentVertex, edgeLabel, parseFlag);
@@ -335,7 +335,7 @@
 		Vertex parentVertex = null;
 		EdgeLabelEnum edgeLabel = null;
 		JsonParseFlagEnum parseFlag = null;
-		Either<Vertex, TitanOperationStatus> result;
+		Either<Vertex, JanusGraphOperationStatus> result;
 
 		// default test
 
@@ -348,7 +348,7 @@
 		Vertex parentVertex = null;
 		EdgeLabelEnum edgeLabel = null;
 		JsonParseFlagEnum parseFlag = null;
-		Either<List<Vertex>, TitanOperationStatus> result;
+		Either<List<Vertex>, JanusGraphOperationStatus> result;
 
 		// default test
 
@@ -362,11 +362,11 @@
 		EdgeLabelEnum edgeLabel = null;
 		JsonParseFlagEnum parseFlag = null;
 		Direction direction = null;
-		Either<List<Vertex>, TitanOperationStatus> result;
+		Either<List<Vertex>, JanusGraphOperationStatus> result;
 
-		Either<TitanGraph, TitanOperationStatus> value = Either.right(TitanOperationStatus.GENERAL_ERROR);
-		TitanVertex value2 = Mockito.mock(TitanVertex.class);
-		Mockito.when(titanClient.getGraph()).thenReturn(value);
+		Either<JanusGraph, JanusGraphOperationStatus> value = Either.right(JanusGraphOperationStatus.GENERAL_ERROR);
+		JanusGraphVertex value2 = Mockito.mock(JanusGraphVertex.class);
+		Mockito.when(janusGraphClient.getGraph()).thenReturn(value);
 		// default test
 		result = Deencapsulation.invoke(testSubject, "getAdjacentVerticies",
 				new Object[] { Vertex.class, EdgeLabelEnum.class, JsonParseFlagEnum.class, Direction.class });
@@ -378,7 +378,7 @@
 		Vertex parentVertex = null;
 		EdgeLabelEnum edgeLabel = null;
 		JsonParseFlagEnum parseFlag = null;
-		Either<List<Vertex>, TitanOperationStatus> result;
+		Either<List<Vertex>, JanusGraphOperationStatus> result;
 
 		// default test
 
@@ -392,7 +392,7 @@
 		GraphVertex vertex = null;
 		EdgeLabelEnum label = null;
 		Map<GraphPropertyEnum, Object> properties = null;
-		Either<Edge, TitanOperationStatus> result;
+		Either<Edge, JanusGraphOperationStatus> result;
 
 		// default test
 
@@ -404,11 +404,11 @@
 
 		GraphVertex fromVertex = new GraphVertex();
 		GraphVertex toVertex = new GraphVertex();
-		Either<Edge, TitanOperationStatus> result;
+		Either<Edge, JanusGraphOperationStatus> result;
 
-		Either<TitanGraph, TitanOperationStatus> value = Either.right(TitanOperationStatus.GENERAL_ERROR);
-		TitanVertex value2 = Mockito.mock(TitanVertex.class);
-		Mockito.when(titanClient.getGraph()).thenReturn(value);
+		Either<JanusGraph, JanusGraphOperationStatus> value = Either.right(JanusGraphOperationStatus.GENERAL_ERROR);
+		JanusGraphVertex value2 = Mockito.mock(JanusGraphVertex.class);
+		Mockito.when(janusGraphClient.getGraph()).thenReturn(value);
 		
 		// default test
 		result = testSubject.deleteEdge(fromVertex, toVertex, EdgeLabelEnum.ADDITIONAL_INFORMATION);
@@ -417,7 +417,7 @@
 	@Test
 	public void testDeleteEdgeByDirection() throws Exception {
 		GraphVertex fromVertex = new GraphVertex();
-		TitanOperationStatus result;
+		JanusGraphOperationStatus result;
 
 		// default test
 		result = testSubject.deleteEdgeByDirection(fromVertex, Direction.BOTH, EdgeLabelEnum.ADDITIONAL_INFORMATION);
@@ -426,9 +426,9 @@
 	@Test
 	public void testDeleteEdgeByDirectionMock() throws Exception {
 		GraphVertex fromVertex = Mockito.mock(GraphVertex.class);
-		TitanOperationStatus result;
+		JanusGraphOperationStatus result;
 
-		TitanVertex value = Mockito.mock(TitanVertex.class);;
+		JanusGraphVertex value = Mockito.mock(JanusGraphVertex.class);;
 		Mockito.when(fromVertex.getVertex()).thenReturn(value);
 		Iterator<Edge> value2 = Mockito.mock(Iterator.class);;
 		Mockito.when(value.edges(Mockito.any(), Mockito.any())).thenReturn(value2);
@@ -443,7 +443,7 @@
 	public void testUpdateVertex() throws Exception {
 
 		GraphVertex graphVertex = new GraphVertex();
-		Either<GraphVertex, TitanOperationStatus> result;
+		Either<GraphVertex, JanusGraphOperationStatus> result;
 
 		// default test
 
@@ -454,7 +454,7 @@
 	public void testGetVerticesByUniqueIdAndParseFlag() throws Exception {
 
 		Map<String, ImmutablePair<GraphPropertyEnum, JsonParseFlagEnum>> verticesToGet = new HashMap<>();
-		Either<Map<String, GraphVertex>, TitanOperationStatus> result;
+		Either<Map<String, GraphVertex>, JanusGraphOperationStatus> result;
 		
 		// default test
 		result = testSubject.getVerticesByUniqueIdAndParseFlag(verticesToGet);
@@ -475,7 +475,7 @@
 		Vertex to = null;
 		EdgeLabelEnum label = null;
 		Edge edgeToCopy = null;
-		TitanOperationStatus result;
+		JanusGraphOperationStatus result;
 
 		// default test
 
@@ -491,7 +491,7 @@
 		Edge prevEdge = null;
 		EdgeLabelEnum prevLabel = null;
 		EdgeLabelEnum newLabel = null;
-		TitanOperationStatus result;
+		JanusGraphOperationStatus result;
 
 		// default test
 
@@ -504,7 +504,7 @@
 		Vertex vertex = Mockito.mock(Vertex.class);;
 		Map<GraphPropertyEnum, Object> properties = new HashMap<>();
 		properties.put(GraphPropertyEnum.COMPONENT_TYPE, "mock");
-		TitanOperationStatus result;
+		JanusGraphOperationStatus result;
 
 		// default test
 
@@ -516,9 +516,9 @@
 	public void testDisassociateAndDeleteLast() throws Exception {
 
 		GraphVertex vertex = Mockito.mock(GraphVertex.class);
-		TitanOperationStatus result;
+		JanusGraphOperationStatus result;
 		
-		TitanVertex value = Mockito.mock(TitanVertex.class);
+		JanusGraphVertex value = Mockito.mock(JanusGraphVertex.class);
 		Iterator<Edge> mockiter = Mockito.mock(Iterator.class);
 		Edge nextmock = Mockito.mock(Edge.class);
 		Mockito.when(vertex.getVertex()).thenReturn(value);
@@ -540,9 +540,9 @@
 	public void testDisassociateAndDeleteLastOut() throws Exception {
 
 		GraphVertex vertex = Mockito.mock(GraphVertex.class);
-		TitanOperationStatus result;
+		JanusGraphOperationStatus result;
 		
-		TitanVertex value = Mockito.mock(TitanVertex.class);
+		JanusGraphVertex value = Mockito.mock(JanusGraphVertex.class);
 		Iterator<Edge> mockiter = Mockito.mock(Iterator.class);
 		Edge nextmock = Mockito.mock(Edge.class);
 		Mockito.when(vertex.getVertex()).thenReturn(value);
@@ -564,7 +564,7 @@
 	public void testDisassociateAndDeleteLastException() throws Exception {
 
 		GraphVertex vertex = Mockito.mock(GraphVertex.class);
-		TitanOperationStatus result;
+		JanusGraphOperationStatus result;
 		
 		Mockito.when(vertex.getVertex()).thenThrow(RuntimeException.class);
 		
@@ -577,7 +577,7 @@
 
 		GraphVertex vertexA = new GraphVertex();
 		GraphVertex vertexB = new GraphVertex();
-		TitanOperationStatus result;
+		JanusGraphOperationStatus result;
 
 		// default test
 
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/jsongraph/TitanDaoTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/jsongraph/JanusGraphDaoTest.java
similarity index 80%
rename from catalog-dao/src/test/java/org/openecomp/sdc/be/dao/jsongraph/TitanDaoTest.java
rename to catalog-dao/src/test/java/org/openecomp/sdc/be/dao/jsongraph/JanusGraphDaoTest.java
index 2c4b868..9019de9 100644
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/jsongraph/TitanDaoTest.java
+++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/jsongraph/JanusGraphDaoTest.java
@@ -1,6 +1,6 @@
 package org.openecomp.sdc.be.dao.jsongraph;
 
-import com.thinkaurelius.titan.core.TitanGraph;
+import org.janusgraph.core.JanusGraph;
 import fj.data.Either;
 import org.apache.tinkerpop.gremlin.structure.Edge;
 import org.apache.tinkerpop.gremlin.structure.Element;
@@ -10,13 +10,13 @@
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mockito;
-import org.openecomp.sdc.be.dao.DAOTitanStrategy;
+import org.openecomp.sdc.be.dao.DAOJanusGraphStrategy;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphClient;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
 import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
 import org.openecomp.sdc.be.dao.jsongraph.types.EdgePropertyEnum;
 import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
 import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
-import org.openecomp.sdc.be.dao.titan.TitanGraphClient;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
 import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
 import org.openecomp.sdc.be.utils.DAOConfDependentTest;
 import org.slf4j.Logger;
@@ -26,25 +26,25 @@
 import java.util.List;
 import java.util.Map;
 
-public class TitanDaoTest extends DAOConfDependentTest{
+public class JanusGraphDaoTest extends DAOConfDependentTest{
 	
 	
-	private static Logger logger = LoggerFactory.getLogger(TitanDaoTest.class);
-	private TitanDao dao = new TitanDao(new TitanGraphClient(new DAOTitanStrategy()));
+	private static Logger logger = LoggerFactory.getLogger(JanusGraphDaoTest.class);
+	private JanusGraphDao dao = new JanusGraphDao(new JanusGraphClient(new DAOJanusGraphStrategy()));
 	
 	@Before
 	public void init(){
-	dao.titanClient.createGraph();
+	dao.janusGraphClient.createGraph();
 	}
 	
 	@After
 	public void end(){
-		dao.titanClient.cleanupGraph();
+		dao.janusGraphClient.cleanupGraph();
 	}
 
 	@Test
 	public void testCreateVertex() throws Exception {
-		Either<GraphVertex, TitanOperationStatus> result;
+		Either<GraphVertex, JanusGraphOperationStatus> result;
 
 		// default test
 		GraphVertex graphVertex = new GraphVertex(VertexTypeEnum.REQUIREMENTS);
@@ -56,7 +56,7 @@
 	
 	@Test
 	public void testGetVertexByLabel() throws Exception {
-		Either<GraphVertex, TitanOperationStatus> result;
+		Either<GraphVertex, JanusGraphOperationStatus> result;
 
 		// default test
 		result = dao.getVertexByLabel(VertexTypeEnum.ADDITIONAL_INFORMATION);
@@ -64,7 +64,7 @@
 	
 	@Test
 	public void testCommit() throws Exception {
-		TitanOperationStatus result;
+		JanusGraphOperationStatus result;
 
 		// default test
 		
@@ -75,7 +75,7 @@
 	@Test
 	public void testRollback() throws Exception {
 		
-		TitanOperationStatus result;
+		JanusGraphOperationStatus result;
 
 		// default test
 		
@@ -85,7 +85,7 @@
 	@Test
 	public void testGetGraph() throws Exception {
 		
-		Either<TitanGraph, TitanOperationStatus> result;
+		Either<JanusGraph, JanusGraphOperationStatus> result;
 
 		// default test
 		
@@ -98,7 +98,7 @@
 		GraphPropertyEnum name = null;
 		Object value = null;
 		VertexTypeEnum label = null;
-		Either<GraphVertex, TitanOperationStatus> result;
+		Either<GraphVertex, JanusGraphOperationStatus> result;
 
 		// default test
 		
@@ -114,7 +114,7 @@
 		Object value = null;
 		VertexTypeEnum label = null;
 		JsonParseFlagEnum parseFlag = null;
-		Either<GraphVertex, TitanOperationStatus> result;
+		Either<GraphVertex, JanusGraphOperationStatus> result;
 
 		// default test
 		
@@ -126,7 +126,7 @@
 	public void testGetVertexById() throws Exception {
 		
 		String id = "";
-		Either<GraphVertex, TitanOperationStatus> result;
+		Either<GraphVertex, JanusGraphOperationStatus> result;
 
 		// default test
 		
@@ -138,7 +138,7 @@
 		
 		String id = "";
 		JsonParseFlagEnum parseFlag = null;
-		Either<GraphVertex, TitanOperationStatus> result;
+		Either<GraphVertex, JanusGraphOperationStatus> result;
 
 		// test 1
 		
@@ -181,7 +181,7 @@
 		
 		VertexTypeEnum type = null;
 		Map<GraphPropertyEnum, Object> props = null;
-		Either<List<GraphVertex>, TitanOperationStatus> result;
+		Either<List<GraphVertex>, JanusGraphOperationStatus> result;
 
 		// default test
 		
@@ -194,7 +194,7 @@
 		VertexTypeEnum type = null;
 		Map<GraphPropertyEnum, Object> props = null;
 		JsonParseFlagEnum parseFlag = null;
-		Either<List<GraphVertex>, TitanOperationStatus> result;
+		Either<List<GraphVertex>, JanusGraphOperationStatus> result;
 
 		// default test
 		
@@ -209,7 +209,7 @@
 		Map<GraphPropertyEnum, Object> props = null;
 		Map<GraphPropertyEnum, Object> hasNotProps = null;
 		JsonParseFlagEnum parseFlag = null;
-		Either<List<GraphVertex>, TitanOperationStatus> result;
+		Either<List<GraphVertex>, JanusGraphOperationStatus> result;
 
 		// default test
 		
@@ -219,7 +219,7 @@
 	@Test
 	public void testGetCatalogVerticies() throws Exception {
 		
-		Either<Iterator<Vertex>, TitanOperationStatus> result;
+		Either<Iterator<Vertex>, JanusGraphOperationStatus> result;
 
 		// default test
 		
@@ -232,7 +232,7 @@
 		Vertex parentVertex = null;
 		EdgeLabelEnum edgeLabel = null;
 		JsonParseFlagEnum parseFlag = null;
-		Either<List<Vertex>, TitanOperationStatus> result;
+		Either<List<Vertex>, JanusGraphOperationStatus> result;
 
 		// default test
 		
@@ -245,7 +245,7 @@
 		Vertex parentVertex = null;
 		EdgeLabelEnum edgeLabel = null;
 		JsonParseFlagEnum parseFlag = null;
-		Either<List<Vertex>, TitanOperationStatus> result;
+		Either<List<Vertex>, JanusGraphOperationStatus> result;
 
 		// default test
 		
@@ -257,7 +257,7 @@
 		
 		Vertex vertex = null;
 		Map<GraphPropertyEnum, Object> properties = null;
-		TitanOperationStatus result;
+		JanusGraphOperationStatus result;
 
 		// default test
 		
@@ -303,7 +303,7 @@
 		String parentId = "";
 		EdgeLabelEnum label = null;
 		Map<GraphPropertyEnum, Object> properties = null;
-		Either<Edge, TitanOperationStatus> result;
+		Either<Edge, JanusGraphOperationStatus> result;
 
 		// default test
 		
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/titan/TitanUtilsTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/titan/TitanUtilsTest.java
deleted file mode 100644
index 641eec5..0000000
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/titan/TitanUtilsTest.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.openecomp.sdc.be.dao.titan;
-
-import com.thinkaurelius.titan.graphdb.query.TitanPredicate;
-import org.apache.tinkerpop.gremlin.structure.T;
-import org.junit.Test;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.Map.Entry;
-public class TitanUtilsTest {
-
-	@Test
-	public void testBuildNotInPredicate() throws Exception {
-		String propKey = "";
-		Collection<T> notInCollection = null;
-		Map<String, Entry<TitanPredicate, Object>> result;
-
-		// default test
-		result = TitanUtils.buildNotInPredicate(propKey, notInCollection);
-	}
-}
\ No newline at end of file
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/TitanGenericDaoTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/JanusGraphGenericDaoTest.java
similarity index 62%
rename from catalog-dao/src/test/java/org/openecomp/sdc/be/resources/TitanGenericDaoTest.java
rename to catalog-dao/src/test/java/org/openecomp/sdc/be/resources/JanusGraphGenericDaoTest.java
index e8c6b3c..09ab6a1 100644
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/TitanGenericDaoTest.java
+++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/JanusGraphGenericDaoTest.java
@@ -21,13 +21,13 @@
 package org.openecomp.sdc.be.resources;
 
 import com.google.gson.Gson;
-import com.thinkaurelius.titan.core.PropertyKey;
-import com.thinkaurelius.titan.core.TitanEdge;
-import com.thinkaurelius.titan.core.TitanFactory;
-import com.thinkaurelius.titan.core.TitanGraph;
-import com.thinkaurelius.titan.core.TitanVertex;
-import com.thinkaurelius.titan.core.attribute.Text;
-import com.thinkaurelius.titan.core.schema.TitanManagement;
+import org.janusgraph.core.PropertyKey;
+import org.janusgraph.core.JanusGraphEdge;
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphVertex;
+import org.janusgraph.core.attribute.Text;
+import org.janusgraph.core.schema.JanusGraphManagement;
 import fj.data.Either;
 import org.apache.commons.configuration.BaseConfiguration;
 import org.apache.commons.lang3.tuple.ImmutablePair;
@@ -38,10 +38,10 @@
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.openecomp.sdc.be.config.ConfigurationManager;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphGenericDao;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
 import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
 import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
-import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
 import org.openecomp.sdc.be.dao.utils.UserStatusEnum;
 import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition;
 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
@@ -72,12 +72,12 @@
 @ContextConfiguration("classpath:application-context-test.xml")
 @TestExecutionListeners(listeners = { DependencyInjectionTestExecutionListener.class,
 		DirtiesContextTestExecutionListener.class, TransactionalTestExecutionListener.class })
-public class TitanGenericDaoTest {
-	private static Logger log = LoggerFactory.getLogger(TitanGenericDaoTest.class.getName());
+public class JanusGraphGenericDaoTest {
+	private static Logger log = LoggerFactory.getLogger(JanusGraphGenericDaoTest.class.getName());
 	private static ConfigurationManager configurationManager;
 
-	@Resource(name = "titan-generic-dao")
-	private TitanGenericDao titanDao;
+	@Resource(name = "janusgraph-generic-dao")
+	private JanusGraphGenericDao janusGraphDao;
 
 	@BeforeClass
 	public static void setupBeforeClass() {
@@ -86,27 +86,26 @@
 		ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(),
 				appConfigDir);
 		configurationManager = new ConfigurationManager(configurationSource);
-		configurationManager.getConfiguration()
-				.setTitanCfgFile("../catalog-be/src/main/resources/config/titan.properties");
-		configurationManager.getConfiguration().setTitanInMemoryGraph(true);
+		configurationManager.getConfiguration().setJanusGraphCfgFile("../catalog-be/src/main/resources/config/janusgraph.properties");
+		configurationManager.getConfiguration().setJanusGraphInMemoryGraph(true);
 	}
 
 	// @Test
 	public void testcheckEdgeProps() {
-		TitanGraph graph = titanDao.getGraph().left().value();
-		TitanVertex v1 = graph.addVertex();
+		JanusGraph graph = janusGraphDao.getGraph().left().value();
+		JanusGraphVertex v1 = graph.addVertex();
 		v1.property("prop1", 123);
-		TitanVertex v2 = graph.addVertex();
+		JanusGraphVertex v2 = graph.addVertex();
 		v2.property("prop1", 456);
-		TitanEdge addEdge = v1.addEdge("label11", v2);
+		JanusGraphEdge addEdge = v1.addEdge("label11", v2);
 		addEdge.property("edgeProp", "my prop edge");
 		graph.tx().commit();
 
-		Either<TitanVertex, TitanOperationStatus> v11 = titanDao.getVertexByProperty("prop1", 123);
+		Either<JanusGraphVertex, JanusGraphOperationStatus> v11 = janusGraphDao.getVertexByProperty("prop1", 123);
 		Iterator<Edge> edges = v11.left().value().edges(Direction.OUT, "label11");
 		Edge edge = edges.next();
 		// String value = (String)edge.value("edgeProp");
-		String value = (String) titanDao.getProperty(edge, "edgeProp");
+		String value = (String) janusGraphDao.getProperty(edge, "edgeProp");
 		log.debug(value);
 
 	}
@@ -118,34 +117,34 @@
 		UserData userData = new UserData("Myname123", "Mylastname", id, "email123", "Tester",
 				UserStatusEnum.ACTIVE.name(), null);
 
-		Either<UserData, TitanOperationStatus> newNode = titanDao.createNode(userData, UserData.class);
+		Either<UserData, JanusGraphOperationStatus> newNode = janusGraphDao.createNode(userData, UserData.class);
 
 		assertTrue(newNode.isLeft());
 
 		log.debug("{}", newNode.left().value());
 
-		titanDao.commit();
+		janusGraphDao.commit();
 
 		ImmutablePair<String, Object> keyValueId = userData.getKeyValueId();
-		Either<UserData, TitanOperationStatus> node = titanDao.getNode(keyValueId.getKey(), keyValueId.getValue(),
+		Either<UserData, JanusGraphOperationStatus> node = janusGraphDao.getNode(keyValueId.getKey(), keyValueId.getValue(),
 				UserData.class);
-		titanDao.commit();
+		janusGraphDao.commit();
 		assertTrue(node.isLeft());
 		log.debug("{}", node.left().value());
 
 		userData.setRole("Designer");
-		node = titanDao.updateNode(userData, UserData.class);
+		node = janusGraphDao.updateNode(userData, UserData.class);
 		assertTrue(node.isLeft());
 		log.debug("{}", node.left().value());
 		assertEquals(null, "Designer", node.left().value().getRole());
-		titanDao.commit();
+		janusGraphDao.commit();
 
-		node = titanDao.deleteNode(userData, UserData.class);
+		node = janusGraphDao.deleteNode(userData, UserData.class);
 		assertTrue(node.isLeft());
 		log.debug("{}", node.left().value());
-		titanDao.commit();
+		janusGraphDao.commit();
 
-		node = titanDao.getNode(keyValueId.getKey(), keyValueId.getValue(), UserData.class);
+		node = janusGraphDao.getNode(keyValueId.getKey(), keyValueId.getValue(), UserData.class);
 		assertTrue(node.isRight());
 		log.debug("{}", node.right().value());
 
@@ -159,29 +158,29 @@
 		UserData userData1 = new UserData("Myname123", "Mylastname", id, "email123", "Tester",
 				UserStatusEnum.ACTIVE.name(), null);
 
-		Either<UserData, TitanOperationStatus> node1 = titanDao.createNode(userData1, UserData.class);
+		Either<UserData, JanusGraphOperationStatus> node1 = janusGraphDao.createNode(userData1, UserData.class);
 		assertTrue(node1.isLeft());
 		log.debug("{}", node1.left().value());
 
 		id = "userIddfkoer45abc";
 		UserData userData2 = new UserData("Mynadyhme123", "Mylasghtname", id, "emaighdl123", "Designer",
 				UserStatusEnum.ACTIVE.name(), null);
-		Either<UserData, TitanOperationStatus> node2 = titanDao.createNode(userData2, UserData.class);
+		Either<UserData, JanusGraphOperationStatus> node2 = janusGraphDao.createNode(userData2, UserData.class);
 		assertTrue(node2.isLeft());
 		log.debug("{}", node2.left().value());
 
-		titanDao.commit();
+		janusGraphDao.commit();
 
 		ImmutablePair<String, Object> keyValueId1 = userData1.getKeyValueId();
 		// get first node
-		Either<UserData, TitanOperationStatus> node = titanDao.getNode(keyValueId1.getKey(), keyValueId1.getValue(),
+		Either<UserData, JanusGraphOperationStatus> node = janusGraphDao.getNode(keyValueId1.getKey(), keyValueId1.getValue(),
 				UserData.class);
 		assertTrue(node.isLeft());
 		log.debug("{}", node.left().value());
-		titanDao.commit();
+		janusGraphDao.commit();
 
 		// get all must be 2 + 1 default user = 3
-		Either<List<UserData>, TitanOperationStatus> all = titanDao.getAll(NodeTypeEnum.User, UserData.class);
+		Either<List<UserData>, JanusGraphOperationStatus> all = janusGraphDao.getAll(NodeTypeEnum.User, UserData.class);
 		assertTrue(all.isLeft());
 		assertTrue(all.left().value().size() > 0);
 
@@ -192,7 +191,7 @@
 		props.put(keyValueId1.getKey(), keyValueId1.getValue());
 
 		// get by criteria. must be 1
-		Either<List<UserData>, TitanOperationStatus> byCriteria = titanDao.getByCriteria(NodeTypeEnum.User, props,
+		Either<List<UserData>, JanusGraphOperationStatus> byCriteria = janusGraphDao.getByCriteria(NodeTypeEnum.User, props,
 				UserData.class);
 		assertTrue(byCriteria.isLeft());
 		assertEquals(1, byCriteria.left().value().size());
@@ -200,9 +199,9 @@
 		log.debug("{}", byCriteria.left().value());
 
 		// delete all nodes
-		node = titanDao.deleteNode(userData1, UserData.class);
+		node = janusGraphDao.deleteNode(userData1, UserData.class);
 		assertTrue(node.isLeft());
-		node = titanDao.deleteNode(userData2, UserData.class);
+		node = janusGraphDao.deleteNode(userData2, UserData.class);
 		assertTrue(node.isLeft());
 	}
 
@@ -211,7 +210,7 @@
 		String id = "userId12345abc";
 		UserData userData = new UserData("Myname123", "Mylastname", id, "email123", UserRoleEnum.ADMIN.name(),
 				UserStatusEnum.ACTIVE.name(), null);
-		titanDao.createNode(userData, UserData.class);
+		janusGraphDao.createNode(userData, UserData.class);
 		ResourceMetadataData resourceData = new ResourceMetadataData();
 		resourceData.getMetadataDataDefinition().setName("resourceForLock");
 		resourceData.getMetadataDataDefinition().setVersion("0.1");
@@ -219,37 +218,37 @@
 		resourceData.getMetadataDataDefinition().setUniqueId(resourceData.getMetadataDataDefinition().getName() + "."
 				+ resourceData.getMetadataDataDefinition().getVersion());
 
-		titanDao.createNode(resourceData, ResourceMetadataData.class);
-		titanDao.createRelation(userData, resourceData, GraphEdgeLabels.LAST_MODIFIER, null);
-		titanDao.commit();
+		janusGraphDao.createNode(resourceData, ResourceMetadataData.class);
+		janusGraphDao.createRelation(userData, resourceData, GraphEdgeLabels.LAST_MODIFIER, null);
+		janusGraphDao.commit();
 
-		Either<List<Edge>, TitanOperationStatus> eitherEdges = titanDao.getEdgesForNode(userData, Direction.OUT);
+		Either<List<Edge>, JanusGraphOperationStatus> eitherEdges = janusGraphDao.getEdgesForNode(userData, Direction.OUT);
 		assertTrue(eitherEdges.isLeft());
         assertEquals(1, eitherEdges.left().value().size());
 
-		eitherEdges = titanDao.getEdgesForNode(userData, Direction.IN);
+		eitherEdges = janusGraphDao.getEdgesForNode(userData, Direction.IN);
 		assertTrue(eitherEdges.isLeft());
         assertEquals(0, eitherEdges.left().value().size());
 
-		eitherEdges = titanDao.getEdgesForNode(resourceData, Direction.OUT);
+		eitherEdges = janusGraphDao.getEdgesForNode(resourceData, Direction.OUT);
 		assertTrue(eitherEdges.isLeft());
         assertEquals(0, eitherEdges.left().value().size());
 
-		eitherEdges = titanDao.getEdgesForNode(resourceData, Direction.IN);
+		eitherEdges = janusGraphDao.getEdgesForNode(resourceData, Direction.IN);
 		assertTrue(eitherEdges.isLeft());
         assertEquals(1, eitherEdges.left().value().size());
 
-		eitherEdges = titanDao.getEdgesForNode(resourceData, Direction.BOTH);
+		eitherEdges = janusGraphDao.getEdgesForNode(resourceData, Direction.BOTH);
 		assertTrue(eitherEdges.isLeft());
         assertEquals(1, eitherEdges.left().value().size());
 
-		eitherEdges = titanDao.getEdgesForNode(userData, Direction.BOTH);
+		eitherEdges = janusGraphDao.getEdgesForNode(userData, Direction.BOTH);
 		assertTrue(eitherEdges.isLeft());
         assertEquals(1, eitherEdges.left().value().size());
 
-		titanDao.deleteNode(userData, UserData.class);
-		titanDao.deleteNode(resourceData, ResourceMetadataData.class);
-		titanDao.commit();
+		janusGraphDao.deleteNode(userData, UserData.class);
+		janusGraphDao.deleteNode(resourceData, ResourceMetadataData.class);
+		janusGraphDao.commit();
 	}
 
 	@Test
@@ -263,37 +262,37 @@
 		resourceData.getMetadataDataDefinition().setUniqueId(resourceData.getMetadataDataDefinition().getName() + "."
 				+ resourceData.getMetadataDataDefinition().getVersion());
 
-		Either<ResourceMetadataData, TitanOperationStatus> resource1 = titanDao.createNode(resourceData,
+		Either<ResourceMetadataData, JanusGraphOperationStatus> resource1 = janusGraphDao.createNode(resourceData,
 				ResourceMetadataData.class);
 		assertTrue(resource1.isLeft());
-		titanDao.commit();
+		janusGraphDao.commit();
 		String lockId = "lock_" + resourceData.getLabel() + "_" + resource1.left().value().getUniqueId();
 
-		Either<GraphNodeLock, TitanOperationStatus> nodeLock = titanDao
+		Either<GraphNodeLock, JanusGraphOperationStatus> nodeLock = janusGraphDao
 				.getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), lockId, GraphNodeLock.class);
 		assertTrue(nodeLock.isRight());
-		assertEquals(TitanOperationStatus.NOT_FOUND, nodeLock.right().value());
+		assertEquals(JanusGraphOperationStatus.NOT_FOUND, nodeLock.right().value());
 
-		TitanOperationStatus status = titanDao.lockElement(resourceData);
-		assertEquals(TitanOperationStatus.OK, status);
+		JanusGraphOperationStatus status = janusGraphDao.lockElement(resourceData);
+		assertEquals(JanusGraphOperationStatus.OK, status);
 
-		nodeLock = titanDao.getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), lockId, GraphNodeLock.class);
+		nodeLock = janusGraphDao.getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), lockId, GraphNodeLock.class);
 		assertTrue(nodeLock.isLeft());
 		assertEquals(lockId, nodeLock.left().value().getUniqueId());
 
-		titanDao.commit();
+		janusGraphDao.commit();
 
-		status = titanDao.lockElement(resourceData);
-		assertEquals(TitanOperationStatus.ALREADY_LOCKED, status);
+		status = janusGraphDao.lockElement(resourceData);
+		assertEquals(JanusGraphOperationStatus.ALREADY_LOCKED, status);
 
-		status = titanDao.releaseElement(resourceData);
-		assertEquals(TitanOperationStatus.OK, status);
+		status = janusGraphDao.releaseElement(resourceData);
+		assertEquals(JanusGraphOperationStatus.OK, status);
 
-		nodeLock = titanDao.getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), lockId, GraphNodeLock.class);
+		nodeLock = janusGraphDao.getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), lockId, GraphNodeLock.class);
 		assertTrue(nodeLock.isRight());
-		assertEquals(TitanOperationStatus.NOT_FOUND, nodeLock.right().value());
-		titanDao.deleteNode(resourceData, ResourceMetadataData.class);
-		titanDao.commit();
+		assertEquals(JanusGraphOperationStatus.NOT_FOUND, nodeLock.right().value());
+		janusGraphDao.deleteNode(resourceData, ResourceMetadataData.class);
+		janusGraphDao.commit();
 
 	}
 
@@ -308,37 +307,37 @@
 		resourceData.getMetadataDataDefinition().setUniqueId(resourceData.getMetadataDataDefinition().getName() + "."
 				+ resourceData.getMetadataDataDefinition().getVersion());
 
-		Either<ResourceMetadataData, TitanOperationStatus> resource1 = titanDao.createNode(resourceData,
+		Either<ResourceMetadataData, JanusGraphOperationStatus> resource1 = janusGraphDao.createNode(resourceData,
 				ResourceMetadataData.class);
 		assertTrue(resource1.isLeft());
-		titanDao.commit();
+		janusGraphDao.commit();
 		String lockId = "lock_" + resourceData.getLabel() + "_" + resource1.left().value().getUniqueId();
 
-		Either<GraphNodeLock, TitanOperationStatus> nodeLock = titanDao
+		Either<GraphNodeLock, JanusGraphOperationStatus> nodeLock = janusGraphDao
 				.getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), lockId, GraphNodeLock.class);
 		assertTrue(nodeLock.isRight());
-		assertEquals(TitanOperationStatus.NOT_FOUND, nodeLock.right().value());
+		assertEquals(JanusGraphOperationStatus.NOT_FOUND, nodeLock.right().value());
 
 		// lock
-		TitanOperationStatus status = titanDao.lockElement(resourceData);
-		assertEquals(TitanOperationStatus.OK, status);
+		JanusGraphOperationStatus status = janusGraphDao.lockElement(resourceData);
+		assertEquals(JanusGraphOperationStatus.OK, status);
 
-		nodeLock = titanDao.getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), lockId, GraphNodeLock.class);
+		nodeLock = janusGraphDao.getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), lockId, GraphNodeLock.class);
 		assertTrue(nodeLock.isLeft());
 		assertEquals(lockId, nodeLock.left().value().getUniqueId());
 		long time1 = nodeLock.left().value().getTime();
 
-		titanDao.commit();
+		janusGraphDao.commit();
 
 		// timeout
-		configurationManager.getConfiguration().setTitanLockTimeout(2L);
+		configurationManager.getConfiguration().setJanusGraphLockTimeout(2L);
 		Thread.sleep(5001);
 
 		// relock
-		status = titanDao.lockElement(resourceData);
-		assertEquals(TitanOperationStatus.OK, status);
+		status = janusGraphDao.lockElement(resourceData);
+		assertEquals(JanusGraphOperationStatus.OK, status);
 
-		nodeLock = titanDao.getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), lockId, GraphNodeLock.class);
+		nodeLock = janusGraphDao.getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), lockId, GraphNodeLock.class);
 		assertTrue(nodeLock.isLeft());
 		assertEquals(lockId, nodeLock.left().value().getUniqueId());
 
@@ -346,15 +345,15 @@
 
 		assertTrue(time2 > time1);
 
-		status = titanDao.releaseElement(resourceData);
-		assertEquals(TitanOperationStatus.OK, status);
+		status = janusGraphDao.releaseElement(resourceData);
+		assertEquals(JanusGraphOperationStatus.OK, status);
 
-		nodeLock = titanDao.getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), lockId, GraphNodeLock.class);
+		nodeLock = janusGraphDao.getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), lockId, GraphNodeLock.class);
 		assertTrue(nodeLock.isRight());
-		assertEquals(TitanOperationStatus.NOT_FOUND, nodeLock.right().value());
+		assertEquals(JanusGraphOperationStatus.NOT_FOUND, nodeLock.right().value());
 
-		titanDao.deleteNode(resourceData, ResourceMetadataData.class);
-		titanDao.commit();
+		janusGraphDao.deleteNode(resourceData, ResourceMetadataData.class);
+		janusGraphDao.commit();
 
 	}
 
@@ -369,7 +368,7 @@
 		resourceData.getMetadataDataDefinition().setUniqueId(resourceData.getMetadataDataDefinition().getName() + "."
 				+ resourceData.getMetadataDataDefinition().getVersion());
 
-		Either<ResourceMetadataData, TitanOperationStatus> resource1 = titanDao.createNode(resourceData,
+		Either<ResourceMetadataData, JanusGraphOperationStatus> resource1 = janusGraphDao.createNode(resourceData,
 				ResourceMetadataData.class);
 		assertTrue(resource1.isLeft());
 
@@ -382,9 +381,9 @@
 		resourceData.getMetadataDataDefinition().setUniqueId(resourceData.getMetadataDataDefinition().getName() + "."
 				+ resourceData.getMetadataDataDefinition().getVersion());
 
-		Either<ResourceMetadataData, TitanOperationStatus> resource2 = titanDao.createNode(resourceData,
+		Either<ResourceMetadataData, JanusGraphOperationStatus> resource2 = janusGraphDao.createNode(resourceData,
 				ResourceMetadataData.class);
-		titanDao.commit();
+		janusGraphDao.commit();
 
 		Map<String, Object> props = new HashMap<>();
 
@@ -393,26 +392,26 @@
 		props.put(GraphPropertiesDictionary.IS_HIGHEST_VERSION.getProperty(), false);
 
 		// get by criteria. must be 1
-		Either<List<ResourceMetadataData>, TitanOperationStatus> byCriteria = titanDao
+		Either<List<ResourceMetadataData>, JanusGraphOperationStatus> byCriteria = janusGraphDao
 				.getByCriteria(NodeTypeEnum.Resource, props, ResourceMetadataData.class);
 		assertTrue(byCriteria.isLeft());
 
-		titanDao.deleteNode(resource1.left().value(), ResourceMetadataData.class);
+		janusGraphDao.deleteNode(resource1.left().value(), ResourceMetadataData.class);
 
-		titanDao.deleteNode(resource2.left().value(), ResourceMetadataData.class);
-		titanDao.commit();
+		janusGraphDao.deleteNode(resource2.left().value(), ResourceMetadataData.class);
+		janusGraphDao.commit();
 	}
 
 	// @Test
 	public void testStringSearch() {
-		TitanGraph graph;
+		JanusGraph graph;
 
 		BaseConfiguration conf = new BaseConfiguration();
 		conf.setProperty("storage.backend", "inmemory");
-		graph = TitanFactory.open(conf);
+		graph = JanusGraphFactory.open(conf);
 
-		// TitanManagement graphMgt = graph.getManagementSystem();
-		TitanManagement graphMgt = graph.openManagement();
+		// JanusGraphManagement graphMgt = graph.getManagementSystem();
+		JanusGraphManagement graphMgt = graph.openManagement();
 		PropertyKey propKey = graphMgt.makePropertyKey("string1").dataType(String.class).make();
 		graphMgt.buildIndex("string1", Vertex.class).addKey(propKey).unique().buildCompositeIndex();
 
@@ -423,49 +422,49 @@
 
 
 		log.debug("**** predicat index search non case");
-		Iterable<TitanVertex> vertices = graph.query().has("string1", Text.REGEX, "my new string 1").vertices();
-		Iterator<TitanVertex> iter = vertices.iterator();
+		Iterable<JanusGraphVertex> vertices = graph.query().has("string1", Text.REGEX, "my new string 1").vertices();
+		Iterator<JanusGraphVertex> iter = vertices.iterator();
 		while (iter.hasNext()) {
 			Vertex ver = iter.next();
 			// System.out.println(com.tinkerpop.blueprints.util.ElementHelper.getProperties(ver));
-			log.debug("{}", titanDao.getProperties(ver));
+			log.debug("{}", janusGraphDao.getProperties(ver));
 		}
 
 	}
 
 	@Test
-	public void testDuplicateResultDueToTitanBug() {
+	public void testDuplicateResultDueToJanusGraphBug() {
 
 		ResourceMetadataData resourceData1 = new ResourceMetadataData();
 		resourceData1.getMetadataDataDefinition().setUniqueId("A");
 		((ResourceMetadataDataDefinition) resourceData1.getMetadataDataDefinition()).setAbstract(true);
 		resourceData1.getMetadataDataDefinition().setName("aaaa");
 
-		Either<ResourceMetadataData, TitanOperationStatus> newNode1 = titanDao.createNode(resourceData1,
+		Either<ResourceMetadataData, JanusGraphOperationStatus> newNode1 = janusGraphDao.createNode(resourceData1,
 				ResourceMetadataData.class);
 		assertTrue(newNode1.isLeft());
 		log.debug("{}", newNode1.left().value());
-		// titanDao.commit();
+		// janusGraphDao.commit();
 
 		Map<String, Object> props = new HashMap<>();
 		props.put(GraphPropertiesDictionary.IS_ABSTRACT.getProperty(), true);
-		Either<List<ResourceMetadataData>, TitanOperationStatus> byCriteria = titanDao
+		Either<List<ResourceMetadataData>, JanusGraphOperationStatus> byCriteria = janusGraphDao
 				.getByCriteria(NodeTypeEnum.Resource, props, ResourceMetadataData.class);
 		assertTrue(byCriteria.isLeft());
 		assertEquals("check one result returned", 1, byCriteria.left().value().size());
-		// titanDao.commit();
+		// janusGraphDao.commit();
 
 		ResourceMetadataData resourceToUpdate = new ResourceMetadataData();
 		((ResourceMetadataDataDefinition) resourceToUpdate.getMetadataDataDefinition()).setAbstract(false);
 		resourceToUpdate.getMetadataDataDefinition().setUniqueId("A");
-		Either<ResourceMetadataData, TitanOperationStatus> updateNode = titanDao.updateNode(resourceToUpdate,
+		Either<ResourceMetadataData, JanusGraphOperationStatus> updateNode = janusGraphDao.updateNode(resourceToUpdate,
 				ResourceMetadataData.class);
 		assertTrue(updateNode.isLeft());
-		// titanDao.commit();
+		// janusGraphDao.commit();
 
-		byCriteria = titanDao.getByCriteria(NodeTypeEnum.Resource, props, ResourceMetadataData.class);
+		byCriteria = janusGraphDao.getByCriteria(NodeTypeEnum.Resource, props, ResourceMetadataData.class);
 		assertTrue(byCriteria.isRight());
-		assertEquals("check one result returned due to titan bug", TitanOperationStatus.NOT_FOUND,
+		assertEquals("check one result returned due to janusgraph bug", JanusGraphOperationStatus.NOT_FOUND,
 				byCriteria.right().value());
 
 		AdditionalInfoParameterData infoParameterData = new AdditionalInfoParameterData();
@@ -474,11 +473,11 @@
 		idToKey.put("key1", "value1");
 		infoParameterData.setIdToKey(idToKey);
 
-		Either<AdditionalInfoParameterData, TitanOperationStatus> newNode2 = titanDao.createNode(infoParameterData,
+		Either<AdditionalInfoParameterData, JanusGraphOperationStatus> newNode2 = janusGraphDao.createNode(infoParameterData,
 				AdditionalInfoParameterData.class);
 		assertTrue(newNode2.isLeft());
 		log.debug("{}", newNode2.left().value());
-		// titanDao.commit();
+		// janusGraphDao.commit();
 
 		Map<String, String> idToKey2 = new HashMap<>();
 		idToKey2.put("key1", "value2");
@@ -490,24 +489,24 @@
 		// props2.put(GraphPropertiesDictionary.ADDITIONAL_INFO_ID_TO_KEY.getProperty(),
 		// idToKey2);
 
-		Either<List<AdditionalInfoParameterData>, TitanOperationStatus> byCriteria2 = titanDao
+		Either<List<AdditionalInfoParameterData>, JanusGraphOperationStatus> byCriteria2 = janusGraphDao
 				.getByCriteria(NodeTypeEnum.AdditionalInfoParameters, props2, AdditionalInfoParameterData.class);
 		assertTrue(byCriteria2.isRight());
-		assertEquals("check one result returned due to titan bug", TitanOperationStatus.NOT_FOUND,
+		assertEquals("check one result returned due to janusgraph bug", JanusGraphOperationStatus.NOT_FOUND,
 				byCriteria2.right().value());
 
 		infoParameterData.setIdToKey(idToKey2);
 
-		Either<AdditionalInfoParameterData, TitanOperationStatus> updateNode2 = titanDao.updateNode(infoParameterData,
+		Either<AdditionalInfoParameterData, JanusGraphOperationStatus> updateNode2 = janusGraphDao.updateNode(infoParameterData,
 				AdditionalInfoParameterData.class);
 		assertTrue(updateNode2.isLeft());
-		// titanDao.commit();
+		// janusGraphDao.commit();
 
 		props2.put(GraphPropertiesDictionary.ADDITIONAL_INFO_ID_TO_KEY.getProperty(), idToKey);
-		byCriteria2 = titanDao.getByCriteria(NodeTypeEnum.AdditionalInfoParameters, props2,
+		byCriteria2 = janusGraphDao.getByCriteria(NodeTypeEnum.AdditionalInfoParameters, props2,
 				AdditionalInfoParameterData.class);
 		assertTrue(byCriteria2.isRight());
-		assertEquals("check one result returned due to titan bug", TitanOperationStatus.NOT_FOUND,
+		assertEquals("check one result returned due to janusgraph bug", JanusGraphOperationStatus.NOT_FOUND,
 				byCriteria2.right().value());
 
 		ComponentInstanceData resourceInstanceData = new ComponentInstanceData();
@@ -515,33 +514,33 @@
 		resourceInstanceData.getComponentInstDataDefinition().setPosX("22");
 		resourceInstanceData.getComponentInstDataDefinition().setName("myresource_1");
 
-		Either<ComponentInstanceData, TitanOperationStatus> newNode3 = titanDao.createNode(resourceInstanceData,
+		Either<ComponentInstanceData, JanusGraphOperationStatus> newNode3 = janusGraphDao.createNode(resourceInstanceData,
 				ComponentInstanceData.class);
 		assertTrue(newNode3.isLeft());
 		log.debug("{}", newNode3.left().value());
-		// titanDao.commit();
+		// janusGraphDao.commit();
 
 		resourceInstanceData.getComponentInstDataDefinition().setPosX("50");
-		Either<ComponentInstanceData, TitanOperationStatus> updateNode3 = titanDao.updateNode(resourceInstanceData,
+		Either<ComponentInstanceData, JanusGraphOperationStatus> updateNode3 = janusGraphDao.updateNode(resourceInstanceData,
 				ComponentInstanceData.class);
 		assertTrue(updateNode3.isLeft());
-		// titanDao.commit();
+		// janusGraphDao.commit();
 
 		resourceInstanceData.getComponentInstDataDefinition().setName("myresource_2");
-		updateNode3 = titanDao.updateNode(resourceInstanceData, ComponentInstanceData.class);
+		updateNode3 = janusGraphDao.updateNode(resourceInstanceData, ComponentInstanceData.class);
 		assertTrue(updateNode3.isLeft());
-		// titanDao.commit();
+		// janusGraphDao.commit();
 
 		Map<String, Object> props3 = new HashMap<>();
 		props3.put("positionX", "22");
-		Either<List<ComponentInstanceData>, TitanOperationStatus> byCriteria3 = titanDao
+		Either<List<ComponentInstanceData>, JanusGraphOperationStatus> byCriteria3 = janusGraphDao
 				.getByCriteria(NodeTypeEnum.ResourceInstance, props3, ComponentInstanceData.class);
 		assertTrue(byCriteria3.isRight());
-		assertEquals("check one result returned due to titan bug", TitanOperationStatus.NOT_FOUND,
+		assertEquals("check one result returned due to janusgraph bug", JanusGraphOperationStatus.NOT_FOUND,
 				byCriteria3.right().value());
 
 		props3.put("positionX", "50");
-		byCriteria3 = titanDao.getByCriteria(NodeTypeEnum.ResourceInstance, props3, ComponentInstanceData.class);
+		byCriteria3 = janusGraphDao.getByCriteria(NodeTypeEnum.ResourceInstance, props3, ComponentInstanceData.class);
 		assertTrue(byCriteria3.isLeft());
 
 		/////////////////////////// check integer ////////////////////////
@@ -550,33 +549,33 @@
 		artifactData.getArtifactDataDefinition().setUniqueId("ad234");
 		artifactData.getArtifactDataDefinition().setTimeout(100);
 
-		Either<ArtifactData, TitanOperationStatus> newNode4 = titanDao.createNode(artifactData, ArtifactData.class);
+		Either<ArtifactData, JanusGraphOperationStatus> newNode4 = janusGraphDao.createNode(artifactData, ArtifactData.class);
 		assertTrue(newNode4.isLeft());
 		log.debug("{}", newNode4.left().value());
-		// titanDao.commit();
+		// janusGraphDao.commit();
 
 		artifactData.getArtifactDataDefinition().setTimeout(50);
-		Either<ArtifactData, TitanOperationStatus> updateNode4 = titanDao.updateNode(artifactData, ArtifactData.class);
+		Either<ArtifactData, JanusGraphOperationStatus> updateNode4 = janusGraphDao.updateNode(artifactData, ArtifactData.class);
 		assertTrue(updateNode4.isLeft());
-		// titanDao.commit();
+		// janusGraphDao.commit();
 
 		Map<String, Object> props4 = new HashMap<>();
 		props4.put("timeout", 100);
-		Either<List<ArtifactData>, TitanOperationStatus> byCriteria4 = titanDao.getByCriteria(NodeTypeEnum.ArtifactRef,
+		Either<List<ArtifactData>, JanusGraphOperationStatus> byCriteria4 = janusGraphDao.getByCriteria(NodeTypeEnum.ArtifactRef,
 				props4, ArtifactData.class);
 		assertTrue(byCriteria4.isRight());
-		assertEquals("check one result returned due to titan bug", TitanOperationStatus.NOT_FOUND,
+		assertEquals("check one result returned due to janusgraph bug", JanusGraphOperationStatus.NOT_FOUND,
 				byCriteria4.right().value());
 
 		props4.put("timeout", 50);
-		byCriteria4 = titanDao.getByCriteria(NodeTypeEnum.ArtifactRef, props4, ArtifactData.class);
+		byCriteria4 = janusGraphDao.getByCriteria(NodeTypeEnum.ArtifactRef, props4, ArtifactData.class);
 		assertTrue(byCriteria4.isLeft());
 
-		titanDao.rollback();
+		janusGraphDao.rollback();
 	}
 
 	@Test
-	public void testDuplicateResultUSeHasNotQueryDueToTitanBug() {
+	public void testDuplicateResultUSeHasNotQueryDueToJanusGraphBug() {
 		
 		String name = "bbbb";
 
@@ -585,46 +584,46 @@
 		((ResourceMetadataDataDefinition) resourceData1.getMetadataDataDefinition()).setAbstract(true);
 		resourceData1.getMetadataDataDefinition().setName(name);
 
-		Either<ResourceMetadataData, TitanOperationStatus> newNode1 = titanDao.createNode(resourceData1,
+		Either<ResourceMetadataData, JanusGraphOperationStatus> newNode1 = janusGraphDao.createNode(resourceData1,
 				ResourceMetadataData.class);
 		assertTrue(newNode1.isLeft());
 		log.debug("{}", newNode1.left().value());
-		// titanDao.commit();
+		// janusGraphDao.commit();
 
 		Map<String, Object> props = new HashMap<>();
 		props.put(GraphPropertiesDictionary.IS_ABSTRACT.getProperty(), true);
-		Either<List<ResourceMetadataData>, TitanOperationStatus> byCriteria = titanDao
+		Either<List<ResourceMetadataData>, JanusGraphOperationStatus> byCriteria = janusGraphDao
 				.getByCriteria(NodeTypeEnum.Resource, props, ResourceMetadataData.class);
 		assertTrue(byCriteria.isLeft());
 		assertEquals("check one result returned", 1, byCriteria.left().value().size());
-		// titanDao.commit();
+		// janusGraphDao.commit();
 
 		ResourceMetadataData resourceToUpdate = new ResourceMetadataData();
 		((ResourceMetadataDataDefinition) resourceToUpdate.getMetadataDataDefinition()).setAbstract(false);
 		resourceToUpdate.getMetadataDataDefinition().setUniqueId("A");
-		Either<ResourceMetadataData, TitanOperationStatus> updateNode = titanDao.updateNode(resourceToUpdate,
+		Either<ResourceMetadataData, JanusGraphOperationStatus> updateNode = janusGraphDao.updateNode(resourceToUpdate,
 				ResourceMetadataData.class);
 		assertTrue(updateNode.isLeft());
-		// titanDao.commit();
+		// janusGraphDao.commit();
 
 		// no result where isAbstract = true
-		byCriteria = titanDao.getByCriteria(NodeTypeEnum.Resource, props, ResourceMetadataData.class);
+		byCriteria = janusGraphDao.getByCriteria(NodeTypeEnum.Resource, props, ResourceMetadataData.class);
 		assertTrue(byCriteria.isRight());
-		assertEquals("check one result returned due to titan bug", TitanOperationStatus.NOT_FOUND,
+		assertEquals("check one result returned due to janusgraph bug", JanusGraphOperationStatus.NOT_FOUND,
 				byCriteria.right().value());
 
 		// one result where isAbstract != true
-		byCriteria = titanDao.getByCriteria(NodeTypeEnum.Resource, null, props, ResourceMetadataData.class);
+		byCriteria = janusGraphDao.getByCriteria(NodeTypeEnum.Resource, null, props, ResourceMetadataData.class);
 		assertTrue(byCriteria.isLeft());
 		assertEquals("check one result returned", 1, byCriteria.left().value().size());
 
 		props.put(GraphPropertiesDictionary.IS_ABSTRACT.getProperty(), false);
-		byCriteria = titanDao.getByCriteria(NodeTypeEnum.Resource, null, props, ResourceMetadataData.class);
+		byCriteria = janusGraphDao.getByCriteria(NodeTypeEnum.Resource, null, props, ResourceMetadataData.class);
 		assertTrue(byCriteria.isRight());
-		assertEquals("check one result returned due to titan bug", TitanOperationStatus.NOT_FOUND,
+		assertEquals("check one result returned due to janusgraph bug", JanusGraphOperationStatus.NOT_FOUND,
 				byCriteria.right().value());
 
-		titanDao.rollback();
+		janusGraphDao.rollback();
 
 	}
 	
diff --git a/catalog-dao/src/test/resources/application-context-test.xml b/catalog-dao/src/test/resources/application-context-test.xml
index 24980df..c07512f 100644
--- a/catalog-dao/src/test/resources/application-context-test.xml
+++ b/catalog-dao/src/test/resources/application-context-test.xml
@@ -13,7 +13,7 @@
        	org.openecomp.sdc.be.dao.impl,	
     	org.openecomp.sdc.be.dao.es,
 		org.openecomp.sdc.be.dao.neo4j,
-		org.openecomp.sdc.be.dao.titan,
+		org.openecomp.sdc.be.dao.janusgraph,
 		org.openecomp.sdc.be.resources.impl
 	">
    
diff --git a/catalog-dao/src/test/resources/config/catalog-dao/configuration.yaml b/catalog-dao/src/test/resources/config/catalog-dao/configuration.yaml
index 67c0ec7..92cf2a3 100644
--- a/catalog-dao/src/test/resources/config/catalog-dao/configuration.yaml
+++ b/catalog-dao/src/test/resources/config/catalog-dao/configuration.yaml
@@ -25,9 +25,9 @@
 version: 1.0
 released: 2012-11-30
 
-titanCfgFile: src/main/resources/config/titan.properties
-titanInMemoryGraph: true
-titanLockTimeout: 30
+janusGraphCfgFile: src/main/resources/config/janusgraph.properties
+janusGraphInMemoryGraph: true
+janusGraphLockTimeout: 30
 
 # Protocols
 protocols:
