Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4d39da8

Browse files
authored
[DE-81] Feature/unicode db name (#405)
* unicode db names * unicode db names tests * gh actions upd * gh actions upd * UnicodeUtils * fixed gh actions * fixed gh actions * initialize by default CursorEntity.extra and CursorEntity.Extras.stats to avoid NPE * added disclaimer header * DbName * deprecated string db names in favour of DbName * refactor internal use of string db names in favour of DbName * moved DbName * fixed links in javadoc * changelog upd * fixed db name for GET /_admin/server/id * testing with preview docker images * gh actions upd * gh actions upd * fixed compilation error
1 parent 1585ee2 commit 4d39da8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+719
-341
lines changed

‎.github/workflows/maven.yml‎

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ jobs:
1919
fail-fast: false
2020
matrix:
2121
docker-img:
22-
- docker.io/arangodb/arangodb:3.7.15
22+
- docker.io/arangodb/arangodb:3.7.16
2323
- docker.io/arangodb/arangodb:3.8.4
24-
- docker.io/arangodb/arangodb-preview:3.9.0-alpha.1
25-
- docker.io/arangodb/enterprise:3.7.15
24+
- docker.io/arangodb/arangodb-preview:3.9.0-beta.1
25+
- docker.io/arangodb/enterprise:3.7.16
2626
- docker.io/arangodb/enterprise:3.8.4
27-
- docker.io/arangodb/enterprise-preview:3.9.0-alpha.1
27+
- docker.io/arangodb/enterprise-preview:3.9.0-beta.1
2828
topology:
2929
- single
3030
- cluster
@@ -35,6 +35,17 @@ jobs:
3535
- 8
3636
user-language:
3737
- en
38+
include:
39+
- docker-img: docker.io/arangodb/arangodb-preview:3.9.0-beta.1
40+
topology: single
41+
db-ext-names: true
42+
java-version: 11
43+
user-language: tr
44+
- docker-img: docker.io/arangodb/enterprise-preview:3.9.0-beta.1
45+
topology: cluster
46+
db-ext-names: true
47+
java-version: 17
48+
user-language: tr
3849

3950
steps:
4051
- uses: actions/checkout@v2
@@ -75,6 +86,21 @@ jobs:
7586
name: logs.tgz
7687
path: ./logs.tgz
7788

89+
# test encodeURIComponent() and normalize('NFC') comparing to Javascript behavior
90+
test-graalvm:
91+
runs-on: ubuntu-latest
92+
steps:
93+
- uses: actions/checkout@v2
94+
- uses: graalvm/setup-graalvm@v1
95+
with:
96+
version: 'latest'
97+
java-version: '11'
98+
github-token: ${{ secrets.GITHUB_TOKEN }}
99+
- name: Info
100+
run: mvn -version
101+
- name: Test
102+
run: mvn -e --no-transfer-progress test -Dtest=com.arangodb.util.UnicodeUtilsTest
103+
78104
test-jwt:
79105
timeout-minutes: 20
80106
runs-on: ubuntu-latest

‎ChangeLog.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
66

77
## [Unreleased]
88

9+
- added `DbName` class to represent database names in public API parameters, to ease unicode names normalization (#405)
10+
911
## [6.15.0] - 2021年12月29日
1012

1113
- JWT authentication (#421)

‎pom.xml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,12 @@
219219
<version>0.9.12</version>
220220
<scope>test</scope>
221221
</dependency>
222+
<dependency>
223+
<groupId>org.graalvm.sdk</groupId>
224+
<artifactId>graal-sdk</artifactId>
225+
<version>21.2.0</version>
226+
<scope>test</scope>
227+
</dependency>
222228
</dependencies>
223229

224230
<dependencyManagement>

‎src/main/java/com/arangodb/ArangoDB.java‎

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,7 @@
2020

2121
package com.arangodb;
2222

23-
import com.arangodb.entity.ArangoDBEngine;
24-
import com.arangodb.entity.ArangoDBVersion;
25-
import com.arangodb.entity.LoadBalancingStrategy;
26-
import com.arangodb.entity.LogEntity;
27-
import com.arangodb.entity.LogEntriesEntity;
28-
import com.arangodb.entity.LogLevelEntity;
29-
import com.arangodb.entity.Permissions;
30-
import com.arangodb.entity.ServerRole;
31-
import com.arangodb.entity.UserEntity;
23+
import com.arangodb.entity.*;
3224
import com.arangodb.internal.ArangoContext;
3325
import com.arangodb.internal.ArangoDBImpl;
3426
import com.arangodb.internal.ArangoDefaults;
@@ -50,10 +42,7 @@
5042
import com.arangodb.model.LogOptions;
5143
import com.arangodb.model.UserCreateOptions;
5244
import com.arangodb.model.UserUpdateOptions;
53-
import com.arangodb.util.ArangoCursorInitializer;
54-
import com.arangodb.util.ArangoDeserializer;
55-
import com.arangodb.util.ArangoSerialization;
56-
import com.arangodb.util.ArangoSerializer;
45+
import com.arangodb.util.*;
5746
import com.arangodb.velocypack.VPack;
5847
import com.arangodb.velocypack.VPackAnnotationFieldFilter;
5948
import com.arangodb.velocypack.VPackAnnotationFieldNaming;
@@ -701,8 +690,20 @@ public synchronized ArangoDB build() {
701690
*
702691
* @param name Name of the database
703692
* @return database handler
693+
* @deprecated Use {@link #db(DbName)} instead
704694
*/
705-
ArangoDatabase db(String name);
695+
@Deprecated
696+
default ArangoDatabase db(String name) {
697+
return db(DbName.of(name));
698+
}
699+
700+
/**
701+
* Returns a {@code ArangoDatabase} instance for the given database name.
702+
*
703+
* @param dbName Name of the database
704+
* @return database handler
705+
*/
706+
ArangoDatabase db(DbName dbName);
706707

707708
/**
708709
* Creates a new database with the given name.
@@ -712,8 +713,23 @@ public synchronized ArangoDB build() {
712713
* @throws ArangoDBException
713714
* @see <a href="https://www.arangodb.com/docs/stable/http/database-database-management.html#create-database">API
714715
* Documentation</a>
716+
* @deprecated Use {@link #createDatabase(DbName)} instead
717+
*/
718+
@Deprecated
719+
default Boolean createDatabase(String name) throws ArangoDBException {
720+
return createDatabase(DbName.of(name));
721+
}
722+
723+
/**
724+
* Creates a new database with the given name.
725+
*
726+
* @param dbName Name of the database to create
727+
* @return true if the database was created successfully.
728+
* @throws ArangoDBException
729+
* @see <a href="https://www.arangodb.com/docs/stable/http/database-database-management.html#create-database">API
730+
* Documentation</a>
715731
*/
716-
Boolean createDatabase(Stringname) throws ArangoDBException;
732+
Boolean createDatabase(DbNamedbName) throws ArangoDBException;
717733

718734
/**
719735
* Creates a new database with the given name.

‎src/main/java/com/arangodb/ArangoDatabase.java‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,19 @@ public interface ArangoDatabase extends ArangoSerializationAccessor {
5252
* Returns the name of the database
5353
*
5454
* @return database name
55+
* @deprecated Use {@link #dbName()} instead
5556
*/
56-
String name();
57+
@Deprecated
58+
default String name() {
59+
return dbName().get();
60+
}
61+
62+
/**
63+
* Returns the name of the database
64+
*
65+
* @return database name
66+
*/
67+
DbName dbName();
5768

5869
/**
5970
* Returns the server name and version number.
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
package com.arangodb;
2+
3+
import com.arangodb.internal.ArangoRequestParam;
4+
import com.arangodb.util.UnicodeUtils;
5+
6+
import java.util.Objects;
7+
import java.util.function.Supplier;
8+
9+
/**
10+
* Class to represent a NFC-normalized database name (as required by ArangoDB extended naming convention).
11+
* To instantiate use {@link DbName#of(String)} or {@link DbName#normalize(String)}.
12+
*
13+
* @see <a href="http://https://www.arangodb.com/docs/stable/data-modeling-naming-conventions-database-names.html">
14+
* API Documentation</a>
15+
*/
16+
public final class DbName implements Supplier<String> {
17+
18+
/**
19+
* DbName of the "_system" database.
20+
*/
21+
public static final DbName SYSTEM = DbName.of(ArangoRequestParam.SYSTEM);
22+
23+
private final String value;
24+
25+
/**
26+
* Creates a new {@link DbName} instance with the provided value. If the provided value is not
27+
* <a href="https://en.wikipedia.org/wiki/Unicode_equivalence#Normal_forms">NFC-normalized</a>, throws
28+
* {@link IllegalArgumentException}. No transformation is applied to the provided value.
29+
* Use {@link #normalize(String)} to create a DbName from a non-NFC-normalized value.
30+
*
31+
* @param value desired db name
32+
* @return the created {@link DbName} instance
33+
* @see <a href="https://en.wikipedia.org/wiki/Unicode_equivalence#Normal_forms">NFC normalization</a>
34+
* @see <a href="http://https://www.arangodb.com/docs/stable/data-modeling-naming-conventions-database-names.html">
35+
* API Documentation</a>
36+
*/
37+
public static DbName of(final String value) {
38+
UnicodeUtils.checkNormalized(value);
39+
return new DbName(value);
40+
}
41+
42+
/**
43+
* Creates a new {@link DbName} instance with the NFC normal form of the provided value.
44+
* Note that the created {@link DbName} will hold a value potentially different from the provided one.
45+
*
46+
* @param value desired db name
47+
* @return the created {@link DbName} instance
48+
* @see <a href="https://en.wikipedia.org/wiki/Unicode_equivalence#Normal_forms">NFC normalization</a>
49+
* @see <a href="http://https://www.arangodb.com/docs/stable/data-modeling-naming-conventions-database-names.html">
50+
* API Documentation</a>
51+
*/
52+
public static DbName normalize(final String value) {
53+
return new DbName(UnicodeUtils.normalize(value));
54+
}
55+
56+
private DbName(final String value) {
57+
this.value = value;
58+
}
59+
60+
@Override
61+
public String get() {
62+
return value;
63+
}
64+
65+
@Override
66+
public boolean equals(Object o) {
67+
if (this == o) return true;
68+
if (o == null || getClass() != o.getClass()) return false;
69+
DbName dbName = (DbName) o;
70+
return Objects.equals(value, dbName.value);
71+
}
72+
73+
@Override
74+
public int hashCode() {
75+
return Objects.hash(value);
76+
}
77+
78+
@Override
79+
public String toString() {
80+
return get();
81+
}
82+
}

‎src/main/java/com/arangodb/async/ArangoDBAsync.java‎

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import com.arangodb.ArangoDBException;
2424
import com.arangodb.ArangoSerializationAccessor;
25+
import com.arangodb.DbName;
2526
import com.arangodb.Protocol;
2627
import com.arangodb.async.internal.ArangoDBAsyncImpl;
2728
import com.arangodb.async.internal.velocystream.VstCommunicationAsync;
@@ -94,8 +95,20 @@ public interface ArangoDBAsync extends ArangoSerializationAccessor {
9495
*
9596
* @param name Name of the database
9697
* @return database handler
98+
* @deprecated Use {@link #db(DbName)} instead
9799
*/
98-
ArangoDatabaseAsync db(final String name);
100+
@Deprecated
101+
default ArangoDatabaseAsync db(final String name) {
102+
return db(DbName.of(name));
103+
}
104+
105+
/**
106+
* Returns a handler of the database by the given name
107+
*
108+
* @param dbName Name of the database
109+
* @return database handler
110+
*/
111+
ArangoDatabaseAsync db(final DbName dbName);
99112

100113
/**
101114
* Creates a new database
@@ -104,8 +117,22 @@ public interface ArangoDBAsync extends ArangoSerializationAccessor {
104117
* @return true if the database was created successfully.
105118
* @see <a href="https://www.arangodb.com/docs/stable/http/database-database-management.html#create-database">API
106119
* Documentation</a>
120+
* @deprecated Use {@link #createDatabase(DbName)} instead
121+
*/
122+
@Deprecated
123+
default CompletableFuture<Boolean> createDatabase(final String name) {
124+
return createDatabase(DbName.of(name));
125+
}
126+
127+
/**
128+
* Creates a new database
129+
*
130+
* @param dbName database name
131+
* @return true if the database was created successfully.
132+
* @see <a href="https://www.arangodb.com/docs/stable/http/database-database-management.html#create-database">API
133+
* Documentation</a>
107134
*/
108-
CompletableFuture<Boolean> createDatabase(final Stringname);
135+
CompletableFuture<Boolean> createDatabase(final DbNamedbName);
109136

110137
/**
111138
* Creates a new database

‎src/main/java/com/arangodb/async/ArangoDatabaseAsync.java‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import com.arangodb.ArangoDBException;
2424
import com.arangodb.ArangoSerializationAccessor;
25+
import com.arangodb.DbName;
2526
import com.arangodb.entity.*;
2627
import com.arangodb.entity.arangosearch.AnalyzerEntity;
2728
import com.arangodb.entity.arangosearch.analyzer.SearchAnalyzer;
@@ -54,8 +55,19 @@ public interface ArangoDatabaseAsync extends ArangoSerializationAccessor {
5455
* Returns the name of the database
5556
*
5657
* @return database name
58+
* @deprecated Use {@link #dbName()} instead
5759
*/
58-
String name();
60+
@Deprecated
61+
default String name() {
62+
return dbName().get();
63+
}
64+
65+
/**
66+
* Returns the name of the database
67+
*
68+
* @return database name
69+
*/
70+
DbName dbName();
5971

6072
/**
6173
* Returns the server name and version number.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /