Skip to content

Commit

Permalink
CIRC-2111 Add param logging
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderkurash committed Jun 21, 2024
1 parent a280199 commit 007de1b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,16 @@ public class CirculationSetting {
private final JsonObject value;

public static CirculationSetting from(JsonObject representation) {
if (getProperty(representation, ID_FIELD) == null ||
getProperty(representation, NAME_FIELD) == null ||
getObjectProperty(representation, VALUE_FIELD) == null ||
!containsOnlyKnownFields(representation)) {
final var id = getProperty(representation, ID_FIELD);
final var name = getProperty(representation, NAME_FIELD);
final var value = getObjectProperty(representation, VALUE_FIELD);

log.info("from:: Circulation setting JSON is invalid: {}", representation);
if (id == null || name == null || value == null || !containsOnlyKnownFields(representation)) {
log.warn("from:: Circulation setting JSON is invalid: {}", representation);
return null;
}

return new CirculationSetting(representation, getProperty(representation, ID_FIELD),
getProperty(representation, NAME_FIELD), getObjectProperty(representation, VALUE_FIELD));
return new CirculationSetting(representation, id, name, value);
}

private static boolean containsOnlyKnownFields(JsonObject representation) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ void get(RoutingContext routingContext) {
final var clients = Clients.create(context, client);
final var circulationSettingsRepository = new CirculationSettingsRepository(clients);

log.debug("get:: parameters id: {}", routingContext.request().getParam("id"));

ofAsync(routingContext.request().getParam("id"))
.thenApply(refuseWhenIdIsInvalid())
.thenCompose(r -> r.after(circulationSettingsRepository::getById))
Expand All @@ -88,6 +90,8 @@ void delete(RoutingContext routingContext) {
final var context = new WebContext(routingContext);
final var clients = Clients.create(context, client);

log.debug("get:: parameters id: {}", routingContext.request().getParam("id"));

ofAsync(routingContext.request().getParam("id"))
.thenApply(refuseWhenIdIsInvalid())
.thenCompose(r -> r.after(clients.circulationSettingsStorageClient()::delete))
Expand All @@ -102,6 +106,7 @@ void getMany(RoutingContext routingContext) {
final var circulationSettingsRepository = new CirculationSettingsRepository(clients);

final var query = routingContext.request().query();
log.debug("get:: parameters id: {}", query);

circulationSettingsRepository.findBy(query)
.thenApply(multipleLoanRecordsResult -> multipleLoanRecordsResult.map(multipleRecords ->
Expand Down Expand Up @@ -144,7 +149,7 @@ private static boolean uuidIsValid(String providedId) {
try {
return providedId != null && providedId.equals(UUID.fromString(providedId).toString());
} catch(IllegalArgumentException e) {
log.debug("uuidIsValid:: Invalid UUID");
log.warn("uuidIsValid:: Invalid UUID");
return false;
}
}
Expand Down

0 comments on commit 007de1b

Please sign in to comment.