diff --git a/components/api-resource-mgt/org.wso2.carbon.identity.api.resource.mgt/src/main/java/org/wso2/carbon/identity/api/resource/mgt/util/APIResourceManagementUtil.java b/components/api-resource-mgt/org.wso2.carbon.identity.api.resource.mgt/src/main/java/org/wso2/carbon/identity/api/resource/mgt/util/APIResourceManagementUtil.java index 9667c9ee76a1..89ac6bfe48f7 100644 --- a/components/api-resource-mgt/org.wso2.carbon.identity.api.resource.mgt/src/main/java/org/wso2/carbon/identity/api/resource/mgt/util/APIResourceManagementUtil.java +++ b/components/api-resource-mgt/org.wso2.carbon.identity.api.resource.mgt/src/main/java/org/wso2/carbon/identity/api/resource/mgt/util/APIResourceManagementUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * Copyright (c) 2023-2024, WSO2 LLC. (http://www.wso2.com). * * WSO2 LLC. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except @@ -19,6 +19,7 @@ package org.wso2.carbon.identity.api.resource.mgt.util; import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.identity.api.resource.mgt.APIResourceManagerImpl; @@ -118,7 +119,8 @@ public static void addSystemAPIs() { .filter(scope1 -> apiResourceFromDB.getScopes().stream() .noneMatch(scope2 -> scope2.getName().equals(scope1.getName()))) .collect(Collectors.toList()); - if (addedScopes.isEmpty()) { + if (addedScopes.isEmpty() && + !StringUtils.equals(apiResourceFromDB.getType(), updatedAPIResource.getType())) { continue; } @@ -131,7 +133,7 @@ public static void addSystemAPIs() { .type(updatedAPIResource.getType()) .tenantId(apiResourceFromDB.getTenantId()) .requiresAuthorization(apiResourceFromDB.isAuthorizationRequired()) - .scopes(updatedAPIResource.getScopes()) + .scopes(apiResourceFromDB.getScopes()) .subscribedApplications(apiResourceFromDB.getSubscribedApplications()) .properties(apiResourceFromDB.getProperties()) .build();