Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
public List<String> listDeks(Map<String, String> requestProperties,
String kekName, boolean lookupDeleted)
throws IOException, RestClientException {
UriBuilder builder = UriBuilder.fromPath("/dek-registry/v1/keks/{name}/deks")

Check failure on line 134 in dek-registry-client/src/main/java/io/confluent/dekregistry/client/rest/DekRegistryRestService.java

View check run for this annotation

SonarQube-Confluent / schema-registry Sonarqube Results

dek-registry-client/src/main/java/io/confluent/dekregistry/client/rest/DekRegistryRestService.java#L134

Define a constant instead of duplicating this literal "/dek-registry/v1/keks/{name}/deks" 3 times.
.queryParam("deleted", lookupDeleted);
String path = builder.build(kekName).toString();

Expand Down Expand Up @@ -264,14 +264,30 @@
String kekName,
CreateDekRequest request)
throws IOException, RestClientException {
UriBuilder builder = UriBuilder.fromPath("/dek-registry/v1/keks/{name}/deks/{subject}");
String path = builder.build(kekName, request.getSubject()).toString();

return httpRequest(
path, "POST",
request.toJson().getBytes(StandardCharsets.UTF_8),
requestProperties,
DEK_TYPE);
try {
UriBuilder builder = UriBuilder.fromPath("/dek-registry/v1/keks/{name}/deks/{subject}");
String path = builder.build(kekName, request.getSubject()).toString();

return httpRequest(
path, "POST",
request.toJson().getBytes(StandardCharsets.UTF_8),
requestProperties,
DEK_TYPE);
} catch (RestClientException e) {
if (e.getErrorCode() == 405) {
// Try fallback to older API that does not have subject in the path
UriBuilder builder = UriBuilder.fromPath("/dek-registry/v1/keks/{name}/deks");
String path = builder.build(kekName).toString();

return httpRequest(
path, "POST",
request.toJson().getBytes(StandardCharsets.UTF_8),
requestProperties,
DEK_TYPE);
} else {
throw e;
}
}
}

public Kek updateKek(String name, UpdateKekRequest request)
Expand Down
Loading