diff --git a/components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/model/Environment.java b/components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/model/Environment.java index 9429d8fdff4d..f993de40a81f 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/model/Environment.java +++ b/components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/model/Environment.java @@ -55,6 +55,9 @@ public class Environment implements Serializable { private String gatewayType; private Map additionalProperties = new HashMap<>(); + private String[] visibilityRoles; + private String visibility; + public boolean isDefault() { return isDefault; } @@ -159,6 +162,37 @@ public void setName(String name) { } } + public String getVisibility() { + return visibility; + } + + public void setVisibility(String visibility) { + this.visibility = visibility; + } + + public String[] getVisibilityRoles() { + if (visibilityRoles != null) { + return visibilityRoles; + } else if (visibility != null) { + return visibility.split(","); + } + return null; + } + + public void setVisibility(String[] visibilityRoles) { + if (visibilityRoles != null && !"".equals(visibilityRoles[0].trim())) { + StringBuilder builder = new StringBuilder(); + for (String role : visibilityRoles) { + builder.append(role).append(','); + } + builder.deleteCharAt(builder.length() - 1); + this.visibility = builder.toString(); + } else { + this.visibility = "all"; + } + this.visibilityRoles = visibilityRoles; + } + public String getDisplayName() { return displayName; } diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIConstants.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIConstants.java index 856731b01b82..e5b0289ee0e5 100755 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIConstants.java +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIConstants.java @@ -758,6 +758,7 @@ private Permissions() { public static final String API_GATEWAY = "APIGateway."; public static final String API_GATEWAY_NAME = "Name"; public static final String API_GATEWAY_DISPLAY_NAME = "DisplayName"; + public static final String API_GATEWAY_VISIBILITY = "Visibility"; public static final String API_GATEWAY_SERVER_URL = "ServerURL"; public static final String API_GATEWAY_USERNAME = "Username"; public static final String API_GATEWAY_PASSWORD = "Password"; diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIConsumerImpl.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIConsumerImpl.java index cae01e9c1ad9..362f8a9a1bd1 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIConsumerImpl.java +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIConsumerImpl.java @@ -4035,13 +4035,12 @@ public API getLightweightAPIByUUID(String uuid, String organization) throws APIM devPortalApi.getVisibleRoles()); API api = APIMapper.INSTANCE.toApi(devPortalApi); - /// populate relavant external info - // environment - String environmentString = null; + // populate relevant external info environment + List environments = null; if (api.getEnvironments() != null) { - environmentString = String.join(",", api.getEnvironments()); + environments = APIUtil.getEnvironmentsOfAPI(api); } - api.setEnvironments(APIUtil.extractEnvironmentsForAPI(environmentString, organization)); + api.setEnvironments(APIUtil.extractEnvironmentsForAPI(environments, organization, userNameWithoutChange)); //CORS . if null is returned, set default config from the configuration if (api.getCorsConfiguration() == null) { api.setCorsConfiguration(APIUtil.getDefaultCorsConfiguration()); diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIManagerConfiguration.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIManagerConfiguration.java index f6282dc4edac..0c8c19c59b46 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIManagerConfiguration.java +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIManagerConfiguration.java @@ -759,6 +759,15 @@ void setEnvironmentConfig(OMElement environmentElem) throws APIManagementExcepti gatewayType = APIConstants.API_GATEWAY_TYPE_REGULAR; } environment.setGatewayType(gatewayType); + OMElement visibility = environmentElem.getFirstChildWithName(new QName(APIConstants.API_GATEWAY_VISIBILITY)); + String[] visibilityRoles; + if (visibility == null) { + visibilityRoles = new String[]{"all"}; + } else { + String visibilityString = visibility.getText(); + visibilityRoles = visibilityString.split(","); + } + environment.setVisibility(visibilityRoles); if (StringUtils.isEmpty(environment.getDisplayName())) {environment.setDisplayName(environment.getName());} environment.setServerURL(APIUtil.replaceSystemProperty(environmentElem.getFirstChildWithName(new QName( APIConstants.API_GATEWAY_SERVER_URL)).getText())); 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 66ceeb1f9b8d..3560b06ec839 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 @@ -5600,13 +5600,12 @@ public API getLightweightAPIByUUID(String uuid, String organization) throws APIM if (publisherAPI != null) { API api = APIMapper.INSTANCE.toApi(publisherAPI); checkAccessControlPermission(userNameWithoutChange, api.getAccessControl(), api.getAccessControlRoles()); - /// populate relavant external info - // environment - String environmentString = null; + // populate relevant external info environment + List environments = null; if (api.getEnvironments() != null) { - environmentString = String.join(",", api.getEnvironments()); + environments = APIUtil.getEnvironmentsOfAPI(api); } - api.setEnvironments(APIUtil.extractEnvironmentsForAPI(environmentString, organization)); + api.setEnvironments(APIUtil.extractEnvironmentsForAPI(environments, organization, userNameWithoutChange)); //CORS . if null is returned, set default config from the configuration if (api.getCorsConfiguration() == null) { api.setCorsConfiguration(APIUtil.getDefaultCorsConfiguration()); diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/AbstractAPIManager.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/AbstractAPIManager.java index 29d8c2decc12..deb49ec23847 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/AbstractAPIManager.java +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/AbstractAPIManager.java @@ -1207,11 +1207,11 @@ protected void populateAPIInformation(String uuid, String organization, API api) Organization org = new Organization(organization); api.setOrganization(organization); // environment - String environmentString = null; + List environments = null; if (api.getEnvironments() != null) { - environmentString = String.join(",", api.getEnvironments()); + environments = APIUtil.getEnvironmentsOfAPI(api); } - api.setEnvironments(APIUtil.extractEnvironmentsForAPI(environmentString, organization)); + api.setEnvironments(APIUtil.extractEnvironmentsForAPI(environments, organization, username)); // workflow status APIIdentifier apiId = api.getId(); WorkflowDTO workflow; @@ -1382,11 +1382,11 @@ protected void populateDevPortalAPIInformation(String uuid, String organization, } api.setOrganization(organization); // environment - String environmentString = null; + List environments = null; if (api.getEnvironments() != null) { - environmentString = String.join(",", api.getEnvironments()); + environments = APIUtil.getEnvironmentsOfAPI(api); } - api.setEnvironments(APIUtil.extractEnvironmentsForAPI(environmentString, organization)); + api.setEnvironments(APIUtil.extractEnvironmentsForAPI(environments, organization, username)); // workflow status APIIdentifier apiId = api.getId(); String currentApiUuid = uuid; diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/ApiMgtDAO.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/ApiMgtDAO.java index 8964e338e4b6..0cbbd5e06b6c 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/ApiMgtDAO.java +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/ApiMgtDAO.java @@ -15027,6 +15027,7 @@ public List getAllEnvironments(String tenantDomain) throws APIManag String uuid = rs.getString("UUID"); String name = rs.getString("NAME"); String type = rs.getString("TYPE"); + String visibility = rs.getString("VISIBILITY"); String displayName = rs.getString("DISPLAY_NAME"); String description = rs.getString("DESCRIPTION"); String provider = rs.getString("PROVIDER"); @@ -15037,6 +15038,7 @@ public List getAllEnvironments(String tenantDomain) throws APIManag env.setUuid(uuid); env.setName(name); env.setType(type); + env.setVisibility(visibility); env.setDisplayName(displayName); env.setDescription(description); env.setProvider(provider); @@ -15071,6 +15073,7 @@ public Environment getEnvironment(String tenantDomain, String uuid) throws APIMa Integer id = rs.getInt("ID"); String name = rs.getString("NAME"); String displayName = rs.getString("DISPLAY_NAME"); + String visibility = rs.getString("VISIBILITY"); String description = rs.getString("DESCRIPTION"); String provider = rs.getString("PROVIDER"); @@ -15079,6 +15082,7 @@ public Environment getEnvironment(String tenantDomain, String uuid) throws APIMa env.setUuid(uuid); env.setName(name); env.setDisplayName(displayName); + env.setVisibility(visibility); env.setDescription(description); env.setProvider(provider); env.setVhosts(getVhostGatewayEnvironments(connection, id)); @@ -15111,11 +15115,12 @@ public Environment addEnvironment(String tenantDomain, Environment environment) prepStmt.setString(1, uuid); prepStmt.setString(2, environment.getName()); prepStmt.setString(3, environment.getType()); - prepStmt.setString(4, environment.getDisplayName()); - prepStmt.setString(5, environment.getDescription()); - prepStmt.setString(6, environment.getProvider()); - prepStmt.setString(7, environment.getGatewayType()); - prepStmt.setString(8, tenantDomain); + prepStmt.setString(4, environment.getVisibility()); + prepStmt.setString(5, environment.getDisplayName()); + prepStmt.setString(6, environment.getDescription()); + prepStmt.setString(7, environment.getProvider()); + prepStmt.setString(8, environment.getGatewayType()); + prepStmt.setString(9, tenantDomain); prepStmt.executeUpdate(); ResultSet rs = prepStmt.getGeneratedKeys(); @@ -15273,7 +15278,8 @@ public Environment updateEnvironment(Environment environment) throws APIManageme try (PreparedStatement prepStmt = connection.prepareStatement(SQLConstants.UPDATE_ENVIRONMENT_SQL)) { prepStmt.setString(1, environment.getDisplayName()); prepStmt.setString(2, environment.getDescription()); - prepStmt.setString(3, environment.getUuid()); + prepStmt.setString(3, environment.getVisibility()); + prepStmt.setString(4, environment.getUuid()); prepStmt.executeUpdate(); deleteGatewayVhosts(connection, environment.getId()); addGatewayVhosts(connection, environment.getId(), environment.getVhosts()); 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 bdad6d440205..78de78c8a774 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 @@ -2732,18 +2732,18 @@ public class SQLConstants { /** Environment related constants **/ public static final String GET_ENVIRONMENT_BY_ORGANIZATION_SQL = - "SELECT ID, UUID, NAME, TYPE, ORGANIZATION, DISPLAY_NAME, DESCRIPTION, PROVIDER, GATEWAY_TYPE " + + "SELECT ID, UUID, NAME, TYPE, VISIBILITY, ORGANIZATION, DISPLAY_NAME, DESCRIPTION, PROVIDER, GATEWAY_TYPE " + "FROM AM_GATEWAY_ENVIRONMENT " + "WHERE ORGANIZATION = ?"; public static final String GET_ENVIRONMENT_BY_ORGANIZATION_AND_UUID_SQL = - "SELECT ID, UUID, NAME, ORGANIZATION, DISPLAY_NAME, DESCRIPTION, PROVIDER, GATEWAY_TYPE " + + "SELECT ID, UUID, NAME, VISIBILITY, ORGANIZATION, DISPLAY_NAME, DESCRIPTION, PROVIDER, GATEWAY_TYPE " + "FROM AM_GATEWAY_ENVIRONMENT " + "WHERE ORGANIZATION = ? AND UUID = ?"; public static final String INSERT_ENVIRONMENT_SQL = "INSERT INTO " + - "AM_GATEWAY_ENVIRONMENT (UUID, NAME, TYPE, DISPLAY_NAME, DESCRIPTION, PROVIDER, GATEWAY_TYPE, ORGANIZATION) " + - "VALUES (?,?,?,?,?,?,?,?)"; + "AM_GATEWAY_ENVIRONMENT (UUID, NAME, TYPE, VISIBILITY, DISPLAY_NAME, DESCRIPTION, PROVIDER, GATEWAY_TYPE, ORGANIZATION) " + + "VALUES (?,?,?,?,?,?,?,?,?)"; public static final String INSERT_GATEWAY_VHOSTS_SQL = "INSERT INTO " + "AM_GW_VHOST (GATEWAY_ENV_ID, HOST, HTTP_CONTEXT, HTTP_PORT, HTTPS_PORT, WS_PORT, WSS_PORT) " + @@ -2758,7 +2758,7 @@ public class SQLConstants { public static final String DELETE_ENVIRONMENT_SQL = "DELETE FROM AM_GATEWAY_ENVIRONMENT WHERE UUID = ?"; public static final String UPDATE_ENVIRONMENT_SQL = "UPDATE AM_GATEWAY_ENVIRONMENT " + - "SET DISPLAY_NAME = ?, DESCRIPTION = ? " + + "SET DISPLAY_NAME = ?, DESCRIPTION = ? , VISIBILITY = ?" + "WHERE UUID = ?"; public static final String INSERT_LLM_PROVIDER_SQL = diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/utils/APIUtil.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/utils/APIUtil.java index fde4b5f08aea..185c2345f1de 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/utils/APIUtil.java +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/utils/APIUtil.java @@ -5031,23 +5031,84 @@ public static Set extractEnvironmentsForAPI(String environments) throws return environmentStringSet; } + public static Set extractVisibleEnvironmentsForUser(List environments, String organization, String userName) throws APIManagementException { + + Set environmentStringSet = new HashSet(); + String[] userRoles = APIUtil.getListOfRoles(userName); + if (environments != null) { + for (Environment environment : environments) { + String[] permittedRoles = environment.getVisibilityRoles(); + if (permittedRoles[0].equals("all")) { + environmentStringSet.add(environment.toString()); + } else { + for (String role : userRoles) { + for (String permission : permittedRoles) { + if (role.equals(permission)) { + environmentStringSet.add(environment.toString()); + } + } + } + } + } + } else { + Map environmentsMap = getEnvironments(organization); + for (Environment environment : environmentsMap.values()) { + String[] permittedRoles = environment.getVisibilityRoles(); + if (permittedRoles[0].equals("all")) { + environmentStringSet.add(environment.toString()); + } else { + for (String role : userRoles) { + for (String permission : permittedRoles) { + if (role.equals(permission)) { + environmentStringSet.add(environment.toString()); + } + } + } + } + } + } + return environmentStringSet; + } + + public static Map extractVisibleEnvironmentsForUser(String organization, String userName) throws APIManagementException { + + Map returnEnvironments = new LinkedHashMap<>(); + String[] userRoles = APIUtil.getListOfRoles(userName); + Map environmentsMap = getEnvironments(organization); + for (Environment environment : environmentsMap.values()) { + String[] permittedRoles = environment.getVisibilityRoles(); + if (permittedRoles[0].equals("all")) { + returnEnvironments.put(environment.getName(), environment); + } else { + for (String role : userRoles) { + for (String permission : permittedRoles) { + if (role.equals(permission)) { + returnEnvironments.put(environment.getName(), environment); + } + } + } + } + } + return returnEnvironments; + } + public static Set extractEnvironmentsForAPI(String environments, String organization) throws APIManagementException { Set environmentStringSet = null; if (environments == null) { environmentStringSet = new HashSet<>(getEnvironments(organization).keySet()); } else { - //handle not to publish to any of the gateways + // Handle not to publish to any of the gateways if (APIConstants.API_GATEWAY_NONE.equals(environments)) { environmentStringSet = new HashSet(); } - //handle to set published gateways nto api object + // Handle to set published gateways into api object else if (!"".equals(environments)) { String[] publishEnvironmentArray = environments.split(","); environmentStringSet = new HashSet(Arrays.asList(publishEnvironmentArray)); environmentStringSet.remove(APIConstants.API_GATEWAY_NONE); } - //handle to publish to any of the gateways when api creating stage + // Handle to publish to any of the gateways when api creating stage else if ("".equals(environments)) { environmentStringSet = new HashSet<>(getEnvironments(organization).keySet()); } @@ -5056,6 +5117,30 @@ else if ("".equals(environments)) { return environmentStringSet; } + public static Set extractEnvironmentsForAPI(List environments, String organization, String userName) throws APIManagementException { + + Set environmentStringSet = null; + if (environments == null) { + environmentStringSet = extractVisibleEnvironmentsForUser(environments, organization, userName); + } else { + // Handle not to publish to any of the gateways + if (environments.contains(APIConstants.API_GATEWAY_NONE)) { + environmentStringSet = new HashSet(); + } + // Handle to set published gateways into api object + else if (!environments.isEmpty()) { + environmentStringSet = extractVisibleEnvironmentsForUser(environments, organization, userName); + environmentStringSet.remove(APIConstants.API_GATEWAY_NONE); + } + // Handle to publish to any of the gateways when api creating stage + else if ("".equals(environments)) { + environmentStringSet = extractVisibleEnvironmentsForUser(environments, organization, userName); + } + } + + return environmentStringSet; + } + /** * This method used to set environment values to governance artifact of API . * diff --git a/components/apimgt/org.wso2.carbon.apimgt.internal.service/swagger.json b/components/apimgt/org.wso2.carbon.apimgt.internal.service/swagger.json index d81009e30f7b..6b4a85360d29 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.internal.service/swagger.json +++ b/components/apimgt/org.wso2.carbon.apimgt.internal.service/swagger.json @@ -1337,6 +1337,10 @@ "type" : "string", "description" : "Context of the API." }, + "contextTemplate" : { + "type" : "string", + "description" : "Context template of the API." + }, "policy" : { "type" : "string", "description" : "API level throttling policy." @@ -1525,8 +1529,8 @@ "type" : "string", "example" : "EXCHANGED", "description" : "The type of the tokens to be used (exchanged or without exchanged). Accepted values are EXCHANGED, DIRECT or BOTH.", - "default" : "DIRECT", - "enum" : [ "EXCHANGED", "DIRECT", "BOTH" ] + "enum" : [ "EXCHANGED", "DIRECT", "BOTH" ], + "default" : "DIRECT" } } }, diff --git a/components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/admin/v1/impl/EnvironmentsApiServiceImpl.java b/components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/admin/v1/impl/EnvironmentsApiServiceImpl.java index c80a0aa46785..f305c978a3fa 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/admin/v1/impl/EnvironmentsApiServiceImpl.java +++ b/components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/admin/v1/impl/EnvironmentsApiServiceImpl.java @@ -33,7 +33,7 @@ public class EnvironmentsApiServiceImpl implements EnvironmentsApiService { private static final Log log = LogFactory.getLog(EnvironmentsApiServiceImpl.class); /** - * Delete gateway envirionment + * Delete gateway environment * * @param environmentId environment ID * @param messageContext message context diff --git a/components/apimgt/org.wso2.carbon.apimgt.rest.api.store.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/store/v1/mappings/APIMappingUtil.java b/components/apimgt/org.wso2.carbon.apimgt.rest.api.store.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/store/v1/mappings/APIMappingUtil.java index bdbaf8021131..8c756afdc82a 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.rest.api.store.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/store/v1/mappings/APIMappingUtil.java +++ b/components/apimgt/org.wso2.carbon.apimgt.rest.api.store.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/store/v1/mappings/APIMappingUtil.java @@ -244,6 +244,12 @@ public static APIDTO fromAPItoDTO(API model, String organization) throws APIMana dto.setEnvironmentList(environmentListToReturn); } + if (model.getEnvironments() != null) { + List environmentListToReturn = new ArrayList<>(); + environmentListToReturn.addAll(model.getEnvironments()); + dto.setEnvironmentList(environmentListToReturn); + } + dto.setAuthorizationHeader(model.getAuthorizationHeader()); dto.setApiKeyHeader(model.getApiKeyHeader()); if (model.getApiSecurity() != null) { @@ -506,7 +512,7 @@ private static List setEndpointURLsForAwsAPIs(ApiTypeWrappe public static List fromAPIRevisionListToEndpointsList(APIDTO apidto, String organization) throws APIManagementException { - Map environments = APIUtil.getEnvironments(organization); + Map environments = APIUtil.extractVisibleEnvironmentsForUser(organization, RestApiCommonUtil.getLoggedInUsername()); APIConsumer apiConsumer = RestApiCommonUtil.getLoggedInUserConsumer(); List revisionDeployments = apiConsumer.getAPIRevisionDeploymentListOfAPI(apidto.getId()); diff --git a/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/conf_templates/templates/repository/conf/api-manager.xml.j2 b/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/conf_templates/templates/repository/conf/api-manager.xml.j2 index 86e7b7d51648..ba5f2106f4fc 100644 --- a/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/conf_templates/templates/repository/conf/api-manager.xml.j2 +++ b/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/conf_templates/templates/repository/conf/api-manager.xml.j2 @@ -132,6 +132,10 @@ {{environment_name.name}} {{environment_name.display_name}} {{environment_name.gateway_type}} + + {% if environment_name.visibility is defined %} + {% for role in environment_name.visibility %}{{role}}{{ "," if not loop.last }}{% endfor %} + {% endif %} {{environment_name.description}} {{environment_name.service_url}} diff --git a/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/db2.sql b/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/db2.sql index 18f79845fdb9..22860ef86d35 100644 --- a/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/db2.sql +++ b/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/db2.sql @@ -3009,6 +3009,7 @@ CREATE TABLE AM_GATEWAY_ENVIRONMENT ( UUID VARCHAR(45) NOT NULL, NAME VARCHAR(255) NOT NULL, TYPE VARCHAR(255) NULL, + VISIBILITY VARCHAR (1024) NULL, DISPLAY_NAME VARCHAR(255) NULL, DESCRIPTION VARCHAR(1023) NULL, PROVIDER VARCHAR(255) NOT NULL, diff --git a/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/h2.sql b/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/h2.sql index 8c0ad159e94b..23148e3a0149 100644 --- a/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/h2.sql +++ b/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/h2.sql @@ -2238,6 +2238,7 @@ CREATE TABLE IF NOT EXISTS AM_GATEWAY_ENVIRONMENT ( NAME VARCHAR(255) NOT NULL, DISPLAY_NAME VARCHAR(255) NULL, TYPE VARCHAR(255) NULL, + VISIBILITY VARCHAR (1024) NULL, DESCRIPTION VARCHAR(1023) NULL, PROVIDER VARCHAR(255) NOT NULL, GATEWAY_TYPE VARCHAR(255) NOT NULL, diff --git a/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/mssql.sql b/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/mssql.sql index 2f4e61448898..1be3b54343d2 100644 --- a/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/mssql.sql +++ b/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/mssql.sql @@ -2501,6 +2501,7 @@ CREATE TABLE AM_GATEWAY_ENVIRONMENT ( UUID VARCHAR(45) NOT NULL, NAME VARCHAR(255) NOT NULL, TYPE VARCHAR(255) NULL, + VISIBILITY VARCHAR (1024) NULL, DISPLAY_NAME VARCHAR(255) NULL, DESCRIPTION VARCHAR(1023) NULL, PROVIDER VARCHAR(255) NOT NULL, diff --git a/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/mysql.sql b/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/mysql.sql index f82158dc982d..f75d4dfc0f8f 100644 --- a/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/mysql.sql +++ b/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/mysql.sql @@ -2272,6 +2272,7 @@ CREATE TABLE IF NOT EXISTS AM_GATEWAY_ENVIRONMENT ( UUID VARCHAR(45) NOT NULL, NAME VARCHAR(255) NOT NULL, TYPE VARCHAR(255) NULL, + VISIBILITY VARCHAR (1024) NULL, DISPLAY_NAME VARCHAR(255) NULL, DESCRIPTION VARCHAR(1023) NULL, PROVIDER VARCHAR(255) NOT NULL, diff --git a/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/mysql_cluster.sql b/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/mysql_cluster.sql index 8a243b9ffc46..e634d6cdc8dc 100644 --- a/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/mysql_cluster.sql +++ b/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/mysql_cluster.sql @@ -2424,6 +2424,7 @@ CREATE TABLE IF NOT EXISTS AM_GATEWAY_ENVIRONMENT ( UUID VARCHAR(45) NOT NULL, NAME VARCHAR(255) NOT NULL, TYPE VARCHAR(255) NULL, + VISIBILITY VARCHAR (1024) NULL, DISPLAY_NAME VARCHAR(255) NULL, DESCRIPTION VARCHAR(1023) NULL, PROVIDER VARCHAR(255) NOT NULL, diff --git a/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/oracle.sql b/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/oracle.sql index fc86392ec80e..4355a9842b81 100644 --- a/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/oracle.sql +++ b/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/oracle.sql @@ -3496,6 +3496,7 @@ CREATE TABLE AM_GATEWAY_ENVIRONMENT ( UUID VARCHAR(45) NOT NULL, NAME VARCHAR(255) NOT NULL, TYPE VARCHAR(255) NULL, + VISIBILITY VARCHAR (1024) NULL, DISPLAY_NAME VARCHAR(255) NULL, DESCRIPTION VARCHAR(1023) NULL, PROVIDER VARCHAR(255) NOT NULL, diff --git a/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/oracle_23c.sql b/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/oracle_23c.sql index 59046ee60d45..13b20362d783 100644 --- a/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/oracle_23c.sql +++ b/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/oracle_23c.sql @@ -3496,6 +3496,7 @@ CREATE TABLE AM_GATEWAY_ENVIRONMENT ( UUID VARCHAR(45) NOT NULL, NAME VARCHAR(255) NOT NULL, TYPE VARCHAR(255) NULL, + VISIBILITY VARCHAR (1024) NULL, DISPLAY_NAME VARCHAR(255) NULL, DESCRIPTION VARCHAR(1023) NULL, PROVIDER VARCHAR(255) NOT NULL, diff --git a/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/oracle_rac.sql b/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/oracle_rac.sql index 304e8bcb1ac6..eba0242a4a7d 100644 --- a/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/oracle_rac.sql +++ b/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/oracle_rac.sql @@ -3468,6 +3468,7 @@ CREATE TABLE AM_GATEWAY_ENVIRONMENT ( UUID VARCHAR(45) NOT NULL, NAME VARCHAR(255) NOT NULL, TYPE VARCHAR(255) NULL, + VISIBILITY VARCHAR (1024) NULL, DISPLAY_NAME VARCHAR(255) NULL, DESCRIPTION VARCHAR(1023) NULL, PROVIDER VARCHAR(255) NOT NULL, diff --git a/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/postgresql.sql b/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/postgresql.sql index 8f741c079bf5..bb26be31702e 100644 --- a/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/postgresql.sql +++ b/features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/postgresql.sql @@ -2590,6 +2590,7 @@ CREATE TABLE IF NOT EXISTS AM_GATEWAY_ENVIRONMENT ( UUID VARCHAR(45) NOT NULL, NAME VARCHAR(255) NOT NULL, TYPE VARCHAR(255) NULL, + VISIBILITY VARCHAR (1024) NULL, DISPLAY_NAME VARCHAR(255) NULL, DESCRIPTION VARCHAR(1023) NULL, PROVIDER VARCHAR(255) NOT NULL,