@@ -138,7 +138,7 @@ public String getAccessTokenRetryableMode() throws ExecutionException, RetryExce
138138 * @param limit The number of records to be fetched
139139 * @return The list of Map; each Map representing a table row
140140 */
141- public List < Map < String , String >> fetchTableRecords (
141+ public RestAPIResponse fetchTableRecords (
142142 String tableName ,
143143 SourceValueType valueType ,
144144 String startDate ,
@@ -161,8 +161,9 @@ public List<Map<String, String>> fetchTableRecords(
161161 String accessToken = getAccessToken ();
162162 requestBuilder .setAuthHeader (accessToken );
163163 RestAPIResponse apiResponse = executeGetWithRetries (requestBuilder .build ());
164+ return apiResponse ;
164165 //return parseResponseToResultListOfMap(apiResponse.getResponseBody());
165- return parseResponseStreamToResultListOfMap (apiResponse .getInputStream ());
166+ // return parseResponseStreamToRecord (apiResponse.getInputStream());
166167
167168 }
168169
@@ -206,20 +207,20 @@ public List<Map<String, String>> parseResponseToResultListOfMap(String responseB
206207 return GSON .fromJson (ja , type );
207208 }
208209
209- public List < Map <String , String >> parseResponseStreamToResultListOfMap (InputStream in ) throws ServiceNowAPIException {
210- List <Map <String , String >> records = new ArrayList <>();
210+ public Map <String , String > parseResponseStreamToRecord (InputStream in ) throws ServiceNowAPIException {
211+ // List<Map<String, String>> records = new ArrayList<>();
211212 // InputStream in = httpResponse.getEntity().getContent();
212213 try (InputStreamReader reader = new InputStreamReader (in , StandardCharsets .UTF_8 );
213214 JsonReader jsonReader = new JsonReader (reader )) {
214215 jsonReader .setLenient (true );
215216 jsonReader .beginObject ();
217+ Map <String , String > record = new HashMap <>();
216218 while (jsonReader .hasNext ()) {
217219 String name = jsonReader .nextName ();
218220 if (ServiceNowConstants .RESULT .equals (name ) && jsonReader .peek () == JsonToken .BEGIN_ARRAY ) {
219221 jsonReader .beginArray ();
220222 while (jsonReader .hasNext ()) {
221223 jsonReader .beginObject ();
222- Map <String , String > record = new HashMap <>();
223224 while (jsonReader .hasNext ()) {
224225 String field = jsonReader .nextName ();
225226 JsonToken token = jsonReader .peek ();
@@ -228,7 +229,7 @@ public List<Map<String, String>> parseResponseStreamToResultListOfMap(InputStrea
228229 record .put (field , token == JsonToken .NULL ? null : jsonReader .nextString ());
229230 }
230231 jsonReader .endObject ();
231- records .add (record );
232+ // records.add(record);
232233 }
233234 jsonReader .endArray ();
234235 } else {
@@ -237,7 +238,7 @@ public List<Map<String, String>> parseResponseStreamToResultListOfMap(InputStrea
237238 }
238239 }
239240 jsonReader .endObject ();
240- return records ;
241+ return record ;
241242 } catch (IOException e ) {
242243 throw new ServiceNowAPIException (e , null );
243244 }
@@ -277,12 +278,14 @@ private String getErrorMessage(String responseBody) {
277278 * @param limit The number of records to be fetched
278279 * @return The list of Map; each Map representing a table row
279280 */
280- public List < Map < String , String >> fetchTableRecordsRetryableMode (String tableName , SourceValueType valueType ,
281+ public RestAPIResponse fetchTableRecordsRetryableMode (String tableName , SourceValueType valueType ,
281282 String startDate , String endDate , int offset ,
282283 int limit ) throws ServiceNowAPIException {
283- final List <Map <String , String >> results = new ArrayList <>();
284+ //final List<Map<String, String>> results = new ArrayList<>();
285+ final RestAPIResponse [] restAPIResponse = new RestAPIResponse [1 ];
284286 Callable <Boolean > fetchRecords = () -> {
285- results .addAll (fetchTableRecords (tableName , valueType , startDate , endDate , offset , limit ));
287+ // results.addAll(fetchTableRecords(tableName, valueType, startDate, endDate, offset, limit));
288+ restAPIResponse [0 ] = fetchTableRecords (tableName , valueType , startDate , endDate , offset , limit );
286289 return true ;
287290 };
288291
@@ -300,7 +303,7 @@ public List<Map<String, String>> fetchTableRecordsRetryableMode(String tableName
300303 e , null , false );
301304 }
302305
303- return results ;
306+ return restAPIResponse [ 0 ] ;
304307 }
305308
306309 /**
0 commit comments