1717import io .kuzzle .sdk .responses .SecurityDocumentList ;
1818import io .kuzzle .sdk .util .Scroll ;
1919
20-
2120/**
2221 * Kuzzle security API
2322 */
@@ -75,12 +74,12 @@ public void fetchRole(@NonNull final String id, Options options, @NonNull final
7574
7675 try {
7776 data = new JSONObject ().put ("_id" , id );
78- this .kuzzle .query (buildQueryArgs ("fetchRole " ), data , options , new OnQueryDoneListener () {
77+ this .kuzzle .query (buildQueryArgs ("getRole " ), data , options , new OnQueryDoneListener () {
7978 @ Override
8079 public void onSuccess (JSONObject response ) {
8180 try {
8281 JSONObject result = response .getJSONObject ("result" );
83- listener .onSuccess (new Role (Security .this .kuzzle , result .getString ("_id" ), result .getJSONObject ("_source" )));
82+ listener .onSuccess (new Role (Security .this .kuzzle , result .getString ("_id" ), result .getJSONObject ("_source" ), result . getJSONObject ( "_meta" ) ));
8483 }
8584 catch (JSONException e ) {
8685 throw new RuntimeException (e );
@@ -135,7 +134,7 @@ public void onSuccess(JSONObject response) {
135134
136135 for (int i = 0 ; i < documentsLength ; i ++) {
137136 JSONObject document = documents .getJSONObject (i );
138- roles .add (new Role (Security .this .kuzzle , document .getString ("_id" ), document .getJSONObject ("_source" )));
137+ roles .add (new Role (Security .this .kuzzle , document .getString ("_id" ), document .getJSONObject ("_source" ), document . getJSONObject ( "_meta" ) ));
139138 }
140139
141140 listener .onSuccess (new SecurityDocumentList (roles , result .getLong ("total" )));
@@ -188,7 +187,7 @@ public void createRole(@NonNull final String id, @NonNull final JSONObject conte
188187 public void onSuccess (JSONObject response ) {
189188 try {
190189 JSONObject result = response .getJSONObject ("result" );
191- listener .onSuccess (new Role (Security .this .kuzzle , result .getString ("_id" ), result .getJSONObject ("_source" )));
190+ listener .onSuccess (new Role (Security .this .kuzzle , result .getString ("_id" ), result .getJSONObject ("_source" ), result . getJSONObject ( "_meta" ) ));
192191 }
193192 catch (JSONException e ) {
194193 throw new RuntimeException (e );
@@ -312,7 +311,7 @@ public Security updateRole(@NonNull final String id, final JSONObject content, f
312311 @ Override
313312 public void onSuccess (JSONObject response ) {
314313 try {
315- listener .onSuccess (new Role (Security .this .kuzzle , response .getJSONObject ("result" ).getString ("_id" ), response .getJSONObject ("result" ).getJSONObject ("_source" )));
314+ listener .onSuccess (new Role (Security .this .kuzzle , response .getJSONObject ("result" ).getString ("_id" ), response .getJSONObject ("result" ).getJSONObject ("_source" ), response . getJSONObject ( "result" ). getJSONObject ( "_meta" ) ));
316315 }
317316 catch (JSONException e ) {
318317 throw new RuntimeException (e );
@@ -359,18 +358,26 @@ public Security updateRole(@NonNull final String id, final JSONObject content) t
359358 *
360359 * @param id Role unique identifier
361360 * @param content Role content
361+ * @param meta Role metadata
362362 * @return new Role object
363363 * @throws JSONException
364364 */
365+ public Role role (@ NonNull final String id , final JSONObject content , final JSONObject meta ) throws JSONException {
366+ return new Role (this .kuzzle , id , content , meta );
367+ }
368+
369+ /**
370+ * {@link #role(String, JSONObject, JSONObject)}
371+ */
365372 public Role role (@ NonNull final String id , final JSONObject content ) throws JSONException {
366- return new Role (this .kuzzle , id , content );
373+ return new Role (this .kuzzle , id , content , null );
367374 }
368375
369376 /**
370- * {@link #role(String, JSONObject)}
377+ * {@link #role(String, JSONObject, JSONObject )}
371378 */
372379 public Role role (@ NonNull final String id ) throws JSONException {
373- return new Role (this .kuzzle , id , null );
380+ return new Role (this .kuzzle , id , null , null );
374381 }
375382
376383 /**
@@ -392,7 +399,7 @@ public void fetchProfile(@NonNull final String id, final Options options, @NonNu
392399
393400 JSONObject data = new JSONObject ().put ("_id" , id );
394401
395- this .kuzzle .query (buildQueryArgs ("fetchProfile " ), data , options , new OnQueryDoneListener () {
402+ this .kuzzle .query (buildQueryArgs ("getProfile " ), data , options , new OnQueryDoneListener () {
396403 @ Override
397404 public void onSuccess (JSONObject response ) {
398405 try {
@@ -415,7 +422,7 @@ public void onSuccess(JSONObject response) {
415422 result .getJSONObject ("_source" ).remove ("policies" );
416423 result .getJSONObject ("_source" ).put ("policies" , formattedPolicies );
417424
418- listener .onSuccess (new Profile (Security .this .kuzzle , result .getString ("_id" ), result .getJSONObject ("_source" )));
425+ listener .onSuccess (new Profile (Security .this .kuzzle , result .getString ("_id" ), result .getJSONObject ("_source" ), result . getJSONObject ( "_meta" ) ));
419426 } catch (JSONException e ) {
420427 throw new RuntimeException (e );
421428 }
@@ -465,7 +472,7 @@ public void onSuccess(JSONObject response) {
465472
466473 for (int i = 0 ; i < documentsLength ; i ++) {
467474 JSONObject document = documents .getJSONObject (i );
468- profiles .add (new Profile (Security .this .kuzzle , document .getString ("_id" ), document .getJSONObject ("_source" )));
475+ profiles .add (new Profile (Security .this .kuzzle , document .getString ("_id" ), document .getJSONObject ("_source" ), document . getJSONObject ( "_meta" ) ));
469476 }
470477
471478 Scroll scroll = new Scroll ();
@@ -526,7 +533,7 @@ public void createProfile(@NonNull final String id, @NonNull final JSONObject[]
526533 public void onSuccess (JSONObject response ) {
527534 try {
528535 JSONObject result = response .getJSONObject ("result" );
529- listener .onSuccess (new Profile (Security .this .kuzzle , result .getString ("_id" ), result .getJSONObject ("_source" )));
536+ listener .onSuccess (new Profile (Security .this .kuzzle , result .getString ("_id" ), result .getJSONObject ("_source" ), result . getJSONObject ( "_meta" ) ));
530537 }
531538 catch (JSONException e ) {
532539 throw new RuntimeException (e );
@@ -665,7 +672,7 @@ public void onSuccess(JSONObject object) {
665672
666673 for (int i = 0 ; i < hits .length (); i ++) {
667674 JSONObject hit = hits .getJSONObject (i );
668- Profile profile = new Profile (Security .this .kuzzle , hit .getString ("_id" ), hit .getJSONObject ("_source" ));
675+ Profile profile = new Profile (Security .this .kuzzle , hit .getString ("_id" ), hit .getJSONObject ("_source" ), hit . getJSONObject ( "_meta" ) );
669676
670677 profiles .add (profile );
671678 }
@@ -718,7 +725,7 @@ public Security updateProfile(@NonNull final String id, final JSONObject[] polic
718725 @ Override
719726 public void onSuccess (JSONObject response ) {
720727 try {
721- listener .onSuccess (new Profile (Security .this .kuzzle , response .getJSONObject ("result" ).getString ("_id" ), response .getJSONObject ("result" ).getJSONObject ("_source" )));
728+ listener .onSuccess (new Profile (Security .this .kuzzle , response .getJSONObject ("result" ).getString ("_id" ), response .getJSONObject ("result" ).getJSONObject ("_source" ), response . getJSONObject ( "result" ). getJSONObject ( "_meta" ) ));
722729 }
723730 catch (JSONException e ) {
724731 throw new RuntimeException (e );
@@ -765,18 +772,26 @@ public Security updateProfile(@NonNull final String id, final JSONObject[] polic
765772 *
766773 * @param id Profile unique identifier
767774 * @param content Profile content
775+ * @param meta Profile metadata
768776 * @return new Profile object
769777 * @throws JSONException
770778 */
779+ public Profile profile (@ NonNull final String id , final JSONObject content , final JSONObject meta ) throws JSONException {
780+ return new Profile (this .kuzzle , id , content , meta );
781+ }
782+
783+ /**
784+ * {@link #profile(String, JSONObject, JSONObject)}
785+ */
771786 public Profile profile (@ NonNull final String id , final JSONObject content ) throws JSONException {
772- return new Profile (this .kuzzle , id , content );
787+ return new Profile (this .kuzzle , id , content , null );
773788 }
774789
775790 /**
776- * {@link #profile(String, JSONObject)}
791+ * {@link #profile(String, JSONObject, JSONObject )}
777792 */
778793 public Profile profile (@ NonNull final String id ) throws JSONException {
779- return new Profile (this .kuzzle , id , null );
794+ return new Profile (this .kuzzle , id , null , null );
780795 }
781796
782797 /**
@@ -798,12 +813,12 @@ public void fetchUser(@NonNull final String id, final Options options, @NonNull
798813
799814 JSONObject data = new JSONObject ().put ("_id" , id );
800815
801- this .kuzzle .query (buildQueryArgs ("fetchUser " ), data , options , new OnQueryDoneListener () {
816+ this .kuzzle .query (buildQueryArgs ("getUser " ), data , options , new OnQueryDoneListener () {
802817 @ Override
803818 public void onSuccess (JSONObject response ) {
804819 try {
805820 JSONObject result = response .getJSONObject ("result" );
806- listener .onSuccess (new User (Security .this .kuzzle , result .getString ("_id" ), result .getJSONObject ("_source" )));
821+ listener .onSuccess (new User (Security .this .kuzzle , result .getString ("_id" ), result .getJSONObject ("_source" ), result . getJSONObject ( "_meta" ) ));
807822 } catch (JSONException e ) {
808823 throw new RuntimeException (e );
809824 }
@@ -849,7 +864,7 @@ public void replaceUser(@NonNull final String id, @NonNull final JSONObject cont
849864 public void onSuccess (JSONObject response ) {
850865 try {
851866 JSONObject result = response .getJSONObject ("result" );
852- listener .onSuccess (new User (Security .this .kuzzle , result .getString ("_id" ), result .getJSONObject ("_source" )));
867+ listener .onSuccess (new User (Security .this .kuzzle , result .getString ("_id" ), result .getJSONObject ("_source" ), result . getJSONObject ( "_meta" ) ));
853868 }
854869 catch (JSONException e ) {
855870 throw new RuntimeException (e );
@@ -919,7 +934,7 @@ public void onSuccess(JSONObject response) {
919934
920935 for (int i = 0 ; i < documentsLength ; i ++) {
921936 JSONObject document = documents .getJSONObject (i );
922- users .add (new User (Security .this .kuzzle , document .getString ("_id" ), document .getJSONObject ("_source" )));
937+ users .add (new User (Security .this .kuzzle , document .getString ("_id" ), document .getJSONObject ("_source" ), document . getJSONObject ( "_meta" ) ));
923938 }
924939
925940 Scroll scroll = new Scroll ();
@@ -971,7 +986,7 @@ public void createUser(@NonNull final String id, @NonNull final JSONObject conte
971986 public void onSuccess (JSONObject response ) {
972987 try {
973988 JSONObject result = response .getJSONObject ("result" );
974- listener .onSuccess (new User (Security .this .kuzzle , result .getString ("_id" ), result .getJSONObject ("_source" )));
989+ listener .onSuccess (new User (Security .this .kuzzle , result .getString ("_id" ), result .getJSONObject ("_source" ), result . getJSONObject ( "_meta" ) ));
975990 }
976991 catch (JSONException e ) {
977992 throw new RuntimeException (e );
@@ -1039,7 +1054,7 @@ public void createRestrictedUser(@NonNull final String id, @NonNull final JSONOb
10391054 public void onSuccess (JSONObject response ) {
10401055 try {
10411056 JSONObject result = response .getJSONObject ("result" );
1042- listener .onSuccess (new User (Security .this .kuzzle , result .getString ("_id" ), result .getJSONObject ("_source" )));
1057+ listener .onSuccess (new User (Security .this .kuzzle , result .getString ("_id" ), result .getJSONObject ("_source" ), result . getJSONObject ( "_meta" ) ));
10431058 }
10441059 catch (JSONException e ) {
10451060 throw new RuntimeException (e );
@@ -1178,7 +1193,7 @@ public void onSuccess(JSONObject object) {
11781193
11791194 for (int i = 0 ; i < hits .length (); i ++) {
11801195 JSONObject hit = hits .getJSONObject (i );
1181- User user = new User (Security .this .kuzzle , hit .getString ("_id" ), hit .getJSONObject ("_source" ));
1196+ User user = new User (Security .this .kuzzle , hit .getString ("_id" ), hit .getJSONObject ("_source" ), hit . getJSONObject ( "_meta" ) );
11821197
11831198 users .add (user );
11841199 }
@@ -1231,7 +1246,7 @@ public Security updateUser(@NonNull final String id, final JSONObject content, f
12311246 @ Override
12321247 public void onSuccess (JSONObject response ) {
12331248 try {
1234- listener .onSuccess (new User (Security .this .kuzzle , response .getJSONObject ("result" ).getString ("_id" ), response .getJSONObject ("result" ).getJSONObject ("_source" )));
1249+ listener .onSuccess (new User (Security .this .kuzzle , response .getJSONObject ("result" ).getString ("_id" ), response .getJSONObject ("result" ).getJSONObject ("_source" ), response . getJSONObject ( "result" ). getJSONObject ( "_meta" ) ));
12351250 }
12361251 catch (JSONException e ) {
12371252 throw new RuntimeException (e );
@@ -1278,18 +1293,26 @@ public Security updateUser(@NonNull final String id, final JSONObject content) t
12781293 *
12791294 * @param id User unique identifier
12801295 * @param content User content
1296+ * @param meta User metadata
12811297 * @return new User object
12821298 * @throws JSONException
12831299 */
1300+ public User user (@ NonNull final String id , final JSONObject content , final JSONObject meta ) throws JSONException {
1301+ return new User (this .kuzzle , id , content , meta );
1302+ }
1303+
1304+ /**
1305+ * {@link #user(String, JSONObject, JSONObject)}
1306+ */
12841307 public User user (@ NonNull final String id , final JSONObject content ) throws JSONException {
1285- return new User (this .kuzzle , id , content );
1308+ return new User (this .kuzzle , id , content , null );
12861309 }
12871310
12881311 /**
1289- * {@link #user(String, JSONObject)}
1312+ * {@link #user(String, JSONObject, JSONObject )}
12901313 */
12911314 public User user (@ NonNull final String id ) throws JSONException {
1292- return new User (this .kuzzle , id , null );
1315+ return new User (this .kuzzle , id , null , null );
12931316 }
12941317
12951318 /**
0 commit comments