@@ -38,80 +38,77 @@ public class InternalUsersDriverImpl extends BaseArangoDriverImpl implements com
3838 private static final String EXTRA = "extra" ;
3939 private static final String ACTIVE = "active" ;
4040 private static final String PW = "passwd" ;
41- private static final String USERNAME = "username" ;
41+ private static final String USERNAME = "user" ;
42+ private static final String GRANT = "grant" ;
43+ private static final String DATABASE = "database" ;
44+ private static final String READ_WRITE = "rw" ;
4245
4346 InternalUsersDriverImpl (ArangoConfigure configure , HttpManager httpManager ) {
4447 super (configure , httpManager );
4548 }
4649
4750 @ Override
48- public DefaultEntity createUser (
49- String database ,
50- String username ,
51- String passwd ,
52- Boolean active ,
53- Map <String , Object > extra ) throws ArangoException {
54-
55- HttpResponseEntity res = httpManager .doPost (createUserEndpointUrl (database ), null , EntityFactory .toJsonString (
51+ public DefaultEntity createUser (String username , String passwd , Boolean active , Map <String , Object > extra )
52+ throws ArangoException {
53+
54+ HttpResponseEntity res = httpManager .doPost (createUserEndpointUrl (), null , EntityFactory .toJsonString (
5655 new MapBuilder ().put (USERNAME , username ).put (PW , passwd ).put (ACTIVE , active ).put (EXTRA , extra ).get ()));
5756
5857 return createEntity (res , DefaultEntity .class );
5958 }
6059
6160 @ Override
62- public DefaultEntity deleteUser (String database , String username ) throws ArangoException {
61+ public DefaultEntity deleteUser (String username ) throws ArangoException {
6362
64- HttpResponseEntity res = httpManager .doDelete (createUserEndpointUrl (database , StringUtils .encodeUrl (username )),
65- null );
63+ HttpResponseEntity res = httpManager .doDelete (createUserEndpointUrl (StringUtils .encodeUrl (username )), null );
6664
6765 return createEntity (res , DefaultEntity .class );
6866 }
6967
7068 @ Override
71- public UserEntity getUser (String database , String username ) throws ArangoException {
69+ public UserEntity getUser (String username ) throws ArangoException {
7270
73- HttpResponseEntity res = httpManager .doGet (createUserEndpointUrl (database , StringUtils .encodeUrl (username )),
74- null );
71+ HttpResponseEntity res = httpManager .doGet (createUserEndpointUrl (StringUtils .encodeUrl (username )), null );
7572
7673 return createEntity (res , UserEntity .class );
7774 }
7875
7976 @ Override
80- public UsersEntity getUsers (String database ) throws ArangoException {
77+ public UsersEntity getUsers () throws ArangoException {
8178
82- HttpResponseEntity res = httpManager .doGet (createUserEndpointUrl (database ), null );
79+ HttpResponseEntity res = httpManager .doGet (createUserEndpointUrl (), null );
8380
8481 return createEntity (res , UsersEntity .class );
8582 }
8683
8784 @ Override
88- public DefaultEntity replaceUser (
89- String database ,
90- String username ,
91- String passwd ,
92- Boolean active ,
93- Map <String , Object > extra ) throws ArangoException {
94-
95- HttpResponseEntity res = httpManager .doPut (createUserEndpointUrl (database , StringUtils .encodeUrl (username )),
96- null ,
85+ public DefaultEntity replaceUser (String username , String passwd , Boolean active , Map <String , Object > extra )
86+ throws ArangoException {
87+
88+ HttpResponseEntity res = httpManager .doPut (createUserEndpointUrl (StringUtils .encodeUrl (username )), null ,
9789 EntityFactory .toJsonString (new MapBuilder ().put (PW , passwd ).put (ACTIVE , active ).put (EXTRA , extra ).get ()));
9890
9991 return createEntity (res , DefaultEntity .class );
10092 }
10193
10294 @ Override
103- public DefaultEntity updateUser (
104- String database ,
105- String username ,
106- String passwd ,
107- Boolean active ,
108- Map <String , Object > extra ) throws ArangoException {
109-
110- HttpResponseEntity res = httpManager .doPatch (createUserEndpointUrl (database , StringUtils .encodeUrl (username )),
111- null ,
95+ public DefaultEntity updateUser (String username , String passwd , Boolean active , Map <String , Object > extra )
96+ throws ArangoException {
97+
98+ HttpResponseEntity res = httpManager .doPatch (createUserEndpointUrl (StringUtils .encodeUrl (username )), null ,
11299 EntityFactory .toJsonString (new MapBuilder ().put (PW , passwd ).put (ACTIVE , active ).put (EXTRA , extra ).get ()));
113100
114101 return createEntity (res , DefaultEntity .class );
115102 }
116103
104+ @ Override
105+ public DefaultEntity grantDatabaseAccess (String username , String database ) throws ArangoException {
106+
107+ final HttpResponseEntity res = httpManager .doPut (
108+ createUserEndpointUrl (StringUtils .encodeUrl (username ), DATABASE , StringUtils .encodeUrl (database )), null ,
109+ EntityFactory .toJsonString (new MapBuilder ().put (GRANT , READ_WRITE ).get ()));
110+
111+ return createEntity (res , DefaultEntity .class );
112+ }
113+
117114}
0 commit comments