- private Flux<String> createPoliciesFlux(String policiesString, String policyTypeId) {
- try {
- List<String> policiesList = new ArrayList<>();
- JSONArray policiesArray = new JSONArray(policiesString);
- for (int i = 0; i < policiesArray.length(); i++) {
- JSONObject policyObject = policiesArray.getJSONObject(i);
- if (policyObject.get("policyTypeId").equals(policyTypeId)) {
- policiesList.add(policyObject.toString());
- }
- }
- logger.debug("A1 client: policies = {}", policiesList);
- return Flux.fromIterable(policiesList);
- } catch (JSONException ex) { // invalid json
- return Flux.error(ex);
- }
- }