Search in sources :

Example 16 with ApplicationThrottlePolicyDTO

use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.ApplicationThrottlePolicyDTO in project carbon-apimgt by wso2.

the class ApplicationThrottlePolicyMappingUtil method fromApplicationThrottlePolicyDTOToModel.

/**
 * Converts a single Application Policy DTO into a model object
 *
 * @param dto Application Policy DTO Object
 * @return Converted Application Policy Model object
 * @throws UnsupportedThrottleLimitTypeException
 */
public static ApplicationPolicy fromApplicationThrottlePolicyDTOToModel(ApplicationThrottlePolicyDTO dto) throws UnsupportedThrottleLimitTypeException {
    // update mandatory fields such as tenantDomain etc.
    dto = CommonThrottleMappingUtil.updateDefaultMandatoryFieldsOfThrottleDTO(dto);
    ApplicationPolicy appPolicy = new ApplicationPolicy(dto.getPolicyName());
    appPolicy = CommonThrottleMappingUtil.updateFieldsFromDTOToPolicy(dto, appPolicy);
    if (dto.getDefaultLimit() != null) {
        appPolicy.setDefaultQuotaPolicy(CommonThrottleMappingUtil.fromDTOToQuotaPolicy(dto.getDefaultLimit()));
    }
    return appPolicy;
}
Also used : ApplicationPolicy(org.wso2.carbon.apimgt.api.model.policy.ApplicationPolicy)

Aggregations

ApplicationPolicy (org.wso2.carbon.apimgt.core.models.policy.ApplicationPolicy)9 ApplicationThrottlePolicyDTO (org.wso2.carbon.apimgt.rest.api.admin.dto.ApplicationThrottlePolicyDTO)6 ApplicationPolicy (org.wso2.carbon.apimgt.api.model.policy.ApplicationPolicy)5 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)3 APIProvider (org.wso2.carbon.apimgt.api.APIProvider)3 APIMgtAdminService (org.wso2.carbon.apimgt.core.api.APIMgtAdminService)3 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)3 Policy (org.wso2.carbon.apimgt.core.models.policy.Policy)3 ErrorDTO (org.wso2.carbon.apimgt.rest.api.common.dto.ErrorDTO)3 ArrayList (java.util.ArrayList)2 Response (javax.ws.rs.core.Response)2 Test (org.junit.Test)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 Test (org.testng.annotations.Test)2 APIMgtAdminServiceImpl (org.wso2.carbon.apimgt.core.impl.APIMgtAdminServiceImpl)2 RequestCountLimit (org.wso2.carbon.apimgt.core.models.policy.RequestCountLimit)2 PoliciesApiServiceImpl (org.wso2.carbon.apimgt.rest.api.admin.impl.PoliciesApiServiceImpl)2 ApplicationThrottlePolicyDTO (org.wso2.carbon.apimgt.rest.api.admin.v1.dto.ApplicationThrottlePolicyDTO)2 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1