Skip to content

Commit 8176c60

Browse files
author
Mark
committed
fixes methods which does not use defaultdatabase
1 parent b909837 commit 8176c60

9 files changed

+43
-21
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
v2.7.5 (2016-11-25)
22
---------------------------
33
* fixed issue #43 (ArangoDriver.getAqlFunctions(String) does not uses the defaultDatabase setting)
4+
* fixed ArangoDriver.getCurrentDatabase() (does not use the defaultDatabase)
5+
* fixed ArangoDriver.deleteQueryCache() (does not use the defaultDatabase)
6+
* fixed ArangoDriver.getQueryCacheProperties() (does not use the defaultDatabase)
7+
* fixed ArangoDriver.setQueryCacheProperties() (does not use the defaultDatabase)
8+
* fixed ArangoDriver.reloadRouting() (does not use the defaultDatabase)
49

510
v2.7.4 (2016-04-15)
611
---------------------------

src/main/java/com/arangodb/ArangoDriver.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2856,7 +2856,7 @@ public ArangoUnixTime getTime() throws ArangoException {
28562856
* @throws ArangoException
28572857
*/
28582858
public DefaultEntity reloadRouting() throws ArangoException {
2859-
return adminDriver.reloadRouting();
2859+
return adminDriver.reloadRouting(getDefaultDatabase());
28602860
}
28612861

28622862
/**
@@ -3850,7 +3850,7 @@ public ImportResultEntity importDocumentsByHeaderValues(
38503850
* @throws ArangoException
38513851
*/
38523852
public DatabaseEntity getCurrentDatabase() throws ArangoException {
3853-
return databaseDriver.getCurrentDatabase();
3853+
return databaseDriver.getCurrentDatabase(getDefaultDatabase());
38543854
}
38553855

38563856
/**
@@ -5478,7 +5478,7 @@ public <V, E> TraversalEntity<V, E> getTraversal(
54785478
* @throws ArangoException
54795479
*/
54805480
public DefaultEntity deleteQueryCache() throws ArangoException {
5481-
return queryCacheDriver.deleteQueryCache();
5481+
return queryCacheDriver.deleteQueryCache(getDefaultDatabase());
54825482
}
54835483

54845484
/**
@@ -5489,7 +5489,7 @@ public DefaultEntity deleteQueryCache() throws ArangoException {
54895489
* @throws ArangoException
54905490
*/
54915491
public QueryCachePropertiesEntity getQueryCacheProperties() throws ArangoException {
5492-
return queryCacheDriver.getQueryCacheProperties();
5492+
return queryCacheDriver.getQueryCacheProperties(getDefaultDatabase());
54935493
}
54945494

54955495
/**
@@ -5500,7 +5500,7 @@ public QueryCachePropertiesEntity getQueryCacheProperties() throws ArangoExcepti
55005500
*/
55015501
public QueryCachePropertiesEntity setQueryCacheProperties(QueryCachePropertiesEntity properties)
55025502
throws ArangoException {
5503-
return queryCacheDriver.setQueryCacheProperties(properties);
5503+
return queryCacheDriver.setQueryCacheProperties(getDefaultDatabase(), properties);
55045504
}
55055505

55065506
/**

src/main/java/com/arangodb/InternalAdminDriver.java

Lines changed: 1 addition & 1 deletion
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
}

src/main/java/com/arangodb/InternalDatabaseDriver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Created by fbartels on 10/27/14.
1111
*/
1212
public interface InternalDatabaseDriver extends BaseDriverInterface {
13-
DatabaseEntity getCurrentDatabase() throws ArangoException;
13+
DatabaseEntity getCurrentDatabase(String database) throws ArangoException;
1414

1515
StringsResultEntity getDatabases(boolean currentUserAccessableOnly, String username, String password) throws ArangoException;
1616

src/main/java/com/arangodb/InternalQueryCacheDriver.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
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) throws ArangoException;
1717

1818
}

src/main/java/com/arangodb/impl/InternalAdminDriverImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ public ArangoUnixTime getTime() throws ArangoException {
114114
}
115115

116116
@Override
117-
public DefaultEntity reloadRouting() throws ArangoException {
117+
public DefaultEntity reloadRouting(String database) throws ArangoException {
118118

119-
HttpResponseEntity res = httpManager.doPost(createEndpointUrl(null, "/_admin/routing/reload"), null,
119+
HttpResponseEntity res = httpManager.doPost(createEndpointUrl(database, "/_admin/routing/reload"), null,
120120
(String) null);
121121

122122
return createEntity(res, DefaultEntity.class, null, false);

src/main/java/com/arangodb/impl/InternalDatabaseDriverImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ public class InternalDatabaseDriverImpl extends BaseArangoDriverImpl implements
4141
}
4242

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

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

4949
}

src/main/java/com/arangodb/impl/InternalQueryCacheDriverImpl.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,27 @@ public class InternalQueryCacheDriverImpl extends BaseArangoDriverImpl
3636
}
3737

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

41-
HttpResponseEntity res = httpManager.doDelete(createEndpointUrl(null, "/_api/query-cache"), null);
41+
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(String database) throws ArangoException {
4848

49-
HttpResponseEntity res = httpManager.doGet(createEndpointUrl(null, "/_api/query-cache"), null);
49+
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)
56+
public QueryCachePropertiesEntity setQueryCacheProperties(String database, QueryCachePropertiesEntity properties)
5757
throws ArangoException {
5858

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

6262
return createEntity(res, QueryCachePropertiesEntity.class);

src/test/java/com/arangodb/ArangoDriverDatabaseTest.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public void test_invalid_dbname_for_delete() throws ArangoException {
9090

9191
@Test
9292
public void test_current_database() throws ArangoException {
93-
93+
driver.setDefaultDatabase("_system");
9494
DatabaseEntity entity = driver.getCurrentDatabase();
9595
assertThat(entity.isError(), is(false));
9696
assertThat(entity.getCode(), is(200));
@@ -101,6 +101,23 @@ public void test_current_database() throws ArangoException {
101101

102102
}
103103

104+
@Test
105+
public void test_current_database2() throws ArangoException {
106+
final String dbName = "abcdefghi1abcdefghi2abcdefghi3abcdefghi4abcdefghi5abcdefghi61234";
107+
try {
108+
try {
109+
driver.deleteDatabase(dbName);
110+
} catch (final ArangoException e) {
111+
}
112+
driver.createDatabase(dbName);
113+
driver.setDefaultDatabase(dbName);
114+
final DatabaseEntity entity = driver.getCurrentDatabase();
115+
assertThat(entity.getName(), is(dbName));
116+
} finally {
117+
driver.deleteDatabase(dbName);
118+
}
119+
}
120+
104121
@Test
105122
public void test_createDatabase() throws ArangoException {
106123

0 commit comments

Comments
 (0)