Skip to content

Commit

Permalink
minor bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dkuppitz committed Dec 7, 2014
1 parent b91118a commit 1b5d5ce
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.io.StringWriter;
import java.net.URISyntaxException;
import java.nio.charset.Charset;
import java.nio.file.Paths;
import java.util.ArrayList;
Expand All @@ -44,16 +45,24 @@ public class GremlinPlugin {
private final static Object LOCK = new Object();
private final static JSONResultConverter RESULT_CONVERTER = new JSONResultConverter(GraphSONMode.NORMAL, 0, Long.MAX_VALUE, null);
private final static ConcurrentMap<String, String> CACHED_SCRIPTS = new ConcurrentHashMap<>();
private final static String SCRIPT_DIRECTORY = Paths.get(GremlinPlugin.class
.getProtectionDomain().getCodeSource().getLocation().toURI())
.getParent().getParent().getParent() + File.separator + "scripts";
private final static String SCRIPT_DIRECTORY = getScriptDirectory();

private static volatile ScriptEngine engine;
private static Neo4j2Graph neo4jGraph;

private final GraphDatabaseService neo4j;
private final Neo4j2Graph graph;

private static String getScriptDirectory() {
try {
return Paths.get(GremlinPlugin.class
.getProtectionDomain().getCodeSource().getLocation().toURI())
.getParent().getParent().getParent() + File.separator + "scripts";
} catch (URISyntaxException e) {
return "." + File.separator + "scripts";
}
}

public GremlinPlugin(@Context GraphDatabaseService database) {
this.graph = getOrCreateGraph(this.neo4j = database);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.io.StringWriter;
import java.net.URISyntaxException;
import java.nio.charset.Charset;
import java.nio.file.Paths;
import java.util.ArrayList;
Expand All @@ -41,16 +42,24 @@ public class GremlinPlugin {

private final static Object LOCK = new Object();
private final static ConcurrentMap<String, String> CACHED_SCRIPTS = new ConcurrentHashMap<>();
private final static String SCRIPT_DIRECTORY = Paths.get(GremlinPlugin.class
.getProtectionDomain().getCodeSource().getLocation().toURI())
.getParent().getParent().getParent() + File.separator + "scripts";
private final static String SCRIPT_DIRECTORY = getScriptDirectory();

private static volatile ScriptEngine engine;
private static Neo4jGraph neo4jGraph;

private final GraphDatabaseService neo4j;
private final Neo4jGraph graph;

private static String getScriptDirectory() {
try {
return Paths.get(GremlinPlugin.class
.getProtectionDomain().getCodeSource().getLocation().toURI())
.getParent().getParent().getParent() + File.separator + "scripts";
} catch (URISyntaxException e) {
return "." + File.separator + "scripts";
}
}

public GremlinPlugin(@Context GraphDatabaseService database) {
this.graph = getOrCreateGraph(this.neo4j = database);
}
Expand Down Expand Up @@ -93,7 +102,7 @@ public Response execute(@QueryParam("script") final String script,

Object result = null;

final GraphSONObjectMapper mapper = GraphSONObjectMapper.build().embedTypes(false).build();
final GraphSONObjectMapper mapper = GraphSONObjectMapper.build().embedTypes(false).create();

final String[] loadScripts = load != null && !load.isEmpty() ? load.split(",") : null;
final JSONObject parameters = params != null ? new JSONObject(params) : null;
Expand Down

0 comments on commit 1b5d5ce

Please sign in to comment.