Skip to content
Merged
Show file tree
Hide file tree
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 @@ -11,6 +11,7 @@
import solutions.bellatrix.data.http.infrastructure.HTTPMethod;
import solutions.bellatrix.data.http.infrastructure.HttpHeader;
import solutions.bellatrix.data.http.infrastructure.QueryParameter;
import solutions.bellatrix.core.utilities.SecretsResolver;

import java.util.*;
import java.util.function.Consumer;
Expand Down Expand Up @@ -77,9 +78,8 @@ public RequestSpecification requestSpecification() {
specBuilder.setBody(requestBody);
}

if (!queryParameters.isEmpty()) {
specBuilder.addQueryParams(getRequestQueryParameters());
}
// Always add query parameters (including authentication parameters)
specBuilder.addQueryParams(getRequestQueryParameters());

specBuilder.addHeaders(getRequestHeaders());

Expand Down Expand Up @@ -136,7 +136,8 @@ private Map<String, String> getRequestQueryParameters() {
if (insertionOrder.equals("start")) {
for (var key : option.keySet()) {
if (!key.equals("type") && !key.equals("insertionOrder")) {
queryParams.put(key, option.get(key).toString());
String value = SecretsResolver.getSecret(option.get(key).toString());
queryParams.put(key, value);
}
}
for (QueryParameter queryParameter : queryParameters) {
Expand All @@ -148,7 +149,8 @@ private Map<String, String> getRequestQueryParameters() {
}
for (var key : option.keySet()) {
if (!key.equals("type") && !key.equals("insertionOrder")) {
queryParams.put(key, option.get(key).toString());
String value = SecretsResolver.getSecret(option.get(key).toString());
queryParams.put(key, value);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,14 @@ public void delete(THttpEntity entity) {

DELETING_ENTITY.broadcast(new EntityDeletedEventArgs(entity));

sendRequest(requestContext);
// For delete operations, we don't need to parse the response as JSON
// Just send the request and check the status code
Response response = sendRequest(requestContext);

// Check if the delete was successful (200-299 status codes)
if (response.getStatusCode() < 200 || response.getStatusCode() >= 300) {
throw new RuntimeException("Delete operation failed with status code: " + response.getStatusCode());
}

ENTITY_DELETED.broadcast(new EntityDeletedEventArgs(entity));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ public static HttpStatusCode parse(int statusCode) {
}
}

throw new IllegalArgumentException("Not found");
// If the status code is not found in the enum, return a generic status code
// based on the status code range
if (statusCode >= 200 && statusCode < 300) {
return OK; // Return OK for any 2xx success code
} else if (statusCode >= 400 && statusCode < 500) {
return BAD_REQUEST; // Return BAD_REQUEST for any 4xx client error
} else if (statusCode >= 500 && statusCode < 600) {
return INTERNAL_SERVER_ERROR; // Return INTERNAL_SERVER_ERROR for any 5xx server error
} else {
// For other status codes (1xx, 3xx, etc.), return OK as default
return OK;
}
}
}