Skip to content

Commit

Permalink
AICORE-527: fix dedup delete caller when no xpath is mentioned
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladimir Pasquier authored and Vladimir Pasquier committed Nov 22, 2021
1 parent 5422101 commit 138421d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@
import java.io.Serializable;
import java.util.Map;
import java.util.Objects;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import org.apache.commons.lang3.StringUtils;
import org.nuxeo.ai.sdk.rest.exception.UnsupportedPathException;

Expand Down Expand Up @@ -180,7 +178,11 @@ public String toPath(HttpMethod method, @Nonnull String project, Map<String, Ser
int threshold = (int) parameters.get(THRESHOLD_PARAM);
return API_DEDUP + project + "/recalculateSimilarTuples?threshold=" + threshold;
case DELETE:
return API_DEDUP + project + "/index/" + docId + "?xpath=" + xpath;
String url = API_DEDUP + project + "/index/" + docId;
if (xpath != null) {
url += "?xpath=" + xpath;
}
return url;
default:
throw new UnsupportedPathException("Invalid API call for " + this.name());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ public void iCanDeleteFromIndex() throws IOException {

result = client.api(Dedup.DELETE).call(params, "{}");
assertThat(result).isTrue();

params.remove(XPATH_PARAM);
result = client.api(Dedup.DELETE).call(params, "{}");
assertThat(result).isTrue();
}

private TensorInstances createTensor(String docId) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"request": {
"method": "DELETE",
"url": "/api/v1/ai/dedup/test/index/document_uuid_001"
},
"response": {
"status": 204
}
}

0 comments on commit 138421d

Please sign in to comment.