Search in sources :

Example 1 with ClaimMetadataMgtListener

use of org.wso2.carbon.identity.claim.metadata.mgt.listener.ClaimMetadataMgtListener in project carbon-identity-framework by wso2.

the class ClaimMetadataManagementServiceImpl method removeLocalClaim.

@Override
public void removeLocalClaim(String localClaimURI, String tenantDomain) throws ClaimMetadataException {
    if (StringUtils.isBlank(localClaimURI)) {
        throw new ClaimMetadataClientException(ERROR_CODE_EMPTY_LOCAL_CLAIM_URI);
    }
    // TODO : validate claim URI already exists?
    // TODO : validate tenant domain?
    int tenantId = IdentityTenantUtil.getTenantId(tenantDomain);
    boolean isMappedLocalClaim = this.externalClaimDAO.isMappedLocalClaim(localClaimURI, tenantId);
    if (isMappedLocalClaim) {
        throw new ClaimMetadataClientException(ERROR_CODE_LOCAL_CLAIM_HAS_MAPPED_EXTERNAL_CLAIM.getCode(), String.format(ERROR_CODE_LOCAL_CLAIM_HAS_MAPPED_EXTERNAL_CLAIM.getMessage(), localClaimURI));
    }
    ClaimMetadataEventPublisherProxy.getInstance().publishPreDeleteLocalClaim(tenantId, localClaimURI);
    Collection<ClaimMetadataMgtListener> listeners = IdentityClaimManagementServiceComponent.getClaimMetadataMgtListeners();
    for (ClaimMetadataMgtListener listener : listeners) {
        if (listener.isEnable() && !listener.doPreDeleteClaim(localClaimURI, tenantDomain)) {
            return;
        }
    }
    this.localClaimDAO.removeLocalClaim(localClaimURI, tenantId);
    ClaimMetadataEventPublisherProxy.getInstance().publishPostDeleteLocalClaim(tenantId, localClaimURI);
    for (ClaimMetadataMgtListener listener : listeners) {
        if (listener.isEnable() && !listener.doPostDeleteClaim(localClaimURI, tenantDomain)) {
            return;
        }
    }
}
Also used : ClaimMetadataClientException(org.wso2.carbon.identity.claim.metadata.mgt.exception.ClaimMetadataClientException) ClaimMetadataMgtListener(org.wso2.carbon.identity.claim.metadata.mgt.listener.ClaimMetadataMgtListener)

Aggregations

ClaimMetadataClientException (org.wso2.carbon.identity.claim.metadata.mgt.exception.ClaimMetadataClientException)1 ClaimMetadataMgtListener (org.wso2.carbon.identity.claim.metadata.mgt.listener.ClaimMetadataMgtListener)1