Skip to content

Commit dd76251

Browse files
author
Dishita Suyal
committed
FINERACT-2591: Log debug when Idempotency-Key header is missing
Signed-off-by: Dishita Suyal <dishitasuyal@gmail.com> A
1 parent 23c67f7 commit dd76251

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

fineract-core/src/main/java/org/apache/fineract/infrastructure/core/filters/IdempotencyStoreFilter.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ public class IdempotencyStoreFilter extends OncePerRequestFilter {
4848
protected void doFilterInternal(@NonNull HttpServletRequest request, @NonNull HttpServletResponse response,
4949
@NonNull FilterChain filterChain) throws ServletException, IOException {
5050
Mutable<ContentCachingResponseWrapper> wrapper = new MutableObject<>();
51+
String headerName = fineractProperties.getIdempotencyKeyHeaderName();
52+
String idempotencyKey = request.getHeader(headerName);
53+
54+
if (headerName != null && !headerName.isBlank() &&
55+
(idempotencyKey == null || idempotencyKey.isBlank())) {
56+
57+
log.debug("Missing {} for request: {} {}",
58+
headerName,
59+
request.getMethod(),
60+
request.getRequestURI());
61+
}
5162
if (helper.isAllowedContentTypeRequest(request)) {
5263
wrapper.setValue(new ContentCachingResponseWrapper(response));
5364
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package org.apache.fineract.portfolio.client.handler;
2+
3+
import org.apache.fineract.commands.annotation.CommandType;
4+
import org.apache.fineract.commands.handler.NewCommandSourceHandler;
5+
import org.apache.fineract.infrastructure.core.api.JsonCommand;
6+
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
7+
import org.apache.fineract.portfolio.client.api.ClientApiConstants;
8+
import org.apache.fineract.portfolio.client.service.ClientChargeWritePlatformService;
9+
import org.springframework.beans.factory.annotation.Autowired;
10+
import org.springframework.stereotype.Service;
11+
import org.springframework.transaction.annotation.Transactional;
12+
13+
@Service
14+
@CommandType(entity = ClientApiConstants.CLIENT_CHARGES_RESOURCE_NAME,
15+
action = ClientApiConstants.CLIENT_CHARGE_ACTION_INACTIVATE)
16+
public class InactivateClientChargeCommandHandler implements NewCommandSourceHandler {
17+
18+
private final ClientChargeWritePlatformService writePlatformService;
19+
20+
@Autowired
21+
public InactivateClientChargeCommandHandler(final ClientChargeWritePlatformService writePlatformService) {
22+
this.writePlatformService = writePlatformService;
23+
}
24+
25+
@Transactional
26+
@Override
27+
public CommandProcessingResult processCommand(final JsonCommand command) {
28+
return this.writePlatformService.inactivateCharge(
29+
command.getClientId(),
30+
command.entityId(),
31+
command
32+
);
33+
}
34+
}

0 commit comments

Comments
 (0)