Upgrade SDC from Titan to Janus Graph
[sdc.git] / asdctool / src / main / java / org / openecomp / sdc / asdctool / servlets / ExportImportJanusGraphServlet.java
@@ -20,7 +20,7 @@
 
 package org.openecomp.sdc.asdctool.servlets;
 
-import com.thinkaurelius.titan.core.TitanGraph;
+import org.janusgraph.core.JanusGraph;
 import org.apache.commons.configuration.BaseConfiguration;
 import org.apache.commons.configuration.Configuration;
 import org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLWriter;
@@ -39,30 +39,30 @@ import java.util.Map.Entry;
 import java.util.Properties;
 //import com.tinkerpop.blueprints.util.io.graphml.GraphMLWriter;
 
-@Path("/titan")
-public class ExportImportTitanServlet {
+@Path("/janusgraph")
+public class ExportImportJanusGraphServlet {
 
-       private static Logger log = Logger.getLogger(ExportImportTitanServlet.class.getName());
+       private static Logger log = Logger.getLogger(ExportImportJanusGraphServlet.class.getName());
 
        @GET
        @Path("export")
        @Consumes(MediaType.MULTIPART_FORM_DATA)
        @Produces(MediaType.APPLICATION_OCTET_STREAM)
-       public Response export(@FormDataParam("titanProperties") File titanPropertiesFile,
+       public Response export(@FormDataParam("janusGraphProperties") File janusGraphPropertiesFile,
                        @FormDataParam("metadata") String exportGraphMetadata) {
 
-               printTitanConfigFile(titanPropertiesFile);
+               printJanusGraphConfigFile(janusGraphPropertiesFile);
                printMetadata(exportGraphMetadata);
 
-               Properties titanProperties = convertFileToProperties(titanPropertiesFile);
+               Properties janusGraphProperties = convertFileToProperties(janusGraphPropertiesFile);
 
-               if (titanProperties == null) {
-                       Response response = Utils.buildOkResponse(400, "cannot parse titan properties file", null);
+               if (janusGraphProperties == null) {
+                       Response response = Utils.buildOkResponse(400, "cannot parse janusgraph properties file", null);
                        return response;
                }
 
                Configuration conf = new BaseConfiguration();
-               for (Entry<Object, Object> entry : titanProperties.entrySet()) {
+               for (Entry<Object, Object> entry : janusGraphProperties.entrySet()) {
                        String key = entry.getKey().toString();
                        Object value = entry.getValue();
                        conf.setProperty(key, value);
@@ -70,14 +70,14 @@ public class ExportImportTitanServlet {
 
                conf.setProperty("storage.machine-id-appendix", System.currentTimeMillis() % 1000);
 
-               try(TitanGraph openGraph = Utils.openGraph(conf)){
+               try(JanusGraph openGraph = Utils.openGraph(conf)){
                        
                        if (openGraph == null) {
                                Response buildErrorResponse = Utils.buildOkResponse(500, "failed to open graph", null);
                                return buildErrorResponse;
                        }
        
-                       // Open Titan Graph
+                       // Open JanusGraph Graph
        
                        Response buildOkResponse = Utils.buildOkResponse(200, "ok man", null);
        
@@ -85,11 +85,11 @@ public class ExportImportTitanServlet {
                }
        }
 
-       private Properties convertFileToProperties(File titanPropertiesFile) {
+       private Properties convertFileToProperties(File janusGraphPropertiesFile) {
 
                Properties properties = new Properties();
 
-               try (FileReader fileReader = new FileReader(titanPropertiesFile)){
+               try (FileReader fileReader = new FileReader(janusGraphPropertiesFile)){
                        properties.load(fileReader);
                } catch (Exception e) {
                        log.error("Failed to convert file to properties", e);
@@ -99,11 +99,11 @@ public class ExportImportTitanServlet {
                return properties;
        }
 
-       private void printTitanConfigFile(File titanPropertiesFile) {
+       private void printJanusGraphConfigFile(File janusGraphPropertiesFile) {
 
                if (log.isDebugEnabled()) {
                        StringBuilder builder = new StringBuilder();
-                       try (BufferedReader br = new BufferedReader(new FileReader(titanPropertiesFile))) {
+                       try (BufferedReader br = new BufferedReader(new FileReader(janusGraphPropertiesFile))) {
                                String line;
                                while ((line = br.readLine()) != null) {
                                        builder.append(line + Utils.NEW_LINE);
@@ -112,7 +112,7 @@ public class ExportImportTitanServlet {
                                log.debug(builder.toString());
 
                        } catch (IOException e) {
-                               log.error("Cannot print titan properties file", e);
+                               log.error("Cannot print janusgraph properties file", e);
                        }
                }
        }
@@ -123,7 +123,7 @@ public class ExportImportTitanServlet {
 
        }
 
-       public String exportGraph(TitanGraph graph, String outputDirectory) {
+       public String exportGraph(JanusGraph graph, String outputDirectory) {
 
                String result = null;