Skip to content
Merged
6 changes: 3 additions & 3 deletions .github/workflows/beta-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ jobs:
uses: ./.github/workflows/shared-build-and-deploy.yml
with:
ref: ${{ github.ref_name }}
server-id: ossrh
server-id: central
profile: maven-central
tag: 'beta'
secrets:
server-username: ${{ secrets.OSSRH_USERNAME }}
server-password: ${{ secrets.OSSRH_PASSWORD }}
server-username: ${{ secrets.CENTRAL_PUBLISHER_PORTAL_USERNAME }}
server-password: ${{ secrets.CENTRAL_PUBLISHER_PORTAL_PASSWORD }}
gpg-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
skyflow-credentials: ${{ secrets.SKYFLOW_CREDENTIALS }} >> .env
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- uses: actions/checkout@v1
- uses: actions/setup-java@v1
with:
java-version: "1.8"
java-version: "11"

- name: create-json
id: create-json
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ jobs:
uses: ./.github/workflows/shared-build-and-deploy.yml
with:
ref: ${{ github.ref_name }}
server-id: ossrh
server-id: central
profile: maven-central
tag: 'public'
secrets:
server-username: ${{ secrets.OSSRH_USERNAME }}
server-password: ${{ secrets.OSSRH_PASSWORD }}
server-username: ${{ secrets.CENTRAL_PUBLISHER_PORTAL_USERNAME }}
server-password: ${{ secrets.CENTRAL_PUBLISHER_PORTAL_PASSWORD }}
gpg-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
skyflow-credentials: ${{ secrets.SKYFLOW_CREDENTIALS }} >> .env
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/shared-build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ jobs:
fetch-depth: 0

- name: Set up maven or jfrog repository
uses: actions/setup-java@v1
uses: actions/setup-java@v4
with:
java-version: "1.8"
java-version: "11"
distribution: "adopt"
server-id: ${{ inputs.server-id }}
server-username: SERVER_USERNAME
Expand Down
46 changes: 21 additions & 25 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.skyflow</groupId>
<artifactId>skyflow-java</artifactId>
<version>2.0.0-beta.2</version>
<version>2.0.0-beta.4</version>
<packaging>jar</packaging>

<name>${project.groupId}:${project.artifactId}</name>
Expand Down Expand Up @@ -45,12 +45,6 @@
</properties>

<dependencies>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.12.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
Expand Down Expand Up @@ -126,9 +120,10 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit-version}</version>
<version>4.13.2</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
Expand All @@ -141,12 +136,6 @@
<version>2.0.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.13.2</version>
<scope>compile</scope>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -185,7 +174,14 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<version>3.2.5</version>
<configuration>
<useModulePath>false</useModulePath>
<includes>
<include>**/*Test.java</include>
<include>**/*Tests.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
Expand Down Expand Up @@ -263,25 +259,25 @@
<id>maven-central</id>
<distributionManagement>
<repository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2</url>
<id>central</id>
<url>https://central.sonatype.com/api/v1/publisher/upload</url>
</repository>
<snapshotRepository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
<id>central-snapshots</id>
<url>https://central.sonatype.com/api/v1/publisher/upload</url>
</snapshotRepository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>0.4.0</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
<publishingServerId>central</publishingServerId>
<tokenAuth>true</tokenAuth>
<autoPublish>true</autoPublish>
</configuration>
</plugin>
</plugins>
Expand Down
36 changes: 24 additions & 12 deletions src/main/java/com/skyflow/VaultClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.skyflow.generated.rest.resources.records.requests.RecordServiceBatchOperationBody;
import com.skyflow.generated.rest.resources.records.requests.RecordServiceInsertRecordBody;
import com.skyflow.generated.rest.resources.records.requests.RecordServiceUpdateRecordBody;
import com.skyflow.generated.rest.resources.records.requests.UploadFileV2Request;
import com.skyflow.generated.rest.resources.strings.StringsClient;
import com.skyflow.generated.rest.resources.strings.requests.DeidentifyStringRequest;
import com.skyflow.generated.rest.resources.strings.requests.ReidentifyStringRequest;
Expand All @@ -32,6 +33,7 @@
import com.skyflow.utils.Utils;
import com.skyflow.utils.logger.LogUtil;
import com.skyflow.utils.validations.Validations;
import com.skyflow.vault.data.FileUploadRequest;
import com.skyflow.vault.data.InsertRequest;
import com.skyflow.vault.data.UpdateRequest;
import com.skyflow.vault.detect.*;
Expand All @@ -44,6 +46,10 @@
import io.github.cdimascio.dotenv.Dotenv;
import io.github.cdimascio.dotenv.DotenvException;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.*;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -209,6 +215,22 @@ protected V1TokenizePayload getTokenizePayload(TokenizeRequest request) {
return payloadBuilder.build();
}

protected File getFileForFileUpload(FileUploadRequest fileUploadRequest) throws IOException {
if (fileUploadRequest.getFilePath() != null) {
return new File(fileUploadRequest.getFilePath());
}
else if (fileUploadRequest.getBase64() != null) {
byte[] decodedBytes = Base64.getDecoder().decode(fileUploadRequest.getBase64());
File file = new File(fileUploadRequest.getFileName());
Files.write(file.toPath(), decodedBytes);
return file;
}
else if (fileUploadRequest.getFileObject() != null) {
return fileUploadRequest.getFileObject();
}
return null;
}

protected void setBearerToken() throws SkyflowException {
prioritiseCredentials();
Validations.validateCredentials(this.finalCredentials);
Expand Down Expand Up @@ -512,7 +534,6 @@ protected DeidentifyPdfRequest getDeidentifyPdfRequest(DeidentifyFileRequest req
Optional<List<EntityType>> entityUniqueCounter = Optional.empty();
Optional<List<String>> allowRegex = Optional.ofNullable(request.getAllowRegexList());
Optional<List<String>> restrictRegex = Optional.ofNullable(request.getRestrictRegexList());
Optional<Transformations> transformations = Optional.ofNullable(getTransformations(request.getTransformations()));

if (tokenFormat != null) {
if (tokenFormat.getEntityOnly() != null && !tokenFormat.getEntityOnly().isEmpty()) {
Expand Down Expand Up @@ -540,13 +561,12 @@ protected DeidentifyPdfRequest getDeidentifyPdfRequest(DeidentifyFileRequest req
return DeidentifyPdfRequest.builder()
.vaultId(vaultId)
.file(file)
.density(request.getPixelDensity() != null ? request.getPixelDensity().intValue() : null)
.maxResolution(request.getMaxResolution() != null ? request.getMaxResolution().intValue() : null)
.density(request.getPixelDensity() != null ? request.getPixelDensity().doubleValue() : null)
.maxResolution(request.getMaxResolution() != null ? request.getMaxResolution().doubleValue() : null)
.entityTypes(mappedEntityTypes)
.tokenType(tokenType)
.allowRegex(allowRegex)
.restrictRegex(restrictRegex)
.transformations(transformations)
.build();
}

Expand All @@ -558,7 +578,6 @@ protected DeidentifyImageRequest getDeidentifyImageRequest(DeidentifyFileRequest
Optional<List<EntityType>> entityUniqueCounter = Optional.empty();
Optional<List<String>> allowRegex = Optional.ofNullable(request.getAllowRegexList());
Optional<List<String>> restrictRegex = Optional.ofNullable(request.getRestrictRegexList());
Optional<Transformations> transformations = Optional.ofNullable(getTransformations(request.getTransformations()));

TokenTypeWithoutVault tokenType = buildTokenType(tokenFormat, entityTypes, entityUniqueCounter);

Expand All @@ -580,7 +599,6 @@ protected DeidentifyImageRequest getDeidentifyImageRequest(DeidentifyFileRequest
.tokenType(tokenType)
.allowRegex(allowRegex)
.restrictRegex(restrictRegex)
.transformations(transformations)
.outputProcessedImage(request.getOutputProcessedImage())
.outputOcrText(request.getOutputOcrText())
.build();
Expand All @@ -594,7 +612,6 @@ protected DeidentifyPresentationRequest getDeidentifyPresentationRequest(Deident
Optional<List<EntityType>> entityUniqueCounter = Optional.empty();
Optional<List<String>> allowRegex = Optional.ofNullable(request.getAllowRegexList());
Optional<List<String>> restrictRegex = Optional.ofNullable(request.getRestrictRegexList());
Optional<Transformations> transformations = Optional.ofNullable(getTransformations(request.getTransformations()));

TokenTypeWithoutVault tokenType = buildTokenType(tokenFormat, entityTypes, entityUniqueCounter);

Expand All @@ -610,7 +627,6 @@ protected DeidentifyPresentationRequest getDeidentifyPresentationRequest(Deident
.tokenType(tokenType)
.allowRegex(allowRegex)
.restrictRegex(restrictRegex)
.transformations(transformations)
.build();
}

Expand All @@ -622,7 +638,6 @@ protected DeidentifySpreadsheetRequest getDeidentifySpreadsheetRequest(Deidentif
Optional<List<EntityType>> entityUniqueCounter = Optional.empty();
Optional<List<String>> allowRegex = Optional.ofNullable(request.getAllowRegexList());
Optional<List<String>> restrictRegex = Optional.ofNullable(request.getRestrictRegexList());
Optional<Transformations> transformations = Optional.ofNullable(getTransformations(request.getTransformations()));

TokenTypeWithoutVault tokenType = buildTokenType(tokenFormat, entityTypes, entityUniqueCounter);

Expand All @@ -638,7 +653,6 @@ protected DeidentifySpreadsheetRequest getDeidentifySpreadsheetRequest(Deidentif
.tokenType(tokenType)
.allowRegex(allowRegex)
.restrictRegex(restrictRegex)
.transformations(transformations)
.build();
}

Expand Down Expand Up @@ -678,7 +692,6 @@ protected DeidentifyDocumentRequest getDeidentifyDocumentRequest(DeidentifyFileR
Optional<List<EntityType>> entityUniqueCounter = Optional.empty();
Optional<List<String>> allowRegex = Optional.ofNullable(request.getAllowRegexList());
Optional<List<String>> restrictRegex = Optional.ofNullable(request.getRestrictRegexList());
Optional<Transformations> transformations = Optional.ofNullable(getTransformations(request.getTransformations()));

TokenTypeWithoutVault tokenType = buildTokenType(tokenFormat, entityTypes, entityUniqueCounter);

Expand All @@ -694,7 +707,6 @@ protected DeidentifyDocumentRequest getDeidentifyDocumentRequest(DeidentifyFileR
.tokenType(tokenType)
.allowRegex(allowRegex)
.restrictRegex(restrictRegex)
.transformations(transformations)
.build();
}

Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/skyflow/enums/DeidentifyFileStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

public enum DeidentifyFileStatus {
IN_PROGRESS("IN_PROGRESS"),
SUCCESS("SUCCESS");
FAILED("FAILED"),
SUCCESS("SUCCESS"),
UNKNOWN("UNKNOWN");

private final String value;

Expand Down
9 changes: 8 additions & 1 deletion src/main/java/com/skyflow/enums/DetectEntities.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@ public enum DetectEntities {
CREDIT_CARD_EXPIRATION("credit_card_expiration"),
CVV("cvv"),
DATE("date"),
DAY("day"),
DATE_INTERVAL("date_interval"),
DOB("dob"),
DOSE("dose"),
DRIVER_LICENSE("driver_license"),
DRUG("drug"),
DURATION("duration"),
EFFECT("effect"),
EMAIL_ADDRESS("email_address"),
EVENT("event"),
FILENAME("filename"),
FINANCIAL_METRIC("financial_metric"),
GENDER_SEXUALITY("gender_sexuality"),
GENDER("gender"),
HEALTHCARE_NUMBER("healthcare_number"),
INJURY("injury"),
IP_ADDRESS("ip_address"),
Expand All @@ -40,30 +42,35 @@ public enum DetectEntities {
MEDICAL_CODE("medical_code"),
MEDICAL_PROCESS("medical_process"),
MONEY("money"),
MONTH("month"),
NAME("name"),
NAME_FAMILY("name_family"),
NAME_GIVEN("name_given"),
NAME_MEDICAL_PROFESSIONAL("name_medical_professional"),
NUMERICAL_PII("numerical_pii"),
OCCUPATION("occupation"),
ORGANIZATION("organization"),
ORGANIZATION_ID("organization_id"),
ORGANIZATION_MEDICAL_FACILITY("organization_medical_facility"),
ORIGIN("origin"),
PASSPORT_NUMBER("passport_number"),
PASSWORD("password"),
PHONE_NUMBER("phone_number"),
PROJECT("project"),
PHYSICAL_ATTRIBUTE("physical_attribute"),
POLITICAL_AFFILIATION("political_affiliation"),
PRODUCT("product"),
RELIGION("religion"),
ROUTING_NUMBER("routing_number"),
SEXUALITY("sexuality"),
SSN("ssn"),
STATISTICS("statistics"),
TIME("time"),
TREND("trend"),
URL("url"),
USERNAME("username"),
VEHICLE_ID("vehicle_id"),
YEAR("year"),
ZODIAC_SIGN("zodiac_sign");

private final String detectEntities;
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/skyflow/errors/ErrorMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ public enum ErrorMessage {
InvalidRequestBody("%s0 Validation error. Invalid request body. Specify the request body as an object."),
EmptyRequestBody("%s0 Validation error. Request body can't be empty. Specify a valid request body."),

// File upload
ColumnNameKeyErrorFileUpload("%s0 Validation error. columnName is missing from the payload. Specify a columnName key."),
MissingFileSourceInUploadFileRequest("%s0 Validation error. Provide exactly one of filePath, base64, or fileObject."),
FileNameMustBeProvidedWithFileObject("%s0 Validation error. fileName must be provided when using fileObject."),
InvalidFileObject("%s0 Validation error. Invalid file object in file upload request. Specify a valid file object."),
InvalidBase64("%s0 Validation error. Invalid base64 string in file upload request. Specify a valid base64 string."),

// detect
InvalidTextInDeIdentify("%s0 Validation error. The text field is required and must be a non-empty string. Specify a valid text."),
InvalidTextInReIdentify("%s0 Validation error. The text field is required and must be a non-empty string. Specify a valid text."),
Expand All @@ -144,6 +151,7 @@ public enum ErrorMessage {
FailedToEncodeFile("%s0 Validation error. Failed to encode the file. Ensure the file is in a supported format and try again."),
FailedToDecodeFileFromResponse("%s0 Failed to decode the file from the response. Ensure the response is valid and try again."),
EmptyFileAndFilePathInDeIdentifyFile("%s0 Validation error. Both file and filePath are empty. Specify either file object or filePath, not both."),
VaultTokenFormatIsNotAllowedForFiles("%s0 Validation error. Vault token format is not allowed for deidentify file request."),
PollingForResultsFailed("%s0 API error. Polling for results failed. Unable to retrieve the deidentified file"),
FailedtoSaveProcessedFile("%s0 Validation error. Failed to save the processed file. Ensure the output directory is valid and writable."),
InvalidAudioFileType("%s0 Validation error. The file type is not supported. Specify a valid file type mp3 or wav."),
Expand Down
Loading
Loading