diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index a503d03d..1c9106b4 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -21,9 +21,11 @@ jobs: build: name: Build runs-on: ubuntu-latest - if: ${{ github.event_name == 'push' }} + if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' }} steps: - uses: actions/checkout@v3 + with: + submodules: true - uses: actions/cache@v3 with: path: ~/.gradle/caches diff --git a/.gitmodules b/.gitmodules index 94a907b4..2d53cbec 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "src/driver/src/test/resources/shared-client-testcases"] path = src/driver/src/test/resources/shared-client-testcases - url = https://github.com/edgedb/shared-client-testcases.git + url = https://github.com/geldata/shared-client-testcases.git diff --git a/README.md b/README.md index 71b64462..ea3ec63d 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,10 @@

☕ The official Java/JVM client library for Gel ☕

- - Build status + + Build status - + diff --git a/build.gradle b/build.gradle index 7c1e3bd8..cbb710b3 100644 --- a/build.gradle +++ b/build.gradle @@ -6,11 +6,11 @@ plugins { ext { project_version = '0.3.1-SNAPSHOT' - github_org = 'edgedb' - project_name = 'edgedb-java' + github_org = 'geldata' + project_name = 'gel-java' artifact_group = 'com.gel' project_description = 'Java binding for Gel' - project_url = "https://edgedb.com" + project_url = "https://geldata.com" project_jdk = '11' jdk = JavaVersion.current().majorVersion jdk_javadoc = "https://docs.oracle.com/javase/$jdk/docs/api/".toString() diff --git a/dbschema/futures.esdl b/dbschema/futures.esdl index fa4b1c5f..eabbe636 100644 --- a/dbschema/futures.esdl +++ b/dbschema/futures.esdl @@ -1,4 +1,4 @@ # Disable the application of access policies within access policies # themselves. This behavior will become the default in Gel 3.0. -# See: https://www.edgedb.com/docs/reference/ddl/access_policies#nonrecursive +# See: https://www.geldata.com/docs/reference/ddl/access_policies#nonrecursive using future nonrecursive_access_policies; diff --git a/docs/connecting.rst b/docs/connecting.rst index 28c509fb..7378c92d 100644 --- a/docs/connecting.rst +++ b/docs/connecting.rst @@ -22,7 +22,7 @@ You can use a provided builder by calling the ``builder()`` method on var builder = GelConnection.builder(); var connection = builder.build(); -The builder accepts several `parameters `_ +The builder accepts several `parameters `_ which are used to construct the final ``GelConnection``. If no parameters are provided, the default behavior is to search for the @@ -35,7 +35,7 @@ The builder has the following methods: +=====================================+==========================+=========================================================================+ | ``withInstance`` | String | The name of the gel instance to connect to. | +-------------------------------------+--------------------------+-------------------------------------------------------------------------+ -| ``withDsn`` | String | The DSN to connect to. See: `here `_ for more information. | +| ``withDsn`` | String | The DSN to connect to. See: `here `_ for more information. | +-------------------------------------+--------------------------+-------------------------------------------------------------------------+ | ``withCredentials`` | String | A json representation of the connection arguments. | +-------------------------------------+--------------------------+-------------------------------------------------------------------------+ diff --git a/docs/index.rst b/docs/index.rst index 9825e717..c042713a 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -22,7 +22,7 @@ Quickstart To get started, you will need to setup an Gel project and have an instance created. For more information regarding how to do this, we recommend going -through the `Quickstart guide `_. +through the `Quickstart guide `_. Once you have an instance running, you can add the driver dependency to your project. diff --git a/gel.toml b/edgedb.toml similarity index 75% rename from gel.toml rename to edgedb.toml index 39a9844b..e9ced650 100644 --- a/gel.toml +++ b/edgedb.toml @@ -1,2 +1,2 @@ -[gel] +[edgedb] server-version = "nightly" diff --git a/src/driver/build.gradle b/src/driver/build.gradle index fd6dc9ee..4c750c60 100644 --- a/src/driver/build.gradle +++ b/src/driver/build.gradle @@ -69,14 +69,14 @@ publishing { pom { name = 'Gel Java' description = 'A JVM-based binding for Gel' - url = 'https://github.com.gel/edgedb-java' + url = 'https://github.com/geldata/gel-java' organization { name = 'Gel' - url = 'https://edgedb.com' + url = 'https://geldata.com' } issueManagement { system = 'GitHub' - url = 'https://github.com.gel/edgedb-java/issues' + url = 'https://github.com/geldata/gel-java/issues' } licenses { license { @@ -86,9 +86,9 @@ publishing { } } scm { - url = 'https://github.com.gel/edgedb-java' - connection = 'scm:git:git://github.com.gel/edgedb-java.git' - developerConnection = 'scm:git:ssh://git@github.com.gel/edgedb-java.git' + url = 'https://github.com/geldata/gel-java' + connection = 'scm:git:git://github.com/geldata/gel-java.git' + developerConnection = 'scm:git:ssh://git@github.com/gel/gel-java.git' } developers { developer { diff --git a/src/driver/src/main/java/com/gel/driver/GelConnection.java b/src/driver/src/main/java/com/gel/driver/GelConnection.java index 851539b1..58b9cf35 100644 --- a/src/driver/src/main/java/com/gel/driver/GelConnection.java +++ b/src/driver/src/main/java/com/gel/driver/GelConnection.java @@ -579,7 +579,7 @@ public boolean isEmpty() { + "\"CredentialsFile\" or \"Host\"/\"Port\""); // The primaryError has priority, so hold on to any other exception // until all primary options are processed. - @Nullable ConfigurationException deferredPrimaryError = null; + @Nullable Exception deferredPrimaryError = null; if (builder.instance != null) { if (hasPrimaryOptions) { @@ -633,12 +633,18 @@ public boolean isEmpty() { credentialsText = "{}"; } } - else { + else if (builder.credentialsFile.toString().equals("")) { deferredPrimaryError = new ConfigurationException(String.format( "Invalid CredentialsFile: \"%s\", could not find file", builder.credentialsFile )); } + else { + deferredPrimaryError = new FileNotFoundException(String.format( + "Invalid CredentialsFile: \"%s\", could not find file", + builder.credentialsFile + )); + } hasPrimaryOptions = true; } if (credentialsText != null) { @@ -684,7 +690,15 @@ public boolean isEmpty() { } if (deferredPrimaryError != null) { - throw deferredPrimaryError; + if (deferredPrimaryError instanceof ConfigurationException) { + throw (ConfigurationException)deferredPrimaryError; + } + else if (deferredPrimaryError instanceof IOException) { + throw (IOException)deferredPrimaryError; + } + else { + throw new ConfigurationException("Error: Unknown exception."); + } } } @@ -705,8 +719,7 @@ public boolean isEmpty() { + "\"GEL_CREDENTIALS_FILE\" or \"GEL_HOST\"/\"GEL_PORT\""); // The primaryError has priority, so hold on to any other exception // until all primary env vars are processed. - @Nullable ConfigurationException deferredPrimaryError = null; - + @Nullable Exception deferredPrimaryError = null; GelEnvVar instanceEnvVar = SystemProvider.getGelEnvVariable(provider, INSTANCE_ENV_NAME); if (instanceEnvVar != null) { if (hasPrimaryEnv) { @@ -750,7 +763,7 @@ public boolean isEmpty() { } else { - deferredPrimaryError = new ConfigurationException(String.format( + deferredPrimaryError = new FileNotFoundException(String.format( "Invalid credential file from %s: \"%s\", could not find file", credentialsFileEnvVar.name, credentialsFileEnvVar.value @@ -794,7 +807,15 @@ public boolean isEmpty() { } if (deferredPrimaryError != null) { - throw deferredPrimaryError; + if (deferredPrimaryError instanceof ConfigurationException) { + throw (ConfigurationException)deferredPrimaryError; + } + else if (deferredPrimaryError instanceof IOException) { + throw (IOException)deferredPrimaryError; + } + else { + throw new ConfigurationException("Error: Unknown exception."); + } } } @@ -985,7 +1006,7 @@ else if (builder.branch != null) { ); } else { - throw new ConfigurationException(String.format( + throw new FileNotFoundException(String.format( "Invalid TLSCertificateAuthorityFile: \"%s\", could not find file", builder.tlsCertificateAuthorityFile )); @@ -1030,7 +1051,7 @@ else if (builder.branch != null) { private static GelConnection _fromResolvedFields( @NotNull ConfigUtils.ResolvedFields resolvedFields, @NotNull SystemProvider platform - ) throws ConfigurationException { + ) throws ConfigurationException, IOException { GelConnection result = new GelConnection(); result.hostname = ConfigUtils.checkAndGetFieldValue( @@ -1334,7 +1355,7 @@ else if (key.startsWith("database")) { } else { value = ResolvedField.invalid( - new ConfigurationException(String.format( + new FileNotFoundException(String.format( "Invalid DSN query parameter: \"%s\" could not find file \"%s\"", oldKey, fileName diff --git a/src/driver/src/main/java/com/gel/driver/datatypes/Range.java b/src/driver/src/main/java/com/gel/driver/datatypes/Range.java index e8e3e48c..931ba147 100644 --- a/src/driver/src/main/java/com/gel/driver/datatypes/Range.java +++ b/src/driver/src/main/java/com/gel/driver/datatypes/Range.java @@ -15,7 +15,7 @@ /** * A class representing the {@code std::range} type. * @param The inner type of the range. - * @see Gel range docs + * @see Gel range docs */ public final class Range { /** diff --git a/src/driver/src/main/java/com/gel/driver/util/ConfigUtils.java b/src/driver/src/main/java/com/gel/driver/util/ConfigUtils.java index db40b969..ef99ccb9 100644 --- a/src/driver/src/main/java/com/gel/driver/util/ConfigUtils.java +++ b/src/driver/src/main/java/com/gel/driver/util/ConfigUtils.java @@ -260,9 +260,9 @@ public static DatabaseOrBranch ofBranch(@NotNull String value) { public static final class ResolvedField { private final @Nullable T value; - private final @Nullable ConfigurationException error; + private final @Nullable Exception error; - private ResolvedField(@Nullable T value, @Nullable ConfigurationException error) { + private ResolvedField(@Nullable T value, @Nullable Exception error) { this.value = value; this.error = error; } @@ -273,12 +273,18 @@ private ResolvedField(@Nullable T value, @Nullable ConfigurationException error) public static @NotNull ResolvedField invalid(@NotNull ConfigurationException error) { return new ResolvedField(null, error); } + public static @NotNull ResolvedField invalid(@NotNull IOException error) { + return new ResolvedField(null, error); + } + private static @NotNull ResolvedField invalid(@NotNull Exception error) { + return new ResolvedField(null, error); + } public final @Nullable T getValue() { return value; } - public @Nullable ConfigurationException getError() { + public @Nullable Exception getError() { return error; } @@ -302,7 +308,7 @@ private ResolvedField(@Nullable T value, @Nullable ConfigurationException error) public static @Nullable T checkAndGetFieldValue( @Nullable ResolvedField field - ) throws ConfigurationException { + ) throws ConfigurationException, IOException { return checkAndGetFieldValue(field, null); } @@ -314,7 +320,7 @@ public interface Checker { public static @Nullable T checkAndGetFieldValue( @Nullable ResolvedField field, @Nullable Checker checker - ) throws ConfigurationException { + ) throws ConfigurationException, IOException { if (field == null) { return null; } @@ -324,7 +330,15 @@ public interface Checker { } if (field.getError() != null) { - throw field.getError(); + if (field.getError() instanceof ConfigurationException) { + throw (ConfigurationException)field.getError(); + } + else if (field.getError() instanceof IOException) { + throw (IOException)field.getError(); + } + else { + throw new ConfigurationException("Error: Unknown exception."); + } } return field.getValue(); @@ -367,7 +381,7 @@ public static HashMap> addServerSettingField( public static HashMap checkAndGetServerSettings( HashMap> serverSettings - ) throws ConfigurationException { + ) throws ConfigurationException, IOException { HashMap result = new HashMap(); for (Map.Entry> entry : serverSettings.entrySet()) { diff --git a/src/driver/src/test/java/SharedClientTests.java b/src/driver/src/test/java/SharedClientTests.java index 25b8c589..c1fa7d93 100644 --- a/src/driver/src/test/java/SharedClientTests.java +++ b/src/driver/src/test/java/SharedClientTests.java @@ -6,6 +6,7 @@ import static org.junit.jupiter.api.Assertions.assertSame; import static org.junit.jupiter.api.Assertions.assertTrue; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; @@ -371,8 +372,10 @@ private static void assertSameException( errorMatch.type, actual.getClass(), String.format( - "%s: %s", + "%s: Wrong exception type \"%s\", expected \"%s\"\n%s", testName, + actual.getClass().getName(), + errorMatch.type.getTypeName(), prettyError(actual) ) ); @@ -399,7 +402,7 @@ public ErrorMatch(@NotNull Type type, @NotNull Pattern text) { entry( "credentials_file_not_found", new ErrorMatch( - ConfigurationException.class, + FileNotFoundException.class, Pattern.compile("cannot read credentials") ) ), @@ -515,7 +518,7 @@ public ErrorMatch(@NotNull Type type, @NotNull Pattern text) { entry( "file_not_found", new ErrorMatch( - ConfigurationException.class, + FileNotFoundException.class, Pattern.compile("could not find file") ) ),