use of org.wso2.carbon.apimgt.keymgt.model.SubscriptionDataStore in project carbon-apimgt by wso2.
the class ApplicationsApiServiceImpl method applicationsGet.
public Response applicationsGet(String name, String uuid, String tenantDomain, MessageContext messageContext) {
tenantDomain = GatewayUtils.validateTenantDomain(tenantDomain, messageContext);
SubscriptionDataStore subscriptionDataStore = SubscriptionDataHolder.getInstance().getTenantSubscriptionStore(tenantDomain);
if (subscriptionDataStore == null) {
log.warn("Subscription data store is not initialized for " + tenantDomain);
return Response.status(Response.Status.NOT_FOUND).build();
}
List<Application> applicationList;
if (StringUtils.isNotEmpty(name)) {
applicationList = subscriptionDataStore.getApplicationsByName(name);
} else if (StringUtils.isNotEmpty(uuid)) {
applicationList = new ArrayList<>();
if (subscriptionDataStore.getApplicationByUUID(uuid) != null) {
applicationList.add(subscriptionDataStore.getApplicationByUUID(uuid));
}
} else {
return Response.status(Response.Status.BAD_REQUEST).entity(new ErrorDTO().moreInfo("required parameters " + "are missing")).build();
}
if (applicationList == null) {
return Response.status(Response.Status.NOT_FOUND).build();
}
ApplicationListDTO applicationListDTO = GatewayUtils.generateApplicationList(applicationList, subscriptionDataStore);
return Response.ok().entity(applicationListDTO).build();
}
use of org.wso2.carbon.apimgt.keymgt.model.SubscriptionDataStore in project carbon-apimgt by wso2.
the class GatewayUtils method generateApplicationList.
public static ApplicationListDTO generateApplicationList(List<Application> applicationList, SubscriptionDataStore subscriptionDataStore) {
ApplicationListDTO applicationListDTO = new ApplicationListDTO();
List<ApplicationInfoDTO> applicationInfoDTOList = new ArrayList<>();
for (Application application : applicationList) {
ApplicationInfoDTO applicationInfoDTO = new ApplicationInfoDTO().id(application.getId()).name(application.getName()).policy(application.getPolicy()).attributes(application.getAttributes()).subName(application.getSubName()).uuid(application.getUUID()).tokenType(application.getTokenType()).keys(convertToApplicationKeyMapping(application.getId(), subscriptionDataStore));
applicationInfoDTOList.add(applicationInfoDTO);
}
applicationListDTO.setList(applicationInfoDTOList);
applicationListDTO.setCount(applicationInfoDTOList.size());
return applicationListDTO;
}
use of org.wso2.carbon.apimgt.keymgt.model.SubscriptionDataStore in project carbon-apimgt by wso2.
the class GatewayUtils method generateAPIInfo.
public static APIInfoDTO generateAPIInfo(API api, List<Subscription> subscriptionsByAPIId, SubscriptionDataStore subscriptionDataStore) {
APIInfoDTO apiInfoDTO = new APIInfoDTO();
apiInfoDTO.setApiId(api.getApiId());
apiInfoDTO.setApiType(api.getApiType());
apiInfoDTO.setName(api.getApiName());
apiInfoDTO.setApiUUID(api.getUuid());
apiInfoDTO.setContext(api.getContext());
apiInfoDTO.setIsDefaultVersion(api.isDefaultVersion());
apiInfoDTO.setPolicy(api.getApiTier());
apiInfoDTO.setProvider(api.getApiProvider());
apiInfoDTO.setUrlMappings(convertUriTemplate(api.getResources()));
apiInfoDTO.setSubscripitons(convertSubscriptionsToSubscriptionInfo(subscriptionsByAPIId, subscriptionDataStore));
return apiInfoDTO;
}
use of org.wso2.carbon.apimgt.keymgt.model.SubscriptionDataStore in project carbon-apimgt by wso2.
the class GatewayUtils method convertSubscriptionsToSubscriptionInfo.
private static List<SubscriptionInfoDTO> convertSubscriptionsToSubscriptionInfo(List<Subscription> subscriptions, SubscriptionDataStore subscriptionDataStore) {
List<SubscriptionInfoDTO> subscriptionInfoDTOList = new ArrayList<>();
for (Subscription subscription : subscriptions) {
SubscriptionInfoDTO subscriptionInfoDTO = new SubscriptionInfoDTO();
subscriptionInfoDTO.setStatus(subscription.getSubscriptionState());
subscriptionInfoDTO.setSubscriptionUUID(subscription.getSubscriptionUUId());
subscriptionInfoDTO.setSubscriptionPolicy(subscription.getPolicyId());
subscriptionInfoDTO.setApplication(convertToApplicationDto(subscription.getAppId(), subscriptionDataStore));
subscriptionInfoDTOList.add(subscriptionInfoDTO);
}
return subscriptionInfoDTOList;
}
use of org.wso2.carbon.apimgt.keymgt.model.SubscriptionDataStore in project carbon-apimgt by wso2.
the class ApisApiServiceImpl method apisApiIdGet.
public Response apisApiIdGet(String apiId, String tenantDomain, MessageContext messageContext) {
tenantDomain = GatewayUtils.validateTenantDomain(tenantDomain, messageContext);
SubscriptionDataStore subscriptionDataStore = SubscriptionDataHolder.getInstance().getTenantSubscriptionStore(tenantDomain);
if (subscriptionDataStore == null) {
log.warn("Subscription data store is not initialized for " + tenantDomain);
return Response.status(Response.Status.NOT_FOUND).build();
}
API api;
if (StringUtils.isNotEmpty(apiId)) {
api = subscriptionDataStore.getAPIByUUID(apiId);
} else {
return Response.status(Response.Status.BAD_REQUEST).entity(new ErrorDTO().moreInfo("required parameters " + "are missing")).build();
}
if (api == null) {
return Response.status(Response.Status.NOT_FOUND).build();
}
List<Subscription> subscriptionsByAPIId = subscriptionDataStore.getSubscriptionsByAPIId(api.getApiId());
APIInfoDTO apiInfoDTO = GatewayUtils.generateAPIInfo(api, subscriptionsByAPIId, subscriptionDataStore);
return Response.ok().entity(apiInfoDTO).build();
}
Aggregations