diff --git a/checkstyle.xml b/checkstyle.xml
new file mode 100644
index 00000000..d7ff94b0
--- /dev/null
+++ b/checkstyle.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 62acbe8c..7c7121b5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -190,6 +190,28 @@
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+ 3.3.1
+
+ checkstyle.xml
+
+ false
+ true
+
+ **/generated/**
+
+
+
+ validate
+ validate
+
+ check
+
+
+
+
org.jacoco
jacoco-maven-plugin
diff --git a/src/main/java/com/skyflow/serviceaccount/util/BearerToken.java b/src/main/java/com/skyflow/serviceaccount/util/BearerToken.java
index eff0bb17..21000f0f 100644
--- a/src/main/java/com/skyflow/serviceaccount/util/BearerToken.java
+++ b/src/main/java/com/skyflow/serviceaccount/util/BearerToken.java
@@ -27,8 +27,8 @@
import java.util.Objects;
public class BearerToken {
- private static final Gson gson = new GsonBuilder().serializeNulls().create();
- private static final ApiClientBuilder apiClientBuilder = new ApiClientBuilder();
+ private static final Gson GSON = new GsonBuilder().serializeNulls().create();
+ private static final ApiClientBuilder API_CLIENT_BUILDER = new ApiClientBuilder();
private final File credentialsFile;
private final String credentialsString;
private final String ctx;
@@ -122,8 +122,8 @@ private static V1GetAuthTokenResponse getBearerTokenFromCredentials(
);
String basePath = Utils.getBaseURL(tokenURI.getAsString());
- apiClientBuilder.url(basePath);
- ApiClient apiClient = apiClientBuilder.token("token").build();
+ API_CLIENT_BUILDER.url(basePath);
+ ApiClient apiClient = API_CLIENT_BUILDER.token("token").build();
AuthenticationClient authenticationApi = apiClient.authentication();
V1GetAuthTokenRequest._FinalStage authTokenBuilder = V1GetAuthTokenRequest.builder().grantType(Constants.GRANT_TYPE).assertion(signedUserJWT);
@@ -137,7 +137,7 @@ private static V1GetAuthTokenResponse getBearerTokenFromCredentials(
LogUtil.printErrorLog(ErrorLogs.INVALID_TOKEN_URI.getLog());
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidTokenUri.getMessage());
} catch (ApiClientApiException e) {
- String bodyString = gson.toJson(e.body());
+ String bodyString = GSON.toJson(e.body());
LogUtil.printErrorLog(ErrorLogs.BEARER_TOKEN_REJECTED.getLog());
throw new SkyflowException(e.statusCode(), e, e.headers(), bodyString);
}
diff --git a/src/main/java/com/skyflow/serviceaccount/util/SignedDataTokenResponse.java b/src/main/java/com/skyflow/serviceaccount/util/SignedDataTokenResponse.java
index 7c9f4674..3d35b541 100644
--- a/src/main/java/com/skyflow/serviceaccount/util/SignedDataTokenResponse.java
+++ b/src/main/java/com/skyflow/serviceaccount/util/SignedDataTokenResponse.java
@@ -4,13 +4,13 @@
import com.skyflow.utils.Constants;
public class SignedDataTokenResponse {
- private static final String prefix = Constants.SIGNED_DATA_TOKEN_PREFIX;
+ private static final String PREFIX = Constants.SIGNED_DATA_TOKEN_PREFIX;
private final String token;
private final String signedToken;
public SignedDataTokenResponse(String token, String signedToken) {
this.token = token;
- this.signedToken = new StringBuilder(prefix).append(signedToken).toString();
+ this.signedToken = new StringBuilder(PREFIX).append(signedToken).toString();
}
public String getToken() {
diff --git a/src/main/java/com/skyflow/utils/Utils.java b/src/main/java/com/skyflow/utils/Utils.java
index cc8d572a..165c6a80 100644
--- a/src/main/java/com/skyflow/utils/Utils.java
+++ b/src/main/java/com/skyflow/utils/Utils.java
@@ -68,7 +68,9 @@ public static String generateBearerToken(Credentials credentials) throws Skyflow
}
public static PrivateKey getPrivateKeyFromPem(String pemKey) throws SkyflowException {
+ @SuppressWarnings("checkstyle:LocalVariableName")
String PKCS8PrivateHeader = Constants.PKCS8_PRIVATE_HEADER;
+ @SuppressWarnings("checkstyle:LocalVariableName")
String PKCS8PrivateFooter = Constants.PKCS8_PRIVATE_FOOTER;
String privateKeyContent = pemKey;
diff --git a/src/main/java/com/skyflow/utils/logger/LogUtil.java b/src/main/java/com/skyflow/utils/logger/LogUtil.java
index 78cfa038..85655506 100644
--- a/src/main/java/com/skyflow/utils/logger/LogUtil.java
+++ b/src/main/java/com/skyflow/utils/logger/LogUtil.java
@@ -9,10 +9,10 @@
public final class LogUtil {
private static final Logger LOGGER = Logger.getLogger(LogUtil.class.getName());
private static final String SDK_LOG_PREFIX = "[" + Constants.SDK_PREFIX + "] ";
- private static boolean IS_LOGGER_SETUP_DONE = false;
+ private static boolean isLoggerSetupDone = false;
synchronized public static void setupLogger(LogLevel logLevel) {
- IS_LOGGER_SETUP_DONE = true;
+ isLoggerSetupDone = true;
LogManager.getLogManager().reset();
LOGGER.setUseParentHandlers(false);
Formatter formatter = new SimpleFormatter() {
@@ -38,7 +38,7 @@ public synchronized String format(LogRecord logRecord) {
}
public static void printErrorLog(String message) {
- if (IS_LOGGER_SETUP_DONE)
+ if (isLoggerSetupDone)
LOGGER.severe(SDK_LOG_PREFIX + message);
else {
setupLogger(LogLevel.ERROR);
@@ -47,17 +47,17 @@ public static void printErrorLog(String message) {
}
public static void printDebugLog(String message) {
- if (IS_LOGGER_SETUP_DONE)
+ if (isLoggerSetupDone)
LOGGER.config(SDK_LOG_PREFIX + message);
}
public static void printWarningLog(String message) {
- if (IS_LOGGER_SETUP_DONE)
+ if (isLoggerSetupDone)
LOGGER.warning(SDK_LOG_PREFIX + message);
}
public static void printInfoLog(String message) {
- if (IS_LOGGER_SETUP_DONE)
+ if (isLoggerSetupDone)
LOGGER.info(SDK_LOG_PREFIX + message);
}
diff --git a/src/main/java/com/skyflow/vault/controller/DetectController.java b/src/main/java/com/skyflow/vault/controller/DetectController.java
index d95bbd6e..5801d688 100644
--- a/src/main/java/com/skyflow/vault/controller/DetectController.java
+++ b/src/main/java/com/skyflow/vault/controller/DetectController.java
@@ -35,7 +35,7 @@ public final class DetectController extends VaultClient {
src.map(context::serialize).orElse(null))
.serializeNulls()
.create();
- private static final JsonObject skyMetadata = Utils.getMetrics();
+ private static final JsonObject SKY_METADATA = Utils.getMetrics();
public DetectController(VaultConfig vaultConfig, Credentials credentials) {
super(vaultConfig, credentials);
@@ -56,7 +56,7 @@ public DeidentifyTextResponse deidentifyText(DeidentifyTextRequest deidentifyTex
DeidentifyStringRequest request = getDeidentifyStringRequest(deidentifyTextRequest, vaultId);
// get SDK metrics and call the API to de-identify the string
- RequestOptions requestOptions = RequestOptions.builder().addHeader(Constants.SDK_METRICS_HEADER_KEY, skyMetadata.toString()).build();
+ RequestOptions requestOptions = RequestOptions.builder().addHeader(Constants.SDK_METRICS_HEADER_KEY, SKY_METADATA.toString()).build();
deidentifyStringResponse = super.getDetectTextApi().deidentifyString(request, requestOptions);
// Parse the response to DeIdentifyTextResponse
@@ -84,7 +84,7 @@ public ReidentifyTextResponse reidentifyText(ReidentifyTextRequest reidentifyTex
ReidentifyStringRequest request = getReidentifyStringRequest(reidentifyTextRequest, vaultId);
// Get SDK metrics and call the API to re-identify the string
- RequestOptions requestOptions = RequestOptions.builder().addHeader(Constants.SDK_METRICS_HEADER_KEY, skyMetadata.toString()).build();
+ RequestOptions requestOptions = RequestOptions.builder().addHeader(Constants.SDK_METRICS_HEADER_KEY, SKY_METADATA.toString()).build();
IdentifyResponse reidentifyStringResponse = super.getDetectTextApi().reidentifyString(request, requestOptions);
// Parse the response to ReidentifyTextResponse
@@ -205,7 +205,7 @@ private DeidentifyFileResponse pollForResults(String runId, Integer maxWaitTime)
.vaultId(super.getVaultConfig().getVaultId())
.build();
- RequestOptions requestOptions = RequestOptions.builder().addHeader(Constants.SDK_METRICS_HEADER_KEY, skyMetadata.toString()).build();
+ RequestOptions requestOptions = RequestOptions.builder().addHeader(Constants.SDK_METRICS_HEADER_KEY, SKY_METADATA.toString()).build();
response = super.getDetectFileAPi()
.getRun(runId, getRunRequest, requestOptions);
diff --git a/src/main/java/com/skyflow/vault/controller/VaultController.java b/src/main/java/com/skyflow/vault/controller/VaultController.java
index 5ea637ae..3a237470 100644
--- a/src/main/java/com/skyflow/vault/controller/VaultController.java
+++ b/src/main/java/com/skyflow/vault/controller/VaultController.java
@@ -31,8 +31,8 @@
import java.util.*;
public final class VaultController extends VaultClient {
- private static final Gson gson = new GsonBuilder().serializeNulls().create();
- private static final JsonObject skyMetadata = Utils.getMetrics();
+ private static final Gson GSON = new GsonBuilder().serializeNulls().create();
+ private static final JsonObject SKY_METADATA = Utils.getMetrics();
public VaultController(VaultConfig vaultConfig, Credentials credentials) {
super(vaultConfig, credentials);
@@ -40,7 +40,7 @@ public VaultController(VaultConfig vaultConfig, Credentials credentials) {
private static synchronized HashMap getFormattedBatchInsertRecord(Object record, Integer requestIndex) {
HashMap insertRecord = new HashMap<>();
- String jsonString = gson.toJson(record);
+ String jsonString = GSON.toJson(record);
JsonObject bodyObject = JsonParser.parseString(jsonString).getAsJsonObject().get("Body").getAsJsonObject();
JsonArray records = bodyObject.getAsJsonArray("records");
JsonPrimitive error = bodyObject.getAsJsonPrimitive("error");
@@ -122,7 +122,7 @@ public InsertResponse insert(InsertRequest insertRequest) throws SkyflowExceptio
setBearerToken();
if (continueOnError) {
RecordServiceBatchOperationBody insertBody = super.getBatchInsertRequestBody(insertRequest);
- RequestOptions requestOptions = RequestOptions.builder().addHeader(Constants.SDK_METRICS_HEADER_KEY, skyMetadata.toString()).build();
+ RequestOptions requestOptions = RequestOptions.builder().addHeader(Constants.SDK_METRICS_HEADER_KEY, SKY_METADATA.toString()).build();
batchInsertResult = super.getRecordsApi().withRawResponse().recordServiceBatchOperation(super.getVaultConfig().getVaultId(), insertBody, requestOptions);
LogUtil.printInfoLog(InfoLogs.INSERT_REQUEST_RESOLVED.getLog());
Optional>> records = batchInsertResult.body().getResponses();
@@ -157,7 +157,7 @@ public InsertResponse insert(InsertRequest insertRequest) throws SkyflowExceptio
}
}
} catch (ApiClientApiException e) {
- String bodyString = gson.toJson(e.body());
+ String bodyString = GSON.toJson(e.body());
LogUtil.printErrorLog(ErrorLogs.INSERT_RECORDS_REJECTED.getLog());
throw new SkyflowException(e.statusCode(), e, e.headers(), bodyString);
}
@@ -181,7 +181,7 @@ public DetokenizeResponse detokenize(DetokenizeRequest detokenizeRequest) throws
Validations.validateDetokenizeRequest(detokenizeRequest);
setBearerToken();
V1DetokenizePayload payload = super.getDetokenizePayload(detokenizeRequest);
- RequestOptions requestOptions = RequestOptions.builder().addHeader(Constants.SDK_METRICS_HEADER_KEY, skyMetadata.toString()).build();
+ RequestOptions requestOptions = RequestOptions.builder().addHeader(Constants.SDK_METRICS_HEADER_KEY, SKY_METADATA.toString()).build();
result = super.getTokensApi().withRawResponse().recordServiceDetokenize(super.getVaultConfig().getVaultId(), payload, requestOptions);
LogUtil.printInfoLog(InfoLogs.DETOKENIZE_REQUEST_RESOLVED.getLog());
Map> responseHeaders = result.headers();
@@ -202,7 +202,7 @@ public DetokenizeResponse detokenize(DetokenizeRequest detokenizeRequest) throws
}
}
} catch (ApiClientApiException e) {
- String bodyString = gson.toJson(e.body());
+ String bodyString = GSON.toJson(e.body());
LogUtil.printErrorLog(ErrorLogs.DETOKENIZE_REQUEST_REJECTED.getLog());
throw new SkyflowException(e.statusCode(), e, e.headers(), bodyString);
}
@@ -244,7 +244,7 @@ public GetResponse get(GetRequest getRequest) throws SkyflowException {
.orderBy(RecordServiceBulkGetRecordRequestOrderBy.valueOf(getRequest.getOrderBy()))
.build();
- RequestOptions requestOptions = RequestOptions.builder().addHeader(Constants.SDK_METRICS_HEADER_KEY, skyMetadata.toString()).build();
+ RequestOptions requestOptions = RequestOptions.builder().addHeader(Constants.SDK_METRICS_HEADER_KEY, SKY_METADATA.toString()).build();
result = super.getRecordsApi().recordServiceBulkGetRecord(
super.getVaultConfig().getVaultId(),
getRequest.getTable(),
@@ -259,7 +259,7 @@ public GetResponse get(GetRequest getRequest) throws SkyflowException {
}
}
} catch (ApiClientApiException e) {
- String bodyString = gson.toJson(e.body());
+ String bodyString = GSON.toJson(e.body());
LogUtil.printErrorLog(ErrorLogs.GET_REQUEST_REJECTED.getLog());
throw new SkyflowException(e.statusCode(), e, e.headers(), bodyString);
}
@@ -277,7 +277,7 @@ public UpdateResponse update(UpdateRequest updateRequest) throws SkyflowExceptio
Validations.validateUpdateRequest(updateRequest);
setBearerToken();
RecordServiceUpdateRecordBody updateBody = super.getUpdateRequestBody(updateRequest);
- RequestOptions requestOptions = RequestOptions.builder().addHeader(Constants.SDK_METRICS_HEADER_KEY, skyMetadata.toString()).build();
+ RequestOptions requestOptions = RequestOptions.builder().addHeader(Constants.SDK_METRICS_HEADER_KEY, SKY_METADATA.toString()).build();
result = super.getRecordsApi().recordServiceUpdateRecord(
super.getVaultConfig().getVaultId(),
updateRequest.getTable(),
@@ -289,7 +289,7 @@ public UpdateResponse update(UpdateRequest updateRequest) throws SkyflowExceptio
skyflowId = String.valueOf(result.getSkyflowId());
tokensMap = getFormattedUpdateRecord(result);
} catch (ApiClientApiException e) {
- String bodyString = gson.toJson(e.body());
+ String bodyString = GSON.toJson(e.body());
LogUtil.printErrorLog(ErrorLogs.UPDATE_REQUEST_REJECTED.getLog());
throw new SkyflowException(e.statusCode(), e, e.headers(), bodyString);
}
@@ -307,12 +307,12 @@ public DeleteResponse delete(DeleteRequest deleteRequest) throws SkyflowExceptio
RecordServiceBulkDeleteRecordBody deleteBody = RecordServiceBulkDeleteRecordBody.builder().skyflowIds(deleteRequest.getIds())
.build();
- RequestOptions requestOptions = RequestOptions.builder().addHeader(Constants.SDK_METRICS_HEADER_KEY, skyMetadata.toString()).build();
+ RequestOptions requestOptions = RequestOptions.builder().addHeader(Constants.SDK_METRICS_HEADER_KEY, SKY_METADATA.toString()).build();
result = super.getRecordsApi().recordServiceBulkDeleteRecord(
super.getVaultConfig().getVaultId(), deleteRequest.getTable(), deleteBody, requestOptions);
LogUtil.printInfoLog(InfoLogs.DELETE_REQUEST_RESOLVED.getLog());
} catch (ApiClientApiException e) {
- String bodyString = gson.toJson(e.body());
+ String bodyString = GSON.toJson(e.body());
LogUtil.printErrorLog(ErrorLogs.DELETE_REQUEST_REJECTED.getLog());
throw new SkyflowException(e.statusCode(), e, e.headers(), bodyString);
}
@@ -328,7 +328,7 @@ public QueryResponse query(QueryRequest queryRequest) throws SkyflowException {
LogUtil.printInfoLog(InfoLogs.VALIDATING_QUERY_REQUEST.getLog());
Validations.validateQueryRequest(queryRequest);
setBearerToken();
- RequestOptions requestOptions = RequestOptions.builder().addHeader(Constants.SDK_METRICS_HEADER_KEY, skyMetadata.toString()).build();
+ RequestOptions requestOptions = RequestOptions.builder().addHeader(Constants.SDK_METRICS_HEADER_KEY, SKY_METADATA.toString()).build();
result = super.getQueryApi().queryServiceExecuteQuery(
super.getVaultConfig().getVaultId(),
QueryServiceExecuteQueryBody.builder().query(queryRequest.getQuery()).build(),
@@ -342,7 +342,7 @@ public QueryResponse query(QueryRequest queryRequest) throws SkyflowException {
}
}
} catch (ApiClientApiException e) {
- String bodyString = gson.toJson(e.body());
+ String bodyString = GSON.toJson(e.body());
LogUtil.printErrorLog(ErrorLogs.QUERY_REQUEST_REJECTED.getLog());
throw new SkyflowException(e.statusCode(), e, e.headers(), bodyString);
}
@@ -359,7 +359,7 @@ public TokenizeResponse tokenize(TokenizeRequest tokenizeRequest) throws Skyflow
Validations.validateTokenizeRequest(tokenizeRequest);
setBearerToken();
V1TokenizePayload payload = super.getTokenizePayload(tokenizeRequest);
- RequestOptions requestOptions = RequestOptions.builder().addHeader(Constants.SDK_METRICS_HEADER_KEY, skyMetadata.toString()).build();
+ RequestOptions requestOptions = RequestOptions.builder().addHeader(Constants.SDK_METRICS_HEADER_KEY, SKY_METADATA.toString()).build();
result = super.getTokensApi().recordServiceTokenize(super.getVaultConfig().getVaultId(), payload, requestOptions);
LogUtil.printInfoLog(InfoLogs.TOKENIZE_REQUEST_RESOLVED.getLog());
if (result != null && result.getRecords().isPresent() && !result.getRecords().get().isEmpty()) {
@@ -370,7 +370,7 @@ public TokenizeResponse tokenize(TokenizeRequest tokenizeRequest) throws Skyflow
}
}
} catch (ApiClientApiException e) {
- String bodyString = gson.toJson(e.body());
+ String bodyString = GSON.toJson(e.body());
LogUtil.printErrorLog(ErrorLogs.TOKENIZE_REQUEST_REJECTED.getLog());
throw new SkyflowException(e.statusCode(), e, e.headers(), bodyString);
}
@@ -395,7 +395,7 @@ public FileUploadResponse uploadFile(FileUploadRequest fileUploadRequest) throws
.returnFileMetadata(false)
.build();
- RequestOptions requestOptions = RequestOptions.builder().addHeader(Constants.SDK_METRICS_HEADER_KEY, skyMetadata.toString()).build();
+ RequestOptions requestOptions = RequestOptions.builder().addHeader(Constants.SDK_METRICS_HEADER_KEY, SKY_METADATA.toString()).build();
UploadFileV2Response uploadFileV2Response = super.getRecordsApi().uploadFileV2(
super.getVaultConfig().getVaultId(),
file,
@@ -409,7 +409,7 @@ public FileUploadResponse uploadFile(FileUploadRequest fileUploadRequest) throws
);
} catch (ApiClientApiException e) {
- String bodyString = gson.toJson(e.body());
+ String bodyString = GSON.toJson(e.body());
LogUtil.printErrorLog(ErrorLogs.UPLOAD_FILE_REQUEST_REJECTED.getLog());
throw new SkyflowException(e.statusCode(), e, e.headers(), bodyString);
} catch (IOException e) {