diff --git a/src/main/java/com/skyflow/VaultClient.java b/src/main/java/com/skyflow/VaultClient.java index 857b176f..176f9349 100644 --- a/src/main/java/com/skyflow/VaultClient.java +++ b/src/main/java/com/skyflow/VaultClient.java @@ -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) diff --git a/src/main/java/com/skyflow/enums/DeidentifyFileStatus.java b/src/main/java/com/skyflow/enums/DeidentifyFileStatus.java index e17c6d0c..87ffc109 100644 --- a/src/main/java/com/skyflow/enums/DeidentifyFileStatus.java +++ b/src/main/java/com/skyflow/enums/DeidentifyFileStatus.java @@ -2,7 +2,9 @@ public enum DeidentifyFileStatus { IN_PROGRESS("IN_PROGRESS"), - SUCCESS("SUCCESS"); + FAILED("FAILED"), + SUCCESS("SUCCESS"), + UNKNOWN("UNKNOWN"); private final String value; diff --git a/src/main/java/com/skyflow/enums/DetectEntities.java b/src/main/java/com/skyflow/enums/DetectEntities.java index f2c21eff..3fd15a67 100644 --- a/src/main/java/com/skyflow/enums/DetectEntities.java +++ b/src/main/java/com/skyflow/enums/DetectEntities.java @@ -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"), @@ -40,6 +42,7 @@ 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"), @@ -47,16 +50,19 @@ public enum DetectEntities { 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"), @@ -64,6 +70,7 @@ public enum DetectEntities { URL("url"), USERNAME("username"), VEHICLE_ID("vehicle_id"), + YEAR("year"), ZODIAC_SIGN("zodiac_sign"); private final String detectEntities; diff --git a/src/main/java/com/skyflow/utils/validations/Validations.java b/src/main/java/com/skyflow/utils/validations/Validations.java index 7a1839a9..7070f358 100644 --- a/src/main/java/com/skyflow/utils/validations/Validations.java +++ b/src/main/java/com/skyflow/utils/validations/Validations.java @@ -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()); } @@ -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()); } diff --git a/src/main/java/com/skyflow/vault/controller/DetectController.java b/src/main/java/com/skyflow/vault/controller/DetectController.java index 047c441c..4675073b 100644 --- a/src/main/java/com/skyflow/vault/controller/DetectController.java +++ b/src/main/java/com/skyflow/vault/controller/DetectController.java @@ -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; @@ -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; @@ -257,9 +277,8 @@ private static synchronized DeidentifyFileResponse parseDeidentifyFileResponse(D File processedFileObject = null; FileInfo fileInfo = null; - Optional processedFileBase64 = firstOutput != null ? firstOutput.getProcessedFile() : Optional.empty(); - Optional processedFileExtension = firstOutput != null ? firstOutput.getProcessedFileExtension() : Optional.empty(); - + Optional processedFileBase64 = Optional.of(firstOutput).flatMap(DeidentifyFileOutput::getProcessedFile); + Optional processedFileExtension = Optional.of(firstOutput).flatMap(DeidentifyFileOutput::getProcessedFileExtension); if (processedFileBase64.isPresent() && processedFileExtension.isPresent()) { try { byte[] decodedBytes = Base64.getDecoder().decode(processedFileBase64.get()); @@ -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),