From 47d9922c3548b3dd3d302693634dc5dda8503f5c Mon Sep 17 00:00:00 2001 From: rusirijayodaillesinghe Date: Fri, 20 Dec 2024 16:23:55 +0530 Subject: [PATCH] Allow creating an API level policy while having a common policy with same name and version and is attached to the API already --- .../wso2/carbon/apimgt/impl/dao/constants/SQLConstants.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/constants/SQLConstants.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/constants/SQLConstants.java index 4e604edd29c1..4fb78dc99788 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/constants/SQLConstants.java +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/constants/SQLConstants.java @@ -4300,6 +4300,8 @@ public static class OperationPolicyConstants { " OP.POLICY_UUID = ? AND OP.ORGANIZATION = ?"; + // CLONED_POLICY_UUID IS NOT NULL was added to the query to allow creating an API level policy while having a common policy with same name and version + // and is attached to the API already public static final String GET_API_SPECIFIC_OPERATION_POLICY_FROM_POLICY_NAME = "SELECT " + " OP.POLICY_UUID, OP.POLICY_NAME, OP.POLICY_VERSION, OP.DISPLAY_NAME, OP.POLICY_DESCRIPTION, OP.APPLICABLE_FLOWS, OP.GATEWAY_TYPES, OP.API_TYPES, " + @@ -4308,7 +4310,7 @@ public static class OperationPolicyConstants { " FROM " + " AM_OPERATION_POLICY OP INNER JOIN AM_API_OPERATION_POLICY AOP ON OP.POLICY_UUID = AOP.POLICY_UUID " + " WHERE " + - " OP.POLICY_NAME = ? AND OP.POLICY_VERSION = ? AND OP.ORGANIZATION = ? AND AOP.API_UUID = ? "; + " OP.POLICY_NAME = ? AND OP.POLICY_VERSION = ? AND OP.ORGANIZATION = ? AND AOP.API_UUID = ? AND AOP.CLONED_POLICY_UUID IS NOT NULL "; public static final String GET_COMMON_OPERATION_POLICY_FROM_POLICY_NAME = "SELECT " +