3131import java .util .*;
3232
3333public final class VaultController extends VaultClient {
34- private static final Gson gson = new GsonBuilder ().serializeNulls ().create ();
35- private static final JsonObject skyMetadata = Utils .getMetrics ();
34+ private static final Gson GSON = new GsonBuilder ().serializeNulls ().create ();
35+ private static final JsonObject SKY_METADATA = Utils .getMetrics ();
3636
3737 public VaultController (VaultConfig vaultConfig , Credentials credentials ) {
3838 super (vaultConfig , credentials );
3939 }
4040
4141 private static synchronized HashMap <String , Object > getFormattedBatchInsertRecord (Object record , Integer requestIndex ) {
4242 HashMap <String , Object > insertRecord = new HashMap <>();
43- String jsonString = gson .toJson (record );
43+ String jsonString = GSON .toJson (record );
4444 JsonObject bodyObject = JsonParser .parseString (jsonString ).getAsJsonObject ().get ("Body" ).getAsJsonObject ();
4545 JsonArray records = bodyObject .getAsJsonArray ("records" );
4646 JsonPrimitive error = bodyObject .getAsJsonPrimitive ("error" );
@@ -122,7 +122,7 @@ public InsertResponse insert(InsertRequest insertRequest) throws SkyflowExceptio
122122 setBearerToken ();
123123 if (continueOnError ) {
124124 RecordServiceBatchOperationBody insertBody = super .getBatchInsertRequestBody (insertRequest );
125- RequestOptions requestOptions = RequestOptions .builder ().addHeader (Constants .SDK_METRICS_HEADER_KEY , skyMetadata .toString ()).build ();
125+ RequestOptions requestOptions = RequestOptions .builder ().addHeader (Constants .SDK_METRICS_HEADER_KEY , SKY_METADATA .toString ()).build ();
126126 batchInsertResult = super .getRecordsApi ().withRawResponse ().recordServiceBatchOperation (super .getVaultConfig ().getVaultId (), insertBody , requestOptions );
127127 LogUtil .printInfoLog (InfoLogs .INSERT_REQUEST_RESOLVED .getLog ());
128128 Optional <List <Map <String , Object >>> records = batchInsertResult .body ().getResponses ();
@@ -157,7 +157,7 @@ public InsertResponse insert(InsertRequest insertRequest) throws SkyflowExceptio
157157 }
158158 }
159159 } catch (ApiClientApiException e ) {
160- String bodyString = gson .toJson (e .body ());
160+ String bodyString = GSON .toJson (e .body ());
161161 LogUtil .printErrorLog (ErrorLogs .INSERT_RECORDS_REJECTED .getLog ());
162162 throw new SkyflowException (e .statusCode (), e , e .headers (), bodyString );
163163 }
@@ -181,7 +181,7 @@ public DetokenizeResponse detokenize(DetokenizeRequest detokenizeRequest) throws
181181 Validations .validateDetokenizeRequest (detokenizeRequest );
182182 setBearerToken ();
183183 V1DetokenizePayload payload = super .getDetokenizePayload (detokenizeRequest );
184- RequestOptions requestOptions = RequestOptions .builder ().addHeader (Constants .SDK_METRICS_HEADER_KEY , skyMetadata .toString ()).build ();
184+ RequestOptions requestOptions = RequestOptions .builder ().addHeader (Constants .SDK_METRICS_HEADER_KEY , SKY_METADATA .toString ()).build ();
185185 result = super .getTokensApi ().withRawResponse ().recordServiceDetokenize (super .getVaultConfig ().getVaultId (), payload , requestOptions );
186186 LogUtil .printInfoLog (InfoLogs .DETOKENIZE_REQUEST_RESOLVED .getLog ());
187187 Map <String , List <String >> responseHeaders = result .headers ();
@@ -202,7 +202,7 @@ public DetokenizeResponse detokenize(DetokenizeRequest detokenizeRequest) throws
202202 }
203203 }
204204 } catch (ApiClientApiException e ) {
205- String bodyString = gson .toJson (e .body ());
205+ String bodyString = GSON .toJson (e .body ());
206206 LogUtil .printErrorLog (ErrorLogs .DETOKENIZE_REQUEST_REJECTED .getLog ());
207207 throw new SkyflowException (e .statusCode (), e , e .headers (), bodyString );
208208 }
@@ -244,7 +244,7 @@ public GetResponse get(GetRequest getRequest) throws SkyflowException {
244244 .orderBy (RecordServiceBulkGetRecordRequestOrderBy .valueOf (getRequest .getOrderBy ()))
245245 .build ();
246246
247- RequestOptions requestOptions = RequestOptions .builder ().addHeader (Constants .SDK_METRICS_HEADER_KEY , skyMetadata .toString ()).build ();
247+ RequestOptions requestOptions = RequestOptions .builder ().addHeader (Constants .SDK_METRICS_HEADER_KEY , SKY_METADATA .toString ()).build ();
248248 result = super .getRecordsApi ().recordServiceBulkGetRecord (
249249 super .getVaultConfig ().getVaultId (),
250250 getRequest .getTable (),
@@ -259,7 +259,7 @@ public GetResponse get(GetRequest getRequest) throws SkyflowException {
259259 }
260260 }
261261 } catch (ApiClientApiException e ) {
262- String bodyString = gson .toJson (e .body ());
262+ String bodyString = GSON .toJson (e .body ());
263263 LogUtil .printErrorLog (ErrorLogs .GET_REQUEST_REJECTED .getLog ());
264264 throw new SkyflowException (e .statusCode (), e , e .headers (), bodyString );
265265 }
@@ -277,7 +277,7 @@ public UpdateResponse update(UpdateRequest updateRequest) throws SkyflowExceptio
277277 Validations .validateUpdateRequest (updateRequest );
278278 setBearerToken ();
279279 RecordServiceUpdateRecordBody updateBody = super .getUpdateRequestBody (updateRequest );
280- RequestOptions requestOptions = RequestOptions .builder ().addHeader (Constants .SDK_METRICS_HEADER_KEY , skyMetadata .toString ()).build ();
280+ RequestOptions requestOptions = RequestOptions .builder ().addHeader (Constants .SDK_METRICS_HEADER_KEY , SKY_METADATA .toString ()).build ();
281281 result = super .getRecordsApi ().recordServiceUpdateRecord (
282282 super .getVaultConfig ().getVaultId (),
283283 updateRequest .getTable (),
@@ -289,7 +289,7 @@ public UpdateResponse update(UpdateRequest updateRequest) throws SkyflowExceptio
289289 skyflowId = String .valueOf (result .getSkyflowId ());
290290 tokensMap = getFormattedUpdateRecord (result );
291291 } catch (ApiClientApiException e ) {
292- String bodyString = gson .toJson (e .body ());
292+ String bodyString = GSON .toJson (e .body ());
293293 LogUtil .printErrorLog (ErrorLogs .UPDATE_REQUEST_REJECTED .getLog ());
294294 throw new SkyflowException (e .statusCode (), e , e .headers (), bodyString );
295295 }
@@ -307,12 +307,12 @@ public DeleteResponse delete(DeleteRequest deleteRequest) throws SkyflowExceptio
307307 RecordServiceBulkDeleteRecordBody deleteBody = RecordServiceBulkDeleteRecordBody .builder ().skyflowIds (deleteRequest .getIds ())
308308 .build ();
309309
310- RequestOptions requestOptions = RequestOptions .builder ().addHeader (Constants .SDK_METRICS_HEADER_KEY , skyMetadata .toString ()).build ();
310+ RequestOptions requestOptions = RequestOptions .builder ().addHeader (Constants .SDK_METRICS_HEADER_KEY , SKY_METADATA .toString ()).build ();
311311 result = super .getRecordsApi ().recordServiceBulkDeleteRecord (
312312 super .getVaultConfig ().getVaultId (), deleteRequest .getTable (), deleteBody , requestOptions );
313313 LogUtil .printInfoLog (InfoLogs .DELETE_REQUEST_RESOLVED .getLog ());
314314 } catch (ApiClientApiException e ) {
315- String bodyString = gson .toJson (e .body ());
315+ String bodyString = GSON .toJson (e .body ());
316316 LogUtil .printErrorLog (ErrorLogs .DELETE_REQUEST_REJECTED .getLog ());
317317 throw new SkyflowException (e .statusCode (), e , e .headers (), bodyString );
318318 }
@@ -328,7 +328,7 @@ public QueryResponse query(QueryRequest queryRequest) throws SkyflowException {
328328 LogUtil .printInfoLog (InfoLogs .VALIDATING_QUERY_REQUEST .getLog ());
329329 Validations .validateQueryRequest (queryRequest );
330330 setBearerToken ();
331- RequestOptions requestOptions = RequestOptions .builder ().addHeader (Constants .SDK_METRICS_HEADER_KEY , skyMetadata .toString ()).build ();
331+ RequestOptions requestOptions = RequestOptions .builder ().addHeader (Constants .SDK_METRICS_HEADER_KEY , SKY_METADATA .toString ()).build ();
332332 result = super .getQueryApi ().queryServiceExecuteQuery (
333333 super .getVaultConfig ().getVaultId (),
334334 QueryServiceExecuteQueryBody .builder ().query (queryRequest .getQuery ()).build (),
@@ -342,7 +342,7 @@ public QueryResponse query(QueryRequest queryRequest) throws SkyflowException {
342342 }
343343 }
344344 } catch (ApiClientApiException e ) {
345- String bodyString = gson .toJson (e .body ());
345+ String bodyString = GSON .toJson (e .body ());
346346 LogUtil .printErrorLog (ErrorLogs .QUERY_REQUEST_REJECTED .getLog ());
347347 throw new SkyflowException (e .statusCode (), e , e .headers (), bodyString );
348348 }
@@ -359,7 +359,7 @@ public TokenizeResponse tokenize(TokenizeRequest tokenizeRequest) throws Skyflow
359359 Validations .validateTokenizeRequest (tokenizeRequest );
360360 setBearerToken ();
361361 V1TokenizePayload payload = super .getTokenizePayload (tokenizeRequest );
362- RequestOptions requestOptions = RequestOptions .builder ().addHeader (Constants .SDK_METRICS_HEADER_KEY , skyMetadata .toString ()).build ();
362+ RequestOptions requestOptions = RequestOptions .builder ().addHeader (Constants .SDK_METRICS_HEADER_KEY , SKY_METADATA .toString ()).build ();
363363 result = super .getTokensApi ().recordServiceTokenize (super .getVaultConfig ().getVaultId (), payload , requestOptions );
364364 LogUtil .printInfoLog (InfoLogs .TOKENIZE_REQUEST_RESOLVED .getLog ());
365365 if (result != null && result .getRecords ().isPresent () && !result .getRecords ().get ().isEmpty ()) {
@@ -370,7 +370,7 @@ public TokenizeResponse tokenize(TokenizeRequest tokenizeRequest) throws Skyflow
370370 }
371371 }
372372 } catch (ApiClientApiException e ) {
373- String bodyString = gson .toJson (e .body ());
373+ String bodyString = GSON .toJson (e .body ());
374374 LogUtil .printErrorLog (ErrorLogs .TOKENIZE_REQUEST_REJECTED .getLog ());
375375 throw new SkyflowException (e .statusCode (), e , e .headers (), bodyString );
376376 }
@@ -395,7 +395,7 @@ public FileUploadResponse uploadFile(FileUploadRequest fileUploadRequest) throws
395395 .returnFileMetadata (false )
396396 .build ();
397397
398- RequestOptions requestOptions = RequestOptions .builder ().addHeader (Constants .SDK_METRICS_HEADER_KEY , skyMetadata .toString ()).build ();
398+ RequestOptions requestOptions = RequestOptions .builder ().addHeader (Constants .SDK_METRICS_HEADER_KEY , SKY_METADATA .toString ()).build ();
399399 UploadFileV2Response uploadFileV2Response = super .getRecordsApi ().uploadFileV2 (
400400 super .getVaultConfig ().getVaultId (),
401401 file ,
@@ -409,7 +409,7 @@ public FileUploadResponse uploadFile(FileUploadRequest fileUploadRequest) throws
409409 );
410410
411411 } catch (ApiClientApiException e ) {
412- String bodyString = gson .toJson (e .body ());
412+ String bodyString = GSON .toJson (e .body ());
413413 LogUtil .printErrorLog (ErrorLogs .UPLOAD_FILE_REQUEST_REJECTED .getLog ());
414414 throw new SkyflowException (e .statusCode (), e , e .headers (), bodyString );
415415 } catch (IOException e ) {
0 commit comments