Skip to content

Commit 3e091ce

Browse files
author
Mark
committed
Merge remote-tracking branch 'origin/4.1'
2 parents 242b4e8 + 77445db commit 3e091ce

24 files changed

+563
-241
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ language: java
33
before_script:
44
- chmod 777 ./tests/travis/setup_arangodb.sh
55
- ./tests/travis/setup_arangodb.sh
6-
6+
77
install: mvn install -DskipTests=true -Dgpg.skip=true -Dmaven.javadoc.skip=true -B -V
88

99
jdk:

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
v4.1.0 (2016-10-xx)
22
---------------------------
33
* changed VelocyStream communication (send protocol header)
4+
* added ArangoUtil for manually de-/serialization
45

56
v4.0.0 (2016-10-17)
67
---------------------------

README.md

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,20 @@
66
2.7: [![Build Status](https://secure.travis-ci.org/arangodb/arangodb-java-driver.svg?branch=2.7)](https://travis-ci.org/arangodb/arangodb-java-driver)
77
3.0: [![Build Status](https://secure.travis-ci.org/arangodb/arangodb-java-driver.svg?branch=3.0)](https://travis-ci.org/arangodb/arangodb-java-driver)
88
3.1: [![Build Status](https://secure.travis-ci.org/arangodb/arangodb-java-driver.svg?branch=3.1)](https://travis-ci.org/arangodb/arangodb-java-driver)
9-
4.0: [![Build Status](https://secure.travis-ci.org/arangodb/arangodb-java-driver.svg?branch=4.0)](https://travis-ci.org/arangodb/arangodb-java-driver)
9+
4.1: [![Build Status](https://secure.travis-ci.org/arangodb/arangodb-java-driver.svg?branch=4.1)](https://travis-ci.org/arangodb/arangodb-java-driver)
1010
master: [![Build Status](https://secure.travis-ci.org/arangodb/arangodb-java-driver.svg?branch=master)](https://travis-ci.org/arangodb/arangodb-java-driver)
1111

1212
## Supported versions
1313

1414
<table>
1515
<tr><th>arangodb-java-driver</th><th>ArangoDB</th><th>network protocol</th><th>Java version</th></tr>
16-
<tr><td>4.0.x</td><td>3.1.x</td><td>VelocyStream</td><td>1.6+</td></tr>
16+
<tr><td>4.1.x</td><td>3.1.x</td><td>VelocyStream</td><td>1.6+</td></tr>
17+
<tr><td>4.0.0</td><td>3.1.0-RC1 to 3.1.0-RC3</td><td>VelocyStream</td><td>1.6+</td></tr>
1718
<tr><td>3.1.x</td><td>3.1.x</td><td>HTTP</td><td>1.6+</td></tr>
1819
<tr><td>3.0.x</td><td>3.0.x</td><td>HTTP</td><td>1.6+</td></tr>
1920
<tr><td>2.7.4</td><td>2.7.x and 2.8.x</td><td>HTTP</td><td>1.6+</td></tr>
2021
</table>
2122

22-
##Server Configuration
23-
24-
To use the driver version 4.0.0 and above, you need to run ArangoDB server with an endpoint using VelocyStream protocol. (see [documentation](https://docs.arangodb.com/current/Manual/Administration/Configuration/Endpoint.html#server-endpoints))
25-
26-
```
27-
unix> ./arangod --server.endpoint vpp+tcp://127.0.0.1:8529
28-
--server.endpoint vpp+ssl://127.0.0.1:8530
29-
--ssl.keyfile server.pem /tmp/vocbase
30-
```
31-
32-
Note: The web interface needs only endpoint tcp. If you want to use both, the driver and the web interface you have to use both endpoints.
33-
34-
```
35-
unix> ./arangod --server.endpoint vpp+tcp://127.0.0.1:8529
36-
--server.endpoint vpp+ssl://127.0.0.1:8530
37-
--server.endpoint tcp://127.0.0.1:8531
38-
--ssl.keyfile server.pem /tmp/vocbase
39-
```
40-
4123
## Maven
4224

4325
To add the driver to your project with maven, add the following code to your pom.xml
@@ -49,7 +31,7 @@ ArangoDB 3.1.X
4931
<dependency>
5032
<groupId>com.arangodb</groupId>
5133
<artifactId>arangodb-java-driver</artifactId>
52-
<version>4.0.0</version>
34+
<version>4.1.0</version>
5335
</dependency>
5436
....
5537
</dependencies>

docs/aql.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,5 @@ or return the AQL result as VelocyPack:
3939
System.out.println(obj.get("name").getAsString());
4040
}
4141
```
42+
43+
**Note**: The parameter `type` in `query()` has to match the result of the query, otherwise you get an VPackParserException. E.g. you set `type` to `BaseDocument` or a POJO and the query result is an array or simple type, you get an VPackParserException caused by VPackValueTypeException: Expecting type OBJECT.

docs/serialization.md

Lines changed: 112 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,112 @@
1-
# serialization / deserialization
2-
## JavaBeans
3-
The driver can serialize/deserialize JavaBeans. They need at least a constructor without parameter.
4-
5-
``` Java
6-
public class MyObject {
7-
8-
private String name;
9-
private Gender gender;
10-
private int age;
11-
12-
public MyObject() {
13-
super();
14-
}
15-
16-
}
17-
```
18-
19-
## internal fields
20-
To use Arango-internal fields (like _id, _key, _rev, _from, _to) in your JavaBeans, use the annotation `DocumentField`.
21-
22-
``` Java
23-
public class MyObject {
24-
25-
@DocumentField(Type.KEY)
26-
private String key;
27-
28-
private String name;
29-
private Gender gender;
30-
private int age;
31-
32-
public MyObject() {
33-
super();
34-
}
35-
36-
}
37-
```
38-
39-
## serialized fieldnames
40-
To use a different serialized name for a field, use the annotation `SerializedName`.
41-
42-
``` Java
43-
public class MyObject {
44-
45-
@SerializedName("title")
46-
private String name;
47-
48-
private Gender gender;
49-
private int age;
50-
51-
public MyObject() {
52-
super();
53-
}
54-
55-
}
56-
```
57-
58-
## ignore fields
59-
To ignore fields at serialization/deserialization, use the annotation `Expose`
60-
61-
``` Java
62-
public class MyObject {
63-
64-
@Expose
65-
private String name;
66-
@Expose(serialize = true, deserialize = false)
67-
private Gender gender;
68-
private int age;
69-
70-
public MyObject() {
71-
super();
72-
}
73-
74-
}
75-
```
76-
77-
## custom de-/serializer
78-
``` Java
79-
final ArangoDB arangoDB = new ArangoDB.Builder()
80-
.registerDeserializer(MyObject.class, new VPackDeserializer<MyObject>() {
81-
@Override
82-
public MyObject deserialize(
83-
final VPackSlice parent,
84-
final VPackSlice vpack,
85-
final VPackDeserializationContext context) throws VPackException {
86-
87-
final MyObject obj = new MyObject();
88-
obj.setName(vpack.get("name").getAsString());
89-
return obj;
90-
}
91-
}).registerSerializer(MyObject.class, new VPackSerializer<MyObject>() {
92-
@Override
93-
public void serialize(
94-
final VPackBuilder builder,
95-
final String attribute,
96-
final MyObject value,
97-
final VPackSerializationContext context) throws VPackException {
98-
99-
builder.add(attribute, ValueType.OBJECT);
100-
builder.add("name", value.getName());
101-
builder.close();
102-
}
103-
}).build();
104-
```
1+
# serialization / deserialization
2+
## JavaBeans
3+
The driver can serialize/deserialize JavaBeans. They need at least a constructor without parameter.
4+
5+
``` Java
6+
public class MyObject {
7+
8+
private String name;
9+
private Gender gender;
10+
private int age;
11+
12+
public MyObject() {
13+
super();
14+
}
15+
16+
}
17+
```
18+
19+
## internal fields
20+
To use Arango-internal fields (like _id, _key, _rev, _from, _to) in your JavaBeans, use the annotation `DocumentField`.
21+
22+
``` Java
23+
public class MyObject {
24+
25+
@DocumentField(Type.KEY)
26+
private String key;
27+
28+
private String name;
29+
private Gender gender;
30+
private int age;
31+
32+
public MyObject() {
33+
super();
34+
}
35+
36+
}
37+
```
38+
39+
## serialized fieldnames
40+
To use a different serialized name for a field, use the annotation `SerializedName`.
41+
42+
``` Java
43+
public class MyObject {
44+
45+
@SerializedName("title")
46+
private String name;
47+
48+
private Gender gender;
49+
private int age;
50+
51+
public MyObject() {
52+
super();
53+
}
54+
55+
}
56+
```
57+
58+
## ignore fields
59+
To ignore fields at serialization/deserialization, use the annotation `Expose`
60+
61+
``` Java
62+
public class MyObject {
63+
64+
@Expose
65+
private String name;
66+
@Expose(serialize = true, deserialize = false)
67+
private Gender gender;
68+
private int age;
69+
70+
public MyObject() {
71+
super();
72+
}
73+
74+
}
75+
```
76+
77+
## custom de-/serializer
78+
``` Java
79+
ArangoDB arangoDB = new ArangoDB.Builder()
80+
.registerDeserializer(MyObject.class, new VPackDeserializer<MyObject>() {
81+
@Override
82+
public MyObject deserialize(
83+
final VPackSlice parent,
84+
final VPackSlice vpack,
85+
final VPackDeserializationContext context) throws VPackException {
86+
87+
final MyObject obj = new MyObject();
88+
obj.setName(vpack.get("name").getAsString());
89+
return obj;
90+
}
91+
}).registerSerializer(MyObject.class, new VPackSerializer<MyObject>() {
92+
@Override
93+
public void serialize(
94+
final VPackBuilder builder,
95+
final String attribute,
96+
final MyObject value,
97+
final VPackSerializationContext context) throws VPackException {
98+
99+
builder.add(attribute, ValueType.OBJECT);
100+
builder.add("name", value.getName());
101+
builder.close();
102+
}
103+
}).build();
104+
```
105+
106+
## manually de-/serialization
107+
To de-/serialize from and to VelocyPack before or after a database call, use the `ArangoUtil` from the method `util()` in `ArangoDB`, `ArangoDatabase`, `ArangoCollection`, `ArangoGraph`, `ArangoEdgeCollection`or `ArangoVertexCollection`.
108+
109+
``` Java
110+
ArangoDB arangoDB = new ArangoDB.Builder();
111+
arangoDB.util().deserialize(vpack, type);
112+
```

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>com.arangodb</groupId>
66
<artifactId>arangodb-java-driver</artifactId>
7-
<version>4.1.0-SNAPSHOT</version>
7+
<version>4.1.1-SNAPSHOT</version>
88
<inceptionYear>2016</inceptionYear>
99
<packaging>jar</packaging>
1010

src/main/java/com/arangodb/ArangoCursor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class ArangoCursor<T> implements Iterator<T>, Closeable {
4949
private final boolean cached;
5050
private final ArangoCursorExecute execute;
5151

52-
public ArangoCursor(final InternalArangoDatabase<?, ?, ?> db, final ArangoCursorExecute execute,
52+
protected ArangoCursor(final InternalArangoDatabase<?, ?, ?> db, final ArangoCursorExecute execute,
5353
final Class<T> type, final CursorEntity result) {
5454
super();
5555
this.execute = execute;

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ public ArangoDatabase db(final String name) {
231231
}
232232

233233
/**
234-
* creates a new database
234+
* Creates a new database
235235
*
236236
* @see <a href="https://docs.arangodb.com/current/HTTP/Database/DatabaseManagement.html#create-database">API
237237
* Documentation</a>
@@ -245,6 +245,8 @@ public Boolean createDatabase(final String name) throws ArangoDBException {
245245
}
246246

247247
/**
248+
* Retrieves a list of all existing databases
249+
*
248250
* @see <a href="https://docs.arangodb.com/current/HTTP/Database/DatabaseManagement.html#list-of-databases">API
249251
* Documentation</a>
250252
* @return a list of all existing databases
@@ -255,6 +257,8 @@ public Collection<String> getDatabases() throws ArangoDBException {
255257
}
256258

257259
/**
260+
* Retrieves a list of all databases the current user can access
261+
*
258262
* @see <a href=
259263
* "https://docs.arangodb.com/current/HTTP/Database/DatabaseManagement.html#list-of-accessible-databases">API
260264
* Documentation</a>
@@ -265,6 +269,22 @@ public Collection<String> getAccessibleDatabases() throws ArangoDBException {
265269
return executor.execute(getAccessibleDatabasesRequest(db().name()), getDatabaseResponseDeserializer());
266270
}
267271

272+
/**
273+
* List available database to the specified user
274+
*
275+
* @see <a href=
276+
* "https://docs.arangodb.com/current/HTTP/UserManagement/index.html#list-the-databases-available-to-a-user">API
277+
* Documentation</a>
278+
* @param user
279+
* The name of the user for which you want to query the databases
280+
* @return
281+
* @throws ArangoDBException
282+
*/
283+
public Collection<String> getAccessibleDatabasesFor(final String user) throws ArangoDBException {
284+
return executor.execute(getAccessibleDatabasesForRequest(db().name(), user),
285+
getAccessibleDatabasesForResponseDeserializer());
286+
}
287+
268288
/**
269289
* Returns the server name and version number.
270290
*

src/main/java/com/arangodb/entity/LogLevelEntity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
public class LogLevelEntity {
2828

2929
public enum LogLevel {
30-
FATAL, ERROR, WARNING, INFO, DEBUG, DEFAULT;
30+
FATAL, ERROR, WARNING, INFO, DEBUG, TRACE, DEFAULT;
3131
}
3232

3333
private LogLevel agency;

src/main/java/com/arangodb/internal/ArangoExecuteable.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
package com.arangodb.internal;
2222

2323
import com.arangodb.internal.velocystream.Connection;
24+
import com.arangodb.util.ArangoUtil;
2425

2526
/**
2627
* @author Mark - mark at arangodb.com
@@ -35,4 +36,7 @@ public ArangoExecuteable(final E executor) {
3536
this.executor = executor;
3637
}
3738

39+
public ArangoUtil util() {
40+
return executor.util();
41+
}
3842
}

0 commit comments

Comments
 (0)