Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3f83809

Browse files
author
Mark
committedOct 18, 2016
fixes methods which does not use defaultdatabase
1 parent ef61715 commit 3f83809

7 files changed

+4732
-4856
lines changed
 

‎ChangeLog

+259-251
Large diffs are not rendered by default.

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

+4,029-4,183
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1-
package com.arangodb;
2-
3-
import com.arangodb.entity.BooleanResultEntity;
4-
import com.arangodb.entity.DatabaseEntity;
5-
import com.arangodb.entity.StringsResultEntity;
6-
import com.arangodb.entity.UserEntity;
7-
import com.arangodb.impl.BaseDriverInterface;
8-
9-
/**
10-
* Created by fbartels on 10/27/14.
11-
*/
12-
public interface InternalDatabaseDriver extends BaseDriverInterface {
13-
DatabaseEntity getCurrentDatabase() throws ArangoException;
14-
15-
StringsResultEntity getDatabases(boolean currentUserAccessableOnly, String username, String password) throws ArangoException;
16-
17-
BooleanResultEntity createDatabase(String database, UserEntity... users) throws ArangoException;
18-
19-
BooleanResultEntity deleteDatabase(String database) throws ArangoException;
20-
}
1+
package com.arangodb;
2+
3+
import com.arangodb.entity.BooleanResultEntity;
4+
import com.arangodb.entity.DatabaseEntity;
5+
import com.arangodb.entity.StringsResultEntity;
6+
import com.arangodb.entity.UserEntity;
7+
import com.arangodb.impl.BaseDriverInterface;
8+
9+
/**
10+
* Created by fbartels on 10/27/14.
11+
*/
12+
public interface InternalDatabaseDriver extends BaseDriverInterface {
13+
14+
DatabaseEntity getCurrentDatabase(String database) throws ArangoException;
15+
16+
StringsResultEntity getDatabases(boolean currentUserAccessableOnly, String username, String password)
17+
throws ArangoException;
18+
19+
BooleanResultEntity createDatabase(String database, UserEntity... users) throws ArangoException;
20+
21+
BooleanResultEntity deleteDatabase(String database) throws ArangoException;
22+
}
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
package com.arangodb;
2-
3-
import com.arangodb.entity.DefaultEntity;
4-
import com.arangodb.entity.QueryCachePropertiesEntity;
5-
import com.arangodb.impl.BaseDriverInterface;
6-
7-
/**
8-
* Created by a-brandt on 2015-09-11.
9-
*/
10-
public interface InternalQueryCacheDriver extends BaseDriverInterface {
11-
12-
DefaultEntity deleteQueryCache() throws ArangoException;
13-
14-
QueryCachePropertiesEntity getQueryCacheProperties() throws ArangoException;
15-
16-
QueryCachePropertiesEntity setQueryCacheProperties(QueryCachePropertiesEntity properties) throws ArangoException;
17-
18-
}
1+
package com.arangodb;
2+
3+
import com.arangodb.entity.DefaultEntity;
4+
import com.arangodb.entity.QueryCachePropertiesEntity;
5+
import com.arangodb.impl.BaseDriverInterface;
6+
7+
/**
8+
* Created by a-brandt on 2015-09-11.
9+
*/
10+
public interface InternalQueryCacheDriver extends BaseDriverInterface {
11+
12+
DefaultEntity deleteQueryCache(String database) throws ArangoException;
13+
14+
QueryCachePropertiesEntity getQueryCacheProperties(String database) throws ArangoException;
15+
16+
QueryCachePropertiesEntity setQueryCacheProperties(String database, QueryCachePropertiesEntity properties)
17+
throws ArangoException;
18+
19+
}
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,95 @@
1-
/*
2-
* Copyright (C) 2012,2013 tamtam180
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
16-
17-
package com.arangodb.impl;
18-
19-
import java.util.TreeMap;
20-
21-
import com.arangodb.ArangoConfigure;
22-
import com.arangodb.ArangoException;
23-
import com.arangodb.entity.BooleanResultEntity;
24-
import com.arangodb.entity.DatabaseEntity;
25-
import com.arangodb.entity.EntityFactory;
26-
import com.arangodb.entity.StringsResultEntity;
27-
import com.arangodb.entity.UserEntity;
28-
import com.arangodb.http.HttpManager;
29-
import com.arangodb.http.HttpResponseEntity;
30-
31-
/**
32-
* @author tamtam180 - kirscheless at gmail.com
33-
*
34-
*/
35-
public class InternalDatabaseDriverImpl extends BaseArangoDriverImpl implements com.arangodb.InternalDatabaseDriver {
36-
37-
private static final String API_DATABASE = "/_api/database";
38-
39-
InternalDatabaseDriverImpl(ArangoConfigure configure, HttpManager httpManager) {
40-
super(configure, httpManager);
41-
}
42-
43-
@Override
44-
public DatabaseEntity getCurrentDatabase() throws ArangoException {
45-
46-
HttpResponseEntity res = httpManager.doGet(createEndpointUrl(null, "/_api/database/current"));
47-
return createEntity(res, DatabaseEntity.class);
48-
49-
}
50-
51-
@Override
52-
public StringsResultEntity getDatabases(boolean currentUserAccessableOnly, String username, String password)
53-
throws ArangoException {
54-
HttpResponseEntity res = httpManager.doGet(
55-
createEndpointUrl(null, API_DATABASE, currentUserAccessableOnly ? "user" : null), null, null, username,
56-
password);
57-
return createEntity(res, StringsResultEntity.class);
58-
59-
}
60-
61-
@Override
62-
public BooleanResultEntity createDatabase(String database, UserEntity... users) throws ArangoException {
63-
64-
validateDatabaseName(database, false);
65-
66-
TreeMap<String, Object> body = new TreeMap<String, Object>();
67-
body.put("name", database);
68-
if (users != null && users.length > 0) {
69-
body.put("users", users);
70-
}
71-
72-
HttpResponseEntity res = httpManager.doPost(createEndpointUrl(null, API_DATABASE), null,
73-
EntityFactory.toJsonString(body));
74-
75-
return createEntity(res, BooleanResultEntity.class);
76-
77-
}
78-
79-
@Override
80-
public BooleanResultEntity deleteDatabase(String database) throws ArangoException {
81-
82-
validateDatabaseName(database, false);
83-
84-
TreeMap<String, Object> body = new TreeMap<String, Object>();
85-
body.put("name", database);
86-
87-
HttpResponseEntity res = httpManager.doDelete(createEndpointUrl(null, API_DATABASE, database), null);
88-
89-
return createEntity(res, BooleanResultEntity.class);
90-
91-
}
92-
93-
}
1+
/*
2+
* Copyright (C) 2012,2013 tamtam180
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.arangodb.impl;
18+
19+
import java.util.TreeMap;
20+
21+
import com.arangodb.ArangoConfigure;
22+
import com.arangodb.ArangoException;
23+
import com.arangodb.entity.BooleanResultEntity;
24+
import com.arangodb.entity.DatabaseEntity;
25+
import com.arangodb.entity.EntityFactory;
26+
import com.arangodb.entity.StringsResultEntity;
27+
import com.arangodb.entity.UserEntity;
28+
import com.arangodb.http.HttpManager;
29+
import com.arangodb.http.HttpResponseEntity;
30+
31+
/**
32+
* @author tamtam180 - kirscheless at gmail.com
33+
*
34+
*/
35+
public class InternalDatabaseDriverImpl extends BaseArangoDriverImpl implements com.arangodb.InternalDatabaseDriver {
36+
37+
private static final String API_DATABASE = "/_api/database";
38+
39+
InternalDatabaseDriverImpl(final ArangoConfigure configure, final HttpManager httpManager) {
40+
super(configure, httpManager);
41+
}
42+
43+
@Override
44+
public DatabaseEntity getCurrentDatabase(final String database) throws ArangoException {
45+
46+
final HttpResponseEntity res = httpManager.doGet(createEndpointUrl(database, "/_api/database/current"));
47+
return createEntity(res, DatabaseEntity.class);
48+
49+
}
50+
51+
@Override
52+
public StringsResultEntity getDatabases(
53+
final boolean currentUserAccessableOnly,
54+
final String username,
55+
final String password) throws ArangoException {
56+
final HttpResponseEntity res = httpManager.doGet(
57+
createEndpointUrl(null, API_DATABASE, currentUserAccessableOnly ? "user" : null), null, null, username,
58+
password);
59+
return createEntity(res, StringsResultEntity.class);
60+
61+
}
62+
63+
@Override
64+
public BooleanResultEntity createDatabase(final String database, final UserEntity... users) throws ArangoException {
65+
66+
validateDatabaseName(database, false);
67+
68+
final TreeMap<String, Object> body = new TreeMap<String, Object>();
69+
body.put("name", database);
70+
if (users != null && users.length > 0) {
71+
body.put("users", users);
72+
}
73+
74+
final HttpResponseEntity res = httpManager.doPost(createEndpointUrl(null, API_DATABASE), null,
75+
EntityFactory.toJsonString(body));
76+
77+
return createEntity(res, BooleanResultEntity.class);
78+
79+
}
80+
81+
@Override
82+
public BooleanResultEntity deleteDatabase(final String database) throws ArangoException {
83+
84+
validateDatabaseName(database, false);
85+
86+
final TreeMap<String, Object> body = new TreeMap<String, Object>();
87+
body.put("name", database);
88+
89+
final HttpResponseEntity res = httpManager.doDelete(createEndpointUrl(null, API_DATABASE, database), null);
90+
91+
return createEntity(res, BooleanResultEntity.class);
92+
93+
}
94+
95+
}
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,66 @@
1-
/*
2-
* Copyright (C) 2012,2013 tamtam180
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
16-
17-
package com.arangodb.impl;
18-
19-
import com.arangodb.ArangoConfigure;
20-
import com.arangodb.ArangoException;
21-
import com.arangodb.entity.DefaultEntity;
22-
import com.arangodb.entity.EntityFactory;
23-
import com.arangodb.entity.QueryCachePropertiesEntity;
24-
import com.arangodb.http.HttpManager;
25-
import com.arangodb.http.HttpResponseEntity;
26-
27-
/**
28-
* @author a-brandt
29-
*
30-
*/
31-
public class InternalQueryCacheDriverImpl extends BaseArangoDriverImpl
32-
implements com.arangodb.InternalQueryCacheDriver {
33-
34-
InternalQueryCacheDriverImpl(ArangoConfigure configure, HttpManager httpManager) {
35-
super(configure, httpManager);
36-
}
37-
38-
@Override
39-
public DefaultEntity deleteQueryCache() throws ArangoException {
40-
41-
HttpResponseEntity res = httpManager.doDelete(createEndpointUrl(null, "/_api/query-cache"), null);
42-
43-
return createEntity(res, DefaultEntity.class);
44-
}
45-
46-
@Override
47-
public QueryCachePropertiesEntity getQueryCacheProperties() throws ArangoException {
48-
49-
HttpResponseEntity res = httpManager.doGet(createEndpointUrl(null, "/_api/query-cache"), null);
50-
51-
return createEntity(res, QueryCachePropertiesEntity.class);
52-
53-
}
54-
55-
@Override
56-
public QueryCachePropertiesEntity setQueryCacheProperties(QueryCachePropertiesEntity properties)
57-
throws ArangoException {
58-
59-
HttpResponseEntity res = httpManager.doPut(createEndpointUrl(null, "/_api/query-cache/properties"), null,
60-
EntityFactory.toJsonString(properties));
61-
62-
return createEntity(res, QueryCachePropertiesEntity.class);
63-
}
64-
65-
}
1+
/*
2+
* Copyright (C) 2012,2013 tamtam180
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.arangodb.impl;
18+
19+
import com.arangodb.ArangoConfigure;
20+
import com.arangodb.ArangoException;
21+
import com.arangodb.entity.DefaultEntity;
22+
import com.arangodb.entity.EntityFactory;
23+
import com.arangodb.entity.QueryCachePropertiesEntity;
24+
import com.arangodb.http.HttpManager;
25+
import com.arangodb.http.HttpResponseEntity;
26+
27+
/**
28+
* @author a-brandt
29+
*
30+
*/
31+
public class InternalQueryCacheDriverImpl extends BaseArangoDriverImpl
32+
implements com.arangodb.InternalQueryCacheDriver {
33+
34+
InternalQueryCacheDriverImpl(final ArangoConfigure configure, final HttpManager httpManager) {
35+
super(configure, httpManager);
36+
}
37+
38+
@Override
39+
public DefaultEntity deleteQueryCache(final String database) throws ArangoException {
40+
41+
final HttpResponseEntity res = httpManager.doDelete(createEndpointUrl(database, "/_api/query-cache"), null);
42+
43+
return createEntity(res, DefaultEntity.class);
44+
}
45+
46+
@Override
47+
public QueryCachePropertiesEntity getQueryCacheProperties(final String database) throws ArangoException {
48+
49+
final HttpResponseEntity res = httpManager.doGet(createEndpointUrl(database, "/_api/query-cache"), null);
50+
51+
return createEntity(res, QueryCachePropertiesEntity.class);
52+
53+
}
54+
55+
@Override
56+
public QueryCachePropertiesEntity setQueryCacheProperties(
57+
final String database,
58+
final QueryCachePropertiesEntity properties) throws ArangoException {
59+
60+
final HttpResponseEntity res = httpManager.doPut(createEndpointUrl(database, "/_api/query-cache/properties"),
61+
null, EntityFactory.toJsonString(properties));
62+
63+
return createEntity(res, QueryCachePropertiesEntity.class);
64+
}
65+
66+
}

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

+242-226
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.