FINERACT-1921: BatchAPI - status code mismatch

This commit is contained in:
jmarta
2023-10-03 12:37:22 +02:00
committed by Arnold Gálovics
parent 666c097ec8
commit 80bcb27b0a
16 changed files with 93 additions and 83 deletions
@@ -48,27 +48,17 @@ public class CreateDatatableEntryCommandStrategy implements CommandStrategy {
@Override
public BatchResponse execute(BatchRequest request, @SuppressWarnings("unused") UriInfo uriInfo) {
final BatchResponse response = new BatchResponse();
final String responseBody;
response.setRequestId(request.getRequestId());
response.setHeaders(request.getHeaders());
final List<String> pathParameters = Splitter.on('/').splitToList(relativeUrlWithoutVersion(request));
// Pluck out the datatable name & loanId out of the relative path
final String datatableName = pathParameters.get(1);
final Long loanId = Long.parseLong(pathParameters.get(2));
// Calls 'createDatatableEntry' function from
// 'DatatablesApiResource' to create a datatable entry on an existing loan
responseBody = datatablesApiResource.createDatatableEntry(datatableName, loanId, request.getBody());
// Calls 'createDatatableEntry' function from 'DatatablesApiResource' to create a datatable entry on an existing
// loan
final String responseBody = datatablesApiResource.createDatatableEntry(datatableName, loanId, request.getBody());
response.setStatusCode(HttpStatus.SC_OK);
// Sets the body of the response after datatable entry is successfully
// created
response.setBody(responseBody);
return response;
// Create the response after datatable entry is successfully created
return new BatchResponse().setRequestId(request.getRequestId()).setStatusCode(HttpStatus.SC_OK).setBody(responseBody)
.setHeaders(request.getHeaders());
}
}
@@ -1587,13 +1587,13 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
if (!rs.next()) {
throw new DatatableNotFoundException(entityTable, appTableId);
}
final Long officeId = rs.getLong("officeId");
final Long groupId = rs.getLong("groupId");
final Long clientId = rs.getLong("clientId");
final Long savingsId = rs.getLong("savingsId");
final Long loanId = rs.getLong("loanId");
final Long transactionId = rs.getLong("transactionId");
final Long entityId = rs.getLong("entityId");
final Long officeId = (Long) rs.getObject("officeId");
final Long groupId = (Long) rs.getObject("groupId");
final Long clientId = (Long) rs.getObject("clientId");
final Long savingsId = (Long) rs.getObject("savingsId");
final Long loanId = (Long) rs.getObject("loanId");
final Long transactionId = (Long) rs.getObject("transactionId");
final Long entityId = (Long) rs.getObject("entityId");
if (rs.next()) {
throw new DatatableSystemErrorException("System Error: More than one row returned from data scoping query");
@@ -1604,7 +1604,7 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
.withGroupId(groupId) //
.withClientId(clientId) //
.withSavingsId(savingsId) //
.withLoanId(loanId).withTransactionId(String.valueOf(transactionId)).withEntityId(entityId)//
.withLoanId(loanId).withTransactionId(transactionId == null ? null : String.valueOf(transactionId)).withEntityId(entityId)//
.build();
}