Skip to content
This repository has been archived by the owner on Apr 18, 2022. It is now read-only.

Commit

Permalink
fix relative path error for trust-store-file (#75)
Browse files Browse the repository at this point in the history
Change-Id: Ie01eddde61de48cf80bea50a9cfeb5b7357daf2c
  • Loading branch information
zhoney authored Nov 20, 2020
1 parent 13eb6a6 commit 8212bf2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
4 changes: 1 addition & 3 deletions assembly/bin/hugegraph
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ else
echo "Warning: please set JAVA_HOME variable, otherwise some libraries related to https may be missing"
fi

cd $TOP

if [ "$1" == "deploy" ]; then
shift
bash $BIN/deploy.sh $@
Expand Down Expand Up @@ -129,5 +127,5 @@ if [ "$JAVA_OPTIONS" = "" ] ; then
JAVA_OPTIONS="-Xms${MIN_MEM}m -Xmx${XMX}m"
fi

exec $JAVA $JAVA_OPTIONS -cp $LIB/hugegraph-tools-*.jar -Djava.ext.dirs=$LIB/ \
exec $JAVA -Dtools.home.path=${TOP} $JAVA_OPTIONS -cp $LIB/hugegraph-tools-*.jar -Djava.ext.dirs=$LIB/ \
com.baidu.hugegraph.cmd.HugeGraphCommand $URL_ARG $GRAPH_ARG $USER_ARG $PASSWORD_ARG $TIMEOUT_ARG $TRUST_STORE_FILE_ARG $TRUST_STORE_PASSWORD_ARG "$@"
15 changes: 14 additions & 1 deletion src/main/java/com/baidu/hugegraph/base/ToolClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

package com.baidu.hugegraph.base;

import java.nio.file.Paths;

import org.apache.commons.lang3.StringUtils;

import com.baidu.hugegraph.driver.GraphManager;
import com.baidu.hugegraph.driver.GremlinManager;
import com.baidu.hugegraph.driver.HugeClient;
Expand All @@ -45,7 +49,8 @@ public ToolClient(ConnectionInfo info) {
String trustStoreFile, trustStorePassword;
if (info.url.startsWith("https")) {
if (info.trustStoreFile == null || info.trustStoreFile.isEmpty()) {
trustStoreFile = DEFAULT_TRUST_STORE_FILE;
trustStoreFile = Paths.get(homePath(), DEFAULT_TRUST_STORE_FILE)
.toString();
trustStorePassword = DEFAULT_TRUST_STORE_PASSWORD;
} else {
E.checkArgumentNotNull(info.trustStorePassword,
Expand Down Expand Up @@ -100,6 +105,14 @@ public ObjectMapper mapper() {
return this.mapper;
}

public static String homePath() {
String homePath = System.getProperty("tools.home.path");
E.checkArgument(StringUtils.isNotEmpty(homePath),
"The system property 'tools.home.path' " +
"can't be empty when enable https protocol");
return homePath;
}

public static class ConnectionInfo {

private String url;
Expand Down
10 changes: 1 addition & 9 deletions src/main/java/com/baidu/hugegraph/cmd/SubCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -694,20 +694,12 @@ public static class HugeTypes {
public List<HugeType> types = HugeTypeListConverter.ALL_TYPES;
}

public static class ExistDirectory {

@Parameter(names = {"--directory", "-d"}, arity = 1,
validateWith = {DirectoryValidator.class},
description = "Directory of graph schema/data")
public String directory = "./";
}

public static class InstallPath {

@Parameter(names = {"-p"}, arity = 1, required = true,
description = "Install path of HugeGraph-Server and " +
"HugeGraph-Studio")
public String directory = null;
public String directory;
}

public static class DownloadURL {
Expand Down

0 comments on commit 8212bf2

Please sign in to comment.