Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<div align="center">
<h1>☕ The official Java/JVM client library for Gel ☕</h1>

<a href="https://github.com.gel/edgedb-java/actions" rel="nofollow">
<img src="https://github.com.gel/edgedb-java/actions/workflows/gradle.yml/badge.svg?event=push&branch=master" alt="Build status">
<a href="https://github.com/geldata/gel-java/actions" rel="nofollow">
<img src="https://github.com/geldata/gel-java/actions/workflows/gradle.yml/badge.svg?event=push&branch=master" alt="Build status">
</a>
<a href="https://github.com.gel/edgedb/blob/master/LICENSE">
<a href="https://github.com/geldata/gel/blob/master/LICENSE">
<img src="https://img.shields.io/badge/license-Apache%202.0-blue" />
</a>
<a href="https://discord.gg/edgedb">
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion dbschema/futures.esdl
Original file line number Diff line number Diff line change
@@ -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;
4 changes: 2 additions & 2 deletions docs/connecting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://docs.edgedb.com/database/reference/connection>`_
The builder accepts several `parameters <https://docs.geldata.com/database/reference/connection>`_
which are used to construct the final ``GelConnection``.

If no parameters are provided, the default behavior is to search for the
Expand All @@ -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 <https://www.edgedb.com/docs/reference/dsn>`_ for more information. |
| ``withDsn`` | String | The DSN to connect to. See: `here <https://www.geldata.com/docs/reference/dsn>`_ for more information. |
+-------------------------------------+--------------------------+-------------------------------------------------------------------------+
| ``withCredentials`` | String | A json representation of the connection arguments. |
+-------------------------------------+--------------------------+-------------------------------------------------------------------------+
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://www.edgedb.com/docs/intro/quickstart>`_.
through the `Quickstart guide <https://www.geldata.com/docs/intro/quickstart>`_.

Once you have an instance running, you can add the driver dependency to your
project.
Expand Down
2 changes: 1 addition & 1 deletion gel.toml → edgedb.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[gel]
[edgedb]
server-version = "nightly"
12 changes: 6 additions & 6 deletions src/driver/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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://[email protected].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://[email protected]/gel/gel-java.git'
}
developers {
developer {
Expand Down
41 changes: 31 additions & 10 deletions src/driver/src/main/java/com/gel/driver/GelConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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.");
}
}
}

Expand All @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.");
}
}
}

Expand Down Expand Up @@ -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
));
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/**
* A class representing the {@code std::range} type.
* @param <T> The inner type of the range.
* @see <a href="https://www.edgedb.com/docs/stdlib/range">Gel range docs</a>
* @see <a href="https://www.geldata.com/docs/stdlib/range">Gel range docs</a>
*/
public final class Range<T> {
/**
Expand Down
28 changes: 21 additions & 7 deletions src/driver/src/main/java/com/gel/driver/util/ConfigUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@ public static DatabaseOrBranch ofBranch(@NotNull String value) {

public static final class ResolvedField<T> {
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;
}
Expand All @@ -273,12 +273,18 @@ private ResolvedField(@Nullable T value, @Nullable ConfigurationException error)
public static @NotNull <T>ResolvedField<T> invalid(@NotNull ConfigurationException error) {
return new ResolvedField<T>(null, error);
}
public static @NotNull <T>ResolvedField<T> invalid(@NotNull IOException error) {
return new ResolvedField<T>(null, error);
}
private static @NotNull <T>ResolvedField<T> invalid(@NotNull Exception error) {
return new ResolvedField<T>(null, error);
}

public final @Nullable T getValue() {
return value;
}

public @Nullable ConfigurationException getError() {
public @Nullable Exception getError() {
return error;
}

Expand All @@ -302,7 +308,7 @@ private ResolvedField(@Nullable T value, @Nullable ConfigurationException error)

public static @Nullable <T> T checkAndGetFieldValue(
@Nullable ResolvedField<T> field
) throws ConfigurationException {
) throws ConfigurationException, IOException {
return checkAndGetFieldValue(field, null);
}

Expand All @@ -314,7 +320,7 @@ public interface Checker<T> {
public static @Nullable <T> T checkAndGetFieldValue(
@Nullable ResolvedField<T> field,
@Nullable Checker<T> checker
) throws ConfigurationException {
) throws ConfigurationException, IOException {
if (field == null) {
return null;
}
Expand All @@ -324,7 +330,15 @@ public interface Checker<T> {
}

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();
Expand Down Expand Up @@ -367,7 +381,7 @@ public static HashMap<String, ResolvedField<String>> addServerSettingField(

public static HashMap<String, String> checkAndGetServerSettings(
HashMap<String, ResolvedField<String>> serverSettings
) throws ConfigurationException {
) throws ConfigurationException, IOException {
HashMap<String, String> result = new HashMap<String, String>();
for (Map.Entry<String, ResolvedField<String>> entry : serverSettings.entrySet())
{
Expand Down
9 changes: 6 additions & 3 deletions src/driver/src/test/java/SharedClientTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
)
);
Expand All @@ -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")
)
),
Expand Down Expand Up @@ -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")
)
),
Expand Down
Loading