Search in sources :

Example 11 with TierPermissionDTO

use of org.wso2.carbon.apimgt.impl.dto.TierPermissionDTO in project carbon-apimgt by wso2.

the class ThrottlingApiServiceImpl method setPolicyPermissionsToDTO.

/**
 * Set subscription throttle policy permission info into the DTO
 *
 * @param policyDTO subscription throttle policy DTO
 * @throws APIManagementException error while setting/retrieve the permissions to the DTO
 */
private void setPolicyPermissionsToDTO(SubscriptionThrottlePolicyDTO policyDTO) throws APIManagementException {
    APIProvider apiProvider = RestApiCommonUtil.getLoggedInUserProvider();
    TierPermissionDTO addedPolicyPermission = (TierPermissionDTO) apiProvider.getThrottleTierPermission(policyDTO.getPolicyName());
    if (addedPolicyPermission != null) {
        SubscriptionThrottlePolicyPermissionDTO addedPolicyPermissionDTO = SubscriptionThrottlePolicyMappingUtil.fromSubscriptionThrottlePolicyPermissionToDTO(addedPolicyPermission);
        policyDTO.setPermissions(addedPolicyPermissionDTO);
    }
}
Also used : TierPermissionDTO(org.wso2.carbon.apimgt.impl.dto.TierPermissionDTO) APIProvider(org.wso2.carbon.apimgt.api.APIProvider)

Aggregations

TierPermissionDTO (org.wso2.carbon.apimgt.impl.dto.TierPermissionDTO)11 HashSet (java.util.HashSet)5 Connection (java.sql.Connection)4 PreparedStatement (java.sql.PreparedStatement)4 ResultSet (java.sql.ResultSet)4 SQLException (java.sql.SQLException)4 LinkedHashSet (java.util.LinkedHashSet)4 Test (org.junit.Test)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 UserRegistry (org.wso2.carbon.registry.core.session.UserRegistry)3 ArrayList (java.util.ArrayList)2 UserStoreException (org.wso2.carbon.user.api.UserStoreException)2 Matchers.anyString (org.mockito.Matchers.anyString)1 APIProvider (org.wso2.carbon.apimgt.api.APIProvider)1 TierPermission (org.wso2.carbon.apimgt.api.model.TierPermission)1 SubscriptionPolicy (org.wso2.carbon.apimgt.api.model.policy.SubscriptionPolicy)1