Skip to content

Nextgen Devportal Configurations #12750

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 47 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
d49dbb3
Next gen devportal configurations - Initial Commit
piyumaldk Jan 8, 2025
7e39c8f
Next gen devportal configurations 2 - Get Org ID from Devportal
piyumaldk Jan 10, 2025
3e56dfa
Next gen devportal configurations 3 - Publishing Part
piyumaldk Jan 10, 2025
7970ff6
Next gen devportal configurations 4 - Org Creation Part
piyumaldk Jan 16, 2025
11d7914
Next gen devportal configurations 5 - APIPublisherForNewPortal Class
piyumaldk Jan 17, 2025
9aaa858
Next gen devportal configurations 6 - Optimize the code
piyumaldk Jan 17, 2025
9c1a8cd
Next gen devportal configurations 7 - Add Truststore
piyumaldk Jan 17, 2025
e2ec6b5
Next gen devportal configurations 8 - Fix Issues
piyumaldk Jan 17, 2025
4e1f8a4
Next gen devportal configurations 9 - API unpublish
piyumaldk Jan 20, 2025
76876fc
Next gen devportal configurations 10 - API delete
piyumaldk Jan 20, 2025
66d81f8
Next gen devportal configurations 11 - API update
piyumaldk Jan 21, 2025
3c70e7d
Next gen devportal configurations 12 - Org ID cache
piyumaldk Jan 21, 2025
605e924
Next gen devportal configurations 13 - Get APIM trustStore and keyStore
piyumaldk Jan 22, 2025
e5a9214
Next gen devportal configurations 14 - Enhance code readability and s…
piyumaldk Jan 22, 2025
ff73ace
Next gen devportal configurations 15 - Change Codebase to meet new re…
piyumaldk Jan 24, 2025
eb420b7
Next gen devportal configurations 16 - Optimize the code
piyumaldk Jan 24, 2025
be3edd4
Next gen devportal configurations 17 - Change code to meet the new ch…
piyumaldk Jan 28, 2025
7a8363d
Next gen devportal configurations 18 - Proper org get
piyumaldk Jan 28, 2025
184fbcc
Next gen devportal configurations 19 - Improve code readability
piyumaldk Jan 29, 2025
bc64ff1
Next gen devportal configurations 20 - Refactor error messages
piyumaldk Jan 29, 2025
bae0595
Next gen devportal configurations 21 - Required changes
piyumaldk Jan 30, 2025
fd9fc40
Next gen devportal configurations 22 - Fix definition related bug
piyumaldk Jan 30, 2025
b103da2
Next gen devportal configurations 23 - Fix endpoint related issues
piyumaldk Jan 31, 2025
4e87533
Next gen devportal configurations 24 - Change getDefinitionForDevPort…
piyumaldk Feb 3, 2025
d549c64
Next gen devportal configurations 25 - Change class Name
piyumaldk Feb 5, 2025
de9cdc9
1st set of required changes
piyumaldk Feb 14, 2025
877f9d6
2nd set of required changes
piyumaldk Feb 14, 2025
3c53605
3ed set of required changes
piyumaldk Feb 14, 2025
62d9a02
Required changes from review
piyumaldk Feb 17, 2025
09129c6
Fix SET NULL unsupported DB issue
piyumaldk Feb 17, 2025
38e8db0
Cache httpClient
piyumaldk Feb 18, 2025
e0bc803
Fix minor issues
piyumaldk Feb 18, 2025
ff5ad03
Remove typeWrapper usecase
piyumaldk Feb 18, 2025
c16d9e4
Throw exceptions from impl
piyumaldk Feb 19, 2025
f0e146f
Ref Id related transactions
piyumaldk Feb 19, 2025
a16b2db
API Reference ID response implementation
piyumaldk Feb 19, 2025
cf64191
Remove get API Id
piyumaldk Feb 19, 2025
1c147b4
Change Impl class structure
piyumaldk Feb 19, 2025
17f3639
Add publish unpublish structure
piyumaldk Feb 19, 2025
ab9f856
Content publish implementation
piyumaldk Feb 19, 2025
7cca5f6
Content publish implementation #2
piyumaldk Feb 20, 2025
ff9017c
Fix org ID related issue
piyumaldk Feb 20, 2025
39c2119
Fix refId related issue
piyumaldk Feb 20, 2025
812a3c9
Change Configuration Method
piyumaldk Feb 21, 2025
03ae527
Fix code commenting
piyumaldk Feb 21, 2025
8133c0a
Fix org not found error
piyumaldk Feb 21, 2025
adc5ff2
Adding Tenant Listener
piyumaldk Feb 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -545,9 +545,10 @@ boolean isScopeExists(String username, String scopeName)
*
* @param organization Organization name.
* @param action Action to perform ("PUBLISH" or "UNPUBLISH").
* @return Published or unpublished input stream.
* @throws APIManagementException If a database error occurs.
*/
void updateOrgThemeStatus(String organization, String action) throws APIManagementException;
InputStream updateOrgThemeStatus(String organization, String action) throws APIManagementException;

/**
* Deletes an organization theme.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2176,10 +2176,10 @@ void importDraftedApiTheme(String organization, InputStream themeContent, String
* @param organization Organization name.
* @param action Action to perform ("PUBLISH" or "UNPUBLISH").
* @param apiId API Identifier.
* @return Published or unpublished input stream.
* @throws APIManagementException If a database error occurs.
*/
void updateApiThemeStatus(String organization, String action, String apiId)
throws APIManagementException;
InputStream updateApiThemeStatus(String organization, String action, String apiId) throws APIManagementException;

/**
* Deletes an API theme.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1689,8 +1689,8 @@ public void importDraftedOrgTheme(String organization, InputStream themeContent)
}

@Override
public void updateOrgThemeStatus(String organization, String action) throws APIManagementException {
apiMgtDAO.updateOrgThemeStatus(organization, action);
public InputStream updateOrgThemeStatus(String organization, String action) throws APIManagementException {
return apiMgtDAO.updateOrgThemeStatus(organization, action);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,10 @@ private Permissions() {
public static final String API_DEVPORTAL_DEFAULT_RESERVED_USERNAME = API_STORE +
"DefaultReservedUsername";
public static final String API_STORE_CREATE_DEFAULT_APPLICATION = API_STORE + "CreateDefaultApplication";
public static final String API_STORE_NEW_PORTAL_ENABLED = API_STORE + "NewPortalEnabled";

public static final String API_STORE_TYPE = API_STORE + "PortalType";
public static final String API_STORE_ACCESS_URL = API_STORE + "PortalAccessURL";

public static final String API_PUBLISHER = "APIPublisher.";
public static final String SHOW_API_PUBLISHER_URL_FROM_STORE = API_PUBLISHER + "DisplayURL";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
import org.wso2.carbon.apimgt.impl.dao.ApiMgtDAO;
import org.wso2.carbon.apimgt.impl.dao.GatewayArtifactsMgtDAO;
import org.wso2.carbon.apimgt.impl.dao.ServiceCatalogDAO;
import org.wso2.carbon.apimgt.impl.dao.constants.DevPortalConstants;
import org.wso2.carbon.apimgt.impl.definitions.OAS3Parser;
import org.wso2.carbon.apimgt.impl.definitions.OASParserUtil;
import org.wso2.carbon.apimgt.impl.deployer.ExternalGatewayDeployer;
Expand Down Expand Up @@ -1057,6 +1058,22 @@ public API updateAPI(API api, API existingAPI) throws APIManagementException {
recommendationThread.start();
}

APIManagerConfiguration apiManagerConfiguration =
ServiceReferenceHolder.getInstance().getAPIManagerConfigurationService().getAPIManagerConfiguration();
String portalType = apiManagerConfiguration.getFirstProperty(APIConstants.API_STORE_TYPE);

if (DevPortalConstants.DEVPORTAL_V2.equals(portalType)) {
if (APIConstants.PUBLISHED.equals(api.getStatus())) {
try {
DevPortalHandler devPortalHandler = DevPortalHandlerV2Impl.getInstance();
String refId = apiMgtDAO.getRefId(api.getUuid(), organization);
devPortalHandler.updateAPIMetadata(organization, api, refId);
} catch (APIManagementException e) {
log.error(e.getMessage());
}
}
}

return api;
}

Expand Down Expand Up @@ -2659,6 +2676,21 @@ public void deleteAPI(String apiUuid, String organization) throws APIManagementE
wso2APIPublisher.deleteFromStore(api.getId(), APIUtil.getExternalAPIStore(store.getName(), tenantId));
}
}

APIManagerConfiguration apiManagerConfiguration =
ServiceReferenceHolder.getInstance().getAPIManagerConfigurationService().getAPIManagerConfiguration();
String portalType = apiManagerConfiguration.getFirstProperty(APIConstants.API_STORE_TYPE);

if (DevPortalConstants.DEVPORTAL_V2.equals(portalType)) {
DevPortalHandler devPortalHandler = DevPortalHandlerV2Impl.getInstance();
try {
String refId = apiMgtDAO.getRefId(api.getUuid(), organization);
devPortalHandler.unpublishAPIMetadata(organization, api, refId);
apiMgtDAO.removeRefId(api.getUuid(), organization);
} catch (APIManagementException e) {
log.error(e.getMessage());
}
}
} catch (APIManagementException e) {
log.error("Error while executing API delete operation on external API stores for API "
+ apiUuid + " on organization " + organization, e);
Expand Down Expand Up @@ -8144,9 +8176,9 @@ public void importDraftedApiTheme(String organization, InputStream themeContent,
}

@Override
public void updateApiThemeStatus(String organization, String action, String apiId)
public InputStream updateApiThemeStatus(String organization, String action, String apiId)
throws APIManagementException {
apiMgtDAO.updateApiThemeStatus(organization, action, apiId);
return apiMgtDAO.updateApiThemeStatus(organization, action, apiId);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*
* Copyright (c) 2025, WSO2 LLC. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 LLC. licenses this file to you 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
*
* 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;

import org.apache.commons.lang3.StringUtils;
import org.wso2.carbon.apimgt.api.model.ApiTypeWrapper;
import org.wso2.carbon.apimgt.api.model.API;
import org.wso2.carbon.apimgt.api.APIManagementException;
import org.wso2.carbon.apimgt.impl.internal.ServiceReferenceHolder;

import java.io.InputStream;

/**
* This interface used to handle different types of developer portals' interactions with APIM.
*/
public interface DevPortalHandler {

/**
* Publishes API metadata to the Developer Portal.
*
* @param organization The organization to which the API belongs.
* @param api The API object containing metadata details.
* @return A reference ID (Devportal side) of API.
* @throws APIManagementException If an error occurs while publishing metadata.
*/
String publishAPIMetadata(String organization, API api) throws APIManagementException;

/**
* Updates API metadata in the Developer Portal.
*
* @param organization The organization to which the API belongs.
* @param api The API object containing updated metadata.
* @param refId The reference ID of the API to be updated.
* @throws APIManagementException If an error occurs while updating metadata.
*/
void updateAPIMetadata(String organization, API api, String refId) throws APIManagementException;

/**
* Un-publishes API metadata from the Developer Portal.
*
* @param organization The organization to which the API belongs.
* @param api The API object whose metadata is to be removed.
* @param refId The reference ID of the API to be unpublished.
* @throws APIManagementException If an error occurs while un-publishing metadata.
*/
void unpublishAPIMetadata(String organization, API api, String refId) throws APIManagementException;

/**
* Publishes API content (e.g., documentation, descriptions) to the Developer Portal.
*
* @param organization The organization to which the API belongs.
* @param refId The reference ID of the API.
* @param content The InputStream containing the content to be published.
* @param apiName The name of the API.
* @throws APIManagementException If an error occurs while publishing content.
*/
void publishAPIContent(String organization, String refId, InputStream content, String apiName) throws APIManagementException;

/**
* Un-publishes API content from the Developer Portal.
*
* @param organization The organization to which the API belongs.
* @param refId The reference ID of the API whose content is to be removed.
* @throws APIManagementException If an error occurs while un-publishing content.
*/
void unpublishAPIContent(String organization, String refId) throws APIManagementException;

/**
* Publishes organization theme to the Developer Portal.
*
* @param organization The organization for which content is being published.
* @param content The InputStream containing the content to be published.
* @throws APIManagementException If an error occurs while publishing organization content.
*/
void publishOrgContent(String organization, InputStream content) throws APIManagementException;

/**
* Un-publishes organization-level content from the Developer Portal.
*
* @param organization The organization whose content is to be removed.
* @throws APIManagementException If an error occurs while un-publishing organization content.
*/
void unpublishOrgContent(String organization) throws APIManagementException;
}
Loading
Loading