Java Code Examples for org.wso2.carbon.apimgt.impl.utils.APIUtil#isAdvanceThrottlingEnabled()
The following examples show how to use
org.wso2.carbon.apimgt.impl.utils.APIUtil#isAdvanceThrottlingEnabled() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractAPIManager.java From carbon-apimgt with Apache License 2.0 | 6 votes |
/** * Returns a list of pre-defined # {@link org.wso2.carbon.apimgt.api.model.Tier} in the system. * * @return Set<Tier> */ public Set<Tier> getTiers() throws APIManagementException { Set<Tier> tiers = new TreeSet<Tier>(new TierNameComparator()); Map<String, Tier> tierMap; if (!APIUtil.isAdvanceThrottlingEnabled()) { if (tenantId == MultitenantConstants.INVALID_TENANT_ID) { tierMap = APIUtil.getTiers(); } else { PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenantId, true); tierMap = APIUtil.getTiers(tenantId); endTenantFlow(); } tiers.addAll(tierMap.values()); } else { tierMap = APIUtil.getTiersFromPolicies(PolicyConstants.POLICY_LEVEL_SUB, tenantId); tiers.addAll(tierMap.values()); } return tiers; }
Example 2
Source File: AbstractAPIManager.java From carbon-apimgt with Apache License 2.0 | 6 votes |
/** * Returns a list of pre-defined # {@link org.wso2.carbon.apimgt.api.model.Tier} in the system. * * @return Set<Tier> */ public Set<Tier> getTiers(String tenantDomain) throws APIManagementException { Set<Tier> tiers = new TreeSet<Tier>(new TierNameComparator()); Map<String, Tier> tierMap; if (!APIUtil.isAdvanceThrottlingEnabled()) { startTenantFlow(tenantDomain); int requestedTenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); if (requestedTenantId == MultitenantConstants.SUPER_TENANT_ID || requestedTenantId == MultitenantConstants.INVALID_TENANT_ID) { tierMap = APIUtil.getTiers(); } else { tierMap = APIUtil.getTiers(requestedTenantId); } tiers.addAll(tierMap.values()); endTenantFlow(); } else { tierMap = APIUtil.getTiersFromPolicies(PolicyConstants.POLICY_LEVEL_SUB, tenantId); tiers.addAll(tierMap.values()); } return tiers; }
Example 3
Source File: AbstractAPIManager.java From carbon-apimgt with Apache License 2.0 | 6 votes |
/** * Returns a list of pre-defined # {@link org.wso2.carbon.apimgt.api.model.Tier} in the system. * * @param tierType type of the tiers (api,resource ot application) * @param username current logged user * @return Set<Tier> return list of tier names * @throws APIManagementException APIManagementException if failed to get the predefined tiers */ public Set<Tier> getTiers(int tierType, String username) throws APIManagementException { Set<Tier> tiers = new TreeSet<Tier>(new TierNameComparator()); String tenantDomain = getTenantDomain(username); Map<String, Tier> tierMap; if (!APIUtil.isAdvanceThrottlingEnabled()) { tierMap = APIUtil.getTiers(tierType, tenantDomain); tiers.addAll(tierMap.values()); } else { int tenantIdFromUsername = APIUtil.getTenantId(username); if (tierType == APIConstants.TIER_API_TYPE) { tierMap = APIUtil.getTiersFromPolicies(PolicyConstants.POLICY_LEVEL_SUB, tenantIdFromUsername); } else if (tierType == APIConstants.TIER_RESOURCE_TYPE) { tierMap = APIUtil.getTiersFromPolicies(PolicyConstants.POLICY_LEVEL_API, tenantIdFromUsername); } else if (tierType == APIConstants.TIER_APPLICATION_TYPE) { tierMap = APIUtil.getTiersFromPolicies(PolicyConstants.POLICY_LEVEL_APP, tenantIdFromUsername); } else { throw new APIManagementException("No such a tier type : " + tierType); } tiers.addAll(tierMap.values()); } return tiers; }