+ private Mono<String> getCreateSchema(String policyTypeResponse, String policyTypeId) {
+ try {
+ JSONObject obj = new JSONObject(policyTypeResponse);
+ JSONObject schemaObj = obj.getJSONObject(CREATE_SCHEMA);
+ schemaObj.put(TITLE, policyTypeId);
+ return Mono.just(schemaObj.toString());
+ } catch (Exception e) {
+ logger.error("Unexcpected response for policy type: {}", policyTypeResponse, e);
+ return Mono.error(e);
+ }
+ }
+
+ private Mono<String> deletePolicyById(String typeId, String policyId) {
+ String uri = POLICY_URI.buildAndExpand(typeId, policyId).toUriString();
+ return restClient.delete(uri);
+ }
+
+ private Flux<String> deletePoliciesForType(String typeId) {
+ return getPolicyIdentitiesByType(typeId) //
+ .flatMap(policyId -> deletePolicyById(typeId, policyId));
+ }
+
+ private Flux<String> parseJsonArrayOfString(String inputString) {
+ try {
+ List<String> arrayList = new ArrayList<>();
+ JSONArray jsonArray = new JSONArray(inputString);
+ for (int i = 0; i < jsonArray.length(); i++) {
+ arrayList.add(jsonArray.getString(i));
+ }
+ logger.debug("A1 client: received list = {}", arrayList);
+ return Flux.fromIterable(arrayList);
+ } catch (JSONException ex) { // invalid json
+ return Flux.error(ex);
+ }
+ }