Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/com/skyflow/VaultClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -539,8 +539,8 @@ protected DeidentifyPdfRequest getDeidentifyPdfRequest(DeidentifyFileRequest req
return DeidentifyPdfRequest.builder()
.vaultId(vaultId)
.file(file)
.density(Double.valueOf(request.getPixelDensity() != null ? request.getPixelDensity().intValue() : null))
.maxResolution(Double.valueOf(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)
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
5 changes: 1 addition & 4 deletions src/main/java/com/skyflow/utils/validations/Validations.java
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ public static void validateDeidentifyFileRequest(DeidentifyFileRequest request)
}

TokenFormat tokenFormat = request.getTokenFormat();
if (tokenFormat != null && !tokenFormat.getVaultToken().isEmpty()) {
if (tokenFormat != null && tokenFormat.getVaultToken() != null && !tokenFormat.getVaultToken().isEmpty()) {
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.VaultTokenFormatIsNotAllowedForFiles.getMessage());
}

Expand Down Expand Up @@ -847,9 +847,6 @@ public static void validateDeidentifyFileRequest(DeidentifyFileRequest request)
));
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidRequestBody.getMessage());
}
if (request.getBleep().getGain() == null) {
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidRequestBody.getMessage());
}
if (request.getBleep().getStartPadding() == null || request.getBleep().getStartPadding() < 0) {
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidRequestBody.getMessage());
}
Expand Down
36 changes: 31 additions & 5 deletions src/main/java/com/skyflow/vault/controller/DetectController.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.skyflow.generated.rest.resources.files.requests.*;
import com.skyflow.generated.rest.resources.strings.requests.DeidentifyStringRequest;
import com.skyflow.generated.rest.resources.strings.requests.ReidentifyStringRequest;
import com.skyflow.generated.rest.types.DeidentifyStatusResponseOutputType;
import com.skyflow.generated.rest.types.*;
import com.skyflow.logs.ErrorLogs;
import com.skyflow.logs.InfoLogs;
Expand Down Expand Up @@ -239,6 +240,25 @@ private static synchronized DeidentifyFileResponse parseDeidentifyFileResponse(D
String runId, String status) throws SkyflowException {
DeidentifyFileOutput firstOutput = getFirstOutput(response);

if (firstOutput == null) {
return new DeidentifyFileResponse(
null,
null,
response.getOutputType().name(),
null,
null,
null,
response.getSize().orElse(null),
response.getDuration().orElse(null),
response.getPages().orElse(null),
response.getSlides().orElse(null),
getEntities(response),
runId,
response.getStatus().name(),
null
);
}

Object wordCharObj = response.getAdditionalProperties().get("word_character_count");
Integer wordCount = null;
Integer charCount = null;
Expand All @@ -257,9 +277,8 @@ private static synchronized DeidentifyFileResponse parseDeidentifyFileResponse(D

File processedFileObject = null;
FileInfo fileInfo = null;
Optional<String> processedFileBase64 = firstOutput != null ? firstOutput.getProcessedFile() : Optional.empty();
Optional<String> processedFileExtension = firstOutput != null ? firstOutput.getProcessedFileExtension() : Optional.empty();

Optional<String> processedFileBase64 = Optional.of(firstOutput).flatMap(DeidentifyFileOutput::getProcessedFile);
Optional<String> processedFileExtension = Optional.of(firstOutput).flatMap(DeidentifyFileOutput::getProcessedFileExtension);
if (processedFileBase64.isPresent() && processedFileExtension.isPresent()) {
try {
byte[] decodedBytes = Base64.getDecoder().decode(processedFileBase64.get());
Expand All @@ -274,11 +293,18 @@ private static synchronized DeidentifyFileResponse parseDeidentifyFileResponse(D
}
}

String processedFileType = firstOutput.getProcessedFileType()
.map(Object::toString)
.orElse(DeidentifyStatusResponseOutputType.UNKNOWN.toString());

String fileExtension = firstOutput.getProcessedFileExtension()
.orElse(DeidentifyStatusResponseOutputType.UNKNOWN.toString());

return new DeidentifyFileResponse(
fileInfo,
firstOutput.getProcessedFile().orElse(null),
firstOutput.getProcessedFileType().get().toString(),
firstOutput.getProcessedFileExtension().get(),
processedFileType,
fileExtension,
wordCount,
charCount,
response.getSize().orElse(null),
Expand Down
Loading