Java Code Examples for org.wso2.carbon.apimgt.api.APIProvider#getPolicies()
The following examples show how to use
org.wso2.carbon.apimgt.api.APIProvider#getPolicies() .
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: ThrottlingApiServiceImpl.java From carbon-apimgt with Apache License 2.0 | 6 votes |
/** * Retrieves all Advanced level policies * * @param accept Accept header value * @param ifNoneMatch If-None-Match header value * @param ifModifiedSince If-Modified-Since header value * @return All matched Advanced Throttle policies to the given request */ @Override public Response throttlingPoliciesAdvancedGet(String accept, String ifNoneMatch, String ifModifiedSince, MessageContext messageContext) { try { APIProvider apiProvider = RestApiUtil.getLoggedInUserProvider(); String userName = RestApiUtil.getLoggedInUsername(); APIPolicy[] apiPolicies = (APIPolicy[]) apiProvider.getPolicies(userName, PolicyConstants.POLICY_LEVEL_API); AdvancedThrottlePolicyListDTO listDTO = AdvancedThrottlePolicyMappingUtil.fromAPIPolicyArrayToListDTO(apiPolicies); return Response.ok().entity(listDTO).build(); } catch (APIManagementException e) { String errorMessage = "Error while retrieving Advanced level policies"; RestApiUtil.handleInternalServerError(errorMessage, e, log); } return null; }
Example 2
Source File: ThrottlingApiServiceImpl.java From carbon-apimgt with Apache License 2.0 | 6 votes |
/** * Retrieves all Application Throttle Policies * * @param accept Accept header value * @param ifNoneMatch If-None-Match header value * @param ifModifiedSince If-Modified-Since header value * @return Retrieves all Application Throttle Policies */ @Override public Response throttlingPoliciesApplicationGet(String accept, String ifNoneMatch, String ifModifiedSince, MessageContext messageContext) { try { APIProvider apiProvider = RestApiUtil.getLoggedInUserProvider(); String userName = RestApiUtil.getLoggedInUsername(); ApplicationPolicy[] appPolicies = (ApplicationPolicy[]) apiProvider.getPolicies(userName, PolicyConstants.POLICY_LEVEL_APP); ApplicationThrottlePolicyListDTO listDTO = ApplicationThrottlePolicyMappingUtil.fromApplicationPolicyArrayToListDTO(appPolicies); return Response.ok().entity(listDTO).build(); } catch (APIManagementException e) { String errorMessage = "Error while retrieving Application level policies"; RestApiUtil.handleInternalServerError(errorMessage, e, log); } return null; }
Example 3
Source File: ThrottlingApiServiceImpl.java From carbon-apimgt with Apache License 2.0 | 6 votes |
/** * Retrieves all Subscription level policies * * @param accept Accept header value * @param ifNoneMatch If-None-Match header value * @param ifModifiedSince If-Modified-Since header value * @return All matched Subscription Throttle policies to the given request */ @Override public Response throttlingPoliciesSubscriptionGet(String accept, String ifNoneMatch, String ifModifiedSince, MessageContext messageContext) { try { APIProvider apiProvider = RestApiUtil.getLoggedInUserProvider(); String userName = RestApiUtil.getLoggedInUsername(); SubscriptionPolicy[] subscriptionPolicies = (SubscriptionPolicy[]) apiProvider.getPolicies(userName, PolicyConstants.POLICY_LEVEL_SUB); SubscriptionThrottlePolicyListDTO listDTO = SubscriptionThrottlePolicyMappingUtil.fromSubscriptionPolicyArrayToListDTO(subscriptionPolicies); return Response.ok().entity(listDTO).build(); } catch (APIManagementException | ParseException e) { String errorMessage = "Error while retrieving Subscription level policies"; RestApiUtil.handleInternalServerError(errorMessage, e, log); } return null; }
Example 4
Source File: ThrottlingApiServiceImpl.java From carbon-apimgt with Apache License 2.0 | 6 votes |
/** * Retrieves all Global level policies * * @param accept Accept header value * @param ifNoneMatch If-None-Match header value * @param ifModifiedSince If-Modified-Since header value * @return All matched Global Throttle policies to the given request */ @Override public Response throttlingPoliciesCustomGet(String accept, String ifNoneMatch, String ifModifiedSince, MessageContext messageContext) { try { APIProvider apiProvider = RestApiUtil.getLoggedInUserProvider(); String userName = RestApiUtil.getLoggedInUsername(); //only super tenant is allowed to access global policies/custom rules checkTenantDomainForCustomRules(); GlobalPolicy[] globalPolicies = (GlobalPolicy[]) apiProvider.getPolicies(userName, PolicyConstants.POLICY_LEVEL_GLOBAL); CustomRuleListDTO listDTO = GlobalThrottlePolicyMappingUtil.fromGlobalPolicyArrayToListDTO(globalPolicies); return Response.ok().entity(listDTO).build(); } catch (APIManagementException e) { String errorMessage = "Error while retrieving Global level policies"; RestApiUtil.handleInternalServerError(errorMessage, e, log); } return null; }
Example 5
Source File: ThrottlingApiServiceImpl.java From carbon-apimgt with Apache License 2.0 | 6 votes |
/** * Retrieves all Advanced level policies * * @param accept Accept header value * @param ifNoneMatch If-None-Match header value * @param ifModifiedSince If-Modified-Since header value * @return All matched Advanced Throttle policies to the given request */ @Override public Response throttlingPoliciesAdvancedGet(String accept, String ifNoneMatch, String ifModifiedSince) { try { APIProvider apiProvider = RestApiUtil.getLoggedInUserProvider(); String userName = RestApiUtil.getLoggedInUsername(); APIPolicy[] apiPolicies = (APIPolicy[]) apiProvider.getPolicies(userName, PolicyConstants.POLICY_LEVEL_API); AdvancedThrottlePolicyListDTO listDTO = AdvancedThrottlePolicyMappingUtil .fromAPIPolicyArrayToListDTO(apiPolicies); return Response.ok().entity(listDTO).build(); } catch (APIManagementException e) { String errorMessage = "Error while retrieving Advanced level policies"; RestApiUtil.handleInternalServerError(errorMessage, e, log); } return null; }
Example 6
Source File: ThrottlingApiServiceImpl.java From carbon-apimgt with Apache License 2.0 | 6 votes |
/** * Retrieves all Application Throttle Policies * * @param accept Accept header value * @param ifNoneMatch If-None-Match header value * @param ifModifiedSince If-Modified-Since header value * @return Retrieves all Application Throttle Policies */ @Override public Response throttlingPoliciesApplicationGet(String accept, String ifNoneMatch, String ifModifiedSince) { try { APIProvider apiProvider = RestApiUtil.getLoggedInUserProvider(); String userName = RestApiUtil.getLoggedInUsername(); ApplicationPolicy[] appPolicies = (ApplicationPolicy[]) apiProvider .getPolicies(userName, PolicyConstants.POLICY_LEVEL_APP); ApplicationThrottlePolicyListDTO listDTO = ApplicationThrottlePolicyMappingUtil .fromApplicationPolicyArrayToListDTO(appPolicies); return Response.ok().entity(listDTO).build(); } catch (APIManagementException e) { String errorMessage = "Error while retrieving Application level policies"; RestApiUtil.handleInternalServerError(errorMessage, e, log); } return null; }
Example 7
Source File: ThrottlingApiServiceImpl.java From carbon-apimgt with Apache License 2.0 | 6 votes |
/** * Retrieves all Subscription level policies * * @param accept Accept header value * @param ifNoneMatch If-None-Match header value * @param ifModifiedSince If-Modified-Since header value * @return All matched Subscription Throttle policies to the given request */ @Override public Response throttlingPoliciesSubscriptionGet(String accept, String ifNoneMatch, String ifModifiedSince) { try { APIProvider apiProvider = RestApiUtil.getLoggedInUserProvider(); String userName = RestApiUtil.getLoggedInUsername(); SubscriptionPolicy[] subscriptionPolicies = (SubscriptionPolicy[]) apiProvider .getPolicies(userName, PolicyConstants.POLICY_LEVEL_SUB); SubscriptionThrottlePolicyListDTO listDTO = SubscriptionThrottlePolicyMappingUtil .fromSubscriptionPolicyArrayToListDTO(subscriptionPolicies); return Response.ok().entity(listDTO).build(); } catch (APIManagementException | ParseException e) { String errorMessage = "Error while retrieving Subscription level policies"; RestApiUtil.handleInternalServerError(errorMessage, e, log); } return null; }
Example 8
Source File: ThrottlingApiServiceImpl.java From carbon-apimgt with Apache License 2.0 | 6 votes |
/** * Retrieves all Global level policies * * @param accept Accept header value * @param ifNoneMatch If-None-Match header value * @param ifModifiedSince If-Modified-Since header value * @return All matched Global Throttle policies to the given request */ @Override public Response throttlingPoliciesCustomGet(String accept, String ifNoneMatch, String ifModifiedSince) { try { APIProvider apiProvider = RestApiUtil.getLoggedInUserProvider(); String userName = RestApiUtil.getLoggedInUsername(); //only super tenant is allowed to access global policies/custom rules checkTenantDomainForCustomRules(); GlobalPolicy[] globalPolicies = (GlobalPolicy[]) apiProvider .getPolicies(userName, PolicyConstants.POLICY_LEVEL_GLOBAL); CustomRuleListDTO listDTO = GlobalThrottlePolicyMappingUtil.fromGlobalPolicyArrayToListDTO(globalPolicies); return Response.ok().entity(listDTO).build(); } catch (APIManagementException e) { String errorMessage = "Error while retrieving Global level policies"; RestApiUtil.handleInternalServerError(errorMessage, e, log); } return null; }