Skip to content

Commit

Permalink
tmp2
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-alhuang committed Jun 10, 2024
1 parent f1c1824 commit 12b535b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,7 @@ SnowflakeFileTransferMetadataV1 fetchSignedURL(String fileName)
payload.put("file_name", fileName);
Map<String, Object> response = this.makeConfigureCall(payload);

JsonNode responseNode =
this.parseStageLocation(mapper.valueToTree(response).get("stage_location"));
JsonNode responseNode = this.parseConfigureResponse(response);

SnowflakeFileTransferMetadataV1 metadata =
(SnowflakeFileTransferMetadataV1)
Expand All @@ -264,14 +263,15 @@ SnowflakeFileTransferMetadataV1 fetchSignedURL(String fileName)
return metadata;
}

protected JsonNode parseStageLocation(JsonNode stageLocation) {
ObjectNode responseNode = mapper.createObjectNode();
protected JsonNode parseConfigureResponse(Map<String, Object> response) {
JsonNode responseNode = mapper.valueToTree(response);

// Currently there are a few mismatches between the client/configure response and what
// SnowflakeFileTransferAgent expects
responseNode.putObject("data");
ObjectNode dataNode = (ObjectNode) responseNode.get("data");
dataNode.set("stageInfo", stageLocation);
ObjectNode mutable = (ObjectNode) responseNode;
mutable.putObject("data");
ObjectNode dataNode = (ObjectNode) mutable.get("data");
dataNode.set("stageInfo", responseNode.get("stage_location"));

// JDBC expects this field which maps to presignedFileUrlName. We will set this later
dataNode.putArray("src_locations").add("placeholder");
Expand Down Expand Up @@ -300,8 +300,7 @@ synchronized SnowflakeFileTransferMetadataWithAge refreshCloudStorageMetadata(bo
Map<Object, Object> payload = getConfigurePayload();
Map<String, Object> response = this.makeConfigureCall(payload);

JsonNode responseNode =
this.parseStageLocation(mapper.valueToTree(response).get("stage_location"));
JsonNode responseNode = this.parseConfigureResponse(response);
// Do not change the prefix everytime we have to refresh credentials
if (Utils.isNullOrEmpty(this.clientPrefix)) {
this.clientPrefix = createClientPrefix(responseNode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,10 @@ void put(String filePath, byte[] blob) {
public String getVolumeHash() {
return volumeHash;
}

private JsonNode parseStageLocation(JsonNode stageLocation) {
Map<String, Object> response = new HashMap<>();
response.put("stage_location", stageLocation);
return parseConfigureResponse(response);
}
}

0 comments on commit 12b535b

Please sign in to comment.