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();
}
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;
}
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();
}
Aggregations