Search in sources :

Example 6 with SubscriptionValidationDAO

use of org.wso2.carbon.apimgt.impl.dao.SubscriptionValidationDAO in project carbon-apimgt by wso2.

the class GlobalPoliciesApiServiceImpl method globalPoliciesGet.

public Response globalPoliciesGet(String xWSO2Tenant, String policyName, MessageContext messageContext) {
    SubscriptionValidationDAO subscriptionValidationDAO = new SubscriptionValidationDAO();
    xWSO2Tenant = SubscriptionValidationDataUtil.validateTenantDomain(xWSO2Tenant, messageContext);
    if (StringUtils.isNotEmpty(xWSO2Tenant)) {
        if (APIConstants.CHAR_ASTERIX.equals(xWSO2Tenant)) {
            return Response.ok().entity(SubscriptionValidationDataUtil.fromGlobalPolicyToGlobalPolicyListDTO(subscriptionValidationDAO.getAllGlobalPolicies())).build();
        } else if (StringUtils.isNotEmpty(policyName)) {
            List<GlobalPolicy> model = new ArrayList<>();
            GlobalPolicy globalPolicy = subscriptionValidationDAO.getGlobalPolicyByNameForTenant(policyName, xWSO2Tenant);
            if (globalPolicy != null) {
                model.add(globalPolicy);
            }
            return Response.ok().entity(SubscriptionValidationDataUtil.fromGlobalPolicyToGlobalPolicyListDTO(model)).build();
        } else {
            return Response.ok().entity(SubscriptionValidationDataUtil.fromGlobalPolicyToGlobalPolicyListDTO(subscriptionValidationDAO.getAllGlobalPolicies(xWSO2Tenant))).build();
        }
    } else {
        if (StringUtils.isNotEmpty(policyName)) {
            return Response.status(Response.Status.BAD_REQUEST.getStatusCode(), "X-WSo2-Tenant header is missing.").build();
        }
    }
    return Response.ok().entity(SubscriptionValidationDataUtil.fromGlobalPolicyToGlobalPolicyListDTO(subscriptionValidationDAO.getAllGlobalPolicies())).build();
}
Also used : GlobalPolicy(org.wso2.carbon.apimgt.api.model.subscription.GlobalPolicy) List(java.util.List) ArrayList(java.util.ArrayList) SubscriptionValidationDAO(org.wso2.carbon.apimgt.impl.dao.SubscriptionValidationDAO)

Example 7 with SubscriptionValidationDAO

use of org.wso2.carbon.apimgt.impl.dao.SubscriptionValidationDAO in project carbon-apimgt by wso2.

the class ApplicationKeyMappingsApiServiceImpl method applicationKeyMappingsGet.

@Override
public Response applicationKeyMappingsGet(String xWSO2Tenant, String consumerKey, String keymanager, MessageContext messageContext) throws APIManagementException {
    SubscriptionValidationDAO subscriptionValidationDAO = new SubscriptionValidationDAO();
    xWSO2Tenant = SubscriptionValidationDataUtil.validateTenantDomain(xWSO2Tenant, messageContext);
    if (StringUtils.isNotEmpty(consumerKey)) {
        ApplicationKeyMapping keyMapping = subscriptionValidationDAO.getApplicationKeyMapping(consumerKey, keymanager, xWSO2Tenant);
        List<ApplicationKeyMapping> applicationKeyMappings = new ArrayList<>();
        if (keyMapping != null) {
            applicationKeyMappings.add(keyMapping);
        }
        return Response.ok().entity(SubscriptionValidationDataUtil.fromApplicationKeyMappingToApplicationKeyMappingListDTO(applicationKeyMappings)).build();
    }
    if (StringUtils.isNotEmpty(xWSO2Tenant)) {
        return Response.ok().entity(SubscriptionValidationDataUtil.fromApplicationKeyMappingToApplicationKeyMappingListDTO(subscriptionValidationDAO.getAllApplicationKeyMappings(xWSO2Tenant))).build();
    }
    return null;
}
Also used : ArrayList(java.util.ArrayList) ApplicationKeyMapping(org.wso2.carbon.apimgt.api.model.subscription.ApplicationKeyMapping) SubscriptionValidationDAO(org.wso2.carbon.apimgt.impl.dao.SubscriptionValidationDAO)

Example 8 with SubscriptionValidationDAO

use of org.wso2.carbon.apimgt.impl.dao.SubscriptionValidationDAO in project carbon-apimgt by wso2.

the class ApplicationsApiServiceImpl method applicationsGet.

@Override
public Response applicationsGet(String xWSO2Tenant, Integer appId, MessageContext messageContext) {
    SubscriptionValidationDAO subscriptionValidationDAO = new SubscriptionValidationDAO();
    if (appId != null && appId > 0) {
        List<Application> application = subscriptionValidationDAO.getApplicationById(appId);
        return Response.ok().entity(SubscriptionValidationDataUtil.fromApplicationToApplicationListDTO(application)).build();
    }
    xWSO2Tenant = SubscriptionValidationDataUtil.validateTenantDomain(xWSO2Tenant, messageContext);
    if (StringUtils.isNotEmpty(xWSO2Tenant)) {
        return Response.ok().entity(SubscriptionValidationDataUtil.fromApplicationToApplicationListDTO(subscriptionValidationDAO.getAllApplications(xWSO2Tenant))).build();
    }
    return Response.ok().entity(SubscriptionValidationDataUtil.fromApplicationToApplicationListDTO(subscriptionValidationDAO.getAllApplications())).build();
}
Also used : Application(org.wso2.carbon.apimgt.api.model.subscription.Application) SubscriptionValidationDAO(org.wso2.carbon.apimgt.impl.dao.SubscriptionValidationDAO)

Aggregations

SubscriptionValidationDAO (org.wso2.carbon.apimgt.impl.dao.SubscriptionValidationDAO)8 ArrayList (java.util.ArrayList)6 List (java.util.List)4 File (java.io.File)1 Response (javax.ws.rs.core.Response)1 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)1 API (org.wso2.carbon.apimgt.api.model.subscription.API)1 APIPolicy (org.wso2.carbon.apimgt.api.model.subscription.APIPolicy)1 Application (org.wso2.carbon.apimgt.api.model.subscription.Application)1 ApplicationKeyMapping (org.wso2.carbon.apimgt.api.model.subscription.ApplicationKeyMapping)1 ApplicationPolicy (org.wso2.carbon.apimgt.api.model.subscription.ApplicationPolicy)1 GlobalPolicy (org.wso2.carbon.apimgt.api.model.subscription.GlobalPolicy)1 Subscription (org.wso2.carbon.apimgt.api.model.subscription.Subscription)1 SubscriptionPolicy (org.wso2.carbon.apimgt.api.model.subscription.SubscriptionPolicy)1 APIListDTO (org.wso2.carbon.apimgt.internal.service.dto.APIListDTO)1