use of org.wso2.carbon.apimgt.impl.dao.SubscriptionValidationDAO in project carbon-apimgt by wso2.
the class SubscriptionsApiServiceImpl method subscriptionsGet.
@Override
public Response subscriptionsGet(String xWSO2Tenant, Integer apiId, Integer appId, String apiUUID, String applicationUUID, MessageContext messageContext) throws APIManagementException {
Response result;
SubscriptionValidationDAO subscriptionValidationDAO = new SubscriptionValidationDAO();
List<Subscription> subscriptionList = new ArrayList<>();
xWSO2Tenant = SubscriptionValidationDataUtil.validateTenantDomain(xWSO2Tenant, messageContext);
if (StringUtils.isNotEmpty(applicationUUID) && StringUtils.isNotEmpty(apiUUID)) {
Subscription subscription = subscriptionValidationDAO.getSubscription(apiUUID, applicationUUID);
if (subscription != null) {
subscriptionList.add(subscription);
}
result = Response.ok().entity(SubscriptionValidationDataUtil.fromSubscriptionToSubscriptionListDTO(subscriptionList)).build();
} else if (apiId != null && appId != null) {
Subscription subscription = subscriptionValidationDAO.getSubscription(apiId, appId);
if (subscription != null) {
subscriptionList.add(subscription);
}
result = Response.ok().entity(SubscriptionValidationDataUtil.fromSubscriptionToSubscriptionListDTO(subscriptionList)).build();
} else if (StringUtils.isNotEmpty(xWSO2Tenant)) {
result = Response.ok().entity(SubscriptionValidationDataUtil.fromSubscriptionToSubscriptionListDTO(subscriptionValidationDAO.getAllSubscriptions(xWSO2Tenant))).build();
} else {
result = Response.ok().entity(SubscriptionValidationDataUtil.fromSubscriptionToSubscriptionListDTO(subscriptionValidationDAO.getAllSubscriptions())).build();
}
return result;
}
use of org.wso2.carbon.apimgt.impl.dao.SubscriptionValidationDAO in project carbon-apimgt by wso2.
the class ApplicationPoliciesApiServiceImpl method applicationPoliciesGet.
@Override
public Response applicationPoliciesGet(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.fromApplicationPolicyToApplicationPolicyListDTO(subscriptionValidationDAO.getAllApplicationPolicies())).build();
} else if (StringUtils.isNotEmpty(policyName)) {
List<ApplicationPolicy> model = new ArrayList<>();
ApplicationPolicy applicationPolicy = subscriptionValidationDAO.getApplicationPolicyByNameForTenant(policyName, xWSO2Tenant);
if (applicationPolicy != null) {
model.add(applicationPolicy);
}
return Response.ok().entity(SubscriptionValidationDataUtil.fromApplicationPolicyToApplicationPolicyListDTO(model)).build();
} else {
return Response.ok().entity(SubscriptionValidationDataUtil.fromApplicationPolicyToApplicationPolicyListDTO(subscriptionValidationDAO.getAllApplicationPolicies(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.fromApplicationPolicyToApplicationPolicyListDTO(subscriptionValidationDAO.getAllApplicationPolicies())).build();
}
use of org.wso2.carbon.apimgt.impl.dao.SubscriptionValidationDAO in project carbon-apimgt by wso2.
the class SubscriptionPoliciesApiServiceImpl method subscriptionPoliciesGet.
@Override
public Response subscriptionPoliciesGet(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.fromSubscriptionPolicyToSubscriptionPolicyListDTO(subscriptionValidationDAO.getAllSubscriptionPolicies())).build();
} else if (StringUtils.isNotEmpty(policyName)) {
List<SubscriptionPolicy> model = new ArrayList<>();
SubscriptionPolicy subscriptionPolicy = subscriptionValidationDAO.getSubscriptionPolicyByNameForTenant(policyName, xWSO2Tenant);
if (subscriptionPolicy != null) {
model.add(subscriptionPolicy);
}
return Response.ok().entity(SubscriptionValidationDataUtil.fromSubscriptionPolicyToSubscriptionPolicyListDTO(model)).build();
} else {
return Response.ok().entity(SubscriptionValidationDataUtil.fromSubscriptionPolicyToSubscriptionPolicyListDTO(subscriptionValidationDAO.getAllSubscriptionPolicies(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.fromSubscriptionPolicyToSubscriptionPolicyListDTO(subscriptionValidationDAO.getAllSubscriptionPolicies())).build();
}
use of org.wso2.carbon.apimgt.impl.dao.SubscriptionValidationDAO in project carbon-apimgt by wso2.
the class ApiPoliciesApiServiceImpl method apiPoliciesGet.
public Response apiPoliciesGet(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.fromApiPolicyToApiPolicyListDTO(subscriptionValidationDAO.getAllApiPolicies())).build();
} else if (StringUtils.isNotEmpty(policyName)) {
List<APIPolicy> model = new ArrayList<>();
APIPolicy apiPolicy = subscriptionValidationDAO.getApiPolicyByNameForTenant(policyName, xWSO2Tenant);
if (apiPolicy != null) {
model.add(apiPolicy);
}
return Response.ok().entity(SubscriptionValidationDataUtil.fromApiPolicyToApiPolicyListDTO(model)).build();
} else {
return Response.ok().entity(SubscriptionValidationDataUtil.fromApiPolicyToApiPolicyListDTO(subscriptionValidationDAO.getAllApiPolicies(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.fromApiPolicyToApiPolicyListDTO(subscriptionValidationDAO.getAllApiPolicies())).build();
}
use of org.wso2.carbon.apimgt.impl.dao.SubscriptionValidationDAO in project carbon-apimgt by wso2.
the class ApisApiServiceImpl method apisGet.
@Override
public Response apisGet(String xWSO2Tenant, String apiId, String context, String version, String gatewayLabel, String accept, MessageContext messageContext) throws APIManagementException {
SubscriptionValidationDAO subscriptionValidationDAO = new SubscriptionValidationDAO();
xWSO2Tenant = SubscriptionValidationDataUtil.validateTenantDomain(xWSO2Tenant, messageContext);
APIListDTO apiListDTO;
if (StringUtils.isNotEmpty(gatewayLabel)) {
if (StringUtils.isNotEmpty(apiId)) {
API api = subscriptionValidationDAO.getApiByUUID(apiId, gatewayLabel, xWSO2Tenant);
apiListDTO = SubscriptionValidationDataUtil.fromAPIToAPIListDTO(api);
} else if (StringUtils.isNotEmpty(context) && StringUtils.isNotEmpty(version)) {
if (!context.startsWith("/t/" + xWSO2Tenant.toLowerCase())) {
apiListDTO = new APIListDTO();
}
API api = subscriptionValidationDAO.getAPIByContextAndVersion(context, version, gatewayLabel);
apiListDTO = SubscriptionValidationDataUtil.fromAPIToAPIListDTO(api);
} else {
// Retrieve API Detail according to Gateway label.
apiListDTO = SubscriptionValidationDataUtil.fromAPIListToAPIListDTO(subscriptionValidationDAO.getAllApis(xWSO2Tenant, gatewayLabel));
}
} else {
apiListDTO = SubscriptionValidationDataUtil.fromAPIListToAPIListDTO(subscriptionValidationDAO.getAllApis(xWSO2Tenant));
}
if (APIConstants.APPLICATION_GZIP.equals(accept)) {
try {
File zippedResponse = GZIPUtils.constructZippedResponse(apiListDTO);
return Response.ok().entity(zippedResponse).header("Content-Disposition", "attachment").header("Content-Encoding", "gzip").build();
} catch (APIManagementException e) {
RestApiUtil.handleInternalServerError(e.getMessage(), e, log);
}
} else {
return Response.ok().entity(apiListDTO).build();
}
return null;
}
Aggregations