Skip to content

Commit

Permalink
Merge pull request #107 from visenze/feature/null_im_url
Browse files Browse the repository at this point in the history
fix null value handling during insert
  • Loading branch information
thehung111 authored Sep 3, 2024
2 parents 7a91421 + 963a504 commit 7c352f3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>com.visenze</groupId>
<artifactId>visearch-java-sdk</artifactId>
<name>ViSearch Java SDK</name>
<version>1.14.4</version>
<version>1.14.5</version>
<packaging>jar</packaging>
<url>https://github.com/visenze/visearch-sdk-java</url>
<description>ViSearch Java SDK</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,15 @@ public InsertTrans insert(List<Image> imageList, Map<String, String> customParam
JsonNode statusNode = responseNode.get("status");
if (statusNode == null) {
throw new InternalViSearchException(ResponseMessages.INVALID_RESPONSE_FORMAT, response);
// throw new ViSearchException("There was a malformed ViSearch response: " + response, response);
} else {
InsertTrans insertTrans = deserializeObjectResult(response, response, InsertTrans.class);
insertTrans.setHeaders(headers);
return insertTrans;
}
} catch (JsonProcessingException e) {
throw new InternalViSearchException(ResponseMessages.PARSE_RESPONSE_ERROR, e, response);
//throw new ViSearchException("Could not parse the ViSearch response: " + response, e, response);
} catch (IOException e) {
throw new InternalViSearchException(ResponseMessages.PARSE_RESPONSE_ERROR, e, response);
//throw new ViSearchException("Could not parse the ViSearch response: " + response, e, response);
}
} catch (InternalViSearchException e) {
return new InsertTrans(e.getMessage(), e.getCause(), e.getServerRawResponse());
Expand All @@ -67,7 +64,6 @@ public InsertTrans insert(List<Image> imageList, Map<String, String> customParam

@Override
public InsertStatus insertStatus(String transId) {

return insertStatus(transId, Maps.<String, String>newHashMap());
}

Expand Down Expand Up @@ -187,11 +183,16 @@ private static Multimap<String, String> imageListToParams(List<Image> imageList)
Image image = imageList.get(i);
if (image != null) {
params.put("im_name" + "[" + i + "]", image.getImName());
params.put("im_url" + "[" + i + "]", image.getImUrl());
if (image.getImUrl() != null) {
params.put("im_url" + "[" + i + "]", image.getImUrl());
}

Map<String, String> metadata = image.getMetadata();
if (metadata != null) {
for (Map.Entry<String, String> entry : metadata.entrySet()) {
params.put(entry.getKey() + "[" + i + "]", entry.getValue());
if (entry.getValue() != null) {
params.put(entry.getKey() + "[" + i + "]", entry.getValue());
}
}
}
}
Expand Down

0 comments on commit 7c352f3

Please sign in to comment.