Skip to content

Commit d519682

Browse files
authored
Merge pull request #82 from AutomateThePlanet/data-module-fixes
Data module fixes
2 parents ee60cda + 5e078e7 commit d519682

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

bellatrix.data/src/main/java/solutions/bellatrix/data/http/httpContext/HttpContext.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import solutions.bellatrix.data.http.infrastructure.HTTPMethod;
1212
import solutions.bellatrix.data.http.infrastructure.HttpHeader;
1313
import solutions.bellatrix.data.http.infrastructure.QueryParameter;
14+
import solutions.bellatrix.core.utilities.SecretsResolver;
1415

1516
import java.util.*;
1617
import java.util.function.Consumer;
@@ -77,9 +78,8 @@ public RequestSpecification requestSpecification() {
7778
specBuilder.setBody(requestBody);
7879
}
7980

80-
if (!queryParameters.isEmpty()) {
81-
specBuilder.addQueryParams(getRequestQueryParameters());
82-
}
81+
// Always add query parameters (including authentication parameters)
82+
specBuilder.addQueryParams(getRequestQueryParameters());
8383

8484
specBuilder.addHeaders(getRequestHeaders());
8585

@@ -136,7 +136,8 @@ private Map<String, String> getRequestQueryParameters() {
136136
if (insertionOrder.equals("start")) {
137137
for (var key : option.keySet()) {
138138
if (!key.equals("type") && !key.equals("insertionOrder")) {
139-
queryParams.put(key, option.get(key).toString());
139+
String value = SecretsResolver.getSecret(option.get(key).toString());
140+
queryParams.put(key, value);
140141
}
141142
}
142143
for (QueryParameter queryParameter : queryParameters) {
@@ -148,7 +149,8 @@ private Map<String, String> getRequestQueryParameters() {
148149
}
149150
for (var key : option.keySet()) {
150151
if (!key.equals("type") && !key.equals("insertionOrder")) {
151-
queryParams.put(key, option.get(key).toString());
152+
String value = SecretsResolver.getSecret(option.get(key).toString());
153+
queryParams.put(key, value);
152154
}
153155
}
154156

bellatrix.data/src/main/java/solutions/bellatrix/data/http/infrastructure/HttpRepository.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,14 @@ public void delete(THttpEntity entity) {
9999

100100
DELETING_ENTITY.broadcast(new EntityDeletedEventArgs(entity));
101101

102-
sendRequest(requestContext);
102+
// For delete operations, we don't need to parse the response as JSON
103+
// Just send the request and check the status code
104+
Response response = sendRequest(requestContext);
105+
106+
// Check if the delete was successful (200-299 status codes)
107+
if (response.getStatusCode() < 200 || response.getStatusCode() >= 300) {
108+
throw new RuntimeException("Delete operation failed with status code: " + response.getStatusCode());
109+
}
103110

104111
ENTITY_DELETED.broadcast(new EntityDeletedEventArgs(entity));
105112
}

bellatrix.data/src/main/java/solutions/bellatrix/data/http/infrastructure/internal/HttpStatusCode.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,17 @@ public static HttpStatusCode parse(int statusCode) {
5050
}
5151
}
5252

53-
throw new IllegalArgumentException("Not found");
53+
// If the status code is not found in the enum, return a generic status code
54+
// based on the status code range
55+
if (statusCode >= 200 && statusCode < 300) {
56+
return OK; // Return OK for any 2xx success code
57+
} else if (statusCode >= 400 && statusCode < 500) {
58+
return BAD_REQUEST; // Return BAD_REQUEST for any 4xx client error
59+
} else if (statusCode >= 500 && statusCode < 600) {
60+
return INTERNAL_SERVER_ERROR; // Return INTERNAL_SERVER_ERROR for any 5xx server error
61+
} else {
62+
// For other status codes (1xx, 3xx, etc.), return OK as default
63+
return OK;
64+
}
5465
}
5566
}

0 commit comments

Comments
 (0)