private Mono getClassBySectionCheck(String classId, ProvisioningPojo provisioningPojo) { return rosterServiceClient.getClassBySectionId(classId) .flatMap(cmsClass -> { Optional cmsClassId = Optional.ofNullable(cmsClass) .map(CMSClass::getData) .map(ClassData::getSection) .map(Section::getId); if(cmsClassId.isPresent()) { provisioningPojo.getRoster().setIsExistingRoster(true); // check if the launched user is present in the Roster class // check if provisioningPojo tooluserid is present in class // // add it to the Class Roster // cmsClass.getData().getSection().getData().getSectionProductsAssociationList(); // set this into ProvisioningPojo provisioningPojo.getRoster().setToolSectionId(classId); /** Based on the check we need to updated the Roster **/ return Mono.just(provisioningPojo); } else { return createClassAndMapping(provisioningPojo.getRoster().getExternalClassId(), provisioningPojo); } }); }