Skip to content

Commit 9cbf8b0

Browse files
author
Mark
committed
fixes methods which does not use defaultdatabase
1 parent 8b3682a commit 9cbf8b0

9 files changed

+358
-512
lines changed

Diff for: ChangeLog

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
v3.0.5 (2016-10-18)
2+
---------------------------
3+
* fixed ArangoDriver.getCurrentDatabase() (does not use the defaultDatabase)
4+
* fixed ArangoDriver.deleteQueryCache() (does not use the defaultDatabase)
5+
* fixed ArangoDriver.getQueryCacheProperties() (does not use the defaultDatabase)
6+
* fixed ArangoDriver.setQueryCacheProperties() (does not use the defaultDatabase)
7+
* fixed ArangoDriver.reloadRouting() (does not use the defaultDatabase)
8+
19
v3.0.4 (2016-10-17)
210
---------------------------
311
* fixed edges deserializer (issue #50)

Diff for: src/main/java/com/arangodb/ArangoDriver.java

+277-460
Large diffs are not rendered by default.

Diff for: src/main/java/com/arangodb/InternalAdminDriver.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ AdminLogEntity getServerLog(
3535

3636
ArangoUnixTime getTime() throws ArangoException;
3737

38-
DefaultEntity reloadRouting() throws ArangoException;
38+
DefaultEntity reloadRouting(String database) throws ArangoException;
3939

4040
DefaultEntity executeScript(String database, String jsCode) throws ArangoException;
4141
}

Diff for: src/main/java/com/arangodb/InternalDatabaseDriver.java

+7-5
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99
/**
1010
* Created by fbartels on 10/27/14.
1111
*/
12-
public interface InternalDatabaseDriver extends BaseDriverInterface {
13-
DatabaseEntity getCurrentDatabase() throws ArangoException;
12+
public interface InternalDatabaseDriver extends BaseDriverInterface {
1413

15-
StringsResultEntity getDatabases(boolean currentUserAccessableOnly, String username, String password) throws ArangoException;
14+
DatabaseEntity getCurrentDatabase(String database) throws ArangoException;
1615

17-
BooleanResultEntity createDatabase(String database, UserEntity... users) throws ArangoException;
16+
StringsResultEntity getDatabases(boolean currentUserAccessableOnly, String username, String password)
17+
throws ArangoException;
1818

19-
BooleanResultEntity deleteDatabase(String database) throws ArangoException;
19+
BooleanResultEntity createDatabase(String database, UserEntity... users) throws ArangoException;
20+
21+
BooleanResultEntity deleteDatabase(String database) throws ArangoException;
2022
}

Diff for: src/main/java/com/arangodb/InternalQueryCacheDriver.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
*/
1010
public interface InternalQueryCacheDriver extends BaseDriverInterface {
1111

12-
DefaultEntity deleteQueryCache() throws ArangoException;
12+
DefaultEntity deleteQueryCache(String database) throws ArangoException;
1313

14-
QueryCachePropertiesEntity getQueryCacheProperties() throws ArangoException;
14+
QueryCachePropertiesEntity getQueryCacheProperties(String database) throws ArangoException;
1515

16-
QueryCachePropertiesEntity setQueryCacheProperties(QueryCachePropertiesEntity properties) throws ArangoException;
16+
QueryCachePropertiesEntity setQueryCacheProperties(String database, QueryCachePropertiesEntity properties)
17+
throws ArangoException;
1718

1819
}

Diff for: src/main/java/com/arangodb/impl/InternalAdminDriverImpl.java

+20-21
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,22 @@ public class InternalAdminDriverImpl extends BaseArangoDriverImpl implements com
3636

3737
// MEMO: ADMINはdatabase関係ない
3838

39-
InternalAdminDriverImpl(ArangoConfigure configure, HttpManager httpManager) {
39+
InternalAdminDriverImpl(final ArangoConfigure configure, final HttpManager httpManager) {
4040
super(configure, httpManager);
4141
}
4242

4343
@Override
4444
public AdminLogEntity getServerLog(
45-
Integer logLevel,
46-
Boolean logLevelUpTo,
47-
Integer start,
48-
Integer size,
49-
Integer offset,
50-
Boolean sortAsc,
51-
String text) throws ArangoException {
45+
final Integer logLevel,
46+
final Boolean logLevelUpTo,
47+
final Integer start,
48+
final Integer size,
49+
final Integer offset,
50+
final Boolean sortAsc,
51+
final String text) throws ArangoException {
5252

5353
// パラメータを作る
54-
MapBuilder param = new MapBuilder();
54+
final MapBuilder param = new MapBuilder();
5555
if (logLevel != null) {
5656
if (logLevelUpTo != null && logLevelUpTo.booleanValue()) {
5757
param.put("upto", logLevel);
@@ -67,23 +67,23 @@ public AdminLogEntity getServerLog(
6767
}
6868
param.put("search", text);
6969

70-
HttpResponseEntity res = httpManager.doGet(createEndpointUrl(null, "/_admin/log"), param.get());
70+
final HttpResponseEntity res = httpManager.doGet(createEndpointUrl(null, "/_admin/log"), param.get());
7171

7272
return createEntity(res, AdminLogEntity.class);
7373
}
7474

7575
@Override
7676
public StatisticsEntity getStatistics() throws ArangoException {
7777

78-
HttpResponseEntity res = httpManager.doGet(createEndpointUrl(null, "/_admin/statistics"));
78+
final HttpResponseEntity res = httpManager.doGet(createEndpointUrl(null, "/_admin/statistics"));
7979

8080
return createEntity(res, StatisticsEntity.class);
8181
}
8282

8383
@Override
8484
public StatisticsDescriptionEntity getStatisticsDescription() throws ArangoException {
8585

86-
HttpResponseEntity res = httpManager.doGet(createEndpointUrl(null, "/_admin/statistics-description"));
86+
final HttpResponseEntity res = httpManager.doGet(createEndpointUrl(null, "/_admin/statistics-description"));
8787

8888
return createEntity(res, StatisticsDescriptionEntity.class);
8989
}
@@ -93,39 +93,38 @@ public StatisticsDescriptionEntity getStatisticsDescription() throws ArangoExcep
9393
*
9494
* @return a ArangoVersion object
9595
* @throws ArangoException
96-
* @see <a href=
97-
* "http://www.arangodb.com/manuals/current/HttpMisc.html#HttpMiscVersion">
98-
* HttpMiscVersion documentation</a>
96+
* @see <a href= "http://www.arangodb.com/manuals/current/HttpMisc.html#HttpMiscVersion"> HttpMiscVersion
97+
* documentation</a>
9998
*/
10099
@Override
101100
public ArangoVersion getVersion() throws ArangoException {
102101

103-
HttpResponseEntity res = httpManager.doGet(createEndpointUrl(null, "/_api/version"));
102+
final HttpResponseEntity res = httpManager.doGet(createEndpointUrl(null, "/_api/version"));
104103

105104
return createEntity(res, ArangoVersion.class);
106105
}
107106

108107
@Override
109108
public ArangoUnixTime getTime() throws ArangoException {
110109

111-
HttpResponseEntity res = httpManager.doGet(createEndpointUrl(null, "/_admin/time"));
110+
final HttpResponseEntity res = httpManager.doGet(createEndpointUrl(null, "/_admin/time"));
112111

113112
return createEntity(res, ArangoUnixTime.class);
114113
}
115114

116115
@Override
117-
public DefaultEntity reloadRouting() throws ArangoException {
116+
public DefaultEntity reloadRouting(final String database) throws ArangoException {
118117

119-
HttpResponseEntity res = httpManager.doPost(createEndpointUrl(null, "/_admin/routing/reload"), null,
118+
final HttpResponseEntity res = httpManager.doPost(createEndpointUrl(database, "/_admin/routing/reload"), null,
120119
(String) null);
121120

122121
return createEntity(res, DefaultEntity.class, null, false);
123122
}
124123

125124
@Override
126-
public DefaultEntity executeScript(String database, String jsCode) throws ArangoException {
125+
public DefaultEntity executeScript(final String database, final String jsCode) throws ArangoException {
127126

128-
HttpResponseEntity res = httpManager.doPost(createEndpointUrl(database, "/_admin/execute"), null, jsCode);
127+
final HttpResponseEntity res = httpManager.doPost(createEndpointUrl(database, "/_admin/execute"), null, jsCode);
129128

130129
return createEntity(res, DefaultEntity.class);
131130
}

Diff for: src/main/java/com/arangodb/impl/InternalDatabaseDriverImpl.java

+14-12
Original file line numberDiff line numberDiff line change
@@ -36,55 +36,57 @@ public class InternalDatabaseDriverImpl extends BaseArangoDriverImpl implements
3636

3737
private static final String API_DATABASE = "/_api/database";
3838

39-
InternalDatabaseDriverImpl(ArangoConfigure configure, HttpManager httpManager) {
39+
InternalDatabaseDriverImpl(final ArangoConfigure configure, final HttpManager httpManager) {
4040
super(configure, httpManager);
4141
}
4242

4343
@Override
44-
public DatabaseEntity getCurrentDatabase() throws ArangoException {
44+
public DatabaseEntity getCurrentDatabase(final String database) throws ArangoException {
4545

46-
HttpResponseEntity res = httpManager.doGet(createEndpointUrl(null, "/_api/database/current"));
46+
final HttpResponseEntity res = httpManager.doGet(createEndpointUrl(database, "/_api/database/current"));
4747
return createEntity(res, DatabaseEntity.class);
4848

4949
}
5050

5151
@Override
52-
public StringsResultEntity getDatabases(boolean currentUserAccessableOnly, String username, String password)
53-
throws ArangoException {
54-
HttpResponseEntity res = httpManager.doGet(
52+
public StringsResultEntity getDatabases(
53+
final boolean currentUserAccessableOnly,
54+
final String username,
55+
final String password) throws ArangoException {
56+
final HttpResponseEntity res = httpManager.doGet(
5557
createEndpointUrl(null, API_DATABASE, currentUserAccessableOnly ? "user" : null), null, null, username,
5658
password);
5759
return createEntity(res, StringsResultEntity.class);
5860

5961
}
6062

6163
@Override
62-
public BooleanResultEntity createDatabase(String database, UserEntity... users) throws ArangoException {
64+
public BooleanResultEntity createDatabase(final String database, final UserEntity... users) throws ArangoException {
6365

6466
validateDatabaseName(database, false);
6567

66-
TreeMap<String, Object> body = new TreeMap<String, Object>();
68+
final TreeMap<String, Object> body = new TreeMap<String, Object>();
6769
body.put("name", database);
6870
if (users != null && users.length > 0) {
6971
body.put("users", users);
7072
}
7173

72-
HttpResponseEntity res = httpManager.doPost(createEndpointUrl(null, API_DATABASE), null,
74+
final HttpResponseEntity res = httpManager.doPost(createEndpointUrl(null, API_DATABASE), null,
7375
EntityFactory.toJsonString(body));
7476

7577
return createEntity(res, BooleanResultEntity.class);
7678

7779
}
7880

7981
@Override
80-
public BooleanResultEntity deleteDatabase(String database) throws ArangoException {
82+
public BooleanResultEntity deleteDatabase(final String database) throws ArangoException {
8183

8284
validateDatabaseName(database, false);
8385

84-
TreeMap<String, Object> body = new TreeMap<String, Object>();
86+
final TreeMap<String, Object> body = new TreeMap<String, Object>();
8587
body.put("name", database);
8688

87-
HttpResponseEntity res = httpManager.doDelete(createEndpointUrl(null, API_DATABASE, database), null);
89+
final HttpResponseEntity res = httpManager.doDelete(createEndpointUrl(null, API_DATABASE, database), null);
8890

8991
return createEntity(res, BooleanResultEntity.class);
9092

Diff for: src/main/java/com/arangodb/impl/InternalQueryCacheDriverImpl.java

+10-9
Original file line numberDiff line numberDiff line change
@@ -31,33 +31,34 @@
3131
public class InternalQueryCacheDriverImpl extends BaseArangoDriverImpl
3232
implements com.arangodb.InternalQueryCacheDriver {
3333

34-
InternalQueryCacheDriverImpl(ArangoConfigure configure, HttpManager httpManager) {
34+
InternalQueryCacheDriverImpl(final ArangoConfigure configure, final HttpManager httpManager) {
3535
super(configure, httpManager);
3636
}
3737

3838
@Override
39-
public DefaultEntity deleteQueryCache() throws ArangoException {
39+
public DefaultEntity deleteQueryCache(final String database) throws ArangoException {
4040

41-
HttpResponseEntity res = httpManager.doDelete(createEndpointUrl(null, "/_api/query-cache"), null);
41+
final HttpResponseEntity res = httpManager.doDelete(createEndpointUrl(database, "/_api/query-cache"), null);
4242

4343
return createEntity(res, DefaultEntity.class);
4444
}
4545

4646
@Override
47-
public QueryCachePropertiesEntity getQueryCacheProperties() throws ArangoException {
47+
public QueryCachePropertiesEntity getQueryCacheProperties(final String database) throws ArangoException {
4848

49-
HttpResponseEntity res = httpManager.doGet(createEndpointUrl(null, "/_api/query-cache"), null);
49+
final HttpResponseEntity res = httpManager.doGet(createEndpointUrl(database, "/_api/query-cache"), null);
5050

5151
return createEntity(res, QueryCachePropertiesEntity.class);
5252

5353
}
5454

5555
@Override
56-
public QueryCachePropertiesEntity setQueryCacheProperties(QueryCachePropertiesEntity properties)
57-
throws ArangoException {
56+
public QueryCachePropertiesEntity setQueryCacheProperties(
57+
final String database,
58+
final QueryCachePropertiesEntity properties) throws ArangoException {
5859

59-
HttpResponseEntity res = httpManager.doPut(createEndpointUrl(null, "/_api/query-cache/properties"), null,
60-
EntityFactory.toJsonString(properties));
60+
final HttpResponseEntity res = httpManager.doPut(createEndpointUrl(database, "/_api/query-cache/properties"),
61+
null, EntityFactory.toJsonString(properties));
6162

6263
return createEntity(res, QueryCachePropertiesEntity.class);
6364
}

Diff for: src/test/java/com/arangodb/ArangoDriverDatabaseTest.java

+17-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public void test_invalid_dbname_for_delete() throws ArangoException {
103103

104104
@Test
105105
public void test_current_database() throws ArangoException {
106-
106+
driver.setDefaultDatabase("_system");
107107
final DatabaseEntity entity = driver.getCurrentDatabase();
108108
assertThat(entity.isError(), is(false));
109109
assertThat(entity.getCode(), is(200));
@@ -114,6 +114,22 @@ public void test_current_database() throws ArangoException {
114114

115115
}
116116

117+
@Test
118+
public void test_current_database2() throws ArangoException {
119+
try {
120+
try {
121+
driver.deleteDatabase(DB_NAME);
122+
} catch (final ArangoException e) {
123+
}
124+
driver.createDatabase(DB_NAME);
125+
driver.setDefaultDatabase(DB_NAME);
126+
final DatabaseEntity entity = driver.getCurrentDatabase();
127+
assertThat(entity.getName(), is(DB_NAME));
128+
} finally {
129+
driver.deleteDatabase(DB_NAME);
130+
}
131+
}
132+
117133
@Test
118134
public void test_createDatabase() throws ArangoException {
119135

0 commit comments

Comments
 (0)