+ return getPolicyTypeIds() //
+ .flatMap(this::deletePoliciesForType);
+ }
+
+ @Override
+ public Mono<String> getPolicyStatus(Policy policy) {
+ String uri = POLICY_STATUS_URI.buildAndExpand(policy.type().name(), policy.id()).toUriString();
+ return restClient.get(uri);
+
+ }
+
+ private Flux<String> getPolicyTypeIds() {
+ return restClient.get(POLICY_TYPES) //
+ .flatMapMany(this::parseJsonArrayOfString);
+ }
+
+ private Flux<String> getPolicyIdentitiesByType(String typeId) {
+ return restClient.get(POLICY_IDS_URI.buildAndExpand(typeId).toUriString()) //
+ .flatMapMany(this::parseJsonArrayOfString);
+ }
+
+ 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);