Merge pull request #1042 from rishy/Batch-API
extended API-docs and exceptions in Batch API
This commit is contained in:
+30
-4
@@ -2897,7 +2897,7 @@ Content-Type: application/json Request Body:
|
||||
|
||||
</div>
|
||||
|
||||
<a id="batch_api" name="batch_api" class="old-syle-anchor"> </a>
|
||||
<a class="old-syle-anchor"> </a>
|
||||
<div class="method-section">
|
||||
<div class="method-description">
|
||||
<h4>Batch requests in a single transaction</h4>
|
||||
@@ -3001,7 +3001,7 @@ Successful transaction response:
|
||||
|
||||
</div>
|
||||
|
||||
<a id="batch_api" name="batch_api" class="old-syle-anchor"> </a>
|
||||
<a class="old-syle-anchor"> </a>
|
||||
<div class="method-section">
|
||||
<div class="method-description">
|
||||
<h4>Batch API Errors</h4>
|
||||
@@ -3010,9 +3010,35 @@ Successful transaction response:
|
||||
In Batch API without "enclosingTransaction=true", if one of the response is erroneous, then an appropriate status code will be set for that request and the error message will be returned in it's "body", while all other requests will return successful response with a status code of "200".
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a class="old-syle-anchor"> </a>
|
||||
<div class="method-section">
|
||||
<div class="method-description">
|
||||
<h4>Available Command Strategies</h4>
|
||||
|
||||
<p>
|
||||
These are the currently available command strategies within the Mifos Batch API. So, these listed operations can be executed using a Batch Request.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
<div class="method-example">
|
||||
<h6>Batch API - available commands</h6>
|
||||
<ul>
|
||||
<li><a href="#clients_create">Create a new Client</a>
|
||||
<li><a href="#clients_update">Update an existing Client</a>
|
||||
<li><a href="#loans_create">Apply a Loan to a Client</a>
|
||||
<li><a href="#savingsaccounts_create">Apply Savings to a Client</a>
|
||||
<li><a href="#loans_charges_create">Add a new Loan Charge</a>
|
||||
<li><a href="#loans_charges_retrieve">Collect an existing Loan Charge</a>
|
||||
<li><a href="#clients_activate">Activate a Pending Client</a>
|
||||
<li><a href="#loans_approve">Approve a Pending Loan</a>
|
||||
<li><a href="#loans_disburse">Disburse a Loan</a>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a id="errors" name="errors" class="old-syle-anchor"> </a>
|
||||
<div class="method-section">
|
||||
<div class="method-description">
|
||||
|
||||
-3
@@ -406,9 +406,6 @@ public class BatchApiTest {
|
||||
final List<BatchResponse> response = BatchHelper.postBatchRequestsWithoutEnclosingTransaction(this.requestSpec, this.responseSpec,
|
||||
jsonifiedRequest);
|
||||
|
||||
System.out.println(response.get(3));
|
||||
System.out.println(response.get(4));
|
||||
|
||||
Assert.assertEquals("Verify Status Code 200 for Approve Loan", 200L, (long) response.get(3).getStatusCode());
|
||||
Assert.assertEquals("Verify Status Code 200 for Disburse Loan", 200L, (long) response.get(4).getStatusCode());
|
||||
}
|
||||
|
||||
@@ -12,9 +12,12 @@ import org.mifosplatform.infrastructure.core.exception.PlatformInternalServerExc
|
||||
import org.mifosplatform.infrastructure.core.exception.UnsupportedParameterException;
|
||||
import org.mifosplatform.infrastructure.core.exceptionmapper.PlatformApiDataValidationExceptionMapper;
|
||||
import org.mifosplatform.infrastructure.core.exceptionmapper.PlatformDataIntegrityExceptionMapper;
|
||||
import org.mifosplatform.infrastructure.core.exceptionmapper.PlatformDomainRuleExceptionMapper;
|
||||
import org.mifosplatform.infrastructure.core.exceptionmapper.PlatformInternalServerExceptionMapper;
|
||||
import org.mifosplatform.infrastructure.core.exceptionmapper.PlatformResourceNotFoundExceptionMapper;
|
||||
import org.mifosplatform.infrastructure.core.exceptionmapper.UnsupportedParameterExceptionMapper;
|
||||
import org.mifosplatform.portfolio.loanaccount.exception.MultiDisbursementDataRequiredException;
|
||||
import org.mifosplatform.portfolio.loanproduct.exception.LinkedAccountRequiredException;
|
||||
import org.springframework.transaction.TransactionException;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
@@ -81,8 +84,22 @@ public class ErrorHandler extends RuntimeException {
|
||||
|
||||
return new ErrorInfo(403, 3001, errorBody);
|
||||
|
||||
} else if (exception instanceof LinkedAccountRequiredException) {
|
||||
|
||||
final PlatformDomainRuleExceptionMapper mapper = new PlatformDomainRuleExceptionMapper();
|
||||
final String errorBody = jsonHelper.toJson(mapper.toResponse((LinkedAccountRequiredException) exception).getEntity());
|
||||
|
||||
return new ErrorInfo(403, 3002, errorBody);
|
||||
|
||||
} else if (exception instanceof MultiDisbursementDataRequiredException) {
|
||||
|
||||
final PlatformDomainRuleExceptionMapper mapper = new PlatformDomainRuleExceptionMapper();
|
||||
final String errorBody = jsonHelper.toJson(mapper.toResponse((MultiDisbursementDataRequiredException) exception).getEntity());
|
||||
|
||||
return new ErrorInfo(403, 3003, errorBody);
|
||||
|
||||
} else if (exception instanceof TransactionException) {
|
||||
return new ErrorInfo(400, 4001, "Exception " + exception.getCause() + " " + exception.getMessage());
|
||||
return new ErrorInfo(400, 4001, "{\"Exception\": " + exception.getMessage()+"}");
|
||||
|
||||
} else if (exception instanceof PlatformInternalServerException) {
|
||||
|
||||
@@ -92,6 +109,6 @@ public class ErrorHandler extends RuntimeException {
|
||||
return new ErrorInfo(500, 5001, errorBody);
|
||||
}
|
||||
|
||||
return new ErrorInfo(500, 9999, exception.toString() + " " + exception.getStackTrace());
|
||||
return new ErrorInfo(500, 9999, "{\"Exception\": " + exception.toString() + "}");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user