Fix issue of deleting claim dialect
@@ -132,11 +132,31 @@ public class ClaimMetadataManagementServiceImpl implements ClaimMetadataManageme
// Add listener
this.claimDialectDAO.removeClaimDialect(claimDialect, tenantId);
+ postRemoveClaimDialect(claimDialect.getClaimDialectURI(), tenantId);
// Add listener
}
+ /**
+ * Remove mapped external claims at post removing claim dialect.
+ *
+ * @param externalClaimDialectURI External claim dialect uri
+ * @param tenantId Tenant Id
+ * @throws ClaimMetadataException If an error occurred while removing external claims.
+ */
+ private void postRemoveClaimDialect(String externalClaimDialectURI, int tenantId)
+ throws ClaimMetadataException {
+
+ String tenantDomain = IdentityTenantUtil.getTenantDomain(tenantId);
+ ClaimMetadataManagementServiceImpl claimMetadataService = new ClaimMetadataManagementServiceImpl();
+ List<ExternalClaim> externalClaims = claimMetadataService.
+ getExternalClaims(externalClaimDialectURI, tenantDomain);
+ for (ExternalClaim externalClaim : externalClaims) {
+ externalClaimDAO.removeExternalClaim(externalClaimDialectURI, externalClaim.getClaimURI(), tenantId);
+ }
+ }
+
@Override
public List<LocalClaim> getLocalClaims(String tenantDomain) throws ClaimMetadataException {
