diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIProviderImpl.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIProviderImpl.java index 3028862f1c44..1f0c9c876d72 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIProviderImpl.java +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIProviderImpl.java @@ -4184,6 +4184,14 @@ public Map> addAPIProductWithoutPublishingToGatewa String apiProductUUID = createAPIProduct(product); product.setUuid(apiProductUUID); + //If the context template ends with {version} this means that the version will be at the end of the context. + String contextTemplate = product.getContextTemplate(); + if (contextTemplate.endsWith("/" + APIConstants.VERSION_PLACEHOLDER)) { + //Remove the {version} part from the context template. + contextTemplate = contextTemplate.split(Pattern.quote("/" + APIConstants.VERSION_PLACEHOLDER))[0]; + } + product.setContextTemplate(contextTemplate); + // Add to database apiMgtDAO.addAPIProduct(product, product.getOrganization()); @@ -4200,13 +4208,6 @@ private static void validateAPIProductContextTemplate(APIProduct product) throws "Cannot add API Product : " + product.getId() + " with unsupported context : " + contextTemplate); } - - //If the context template ends with {version} this means that the version will be at the end of the context. - if (contextTemplate.endsWith("/" + APIConstants.VERSION_PLACEHOLDER)) { - //Remove the {version} part from the context template. - contextTemplate = contextTemplate.split(Pattern.quote("/" + APIConstants.VERSION_PLACEHOLDER))[0]; - } - product.setContextTemplate(contextTemplate); } private String calculateVersionTimestamp(String provider, String name, String version, String org) diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/SubscriptionValidationDAO.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/SubscriptionValidationDAO.java index 91e962a9396c..7748326d9921 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/SubscriptionValidationDAO.java +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/SubscriptionValidationDAO.java @@ -448,8 +448,6 @@ public List getAllApis(String organization, boolean isExpand) { return apiList; } - - /* * This method can be used to retrieve all the APIs of a given tesanat in the database * @@ -1224,6 +1222,7 @@ public API getAPIByContextAndVersion(String context, String version, String depl } else { api.setPolicy(null); } + return api; } } } diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/utils/APIProductVersionComparator.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/utils/APIProductVersionComparator.java index e31ec41bf606..ac32fe39932b 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/utils/APIProductVersionComparator.java +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/utils/APIProductVersionComparator.java @@ -1,17 +1,17 @@ /* - * Copyright WSO2 Inc. + * Copyright (c) 2023, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.wso2.carbon.apimgt.impl.utils; diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/utils/LifeCycleUtils.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/utils/LifeCycleUtils.java index 97b066c6cf2c..5a57a201a9e3 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/utils/LifeCycleUtils.java +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/utils/LifeCycleUtils.java @@ -64,7 +64,7 @@ public static void changeLifecycle(String user, APIProvider apiProvider, String targetStatus = LCManagerFactory.getInstance().getLCManager().getStateForTransition(action); // Update lifecycle state in the registry - UpdateLifeCycleState(apiProvider, orgId, apiTypeWrapper, checklist, targetStatus, currentStatus); + updateLifeCycleState(apiProvider, orgId, apiTypeWrapper, checklist, targetStatus, currentStatus); //Sending Notifications to existing subscribers if (APIConstants.PUBLISHED.equals(targetStatus)) { @@ -100,7 +100,7 @@ public static void changeLifecycle(String user, APIProvider apiProvider, String } } - private static void UpdateLifeCycleState(APIProvider apiProvider, String orgId, ApiTypeWrapper apiTypeWrapper, + private static void updateLifeCycleState(APIProvider apiProvider, String orgId, ApiTypeWrapper apiTypeWrapper, Map checklist, String targetStatus, String currentStatus) throws APIManagementException { if (!apiTypeWrapper.isAPIProduct()) { API api = apiTypeWrapper.getApi();