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;
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);
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);
}
}
- 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);
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);
log.debug(builder.toString());
} catch (IOException e) {
- log.error("Cannot print titan properties file", e);
+ log.error("Cannot print janusgraph properties file", e);
}
}
}
}
- public String exportGraph(TitanGraph graph, String outputDirectory) {
+ public String exportGraph(JanusGraph graph, String outputDirectory) {
String result = null;