11package com .pubnub .api .endpoints .access ;
22
33import com .fasterxml .jackson .core .type .TypeReference ;
4- import com .fasterxml .jackson .databind .ObjectMapper ;
54import com .pubnub .api .PubNub ;
65import com .pubnub .api .PubNubException ;
76import com .pubnub .api .PubNubUtil ;
87import com .pubnub .api .builder .PubNubErrorBuilder ;
98import com .pubnub .api .endpoints .Endpoint ;
109import com .pubnub .api .enums .PNOperationType ;
10+ import com .pubnub .api .managers .MapperManager ;
1111import com .pubnub .api .models .consumer .access_manager .PNAccessManagerGrantResult ;
1212import com .pubnub .api .models .consumer .access_manager .PNAccessManagerKeyData ;
1313import com .pubnub .api .models .consumer .access_manager .PNAccessManagerKeysData ;
1919import retrofit2 .Response ;
2020import retrofit2 .Retrofit ;
2121
22- import java .io .IOException ;
2322import java .util .ArrayList ;
2423import java .util .HashMap ;
2524import java .util .List ;
@@ -101,7 +100,6 @@ protected Call<Envelope<AccessManagerGrantPayload>> doWork(Map<String, String> q
101100
102101 @ Override
103102 protected PNAccessManagerGrantResult createResponse (Response <Envelope <AccessManagerGrantPayload >> input ) throws PubNubException {
104- ObjectMapper mapper = new ObjectMapper ();
105103 PNAccessManagerGrantResult .PNAccessManagerGrantResultBuilder pnAccessManagerGrantResult = PNAccessManagerGrantResult .builder ();
106104
107105 if (input .body () == null || input .body ().getPayload () == null ) {
@@ -121,18 +119,15 @@ protected PNAccessManagerGrantResult createResponse(Response<Envelope<AccessMana
121119 if (channelGroups .size () == 1 ) {
122120 constructedGroups .put (data .getChannelGroups ().asText (), data .getAuthKeys ());
123121 } else if (channelGroups .size () > 1 ) {
124- try {
125- HashMap <String , PNAccessManagerKeysData > channelGroupKeySet = mapper .readValue (data .getChannelGroups ().toString (),
126- new TypeReference <HashMap <String , PNAccessManagerKeysData >>() {
127- });
122+ MapperManager mapper = this . getPubnub (). getMapper ();
123+ HashMap <String , PNAccessManagerKeysData > channelGroupKeySet = mapper .fromJson (data .getChannelGroups ().toString (),
124+ new TypeReference <HashMap <String , PNAccessManagerKeysData >>() {
125+ });
128126// for (String fetchedChannelGroup : channelGroupKeySet.keySet()) {
129127// constructedGroups.put(fetchedChannelGroup, channelGroupKeySet.get(fetchedChannelGroup).getAuthKeys());
130128// }
131- for (Map .Entry <String , PNAccessManagerKeysData > entry : channelGroupKeySet .entrySet ()) {
132- constructedGroups .put (entry .getKey (), entry .getValue ().getAuthKeys ());
133- }
134- } catch (IOException e ) {
135- throw PubNubException .builder ().pubnubError (PubNubErrorBuilder .PNERROBJ_PARSING_ERROR ).errormsg (e .getMessage ()).build ();
129+ for (Map .Entry <String , PNAccessManagerKeysData > entry : channelGroupKeySet .entrySet ()) {
130+ constructedGroups .put (entry .getKey (), entry .getValue ().getAuthKeys ());
136131 }
137132 }
138133 }
0 commit comments